mirror of
https://github.com/block/buzz.git
synced 2026-10-27 20:41:57 +00:00
Removes the dead relay-side authority ledger introduced by migrations 0041 and 0042, and the dead `require_attested_key` verifier knob from `buzz-auth`. Both are unreachable by design under NIP-FI spec v2 (#7214, squash `d4420eb47`), which makes OSS Buzz stateless for identity: the relay neither stores nor verifies an authority chain. ## What changes **`migrations/0044_drop_nip_fi_ledger.sql`** Drops all fifteen NIP-FI ledger tables and their trigger functions using `CASCADE` to resolve the circular deferred FK between `identity_bindings` and `identity_lifecycle_history`. Drops proceed in FK dependency order: selectors → history/bindings → enrollment_policies/receipts → parallel drop of auth tables. Restores `community_write_fence_excluded_table` to its pre-0041 body (removes NIP-FI table names from the exclusion array). **`schema/schema.sql`** Removes the NIP-FI section (~1885 lines of tables, functions, and triggers) and updates `community_write_fence_excluded_table` to match. **`crates/buzz-db/src/runtime/migration.rs`** - Updates the `embedded_migrator_contains_consolidated_initial_schema` sanity check: count 43→44, adds 0044 assertion block (verifies `DROP TABLE` statements and absence of NIP-FI names from `schema.sql`). - Removes ~2580 lines of NIP-FI Postgres integration tests (all `#[tokio::test] #[ignore = "requires Postgres"]` from the 0041/0042 behavioral coverage). - Removes the `extract_excluded_table_array` drift check (0042 body no longer matches `schema.sql` by design). - Adds `migration_0044_drops_populated_nip_fi_ledger_cleanly`: runs migrations to 0042, seeds rows in `authorization_operation_receipts` and `authorization_invalidation_domains`, then runs to 0044 and verifies all fifteen NIP-FI tables are absent. **`crates/buzz-auth/src/nip_fi/config.rs`** Removes `require_attested_key: bool` from `IssuerPolicy` — field, constructor parameter, accessor, and its contribution to `derive_assertion_policy_id`. **`crates/buzz-auth/src/nip_fi/verifier.rs`** `parse_nostr_pubkey_claim` no longer takes a `policy` parameter. The `None` (absent claim) arm now returns `Err(VerifierError::ClaimRejected)` unconditionally instead of conditionally on `policy.require_attested_key()`. **`crates/buzz-auth/src/nip_fi/verifier/tests.rs`** - Removes `missing_nostr_pubkey_denies_under_attested_key_policy` (the sole `require_attested_key: true` call site). - Removes `false,` from all eleven `IssuerPolicy::new` call sites. - Injects `nostr_pubkey` by default in `mint_signed_by` (spec v2 requires it unconditionally). - Updates `valid_access_token_verifies` to assert `asserted_key().is_some()`. **`crates/buzz-auth/src/nip_fi/startup/tests.rs` + `jwks/tests.rs`** Removes `false,` from all `IssuerPolicy::new` call sites and adds `nostr_pubkey` to all token-minting helpers. ## Verification - Fresh-DB migration run to head: all migrations apply cleanly in sequence. - Populated-0041/0042-DB migration through 0044: seeds rows in live NIP-FI tables, verifies all fifteen are dropped without error. Closes the dead-code inventory item from the spec-v2 cleanup plan (channel `48374f48`). Follows #7214. --------- Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
70 lines
4.0 KiB
PL/PgSQL
70 lines
4.0 KiB
PL/PgSQL
-- Remove the Phase-A NIP-FI relay-side authority ledger (migrations 0041 and
|
|
-- 0042). Will+Tyler resolved 2026-09-01: OSS Buzz is stateless for identity
|
|
-- ("Buzz speaks Nostr, nothing else"). The merged NIP-FI spec v2 (PR #7214,
|
|
-- squash d4420eb47) requires the nostr_pubkey claim + NIP-42 proof
|
|
-- unconditionally; the durable ledger tables are dead code.
|
|
--
|
|
-- CASCADE handles the circular deferred FK between identity_bindings and
|
|
-- identity_lifecycle_history, and dispenses with strict drop ordering.
|
|
|
|
-- ── 0042 tables ─────────────────────────────────────────────────────────────
|
|
DROP TABLE authorization_operation_version_deltas CASCADE;
|
|
DROP TABLE authorization_operation_version_delta_manifests CASCADE;
|
|
DROP TABLE authorization_authentication_denial_attempts CASCADE;
|
|
DROP TABLE authorization_admission_results CASCADE;
|
|
DROP TABLE authorization_events CASCADE;
|
|
DROP TABLE protected_object_authority CASCADE;
|
|
DROP TABLE authorization_authority_epochs CASCADE;
|
|
DROP TABLE authorization_invalidation_floors CASCADE;
|
|
DROP TABLE authorization_invalidation_domains CASCADE;
|
|
DROP TABLE authorization_event_capacity CASCADE;
|
|
|
|
-- ── 0041 tables ─────────────────────────────────────────────────────────────
|
|
-- Circular deferred FK: identity_bindings ↔ identity_lifecycle_history.
|
|
-- DROP TABLE with CASCADE resolves it without a two-step ALTER/DROP.
|
|
DROP TABLE identity_lifecycle_selectors CASCADE;
|
|
DROP TABLE identity_lifecycle_history CASCADE;
|
|
DROP TABLE identity_bindings CASCADE;
|
|
DROP TABLE identity_enrollment_policies CASCADE;
|
|
DROP TABLE authorization_operation_receipts CASCADE;
|
|
|
|
-- ── Shared functions (0041 introduced, 0042 widened) ────────────────────────
|
|
-- Triggers were dropped with their tables above; drop functions separately.
|
|
DROP FUNCTION identity_enrollment_policy_revision_guard_v1;
|
|
DROP FUNCTION nip_fi_reject_row_mutation_v1;
|
|
DROP FUNCTION nip_fi_reject_truncate_v1;
|
|
DROP FUNCTION identity_lifecycle_lock_coordinates_v1;
|
|
DROP FUNCTION identity_bindings_insert_guard_v1;
|
|
DROP FUNCTION identity_bindings_transition_guard_v1;
|
|
DROP FUNCTION identity_lifecycle_history_insert_guard_v1;
|
|
DROP FUNCTION identity_binding_history_semantics_guard_v1;
|
|
DROP FUNCTION identity_binding_birth_eligibility_guard_v1;
|
|
DROP FUNCTION authorization_operation_receipt_history_guard_v1;
|
|
DROP FUNCTION identity_lifecycle_selector_insert_guard_v1;
|
|
DROP FUNCTION identity_lifecycle_selector_history_guard_v1;
|
|
DROP FUNCTION identity_lifecycle_transition_integrity_guard_v1;
|
|
DROP FUNCTION authorization_event_capacity_before_insert_v1;
|
|
DROP FUNCTION authorization_invalidation_domain_guard_v1;
|
|
DROP FUNCTION authorization_invalidation_floor_guard_v1;
|
|
DROP FUNCTION authorization_authority_epoch_guard_v1;
|
|
DROP FUNCTION authorization_event_capacity_guard_v1;
|
|
DROP FUNCTION protected_object_authority_guard_v1;
|
|
DROP FUNCTION authorization_denial_attempt_guard_v1;
|
|
DROP FUNCTION authorization_operation_version_delta_cardinality_guard_v1;
|
|
DROP FUNCTION authorization_admission_result_guard_v1;
|
|
DROP FUNCTION authorization_operation_receipt_event_guard_v1;
|
|
|
|
-- ── Restore community_write_fence_excluded_table to its pre-0041 body ───────
|
|
-- 0041 and 0042 each widened this function via CREATE OR REPLACE to exempt
|
|
-- the NIP-FI ledger relations from the community write fence and deletion
|
|
-- catalog. With those tables gone, revert to migration 0030's body.
|
|
CREATE OR REPLACE FUNCTION community_write_fence_excluded_table(target NAME) RETURNS BOOLEAN
|
|
LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS $$
|
|
SELECT target::TEXT = ANY (ARRAY[
|
|
'community_deletion_requests', 'community_deletion_approvals',
|
|
'community_deletion_checkpoints', 'community_serving_write_leases',
|
|
'community_deletion_executor_heartbeats', 'product_feedback',
|
|
'rate_limit_violations'
|
|
]::TEXT[])
|
|
$$;
|