mirror of
https://github.com/block/buzz.git
synced 2026-10-29 13:31:44 +00:00
Merge main and reconcile owner deletion migration assertions
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -1522,7 +1522,7 @@ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS $$
|
||||
'community_deletion_requests', 'community_deletion_approvals',
|
||||
'community_deletion_checkpoints', 'community_serving_write_leases',
|
||||
'community_deletion_executor_heartbeats', 'product_feedback',
|
||||
'rate_limit_violations'
|
||||
'rate_limit_violations', 'operator_listener_outbox'
|
||||
]::TEXT[])
|
||||
$$;
|
||||
|
||||
@@ -1906,6 +1906,51 @@ CREATE INDEX idx_relay_admin_outbox_pending
|
||||
INSERT INTO _operator_global_tables (table_name, reason) VALUES
|
||||
('relay_admin_outbox', 'deployment-global enforcement artifact delivery queue');
|
||||
|
||||
-- ── Operator-listener mention delivery ──────────────────────────────────────
|
||||
-- Listener registrations are deployment-global. The outbox records community
|
||||
-- provenance for the event, but is intentionally not tenant-owned.
|
||||
|
||||
CREATE TABLE operator_listener_pubkeys (
|
||||
listener_pubkey BYTEA NOT NULL CHECK (length(listener_pubkey) = 32),
|
||||
target_pubkey BYTEA NOT NULL CHECK (length(target_pubkey) = 32),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (listener_pubkey, target_pubkey)
|
||||
);
|
||||
CREATE INDEX operator_listener_pubkeys_target
|
||||
ON operator_listener_pubkeys (target_pubkey, listener_pubkey);
|
||||
CREATE INDEX operator_listener_pubkeys_created_at
|
||||
ON operator_listener_pubkeys (created_at);
|
||||
|
||||
CREATE TABLE operator_listener_outbox (
|
||||
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
listener_pubkey BYTEA NOT NULL CHECK (length(listener_pubkey) = 32),
|
||||
target_pubkey BYTEA NOT NULL CHECK (length(target_pubkey) = 32),
|
||||
community_id UUID NOT NULL,
|
||||
event_id BYTEA NOT NULL CHECK (length(event_id) = 32),
|
||||
event_kind INTEGER NOT NULL,
|
||||
event_created_at TIMESTAMPTZ NOT NULL,
|
||||
state TEXT NOT NULL DEFAULT 'pending'
|
||||
CHECK (state IN ('pending', 'sending')),
|
||||
attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0),
|
||||
next_attempt_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
lease_until TIMESTAMPTZ,
|
||||
claim_id UUID,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (listener_pubkey, target_pubkey, community_id, event_id)
|
||||
);
|
||||
CREATE INDEX operator_listener_outbox_due
|
||||
ON operator_listener_outbox (next_attempt_at, created_at, id)
|
||||
WHERE state = 'pending';
|
||||
CREATE INDEX operator_listener_outbox_recovery
|
||||
ON operator_listener_outbox (lease_until, created_at, id)
|
||||
WHERE state = 'sending';
|
||||
CREATE INDEX operator_listener_outbox_created_at
|
||||
ON operator_listener_outbox (created_at);
|
||||
|
||||
INSERT INTO _operator_global_tables (table_name, reason) VALUES
|
||||
('operator_listener_pubkeys', 'deployment-global target registrations for operator listeners'),
|
||||
('operator_listener_outbox', 'deployment-global mention delivery queue; community_id is event provenance');
|
||||
|
||||
-- ── Relay operator audit (append-only roster mutation trail) ─────────────────
|
||||
-- One row per PUT/DELETE /operators/{pubkey} mutation. The roster is the
|
||||
-- deployment-wide root of trust and its mutations overwrite/remove in place;
|
||||
|
||||
Reference in New Issue
Block a user