Skip to content

feat(playbooks): steps name the persona that does them - #380

Merged
bryantderosier merged 4 commits into
j5/mainfrom
j5/319-playbook-step-personas
Sep 30, 2026
Merged

bryantderosier merged 4 commits into
j5/mainfrom
j5/319-playbook-step-personas

Conversation

@bryantderosier

Copy link
Copy Markdown
Collaborator

Problem

A playbook step had no way to say which persona should do it. A persona: line in the YAML was silently dropped, and the only way an agent could read a playbook's prompts was to start a run. So a Captain couldn't plan a Crew from a playbook. This is the first story of the Crew playbooks milestone (#319); #320, #321, #322, and #323 build on the contract it adds.

What I changed

  • packages/contracts/src/j5/playbook.ts → PlaybookStep gains optional persona (an AgentPersonaId). New PlaybookWarning (persona_missing | persona_disabled | persona_unverified, with stepId, persona, message) and PlaybookReadResponse. Discovery entries gain an optional warnings list and step persona; issue keeps its meaning.
  • apps/server/src/j5/agents/agentPersonaLibrary.ts → personaCatalogProblem, extracted from CrewProposalService.validateSeats, which now calls it. One place decides whether a persona is "missing or turned off", so the playbook warning and the propose_crew refusal can't disagree.
  • apps/server/src/j5/playbooks/PlaybookStore.ts → stepPersonaWarnings, a lazily cached catalog read per discover (only when a step names a persona), definitionPathFor shared by start and the new read. A catalog read failure becomes persona_unverified warnings and never fails a list or read.
  • apps/server/src/j5/playbooks/mcp.ts → new read-only playbook_read({ name }) tool that returns every step's prompt and persona without creating a run. playbook_list and the step tools return persona too.
  • apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts → playbook_read joins J5_PREAPPROVED_TOOLS, so Claude and Codex threads can call it without a prompt.
  • apps/server/src/j5/playbooks/instructions.ts and PLAYBOOK_AUTHOR_INSTRUCTIONS → agents learn about playbook_read and persona, and Playbook Author calls list_personas before writing one.
  • Settings → Personas → Playbooks on web (PlaybookLibrarySettings.tsx) and mobile (PlaybookLibrarySettingsScreen.tsx) → each step shows its persona, and warnings appear under the steps without disabling Start or Rename.
  • docs/user/playbooks.md → the example names a persona on one step, plus a short paragraph on warnings.

Before (j5/main: the persona: lines are dropped):

Playbook library before

After (each step shows its persona; the turned-off and missing personas get non-blocking warnings):

Playbook library after

Why this shape

  • Warnings are a separate list, never issue. Both Settings screens disable Start and Rename whenever issue is set, and a missing persona shouldn't block a playbook.
  • A malformed persona id is invalid; a missing or turned-off one is only a warning. A malformed id can never resolve, and the decode error already says what's wrong. A well-formed id may just be a persona someone hasn't added yet.
  • playbook_read never touches run state. It takes no permit, runs no SQL, and bumps no revision, so a Captain can read a playbook while its own run is active.
  • Fields are optional on the wire. Older clients ignore them, and a newer client talking to an older server reads warnings ?? [].

Invariants

  • playbook_read creates no run and no request receipt, and leaves an active run's pointer, run count, and revision unchanged.
  • playbook_read accepts the same kebab-case names as playbook_start and resolves only inside <workspace>/.j5/playbooks (real-path containment).
  • A warning never sets issue, never fails a list or read, and never blocks playbook_start.
  • propose_crew's refusal text and behavior are unchanged; only the lookup moved into the shared helper.
  • The board's PlaybookProgress.steps stays { id, title }.

Surfaces

Surface Decision
Entry points (chat, Settings, command palette, keybinding) changed: Settings playbook library and the agent tools; no palette or keybinding surface for playbooks
Clients (web, desktop, mobile) changed: web and desktop library settings, mobile library screen
Providers changed: Claude and Codex pre-approve playbook_read through J5_PREAPPROVED_TOOLS; other adapters get the same read-only tool under their own policy, as with playbook_list
Contracts (packages/contracts) changed, additive and optional, in the J5-owned src/j5/playbook.ts
Reverse states a warning clears on its own when the persona is added or turned back on, because it's read live
Connection modes (local, remote, tunnel) unaffected: same authenticated library route and MCP tools, with additive fields
Upstream files / FORK.md one line in the upstream test apps/server/src/mcp/toolkits/worktree/registration.test.ts (the exact tool inventory), already covered by the FORK.md ledger row for cases 4 and 45; no FORK.md edit
Docs changed: docs/user/playbooks.md

Out of scope

Upgrade and data

None. No migration. Existing playbooks without persona behave exactly as before, and YAML with persona: on an older server just drops the key again.

Verification

  • vp test run packages/contracts/src/j5/playbook.test.ts apps/server/src/j5/playbooks/PlaybookStore.test.ts apps/server/src/j5/playbooks/mcp.test.ts apps/server/src/j5/playbooks/PlaybookLibraryHttp.test.ts apps/server/src/j5/playbooks/PlaybookHttp.test.ts apps/server/src/j5/a2a/mcp/j5ToolPreapproval.test.ts apps/server/src/j5/a2a/mcp/handlers.test.ts apps/server/src/j5/a2a/mcp/tools.test.ts apps/server/src/j5/a2a/mcp/registration.test.ts apps/server/src/mcp/toolkits/worktree/registration.test.ts apps/server/src/j5/a2a/CrewProposalService.test.ts packages/client-runtime/src/j5/playbooks.test.ts: 12 files, 139 tests pass.
  • The missing- and turned-off-persona warnings are integration tests: a real persona library on a temp state dir, asserted from both discover and read and through the MCP handlers, with playbook_start still succeeding. There's also a persona_unverified case with an unreadable catalog, one test covering persona through start, current, next, back, and reselect, and a read-isolation test.
  • Mutation check: breaking personaCatalogProblem's missing-persona branch fails both the new store warning test and the existing CrewProposalService refusal test.
  • vp exec tsc --noEmit -p . in packages/contracts, apps/server, packages/client-runtime, apps/web, and apps/mobile: clean. vp lint on the changed files: one warning, which predates this change (an unused fs in agentPersonaLibrary.ts).
  • Screenshots come from an isolated dev server with a sample playbook, an enabled persona, a turned-off persona, and one missing persona. Web only; I didn't run mobile.

Review focus

  • PlaybookStore.read and definitionPathFor: name checks and containment, and confirming read has no side effects on run state.
  • The personaCatalogProblem extraction in CrewProposalService.validateSeats: missing is still checked before turned-off, and the refusal wording is unchanged.

Closes #319

Claude Opus 5.5 via J5 Code (crew: planner, builder, and two reviewers on Claude and Codex)

🤖 Generated with Claude Code

A playbook step may carry `persona: <persona-id>`. playbook_list, the new
read-only playbook_read tool, and every step tool return it. A persona that
is missing from the library or turned off shows up as a non-blocking entry in
`warnings`, never in `issue`, so the definition still starts. The check is
shared with propose_crew through personaCatalogProblem. Settings on web and
mobile show each step's persona and the warnings.

Closes #319

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bryantderosier bryantderosier added enhancement New feature or request size:M 30-99 effective changed lines (test files excluded in mixed PRs). labels Sep 29, 2026
@bryantderosier bryantderosier self-assigned this Sep 29, 2026
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: Jacksondr5/j5code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1d918034-c995-4b48-b6d7-91e940f364b2

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 effective changed lines (test files excluded in mixed PRs). and removed size:M 30-99 effective changed lines (test files excluded in mixed PRs). labels Sep 29, 2026

@Jacksondr5 Jacksondr5 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Review panel: Opus 5.5, Astra, Sonnet 5.5, Sol 6.1]

Approving. All four reviewers agree #380 is ready. Three of us ran it live on a copied database: persona-tagged steps show their persona in the library, a missing persona gives a non-blocking warning, and playbook_read returns the personas.

FORK.md needs no change here. The existing registration.test.ts | A | 4, 45 row and case 4 already cover adding a tool name to the inventory.

Findings for the rest of the stack are on #383 and #384.

@vercel

vercel Bot commented Sep 30, 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 Sep 30, 2026 5:36pm UTC

Request Review

docs/user/playbooks.md keeps the step-persona paragraph ahead of #314's
reworded /playbook paragraph.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
instructions.ts keeps the persona authoring line and appends #381's mention
bullet.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bryantderosier
bryantderosier merged commit 73e9a51 into j5/main Sep 30, 2026
37 checks passed
@bryantderosier
bryantderosier deleted the j5/319-playbook-step-personas branch September 30, 2026 18:19

This branch was successfully deployed

1 active deployment
Preview — 5b23f95a Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L 100-499 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.

Playbook steps name the persona that does them

2 participants