Skip to content
Closed
2 changes: 1 addition & 1 deletion FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ migrations after upstream migrations.
72. Settings › People, and a project's Sharing section ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#541](https://github.com/Jacksondr5/j5code/issues/541), register D33, Jackson's 2026-10-12 design and approval of the Settings navigation and route registration). The page (`apps/web/src/j5/sharing/PeoplePage.tsx`) and everything it draws are J5-owned; `apps/web/src/routes/settings.people.tsx` is a J5-owned route file in upstream's routes folder, the shape of `settings.skills.tsx` (case 42), and `routeTree.gen.ts` regenerates with it. Registering a settings section takes upstream's own tables, each one entry: in `apps/web/src/components/settings/settingsSearch.ts` the `SettingsPath` union, `SETTINGS_SECTION_LABELS` (after Connections, which sets the sidebar order), `SETTINGS_CATEGORY_SCOPES` (`"connections"`, the page is about the primary server as Connections is) and one search item, `people`; in `SettingsSidebarNav.tsx` the icon map (`UsersIcon`) and one more condition in the nav filter, `item.to !== "/settings/people" || canSeePeople`, with `useCanSeePeople()` from J5-owned `j5/sharing/peopleAccess.ts` (the primary connection holds `access:read`, which a guest's never does); in `SettingsScopeSentence.tsx` one line adding the path to `SETTINGS_DEVICE_ONLY_PATHS`, so the page shows no project-and-environment picker, as Connections shows none. `apps/web/src/components/settings/ProjectSettingsPanel.tsx` gains one import and one mount, `<ProjectSharingSettings projects={group.memberProjects} />`, above the Danger section; `ProjectSettingsPanel.test.tsx` mocks that one module (two lines), because the test replaces the connection runtime with `undefined` and J5's sharing commands are made from it when their module loads. The palette entry "Open People" joins case 71's hook with no further upstream edit. On a pin advance: if upstream reshapes how a settings section is declared, re-register People after Connections; if upstream adds a settings page of its own for people or access, read D33 before keeping J5's.
73. A shared thread says who is on it, and a guest's client fits what a guest can do ([#535](https://github.com/Jacksondr5/j5code/issues/535), [#541](https://github.com/Jacksondr5/j5code/issues/541), register D33, Jackson's 2026-10-12 design and approval of one mount or item in each of these files). All of it is J5-owned code under `apps/web/src/j5/sharing/`, mounted once in each upstream file. `apps/web/src/components/chat/ChatHeader.tsx`: one import and `<ThreadPeopleChip … />` after the breadcrumb, for a server thread; it draws nothing unless a guest holds a grant on the thread or its project. `apps/web/src/components/chat/ThreadDetailsPanel.tsx`: one import and `<ThreadPeopleSection … />` after `ThreadRelationshipsPanel`, under the same `density === "full" && !props.draftId` condition as its neighbours; it uses upstream's exported `ThreadDetailsSection`. `apps/web/src/components/chat/ChatComposer.tsx`: one import, one hook call after the props are read (`useViewOnlyComposerProps(environmentId, canOperateThread)`), and one spread, `{...viewOnlyComposerProps}`, placed after upstream's `placeholder={…}` prop so that it replaces the placeholder for a guest whose level on the thread is View and is empty for everyone else; a first branch in upstream's nested ternary would have re-indented all of it. The composer collapsed to one line on a narrow window has its own fallback text, `"Ask anything..."`, a few hundred lines above; that literal becomes `(viewOnlyComposerProps.placeholder ?? "Ask anything...")` (one line and a comment). A guest's thread menu needs no further upstream line: case 71's two calls in `useThreadActionMenu.ts` and `Sidebar.tsx` now drop Archive, Delete, "Project settings" and "Share thread…" for a guest and put "Leave thread" where Archive was (`j5/sharing/sharingMenu.ts`, told who is a guest by `guestAccess.ts` so that it still imports nothing of the connection runtime). The chip and the section ask the server who reaches the thread (`j5.sharing.listThreadPeople`) and ask again when its counter moves (`j5.sharing.subscribeThreadPeopleChanges`); that stream joins `EnvironmentSubscriptionRpcTag` in `packages/client-runtime/src/rpc/client.ts`, one more line beside case 69's `subscribeThreadAccess`. Two route files carry the guest's way in (Jackson's 2026-10-13 approval). `apps/web/src/routes/pair.tsx`: the import of upstream's `PairingRouteSurface` becomes an import of J5's `GuestAwarePairingSurface`, and the JSX tag changes with it (three lines; the props are the same and upstream's `components/auth/PairingRouteSurface.tsx` is not edited). J5's surface asks `POST /api/j5/sharing/describe` what the link opens, without spending it, only for a link that carries J5's mark, and waits up to five seconds for the answer. Everything else gets upstream's surface with the props it was given: no token, and any link without the mark, at once and with no request made about it (an ordinary pairing token is sent nowhere but upstream's own exchange); a marked link when the server cannot be asked or does not answer in time. Case 71's link step puts that mark, `j5share=1`, in the fragment beside upstream's `token`; upstream reads the fragment as parameters and takes only `token`, in the direct and the hosted form. `apps/web/src/routes/_chat.index.tsx`: one import, and `<IndexDraftLanding />` is wrapped in `<GuestLanding>`. For a member the wrapper renders its child at once, with the sharing answer pending or failed; it holds the frame only for a browser that remembers being paired through a share link (one `localStorage` key, written by the pairing surface and overwritten by the server's answer), and for a guest it shows their thread, a list, or that nothing is shared with them. Upstream's hosted pairing surface is left alone, so a named link opened through the hosted app pairs as upstream has it, and a join link is never offered in the hosted form. Two edits quiet what a guest could only see fail (the build lead under Jackson's 2026-10-13 standing permission for one import and one or two lines). `ThreadDetailsPanel.tsx`, beside the People mount: one more import, `const isGuest = useIsGuest(props.environmentId)` at the top of the component, and `&& !isGuest` on the condition that mounts upstream's `ThreadAutomationsPanel`, which asks for the server's scheduled tasks. `apps/web/src/components/settings/SettingsSidebarNav.tsx`: case 72's nav-filter condition becomes one call into J5, `shownForConnection(item.to)` from `useSettingsNavShown()` (the file gains two lines over case 72), which also leaves Scheduled Tasks, Source Control and Archive, and J5's own Personas and Skills, out of the Settings sidebar of a person who is a guest on every connected server (someone who is also a member of another keeps them; People follows the primary server's own answer); those pages still show upstream's own error to a guest who types their address. `apps/web/src/routes/__root.tsx` (Jackson approved it on 2026-10-13 with one rule: a client is changed only for a person who is a guest on every server they are connected to, never because one of several is a guest one): one import, one hook call beside `primaryEnvironmentAuthenticated`, `useFirstRunSetupOffered(primaryEnvironmentAuthenticated)`, and `FirstRunGate`'s `enabled` reads its answer. For a browser never paired through a share link the answer is upstream's own; a browser that remembers being paired through one is not sent to the setup wizard, which asks a guest to connect computers and import projects, and is offered it again when the server's answer says member and the key clears, or as soon as any other connected server says this person is a member of it (the hook lives in J5's `j5/sharing/firstRunSetup.ts`). `apps/web/src/components/Sidebar.tsx` (approved the same day, under the same rule): one import, `const isGuest = useIsGuestEverywhere()` beside the primary environment's id, and `&& !isGuest` on the empty list's `projects.length === 0` condition, so a guest with nothing shared reads upstream's own "No threads yet" in place of "No projects yet" over an "Add project" button that could only fail. `apps/web/src/j5/artifacts/ArtifactsPage.tsx` is J5's own file. On a pin advance: if upstream moves the composer's `placeholder` prop, keep the spread after it, or a View guest reads upstream's "Ask anything…" over a composer that cannot send; if upstream renames the menu's `archive` or `delete` items, a guest sees them again, disabled, and `sharingMenu.test.ts` still passes, so check a guest's menu in a browser; if upstream reorders the details panel, keep People after Lineage and the guest condition on the Automations mount; if upstream adds a Settings page that asks a guest for what it is not given, add its path to `HIDDEN_FROM_A_GUEST` in `j5/sharing/peopleAccess.ts`; if upstream changes how a pairing address carries its token, or starts to refuse a fragment it does not know, reread `SHARE_LINK_MARK` in J5-owned `packages/contracts/src/j5/sharing.ts` (the web client and the live-test rig's `guest` both mark a link there), whose test in `apps/web/src/j5/sharing/shareLink.logic.test.ts` reads a marked address with upstream's own `getPairingTokenFromUrl`; if upstream renames `PairingRouteSurface` or changes its props, J5's surface fails to compile; if upstream's index route stops rendering `IndexDraftLanding`, re-wrap whatever it renders, or a guest's first screen is a draft they cannot send; if upstream renames `FirstRunGate`'s `enabled` or gates first run elsewhere, a guest with nothing shared lands on the setup wizard again.
74. An agent's browser tab is private unless it names a profile (register D34, Jackson's 2026-10-13 decision). Upstream's `resolveOpenProfile` in `apps/server/src/preview/ServerBrowser.ts` gives a `preview_open` call without a `profileId` the person's default profile, whose stored state every agent tab on the server shares. J5 changes that one return to `INCOGNITO_BROWSER_PROFILE_ID`, which the file already imports, so the tab gets its own throwaway storage through upstream's existing incognito path. A named profile resolves as upstream's does. The `preview_open` description in `apps/server/src/mcp/toolkits/preview/tools.ts` changes one clause to say what omitting `profileId` now means. `ServerBrowser.test.ts` changes two expectations and their test titles. On a pin advance, keep the return and the description clause; if upstream makes agent tabs private by default, take upstream's and retire this case and D34.
75. A guest who holds Collaborate writes to the agent, and the agent is told who is speaking ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33, Jackson's 2026-10-09 and 2026-10-11 rulings; **draft: the `ws.ts` edit and the agent-facing wording await Jackson's approval**). All of it is J5-owned code under `apps/server/src/j5/sharing/` (`GuestCommands.ts`, `SharedConversation.ts`), reached from one upstream file. In `apps/server/src/ws.ts`, `layerWsRpc` reads `sharedConversation` once and returns upstream's handler record with `orchestration.dispatchCommand` wrapped: `admit(currentSession, command)` runs before upstream's own handler and hands it the command to dispatch (one import, one read, and the wrapped return; nothing inside upstream's handler changes). For a member's connection in a thread no guest holds Collaborate on, `admit` returns the very command it was given, after one lookup for any Collaborate grant on the server. In a shared conversation it puts the author's line first in a person's message text. For a guest's connection it refuses every command type but the five in `GUEST_COMMAND_TYPES` and rebuilds each from the fields a guest may set, so a guest's message always uses upstream's `queue_after_active`. The guest gate's rule for `orchestration.dispatchCommand` reads the thread from the command itself and needs Collaborate on it. Nothing in `Orchestrator.ts`, the adapters or upstream's contracts is edited; who wrote a message is J5's own table (migration 39).
75. A guest who holds Collaborate writes to the agent, and the agent is told who is speaking ([#533](https://github.com/Jacksondr5/j5code/issues/533), register D33, Jackson's 2026-10-09 and 2026-10-11 rulings; **draft: the `ws.ts` edit and the agent-facing wording await Jackson's approval**). All of it is J5-owned code under `apps/server/src/j5/sharing/` (`GuestCommands.ts`, `SharedConversation.ts`, `sharedConversationNotes.ts`) and `apps/server/src/j5/a2a/`, reached from one upstream file. In `apps/server/src/ws.ts`, `layerWsRpc` reads `sharedConversation` once and returns upstream's handler record with `orchestration.dispatchCommand` wrapped: `admit(currentSession, command)` runs before upstream's own handler and hands it the command to dispatch (one import, one read, and the wrapped return; nothing inside upstream's handler changes). For a member's connection in a thread no guest holds Collaborate on, `admit` returns the very command it was given, after one lookup by key and one for any Collaborate grant on the server. In a shared conversation it puts the author's line first in a person's message text. For a guest's connection it refuses every command type but the five in `GUEST_COMMAND_TYPES` and rebuilds each from the fields a guest may set, so a guest's message always uses upstream's `queue_after_active`. The guest gate's rule for `orchestration.dispatchCommand` reads the thread from the command itself and needs Collaborate on it. A platform note to the agent is never a message of its own: it goes at the top of the message a person sends next, in the same stored text, so J5 sends nothing through upstream for it. J5's one command of its own is `queued-run.cancel`, through `ThreadManagementService.dispatch`, to withdraw a queued message. Nothing in `Orchestrator.ts`, the adapters or upstream's contracts is edited; who wrote a message and what an agent was last told are J5's own tables (migrations 39 and 40).

## Pin and upstream advance runbook

Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/j5/a2a/Migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ it.effect("tracks J5 A2A migrations independently from upstream migrations", ()
{ migration_id: 37, name: "PersonNames" },
{ migration_id: 38, name: "OpenLinkJoins" },
{ migration_id: 39, name: "MessageAuthors" },
{ migration_id: 40, name: "SharedThreadTold" },
]);
assert.deepStrictEqual(
migrationEntries.map(([id, name]) => [id, name]),
Expand Down Expand Up @@ -136,6 +137,7 @@ it.effect("tracks J5 A2A migrations independently from upstream migrations", ()
[37, "PersonNames"],
[38, "OpenLinkJoins"],
[39, "MessageAuthors"],
[40, "SharedThreadTold"],
],
);
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
Expand Down Expand Up @@ -1384,7 +1386,7 @@ it.effect("recreates earlier-shaped crews tables when 14 runs over them", () =>
applied.map((row) => row.migration_id),
[
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39,
36, 37, 38, 39, 40,
],
);
const memberColumns = yield* sql<{ readonly name: string }>`
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/j5/a2a/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Migration0036 from "./migrations/036_OpenLinks.ts";
import Migration0037 from "./migrations/037_PersonNames.ts";
import Migration0038 from "./migrations/038_OpenLinkJoins.ts";
import Migration0039 from "./migrations/039_MessageAuthors.ts";
import Migration0040 from "./migrations/040_SharedThreadTold.ts";

export const J5_A2A_MIGRATIONS_TABLE = "j5_a2a_migrations";

Expand Down Expand Up @@ -90,6 +91,7 @@ export const migrationEntries = [
[37, "PersonNames", Migration0037],
[38, "OpenLinkJoins", Migration0038],
[39, "MessageAuthors", Migration0039],
[40, "SharedThreadTold", Migration0040],
] as const;

const makeMigrationLoader = (throughId?: number) =>
Expand Down
101 changes: 101 additions & 0 deletions apps/server/src/j5/a2a/SendService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,107 @@ it.effect("refuses plain human sends while allowing human asks and replies", ()
}).pipe(Effect.provide(testLayer)),
);

it.effect("refuses an ask to a person's inbox from a shared conversation", () =>
Effect.gen(function* () {
yield* runMigrations();
const projectId = yield* setupSameProject();
yield* registerPerson();
const service = yield* A2ASendService;
const ledgerService = yield* A2ALedger;
const sql = yield* SqlClient.SqlClient;
// A guest holds Collaborate on the sender's thread, and only View on the receiver's.
yield* sql`
INSERT INTO j5_a2a_human_person (person_id, is_local_operator, created_at, kind, display_name)
VALUES ('human:guest', 0, ${timestamp}, 'guest', 'Priya')
`;
for (const [threadId, level] of [
[sender.threadId, "collaborate"],
[receiver.threadId, "view"],
] as const) {
yield* sql`
INSERT INTO j5_a2a_person_grant (
person_id, target_kind, target_id, level, created_at, updated_at
) VALUES ('human:guest', 'thread', ${threadId}, ${level}, ${timestamp}, ${timestamp})
`;
}
const ask = (commandId: string, senderThreadId: ThreadId) =>
service.send({
commandId: CommCommandId.make(commandId),
senderThreadId,
to: person.id,
message: "Should I go ahead?",
expectReply: true,
intent: "Obtain a decision",
urgency: "soon",
acceptedAt: timestamp,
});

const refused = yield* Effect.flip(ask("command:shared-ask", sender.threadId));
assert.equal(refused._tag, "A2ASharedConversationAskError");
assert.equal(
refused.message,
"This thread is a shared conversation, so an ask to a person's inbox is refused. Ask in this thread instead and name the person you are asking. Everyone on the thread sees the question and the answer.",
);
// A plain send is told the same, not to open an ask.
const plain = yield* Effect.flip(
service.send({
commandId: CommCommandId.make("command:shared-plain"),
senderThreadId: sender.threadId,
to: person.id,
message: "FYI.",
acceptedAt: timestamp,
}),
);
assert.equal(plain._tag, "A2ASharedConversationAskError");
const writes = yield* sql<{ readonly count: number }>`
SELECT COUNT(*) AS count FROM j5_a2a_comm_event
WHERE command_id IN ('command:shared-ask', 'command:shared-plain')
`;
assert.deepStrictEqual(writes, [{ count: 0 }]);

// A thread a guest can only read is not a shared conversation: its agent asks as before.
assert.equal((yield* ask("command:viewed-ask", receiver.threadId)).exchangeState, "open");
// Agents in a shared conversation still message each other.
const peer = yield* service.send({
commandId: CommCommandId.make("command:shared-peer"),
senderThreadId: sender.threadId,
to: receiver.id,
message: "Over to you.",
acceptedAt: timestamp,
});
assert.equal(peer.exchangeState, "none");
// And a reply to something a person asked the agent is not an ask.
const inbound = ExchangeId.make("exchange:shared-inbound");
yield* ledgerService.append({
commandId: CommCommandId.make("command:shared-inbound"),
projectId,
acceptedAt: timestamp,
event: {
kind: "exchange.opened",
sender: person.id,
receiver: sender.id,
exchangeId: inbound,
correlationId: null,
payload: { intent: "Request a reply", urgency: "soon" },
createdAt: timestamp,
},
});
const reply = yield* service.send({
commandId: CommCommandId.make("command:shared-reply"),
senderThreadId: sender.threadId,
to: person.id,
message: "Here it is.",
exchangeId: inbound,
acceptedAt: timestamp,
});
assert.equal(reply.exchangeState, "closed");

// The guest's grant goes: the thread is one person's again, and its agent asks as before.
yield* sql`DELETE FROM j5_a2a_person_grant WHERE target_id = ${sender.threadId}`;
assert.equal((yield* ask("command:unshared-ask", sender.threadId)).exchangeState, "open");
}).pipe(Effect.provide(testLayer)),
);

it.effect("rolls back the send receipt when its projection write fails", () =>
Effect.gen(function* () {
yield* setupSameProject();
Expand Down
Loading
Loading