Skip to content

buzz-db: build the community deletion lock key in Rust - #9396

Merged
TheSentinel454 merged 1 commit into
mainfrom
elrond/community-deletion-lock-key-app
Nov 13, 2026
Merged

TheSentinel454 merged 1 commit into
mainfrom
elrond/community-deletion-lock-key-app

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

This is phase 1 of 2 for retiring the SQL function community_deletion_lock_key(uuid). Every relay caller now builds the lock name in Rust, with buzz_db::deletion::community_deletion_lock_key(CommunityId) -> String. It then locks with the built-in hashtextextended($1, 0), the same pattern the other advisory locks here use (channel_ttl_lock_key, push_gate_lock_key). The string is byte-for-byte the one the function hashes ('buzz-community-deletion:' || target::text), so the lock is identical. Old and new relays, and the fence functions still in the database (community_write_allowed, assert_community_write_allowed), keep excluding each other during a rolling deploy.

  • Production callers: exclusive lock_community_deletion, shared lock_community_deletion_shared, and the bulk shared lock in bind_nip_fi_issuers_to_active. The bulk lock now binds a text[] of keys, sorted by community id in Rust and locked WITH ORDINALITY. That keeps the old ORDER BY id lock order, because Uuid and Postgres uuid both compare bytewise.
  • Startup check: validate_serving_catalog_on no longer requires the function to exist, so the phase-2 drop can't make this release refuse to serve or delete.
  • Tests and docs: test lock holders use the helper. docs/database.md gives repair scripts the inline expression, which keeps working after the drop.
  • The test-schema shims in api/bridge.rs and handlers/ingest.rs stay. Test schemas still copy the fence functions that call the function.

