Skip to content

feat(server): a guest's connection reaches only what its grants cover - #561

Merged
Jacksondr5 merged 7 commits into
j5code/share-1-people-grantsfrom
j5code/share-2-guest-filter
Oct 13, 2026
Merged

Jacksondr5 merged 7 commits into
j5code/share-1-people-grantsfrom
j5code/share-2-guest-filter

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Problem

A guest can be recorded and granted a thread (#536), and nothing limits what a guest's connection can read. Upstream's permissions are per connection and server-wide, so a guest holding "view" would see every thread, project and file listing on the server. This is the second of four stacked pieces (#532), and it has to land before anything can make a guest link (#535).

Stacked on #536. Three things described below are changed by #577, the layer above, which merges with this one: the HTTP sidebar snapshot is refused to a guest and its filter removed (a guest's client uses the socket feed), so this stack does not edit orchestration-v2/http.ts; a guest is given a reduced provider list; and a guest may load the attachments of a granted thread's messages.

What changed

A guest is a session whose subject is j5:guest. Everything here starts with that one comparison and leaves any other session exactly as upstream handles it.

  • One gate for HTTP (j5/sharing/GuestGate.ts). Every route and WebSocket upgrade signs in through upstream's EnvironmentAuth; J5 wraps it where server.ts composes it. A guest's session keeps its permissions only on /ws, the sidebar snapshot, and the three thread loads for a thread a grant covers. On every other route it comes back with none, so that route's own check refuses it with upstream's ordinary missing-permission response. No route was edited to add a check.
  • An allow-list for WebSocket requests. A guest may subscribe to a granted thread, read its diffs, search within it, and open the three feeds a client cannot connect without. A request that is not listed is refused whatever it names, so a request upstream adds later is closed to guests until someone lists it.
  • Reduced answers for the three feeds (j5/sharing/GuestView.ts):
    • Configuration: the server's id, version and protocol flags, with placeholder paths, no providers, no addresses and default settings. It is built field by field, so a field upstream adds is left out. Later configuration updates are dropped.
    • Lifecycle: the welcome only, with no host details.
    • Sidebar: only the threads the guest's grants cover, with each thread's worktree path replaced, and each project reduced to its id, title and dates.
  • Grants take effect while connected (Shared server AC10, AC11). A change to a guest's grants restarts that guest's sidebar feed inside the open stream, so the client gets a fresh snapshot without reconnecting.

Upstream files: ws.ts (+14 −5), server.ts (+8 −4), orchestration-v2/http.ts (+4 −1). Recorded as FORK.md case 69 and divergence D33.

Things a reviewer should check

  • A guest's sidebar feed never resumes from a cursor. It always starts from a filtered full snapshot, which is what upstream already answers when a cursor is too old. A replay cannot be filtered correctly without knowing what the client was sent before. Sequence numbers and the completion marker are upstream's own.
  • Thread rows are passed through with one field replaced, not rebuilt field by field. The configuration and project reductions are allow-lists; the thread row is not, because rebuilding it would break the client whenever upstream adds a required field. A path-bearing field upstream adds to a thread row would reach a guest of that thread.
  • A granted thread is shared whole, host paths included. The reduced configuration and sidebar hide the host's paths outside the threads a guest was granted. The thread's own load and stream still carry its real worktree path and its provider sessions' working folders, and its history shows absolute paths in tool calls.
  • Sequence numbers are upstream's own, so gaps in a guest's sidebar feed show that activity is happening on threads it cannot see.
  • Still visible to a guest: the public /.well-known/t3/environment descriptor (real server label and platform); lineage and forkedFrom on a granted thread's row, which can name the id of a thread the guest was not granted; the session cookie name, which contains the server port.
  • A Peer Agent's placement can be written after its thread's first event, so a guest sees a newly spawned agent beneath a granted thread on that thread's next event, not its first.
  • Requests keyed by a folder are refused (Jackson's ruling on Share links 2: a guest views one thread, enforced by the server #532): a guest gets the thread-keyed diffs and not the changed-files panel. The preview browser is refused until Share links: a view guest watches the thread's preview tabs #540.

Verified

  • vp test run apps/server/src/j5/sharing: 32 pass. The feed tests run upstream's real subscribeOrchestrationV2Shell and real HTTP route on real persistence. They cover: a guest's configuration holds no host path, address, account or non-default setting; the sidebar over both transports holds only granted threads, including after changes to an ungranted thread, a new thread and an ungranted project; every item a guest receives is one the member received, in the same order with the same number; a grant given and removed while connected changes the feed and another guest's change does not; a guest with no person recorded gets an empty sidebar; a member gets the same objects back.
  • Hostile requests in GuestGate.test.ts: another thread's id, a thread that does not exist, an unlisted request that names the granted thread, a request name that does not exist yet.
  • On an isolated live-test server with a guest made by hand, driven by curl and a raw WebSocket: the granted thread loaded and an ungranted one returned 403; /api/projects, server.getSettings, the archived sidebar and projects.readFile were refused; the three feeds returned reduced answers with no host strings; a member's same calls returned the full answers.
  • An earlier browser run (report on Share links 2: a guest views one thread, enforced by the server #532) showed the web client connects and renders a thread and its diff with this reduced configuration.

An independent security review (Fable 5.1) tried to break the promise and found one real gap, fixed here: a thread stream a guest already had open kept delivering after its grant was removed. A guest's thread-keyed request now ends, refused as a new one would be, as soon as a grant change leaves the thread out of reach, and stays open through changes that do not. It confirmed that every authenticating route signs in through the two gated functions, that the allowed requests cannot be made to name another thread, and that a member's connection is unchanged.

Not verified: that ending a request in the middleware interrupts a real streaming handler over a socket (the tests use a stand-in handler, and the claim rests on reading how the RPC server wraps a stream into one effect); a browser pass on this exact code; a grant change on a running server, since nothing outside a test can change a grant yet.

Not in this PR

What the client shows a guest: the composer is not read-only yet, and a guest's client keeps polling a few things that are refused (inbox count, Crew proposals). That is the next piece. No guest can exist outside a test until #535.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: before/after screenshots above, and a video for motion or interaction: no UI changes
  • Upstream-owned files: each one is recorded in FORK.md (case text and file-table row) in this PR
  • Upstream product: any change to what upstream's product does has a human decision linked above and a register entry in docs/j5/product/upstream.md: D33; decisions on Share links 1: people, grants, and recognising a guest connection #531 and Share links 2: a guest views one thread, enforced by the server #532 and in docs/j5/worklog/2026-10-09-multi-player-session.md
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md): server only; HTTP and WebSocket both gated; a grant removed takes access away while connected
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them: the definition merged in docs(j5): define members, guests, grants and shared conversations #529; nothing user-visible yet

Refs #532.

Opus 5.5, Claude Code in J5 Code. The first commits and the review are mine; a Peer Agent on Opus 5.5 built the reduced answers and the feed filter; a Peer Agent on GPT-6 Astra did the browser research.

🤖 Generated with Claude Code

Jacksondr5 and others added 4 commits October 11, 2026 17:29
One gate in front of upstream's auth service narrows a guest's
permissions to the routes J5 allows, and one wrapper on the
per-connection RPC check allows a guest only listed requests for
threads a grant covers. Both refuse by default. A member's connection
is untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hat is shared

A guest's client cannot connect without the server configuration, the
lifecycle welcome and the sidebar feed, and each was refused. A guest's
connection now gets all three in a reduced form: the configuration and
welcome name nothing of the host, and the sidebar, over HTTP and over the
feed, holds only the threads the guest's grants cover and their projects.
A grant given or removed while the guest is connected restarts their feed
from a fresh snapshot, so it shows without a reconnect.

A member's connection is answered by upstream's code untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gate's comments named case 65, which the shard weights took first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Oct 12, 2026 10:14pm UTC

Request Review

The guest check ran once, before the handler, so a thread feed or a
streaming search opened while a grant held kept delivering after the
grant was removed. A guest's thread request now runs against the guest's
grants changing: on the first change that leaves the thread out of
reach it ends with the refusal a new request would get.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Jacksondr5
Jacksondr5 added this pull request to stack #575 October 12, 2026 22:02
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels Oct 12, 2026
@Jacksondr5
Jacksondr5 marked this pull request as ready for review October 13, 2026 01:11
@Jacksondr5
Jacksondr5 merged commit ff76293 into j5/main Oct 13, 2026
39 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/share-2-guest-filter branch October 13, 2026 01:11
@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 10 billable files and costs up to $2.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 60 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 4f0f5c46-e7ec-4e83-a915-aa65bbc9ab6c
📥 Commits

Reviewing files that changed from the base of the PR and between 9af7956 and 3fc1eb0.

📒 Files selected for processing (10)
  • FORK.md
  • apps/server/src/j5/sharing/GuestGate.test.ts
  • apps/server/src/j5/sharing/GuestGate.ts
  • apps/server/src/j5/sharing/GuestView.test.ts
  • apps/server/src/j5/sharing/GuestView.ts
  • apps/server/src/j5/sharing/PersonAccess.ts
  • apps/server/src/orchestration-v2/http.ts
  • apps/server/src/server.ts
  • apps/server/src/ws.ts
  • docs/j5/product/upstream.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Jacksondr5 added a commit that referenced this pull request Oct 13, 2026
Rebased onto guest sharing (#536, #561, #577). The guest gate refuses every
J5 read by default; the client now skips them for a connection it knows is a
guest's, as it did for the HTTP reads, and hides the playbook boards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jacksondr5 added a commit that referenced this pull request Oct 13, 2026
* feat(j5): J5's client reads run over WebSocket methods

J5's client reads called J5's own HTTP routes, each with its own
authentication, error shape and "is this route missing" probe. Upstream's
rule is that a small read is a socket query and a large, compressible
payload goes over HTTP.

Fourteen reads move to RPC methods: the Inbox list and open count, Crew
proposals, runtime requests and memberships, the Fleet, spawned children,
the archive preflight, participant identities, the peer list, the three
playbook reads and the artifact list. Their routes are removed. Reading
one artifact's content stays on HTTP, because it can be megabytes.

Part of #506 (step 3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(web): the Artifacts page waits for the socket before listing

The list is read over the socket now, which comes up after the prepared
connection the page waited for, so a direct visit to /artifacts failed as
"not connected" until Try again. Found in live testing.

Review fixes: FORK.md no longer names deleted route files, and says which
views skip an unsupported server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(server): drop an unused import

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(j5): a known guest is sent none of J5's socket reads

Rebased onto guest sharing (#536, #561, #577). The guest gate refuses every
J5 read by default; the client now skips them for a connection it knows is a
guest's, as it did for the HTTP reads, and hides the playbook boards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mobile): the playbook board calls its hooks unconditionally

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 3fc1eb02 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant