Skip to content

feat(relay): support community-scoped NIP-AR artifacts - #9650

Merged
LordMelkor merged 12 commits into
mainfrom
sigil/nip-ar-community-relay
Nov 18, 2026
Merged

LordMelkor merged 12 commits into
mainfrom
sigil/nip-ar-community-relay

Conversation

@LordMelkor

@LordMelkor LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

NIP-AR clients can store community-scoped artifacts and subscribe to live changes for one exact artifact type. Community and channel artifacts share revision and retry semantics and use separate identity scopes. Community owners and admins can choose whether a type accepts edits from all admitted members or only administrators. This PR combines the protocol from #9638 with the relay implementation. Protocol

  • Kind 45010 binds community writes to a signed tenant UUID. Explicit community filters select signed HTTP reads and WebSocket sync. NIP-11 advertises capability after the schema transition.
  • Kind 9034 sets per-type policy using compare-and-set. The relay commits the policy update and audit entry together. Readers fetch the current policy and its revision through the explicit policy view.
  • Kind 9005 redacts a community revision. Relay peers send tenant-scoped change metadata and re-read the authorized head for delivery. This reuses the existing snapshot, bounded buffering, and resync semantics.

Rollout

Migration 0097 expands storage and retains the existing channel write key. Deploy compatible serving backends, deletion executors and operator tools with community scope disabled. Then run the guarded key transition and enable the capability. The resulting rollback floor is the first compatible relay version. Rollout guide

Why each change belongs in the relay or protocol

Change Necessity Minimality
NIP-AR community scope The current protocol gives every artifact a home channel and defines channel-based access. Clients need a shared contract for community identity, admission, reads and moderation to interoperate. NIP-AR.md:9 NIP-AR.md:65 An optional version-1 section reuses the artifact envelope version and revision operations. The channel sections state where their existing rules apply. NIP-AR.md:242
Signed community revisions The validator requires an h tag, and the write path stores an event and mentions for that channel. A client-defined tag cannot establish a different audience on the relay. artifact.rs:122 artifact.rs:196 The existing event kind accepts a mutually exclusive, signed community UUID. HTTP and WebSocket bind it to the resolved tenant at ingest and reuse the revision authentication checks. community_artifact.rs:120 community_artifact.rs:174
Scoped heads and revisions The database key places every artifact in one identity space per community. Only the relay can advance an accepted head atomically across clients. artifact_heads.sql:2 artifact.rs:187 The head and revision ledger gain a scope discriminator. Community revisions keep their signed payload in the ledger and reuse the compare-and-set, replay and tombstone rules. community_artifact.rs:350
Community admission Channel reads check channel visibility and membership. A client can filter its own view but cannot enforce admission for other readers or synchronize delivery with a revocation. artifact_query.rs:65 Explicit community reads and writes share an admission check against current membership, verified delegation and bans. Administrative authority requires a direct role. community_artifact.rs:36
Per-type write policy The administrative scope dispatch has no artifact-policy command. A client preference cannot enforce an edit rule against another client or a concurrent write. ingest.rs:650 One signed admin command sets policy for one exact type using compare-and-set. A bounded map on the existing community row records the policy and revision. A shared lock orders policy changes with writes, and the existing audit chain commits in the same transaction. community_artifact.rs:183 community_artifact.rs:365 community_artifact.rs:189
Signed HTTP reads The artifact endpoint dispatches to the channel store. It cannot return a community head, its history or the authoritative write policy. artifact.rs:70 artifact_query.rs:65 One scope selector on the existing signed endpoint extends the current, history and head views and adds an exact-type policy lookup. Counts and HTTP incremental tokens stay channel-only. artifact.rs:73 artifact_sync.rs:154
Community WebSocket sync The relay requires channel IDs and confirms live interest on those channels. A client cannot register community interest through the existing filter. artifact_sync.rs:51 artifact_sync.rs:440 One exact type selects the community set. The relay reuses subscription ownership, snapshot paging, bounded buffering, EOSE and resync, with a current admission check before delivery. artifact_sync.rs:683 artifact_sync.rs:755 artifact_sync.rs:934
Cross-node delivery Redis routes channel and ordinary global events. A connected client cannot coordinate when peers reread an authorized head. topic.rs:15 One tenant-scoped topic carries the identity, exact type and change cause. Each relay filters its own subscriptions and rereads the authorized head or signals resync. artifact_sync.rs:211 artifact_sync.rs:1039
Ordinary event audience Generic queries and search apply event-store rules. A client cannot enforce who else receives a response from those paths, including on a relay with community writes disabled. event.rs:785 query.rs:329 Community payloads stay in the ledger. Ordinary reads and fan-out enforce the channel boundary, including for rows from older paths. Explicit artifact views enforce community admission. event.rs:7267 event.rs:153
Community redaction The moderation path requires a channel in h. A client delete cannot apply relay moderation to a stored community revision. side_effects.rs:671 The existing moderation kind gains one community-scoped target form for direct owners and admins. Redaction preserves the accepted revision ID and sends affected syncs through the existing resync path. community_artifact.rs:214 community_artifact.rs:609
Community purge The deletion executor retains the community row as a tombstone. Client-side removal cannot clear authoritative policy on that row or prove it was erased. deletion.rs:2448 deletion.rs:3488 The existing purge covers both ledger tables. The tombstone transaction clears the policy map when the column exists, and the absence check verifies it. deletion.rs:2451 deletion.rs:3489
Schema rollout Older writers use the existing two-column conflict target. Clients cannot preserve that write contract during a key change or attest which relay binaries are serving. artifact.rs:196 Migration 0097 adds columns and indexes without a backfill and preserves the old key. A separate guarded SQL operation installs the scoped key after the compatible fleet is in place. The rollout guide documents the sequence and rollback boundary. 0097_community_artifact_expand.sql:7 community-artifact-contract.sql:13 community-artifact-rollout.md:38
NIP-11 and enablement The baseline artifact descriptor supplies neither the tenant UUID nor a signal that the scoped schema is active. Clients cannot infer activation across mixed-version deployments. nip11.rs:478 One optional discovery object advertises the version, canonical tenant UUID and policy limit. The handlers and NIP-11 share the configuration and schema-readiness gate. nip11.rs:482 community_artifact.rs:51

