Skip to content

feat(j5): J5's read models follow a change stream, not timers - #586

Merged
Jacksondr5 merged 3 commits into
j5/reads-over-socketfrom
j5/read-change-stream
Oct 13, 2026
Merged

Jacksondr5 merged 3 commits into
j5/reads-over-socketfrom
j5/read-change-stream

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Problem

The Inbox, Crew proposals, a seat's approvals, the Fleet and the sidebar's Crew chips and children were re-read on 7.5 and 30 second timers whether or not anything had changed, once per connected environment. Closes #182. Part of #506 (the last part of step 3). Stacked on #584.

What changed

  • One change stream per environment. j5.reads.subscribeChanges streams four revisions: inbox, crew, fleet and runtimeRequests. It says which read models went out of date, never what changed. Each read re-reads when a revision it depends on moves, through upstream's refreshTrigger, as upstream's pull-request summaries do.
  • What moves each revision
    • inbox: an Exchange closing or dropping, and a delivery, cancellation or delivery failure that reaches a person.
    • fleet: any participant event, an Exchange opening, closing or dropping, a placement, and a playbook run changing.
    • crew: a proposal being admitted, resolved or attached to its Crew, and a Crew being recorded, gaining or losing seats, retired or restored.
    • runtimeRequests: a provider request opening or resolving, an approval's turn item, and a thread being archived, unarchived, deleted or renamed.
  • How the server knows. A small hub (ReadChanges) holds the revisions. Feeds turn what the server already publishes into revisions: the ledger's committed events, the orchestration event store and the playbook store. The Crew services and spawn placement had no signal, so they notify after their own commits.
  • One message per half second at most. A burst of writes is one message, and constant writes cannot hold a message back.
  • Timers removed: the Inbox bell count and Inbox page (7.5 s), Crew proposals (7.5 s), Crew runtime requests (7.5 s), and the Fleet rail and Fleet page (30 s).
  • Refresh on tab focus stays for those views. It covers what has no server signal, such as a playbook file edited by hand or by an agent.
  • The Fleet page no longer re-reads the Fleet on every playbook revision; the fleet revision covers it.

Still on a timer after this PR: the peer list (30 s) and a playbook board with an active run (30 s). Neither had a change signal for everything that changes it. #593, on top of this, adds those signals and removes both.

Things to know

  • A query mounted before the stream's first value reads twice, once per connection. Upstream's pull-request atoms behave the same way.
  • A revision moves for any thread's approval, not only a Crew seat's. The client still only asks environments that have a thread with a pending approval.
  • Under a busy fleet the Fleet read can run up to twice a second per client while the Fleet page or rail is mounted, where it ran every 30 seconds. It does not run at all while nothing changes.
  • The revisions start from the server's start time, so a client that reconnects after a restart sees them moved.
  • The sidebar rows are re-read once on the first revisions heard for a server, since they may already count a change the rows were read before.
  • An outside agent's changed name has no signal and waits for a focus refresh.

Verification

  • Typecheck clean in contracts, client-runtime, web, mobile and server. Lint and format clean on the changed files (one existing warning in HumanInboxPage.tsx).
  • Reviewed by an Opus 5.5 subagent reading by ref: no blocking findings. Its two should-fix findings are fixed in a7b305cd9c (the event follower notified before taking its new mark; the sidebar rows could miss a change at first load and across a restart).
  • Tests: contracts 689, client-runtime (src/j5, src/state) 907, web src/j5 280, mobile src/j5 31, server (src/j5, src/auth, src/observability, ws.test.ts) 1,235.
  • New tests cover: the hub (one source moves, a new subscriber gets the current value, a burst is one message, constant writes still get through), the mapping from each ledger event kind and stored event type to its revisions, the Crew services and spawn placement notifying, the read scope, a moved inbox revision re-running the Inbox query and not the proposals query, and the sidebar rows refreshing on crew.

UI changes

No layout or styling changes, so there are no before/after stills. The visible difference is timing: these views update about half a second after a change.

The bell and Inbox update when an agent on the second server asks a question Inbox and bell update
The Fleet and sidebar update when a Crew is approved Fleet and sidebar update

Live testing

Pass on 9c99e0ae01, by a GPT-6 Astra peer agent on two peered isolated servers, with Claude Haiku 5.5 for the turns. Report: artifacts/test-reports/j5-read-change-stream.md.

  • No polling: 83 seconds idle with the Fleet page focused made zero J5 reads, with one open stream per server.
  • Found and fixed during the test: a playbook change read the Fleet four times, because the Fleet page still re-read it on every playbook revision beside the stream. Fixed in 9c99e0ae01; it is now one rail read and one page read.
  • Each view updated on its own, timed from the stored event to the visible change:
Cause Change Time
A question from the second server Bell and open Inbox 510 ms
The answer Question leaves, bell clears 92 ms
A Crew proposal Roster card 628 ms
Approving it Fleet row; sidebar chip and children 584 ms; 713 ms
An added-seat proposal; declining it Inbox card appears; leaves 621 ms; 81 ms
A new thread Fleet count 676 ms
A playbook starting; advancing Fleet step 725 ms; 549 ms
A seat's command needing approval Inbox card 211 ms
Renaming that seat's thread Card title 543 ms
Archiving the Crew Fleet's Retired crews; sidebar chip clears 465 ms; 650 ms
  • Nothing over-refreshes: a Crew change ran no Inbox reads, and the rename moved runtimeRequests alone and ran one read.
  • Burst: a three-seat Crew working for a minute produced 11 stream messages and 22 Fleet reads (rail and page), peaking at 2 a second, with the UI responsive.
  • Recovery: after a restart at rest both streams reopened with new revisions, the views were right, and a new question still arrived on its own in 517 ms.
  • Read-only session: the stream opens with orchestration:read alone (on the first head tested).

