Repository navigation
Description
Item 9 of 9 in the Playbooks v2: one owner, flexible staffing milestone. It doesn't depend on the others and can land any time.
The problem
How playbooks get saved doesn't match who's allowed to change things, or how personas handle team copies:
- Settings only lets Owners save, but any agent can call
j5_playbook_save, whoever is driving it. - Playbook Author is told to write
.j5/playbooksfiles straight into the workspace, which skips both the library and the save check. - A team-folder playbook can't be edited at all, and copying it to the library fails because the name is taken.
Where this sits
This is section 5 of the Playbooks proposal (26 October), "Authoring":
- Conversation is the main way to write playbooks. I approve the draft before it's saved, and cancelling saves nothing.
- Only Owners save. A Collaborator who asks gets a draft, not a save.
- New playbooks go to the environment library unless I ask for a workspace-only one.
- Editing a team-folder playbook in conversation saves a library copy that overrides the folder version, the same as persona decision 11. The agent warns first that the copy hides later team updates, and that removing the copy brings the team version back.
The workspace-over-library rule (AC14) doesn't change.
What we already have
- MCP save.
j5_playbook_save(apps/server/src/j5/playbooks/mcp.ts:53-61,162-180) checks plan mode and the persona's write policy, but not the person's role. - RPC save. It requires
settings:write, which only Owners hold (playbookRpc.ts:22-33,59-60,packages/contracts/src/j5/clientRpcPermissions.ts:43-47). PlaybookLibrary.save.PlaybookLibrary.ts:203-256does three things:- the digest check (
:214-231,stale_digest); - refusing an edit of a playbook outside the library (
:233-237); - refusing a new name that any source already holds, folders included (
:238-243).
- the digest check (
- Resolution order. Workspace, then the environment library, then configured folders (
:78-129).selectPlaybookSource(:28-52) raisesduplicate_nameat:46-49. - Folder playbooks are read-only for delete and rename (
PlaybookStore.ts:476-479,538-541). "Copy to library" in Settings (PlaybookLibrarySettings.tsx:145-161,364) fails on a same-named copy. - Playbook Author. It has workspace write and is told to write
.j5/playbooksfiles directly (packages/client-runtime/src/j5/playbooks.ts:32,77,91-106). It runs from webPlaybookConversationDialog.tsxand mobilePlaybookConversationModal.tsx. - The persona precedent. An imported copy overrides its folder or bundled source (
agentPersonaLibrary.ts:414-434). Edits checkexpectedDigest(:534-582), and import replaces an existing id only after the person confirms by digest (:497-520). A clash between two folders is still a hard error (:258-262).
Proposal
- The library save checks the role of the person behind the call. The RPC already does. MCP needs the person driving the agent; see the open question below.
- A library copy with the same name as a folder playbook is the override, not an error. Resolution becomes workspace, then library, then folder, so removing the library copy brings the folder version back.
- Playbook Author saves through
j5_playbook_saveto the library, shows the full draft first, and saves only after I approve. It writes a workspace file only when I ask for a workspace-only playbook.
Acceptance criteria
- Only Owners can save a library playbook, through MCP or RPC. For a Collaborator,
j5_playbook_saveis refused with a reason the agent turns into "here's the draft; an Owner needs to save it", and the draft stays in the conversation. - Workspace-only playbooks in
.j5/playbooks/stay ordinary repository files and follow the workspace's own write access. - Playbook Author shows the full draft and saves only after the person approves it. Cancelling saves nothing.
- New playbooks go to the environment library unless the person asks for a workspace-only one.
- Editing a team-folder playbook in conversation saves a same-named library copy that overrides the folder version. Before saving, the agent warns that the copy hides later team updates, and that removing the copy brings the team version back. "Copy to library" in Settings does the same, with the same warning.
- A library playbook and a folder playbook with the same name is no longer an error; the library copy wins. Two folders with the same name are still an error, and the workspace still beats both.
- Settings marks a library playbook that overrides a folder one, and removing it brings the folder version back with no other step.
- Existing library edits still need the current digest.
- Focused tests cover: an Owner save; a Collaborator refused through MCP and through RPC; a library copy overriding a folder playbook; removing it restoring the folder version; a two-folder clash still erroring; and the workspace beating the library.
-
docs/j5/product/features/playbooks.mdAC15 and the definition's library paragraph are rewritten.docs/j5/user/playbooks.mdexplains overrides and who can save.
Surfaces
Settings and Playbook Author on web, desktop, and mobile; MCP for agents; and remote connections, where the person behind a connection carries their level.
Open question
How does j5_playbook_save know which person is behind the agent? I'd use the person whose message started the agent's current turn. People and access (#638) already attributes messages in shared conversations (apps/server/src/j5/sharing/SharedConversation.ts), and the PR should confirm that covers every turn. A turn with no person behind it, like a scheduled task or a message from another agent, would be refused for library saves. Does that hold up, or does the save need its own confirmation from an Owner?
Activity
[-]Playbooks: owner guidance for starting, working, and finishing[/-][+]Playbooks: only Owners save, and a library copy overrides a team folder[/+]