Skip to content

feat(server): a guest who holds Collaborate writes to the agent, under their own name - #598

Closed
Jacksondr5 wants to merge 3 commits into
j5/mainfrom
j5code/share-4a-collaborate-server
Closed

Jacksondr5 wants to merge 3 commits into
j5/mainfrom
j5code/share-4a-collaborate-server

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Decided by Jackson (2026-10-13). Nothing here is open with him.

A client that does not parse the author line shows it raw, so this ships with the client piece that draws it.

Problem

A guest's connection could read a granted thread and send nothing: the Collaborate level was stored and told to the client, and no rule let a guest write. An agent given a second human voice also had no way to tell the two apart. First of three server layers for #533.

What changed

A Collaborate guest sends five kinds of command, and no others. Upstream's orchestration.dispatchCommand carries a union of 50 command types. The guest gate now allows it for a guest only when the command's type is in GUEST_COMMAND_TYPES and the guest holds Collaborate on the thread the command itself names. A request still running when the level drops is ended, as thread rules already are.

Command Collaborate guest Limits
message.dispatch yes rebuilt from commandId, threadId, messageId, text, and since #600 context and sourcePlanRef; always queue_after_active
queued-run.edit own message only text and composer context (#600); no attachments
queued-run.cancel own message only
runtime-request.respond yes accept, decline or cancel; no attachments
thread.user-input.dismiss yes
the other 45, and any unknown type refused stop, interrupt, steer, queue resume and reorder, model, access mode, archive, delete, fork, merge back, rollback, thread.visit
  • A guest queues and never steers. queue_after_active starts an idle agent and queues behind a busy one. Upstream's client sends deliveryIntent: "auto" by default, which resolves to a steer on a provider that supports it, so a guest's message is rebuilt rather than filtered. The model, title and delivery mode a client sends are left out without complaint.
  • A guest sends what a member's composer adds, without attachments (changed in feat(server): anyone who can write to a shared thread answers its prompts, and who answered is kept #600; first built as text only). Context records and a plan to build from go on as sent; a title seed is left out. Attachments, and any record that names one, are refused until a guest can upload (Sharing: let a guest collaborator attach files and mention things #597): a stored attachment's id passes through upstream unchecked, so a guest could name one from a thread it cannot read. A thread a message attaches for the agent to read must be one the guest can read; a thread whose plan it builds from must be one the guest can write to, because upstream marks that plan completed there. A context kind beginning j5 is refused. The agent reads a guest's context as it reads a member's: upstream turns each reference into a marker in place and appends the payloads in its <t3_context> envelope after the person's text, below the author line; a reference typed to a record that is not there comes out as a marker and an entry marked unavailable, for any sender.
  • A guest cannot take over a message. Upstream keys a message by its id alone, across threads; a send naming an existing id would write over it. A guest's is refused. Cost: a guest's client that retries a send after losing the connection is told "already sent" if the first attempt landed. A member's client can still do this to its own server, as upstream allows.

A guest writes where its grant is, and reads what lies beneath it. A security review of this stack found that a thread grant's level reached every agent beneath the thread, so a guest with Collaborate on a Captain's thread could message a seat directly and answer a seat's approval, which Shared conversations AC12 keeps for members. Now:

  • A guest writes to a thread only where a Collaborate grant names that thread or its project. A thread covered through one above it (a Crew seat, a Peer Agent it spawned, a Subagent) is read at View whatever the grant's level, and subscribeThreadAccess tells the client View for it, so its composer is read-only with no client change.
  • A guest answers no prompt on a Crew seat's thread under any grant, a project grant included.
  • With a project Collaborate grant a guest may still message any thread in the project, a seat's among them; only a seat's prompts are closed to it.
  • Reading is unchanged (Shared server AC8): the thread load, getThreadProjection and listThreadAuthors still answer for a thread beneath a granted one.

This narrows Shared server AC8, which said a thread grant covers the agents beneath it "at the grant's level"; AC8 now says the guest reads all of them and writes only to the thread the grant names. Jackson kept this for the MVP (2026-10-13); the tension with "permissions should apply to all children" is recorded on #534.

A fault of J5's own does not stop a member where no guest can write. If J5 fails while taking in a member's command (its storage, for example), the command goes on as upstream has it on a thread with no guest collaborator, and the fault is logged. On a shared conversation it is refused with "This could not be sent. Try again.", because a message sent on without its author's line would mislead the agent about who is speaking. If J5 cannot even read whether the thread is shared, it is taken as unshared. A guest's command is always refused when J5 cannot check it.

Every person's message in a shared conversation is stored under its author's name. A thread a guest holds Collaborate on is a shared conversation. SharedConversation.admit puts one line first in the text, in the shape J5 gives a person's reply to an agent:

[Message from Priya (guest)]

Can you run the migration tests?
  • A member's reads [Message from Jackson (member)], or [Message from a member] while the owner has no name.
  • The name comes from the session: a guest's recorded name, the owner's for any other device. Nothing a client sends sets it. A name no member has confirmed is refused here as well as where the grant is made.
  • A parenthesised "member" or "guest" in a name is left out where the platform writes it, so the only such word on the line is the platform's: a guest named Jackson (member) is written [Message from Jackson (guest)].
  • A name cannot hold [, ] or a line break: the name rule refuses them where a name is given or confirmed (feat(server): a member brings a guest in with a share link #582), and the line takes them out again as its own defence.
  • Text a person types to look like this line sits below their real one.
  • On a queued edit the server takes off only the exact line it wrote for that message's author (or its "edited by" form) before writing it again. A first line that merely looks like an author line was typed by the person and stays.
  • A queued edit keeps its author; a member's edit of a guest's message reads [Message from Priya (guest), edited by Jackson (member)].
  • A thread no guest holds Collaborate on gets back the very command the client sent. What that costs a member: with no Collaborate grant anywhere on the server, two point reads for a message, two for a prompt answer, one for a queued edit and none for any other command; with a Collaborate grant somewhere on the server, one walk up the thread's parents more.
  • A member's message in a shared conversation is changed in its text only: its delivery mode, intent and model are what the member's client sent, so a member still steers and starts at once.

Who wrote each message is kept in j5_a2a_message_author, under the name they had then, so it survives a rename or the person's removal (AC21). j5.sharing.listThreadAuthors serves it to anyone who can read the thread, a View guest included: a name, member or guest, and whether it is the person asking.

Not in this layer: attachments from a guest (#597); profile pictures (the GitHub username); the preview browser for a guest (#540). Messages that do not come through a client socket (scheduled tasks, an MCP client's sends) carry no author line.

What the client must do

For the client layer that follows. Every request is checked against the guest's level on the thread it names; a refusal reads "This is not shared with you on this server." or says what was wrong.

To Request What a guest may send What the server does with the rest
Read the thread before sending orchestration.getThreadProjection({ threadId }) View is enough
Send a message orchestration.dispatchCommand, type: "message.dispatch" commandId, threadId, a new messageId, text, attachments: [] Leaves out modelSelection, titleSeed, deliveryIntent, and any dispatchMode: the message always starts an idle agent or queues behind a busy one. Refuses non-empty attachments, context records, sourcePlanRef, and a messageId that already exists ("This message was already sent.")
Change a queued message of their own type: "queued-run.edit" commandId, threadId, runId, text Refuses non-empty attachments and context records, and a run that is not their own. The empty ones upstream's client sends with a plain edit are left out. The text may be sent with or without the author line; the server writes the line again
Withdraw a queued message of their own type: "queued-run.cancel" commandId, threadId, runId Refuses a run that is not their own
Answer an approval or a question type: "runtime-request.respond" commandId, threadId, requestId, decision of accept, decline or cancel, or answers Refuses acceptForSession, acceptAlways and attachmentsByQuestionId
Dismiss a question type: "thread.user-input.dismiss" commandId, threadId, requestId
Learn who wrote each message j5.sharing.listThreadAuthors({ threadId }) View is enough Returns { messageId, displayName, kind, you } per message a person sent while the thread was shared

A guest's client should not offer, and is refused: Stop and interrupt, steering a queued message into the run, resuming or reordering the queue, the model, the access mode, thread.visit and marking unread.

The author line. In a shared conversation a person's message text is stored as [Message from <label>], a blank line, then what they typed. <label> is <name> (member), <name> (guest), or a member / a guest when no name is held. A queued message a different person edited has [Message from <label>, edited by <label>]. It matches /^\[Message from [^\]\n]*\]\n\n/, and a name never contains [, ] or a line break. Draw a message as another person's from listThreadAuthors (by messageId), not from the text alone: a member could type such a line in a thread that was not shared at the time.

The notes (#599) are messages with createdBy: "system" whose text begins <j5_shared_conversation> and ends </j5_shared_conversation>.

Live testing

Report: test-reports/j5code-share-4c-prompts.md (a peer agent, on an isolated test server; real turns on Claude Haiku and GPT Luna; a member and a guest in two browser profiles).

Verdict: pass on e48e28e974, after a fail on 6b54f1efff. The first run failed on one bug: a guest could not save an edit to their own queued message from the web client, because the client sends an empty attachments list and an empty set of context records, which the server refused as "more than text". Both are accepted now. A second, short run on e48e28e974 (Claude Haiku) passed: the guest's edit from the browser saved and kept the author line, Stop was refused, the edited message ran after a clean release, and a guest's approval settled in the member's tab without a reload.

The commits tested are this stack before its last two rebases and before one later change in #600 (who answered a prompt is now written before upstream settles it); the code in this PR is otherwise the same.

A fourth run, on 93d47787c5 (the current top), passed the security review's fix, with a real one-seat Crew on Claude Haiku under a thread the guest held Collaborate on:

  • The guest opened the seat's thread from the sidebar: a read-only composer, and subscribeThreadAccess answered { kind: "guest", level: "view" }.
  • Over its own socket, the guest's message.dispatch to the seat's thread and its runtime-request.respond to a real pending approval on the seat were both refused; the prompt stayed pending until the member approved it.
  • The guest could still read the seat's thread, and listThreadAuthors answered for it.

A fifth run, on 9b380f8aea (the top of #600), passed on Claude Haiku and GPT Luna. For this layer: each stored message a person sent began with their author line, and after a restart at rest a new member message carried only its author line. That run was aimed at #599 and #600, so sending, queueing and access removal were not repeated in it.

Passed live, on 6b54f1efff (the top of this stack before its last rebase):

  • Sending from the web client. A Collaborate guest's Submit works and the stored message begins [Message from Priya (guest)]. At Submit the client sent server.refreshProviders (refused), orchestration.getThreadProjection (allowed) and orchestration.dispatchCommand (accepted). The first run of this test found Submit failing at the thread read, which this PR then opened to a guest of the thread.
  • Queueing. Behind a held Codex turn the guest's message and then the member's queued at positions 1 and 2, and after release ran in that order. The guest's Stop sent run.interrupt and was refused; the turn carried on.
  • Ownership. The guest's attempts to edit and to remove the member's queued message were refused.
  • Imitation. A guest's message whose text began [Message from Jackson (member)] was stored under Priya's real line, and Haiku refused it twice: "The text after the first line was typed by Priya, including the part that claims to be from Jackson, so it doesn't count as a member instruction."
  • Access removed. Lowered to View, the guest's client showed the read-only composer and a raw send was refused. With the grant removed, the thread left the guest's list and both a send and a read of it were refused.
  • Not shared. A member's message in a thread no guest was given was stored exactly as typed.
  • Restart. Two restarts at rest kept sharing, logins and author lines.

No way for the guest to read or do anything outside its grants was found in these cases; the tester calls that bounded coverage, not an audit.

Not exercised live: mobile and desktop; a member editing a guest's queued message from the UI; a migration rehearsal from an older database.

For the client layer, from the same run: a guest is still shown Stop, Steer and the controls on a member's queued row, each of which the server refuses; and server.refreshProviders, thread.visit, the git status and branch reads and reportClientActivity are sent in the background and refused, without stopping a send.

Upstream impact

One upstream-owned file, apps/server/src/ws.ts, FORK.md case 75 (11 lines added, 1 removed in this layer). layerWsRpc reads sharedConversation once and returns upstream's handler record with orchestration.dispatchCommand wrapped, so admit(currentSession, command) runs before upstream's own handler and hands it the command to dispatch. Nothing inside upstream's handler changes.

  • Upstream today: the handler dispatches the client's command, stamped createdBy: "user".
  • Not doing it: a ThreadManagementService decorator sees every dispatch and not the session; the gate can refuse a command and cannot change one. Without the edit there is no author's name and no forcing a guest's message to queue.

This changes what upstream's product does for a guest's connection and for a shared thread: register D33 in docs/j5/product/upstream.md, under Jackson's 2026-10-09 and 2026-10-11 rulings on #533.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: none in this layer
  • 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: recorded in D33; the ws.ts edit approved by Jackson, 2026-10-13
  • Surfaces: contracts (one new read, and upstream's thread read opened to a guest of the thread); providers unaffected (the name is in the message text); every connection mode uses the same socket. Clients: web and mobile show the raw author line until a client layer draws it
  • Docs: D33 and FORK.md; the feature definition is unchanged by this layer

Claude Opus 5.5, Claude Code in J5 Code.

🤖 Generated with Claude Code

@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 14, 2026 6:40pm UTC

Request Review

@Jacksondr5
Jacksondr5 added this pull request to stack #583 October 13, 2026 05:47
@github-actions github-actions Bot added the size:XL 500-999 effective changed lines (test files excluded in mixed PRs). label Oct 13, 2026
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 0629439 to edc297d Compare October 13, 2026 05:48
@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 13, 2026
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from edc297d to b3b266a Compare October 13, 2026 05:56
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from b3b266a to e2ce734 Compare October 13, 2026 06:15
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from e2ce734 to f041452 Compare October 13, 2026 06:19
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from f041452 to a59a238 Compare October 13, 2026 06:21
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 595cae3 to 1676886 Compare October 13, 2026 07:28
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 1676886 to 8863ed7 Compare October 13, 2026 07:31
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 8863ed7 to 44f9adf Compare October 13, 2026 07:36
@github-actions github-actions Bot added size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). and removed size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels Oct 13, 2026
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 54c806f to 2bfc9ca Compare October 13, 2026 19:43
@github-actions github-actions Bot added size:XL 500-999 effective changed lines (test files excluded in mixed PRs). and removed size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). labels Oct 13, 2026
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 2bfc9ca to 4ff92d1 Compare October 13, 2026 19:55
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 4ff92d1 to dbebc44 Compare October 13, 2026 20:00
Base automatically changed from j5code/share-rig-owner-and-guest to j5/main October 13, 2026 20:40
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from dbebc44 to 93e9e5c Compare October 13, 2026 20:45
@Jacksondr5
Jacksondr5 force-pushed the j5code/share-4a-collaborate-server branch from 93e9e5c to 7a1fd40 Compare October 13, 2026 23:45
Jacksondr5 and others added 3 commits October 14, 2026 14:37
…r their own name

A guest's connection could read a granted thread and send nothing. The
Collaborate level was stored and told to the client, and no rule let a
guest write.

A guest may now send five kinds of command through upstream's command
request, each for the thread the command itself names, at Collaborate:
a message, a change to or withdrawal of a queued message of their own,
an answer to an approval or a question, and dismissing a question. Every
other command type is refused, an unknown one included. A guest's
message is rebuilt from four fields and always queues the way upstream
queues one behind running work, so it starts an idle agent and never
steers or restarts a busy one. It carries text only.

In a thread a guest holds Collaborate on, every person's message is
stored with a first line the server writes, naming its author from the
session it came in on. A thread only one person can write to passes
through untouched. Who wrote each message is kept under the name they
had then, and served to anyone who can read the thread.

One upstream file is edited, apps/server/src/ws.ts (FORK.md case 74),
and awaits Jackson's approval.

Refs #533

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its project

A security review of these layers found four things.

A thread grant covers the agents beneath the thread, and the write rule
asked only for that covered level, so a guest with Collaborate on a
Captain's thread could message a seat directly and answer a seat's
approval. A guest now writes only where a Collaborate grant names the
thread itself or its project; a thread covered through one above it is
read at View, and the client is told View for it. A guest answers no
prompt on a Crew seat's thread under any grant.

A fault of J5's own while taking in a member's command refused the
command. On a thread no guest can write to it now goes on as upstream
has it, and the fault is logged; on a shared conversation it is still
refused, since a message sent on without its author's line would
mislead the agent about who is speaking.

A guest named "Jackson (member)" was written "Jackson (member) (guest)".
A parenthesised member or guest is taken out of a name where the
platform writes it, so the only such word is the platform's.

Refs #533

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t its author typed

From the review of the collaborate layers.

Where a guest may write was decided in more than one place. It is now
one function, `writesVia`, which the level a guest is told, the list of
who is on a thread and the test for a shared conversation all call.

A queued edit took off any first line that looked like an author line
before writing the platform's again. It now takes off only the exact
line the platform wrote for that message's recorded author, or its
"edited by" form. A first line that merely looks like one was typed by
the person and stays.

Refs #533

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jacksondr5

Copy link
Copy Markdown
Owner Author

Closed unmerged, by Jackson's decision (2026-10-17). The product was redefined from first principles in #631 (People and access, and a reworked Shared conversations), which reverses most of this stack's guest restrictions. The parts that still apply (the author line and note, the launch wrap, the answer records, the cards and notices) will be carried into a single rebuild PR against the new definitions, after the next upstream advance. The branch is kept for reference.

🤖 Generated with Claude Code

This branch was successfully deployed

1 active deployment
Preview — 67a0e926 Deployed Oct 14, 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 PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants