mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
Reverts #9650 (squash commit `eebf62b6`), except for migration `0097` and the channel artifact sync fences it added. Community scope adds a relay access gate based on community admission rather than channel membership, a new relay-admin command kind (`9034`) and an operator-run key transition. Its design and NIP-AR text need relay maintainer review before they ship. Two integration gaps also remain: - Media download authorization looks up references only in `events`, so an attachment referenced only by a community artifact is unreadable when media-read enforcement is on. - User erasure retires a community head in the database without signaling live syncs, so members who are already syncing keep the erased copy. The feature can return as a new PR once those are resolved. ## Kept from #9650 - **Migration `0097`, byte for byte.** Published images already include it, and databases that auto-migrated have recorded it. Dropping it would stop those relays from starting. It only adds columns and indexes that the channel code ignores. The declared schema matches that expanded shape and keeps the `(community_id, artifact_id)` primary key, so the operator key transition no longer exists. - **Channel artifact sync fences.** Snapshot and live sends check for a pending resync and for connection cancellation under the queue lock. A reader who loses access, or whose content is redacted, while a frame is in flight therefore receives no further payload. Handler-backed tests cover a resync recorded while a snapshot payload waits for queue room and one recorded after a live head read. ## Compatibility This revert supports databases that applied only migration `0097`, which is all that auto-migration runs. A database that ran #9650's operator contract script, or was bootstrapped from #9650's declared schema, has no `(community_id, artifact_id)` key, so channel artifact writes fail there. Before deploying to such a database, check that `artifact_heads_pkey` is on `(community_id, artifact_id)` and that `artifact_heads` has no rows with `scope = 'community'`; if either check fails, it needs a separate recovery step. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
-- OPERATOR CONTRACT, never an automatic migration. Read
|
||||
-- docs/community-artifact-rollout.md before running this file.
|
||||
-- The calling session must explicitly attest that all serving backends,
|
||||
-- deletion executors and operator tools run the compatible audience bridge:
|
||||
-- SET buzz.community_artifact_contract_ready = 'all-backends-enforce-community-audience';
|
||||
BEGIN;
|
||||
SET LOCAL lock_timeout = '5s';
|
||||
SET LOCAL statement_timeout = '30s';
|
||||
DO $$
|
||||
DECLARE
|
||||
current_key text[];
|
||||
BEGIN
|
||||
IF current_setting('buzz.community_artifact_contract_ready', true)
|
||||
IS DISTINCT FROM 'all-backends-enforce-community-audience' THEN
|
||||
RAISE EXCEPTION 'community artifact contract requires explicit fleet compatibility attestation';
|
||||
END IF;
|
||||
SELECT array_agg(a.attname::text ORDER BY k.ord) INTO current_key
|
||||
FROM pg_index i
|
||||
CROSS JOIN LATERAL unnest(i.indkey) WITH ORDINALITY k(num,ord)
|
||||
JOIN pg_attribute a ON a.attrelid=i.indrelid AND a.attnum=k.num
|
||||
WHERE i.indrelid='artifact_heads'::regclass AND i.indisprimary
|
||||
AND i.indisvalid AND i.indisready AND i.indpred IS NULL AND i.indexprs IS NULL;
|
||||
IF current_key = ARRAY['community_id','scope','artifact_id'] THEN
|
||||
RETURN; -- Already contracted; safe to rerun without touching payloads.
|
||||
END IF;
|
||||
IF current_key IS DISTINCT FROM ARRAY['community_id','artifact_id'] THEN
|
||||
RAISE EXCEPTION 'unexpected artifact head primary key';
|
||||
END IF;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_index i
|
||||
WHERE i.indexrelid=to_regclass('artifact_heads_scoped_identity')
|
||||
AND i.indrelid='artifact_heads'::regclass AND i.indisunique
|
||||
AND i.indisvalid AND i.indisready AND i.indpred IS NULL AND i.indexprs IS NULL
|
||||
AND pg_get_indexdef(i.indexrelid) = 'CREATE UNIQUE INDEX artifact_heads_scoped_identity ON public.artifact_heads USING btree (community_id, scope, artifact_id)'
|
||||
) THEN
|
||||
RAISE EXCEPTION 'missing or incompatible expanded artifact identity index';
|
||||
END IF;
|
||||
-- Atomic: no interval without a primary key. All key columns are already
|
||||
-- NOT NULL; attaching the prebuilt index needs no table rewrite or backfill.
|
||||
ALTER TABLE artifact_heads DROP CONSTRAINT artifact_heads_pkey,
|
||||
ADD CONSTRAINT artifact_heads_pkey PRIMARY KEY USING INDEX artifact_heads_scoped_identity;
|
||||
END $$;
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user