Size

Measured with git diff from 493cb4cc1 to 0b8949f5e. Dedicated test files and changed lines inside Rust #[cfg(test)] items count as tests. Each side of a mixed hunk is classified against its own revision.

Added Removed
Production, including schema and rollout SQL 2,249 117
Tests 1,897 53
Docs 180 8
Standalone runtime probe 397 0
Total 4,723 178

The total includes crates/buzz-relay/examples/community_artifact_probe.rs. The production and test rows exclude it. The probe supports manual mixed-version and feature-disabled checks against a running relay.

Validation

Validated at 0b8949f5e29f5ccf51ec5e2d487f09e2f49bffeb against 493cb4cc1369ff9fdb44ae6c50f18c66d1fb6474.

  • The signed HTTP and WebSocket workflow exercised the old and new channel writers on the expanded schema, the guarded key transition, community snapshot and live sync, policy compare-and-set and replay, tenant binding, scope isolation, and redaction followed by resync. Restarting the relay with community scope disabled after the transition withheld capability advertisement and preserved channel artifact operations.
  • The normal buzz-db suite passed 268 tests, including doctests. All 860 buzz-db PostgreSQL tests passed, including the wide #e read regression from perf(db): stop per-id planning of wide #e reads #9591.
  • The full eight-package PostgreSQL run passed 1,695 of 1,696 tests. handlers::ingest::postgres_tests::reaction_and_deletion_h_must_name_the_target_channel failed while setting up its private-channel fixture. The same fixture failed on the protocol base 27a4c8a86e9e9795bfaf5fe59f35164a6389a9ed.
  • The hosted PostgreSQL run at 686b8445 passed 1,698 of 1,699 tests. The same test was the sole failure on the PR and on main at 493cb4cc13. In both runs, fixture setup returned restricted: not a channel member while storing the private target. test(relay): refresh the author's membership cache after the stray-h private channel insert #9640 fixes the fixture by invalidating the author's membership cache after creating the private channel. Its PostgreSQL run passes the test. PR run 44325182932 · Main run 44254013047 · Fix #9640 · Passing test on #9640
  • just test-unit and just test passed on Linux in separate runs. The commands recorded 6,611 and 7,243 passing test executions, respectively, with overlap between the suites. These runs passed the CLI socket ownership tests and push-gateway fixture that failed during the earlier parallel hook run. Both Tauri Clippy configurations and 3,560 Tauri test executions also passed at this commit.
  • just ci passed Rust formatting, workspace Clippy, and desktop, Tauri, and web checks. It stopped at mobile formatting after the Linux environment failed to resolve pub.dev for the Flutter dependencies.