Phase 2 (not here): a migration and desired-state change drops the function after this release is fully deployed and the fence functions are gone (#8323). It also removes the two test shims.

Tests

  • deletion::postgres_tests::community_deletion_lock_key_matches_the_sql_function checks that hashtextextended(rust_key, 0) equals community_deletion_lock_key(uuid) for the nil UUID, the max UUID and 64 random ones.
  • migration_schema_fence_objects_are_optional_for_serving_and_deletion already drops the universal fence objects by hand. It now also drops community_deletion_lock_key(UUID). With both present and absent, it runs the startup and readiness checks, serving leases (shared lock), bind_nip_fi_issuers_to_active (bulk shared lock) and lock_community_deletion (exclusive lock).

Must-fail mutants, each run on Blox against its guarding test: a changed key prefix, the shared, exclusive and bulk locks reverted to the SQL function, and the startup check requiring the function again.

What got simpler

No relay code path calls a database function to build this lock any more. The key has one definition in Rust instead of one in SQL plus about 20 SQL call sites. One fewer object stands between the schema and declarative-only management (docs/database.md Rule 1).

Verification

Blox, at 3020a44148d942f1502395640730cd0548a76400 (clean tree):

Gate Result
cargo fmt --all --check pass
cargo clippy -p buzz-db -p buzz-relay --all-targets -- -D warnings pass
cargo nextest run -p buzz-db --lib 214/214
scripts/postgres-test-run.sh -p buzz-db --lib over deletion::postgres_tests, nip_fi_binding::postgres_tests and the reaction and channel-member lock tests 101/101
Must-fail mutants (prefix, shared, exclusive, bulk, startup check) 5/5 killed

CI runs the full Postgres lanes.

🤖 Generated with Claude Code

buzz-review-completed

@TheSentinel454
TheSentinel454 marked this pull request as ready for review November 12, 2026 15:39
@TheSentinel454
TheSentinel454 requested a review from a team as a code owner November 12, 2026 15:39
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 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: ce42853982d4e1673fadfd5fbde7e691cfde9694...b9fcec5bc0a136cba5ab2e791a21dd5411961624
  • 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 regressions found in the authorized PR range. Lock keys remain compatible with existing SQL callers, and community state checks are preserved.

Findings

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

Notes

  • Review used read-only source and history inspection. Builds and tests were not run, as instructed.

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

@brow
brow enabled auto-merge (squash) November 12, 2026 17:23
@TheSentinel454
TheSentinel454 force-pushed the elrond/community-deletion-lock-key-app branch from 3020a44 to bffe06c Compare November 12, 2026 20:37
@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 12, 2026
@brow
brow disabled auto-merge November 12, 2026 22:05
Every relay lock on a community's deletion advisory lock now binds the key
`deletion::community_deletion_lock_key` builds and hashes it with the
built-in `hashtextextended($1, 0)`, instead of calling the SQL function
`community_deletion_lock_key(uuid)`. The key bytes are the function's, so
old and new relays, and the fence functions still in the database, keep
taking the same lock.

The deletion startup check no longer requires the function. The test that
drops the fence objects now drops the function too and still exercises
serving leases, the bulk NIP-FI bind, and the exclusive deletion lock. A
parity test pins the Rust key against the function. A later migration
drops the function once this release and the fence-function drop have
shipped.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Luke Tornquist <[email protected]>
@TheSentinel454
TheSentinel454 force-pushed the elrond/community-deletion-lock-key-app branch from bffe06c to b9fcec5 Compare November 12, 2026 22:27
@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 12, 2026

@kazemek21 kazemek21 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.

Kyle reviewed this PR and the Nexus review-tracker notes and approved with no comments.

Posted by Codex (gpt-6.1-sol) on behalf of kylez.

@TheSentinel454
TheSentinel454 merged commit 745f7da into main Nov 13, 2026
90 checks passed
@TheSentinel454
TheSentinel454 deleted the elrond/community-deletion-lock-key-app branch November 13, 2026 00:34
bostonaholic added a commit that referenced this pull request Nov 13, 2026
Co-authored-by: mboston.Engineer <932d3b6ebea6cc83e091551ae46d1c7e7f8f7d0fa8e9cef5e6facc8544af413b@buzz.block.builderlab.xyz>

* origin/main:
  fix(mobile): require Builderlab consent for existing identities (#8823)
  feat(mobile): use HTTP/2 on iOS through app-wide URLSessions (#8897)
  fix(relay): publish a git push only when refs changed; check the protocol by refinement (#9425)
  fix(mobile): show shared chats under Solo (#9348)
  chore(release): release Buzz Desktop version 0.5.29 (#9456)
  feat(mobile): render messages with gpt_markdown 1.3.4 plusparse (#8945)
  fix(acp): bound observer retention by bytes (#7987) (#9436)
  Tune release codegen for faster/smaller binaries (#9434)
  feat(desktop): add dismissible banner pointing to the new buzz app (#9379)
  fix(mobile): keep publishing presence while the app is open (#9441)
  feat(mobile): share into Buzz from the iOS share sheet (#9433)
  fix(mobile): qualify every namesake mention and keep authored mention casing (#9325)
  fix(mobile): match browser GIF timing in the iOS reaction sheet (#9437)
  fix(mobile): play short-delay animation frames at browser speed (#9432)
  buzz-search: read profile names without the profile_name_fields function (#9397)
  buzz-db: build the community deletion lock key in Rust (#9396)
  fix(cli): pair for the active community, skip stopped desktops, accept a bare relay host (#9417)
  test(mobile): run push tests without a gateway dart-define (#9423)
  fix(mobile): never pop Home when archiving from channel settings (#9387)
  perf(acp): reduce observer CPU and lock overhead (#9381)

Signed-off-by: Matthew Boston <[email protected]>
bostonaholic added a commit that referenced this pull request Nov 13, 2026
…count-backfill

Co-authored-by: mboston.Engineer <932d3b6ebea6cc83e091551ae46d1c7e7f8f7d0fa8e9cef5e6facc8544af413b@buzz.block.builderlab.xyz>

* bostonaholic--agent-reply-count:
  fix(mobile): require Builderlab consent for existing identities (#8823)
  feat(mobile): use HTTP/2 on iOS through app-wide URLSessions (#8897)
  fix(relay): publish a git push only when refs changed; check the protocol by refinement (#9425)
  fix(mobile): show shared chats under Solo (#9348)
  chore(release): release Buzz Desktop version 0.5.29 (#9456)
  feat(mobile): render messages with gpt_markdown 1.3.4 plusparse (#8945)
  fix(acp): bound observer retention by bytes (#7987) (#9436)
  Tune release codegen for faster/smaller binaries (#9434)
  feat(desktop): add dismissible banner pointing to the new buzz app (#9379)
  fix(mobile): keep publishing presence while the app is open (#9441)
  feat(mobile): share into Buzz from the iOS share sheet (#9433)
  fix(mobile): qualify every namesake mention and keep authored mention casing (#9325)
  fix(mobile): match browser GIF timing in the iOS reaction sheet (#9437)
  fix(mobile): play short-delay animation frames at browser speed (#9432)
  buzz-search: read profile names without the profile_name_fields function (#9397)
  buzz-db: build the community deletion lock key in Rust (#9396)
  fix(cli): pair for the active community, skip stopped desktops, accept a bare relay host (#9417)
  test(mobile): run push tests without a gateway dart-define (#9423)
  fix(mobile): never pop Home when archiving from channel settings (#9387)
  perf(acp): reduce observer CPU and lock overhead (#9381)

Signed-off-by: Matthew Boston <[email protected]>

This branch was successfully deployed

1 active deployment
codex-review — b9fcec5b Deployed Nov 12, 2026 by TheSentinel454 via Run Codex Security Review #14714
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.

3 participants