Repository navigation
perf(j5): field-scoped thread reads in the Crew services - #917
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
This review includes 14 billable files and costs up to $3.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 36 minutes for your next included review. View limit details
CodeRabbit Verify
|
Jacksondr5
left a comment
There was a problem hiding this comment.
Combined review from the panel (Claude Opus 5.5 lead, GPT Sol 6.1), at 087a15929e. No correctness findings. Two wording notes below, neither blocking.
Checked in source
- Inventory: all 12 production full reads moved, and
getThreadProjectionIfPresentis gone. The only J5 callers ofgetThreadProjectionleft are intest-support/devDeliverySeed.ts.RosterServiceandnativeQuestionInboxReadstay as the PR body explains. - Fields: each site loads only what it uses.
j5_stop_agentcorrectly keepsruns. - Filters:
messageIdsandturnItemRunIddrop only rows the callers already discarded, and the real-store test covers both.refreshSeat's run selection and status branches are unchanged, and reading runs first means its items are at least as new. - Forks:
getThreadProjectiondiffers fromgetThreadRecordsonly invisibleTurnItems, and no J5 production code reads that field. - Not-found and deleted threads:
getThreadRecordsIfPresentkeeps the same not-found rule and still returns deleted threads, so thedeletedAtchecks hold. - Reader connection: no swapped read runs inside a writer transaction.
crews.serializeis a keyed lock, not a transaction. The reads that follow a dispatch happen after it has committed. - Settle cascade on the SQL shell:
shellFromStatesupplies every fieldisAutoSettlementCandidatereads, and the settlement candidates path uses the samederivePendingBackgroundWork. The deleted-seat skip is the only behaviour change, and the Captain approved it. j5_list_participants: thethreadIdspredicate matches thelocalRowspredicate, so every shell the listing uses is still loaded, active and archived alike.- Spans and tests:
Effect.fnspans are preserved, and fakes on these paths moved to the new reads.
Non-blocking notes
CrewLaunchReporter.ts,refreshSeat: the comment "so a run that has failed already has its error item here", repeated in the PR body, promises more than the code does.runFailures.tssays a run can endfailedwith no error item. Suggested wording: "Read after the run, so the items are at least as new as its status." There's no runtime effect.- PR body: the behaviour change is described as the "settle cascade", but
moveSeatsalso serves unsettle. A settled deleted seat used to be rejected on a Captain's unsettle, and it's now skipped too. Please say "settle and unsettle". The new test covers the settle direction, and both directions use the same null check.
Validation so far
- Sol ran
CrewLaunchReporter.test.ts,CrewCaptainArchiveCascade.test.tsanda2a/mcp/handlers.test.tsat this head: 38 tests passed. - Opus reviewed from source and ran no tests.
- The full
apps/server/src/j5suite hasn't passed in one complete run at this head, as the PR body says. CI's server shards were still pending when this was posted and will be the first complete run, so this review doesn't vouch for them.
Reviewed by Claude Opus 5.5 and GPT Sol 6.1 in J5 Code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Every J5 full-thread read waits behind event commits, because
getThreadProjectionreads on the writer connection whilegetThreadRecordsuses a separate reader (upstream pingdotgg#23902). Part 1 (#810) moved everything outside the Crew services. This moves the rest. Closes #278.What changed
Every remaining full read in J5 server code outside tests now loads only the fields it uses:
CrewLaunchReporter.post,coversFailure(Captain)messages, filtered to the launch notice's idCrewLaunchReporter.refreshSeatruns, thenturnItemsfiltered to the chosen run, only when the verdict reads itemsCrewLaunchReporter.dropSeatsNeverCreated,CrewLaunchServiceseat,CrewProposalService×2getThreadRecordsIfPresent(id, [])SpawnAgentServicecaller and child,preflightCrewCaptaingetThreadRecords(id, [])j5_stop_agenttargetrunsCrewCaptainArchiveCascade.moveSeatsgetThreadShell: upstream's SQL shell, no morethreadShellFromProjectionj5_list_participantsgetShellSnapshot({ threadIds })for the project's agents, instead of every threadgetThreadProjectionIfPresenthad no callers left, so it is deleted.refreshSeatmakes two reads because it needs the run before it can filter items by run. It reads runs first, so the items are at least as new as the run's status.Left as is
RosterServicekeeps the whole shell snapshot, because it joins every membership and athreadIdslist would name nearly every thread.nativeQuestionInboxReadis alreadylocation: "active", and it only reads records for threads with a pending request.test-support/devDeliverySeed.tsis test support.Forks.
getThreadProjectionfollows a fork's history only forvisibleTurnItems, and no J5 server code reads that field. So no swapped site sees different rows on a fork.One behaviour change, approved by the Captain.
getThreadShellreturns null for a deleted thread, so the settle and unsettle cascade now skips a deleted seat. Before, the orchestrator rejected the command on that seat (Thread is deleted), and the remaining seats of that Crew didn't move. Now those seats still follow the Captain. Nothing else changes.Tests
Fakes on these paths moved to the new reads. Real-store tests cover the places where a swap changes which rows are read:
activityRunStatus,pendingRuntimeRequestand a queued turn start, and an archived seat. Only the idle seat after them settles.coversFailurefinds the notice by id, so a look-alike message on the Captain doesn't count. Breaking theturnItemRunIdfilter or themessageIdsfilter fails this test: checked by mutating each.Live testing
Server-only change, so no UI. I ran this myself on an isolated
j5-live-testserver at97c107fdfb, on Claude Haiku only. A Crew seat can't spawn a separate tester.Head vs tested commit. The head differs from the tested commit only in test fakes and two code comments. Nothing an agent or a person sees changed, so I did not re-test.
Not exercised live, and why: a failed seat, a seat in a real launch window with a brief running (this launch's seats were created waiting for work), and a deleted seat in the cascade. Tests cover all three. No Codex turn: the turn path and adapters are unchanged. No restart: stored state is unchanged.
Checklist
vp run check:changed: format, lint, knip, graphql, typecheck and the 7 test files beside the changes pass. The whole ofapps/server/src/j5: 192 test files pass and 1 is skipped (1599 tests pass, 1 skipped) at087a15929e. The head adds only a one-line comment change after that.Built by Claude Opus 5.5 in Claude Code (J5 Code Crew builder seat).
🤖 Generated with Claude Code