Skip to content

buzz-db: stop calling the dropped lock-key function in SQL - #9615

Merged
TheSentinel454 merged 1 commit into
mainfrom
elrond/fix-main-update-channel-sender
Nov 17, 2026
Merged

TheSentinel454 merged 1 commit into
mainfrom
elrond/fix-main-update-channel-sender

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Main's user content cleanup still calls the SQL function community_deletion_lock_key. Migration 0094 (#9598) drops it. On any database at 0094, every user-deletion content batch fails with 42883 function community_deletion_lock_key(uuid) does not exist.

#9363 added this caller after #9396 moved the key to Rust. This PR binds the Rust-built key with hashtextextended($1, 0), as every other caller does.

  • content_batches/execute.rs: the batch's exclusive advisory lock uses the Rust key.
  • content_batches/safety_postgres_tests.rs: the test blocker takes the same lock the same way.
  • docs/trigger-retirement-deployment.md: builds from Add real content cleanup for users and agents #9363 up to this PR are not valid stops before 0094.

Rebased onto main e894d75d. The renumber and the update_channel test-call fixes this PR first carried are already on main through #9616, so they are gone from this PR.

Deployed relays are unaffected: the deployed build predates #9363.

Tests

The 17 user_deletion::content_batches PostgreSQL tests fail on main at 0094 with the error above. This PR makes them pass.

What got simpler

One fewer SQL-side copy of the lock key. Every caller now builds the key in Rust.

🤖 Generated with Claude Code

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

github-actions Bot commented Nov 17, 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: e894d75d26e46730ffc20596861908a02177d754...4431631ab1011ec98ac1e478920989e56303bab5
  • Model: gpt-6.1-sol

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


Review Summary

Overall Risk: NONE

No concrete regressions found. The replacement preserves the advisory lock key, community scope, and transaction safeguards while removing the dependency on the dropped SQL function.

Findings

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

Notes

  • Review used read-only source and history inspection. Tests were not executed, as requested.

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

@TheSentinel454
TheSentinel454 force-pushed the elrond/fix-main-update-channel-sender branch from 9c7d7d3 to 430b662 Compare November 17, 2026 19:14
@TheSentinel454 TheSentinel454 changed the title buzz-db: pass the sender in two update_channel test calls buzz-db: fix main (test call, duplicate 0093 migration, dropped lock-key function) Nov 17, 2026
@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
#9363 added a SQL caller of `community_deletion_lock_key` in user
content cleanup after #9396 moved the key to Rust. Migration 0094 drops
the function, so that cleanup fails with 42883 on any database at 0094.
Bind the Rust-built key with `hashtextextended`, as every other caller
does. The deployment doc now says builds with that caller are not valid
stops before 0094.

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
TheSentinel454 force-pushed the elrond/fix-main-update-channel-sender branch from 430b662 to 4431631 Compare November 17, 2026 19:52
@TheSentinel454 TheSentinel454 changed the title buzz-db: fix main (test call, duplicate 0093 migration, dropped lock-key function) buzz-db: stop calling the dropped lock-key function in SQL 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
TheSentinel454 enabled auto-merge (squash) November 17, 2026 20:09
@TheSentinel454
TheSentinel454 merged commit 0a05330 into main Nov 17, 2026
90 checks passed
@TheSentinel454
TheSentinel454 deleted the elrond/fix-main-update-channel-sender branch November 17, 2026 20:31
tellaho added a commit that referenced this pull request Nov 17, 2026
Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz>

* origin/main:
  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)

Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
ravarora2 added a commit that referenced this pull request Nov 17, 2026
Include the upstream correction from #9615 so content-to-profile cleanup works after SQL function retirement. Preserve the profile cleanup changes.

Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
Signed-off-by: Ravneet Arora <rarora@squareup.com>
ravarora2 added a commit that referenced this pull request Nov 17, 2026
## Summary

Content, account and media cleanup leave profile records behind. Add
`buzz-admin user-deletions profile-batches` to preview or delete those
records in one community. Preview is the default; explicit `--delete`
applies bounded, retryable transactions.

Every run and retry discovers the human’s current direct agents in that
community. Ownership elsewhere cannot authorize deletion here. If Alice
owns an agent in A but Bob owns it in B, deleting Alice in B preserves
that agent. Each write batch locks and rechecks ownership. All profile
data is removed before identity rows, so an interrupted run resumes
without saved agent keys. The command no longer accepts
`--agent-pubkey`.

The handler removes profile/configuration events and projections,
rebuilds shared archive snapshots with valid signatures, and finally
removes identity rows. Repository announcements/state (30617/30618) and
name mappings remain intact without blocking identity removal; other
authored content still requires prior cleanup. Unresolved dependencies,
changed sources, untrusted signers or excessive plans stop deletion.
This includes historical `replaced-by` references in archive requests
and deltas, even after unarchive removes the current archive row. See
[operator instructions and verification steps](docs/profile-cleanup.md).

Writers must be stopped. Coordinator integration, online admission
fencing, media objects, client caches and final account-erasure
verification remain separate. The command always reports
`account_erasure_complete: false`.

### Related issue

Fixes #9576. Continues the standalone handler pattern from #9363
(content) and #9364 (account). This is an independent PR against main.

### Testing

The latest correction adds a PostgreSQL regression that runs content
cleanup followed by profile preview/delete/retry for human and agent
repository owners. It checks unchanged repository events, mentions, name
mappings and other-community data, and verifies ordinary content still
blocks profile deletion. The merge of main brings in `buzz-deletion
--lib` coverage in the CI unit lane and its fallback, covering the
preview-default parser test without duplicate runs. Account, content,
media and profile command dispatch are all preserved. The
archive-history documentation also now distinguishes planning errors
from printed blockers.

The latest main merge includes the shared dependency-policy correction
from #9609 and the content cleanup lock fix from #9615. On `54bd50299`,
PostgreSQL CI passed 1647 tests and failed 18 because content cleanup
still called the retired SQL lock-key function; this also blocked the
new content→profile regression. The merged upstream fix uses the
existing Rust-built key for both the cleanup lock and the test blocker.
Local test suites and hooks remain skipped at the owner’s request. CI
and review of the updated head are pending. The results below apply to
earlier revisions.

At `92aa9c216`, exercised the rebuilt `buzz-admin` against signed
archive/unarchive events stored in disposable PostgreSQL:

- For kinds 9035 and 8002, test a historical `replaced-by` reference to
the human and then to their owned agent after unarchive.
- Run `profile-batches --pubkey <human> --community <A> --relay-pubkey
<relay>` in preview and `--delete` modes. Both refuse the unresolved
reference; full table dumps remain unchanged.
- Keep that history only in community B. Cleanup in A succeeds,
preserves B, and selects zero work on retry.
- Delete the archive subject in B. Its history is removed while the
replacement identities remain intact.

All four scenarios passed. These are signed database fixtures exercised
through the real CLI; they do not claim live relay admission. The
correction also merges main and preserves content, media and profile
command dispatch.

The initial full database run passed 880/881 tests: the new request
fixture lost its required self-`p` tag during signing. Commit
`ff6689386` preserves that tag; all ten profile regressions now pass.
Further local checks and pre-push hooks were skipped at the owner’s
explicit request. The full corrected database suite has not been rerun;
GitHub CI will validate the new head. At `ff6689386`, the production
code matched the CLI-tested revision; the repository-retention
correction above is newer.

Previous ownership validation follows:

At `090d2a1cf`, exercised the rebuilt `buzz-admin` binary against a
disposable PostgreSQL fixture:

- Run `user-deletions profile-batches --pubkey <human> --community <A>`:
preview left table exports unchanged and selected four profile/identity
mutations.
- Repeat with `--delete --batch-size 2`: all four mutations committed;
retry selected zero work.
- Use the same human and agent keys in another community, with the agent
owned by someone else: only the human was selected, and the agent
remained intact.

This fixture uses placeholder profile signatures and validates
database/CLI behavior. It does not claim live signed-event admission.
The earlier live relay and Desktop results below cover the previous
revision.

Independent agent review covered the previous ownership correction. A
later review found the historical replacement-reference bug; the
historical-reference correction addresses that finding. Fresh review of
this revision is still required. Human command verification has not been
recorded; it is not claimed by the agent-run checks. Follow the local
verification steps in `docs/profile-cleanup.md`; preview must leave data
unchanged, deletion must preserve other-community records, and retry
must select zero work.

<details>
<summary>Historical validation at fdf8a83, before the ownership
correction</summary>

These records are retained from the earlier PR description. They do not
validate the current revision. The saved-agent-key retry below describes
the old interface, which this update removes.

- `cargo test -p buzz-db -p buzz-deletion -p buzz-admin`: passed at
`fdf8a8363` (298 tests, with PostgreSQL tests in the separate lane).
- `cargo clippy -p buzz-db -p buzz-deletion -p buzz-admin --all-targets
-- -D warnings`: passed.
- Full PostgreSQL lane for those three packages: **814/818 passed**,
including all five new profile tests. Four unchanged infrastructure
tests failed: reader-pool startup, a `postgres://`-only test given a
`postgresql://` URL, a one-second partition-lock timing assertion (1.55
seconds), and size-one matcher pool startup. The URL spelling has been
corrected for future runs; the full lane has not yet been rerun. The run
experienced heavy host contention.
- Actual `buzz-admin` command against a separate disposable SQL fixture:
default preview, `--print-only`, and `--read-only` left all table
exports unchanged; `--delete` removed four selected rows;
survivor/second-community data remained; retry selected zero rows. This
is database/CLI evidence, not live relay acceptance.
- Workspace Rust clippy and desktop static checks passed. `just ci`
initially stopped at mobile formatting because the fresh worktree lacked
Flutter package configuration; dependencies were installed and the retry
remains incomplete. The long-running local pre-push run was stopped to
publish the draft at the author’s request; incomplete gates are not
claimed as passing.
- Isolated live relay at `fdf8a8363`: 22 signed client events accepted
across two communities; WebSocket authentication established four
agent-owner links. All three preview forms left all 67 public tables
unchanged. `--delete --batch-size 2` removed eight selected source
events, four mention rows, one archive row and two identity rows, and
inserted one independently verified survivor-only archive snapshot. All
other rows matched exactly; retry selected zero work.
- Eight refusal cases left every table unchanged. A real process kill
after a committed batch, followed by retry with saved agent keys,
produced the exact expected result. Separate signed SQL fixtures covered
kind 30382, verified heads and historical kind 30179; these do not claim
live issuer-backed admission.
- Independent restart checks passed: target profiles stayed absent from
events, search and NIP-05; the other community was preserved; the
surviving user could publish and read a profile update. A separate
replay clone confirmed the boundary: replaying the original target
profile recreated its user row, and a fresh profile was accepted too.
Permanent erasure requires external admission/write fencing.
- Native Desktop experiment: relay/admin `fdf8a8363`, `buzz-app`
`859c9953a` with isolated app storage and a local TLS configuration.
Seed a survivor-owned conversation, open Alice and her agent's profiles,
then run `profile-batches --delete --batch-size 2` while app and relay
remain running. Preview selected 17 mutations across nine batches
without changing any of 67 tables. Deletion removed ten source events,
four associated mention rows and two users, then inserted one validly
signed survivor-only archive snapshot. Every other row, including eight
survivor events and community B, matched exactly. Retry did zero work.
- Desktop observations: fresh signed relay reads returned no target
profiles/events/NIP-05 in A; B and the survivor conversation remained
readable. Bob updated his profile through the API and sent a reply
through the native composer, with signed relay readback and visible
receipt. Cached target details remained in the open profile panel,
reopened search and after an app-page reload/reconnect. This does not
erase client caches or prove safety under concurrent target writes; the
stopped-writer contract remains.
- At that earlier revision, the PR was draft pending human command
verification. Agent testing does not satisfy the repository's
human-testing requirement, and this command does not certify online
erasure.

</details>

Generated with Codex

---------

Signed-off-by: Ravneet Arora <rarora@squareup.com>
Co-authored-by: dessert <7d616e7e143e5d408159614dccff1371350a1c1bd36c8de838a45ece5aca0aca@buzz.block.builderlab.xyz>
Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
TheSentinel454 added a commit that referenced this pull request Nov 17, 2026
Rebased off #9610 onto main, which ends at 0094, so the drop is 0095.
A build between #9363 and #9615 is not a valid 0094 stop, so the shared
stop must also satisfy 0094's rule, not only come before it.

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>
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>
wpfleger96 added a commit that referenced this pull request Nov 18, 2026
…e-recovery

* origin/main:
  feat(cli)!: consistent channels list/get/search output (type, visibility, labels, real created_at) (#9617)
  ci(docker): publish the push gateway only when its inputs change (#9658)
  feat(mobile): reply to a message from its iOS notification (#9439)
  fix(mobile): stop reporting saved images as failed on iOS (#9599)
  perf(db): stop per-id planning of wide #e reads (#9591)
  [buzz] fix(ci): link relay image indexes to their source (#9637)
  feat(push-gateway): verify Android Key Attestation (#9562)
  fix(relay): remove an owner's agents with the owner (#9575)
  relay: refuse a reaction or deletion whose h names another channel (#9006)
  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)

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

This branch was previously deployed

1 inactive deployment
codex-review — 4431631a Deployed Nov 17, 2026 by TheSentinel454 via Run Codex Security Review #15780
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.

2 participants