Skip to content

feat(server): a member brings a guest in with a share link - #582

Merged
Jacksondr5 merged 2 commits into
j5code/share-3a-project-artifactsfrom
j5code/share-3b-people-and-links
Oct 13, 2026
Merged

Jacksondr5 merged 2 commits into
j5code/share-3a-project-artifactsfrom
j5code/share-3b-people-and-links

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Problem

Nothing can create a guest. PersonAccess can record one, give it grants and tie a session to it, and only tests call it, so no member can bring anyone in (Shared server AC17, AC19, AC20, AC25). This is the server half of #535; the Share dialog and People page are a separate piece.

What changed

People, grants and devices. A new service, People (apps/server/src/j5/sharing/People.ts), and J5 requests over it in packages/contracts/src/j5/sharing.ts:

Request Needs Does
j5.sharing.listPeople access:read every person, their grants, devices and unused links
createGuest, putGrant, removeGrant, removePerson, revokeDevice, createLink, revokeLink access:write what the names say; revokeLink cancels a guest's unused link and refuses a member's pairing link
listOwnGrants, leaveGrant orchestration:read a connection's own grants; a guest gives one up

The manage requests are absent from GUEST_RPC_RULES, so a guest is refused them whatever its session holds, and there is no MCP tool for any of them. leaveGrant has its own rule kind, ownGrant: the target must be exactly a grant the session's own guest holds. A grant keeps the optional line a member writes when sharing (Shared conversations AC6); nothing sends it to an agent yet.

The link. A share link is one of upstream's single-use pairing links with the subject j5:guest, a seven-day life and exactly orchestration:read, orchestration:operate and preview:operate. Which guest it is for is recorded in j5_a2a_guest_link (J5 migration 35), found again by a hash of the credential.

Tying the session to the person. Upstream's EnvironmentAuth.ts calls J5 as one pipe step where it issues a session from a pairing grant. For a guest's link, upstream's sessions.issue and the insert into j5_a2a_person_session run in one transaction, so they commit together or not at all. It issues nothing when the link names no guest, carries any permission outside the three, or sharing is not wired in.

Every path that turns a pairing grant into something:

Path Choice
Browser cookie exchange (createBrowserSession) binds
/oauth/token bearer and DPoP exchange (exchangeBootstrapCredentialForAccessToken) binds, because mobile and desktop clients pair this way; a request for more scopes gets only what the link holds
MCP approval code (consumeMcpApprovalCode) refuses a guest's link. Without this a guest could spend their own link to approve an MCP client with the full toolkit. The link is used up as well as refused, since upstream spends a pairing code before it is checked

Every change publishes. removePerson and revokeDevice go through PersonAccess, which publishes to the feeds already open for that guest, as grant changes do.

Ending a device, however it is ended. Upstream leaves a revoked session's open socket open, and its Connections page ends a session through upstream's own methods. J5's decorator around EnvironmentAuth (layerGatedEnvironmentAuth, a J5 file) now cuts a guest's session loose from its guest before any of upstream's four revoke methods runs, so the guest's open feeds end and its requests find nothing. For a member's session that costs one delete by primary key that matches nothing; "revoke other clients" is one delete for all of them.

A guest's browser that pairs again. Upstream replaces the browser's old session inside its session store, around the four revoke methods. The decorator cuts a guest's old session loose from its guest once upstream has paired the browser, whatever link was opened, so a socket still open on it ends and reads nothing. It is done after pairing succeeds and not before, because upstream replaces the old session only then: a guest's browser that tries a junk or used link keeps its session, its grants and its device row. A session that ends by expiring passes through none of this, as for a member upstream.

A guest is told the server's real name and platform (Jackson, 2026-10-12). The reduced configuration and lifecycle welcome carried the fixed label "Shared server" and a placeholder platform, so a guest of two servers saw two with one name. Upstream's public descriptor at /.well-known/t3/environment already gives both to anyone who can reach the server. Everything else in the reduction is unchanged.

A guest sees the icon a person chose for a project (Jackson, 2026-10-12). The reduced project now carries projectIcon (a named glyph, an emoji or a monogram), which is plain data. A favicon file is still withheld; see the decisions below.

What the settled UI design asks of this layer (design of 2026-10-12, artifacts/share-links-ui-design.md).

  • createLink takes a lifetime: 1h, 24h, 7d (the default) or 30d, and nothing else.
  • renamePerson renames a guest. Every person's name, whoever typed it, is one line of visible characters up to 80: no control characters, line breaks, format, private-use, unassigned or surrogate characters, no square brackets (a name goes inside the bracketed line that tells an agent who wrote a message; parentheses are allowed), and no more than two combining marks in a row.
  • listThreadPeople says who can reach one thread: the guests whose grants cover it, each with their level and every grant that covers it (thread, ancestor or project), and the members. Any member's connection may ask. A guest may ask it of a thread its own grants cover (a thread rule at View) and is told names and levels only: no ids, devices, links, notes or other grants. The server has recorded no name for any member, so a member row carries displayName: null.
  • subscribeThreadPeopleChanges is a count that moves when that answer changes for that connection, under the same rule. For the People page, the plan is a sharing counter on feat(j5): J5's read models follow a change stream, not timers #586's j5.reads.subscribeChanges at the rebase, since that stream is server-wide and a guest is refused it.
  • listOwnGrants no longer tells a guest the line a member wrote about them for the agent.
  • A name belongs to one person on a server (Jackson, 2026-10-13). createGuest, renamePerson and setOwnerName refuse a name another person already has, with PersonNameTakenError ("That name is already in use on this server. Choose another."). Names are compared folded: NFKC, lower-cased, trimmed, whitespace runs made one. Look-alike letters across scripts are not caught. The name is stored and shown as typed. A unique index on the folded name (J5 migration 37) holds it under concurrent writes. Names already recorded are folded by the migration; no release had a way to make a second person, so it does not provide for two people who already share one, and would fail on such a database. Rebased onto j5/main as one commit; the fifteen it replaces are listed in its message. The layers are not to be run separately against a database anyone keeps: migration 37 is here and 36 is in feat(server): one view-only link several people can join a thread with #585, so a database run on this layer alone and then moved to feat(server): one view-only link several people can join a thread with #585 would skip 36. The stack merges as one. A person may re-case their own name, and a name given up or removed is free again.
  • A member's client is told when the people it lists change. j5.reads.subscribeChanges carries a sixth counter, sharing, that moves when a person, a name (the owner's too), a grant, a device or a share link changes. The sharing services notify it after each write, as the Crew stores do. A guest is refused that stream and follows the thread it has open.
  • The owner has a name. setOwnerName { displayName } (access:write) names the person the server belongs to, on the local operator's existing row, under the same rules. listPeople and listThreadPeople return it for the member; a guest of a thread reads it as one of the people on that thread. Until it is set there is none. Every connection that is not a guest's is that one owner today; several named members is set aside (Sharing v2: what was set aside #542).
  • A member's connection is told the owner's name. getConnectionAccess answers { kind: "member", ownerName } (null until set) for a member and { kind: "guest" }, with no name, for a guest. This is one read of the operator's row per member connection, on a request that connection already makes.
  • Sharing waits for the owner's name. createGuest and createLink are refused with OwnerNameRequiredError ("Set your name first, so the people you share with know who you are.") while the owner has none. putGrant for a guest who already exists is not held back.
  • Agents see the owner's name in the address book. The owner's person row in j5_list_participants had display_name: null; it now carries the owner's name once set. No other field of the row and nothing in the tool's description changed, and nothing was added to J5's standing instructions or any envelope (Consider: tell every agent who owns the server, in J5's standing instructions #595). A name_contains filter can now match the owner. For Jackson to read before merge.
  • listPeople marks the asking connection's own row with you: true. Only a member's connection is told of people, and every such connection is the one member there is, so it is the member's row.
  • Migration numbering. The names migration is 37 and sits in this layer; 36 is the layer above. Ids are never renumbered, and the stack merges as one. A database run on this layer alone would skip 36 when the layer above arrived; that affects only a development database made that way.

UI changes

No client code changed for the icon; the page text is one sentence in upstream's web pairing error.

Before After
A signed-in member opens a guest's share link: the pairing page's message before after
A guest's view of a thread in a project whose icon is a chosen emoji: sidebar and thread header before after

Not captured: a monogram or named-glyph icon (same field, same path as the emoji), and mobile, whose pairing never meets this refusal.

Decisions to check

  • The link lasts seven days (upstream's last five minutes), since it is sent to a person to open later. It is single use, and revokeLink cancels it before it is used.
  • Revoking a device does not close its socket. Upstream does not end an open connection when a session is revoked. The socket stays open and empty: its feeds end, its requests are refused, and it cannot reconnect.
  • PersonAccess.bindSession stays, used only by tests. Four test files stand in for upstream's sign-in and bind a session directly; moving them onto real pairing would mean building upstream's real auth in each.
  • Removing a person deletes their record. Nothing a guest does is stored under their id yet. Once guests can send (Shared conversations AC21), removal must keep the name.
  • A member's devices are not listed per person. A session that is not a guest's belongs to no particular member; upstream's client list shows them.
  • No change feed for the people list. A client refetches after its own changes; a guest leaving does not update an open People page.
  • A member who opens a guest's link stays a member, and is told why (Jackson, 2026-10-12). Upstream replaces a browser's session with the one a pairing link pairs. J5's decorator refuses the browser exchange before upstream is called when the browser's previous session is a live one that is not a guest's and the credential is a guest's link, so the link is not used up. The refusal travels as upstream's rejected-credential error with one optional key, pairingRefusal: "guest_link_for_member", beside upstream's own optional dpopFailureReason; reason stays invalid_credential, so a client from before this ignores the key and shows "Invalid pairing token". I chose an optional key over a new reason literal because an older client fails to decode an unknown literal and would show "Primary environment request failed … (HTTP 401)". Mobile is untouched: it pairs through /oauth/token, which carries no earlier session and is never refused this way. A browser with no session costs nothing more; one with a session costs one read of J5's record of guest links.
  • A favicon file is not served by this layer. Upstream's client asks for a favicon by the project's folder, and the link upstream signs for it carries that folder in readable base64. Jackson chose to have J5 serve it (2026-10-12); that is the layer above, feat(server): a guest sees a project's favicon, served by J5 #591. In this layer a project with no chosen icon shows upstream's default to a guest.

Live testing

Run by the builder on an isolated j5-live-test server at 1502675f48 (default flags); the review panel's independent tester re-ran these checks and they held. There is no UI, so requests were sent over a real socket by a script holding a member's session; the link was opened in an incognito browser profile.

  • Live: the link paired the browser as a guest, which saw the one granted thread of about twenty and nothing else. Granting a second thread made it appear in the sidebar without reloading. Removing the first grant took the thread out of the sidebar and moved the open view off it; a second device's open subscribeThread ended with "This is not shared with you on this server". Revoking the browser's device emptied its sidebar, and its cookie stopped signing in (/api/auth/session unauthenticated, ticket request 401); the other device carried on. The guest's own socket was refused listPeople, createGuest, createLink and removePerson, left its own project grant, and was refused leaving a grant it did not hold. A member calling leaveGrant got NotAGuestError. Removing the person ended the remaining device (401) and the unused link (401).
  • Live, after the review round (tip 342180fd4c plus the layer above): a member ran a turn in a new thread through the UI. A guest held that thread's feed open on a real socket. The guest's device was revoked through upstream's own route, POST /api/auth/clients/revoke: the feed ended with the same refusal. The member's next turn reached the member's feed and not the guest's, and the guest could not get a new socket.
  • Live (tip ecf26c205b plus the layer above): signed in as a member, I opened a guest's link in the same browser profile. The page showed "Invalid pairing token. Check the token and try again.", /api/auth/session still reported Manage access, and the same link then paired a second profile as the guest with its one thread.
  • Live (tip efb88efcd8 against the previous tip 5c85445061, --base): the two pairs above. On the new code the member stayed a member and the same link then paired a second profile as the guest, whose sidebar and thread header showed the project's emoji.
  • Live (tip b651c96b83): one browser paired as guest A and read the thread, then paired as guest B. The people list moved the device from A to B, no binding was left for A's session, and A's old cookie got 401.
  • Live (tip 6cd32815e9 under the layers above): a one-hour link expired in 60 minutes; a guest was renamed; a member asking who is on a thread was told ids, names, levels and how each reaches it; the guest asking was told the same without ids, and was refused another thread; its own grants came back as target and level only; its change count stayed at 0 for a grant on another thread and moved to 1 for one on its own.
  • Live (tip 2e9bef4670 under the layers above): the owner was named; a second guest written MARCO, a guest named like the owner and a rename onto the owner's name were each refused; a guest re-cased its own name; a guest of a thread was told the owner's name and no id.
  • Live (tip 704423b494, the whole stack): with the owner unnamed a member's connection was told ownerName: null, and createGuest and createOpenLink were refused with OwnerNameRequiredError; after setOwnerName the connection was told the name and both went through; a guest's connection was told { kind: "guest" } only.
  • Live, after the rebase onto j5/main (commit 3ed8990140, the top of the stack; the pushed tip differs only in one test file's formatting), in headless browsers. A guest's browser, watched for about a minute: it sent j5.crews.listMemberships and j5.fleet.listSpawnedChildren once each, in the same instant as getConnectionAccess, and each was refused once with no retry; it never opened j5.reads.subscribeChanges and sent no inbox, Fleet or proposal read; nothing on screen showed an error. The server's trace agrees (one span each). j5.agentPersonas.getCatalog was also sent once and refused. A member's browser opened the stream and read the inbox count, Fleet and proposals; the sharing counter moved when another connection created a guest; after one Claude Haiku turn in which the agent asked the person a question, inbox moved, the client re-read the count and the sidebar showed 1. No J5 request of the member's failed.
  • Seen in the same pass and not part of this stack: a guest's browser sitting on the new-thread draft keeps asking upstream's vcs.listRefs (8 in a minute) and server.reportClientActivity (7), each refused.
  • By test only: the binding failing mid-pairing, a link with extra permissions, the MCP approval refusal, a member without Manage access, upstream's other three ways of ending a session, cancelling a link.
  • Not exercised live: a live agent turn (the change adds no turn path, and a guest watching a turn was covered by feat(j5): a guest's client reads a thread at the level it was granted #577); mobile and desktop clients pairing with a share link; relay and tunnel connections.

Upstream impact

  • apps/server/src/auth/EnvironmentAuth.ts: 11 lines added, 2 changed (one import, one line in make, one pipe step on each of two sessions.issue calls, one condition in consumeMcpApprovalCode). FORK.md case 70. Approved by Jackson on Share links 1: people, grants, and recognising a guest connection #531, 2026-10-11.
  • apps/server/src/server.ts: 3 lines (one import, one Layer.provideMerge inside case 69's layerAuth). Case 70.
  • packages/contracts/src/environmentHttp.ts: 2 lines (the optional pairingRefusal key and its comment). Case 70. Approved by Jackson, 2026-10-12.
  • apps/server/src/auth/http.ts: 5 lines (one import, a third optional argument and its spread in failEnvironmentAuthInvalid, two lines at the browserSession handler). Case 70.
  • apps/web/src/environments/primary/auth.ts: 6 lines added, 1 changed (an optional field on the rejected-credential error, its message, and one line where the error is made). Case 70.
  • rpc.ts, client.ts and ws.ts are unchanged: the new requests join the group case 69 already merges.
  • Pairing a guest changes what upstream's pairing does: register D33 is extended.

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 — two pairs; no motion
  • Live testing: the section above says what ran live and what did not
  • 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
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md) — server and contracts only. No client calls these yet; agents deliberately cannot. Reverse states exist for each: remove a grant, revoke a device, remove a person, leave
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them — no user docs until there is a screen to describe

Tests: apps/server/src/j5/sharing/People.test.ts runs upstream's real EnvironmentAuth over a real database. The existing tests in apps/server/src/auth/ pass unchanged.

Claude Opus 5.5, Claude Code

🤖 Generated with Claude Code

@Jacksondr5
Jacksondr5 added this pull request to stack #583 October 13, 2026 01:45
@vercel

vercel Bot commented Oct 13, 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 13, 2026 5:53am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 38 billable files and costs up to $9.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 21 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 61 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: ba7854ca-f932-4dcd-bf9c-af9e9084998c
📥 Commits

Reviewing files that changed from the base of the PR and between b5bf3cc and aa21971.

📒 Files selected for processing: 38
  • FORK.md
  • apps/server/src/auth/EnvironmentAuth.ts
  • apps/server/src/auth/http.ts
  • apps/server/src/j5/a2a/AgentCrewProposalService.test.ts
  • apps/server/src/j5/a2a/HumanPersonRegistry.ts
  • apps/server/src/j5/a2a/Migrations.test.ts
  • apps/server/src/j5/a2a/Migrations.ts
  • apps/server/src/j5/a2a/ReadChanges.test.ts
  • apps/server/src/j5/a2a/ReadChanges.ts
  • apps/server/src/j5/a2a/SendService.machine.test.ts
  • apps/server/src/j5/a2a/SendService.ts
  • apps/server/src/j5/a2a/clientReadRpc.test.ts
  • apps/server/src/j5/a2a/contracts.ts
  • apps/server/src/j5/a2a/mcp/handlers.test.ts
  • apps/server/src/j5/a2a/mcp/handlers.ts
  • apps/server/src/j5/a2a/migrations/035_GuestLinks.ts
  • apps/server/src/j5/a2a/migrations/037_PersonNames.test.ts
  • apps/server/src/j5/a2a/migrations/037_PersonNames.ts
  • apps/server/src/j5/sharing/GuestArtifacts.test.ts
  • apps/server/src/j5/sharing/GuestGate.test.ts
  • apps/server/src/j5/sharing/GuestGate.ts
  • apps/server/src/j5/sharing/GuestPairing.ts
  • apps/server/src/j5/sharing/GuestView.test.ts
  • apps/server/src/j5/sharing/GuestView.ts
  • apps/server/src/j5/sharing/People.test.ts
  • apps/server/src/j5/sharing/People.ts
  • apps/server/src/j5/sharing/PersonAccess.test.ts
  • apps/server/src/j5/sharing/PersonAccess.ts
  • apps/server/src/j5/sharing/sharingRpc.ts
  • apps/server/src/j5/wsRpc.ts
  • apps/server/src/server.ts
  • apps/web/src/environments/primary/auth.ts
  • docs/j5/product/upstream.md
  • packages/client-runtime/src/j5/state.test.ts
  • packages/contracts/src/environmentHttp.ts
  • packages/contracts/src/j5.ts
  • packages/contracts/src/j5/clientRpcPermissions.ts
  • packages/contracts/src/j5/sharing.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

One commit for the rebase onto j5/main, in place of these:

- feat(server): a member brings a guest in with a share link
- fix(server): a guest's device ended from upstream's list loses its open connection
- fix(server): a member who opens a guest's link stays a member
- fix(server): a guest is told the server's real name and platform
- feat(server): a guest sees the icon a person chose for a project
- feat(web): the pairing page says why a member's browser was refused a guest's link
- fix(server): a guest's old session is cut loose when its browser pairs again
- feat(server): what the share links UI asks of people, grants and named links
- fix(server): a guest's browser that tries a link that does not work keeps its session
- feat(server): a name belongs to one person on a server, and the owner has one
- feat(server): the people list says which row is the asking connection's own
- feat(server): the owner's name reaches clients and agents, and sharing waits for it
- refactor(server): the names migration no longer provides for people who already share a name

Refs #532

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A name is written inside the bracketed line that tells an agent who a
message is from. A name holding a bracket could make that line read as
two. The one name rule now refuses both brackets, for a guest, a rename,
a self-given name and the owner's name. Parentheses stay allowed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Jacksondr5
Jacksondr5 removed this pull request from stack #583 October 13, 2026 15:20
@Jacksondr5
Jacksondr5 added this pull request to stack #605 October 13, 2026 15:20
@Jacksondr5
Jacksondr5 marked this pull request as ready for review October 13, 2026 20:39
@Jacksondr5
Jacksondr5 merged commit 4dbd862 into j5/main Oct 13, 2026
43 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/share-3b-people-and-links branch October 13, 2026 20:40
Jacksondr5 added a commit that referenced this pull request Nov 23, 2026

This branch was successfully deployed

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

Labels

size:XXL 1,000+ 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