Skip to content

Revert "feat(relay): support community-scoped NIP-AR artifacts" - #9689

Merged
wpfleger96 merged 3 commits into
mainfrom
wpfleger/revert-community-scoped-artifacts
Nov 19, 2026
Merged

wpfleger96 merged 3 commits into
mainfrom
wpfleger/revert-community-scoped-artifacts

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Reverts #9650 (squash commit eebf62b6), except for migration 0097 and the channel artifact sync fences it added.

Community scope adds a relay access gate based on community admission rather than channel membership, a new relay-admin command kind (9034) and an operator-run key transition. Its design and NIP-AR text need relay maintainer review before they ship. Two integration gaps also remain:

  • Media download authorization looks up references only in events, so an attachment referenced only by a community artifact is unreadable when media-read enforcement is on.
  • User erasure retires a community head in the database without signaling live syncs, so members who are already syncing keep the erased copy.

The feature can return as a new PR once those are resolved.

Kept from #9650

  • Migration 0097, byte for byte. Published images already include it, and databases that auto-migrated have recorded it. Dropping it would stop those relays from starting. It only adds columns and indexes that the channel code ignores. The declared schema matches that expanded shape and keeps the (community_id, artifact_id) primary key, so the operator key transition no longer exists.
  • Channel artifact sync fences. Snapshot and live sends check for a pending resync and for connection cancellation under the queue lock. A reader who loses access, or whose content is redacted, while a frame is in flight therefore receives no further payload. Handler-backed tests cover a resync recorded while a snapshot payload waits for queue room and one recorded after a live head read.

Compatibility

This revert supports databases that applied only migration 0097, which is all that auto-migration runs. A database that ran #9650's operator contract script, or was bootstrapped from #9650's declared schema, has no (community_id, artifact_id) key, so channel artifact writes fail there. Before deploying to such a database, check that artifact_heads_pkey is on (community_id, artifact_id) and that artifact_heads has no rows with scope = 'community'; if either check fails, it needs a separate recovery step.

This reverts commit eebf62b.

Community scope adds a relay access gate outside channel membership and
needs relay maintainer review before it ships. Reverting before
migration 0097 reaches a deployed database keeps the revert free of a
schema recovery step.

Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
@wpfleger96
wpfleger96 force-pushed the wpfleger/revert-community-scoped-artifacts branch from d17ffe2 to 1a70c29 Compare November 19, 2026 01:35
@wpfleger96
wpfleger96 marked this pull request as ready for review November 19, 2026 01:42
@wpfleger96
wpfleger96 requested a review from a team as a code owner November 19, 2026 01:42
@wpfleger96
wpfleger96 deployed to codex-review November 19, 2026 01:42 — with GitHub Actions Active
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 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: db40da87b4fb85973f0fb893ecfea09dc3db9423...00d41369a92671323cc77470700903caf846e4c8
  • Model: gpt-6.1-sol

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


Review Summary

Overall Risk: MEDIUM

The reverted upsert can disable channel artifact writes on databases using the previously supported scoped primary key.

Findings

[MEDIUM] Preserve compatibility with existing scoped artifact keys

  • Category: Reliability
  • Location: crates/buzz-db/src/store/artifact.rs:196 (source)
  • Description: Databases bootstrapped from the base revision's declarative schema, or upgraded through its documented operator contract, have a primary key on community_id, scope, artifact_id without a unique key on community_id, artifact_id. This restored conflict target therefore fails PostgreSQL constraint inference for every otherwise-valid new artifact revision. Retaining migration 0097 does not repair that key, and changing the declarative schema does not update existing databases during startup.
  • Impact: Affected installations can start successfully but cannot create, edit, move, delete, or restore channel artifacts.
  • Recommendation: Keep channel-scoped reads and the scoped conflict target while disabling community artifacts, or provide a guarded schema recovery procedure before requiring the legacy key.

Notes

  • Deployment schema state was unavailable. The finding applies to installations using the scoped primary key supported by the base revision.

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

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Star Lord recommends changes at 1a70c29 before merge. The source review found a startup regression for databases that applied the published migration. Databases using the scoped primary key also need a separate rollback plan, because the restored channel artifact upsert requires the legacy key. Reverted upsert · Rollback floor

The reverted change also made channel snapshot and live sends check a
pending resync and connection cancellation under the queue lock. Keep
those fences so a reader who loses access or sees a redaction while a
frame is in flight receives no further payload.

Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
@wpfleger96
wpfleger96 deployed to codex-review November 19, 2026 02:06 — with GitHub Actions Active
@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 19, 2026
The public main image already shipped 0097, and auto-migrating
databases have recorded it; removing the file makes those relays refuse
to start. 0097 only adds columns and indexes the channel code ignores,
so keep it and declare its expanded shape with the legacy primary key.

Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
@wpfleger96
wpfleger96 deployed to codex-review November 19, 2026 02:13 — with GitHub Actions Active
@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 19, 2026
@wpfleger96
wpfleger96 enabled auto-merge (squash) November 19, 2026 02:22
@wpfleger96
wpfleger96 merged commit a406191 into main Nov 19, 2026
91 checks passed
@wpfleger96
wpfleger96 deleted the wpfleger/revert-community-scoped-artifacts branch November 19, 2026 02:38
TheSentinel454 added a commit that referenced this pull request Nov 19, 2026
Review found that SET NOT NULL scanned artifact_heads under ACCESS
EXCLUSIVE. docs/database.md requires three steps instead:
- 0098 adds a NOT VALID check;
- 0099 validates it under SHARE UPDATE EXCLUSIVE, so writes continue;
- 0100 sets NOT NULL from the validated check and drops 0097's
  indexes and columns.

0098 also refuses a database whose artifact head key is the scoped key
from the removed operator contract, before any cleanup runs. The
migrations name #9689 as a required stop, because relays built from
#9650 read the dropped column.

Tests now bind the surviving head's exact channel and event, and check
its revision. New tests check that 0099 runs beside an open head writer
and that 0098 refuses the scoped key.

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 19, 2026
Relay images built from #9650 up to, but not including, #9689 read the
columns 0100 drops. The chart's upgrade notes now tell operators to move
every pod, job and rollback target to sha-a406191 or later first, and
how to roll back after 0100.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
bostonaholic added a commit that referenced this pull request Nov 19, 2026
…ction-p

* origin/main: (200 commits)
  fix(mobile): keep open shared sessions in Solo (#9704)
  fix(mobile): align channel indicators and Duo section menus (#9703)
  fix(mobile): allow person mentions in Solo chats (#9705)
  fix(mobile): let code scroll under the code block copy button (#9612)
  Transcribe Bestie hold recordings into text on device (#9645)
  feat(cli): show and search verified identity in users get (#9647)
  fix(mobile): keep agent poster up until the iOS video draws (#9688)
  test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
  Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
  feat(relay): add conditional Solo member role updates (#9667)
  feat(mobile): add saved channel section filters (#8479)
  feat(relay): support community-scoped NIP-AR artifacts (#9650)
  feat(mobile): add a diagnostics test report and test crash to Settings (#9676)
  fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
  feat(mobile): add diagnostic reporting module with crash capture (#9613)
  fix(mobile): recover stuck read-state updates and stale Mark Read (#9492)
  test(relay): refresh the author's membership cache after the stray-h private channel insert (#9640)
  fix(mobile): name the cause of account-unavailable sign-in errors (#9628)
  perf(db): bound deep keyset history pages by the cursor timestamp (#9549)
  feat(cli)!: consistent channels list/get/search output (type, visibility, labels, real created_at) (#9617)
  ...

Signed-off-by: Matthew Boston <mboston@squareup.com>
bostonaholic added a commit that referenced this pull request Nov 19, 2026
…eaction-recipients

* origin/main: (72 commits)
  fix(mobile): keep open shared sessions in Solo (#9704)
  fix(mobile): align channel indicators and Duo section menus (#9703)
  fix(mobile): allow person mentions in Solo chats (#9705)
  fix(mobile): let code scroll under the code block copy button (#9612)
  Transcribe Bestie hold recordings into text on device (#9645)
  feat(cli): show and search verified identity in users get (#9647)
  fix(mobile): keep agent poster up until the iOS video draws (#9688)
  test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
  Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
  feat(relay): add conditional Solo member role updates (#9667)
  feat(mobile): add saved channel section filters (#8479)
  feat(relay): support community-scoped NIP-AR artifacts (#9650)
  feat(mobile): add a diagnostics test report and test crash to Settings (#9676)
  fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
  feat(mobile): add diagnostic reporting module with crash capture (#9613)
  fix(mobile): recover stuck read-state updates and stale Mark Read (#9492)
  test(relay): refresh the author's membership cache after the stray-h private channel insert (#9640)
  fix(mobile): name the cause of account-unavailable sign-in errors (#9628)
  perf(db): bound deep keyset history pages by the cursor timestamp (#9549)
  feat(cli)!: consistent channels list/get/search output (type, visibility, labels, real created_at) (#9617)
  ...

Signed-off-by: Matthew Boston <mboston@squareup.com>
TheSentinel454 added a commit that referenced this pull request Nov 19, 2026
## What

Migrations `0098`–`0100` undo migration `0097` (community artifact
expand). The declared schema goes back to its shape before #9650.

#9650 added `0097`. The revert, #9689, removed the feature but kept
`0097` byte for byte, because databases that auto-migrated recorded its
checksum. No code on `main` reads or writes what `0097` added. This PR
removes it with forward migrations, as `docs/database.md` requires
("Never edit a merged migration. Fix forward.").

`artifact_heads.channel_id` gets `NOT NULL` back in the three steps from
*Adding `NOT NULL` to a populated table*:
- `0098` checks that the artifact head key is `(community_id,
artifact_id)`, then adds `CHECK (channel_id IS NOT NULL) NOT VALID`.
- `0099` validates the check under `SHARE UPDATE EXCLUSIVE`, so channel
artifact reads and writes continue.
- `0100` sets `NOT NULL` from the validated check (no scan), drops the
check, drops `artifact_heads_live_type`,
`artifact_heads_scoped_identity` and
`artifact_revisions_scoped_identity`, and drops `artifact_heads.scope`,
`artifact_revisions.scope`, `artifact_revisions.community_event`,
`artifact_revisions.redacted` and `communities.artifact_type_policies`.

The primary keys don't change. `0097` never changed them.

## Review checklist (docs/database.md)

- **Phase:** contract. It follows the expand in #9650 (`0097`) and the
code revert in #9689.
- **Required stop:** every relay pod, job and rollback target must run
#9689 (`sha-a406191`) or later before `0100` runs. The chart's upgrade
notes (`deploy/charts/buzz/README.md`) say this, along with how to roll
back with auto-migration off. No tagged relay release contains #9650.
Only rolling images from `eebf62b6` up to, but not including, `a4061916`
are affected. Relays built from #9650 itself read `artifact_heads.scope`
and write with `ON CONFLICT` on `artifact_heads_scoped_identity`.
Releases before #9650 never read these objects.
- **Fails closed:** `0098` refuses a database whose artifact head key is
the scoped key from #9650's removed operator contract script or declared
schema. That database needs the recovery in #9689's Compatibility
section. `0099` fails if any head has a null `channel_id`. Both stop
before any cleanup.
- No trigger, function, procedure, rule or foreign key is added. No
migration changes existing rows.
- Every schema location in Rule 4 is updated: `migrations/` and
`schema/tables/public/` (`artifact_heads.sql`, `artifact_revisions.sql`,
`communities.sql`). No reconcile-script or gateway change applies.
- **Currently deployed relay:** a relay from #9689 or later doesn't use
these objects, and neither does a relay from before #9650. The
populated-table test runs every migration over channel artifact data.
- **Locks:** each migration sets `lock_timeout = '5s'` and
`statement_timeout = '30s'`. No index is built.

## Tests

- `admin_schema_parity_between_desired_state_and_migrations` compares
`artifact_heads`, `artifact_revisions` and `communities` across the
desired-state and migrated paths. It fails without `0100`.
- `populated_artifact_tables_auto_migrate_through_every_migration`
checks that a channel head and revision written before `0097` survive
with the same channel and event.
- `artifact_unexpand_validates_while_channel_heads_are_written`: `0099`
completes while a channel head write is still open. It fails if `0099`
sets `NOT NULL` directly.
- `artifact_unexpand_refuses_scoped_head_key`: `0098` stops on the
scoped key and leaves `0097`'s columns in place.

## What got simpler

The schema loses 5 unused columns and 3 unused indexes.
`artifact_heads.channel_id` is required again, as the channel code
assumes.

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

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
wpfleger96 added a commit that referenced this pull request Nov 19, 2026
…c-spec-mobile

* origin/main:
  fix(mobile): keep glass controls mounted and the wide thread push parallax (#9726)
  fix(mobile): stabilize Duo chat switching and sheet layering (#9717)
  Require relay schema owner review for migrations and schema (#9708)
  fix(relay): resurface a hidden DM when someone else messages it (#9678)
  fix(deploy): pin self-host installs to relay 0.3.0 (#9714)
  fix(mobile): keep open shared sessions in Solo (#9704)
  fix(mobile): align channel indicators and Duo section menus (#9703)
  fix(mobile): allow person mentions in Solo chats (#9705)
  fix(mobile): let code scroll under the code block copy button (#9612)
  Transcribe Bestie hold recordings into text on device (#9645)
  feat(cli): show and search verified identity in users get (#9647)
  fix(mobile): keep agent poster up until the iOS video draws (#9688)
  test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
  Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
  feat(relay): add conditional Solo member role updates (#9667)
  feat(mobile): add saved channel section filters (#8479)
  feat(relay): support community-scoped NIP-AR artifacts (#9650)
  feat(mobile): add a diagnostics test report and test crash to Settings (#9676)
  fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
  feat(mobile): add diagnostic reporting module with crash capture (#9613)

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

# Conflicts:
#	mobile/test/features/activity/activity_page_test.dart
cshtdd added a commit that referenced this pull request Nov 19, 2026
…-workflow-verified-mentions

* 'main' of https://github.com/block/buzz: (21 commits)
  chore: require relay owner review for the relay and db crates (#9728)
  fix(mobile): align Huddle cards and preserve conversation navigation (#9713)
  Match mobile mention chips to desktop styling (#9706)
  feat(relay): push mentions to people outside a listed channel (#9623)
  fix(db): undo migration 0097 (#9710)
  fix(mobile): keep glass controls mounted and the wide thread push parallax (#9726)
  fix(mobile): stabilize Duo chat switching and sheet layering (#9717)
  Require relay schema owner review for migrations and schema (#9708)
  fix(relay): resurface a hidden DM when someone else messages it (#9678)
  fix(deploy): pin self-host installs to relay 0.3.0 (#9714)
  fix(mobile): keep open shared sessions in Solo (#9704)
  fix(mobile): align channel indicators and Duo section menus (#9703)
  fix(mobile): allow person mentions in Solo chats (#9705)
  fix(mobile): let code scroll under the code block copy button (#9612)
  Transcribe Bestie hold recordings into text on device (#9645)
  feat(cli): show and search verified identity in users get (#9647)
  fix(mobile): keep agent poster up until the iOS video draws (#9688)
  test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
  Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
  feat(relay): add conditional Solo member role updates (#9667)
  ...

Signed-off-by: Camilo Sanchez <camilos@squareup.com>
@LordMelkor

Copy link
Copy Markdown
Contributor

🤖 A note for the record, now that this revert has merged. It isn't a request to bring the feature back.

Without community-scoped artifacts, the Mention Groups plugin now keeps a community's groups in one open system channel, at one of eight channel IDs derived from the community's host. That works on today's relay, but a plugin can't stop someone from taking those IDs first:

  • Anyone can take an ID. The relay lets anyone the community admits create a channel at any ID, so a member can create a channel at a derived ID before a community owner or admin does.
  • The client limits the damage. The plugin uses a channel only while its creator (the relay-signed P tag on its kind 39000) and every owner in its kind 39002 are owners or admins in the community's kind 13534 roster. It skips every other channel at those IDs.
  • Two gaps stay open:
    • Someone can take all eight IDs first, and nobody can free one. Only a channel's owner can delete it, community owners and admins have no rights in a channel they aren't in, and a deleted channel keeps its ID. More IDs only raise the cost.
    • If the store channel's creator stops being a community owner or admin, readers skip it with its groups, and the next save starts an empty one.
  • The relay enforces none of these checks. They run only in the client.

Closing either gap needs the relay: for example, data that belongs to the community rather than to a channel, or channel IDs that only community owners and admins can create. The community scope in #9650 had neither gap, because its records belonged to the community.

This branch was successfully deployed

1 active deployment
codex-review — 00d41369 Deployed Nov 19, 2026 by wpfleger96 via Run Codex Security Review #16210
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.

4 participants