Repository navigation
feat(crews): a Crew proposal records the playbook it follows - #383
Conversation
propose_crew can name a playbook and give each seat the step ids it owns; request_crew_member can claim steps no seat owns yet. The server checks every claim against the live YAML at propose, preview, and approve, and refuses a playbook proposal while the Captain's thread runs a playbook. The proposal and instance record the playbook's definition path and each member its step ids (migration 023); ownership is enforced again inside the member store's serialized reservation, and that refusal reaches the gate unwrapped, so of two additions racing for one step the second is refused and stays open. Persona swaps are computed by the server and bound, with the card-visible plan, into the approval token. Each seat's first turn lists its steps, and the roster card and Fleet show the plan. Closes #321 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A retried record keeps the stored row of every seat already on the roster, so that seat's stored steps stay owned; the ownership check now counts them instead of skipping the seat, and a new seat claiming one is refused with nothing written. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A seat's stored step ids were capped at the seat-name length, so a valid playbook step id over 100 characters passed every door and then failed to encode when the proposal was written. Stored step ids now follow PlaybookStep.id: non-empty with no length cap; only their count is bounded. A step id also sits on the same line of the <seat_playbook> block as its title, so it gets the same one-line, close-tag-safe treatment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A re-approval after a failed link replays record under the same instance id. Ownership is now checked over the roster as it will stand (rows no incoming seat replaces, plus every incoming seat with its incoming steps), and the member write takes a same-named seat's newly approved steps with ON CONFLICT DO UPDATE on playbook_step_ids only. A step moved to a new seat or left unowned is stored as approved; a kept row's step still refuses a new claimant, with nothing written. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: Jacksondr5/j5code/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID:
Comment |
Jacksondr5
left a comment
There was a problem hiding this comment.
[Review panel: Opus 5.5, Astra, Sonnet 5.5, Sol 6.1]
Two findings the whole panel agrees on are inline. Product questions about where a Crew's playbook link lives go to Jackson separately.
|
@Jacksondr5 thanks for the thorough pass on the stack. We're taking all the fixes: dropping the crew clause from the mention instructions (#387 owns that now), hiding the misnamed rows, keeping trailing punctuation, fixing the FORK.md rows, letting a Crew add stepless seats after its playbook file is gone, removing the active-run guard at propose time, removing the boot sweep, showing an unreadable run as "needs attention" on Fleet, rewriting the playbooks definition, and fixing case 45. Fix commits are on the way and I'll reply on each thread as they land. One thing I want to flag, though. A few of the comments lean on a standing decision from 2026-09-18: that playbooks are step tracking only and never affect spawn-time choices, and that there's no crash-recovery machinery. I can't find either of those written down anywhere in the repo, not in The first one is a bigger deal than a single comment, because it conflicts with this whole milestone. #319 through #323 are about building a Crew from a playbook: steps name the persona that does them, and #323 (#387) has the Captain staff the roster from those personas. The playbooks definition also says the opposite today. AC2 reads "A Role or a Crew can be spawned with a Playbook and told to follow it." None of the fixes above depend on settling this, so they're going ahead either way. But #387's premise does. Can we talk it through before #387 merges, and get whichever way we land written into the product docs so it's not a hallway ruling? |
A Captain already running a playbook could not propose a Crew that follows one. playbook_start's one-active-run refusal already governs when the Crew's run can start, so propose_crew no longer duplicates it, and PlaybookStore.activeRunFor, which only that guard used, is removed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ss seat Every seat joining a playbook Crew re-read its YAML, so once the file was gone or broken the Crew could add no seat at all, and the refusal said "No playbook named ...". The definition is now needed only when a joining seat claims steps: a missing or broken file refuses just that seat, saying the Crew's playbook can no longer be read, and a stepless seat launches with your_steps: none. A roster still records its playbook without it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ered to 28 Merges origin/j5/319-playbook-step-personas, which carries j5/main's peering PRs and J5 migrations 23–27. CrewPlaybooks moves from 023 to 028 (migrations/028_CrewPlaybooks.ts, [28, "CrewPlaybooks", Migration0028]); the pinned lists and the upgrade test (now through 27, then 28) follow. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…bered to 29 j5/main's peering migrations take J5 ids 23-27 and #383 moves CrewPlaybooks to 28, so CrewPlaybookRuns becomes 29. The upgrade test now runs through 28 before 29 and keeps its named-columns read. The playbooks definition keeps its rewrite and gains main's pre-approval sentence. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
[Coordinator notes for discussion: D1 and D2 across #383 and #384] @bryantderosier, Jackson wants to talk these two through with you before ruling. They are open questions, not decisions. The review panel split on both, and these are my recommendations. The example throughout is a Playbook D1: when does a Crew get its step assignments?Today (#383, following the #319–#323 plan)
This makes the Playbook part of the Crew's identity. The Crew stores the Playbook, each seat stores the steps it owns, and every roster path (propose, member addition, approval) has to re-read the YAML to validate ownership. The posted findings come from that:
Alternative: bind when the run starts
The Crew knows nothing about Playbooks. That removes:
A Crew could also run one Playbook and then another. This matches Jackson's 2026-09-18 ruling that Playbooks are step tracking added onto existing agents or Crews. What the alternative gives up
My recommendation: the alternative. Approving the assignment up front is the one real benefit of binding at proposal, and every roster operation has to know about Playbooks to provide it. The person approves the people either way. I know this is a substantial rework of #383 against the milestone plan, which is why Jackson wants to discuss it rather than just rule. D2: how much machinery surrounds a step hand-off (#384)?What has to happen: when the run lands on Verify, a message with Verify's prompt is posted to verifier-seat's thread, which starts its turn. If there's no live owner, the Captain does the step, and its own tool response already carries the prompt. Today,
Smaller design (Opus and Sonnet on the panel, and me)
That removes the table, the pending state, the drain gate, the sweep, and the rejection fallback. The relay goes from about 390 lines to about 120, and the migration shrinks to the run's Crew link, plus the owner map under the D1 alternative. The case for keeping it (Astra and Sol on the panel)
All three are true, but they cover rare cases. A retry after a roster change that reaches the Captain instead is acceptable, and a failed send is already visible to the Captain as an error. That fits "error out instead of building machinery for rare cases" in AGENTS.md. How D2 relates to D1: under today's D1, ownership lives on Crew members and can change as seats are added, so the recorded target matters a little. Under the alternative, the owner map is fixed on the run, so "who holds this step" comes straight from the run and the table has nothing left to do. The smaller design works with either choice. My recommendation: the smaller design, whichever way D1 goes. Coordinator: Claude Opus 5.5 (Claude Code) |
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
[Coordinator: outcome of the D1/D2 discussion]
Correction: an earlier version of this comment said F1 still applies. Bryant fixed it in 446b911, which the panel is verifying. Coordinator: Claude Opus 5.5 (Claude Code) |
Jacksondr5
left a comment
There was a problem hiding this comment.
[Review panel: Opus 5.5, Astra, Sonnet 5.5, Sol 6.1]
Approving at 5e5e717. The panel checked both fixes against the source:
- F1: a Crew whose Playbook file is gone can still add a seat that claims no steps.
- F4: the propose-time guard is removed.
Migrations 28 and 29 are clean after the peering merge.
D1 stays as implemented. D2, the delivery machinery, is tracked in #389.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
A Crew had no way to say which playbook it follows or which seat owns which step, so "create a crew that uses this playbook" could only produce a roster with no plan behind it (#321). This PR lets
propose_crewname a playbook and give each seat its steps, records that plan on the Crew, and shows it on the roster card before anyone approves.This PR is stacked on #380 (#319, which adds
playbook_read, per-steppersona, andpersonaCatalogProblem). #384 (#322) is stacked on this one and reads the storage it adds.What I changed
packages/contracts/src/j5.ts→ optionalCrewProposalSeat.stepsandpersonaSwaps,CrewPersonaSwap,CrewProposalPlaybook,CrewProposal.playbook, previewplaybookandunownedSteps,FleetCrew.playbook, and rostersteps. All additive and optional.apps/server/src/j5/a2a/migrations/028_CrewPlaybooks.ts→playbook_nameandplaybook_definition_pathon the proposal and instance tables,playbook_step_idson members. Registered inMigrations.ts.apps/server/src/j5/a2a/crewPlaybookPlan.ts→planCrewPlaybook, one pure check called fromCrewProposalService.validateSeats. It refuses an unknown playbook, an invalid definition, an unknown step id, a step claimed twice (or already owned by a live member, for additions), andstepswithout a playbook, each with a next step. It computes persona swaps and unowned steps.CrewProposalService.ts→propose,requestMember,preview, andresolveall run that check against the live YAML. A Crew's playbook is read for an addition only when the joining seat claims steps, so a stepless seat can still join after the playbook file is gone.resolvere-reads the definition, carriesstepsinto the launch seats, and mapsCrewStepAlreadyOwnedErrorto a refusal that leaves the proposal open.crewRuntimePreview.ts→crewPlaybookPlanDigest, a hash of what the card shows (definition path, title, each step's id, title, and persona, the swaps, unowned steps). It goes into the approval token, so a same-id title or persona edit, or a persona being turned off between preview and approve, makes the token stale. Prompts are left out. A proposal without a playbook gets the same token as before.AgentCrewInstanceService.ts→recordandaddMembersenforce step ownership inside the Crew's serialized member transaction and fail with the taggedCrewStepAlreadyOwnedError, writing nothing.recordchecks over the roster as it will stand after the write, and a re-approval replay updates a same-named seat'splaybook_step_idswithON CONFLICT DO UPDATEon that column only.CrewLaunchService.ts→stepsridesCrewLaunchSeatthroughlaunch,record, andaddSeats. Both error wrappers passCrewStepAlreadyOwnedErrorthrough unwrapped.spawnIds.ts→ each seat's first turn gets a<seat_playbook>block with the playbook and its steps (oryour_steps: none), between<j5_crew_context>and<spawner_brief>. Titles and ids go throughbriefLine, so a newline or</seat_playbook>can't break the block.apps/server/src/j5/playbooks/workspace.ts→playbookWorkspaceRoot(threadId), moved out ofplaybooks/mcp.tsso the playbook tools andpropose_crewresolve the same root.PlaybookStoregainsreadPath.mcp/tools.tsandmcp/handlers.ts→propose_crew.playbook, seatsteps,request_crew_member.steps, and aplaybookblock on the result (unowned_steps,persona_swaps).CrewProposalsHttp.tsandFleetReadsHttp.ts→ the list and preview return the playbook projection (a read error becomesissue, never a failed list); Fleet returns the playbook name and each seat's steps.CrewProposalCard.tsxand newcrewPlaybookPlan.ts→ "Follows playbook", each seat's steps, a swap line per swapped step, "Unowned steps, done by the Captain", and "Removing leaves unowned". The card renders from the preview response, the same values the token binds.crewProposalDraft.tsandcrewSeatRuntime.tskeepstepswhen a seat is edited.FleetPage.tsxshows "Playbook: " and each seat's steps.docs/user/personas.md,docs/j5/product/features/crews.md,docs/j5/product/a2a/agent-tools.md.Before (no playbook: the roster card as it was):
After (the Crew follows "Release review": each seat's steps, a persona swap because
builder-botis turned off, and the two steps the Captain does):Why this shape
crews.serialize, so the first approval wins and the second is refused with nothing written. The tagged error has to surviveCrewLaunchService's wrapping, or the person gets a generic launch failure and the proposal closes.PlaybookStep.id: non-empty, no length cap. Only their count is bounded. An earlier cap at the seat-name length let a valid long id pass every check and then fail to encode.Invariants
AgentCrewInstance.playbookis set at approval and never changes.playbook_start(already_active), when the run starts. Proposing a playbook Crew isn't gated on run state. I dropped the propose-time refusal after review, so the original plan's version of this rule no longer applies.CrewStepAlreadyOwnedErrorreachesresolveunwrapped, and the proposal stays open.Surfaces
propose_crewandrequest_crew_member, the roster card in the Captain's thread, and the Inbox addition card (it reuses the same card); no Settings, palette, or keybinding surfacepackages/contracts)src/j5.tsdocs/user/personas.md,docs/j5/product/features/crews.md,docs/j5/product/a2a/agent-tools.mdOut of scope
Upgrade and data
Migration 028 adds five nullable columns. Existing proposals, Crews, and members read back with
playbook: nulland no steps and behave exactly as before. Older clients ignore the new optional fields. Rolling back leaves the columns unused. Numbering: j5/main's peering work took J5 migrations 23–27, so this is now migration 028. A dev database that ran an earlier build of this stack already recorded 23 as ours and would skip the peering migration with that number, so reset or re-copy such a database before testing. Real installs never ran the old number.Verification
vp test run apps/server/src/j5/a2a/crewPlaybookPlan.test.ts apps/server/src/j5/a2a/CrewProposalService.test.ts apps/server/src/j5/a2a/AgentCrewProposalService.test.ts apps/server/src/j5/a2a/AgentCrewInstanceService.test.ts apps/server/src/j5/a2a/CrewLaunchService.test.ts apps/server/src/j5/a2a/CrewLaunchReporter.test.ts apps/server/src/j5/a2a/CrewProposalsHttp.test.ts apps/server/src/j5/a2a/FleetReadsHttp.test.ts apps/server/src/j5/a2a/Migrations.test.ts apps/server/src/j5/a2a/spawnIds.test.ts apps/server/src/j5/a2a/mcp/tools.test.ts apps/server/src/j5/a2a/mcp/handlers.test.ts apps/server/src/j5/playbooks/PlaybookStore.test.ts apps/server/src/j5/playbooks/mcp.test.ts apps/web/src/j5/crew/crewPlaybookPlan.test.ts apps/web/src/j5/crew/crewProposalDraft.test.ts: 16 files, 153 tests pass.resolve→CrewLaunchService→AgentCrewInstanceService: the second gets the "already owned" refusal, not a launch error, with no member row and the proposal still open;</seat_playbook>inside an id escaped in the brief;vp exec tsc --noEmit -p .inpackages/contracts,packages/client-runtime,apps/server, andapps/web: clean.vp linton the touched files: clean.Review focus
AgentCrewInstanceService.recordandaddMembers: the post-write ownership check and theON CONFLICT DO UPDATEonplaybook_step_ids. I most want the replay cases challenged.crewPlaybookPlanDigestand wherepreviewandresolvecompute it: whether anything the card shows is missing from the digest.Closes #321 (stacked on #380)
Claude Opus 5.5 via J5 Code (crew: planner, builder, and two reviewers on Claude and Codex)
🤖 Generated with Claude Code