End-user test

The PR author’s agent ran the app and plugin end to end on Linux against a local relay built at 0b8949f5e. The final browser rerun passed all 15 steps plus the public default-channel case. The native desktop run passed all seven steps it covered.

  • A group saved by the owner appeared in a member’s open Settings without a reload.
  • Changing the write policy to owners and admins made the member’s editor read-only. The relay refused a signed write by that member and preserved the current record.
  • The audit log identified the policy revision as the accepted kind-9034 event ID. The policy change back to everyone used that ID as prev.
  • A second relay with community artifacts disabled advertised no community scope, and the app withheld shared group actions.

End-user test evidence

Supersedes #9646. The reviewed commit is now on an upstream branch.

LordMelkor and others added 5 commits November 17, 2026 21:00
Add a proposed extension to NIP-AR for kind 45010 artifacts scoped to a
whole community instead of a home channel: a signed community tag, an
explicit query scope, a separate identity space, and a per-type write
policy set by community owners and admins through a relay-admin command.
Documentation only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Krish Ray <kray@block.xyz>
…nity

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Krish Ray <kray@block.xyz>
Bind community-scoped artifacts and type policies to the signed tenant.
Reuse NIP-AR revision receipts and exact sync with scoped notifications,
current community admission, and an explicit shape for policy reads.

Expand the head key while preserving old channel writers, then require an
operator step before advertising the new scope. Exercise signed HTTP and
WebSocket behavior, cluster delivery, and both rollout stages.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Krish Ray <kray@block.xyz>
…p-ar-community-relay

* commit 'bc3afbb293244b72cb0b940d3c939ec1a34f1be3':
  [buzz] fix(ci): link relay image indexes to their source (#9637)
  feat(push-gateway): verify Android Key Attestation (#9562)

Signed-off-by: Krish Ray <kray@block.xyz>
…p-ar-community-relay

* commit '493cb4cc1369ff9fdb44ae6c50f18c66d1fb6474':
  perf(db): stop per-id planning of wide #e reads (#9591)

Signed-off-by: Krish Ray <kray@block.xyz>
joahg
joahg previously requested changes Nov 18, 2026

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 Requesting changes for one P1. A human core-team maintainer also needs to review this PR, because it comes from outside the core maintainer group.

What I checked

  • The authorization model holds. Every read, write and 9034/9005 path binds the signed community UUID to the request tenant, admission is rechecked under locks, and owner/admin authority requires a direct role.
  • The ordinary event, search and fan-out paths exclude community payloads.
  • Migration 0097 follows the expand-only rules.
  • I found no auth bypass and no cross-community leak.

P1 (inline): send_initial_set maps every open_community_artifact_snapshot error to restricted:. That includes snapshot-permit timeouts and pool or statement timeouts. A rolling deploy that makes every client re-sync at once would tell most of them that they lost access, and NIP-AR tells a client to discard its active set for the community when that happens. Only a real admission denial should close as restricted. Capacity and timeout errors should close as read-failed, like the channel branch right below.

P2 (inline):

  • schema/tables/public/artifact_heads.sql still declares the legacy primary key. After the contract step, production no longer matches the desired-state source, and a routine reconcile would try to restore that key.
  • Kind 9034 skips the relay-admin write-restriction gate, so a timed-out admin can still change write policy. The comment says this matches the shared gate, but that gate blocks 9030–9033.

P2: history reads don't push #d down to artifact_id. A single-artifact history read therefore scans the JSON of every revision in the community, and the new scoped-identity index goes unused.

P3:

  • Writers take the per-type policy lock exclusively, so all writes to one type serialize community-wide. A shared lock for writers, with the exclusive lock kept for policy commands, would keep the ordering.
  • Redacting the current head strands the artifact identity: create reports the identity as taken, and update needs a prev no one else can see. The spec doesn't describe how a client recovers.

Comment thread schema/tables/public/artifact_heads.sql Resolved
Distinguish admission denial from a transient sync read failure, use the shared administrative write restriction for policy commands, reconcile the desired schema with the contracted key, and constrain history scans by artifact identity.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Krish Ray <kray@block.xyz>
@LordMelkor

LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 The review follow-up is in 686b8445bb2adb02309772e7c145c943b91e3d7e.

  • Community sync closes with restricted: only on admission denial. Snapshot capacity and database errors close with error: sync read failed, so clients can retry.
  • The desired schema declares the scoped primary key. Existing deployments still expand with migration 0097 and run the guarded contract before reconciling the key.
  • Kind 9034 uses the same write-restriction gate as other relay admin commands. The policy transaction also checks timeouts under the admission locks before a write or exact replay.
  • Community history applies #d to the indexed UUID column and preserves exact matching for canonical IDs.

All five regression checks failed on the previous head with only the tests applied. All seven focused checks passed on the follow-up. The full PostgreSQL lane passed 1,698 of 1,699 tests. The sole failure, reaction_and_deletion_h_must_name_the_target_channel, rejected its private-channel fixture during setup. The same failure reproduced on the spec base 27a4c8a.

just test-unit, just test, and the Tauri Clippy and test lane passed on Linux. just ci reached mobile formatting, where the Linux worker could not resolve flutter_lints or reach pub.dev. GitHub started a new security review for this commit.

Writes to the same artifact type serialize on the type lock. Redacting the current head keeps the identity reserved, so a client that lacks the current revision ID cannot supply prev.

Follow-up to brow’s review

The fixes are in f532add8bbb72151be3dd7d9939950eddd6d5c0d (+182/−64 production lines, net +118).

  • One SQL predicate checks the tag-name position after the containment prefilter. The regression publishes a channel artifact with a community tag value while the feature is disabled and verifies HTTP reads, WebSocket REQ and COUNT, both by-ID lookups, search, and moderation previews.
  • Admission takes the community row before member rows and the verified owner before the agent. Policy commands take the community row with FOR NO KEY UPDATE up front. The concurrent test uses a real ownership transfer. PostgreSQL reports deadlock 40P01 on the old head, and both operations complete with the fixed order.
  • Lag in the typed community-signal receiver resyncs community subscriptions. The regression overflows the real Redis-backed receiver and confirms that the existing channel sync delivers its next revision.
  • A live community read that loses admission closes with resync: community access changed. A transient read failure still closes with error: sync read failed.
  • Account content deletion clears community revision payloads for the user and their owned agents within the selected community. It preserves acceptance receipts and the head ID, so a deleted head cannot reveal an older revision. Profile cleanup checks that this stage has finished.

All five regression tests failed for the reported behavior on 686b8445 with only the tests applied. All five pass on the new head. Rust unit tests, Tauri Clippy and tests, formatting, and PostgreSQL test discovery passed. The full PostgreSQL lane passed 1,703 of 1,704. The sole failure is the previously documented private-channel fixture.

On Blox, just test reached service startup on this SHA and exited before running integration tests. Docker could not resolve quay.io to pull quay.io/keycloak/keycloak:26.0, and the service readiness check timed out.

I measured writer-pool load using real PostgreSQL and Redis, a 10-slot writer pool, and 30 sequential writes per subscriber count. The subscription_history metric counted two writer checkouts per subscriber and one per publish for the replay check. These counts exclude the publish transaction itself. At 1, 8, 32, and 64 subscribers, P95 checkout waits were 0.1, 0.5, 8.9, and 20.6 ms. P95 publish-to-all latencies were 3.6, 7.2, 22.5, and 44.3 ms. These isolated measurements used the same live path before the additional deletion and error-classification fixes, without competing chat traffic. The head read and the enqueue admission check remain writer-backed so a lagging replica cannot supply an older revision.

Delivery design and sharing follow-up

Commit Production diff against 493cb4cc13 Change
f532add8 +2,408/−126 Previous draft head
38748fdef +2,399/−126 Removed the example probe and unused helper
4f4cc72a +2,268/−126 −131 net production lines
8288294f +2,299/−220 −63 net production lines

The draft branch includes main at 7cf19b71 through db4242de. Main changed the event store in #9549. The merge was clean and the production diff against that base is +2,299/−220. Main change

The delivery change checks community admission and the stored FI policy within the primary-backed snapshot and each live head read. Denied live admission closes with resync:. Local host-policy invalidation also resyncs affected subscriptions. Socket expiry and revocation still apply. This removes the database check at enqueue, read locks and the artifact-specific idle sweep. An idle subscription can retain a stale set after a missed notification until a relevant signal or socket revocation. NIP-AR

Writer-pool checkouts Community Channel
Completed reconnect 1 1
Live change 1 per affected subscriber 1 per affected subscriber

These counts come from tracing the connection acquisition paths. The two-checkout benchmark above describes the earlier revision. Community reads · Channel reads

The sharing commit reuses snapshot setup, paging and finish, scoped receipt SQL, revision checks, outcome handling, and limits. The channel write keeps its deployed lock key and authorizes the source before comparing prev. The community row serializes policy changes with member writes. A directly admitted agent locks its own roster row and still checks the verified owner's restrictions. Community live reads use the stored head deletion bit and preserve redaction and payload checks. The change signal reuses the parsed envelope. The candidate to pass that envelope into the replay lookup increased production code and was dropped.

Test changes

  • Removed revoked_live_head_never_emits_after_committed_removal and idle_sync_credential_revocation_uses_node_wide_backstop, which asserted the retired delivery checks.
  • Replaced read_guard_serializes_committed_revocation with community_snapshot_capacity_and_new_reads_use_current_admission. Replaced cluster_global_artifact_admission_and_owner_transfer_both_finish with cluster_global_community_artifact_snapshot_can_open_during_ownership_transfer. The old read-lock ordering exercise became moot when reads stopped taking those locks.
  • Replaced revoked_initial_snapshot_never_emits_payload_or_eose_after_output_wait with socket_revocation_or_local_policy_change_stops_initial_snapshot. It covers socket revocation, local FI policy invalidation, and an attempt to reopen before the socket sweep. Renamed the two-node test to two_nodes_resync_matching_community_artifacts_on_redaction and removed its idle-sweep assertions.
  • Updated owner_restrictions_and_roster_fallback_remain_separate_after_direct_auth to exercise a live signal. Updated principal setup in community_sync_retries_after_snapshot_capacity_is_exhausted and user_deletion_erases_community_artifact_payloads_without_resurrecting_heads. The signal-lag and live-admission-denial regressions are unchanged. The tag-value regression only changed to a borrowed slice for Clippy.
  • Reworked the policy race as cluster_global_member_write_waits_for_admins_policy_commit. Added direct_artifact_write_does_not_wait_for_delegated_roster_row, which failed with the expected lock wait on f532add8 and passed on 8288294f. Existing channel tests kept their source and assertions.

Validation on db4242de

The merged head passed formatting, all four focused sharing checks, PostgreSQL test discovery, just clippy, just test-unit, and Tauri Clippy and tests. The full PostgreSQL suite passed 1,703 of 1,704 tests, including the existing channel tests in its scope. Its sole failure was reaction_and_deletion_h_must_name_the_target_channel, the same private-channel fixture failure on the base and addressed in #9640. The standalone delivery commit 4f4cc72a passed all 12 focused checks on Linux. Base CI · Fix

On db4242de, the full Blox just test ran against Compose PostgreSQL and Redis. buzz-auth and workspace integration passed. The overall command exited 1 because catalog::tests::v2_discovery_degrades_a_stalled_secondary_catalog exceeded its 40 ms budget in buzz-agent (549 passed, one failed, one ignored). The full rerun on the same SHA exited 0 at 18:54:50 UTC with RUST_TEST_THREADS=5. The catalog test passed. Both buzz-auth and workspace integration ran against Compose PostgreSQL and Redis and passed. The pre-merge run on 8288294f passed workspace integration and exited 1 because a buzz-agent catalog test exceeded its 40 ms request budget. That test passed in the separate just test-unit run, and its source and implementation are untouched by this PR. Hosted PostgreSQL on db4242de independently passed 1,703 of 1,704 tests. Its sole failure was the same known private-channel fixture documented above. Hosted PostgreSQL

Hosted Rust Lint and Windows Rust also passed on db4242de. Rust Lint · Windows Rust Hosted CI

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 Re-reviewed at 686b844. The fixes for every point in my last review hold up:

  • P1, snapshot errors: send_initial_set now closes with restricted: only on DbError::AccessDenied. Other errors are logged by kind and close with READ_FAILED, the same as the channel branch.
  • Desired-state key: artifact_heads.sql now declares PRIMARY KEY (community_id, scope, artifact_id). The new migration test runs the guarded contract script and asserts that pgschema plans no artifact_heads changes afterwards.
  • Kind 9034: the handler calls enforce_write_restriction, and the store refuses timed_out under the admission locks, exact retries included.
  • History #d: the filter now uses the indexed r.artifact_id with canonical UUIDs only, so non-canonical spellings still can't match. The EXPLAIN test covers it.

On the P3s, keeping writes serialized on the type lock and reserving the identity after redaction are reasonable maintainer calls, and I'm not pushing on them.

This is a comment, not an approval. The PR comes from outside the core maintainer group, so a human maintainer needs to review it before it merges. I'm dismissing my earlier change request because its blocking point is fixed.

@joahg
joahg dismissed their stale review November 18, 2026 14:41

🤖 The blocking point (snapshot errors closing as restricted) is fixed in 686b844; see the follow-up review.

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

🤖 The pre-review recommends rework. Three problems reach existing behavior:

  1. The new tags @> '[["community"]]' exclusions match any tag whose value is community, not only a tag named community. A channel artifact with, for example, the title community therefore disappears from artifact reads, REQ, count, by-id, search and moderation previews, even with community artifacts disabled.
  2. Community admission takes relay_members rows FOR SHARE before the communities row, and an agent's row before its owner's. That is the reverse of ownership transfer and cascading member removal, so with the feature enabled those operations can deadlock with artifact reads and writes and be aborted.
  3. The community-signal consumer handles a lagged receiver with resync_all, which also closes every channel-scope artifact sync on the node and forces full snapshot downloads.

To resolve them: check the tag name positionally at every new exclusion (keeping the containment test as a prefilter), with a test for a channel artifact carrying that value. Align the admission lock order with the existing membership writers. Resync only community-interest syncs on signal lag.

@LordMelkor
LordMelkor marked this pull request as draft November 18, 2026 16:33
LordMelkor and others added 5 commits November 18, 2026 11:41
Share the positional tag exclusion, take admission locks in membership writer order, scope signal-lag recovery, resync on live admission loss, and erase account-owned community revision payloads while preserving their acceptance receipts.

Co-authored-by: Codex <codex@openai.com>

Signed-off-by: Krish Ray <kray@block.xyz>
Keep the manual probe on a local branch and remove an unused ArtifactScope accessor.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Krish Ray <kray@block.xyz>
Remove the database enqueue check and artifact-specific idle sweep. Preserve socket credential checks and retire local syncs on host policy invalidation.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Krish Ray <kray@block.xyz>
Keep channel source authorization and lock identity. Use the stored deletion state for community live reads, and serialize policy updates on the community row. Only the roster row supplying authority needs a member lock.

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Krish Ray <kray@block.xyz>
* commit '7cf19b713c506b6ce2af72897d23ec1c5c147390':
  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)
  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)

Signed-off-by: Krish Ray <kray@block.xyz>
@LordMelkor
LordMelkor requested a review from brow November 18, 2026 19:47
@LordMelkor
LordMelkor marked this pull request as ready for review November 18, 2026 23:10
@LordMelkor
LordMelkor merged commit eebf62b into main Nov 18, 2026
97 of 98 checks passed
@LordMelkor
LordMelkor deleted the sigil/nip-ar-community-relay branch November 18, 2026 23:57
wpfleger96 added a commit that referenced this pull request Nov 19, 2026
…voke

* origin/main:
  feat(mobile): add saved channel section filters (#8479)
  feat(relay): support community-scoped NIP-AR artifacts (#9650)

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
wpfleger96 added a commit that referenced this pull request Nov 19, 2026
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 added a commit that referenced this pull request Nov 19, 2026
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.

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
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

This branch was successfully deployed

No deployments
codex-review — 3cc3b3f8 Deployed Nov 18, 2026 by LordMelkor via Run Codex Security Review #16151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants