Repository navigation
Separate viewer membership from peer rosters - #4157
bradseiler wants to merge 1 commit into
Conversation
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord reviewed 3f02e56 from source. I recommend landing the viewer-membership fixes and moving the compact reader, browser broker routes and default Tauri command to the PR that wires up discovery. If the core team wants to ship those adapters now, fix the legacy browser fallback in the inline comment.
| const discover = async () => { | ||
| const info = await host.info(signal); | ||
| signal.throwIfAborted(); | ||
| if (!record(info) || info.self !== host.relay) throw invalid(); |
There was a problem hiding this comment.
🤖 A legacy relay can connect to the browser broker with only a NIP-11 pubkey (relay-broker.mjs:348). The new info route drops that key, so this check rejects the relay before an absent descriptor can produce MembershipUnsupported. If the compact reader ships here, carry pubkey through and verify it against the broker's pinned key for the unsupported case. Keep the explicit self check for v1 and add a pubkey-only fallback test.
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Requesting changes for one issue. The viewer-membership change itself looks right.
Blocking: in the browser host, a legacy relay can't be reported as "snapshot unsupported". The broker accepts a relay that identifies itself with only the NIP-11 pubkey (browser-host/relay-broker.mjs:348, self ?? pubkey), but the new /api/relay/membership-info route passes through only self (browser-host/relay-broker.mjs:1308-1311). readMembershipSnapshot then rejects the missing self (src/features/relay/membership-snapshot.ts:316) before it looks at the missing membership_snapshot descriptor. The caller gets invalid-response instead of MembershipUnsupported, so it can't fall back to the legacy read. Nothing calls the reader yet, so this doesn't affect first open today. Either fix works:
- Move the compact reader (the verifier, the broker routes, the
relay_membership_snapshotcommand and its capability grant, and the transport/reader plumbing) into the PR that wires up discovery, so it lands with its first caller. This is the one we'd pick: it keeps this PR to the viewer-membership change, and the reader and its first caller get reviewed together. - Or fix it here: treat a missing or newer
membership_snapshotdescriptor as unsupported before requiringself, keep theselfand pinned-key check for advertised v1 support, and add a broker test with apubkey-only NIP-11 document that expects unsupported and no compact query.
What we checked and found no issues with:
- Every viewer check this PR switches goes through
viewerMember(src/features/relay/membership.ts:81-89), which lets explicit viewer membership win over a retained roster. Discovery sets it from the roster and the channel's denial state (src/features/relay/discovery.ts:418-421,501), so a denied channel with a stale roster no longer counts as joined, andsrc/features/relay/store.ts:496-497picks up the change. Checks that need real peer facts (agent membership, the DM partner, excluding the relay author) still read the roster and fail closed when it's missing. - The snapshot verifier checks the event signature, binds the response to the relay key, viewer, request ID, host, community, exact types and
complete: true, requires sorted unique channel IDs, and recomputes the snapshot ID. We found no way for a partial or replayed response to pass. - The native command goes through the policy-checked relay URL with a host-built filter, so it doesn't widen what the webview can already reach with signed relay HTTP.
jedwards27
left a comment
There was a problem hiding this comment.
🤖
Client accepts relay-signed kind 39008 compact membership snapshots and changes viewer-membership admission. Check desktop and mobile against a relay enforcing membership, including the existing 39002 compatibility path on mobile.
Verdict: COMMENT — recommend request changes for the browser compatibility defect below. Reviewed 9763561d55259ea6ed39998de3aad7f521bd3b31..3f02e564e3482cbdf1e41b2ab9516637d8d68113 (merge-base 1667bf09f5927a6f4736634248ac00a6385a769d). Risk: high: viewer authorization presentation, stale peer rosters, and new signed-snapshot host adapters.
Blocking finding — legacy NIP-11 fallback: browser-host/relay-broker.mjs:345-350 accepts relays advertising their identity through pubkey alone, but the new /membership-info route forwards only self (:1295-1312). src/features/relay/membership-snapshot.ts:313-320 requires info.self to match the pinned relay before it checks whether membership_snapshot is absent. On a supported legacy relay, a compact read therefore fails with invalid-response instead of MembershipUnsupported, preventing the documented legacy fallback. This is latent in the current UI because discovery does not call the compact reader yet; it is nevertheless a broken contract in the new adapter. Author action: move the unused compact reader and browser/native adapters into the follow-up that first wires discovery, or fix unsupported negotiation without weakening the relay-key check for advertised v1 support, and add a pubkey-only broker regression proving unsupported with no compact /query.
Other findings: no additional author-actionable issue established. viewerMember gives explicit viewer evidence precedence over retained peer rosters (src/features/relay/membership.ts:79-90); discovery stamps denial-aware viewer evidence (src/features/relay/discovery.ts:494-503). The channel action and Solo-region paths recheck live eligibility (src/bundled/channels/ChannelsPage.tsx:2762-2780; src/features/channel-navigation/RegionChannelGroup.tsx:59-110). The snapshot reader binds the signed event to viewer, relay, request, host, community, types and completeness (src/features/relay/membership-snapshot.ts:146-267), with native request correlation in src-tauri/src/relay/membership.rs:31-107.
Validation: source review and git diff --check 1667bf09f5927a6f4736634248ac00a6385a769d..3f02e564e3482cbdf1e41b2ab9516637d8d68113 passed on the pinned object; hosted CI run 44843970407 completed at the exact head with 67 successful checks and one skipped Windows-native check. No reviewer-run full package suite or native app/device journey is claimed. The PR description reports macOS launch and first-open/refresh, not revocation/rejoin.
Verification owner: author for the fallback fix/regression; reviewer/tooling for exact-head desktop and mobile relay-enforced compatibility checks before merge. In isolated app/relay state, exercise member → revoke while retaining a stale peer roster → public read-only preview with member actions/composer absent → rejoin/reconnect; also verify private access denial and navigation. On mobile verify the existing 39002 route, not 39008 support. Record relay/client revisions and native evidence. This unrun gate is a confidence gap, not a second code defect.
— :bot: Jude’s code review agent
request changes
Represent viewer membership independently from retained peer rosters. Respect explicit denial across channel actions, navigation, unread state, agent setup, and live eligibility checks while preserving legacy roster fallback. Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz> Co-authored-by: Harrington <91868d0cc0b8144564e350ce0a9e46447f654ad3fe93b23e39fe71314c911781> Signed-off-by: Brad Seiler <seiler@squareup.com>
3f02e56 to
d8ce6aa
Compare
Why
A channel can retain an old peer roster after the viewer loses access. If the channel reappears as a public preview, a link to it can still say “Joined.” An open agent setup can also retain stale membership eligibility.
What
Record whether the viewer belongs to a channel and use that result for viewer-only checks. A public preview can show “Not joined” even when the retained roster still lists the viewer.
How
Discovery derives the viewer’s membership from its existing roster and denial state. Explicit membership evidence takes precedence when the app checks an action or describes a channel link. Hold the background DM page in its test until the assertion has observed the restored pages.
Risk
The change affects membership labels and which actions the client offers. The relay continues to enforce access and writes. Reverting the commit restores the previous client checks.
Testing
Desktop and browser-host validation remains pending. Revoke membership, check that the public preview is read-only and its link says “Not joined,” then verify private access stays denied. Rejoin and reconnect, and verify the link says “Joined” and the composer is available.
Bigger picture
Supersedes #2661 and #2700. The relay already supports compact snapshots (protocol, relay implementation). The app already skips a full channel-list read on a continuous membership replay when no full read is owed (#2203). First load and reconnects that still require discovery use the existing full channel-list read. The compact reader is preserved on a separate local branch for a future change that wires it into discovery.
Generated with Codex