Playbooks and flows
Playbooks and Flows add a coordination view on top of existing Kheish primitives. They do not introduce a second runtime. Use this model when you want a durable, reviewable procedure that starts normal session runs and then tracks the daemon evidence those runs produce.Model
A Playbook is an immutable, digest-covered manifest version. It describes:- the objective
- expected inputs
- preconditions
- roles
- phases
- acceptance criteria
- evidence expectations
- tool policy hints
- provider and model defaults
- capability and credential scope guidance
draft, verified, canary, active, or revoked.
A Flow is one durable projection of a started Playbook version. It stores correlation data and references to Kheish primitives such as:
session_id- the root
run_id - root and sidechain agent ids linked to the root run
- runs in sidechain sessions spawned from the root run
- session task ids created by scoped runs or legacy scoped agents
- pending and historical approval/question ids visible through run state and run events
- output and debug evidence reachable through the normal run APIs
interrupted for audit while the Flow projection still reaches a useful terminal state from scoped child work. A failed scoped run or task makes the Flow fail closed instead of reporting success from a root answer alone.
Why this is not a workflow engine
Kheish still executes work through sessions and runs. A Flow start wraps a normalSubmitInputRequest, attaches daemon-owned kheish_flow metadata, and schedules the underlying session run through the existing run path.
This avoids duplicating:
- run scheduling
- approvals and questions
- background task tracking
- sidechain agents and mailboxes
- MCP and tool exposure
- connector and output routing
- debug artifacts
- restart recovery
Release safety
Only startable Playbook versions can start Flows. Startable states are:verifiedcanaryactive
Correlation metadata
Flow start reserves the metadata keykheish_flow. Callers cannot provide that key themselves on normal run input. The daemon writes it when starting a Flow so run views and debug evidence can be correlated back to:
flow_idplaybook_idversiondigest- a daemon-generated correlation nonce
Evidence Used
- API routes and DTOs:
crates/kheish-daemon/src/api/handlers.rs,crates/kheish-daemon/src/playbooks.rs - Execution path:
crates/kheish-daemon/src/state/playbook_workflow.rs,crates/kheish-daemon/src/state/run_workflow.rs - Existing primitives: Sessions and runs, Agents and sidechains, Approvals and questions, Tasks and schedules
Evidence Note
- Code verified:
crates/kheish-daemon/src/playbooks.rs,crates/kheish-daemon/src/state/playbook_workflow.rs,crates/kheish-daemon/src/control_tools/helpers.rs,crates/kheish-daemon/src/control_tools/tasks.rs,crates/kheish-daemon/src/control_tools/bash.rs. - CLI/API verified:
playbooks ...,flows ...,agents list,runs events,tasks list/outputsurfaces checked against command and handler code. - Daemon live tested for this note: no; deterministic Flow projection tests cover root, sidechain, approvals, and tasks.
- Provider-specific tested for this note: no; Flow projection is provider-neutral.