Not exercised live

  • A guest's client. The test rig has no way to create a guest. That a known guest is sent no J5 reads is covered by tests in sharing.test.ts, and the server's guest gate refuses any method it does not name.
  • A socket-only reconnect on the final head (it passed on the first head; the restart check ran on the final one).
  • A view staying stale until focus: the project rename the tester tried already reaches the client through upstream's own stream. A focus event did trigger one rail and one page read.
  • Mobile, the desktop app, relay and tunnel connections, and a client against an older server.

Upstream impact

  • packages/client-runtime/src/rpc/client.ts: the stream's tag joins EnvironmentSubscriptionRpcTag, its import and one union member, as the artifact and playbook streams did (FORK.md cases 45 and 64).
  • No ws.ts edit: the hub reaches the socket through the J5 services wsRpc.ts already picks.

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 recordings; no layout changed
  • 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 — none changed
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md) — web only; mobile has no consumer of these reads; relay and tunnel not run live
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them — none state the polling

Built by Claude Opus 5.5 in Claude Code, with Opus 5.5 subagents.

🤖 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 13, 2026 3:53am UTC

Request Review

@Jacksondr5
Jacksondr5 added this pull request to stack #587 October 13, 2026 02:19
@github-actions github-actions Bot added the vouch:trusted Author is trusted by repo permissions or the VOUCHED list. label Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 41 billable files and costs up to $10.25.

  • 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 22 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 62 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: 7d78efc5-4e62-42ce-96e9-bf9cc0cd4df3
📥 Commits

Reviewing files that changed from the base of the PR and between 2a97bf7 and e6c1fbf.

📒 Files selected for processing (41)
  • FORK.md
  • apps/server/src/j5/a2a/AgentCrewInstanceService.ts
  • apps/server/src/j5/a2a/AgentCrewProposalService.test.ts
  • apps/server/src/j5/a2a/AgentCrewProposalService.ts
  • apps/server/src/j5/a2a/ReadChangeFeeds.test.ts
  • apps/server/src/j5/a2a/ReadChangeFeeds.ts
  • apps/server/src/j5/a2a/ReadChanges.test.ts
  • apps/server/src/j5/a2a/ReadChanges.ts
  • apps/server/src/j5/a2a/SpawnCompositionService.test.ts
  • apps/server/src/j5/a2a/SpawnCompositionService.ts
  • apps/server/src/j5/a2a/clientReadRpc.test.ts
  • apps/server/src/j5/a2a/clientReadRpc.ts
  • apps/server/src/j5/a2a/runtimeLayer.test.ts
  • apps/server/src/j5/a2a/runtimeLayer.ts
  • apps/server/src/j5/a2a/test-support/readRevisions.ts
  • apps/server/src/j5/wsRpc.ts
  • apps/web/src/j5/a2a/HumanInboxBell.test.ts
  • apps/web/src/j5/a2a/HumanInboxBell.tsx
  • apps/web/src/j5/a2a/HumanInboxPage.tsx
  • apps/web/src/j5/crew/CrewMembershipsClient.ts
  • apps/web/src/j5/crew/CrewRosterGate.tsx
  • apps/web/src/j5/crew/crewProposalsClient.ts
  • apps/web/src/j5/crew/crewRuntimeRequests.logic.test.ts
  • apps/web/src/j5/crew/crewRuntimeRequests.logic.ts
  • apps/web/src/j5/crew/crewRuntimeRequestsClient.ts
  • apps/web/src/j5/fleet/FleetPage.tsx
  • apps/web/src/j5/fleet/fleet.logic.test.ts
  • apps/web/src/j5/fleet/fleet.logic.ts
  • apps/web/src/j5/fleet/fleetClient.ts
  • apps/web/src/j5/playbooks/PlaybookRunsSection.tsx
  • apps/web/src/j5/state.ts
  • apps/web/src/j5/threads/SpawnedChildrenClient.ts
  • apps/web/src/j5/threads/useThreadRowReads.ts
  • apps/web/src/j5/useVisibleRefresh.test.ts
  • apps/web/src/j5/useVisibleRefresh.ts
  • packages/client-runtime/src/j5/scopedThreadReadStore.test.ts
  • packages/client-runtime/src/j5/scopedThreadReadStore.ts
  • packages/client-runtime/src/j5/state.test.ts
  • packages/client-runtime/src/j5/state.ts
  • packages/client-runtime/src/rpc/client.ts
  • packages/contracts/src/j5.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Jacksondr5 and others added 3 commits October 12, 2026 23:51
The Inbox, Crew proposals, a seat's approvals, the Fleet and the sidebar's
Crew chips were re-read on 7.5 and 30 second timers whether or not anything
had changed.

The server now streams four revisions (inbox, crew, fleet,
runtimeRequests) over `j5.reads.subscribeChanges`, and each read re-reads
when a revision it depends on moves. The ledger's committed events, the
orchestration event store and the playbook store feed the revisions; the
Crew services and spawn placement notify after their own commits. The
timers are removed; a refresh on tab focus stays for what has no signal.

Closes #182. Part of #506.

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

Review fixes. The revisions start from the server's start time, so a client
that reconnects after a restart sees them moved. The sidebar rows re-read on
the first revisions heard, which may already count a change. After losing
the event stream, the follower takes its new mark before it notifies. A
thread's title change moves runtimeRequests, since the approval card shows
it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Fleet page re-read the Fleet on every playbook revision. The fleet
revision already moves when a playbook run does, so the page read it again
beside the stream. Found in live testing.

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

This branch was successfully deployed

1 active deployment
Preview — e6c1fbf4 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: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.

feat(j5): one change stream per environment to replace the J5 read polls

1 participant