# Session Lifecycle This runbook is the minimum lifecycle contract for agents using BeadBoard Driver. ## 1) Session Start 1. Run preflight and discovery checks: ```bash node {baseDir}/scripts/session-preflight.mjs ``` 2. Create or identify your agent bead first (required before claiming work): ```bash bd create --title "Agent: " --type task --priority 0 --label "gt:agent,role:" ``` 3. Set state transitions and attach hook when work begins: ```bash bd agent state spawning bd agent state running ``` 4. Query hard memory for your domain before claim: ```bash # Select domain: memory-arch | memory-workflow | memory-agent | memory-ux | memory-reliability bd query "label=memory AND label=mem-canonical AND label= AND status=closed" --sort updated --reverse ``` ## 2) Discover Work and Read Epic Context 1. Find ready work: ```bash bd ready ``` 2. For child tasks, read parent epic first: ```bash bd show bd children ``` 3. Read full assigned bead: ```bash bd show ``` ## 3) Claim Correctly (`--assignee`, not `--claim`) Claim order is strict: 1. Agent bead exists 2. Set bead to in_progress with assignee 3. Hook agent slot to current bead ```bash bd update --status in_progress --assignee bd slot set hook bd agent state working ``` ## 4) Dependency Workflow During Execution Use dependencies to model execution order, not visual grouping. Add blocker dependency (`` depends on ``): ```bash bd dep add ``` Add non-blocking related context link: ```bash bd dep relate ``` Inspect dependency state: ```bash bd dep list bd dep tree ``` ## 5) BLOCKED Path (Mandatory Pattern) When blocked, do all four actions: 1. State signal: ```bash bd agent state stuck ``` 2. Coordination signal: ```bash bd mail send --to --bead --category BLOCKED --subject "" --body "" ``` 3. Keep heartbeat while waiting: ```bash bd agent heartbeat ``` 4. Resume cleanly once unblocked: ```bash bd agent state running bd agent state working ``` ## 6) Verification and Closure Run gates before close claims: ```bash npm run typecheck npm run lint npm run test ``` Record evidence and close bead: ```bash bd update --notes "Commands run: ... Outputs: ..." bd close --reason "" ``` Detach hook when bead is complete: ```bash bd slot clear hook bd agent state done ``` ## 7) Memory Review Rule (Create vs Skip) Create/supersede canonical memory only when BOTH are true: - Rule is reusable across future tasks - Evidence exists from at least one concrete failure/recovery pattern Otherwise, record: ```bash bd update --notes "Memory review: no new reusable memory." ``` If reusable and novel: - Create new memory decision bead - Link anchor + evidence via `bd dep relate` - Supersede old memory if replacing policy (`bd supersede --with `) ## 8) Session End Hygiene 1. Ensure no lingering hook slot: ```bash bd slot show ``` 2. Ensure no unresolved required-ack backlog for your active work. 3. Set end state: ```bash bd agent state stopped ```