Repository navigation
feat(j5): a Captain can replace a crew seat - #935
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
This review includes 27 billable files and costs up to $6.75. Or wait 38 seconds for your next included review. View limit details
|
tyler-barton-horizon
left a comment
There was a problem hiding this comment.
Automated review of this layer of stack pingdotgg#933 (diff against its base branch). Findings were not individually verified against the source, so please treat them as likely issues and push back on any that are wrong.
apps/server/src/j5/a2a/ArchiveCrewService.ts:340 (not in this diff): Archive and cleanup loop only over instance.members, so replaced members (now in j5_agent_crew_replaced_member) are never archived and their crew worktrees are never cleaned up when the Crew retires.
🤖 Generated with Claude Code
| }; | ||
| const owned = stepOwnershipConflict( | ||
| id, | ||
| current.members.filter((member) => member.seatName !== old.seatName), |
There was a problem hiding this comment.
A replacement can claim steps the replaced seat already finished, so one step ends up owned by both.
Seat builder owns [plan, build, test] and the run is at test. The Captain replaces it with steps: ["build"]. Validation (withoutReplaced / memberSteps(live)) and stepOwnershipConflict both pass. The replaced row keeps [plan, build] and the new member owns [build, test], which breaks 'every step keeps one owner', and a later reselect of build goes to the new member.
There was a problem hiding this comment.
The replaced row is a record of what that member finished; it isn't an owner any more. Ownership is only the live roster, which is what the relay and the one-owner check read, so build has one owner, the new member. Sending a later reselect of build there is intended. Leaving this as is.
|
On the review-body note about |
|
Follow-up on the |
c884bee to
9068716
Compare
9068716 to
ba02033
Compare
j5_request_crew_member takes an optional `replaces`. The new member launches first; only after it exists does one store write move the replaced seat's unfinished playbook steps to it and move the old member to j5_agent_crew_replaced_member (migration 052). The old member's turn is then interrupted with stopThread, and a current step it held is handed to the new owner through a relay reselect. A failed launch moves nothing. Replaced members still count as authors for independent reviewers, and Fleet and the Captain's expander show them as "Replaced by <new member>". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The steps a replacement takes over were read before the addition took the Crew's lock, so a playbook move that held the lock meanwhile left them stale: an advance moved a finished step, and a back left an unfinished one on the retired member. They are now read inside the locked swap, and the new member's brief lists the same steps. Adds a test for that race and one for retrying a replacement whose post-swap stop failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…keeps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The re-check under the Crew lock now refuses as a seat error, so a second replacement of the same seat is declined instead of staying open. The new seat's own step claims are checked there too, before anything spawns. A replacement whose thread was created but never got its home archives that thread. The moved steps are computed once, and a replacement skips the admission cap since it never grows the Crew. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Members the Captain replaced keep the worktree J5 made for their seat. A Crew's archive now looks at those worktrees under the same rules as seats, without archiving the replaced members' threads. The docs say so, and the user doc now says finished steps stay with a replaced member only for the current run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A member the Captain replaced stays a plain agent until its Crew is archived. Then the Crew's archive takes it too: it's listed beside the seats as "<seat> (replaced)" with its running turn and open asks, its turn is interrupted, and its J5-made worktree is cleaned up like a seat's. Fleet's Archive crew dialog lists it. Unarchiving the Captain brings its thread back with the Crew's, but it stays replaced and off the roster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the Captain's expander, a replaced member's row showed its last run status (a green Completed, say) instead of who replaced it, because the label only rendered when there was no status. Being replaced now takes precedence over the run status in that row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6fe827f to
488c697
Compare
Summary
A Crew member sometimes needs to run on a different model. The usual case is a reviewer whose model just wrote the work it's about to review. A Captain could add a new member, but the new member couldn't take over the old one's Playbook steps, because a step has exactly one owner and an addition can only claim unowned steps. Now
j5_request_crew_membertakes an optionalreplaces(a seat name), and the new member takes the seat over. Closes #784.replaceMember) do the swap. It moves the replaced seat's unfinished steps to the new member, moves the old row into the newj5_agent_crew_replaced_membertable with the steps it finished and who replaced it, puts the new member at the old member's position, and bumps the version.CrewSeatInactiveError). A failed launch writes no roster rows, and the original keeps its steps and keeps running.stopThread, the same helperj5_stop_agentand Crew stop use, with no message to it.PlaybookCrewRelay.handOver. That's a reselect of the current step, the same pathj5_playbook_reselecttakes. If the hand-off to the old thread is still pending, it's marked skipped first, so a drain can't send the step to the retired member.client_request_idfinishes whichever one didn't happen.j5_agent_crew_member, sofindMembershipreturns null. It doesn't count toward the cap and gets no Crew deliveries or finish notices. Its thread and finished steps stay readable. Archiving the Crew archives it too, and cleans up its worktree like a seat's. Unarchiving the Captain brings its thread back, but it stays replaced.reviewsmay name a replaced seat.FleetAgentandSpawnedChildget an optionalreplaced(crewName,seat,replacedBy). The Fleet row and the Captain's expander show the replaced member as "Replaced by ", with the new member in the Crew. Mobile shows Crew members as ordinary agents, so nothing changes there.The model-facing text changed: the
j5_request_crew_memberdescription, thereplacesparameter, and one sentence of Captain guidance inorchestrationInstructions.ts. I ran the 33 Claude orchestration cases on Sonnet 5.5, and 62 of 68 samples passed, for about $4.09. Three cases failed some samples.opus-review-too-via-delegatefailed 0/2, the known flake, and it's also 0/2 on base.delegates-then-new-thread-with-modelandreview-followup-ask-sol-to-confirmeach passed 1/3. I re-ran those two at 4 samples each on head and on base (a85bc9f), and they scored the same on both (3/4 and 4/4), so they're existing flakes, not regressions. Total eval spend was about $5.31.node --env-file-if-exists=../.env mcp-tool-use/run.ts --model claude-sonnet-5-5 --cases mcp-tool-use/cases/orchestration.jsonl --out runs/784-sonnet(fromevals/)UI changes
Cropped from 1280x800 on the head test server. Before is the Crew just after launch, and after is the same Crew once the Captain replaced the reviewer:
From Jackson's live test of the stack: a replaced member that had finished a run still showed its green Completed in the expander. It now always says who replaced it (6fe827f). The after is from my test home, captured at 6fe827f, where the replaced member never ran, so it shows the label but not a run status being overridden.
Live testing
Partial, at d8847f6, on
setup-agent-live-test.ts --base origin/feat/persona-model-switch. I sent two Captain turns on Claude Haiku 5.5, and each was followed by the Captain's automatic launch-report turn.j5_request_crew_memberwithreplaces:j5_agent_crew_replaced_member.thread.stop.Evidence
CrewProposalService.test.ts, "a Captain replaces a seat: its unfinished steps, its current step and its turn move to the new member". This goes through the real launcher and a real playbook run at stepbuild:replaces: "captain", and a seat above the Captain's access. Each refusal changes nothing.planner→planner-2: only the unfinishedreviewmoves, andplanstays on the replaced row. The old thread gets onethread.stop, and the new member gets no step notice, becausebuildisn't its step. Its brief names the old seat, its model and its thread, and listsreview.planneragain is refused as already replaced.builder→builder(same name): the new member ownsbuild, gets exactly one step notice, and the run reports it as holding the step. Retrying the call sends nothing new, and the old builder is no longer a member.CrewProposalService.test.ts, "a replacement on a Crew without a playbook is an addition and a stop".CrewProposalService.test.ts, "a replacement takes the steps unfinished when it gets the Crew, not when it asked". Anextholds the Crew's lock with the run atplanwhile the replacement asks and waits for the lock. Once the run moves tobuild,planstays on the replaced row and onlyreviewmoves. This failed on d8847f6, whereplanmoved too.CrewProposalService.test.ts, "a retry after a replacement's stop failed finishes the stop and hand-off once". The swap lands and then the stop fails. Retrying the same request twice stops the old builder under one command id and handsbuildover exactly once, with no second swap and no version bump.AgentCrewInstanceService.test.ts:findMembership, the cap no longer counting the old member, idempotent replay, and that it stays out after an unarchive.PlaybookCrewRelay.test.ts:CrewLaunchService.test.ts, "a reviewer added after a builder was replaced avoids both builders' models": terra (old) and sol (new) are both avoided, so the reviewer lands on luna.vp test run src/j5/a2a/CrewProposalService.test.ts src/j5/a2a/AgentCrewInstanceService.test.ts src/j5/playbooks/PlaybookCrewRelay.test.ts src/j5/a2a/CrewLaunchService.test.ts(fromapps/server)CrewProposalService.test.ts. Each of these fails without its fix:reviewwhile the replacement waits for the lock, and the replacement is refused with nothread.create.ArchiveCrewService.test.ts, "archives a replaced member with its Crew and cleans up its worktree like a seat's": the confirmation listscritic (replaced)beside the seats, its turn is interrupted under its own command id, and its thread is archived and its worktree cleaned up.CrewCaptainArchiveCascade.test.ts, "unarchiving a Captain brings a replaced member's thread back, still replaced". The store test above checks that it stays off the roster after the unarchive.vp run check:changedat 6fe827f, on feat(j5): people can switch a persona worker's model #934's 4fd8a2a: format, lint, knip, typecheck (32 packages) and tests (34 files) all pass.Not verified:
Merge Danger
Door: one-way, in a small way. Migration 052 adds a table. After a revert, replaced members' rows stay in that table and nothing reads them. Those members stay off their Crews, which is the state they were left in.
Blast Radius: Crew additions. The new path only runs when
replacesis set. Additions without it go through the same reservation path as before. The reviewer-author change affects reviewers added to a Crew that has replaced members.After merge: nothing.
Checklist
FORK.md(case text and file-table row) in this PR (none touched)docs/j5/product/upstream.md(none)AGENTS.md)docs/j5/product/and user docs rewritten where this changes themClaude Opus 5.5 in J5 Code (Claude Code harness).
🤖 Generated with Claude Code