Skip to content

Retire the 0032 roster trigger in migration 0095 - #8696

Merged
TheSentinel454 merged 2 commits into
mainfrom
larry/retire-roster-trigger-migration
Nov 17, 2026
Merged

TheSentinel454 merged 2 commits into
mainfrom
larry/retire-roster-trigger-migration

Conversation

@loganj

@loganj loganj commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Migration 0095 drops the 0032 channel roster trigger (trg_events_guard_channel_roster_snapshot) and its function (guard_channel_roster_snapshot()).

The trigger repeats a check that the relay already does in Rust. Every kind:39002 roster writer checks the roster against the channel's membership before it saves it (#8316). Since #8611, no relay requires the trigger at startup. This PR is the last step of the trigger retirement sequence in docs/database.md.

This PR was split out of #8494 so the migration can roll out by itself. A relay from this PR does not change how it stores or publishes roles, and it has no new startup check. It serves correctly whether or not 0095 has run. #8494 stacks on this PR and must not merge until 0095 has run in every environment.

Details

Rollout

Required stop: the stop build in docs/trigger-retirement-deployment.md (a relay build at or after 68785206, the merge of #8325). That build contains #8316 (the app-side roster check) and #8611 (no startup trigger check), so it covers 0095 too. relay-v0.3.0 contains #8316 and #8611 but not #8325, so it is no longer enough on its own: any build with 0095 also has 0089–0091. Without the stop, an untagged main build between 0032 and #8611 refuses to start once the trigger is gone, and a relay without #8316 can save stale kind:39002 snapshots (docs/database.md Rule 5).

Merge gate. Every push to main publishes relay :main images, and the Helm chart defaults to migrate.autoMigrate=true. Do not merge this PR until the stop build or later runs on every serving and rollback target. That is the same gate #8326 had for 0089–0091.

After that, either way works:

  • With autoMigrate=true, the first relay from this PR applies 0095 at startup.
  • With autoMigrate=false, run buzz-admin migrate when convenient. Relays from this PR serve with or without 0095.

As with every new migration, an older binary with auto-migration on refuses a database that has 0095 (sqlx VersionMissing). A rollback past this release needs auto-migration off (docs/database.md).

What happens next

#8494 computes the member/bot label at read time. The 0032 trigger compares labels with the stored role exactly, so it would refuse those rosters. #8494 adds a startup check that refuses to serve while the trigger is installed. Merge it only after 0095 has run everywhere.

Testing

  • migration_0095_retires_the_roster_trigger: on a database migrated through 0094, the trigger and function are installed. After the remaining migrations, both are gone, and a raw kind:39002 insert that does not match membership is accepted. It fails if 0095 does not drop them.
  • embedded_migrator_contains_consolidated_initial_schema pins 95 migrations and the 0095 statements, and checks that the desired-state schema no longer installs the function.
  • migration_schema_desired_pgschema_reconcile_matches_populated_upgrade: its fixture drops each retired parent trigger before pgschema runs (pgschema drops partition copies before the parent, which PostgreSQL refuses with 2BP01). It now drops the roster trigger too.
  • Locally at this head: cargo check, cargo fmt --check, and 245/245 buzz-db unit tests pass; 760/764 buzz-db Postgres tests pass. The four event_follow_up_contract tests fail the same way on main locally and pass in CI. CI runs clippy and the full PostgreSQL lane.

🤖 Generated with Claude Code

@loganj
loganj requested a review from a team as a code owner October 29, 2026 18:01
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 051dd2d7aaae2cb6ce288cf55d571e9790fc38c2...ab67806b8cf7d05483880e3bf9455935dfb59b5b
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings in the authorized PR range. The application roster checks retain the retired trigger’s validation and locking behavior, and the documented stop build includes the required compatibility changes.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds, tests, and migrations were not executed.

Generated by Codex Security Review |
Requested by: @loganj |
Workflow run

@TheSentinel454 TheSentinel454 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Approving at d835556. Splitting the drop out of #8494 means the 0076 step can be rolled out and judged on its own. Every kind:39002 writer still has the application roster check, and the migration test fails if 0076 stops dropping the trigger. The SQL is identical to the 0074 we ran yesterday against a local relay, where a #8611 relay started both with and without the trigger. The one red PostgreSQL test (session_statement_timeouts_bound_writer_and_reader_sessions, PoolTimedOut) does not touch this change, and it passed in #8494, which contains all of this PR. As the PR says, merge only after #8611 runs in every environment.

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude's code review agent — APPROVE at exact head d835556200dce52c0b50c6d1c24816c59fd0ca91 (base 3dbc95c3f668547e501c7d5f306d85ca5dcd055e).

I reviewed this as the integrated A-Team verdict, incorporating the product/operator lane and the systems/integration lane. No unresolved author-actionable defect was found.

What I verified:

  • Freshness/review state: GitHub PR head and local review head both stayed at d835556200dce52c0b50c6d1c24816c59fd0ca91; authenticated reviewer and PR author are different GitHub identities; there are no unresolved review threads; required checks are green, with Mobile/Web skipped by path filter.
  • Migration scope: migrations/0076_retire_channel_roster_trigger.sql only drops trg_events_guard_channel_roster_snapshot and guard_channel_roster_snapshot() with bounded lock_timeout / statement_timeout; no data rewrite or backfill is introduced.
  • Desired-state convergence: the schema no longer installs the retired roster trigger/function, while the remaining events floor/write-fence triggers stay intact.
  • Runtime contract: the application-side kind 39002 roster validation remains on the production write seams before event insertion/replacement, including the relay-authored member snapshot path.
  • Regression coverage: the migration/schema tests pin the migration count/statements, desired-state absence, and the post-0076 behavior where raw stale roster inserts are no longer blocked by the retired trigger.

Validation evidence reviewed:

  • GitHub required checks at this head: Rust lint/unit, PostgreSQL tests, Desktop E2E Relay, Backend Integration, Relay E2E, Security, DCO, Desktop RC all green; Mobile/Web skipped by path filter.
  • Local exact-head lane evidence: cargo fmt --check, scripts/test-postgres-test-discovery.sh, cargo test -p buzz-db --lib embedded_migrator_contains_consolidated_initial_schema -- --nocapture, and cargo test -p buzz-db --lib all passed in the lane checkouts. Local Postgres-gated tests were not rerun outside CI.

Important operational gate, not author rework: the PR's documented required stop is still real. The visible relay-v* tags currently top out at relay-v0.2.1, and none contain #8611's merge commit (646ef8abf9bc5ac3e698826b38811033537a4806). Do not merge/deploy 0076 until a relay-v* release containing #8611 is tagged and deployed to every serving and rollback target, and the release notes name that required stop.

Author action: none from this review.
Verification owner: release/merge operator must enforce the #8611 required-stop gate before merge/deploy.

jedwards27
jedwards27 previously approved these changes Oct 30, 2026

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

Verdict: APPROVE

Reviewed: 3dbc95c3f668547e501c7d5f306d85ca5dcd055e..d835556200dce52c0b50c6d1c24816c59fd0ca91 (exact head d835556200dce52c0b50c6d1c24816c59fd0ca91)

Risk: medium-high operational/database risk. The code change is narrow, but it retires a database trigger/function that used to enforce the kind:39002 roster snapshot contract at the database boundary.

Behavior/contracts traced: migration 0076_retire_channel_roster_trigger, desired-state schema convergence, event insert/replaceable writer seams, relay-authored roster snapshot path, PostgreSQL/relay CI evidence, and the PR’s documented rollout prerequisite for #8611.

Findings: no unresolved author-actionable code/product defect.

Integrated review evidence:

  • Product/operator lane found no user-facing or operator-trust defect. The migration documents the required #8611 stop, lock/statement timeout behavior, and drops only trg_events_guard_channel_roster_snapshot plus guard_channel_roster_snapshot() (migrations/0076_retire_channel_roster_trigger.sql:1-20).
  • Systems lane verified desired-state convergence: schema/schema.sql:65-68 no longer includes the roster function, schema/triggers/events.sql:1-12 keeps only the remaining events triggers, and scripts/reconcile-schema-after-pgschema.sql:16-21 no longer carries roster child-trigger cleanup.
  • The app-side roster guard remains on the production write seams before event writes: canonical roster validation in crates/buzz-db/src/store/channel_members.rs:72-152; generic append calls before insert in crates/buzz-db/src/store/event.rs:492 and :1880; replaceable writers guard before delete/insert in crates/buzz-db/src/store/replaceable.rs:120-132, :263-264, and :442-492; relay-authored member snapshots revalidate in the locked writer path in crates/buzz-db/src/store/channel_members.rs:398-456 and :510-526.
  • Test coverage pins the retirement: migration count/statements in crates/buzz-db/src/runtime/migration.rs:779-788, desired-state absence in :1331-1347, and migration_0076_retires_the_roster_trigger in crates/buzz-db/src/store/channel_members.rs:5049-5113 proves pre-0076 trigger presence, post-0076 absence, and raw stale-roster acceptance after retirement.

Author action: none.

Verification owner: release/operator. The PR’s own rollout gate must be enforced before merge/deploy: do not merge/deploy migration 0076 until a relay-v* containing #8611’s merge commit 646ef8abf9bc5ac3e698826b38811033537a4806 is tagged and deployed to every serving and rollback relay target, with release notes naming that required stop. Visible relay-v* tags still topped out at relay-v0.2.1 in the review-room check and did not contain that commit. That is an operational release gate, not author code rework.

Validation: review lanes reported exact-head green required GitHub checks for Rust Lint, Unit Tests, PostgreSQL Tests, Desktop E2E Relay, Backend Integration, Relay E2E, Security, DCO, and Desktop RC, with Mobile/Web skipped by path filter. Local exact-head checks reported by the lanes: cargo fmt --check PASS, scripts/test-postgres-test-discovery.sh PASS, cargo test -p buzz-db --lib embedded_migrator_contains_consolidated_initial_schema -- --nocapture PASS, and cargo test -p buzz-db --lib PASS (182 passed; 642 ignored). Local Postgres-gated tests were not rerun by the lanes; exact-head GitHub PostgreSQL Tests were green.

Manual/native evidence: not applicable; this is a relay/database migration retirement with no Desktop/UI runtime behavior.

Residual risk: rollout ordering is the material remaining risk and is owned by the release/operator gate above.

@jedwards27
jedwards27 dismissed their stale review October 30, 2026 12:58

Agent correction: duplicate exact-head approval submitted after an equivalent approval already existed; dismissing duplicate per review idempotency contract.

@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from d835556 to 33d4fbb Compare October 30, 2026 15:53
@github-actions github-actions Bot added codex-security-review-current The posted Codex security review matches its recorded range. and removed codex-security-review-current The posted Codex security review matches its recorded range. labels Oct 30, 2026
loganj added a commit that referenced this pull request Oct 30, 2026
`bot` has the same permissions as `member`; it only labels a key with a
recorded agent owner. Writers store `member` for both ordinary roles, and
every role read computes the label: `bot` exactly when
users.agent_owner_pubkey is set for the key in that community.

- The app-side roster check treats `member` and `bot` as one role.
- When first AUTH or a v1/v2 invite claim records an agent's owner, the
  relay updates its owner caches and republishes the agent's rosters in
  the background, at most two republishes at a time per process.
- A re-add that changes only member/bot reports the member as already
  present.
- The relay refuses to start while the 0032 roster trigger is installed:
  migration 0079 (#8696) must run first.

This restacks the branch onto #8696 after main took migrations
0076-0078. It replaces these earlier commits:

- Update the owner caches when an invite claim records an agent owner (47458e4)
- Republish an agent's rosters when an invite claim records its owner (35fc447)
- Renumber the roster-trigger retirement to migration 0076 (62290cf)
- test(relay): bind the member/bot re-add report to the kind:9000 path (c1aabfa)
- Treat member and bot as one role when reporting a re-add (d20e11d)
- Drop the one-shot member/bot roster reconcile scan (f8ebee0)
- Refuse to start while the 0032 roster trigger is installed (a4311bb)
- Bound roster republishes and tighten the 0074 rollout (4c2448c)
- test(relay): first AUTH is not held by a contended roster lock (143e4c7)
- Compute the member/bot label at read time and retire the roster trigger (02ccba9)

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0076 Retire the 0032 roster trigger in migration 0079 Oct 30, 2026
@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from 33d4fbb to 64b5dcb Compare October 30, 2026 23:44
@github-actions github-actions Bot added codex-security-review-current The posted Codex security review matches its recorded range. and removed codex-security-review-current The posted Codex security review matches its recorded range. labels Oct 30, 2026
loganj added a commit that referenced this pull request Oct 30, 2026
`bot` has the same permissions as `member`; it only labels a key with a
recorded agent owner. Writers store `member` for both ordinary roles, and
every role read computes the label: `bot` exactly when
users.agent_owner_pubkey is set for the key in that community.

- The app-side roster check treats `member` and `bot` as one role.
- When first AUTH or a v1/v2 invite claim records an agent's owner, the
  relay updates its owner caches and republishes the agent's rosters in
  the background, at most two republishes at a time per process.
- A re-add that changes only member/bot reports the member as already
  present.
- The relay refuses to start while the 0032 roster trigger is installed:
  migration 0079 (#8696) must run first.

This restacks the branch onto #8696 after main took migrations
0076-0078. It replaces these earlier commits:

- Update the owner caches when an invite claim records an agent owner (47458e4)
- Republish an agent's rosters when an invite claim records its owner (35fc447)
- Renumber the roster-trigger retirement to migration 0076 (62290cf)
- test(relay): bind the member/bot re-add report to the kind:9000 path (c1aabfa)
- Treat member and bot as one role when reporting a re-add (d20e11d)
- Drop the one-shot member/bot roster reconcile scan (f8ebee0)
- Refuse to start while the 0032 roster trigger is installed (a4311bb)
- Bound roster republishes and tighten the 0074 rollout (4c2448c)
- test(relay): first AUTH is not held by a contended roster lock (143e4c7)
- Compute the member/bot label at read time and retire the roster trigger (02ccba9)

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from 64b5dcb to ecce12f Compare November 1, 2026 22:58
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 1, 2026
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0079 Retire the 0032 roster trigger in migration 0081 Nov 1, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 1, 2026
loganj added a commit that referenced this pull request Nov 1, 2026
`bot` has the same permissions as `member`; it only labels a key with a
recorded agent owner. Writers store `member` for both ordinary roles, and
every role read computes the label: `bot` exactly when
users.agent_owner_pubkey is set for the key in that community.

- The app-side roster check treats `member` and `bot` as one role.
- When first AUTH or a v1/v2 invite claim records an agent's owner, the
  relay updates its owner caches and republishes the agent's rosters in
  the background, at most two republishes at a time per process.
- A re-add that changes only member/bot reports the member as already
  present.
- The relay refuses to start while the 0032 roster trigger is installed:
  migration 0081 (#8696) must run first.

This restacks the branch onto #8696 after main took migrations
0076-0078. It replaces these earlier commits:

- Update the owner caches when an invite claim records an agent owner (47458e4)
- Republish an agent's rosters when an invite claim records its owner (35fc447)
- Renumber the roster-trigger retirement to migration 0076 (62290cf)
- test(relay): bind the member/bot re-add report to the kind:9000 path (c1aabfa)
- Treat member and bot as one role when reporting a re-add (d20e11d)
- Drop the one-shot member/bot roster reconcile scan (f8ebee0)
- Refuse to start while the 0032 roster trigger is installed (a4311bb)
- Bound roster republishes and tighten the 0074 rollout (4c2448c)
- test(relay): first AUTH is not held by a contended roster lock (143e4c7)
- Compute the member/bot label at read time and retire the roster trigger (02ccba9)

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@presentyourlove

Copy link
Copy Markdown

Hi @loganj,

I have resolved the merge conflicts with the latest main branch:

  1. replaceable.rs: Preserved the new superseded_with_mentions_sql! macro and tests from main (fix(db): drop a superseded head's mention rows with it #8948) while cleanly removing the retired trigger test stale_legacy_roster_cannot_replace_new_locked_snapshot.
  2. Migration Renumbering: Since migration 0081 was allocated to 0081_nip_fi_profile_head_names.sql on main, I renumbered this migration to 0082_retire_channel_roster_trigger.sql and updated the embedded migrator assertion in crates/buzz-db/src/runtime/migration.rs (migrations.len() == 82).

A clean, zero-conflict branch is available at:
https://github.com/presentyourlove/buzz/tree/fix/retire-roster-trigger-8696

You can pull it directly into your branch:

git fetch https://github.com/presentyourlove/buzz.git fix/retire-roster-trigger-8696
git merge --ff-only FETCH_HEAD

jedwards27

This comment was marked as resolved.

@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from ecce12f to c3969f4 Compare November 10, 2026 19:25
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0081 Retire the 0032 roster trigger in migration 0087 Nov 10, 2026
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 16, 2026
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0092 Retire the 0032 roster trigger in migration 0093 Nov 16, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 16, 2026
@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from 9205580 to 70cd5d0 Compare November 17, 2026 18:21
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0093 Retire the 0032 roster trigger in migration 0094 Nov 17, 2026
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 17, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 17, 2026
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
… functions (contract) (#9598)

## Summary

Phase 2 of retiring the two remaining plain SQL functions. Phase 1 moved
their work into the relay:

- #9396 builds the community deletion lock key in Rust
(`deletion::community_deletion_lock_key`, locked with
`hashtextextended($1, 0)`).
- #9397 reads profile names with inline SQL (`PROFILE_NAME_FIELDS` in
`buzz-search`).

No relay at or after #9397's merge (`279a31da`) calls either function.
This PR drops them:

- **Migration 0093** runs `DROP FUNCTION
community_deletion_lock_key(UUID)` and `DROP FUNCTION
profile_name_fields(TEXT)` under a 5s `lock_timeout`, with no `IF
EXISTS` and no `CASCADE`. If anything still depends on a function, the
migration fails instead. Migrations 0029 and 0064 stay frozen. No
database function calls either one any more: 0090 dropped the fence
functions, which were the only SQL callers of the lock key.
- **Desired state:** removes both `schema/functions/` files and their
`schema.sql` includes. Both boot paths stay catalog-equivalent
(`admin_schema_parity_between_desired_state_and_migrations`).
- **Tests:**
- New `migration_0093_drops_plain_sql_functions`. It migrates to 0092,
checks that both functions exist and that serving and deletion catalog
validation pass, then runs 0093 and checks that both functions are gone
and that validation still passes. This covers new code on either side of
the drop.
- The migration listing test pins 0093's statements and that it has no
`CASCADE`.
- `desired_state_catalog_has_no_universal_fence_and_still_boots` now
asserts that both functions are absent.
- Replaces the Rust-vs-SQL lock key parity test with
`community_deletion_lock_key_bytes_are_fixed`, a unit test that maps
fixed UUIDs (nil, max, and one with hex letters) to their exact keys.
Older replicas and the repair-script key in `docs/database.md` build the
same string, so a changed prefix or UUID format must fail a test.
- Removes two relay test-schema wrappers (`bridge.rs`, `ingest.rs`) that
forwarded `community_deletion_lock_key` to `public`. Writers no longer
call it, and the wrapper's `CREATE FUNCTION` would fail once the
function is gone.
- **Docs:** `docs/trigger-retirement-deployment.md` gets a `0093`
section with the required stop.

## Deploy gate

**Required stop:** any relay build at or after `279a31da` (#9397's
merge, which follows #9396). `relay-v0.3.0` does not contain it. A relay
older than that which still serves after 0093 fails every write and
deletion that takes the community deletion lock, with `42883
community_deletion_lock_key(uuid) does not exist`, and its profile name
search fails with `42883 profile_name_fields(text) does not exist`. 0093
takes no table locks and needs no cleanup.

Migration number: #8696 and #9398 also propose `0093`. Whichever lands
second renumbers.

## Review-Proven Rules

- **RPR #2 (every path):** I checked every reference on `main` and at
the stop build `279a31da`. At both, only test code reads either
function: no boot, readiness, catalog or runtime query depends on them.
Serving and deletion catalog validation pass before and after 0093, in
the new test.
- **RPR #3 (falsifiable):** removing the `profile_name_fields` drop from
0093 turns `migration_0093_drops_plain_sql_functions` red.
- **RPR #3 (lock key bytes):** a changed prefix, `.simple()` UUID
formatting, or uppercase formatting each turns
`community_deletion_lock_key_bytes_are_fixed` red.

## What got simpler

Two database functions, their desired-state files, a cross-language
parity test and two test-only SQL wrappers are gone. After this PR, the
only functions left in `schema/functions/` are trigger functions.

## Validation

Blox gate at `95ac71c8`:

- `cargo fmt --all --check`, and `cargo clippy -p buzz-db -p buzz-relay
--all-targets -D warnings`.
- `buzz-db --lib` unit tests: 216/216, including the migration listing
test.
- `buzz-db` Postgres tests (`migration::`, `deletion::`,
`nip_fi_binding::` postgres_tests): 130/130. These include
`migration_0093_drops_plain_sql_functions`,
`admin_schema_parity_between_desired_state_and_migrations` and
`deletion_surface_parity_between_migration_0029_and_schema_sql`.
- `buzz-search` `profile_names*` Postgres tests: 4/4, on a fully
migrated database where `profile_name_fields` no longer exists.
- The two relay tests whose test-schema wrapper this PR removes: 2/2.
- Must-fail check: with the `profile_name_fields` drop removed from
0093, `migration_0093_drops_plain_sql_functions` fails.

Second Blox gate at `e1b5513a` (the lock key vector test):

- `cargo fmt --all --check`, and `cargo clippy -p buzz-db --all-targets
-D warnings`.
- `buzz-db --lib` unit tests: 217/217.
- Must-fail checks: a changed prefix, `.simple()` and uppercase UUID
formatting each fail `community_deletion_lock_key_bytes_are_fixed`.

The first gate run found that
`deletion_surface_parity_between_migration_0029_and_schema_sql` still
expected `community_deletion_lock_key` in `schema.sql`. The second
commit fixes that.

🤖 Generated with [Claude Code](https://claude.com/claude-code)



buzz-review-completed

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@loganj loganj changed the title Retire the 0032 roster trigger in migration 0094 Retire the 0032 roster trigger in migration 0095 Nov 17, 2026
@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from 70cd5d0 to 13b5497 Compare November 17, 2026 20:19
@github-actions github-actions Bot added codex-security-review-current The posted Codex security review matches its recorded range. and removed codex-security-review-current The posted Codex security review matches its recorded range. labels Nov 17, 2026
loganj and others added 2 commits November 17, 2026 16:09
Every kind:39002 roster writer already checks the roster against
canonical channel membership in the application (#8316), and since #8611
no relay requires the 0032 trigger at startup. Migration 0095 drops the
trigger and its function, with the lock and statement timeouts from 0049.
The desired-state schema and the pgschema reconcile script no longer
install them. With this trigger gone, events has no triggers left, so
schema/triggers/events.sql and the reconcile script's pre-attach
trigger drops go too.

Relays from this change still store and publish the requested role, so
they serve correctly whether or not 0095 has run. Every relay, and every
rollback target, must run #8611 or later before 0095 is applied.

Tests that compared the trigger with the app check, or that disabled the
trigger first, now test the app check alone. A new Postgres test applies
0095 to a database migrated through 0094 and checks that the trigger and
function are gone. The pgschema populated-upgrade fixture now drops the
roster trigger on events before pgschema runs, as it does for the other
retired parent triggers.

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
docs/trigger-retirement-deployment.md is the operator guide for the
trigger-dropping migrations 0089-0091. Migration 0095 drops one more, so
add it there: its row, the two ways an older relay fails (a relay
without #8316 can save stale rosters; a build with 0032 but without
#8611 cannot start once the trigger is gone), the migrate check, and the
parent trigger a pgschema deployment must drop first. The guide's stop
build already contains #8316 and #8611.

The Helm chart README now names the required stop and points to that
guide instead of describing it separately (docs/database.md Rule 5).

Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Logan Johnson <loganj@squareup.com>
@loganj
loganj force-pushed the larry/retire-roster-trigger-migration branch from 13b5497 to ab67806 Compare November 17, 2026 21:16
@github-actions github-actions Bot added codex-security-review-current The posted Codex security review matches its recorded range. and removed codex-security-review-current The posted Codex security review matches its recorded range. labels Nov 17, 2026
@TheSentinel454
TheSentinel454 merged commit b568d9b into main Nov 17, 2026
93 checks passed
@TheSentinel454
TheSentinel454 deleted the larry/retire-roster-trigger-migration branch November 17, 2026 21:56
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
Main now has 0095 for the roster trigger drop (#8696). Move this drop to
0096 and name 0096 in the chart's required-stop note.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
…#9398)

> [!NOTE]
> **Rollout:** #8320 (app guards + catalog expand) is deployed, so the
hold is lifted. With `autoMigrate=true`, `0096` runs at startup under a
5s lock timeout, and a failure stops startup. With
`BUZZ_AUTO_MIGRATE=false`, deploy this binary first and then run
`buzz-admin migrate`. Both orders are safe because the expand tolerates
the objects being present or absent.

## What

The required stop for `0096` is in
`docs/trigger-retirement-deployment.md` (from #9622): a relay build at
or after #8320 (`ec778bff`). A build older than that needs the tombstone
trigger at startup and readiness.

Migration `0096_drop_single_table_guards.sql` drops five triggers and
their functions. #8320 moved each invariant into the application
writers:

| Trigger (table) | Function |
|---|---|
| `trg_channels_community_id_immutable` (channels) |
`channels_community_id_immutable()` |
| `communities_deletion_tombstone` (communities) |
`enforce_community_tombstone()` |
| `community_deletion_request_retargeting_guard`
(community_deletion_requests) |
`prevent_community_deletion_request_retargeting()` |
| `community_deletion_approval_removal_guard`
(community_deletion_approvals) |
`prevent_community_deletion_approval_removal()` |
| `community_deletion_manifest_keys_guard`
(community_deletion_manifest_keys) |
`protect_community_deletion_manifest_keys()` |

Desired state (`schema/`) drops the five functions and four trigger
files, plus the channels trigger declaration. The universal write fence
on `channels` stays. Both boot paths stay catalog-equivalent: the
pgschema-vs-migration parity check now also compares columns, key and FK
shapes, and the remaining triggers on all five tables.

Executor GUCs stay because `assert_community_write_allowed` still reads
them through the universal write fence. `transition_community` and every
phase-1 app guard are byte-identical to #8320.
`scripts/reconcile-schema-after-pgschema.sql` has no entries for these
objects.

## Tests

- #8320's six `single_table_guard_*_without_trigger` PG tests no longer
need to disable a trigger. They are now plain app-path tests with the
same assertions.
- New per-test regressions for the desired-template and migration boot
paths assert that none of the ten objects exist, including disabled
triggers and function overloads.
- Deleted assertions that only exercised raw SQL against the triggers:
retarget, rewrite and approval mutation, frozen-manifest rewrite, and
tombstone DELETE. The app-path coverage for each remains.
- The expand regression in #8320 migrates through `0086`, validates
serving, readiness and the deletion lifecycle, drops the five guards,
then validates again.
- Rebased onto main `b568d9bf` after #8696 took `0095`; renumbered to
`0096`. Blox gate at `7bda1f45`: fmt, clippy and buzz-db `--lib` pass;
the PostgreSQL lane ran 219 tests, all pass.
- Gate at `c8bc061c` (on main `051dd2d7`, then numbered `0095`, #9622
folded in): on Blox, `cargo fmt --check`, clippy and the buzz-db `--lib`
tests pass. The PostgreSQL lane (migrations, single-table guards, floor
retirement, fence and deletion) ran 208 tests: all pass.
- Earlier gate at `0840ba49`: CI was green, and the Blox PostgreSQL lane
passed 840 of 841 (the one failure, `media_reference_full_query_plans`,
is a timing check that fails the same way on main on that host).
- The rebase updates main's fence-retirement tests to expect the
tombstone trigger gone.

## What got simpler

Ten database behavior objects and nine desired-state files are gone
(about 150 lines). Each rule has a single owner, the application writer.

buzz-review-completed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
wpfleger96 added a commit that referenced this pull request Nov 18, 2026
…c-spec-mobile

* origin/main: (37 commits)
  buzz-db: drop the five single-table guard triggers (BUZZ-318 phase 2) (#9398)
  push-gateway: lock expired installations before reaping (#9627)
  Retire the 0032 roster trigger in migration 0095 (#8696)
  fix(db): hard-delete superseded relay-signed lists (#9586)
  Add community-scoped user and agent profile cleanup (#9580)
  fix(sdk): timestamp channel messages with millisecond offsets (#9548)
  Check product_feedback's community in the writing transaction (#9608)
  buzz-db: stop calling the dropped lock-key function in SQL (#9615)
  Clean up account records and refresh member lists (#9364)
  perf(mobile): save own thread interest once per unread catch-up (#9614)
  buzz-db: fix main (renumber the function drop to 0094, update_channel test call) (#9616)
  feat(relay): name the agent whose add policy refuses a DM (#9601)
  buzz-db: drop the community_deletion_lock_key and profile_name_fields functions (contract) (#9598)
  fix(deps): clear chrono, humantime and zip advisories from the dependency policy (#9609)
  docs: define mobile diagnostic reporting (#9600)
  build(mobile): link iOS plugins through Swift Package Manager (#9597)
  feat(push-gateway): enroll Android installations and send FCM wakes (#9560)
  perf(mobile): cache and animate custom emoji in the iOS picker (#9479)
  fix(ios): end each bold or strikethrough run at its first closing marker (#9559)
  Apply the private-to-open rule in update_channel too (#9581)
  ...

Signed-off-by: Will Pfleger <wpfleger@block.xyz>

This branch was previously deployed

1 inactive deployment
codex-review — ab67806b Deployed Nov 17, 2026 by loganj via Run Codex Security Review #15825
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants