mirror of
https://github.com/block/buzz.git
synced 2026-11-11 20:01:09 +00:00
fix(nip-fi): renumber migrations 0043→0044 and 0044→0045
main merged 0043_push_gateway_dogfood_profile.sql while this branch was in review, colliding with the NIP-FI 0043_nip_fi_proof_replay_claims.sql introduced by this PR. Rename: 0043_nip_fi_proof_replay_claims.sql → 0044_nip_fi_proof_replay_claims.sql 0044_nip_fi_proof_claim_owner.sql → 0045_nip_fi_proof_claim_owner.sql Update all test assertions and doc comments that referred to migration 0043 or 0044 by the old NIP-FI numbering. No behavioural change. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
@@ -699,7 +699,7 @@ mod postgres_tests {
|
||||
let mut migrations: Vec<_> = MIGRATOR.iter().collect();
|
||||
migrations.sort_by_key(|migration| migration.version);
|
||||
|
||||
assert_eq!(migrations.len(), 44);
|
||||
assert_eq!(migrations.len(), 45);
|
||||
assert_eq!(migrations[0].version, 1);
|
||||
assert_eq!(&*migrations[0].description, "initial schema");
|
||||
assert!(migrations[0]
|
||||
@@ -1264,9 +1264,9 @@ mod postgres_tests {
|
||||
|
||||
// The consolidated desired-state exclusion function must byte-match the
|
||||
// most recent CREATE OR REPLACE in the migration sequence. Migration
|
||||
// 0042 defines the initial NIP-FI exclusion list; migration 0043
|
||||
// 0042 defines the initial NIP-FI exclusion list; migration 0044
|
||||
// extends it with `nip_fi_proof_replay_claims`. schema.sql must
|
||||
// therefore match 0043's definition, not 0042's.
|
||||
// therefore match 0044's definition, not 0042's.
|
||||
fn extract_excluded_table_array(sql: &str) -> &str {
|
||||
let anchor = "community_write_fence_excluded_table(target NAME) RETURNS BOOLEAN";
|
||||
let start = sql.find(anchor).expect("exclusion function definition");
|
||||
@@ -1280,27 +1280,27 @@ mod postgres_tests {
|
||||
|
||||
// NIP-FI proof replay claims (migration 0043): idempotency ledger for
|
||||
// admission proofs. Never fence-attached (immutable ledger relation).
|
||||
// 0043 also issues a CREATE OR REPLACE for community_write_fence_excluded_table
|
||||
// 0044 also issues a CREATE OR REPLACE for community_write_fence_excluded_table
|
||||
// to add 'nip_fi_proof_replay_claims'; that extended definition is the
|
||||
// one schema.sql must track.
|
||||
assert_eq!(migrations[42].version, 43);
|
||||
assert_eq!(migrations[43].version, 44);
|
||||
let replay_claims = migrations[42].sql.as_str();
|
||||
assert!(replay_claims.contains("CREATE TABLE nip_fi_proof_replay_claims"));
|
||||
assert!(
|
||||
replay_claims
|
||||
.contains("CREATE OR REPLACE FUNCTION community_write_fence_excluded_table"),
|
||||
"migration 0043 must update the exclusion function"
|
||||
"migration 0044 must update the exclusion function"
|
||||
);
|
||||
assert_eq!(
|
||||
extract_excluded_table_array(replay_claims),
|
||||
extract_excluded_table_array(desired_schema),
|
||||
"schema.sql exclusion list drifted from migration 0043"
|
||||
"schema.sql exclusion list drifted from migration 0044"
|
||||
);
|
||||
|
||||
// Brownfield relay databases created through SQLx still carry the
|
||||
// production/sandbox constraint from 0015. Converge them to the same
|
||||
// dogfood-only authority declared by the desired-state schema.
|
||||
assert_eq!(migrations[42].version, 43);
|
||||
assert_eq!(migrations[43].version, 44);
|
||||
let dogfood_profile = migrations[42].sql.as_str();
|
||||
assert!(dogfood_profile.contains("DELETE FROM push_gateway_delegations"));
|
||||
assert!(dogfood_profile.contains("DELETE FROM push_gateway_installations"));
|
||||
|
||||
@@ -1254,7 +1254,7 @@ async fn commit_admission_body(
|
||||
// determine if it is the same connection (same-conn reuse, allowed)
|
||||
// or a different connection (cross-conn replay, ProofReplayed).
|
||||
//
|
||||
// The appended-only immutability trigger from migration 0043 holds:
|
||||
// The appended-only immutability trigger from migration 0044 holds:
|
||||
// once committed, connection_id cannot change.
|
||||
{
|
||||
let retained_until = upstream_deadline;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
--
|
||||
-- A claim is inserted only during final admission (never at AUTH), after
|
||||
-- all other authority mutations succeed. The append-only immutability
|
||||
-- trigger from migration 0043 continues to hold: once a row is committed,
|
||||
-- trigger from migration 0044 continues to hold: once a row is committed,
|
||||
-- connection_id cannot be changed.
|
||||
--
|
||||
-- This column enables the amended Design C ownership protocol:
|
||||
@@ -17,7 +17,7 @@
|
||||
-- 3. Different conn_id → ProofReplayed (cross-connection reuse)
|
||||
-- 4. No row → proceed; INSERT this row at step 9 of commit_admission_body
|
||||
|
||||
-- Existing 0043-shape rows (if any) receive a synthetic owner UUID matching no
|
||||
-- Existing 0044-shape rows (if any) receive a synthetic owner UUID matching no
|
||||
-- live connection. This is deliberate fail-closed: replays of pre-0044 legacy
|
||||
-- proofs from any connection are rejected as cross-connection reuse (the stored
|
||||
-- sentinel never matches a live conn_id), preventing any legacy claim from being
|
||||
Reference in New Issue
Block a user