A workflow that can prove the task is done.
Ten states, eight phases plus a policy gate, and one rule: completion is evidence, not a claim. This reference keeps the original lifecycle and adds the invariants that make it safe to run unattended.
The lifecycle at a glance
Eight phases plus a policy gate. Self-audit and the Oracle are parallel checks, not a chain; the Oracle is mandatory for promise mode and high-risk audit mode.
- 00
Intake & policy
Classify type and complexity, attach risk, spend and data-access policy. Pick a strategy with enough evidence.
- 01
Recon & plan
Inspect the workspace, images and memory. Write plan.md with steps, risks, dependencies and a verification plan.
- 02
Execute
Run with a scoped sandbox and a heartbeat. Every tool call that mutates state is idempotent.
- 03
Self-audit
Check acceptance criteria against the plan. Produce structured evidence, not prose only.
- 04
Oracle
Independent, clean-context verifier re-runs or attests the evidence. No access to the agent’s session history.
- 05
Peer review
Blind, rotated reviewer checks quality and risk. Same-pool peers are not enough for critical work.
- 06
Human gate
Approval depends on reversibility, spend, data access and blast radius — not just complexity.
- 07
Orchestrate
DAG dependencies, leases, cycle detection and workload-aware routing.
- 08
Watchdog & post-mortem
Detect stalls vs waiting, escalate by tier, preserve evidence and extract structured lessons.
State machine
Every transition needs an owner, a guard and an audit event. Terminal states never transition again.
| State | Entered when | Meaning |
|---|---|---|
pending | created + classified | Task is valid and has an owner. |
planning | complex task | Recon and plan are in progress. |
pending_clarification | gaps found | A specific question is waiting; max 3 rounds. |
in_progress | plan approved / simple | Agent is executing with a lease. |
audit | execution complete | Self-audit is running. |
promise | promise-mode completion | Promise gate and Oracle are running. |
peer_review | audit passed | Independent peer checks the result. |
pending_review | peer approved | Human gate is waiting. |
completed | all gates passed | Terminal; write the score and evals. |
blocked | stuck / 4+ fails | Needs escalation; never silently retried. |
transition(task, from, to):
assert task.state == from
assert guard(from, to) # owner, lease, evidence
update tasks set state = to
where id = task.id and state = from # compare-and-set
append audit_log(task, from, to, actor, evidence_hash) Rejection context and retry
A retry without structured feedback is just another attempt at the same mistake.
| Failure | Action | Context policy |
|---|---|---|
| 1–2 | Same session, continuation prompt with rejection-context.json. | Fix only listed issues. |
| 3 | Prune context, switch strategy, fresh session. | Keep task brief, rejection context and new strategy only. |
| 4+ | Block and escalate to the human owner. | Dead-letter with full evidence; no silent loop. |
Evidence contract
An Oracle with clean context is only as good as the evidence it is given.
| Field | Requirement |
|---|---|
| Command | The exact command or tool call, with its working directory and environment version. |
| Output | Exit code, stdout/stderr hashes and the relevant excerpt. |
| Artifact | Hash, path, size and timestamp of every produced file. |
| Check | The acceptance criterion it satisfies and who verified it. |
| Nonce | A unique task/attempt identity so stale evidence cannot be replayed. |
{
"task_id": "TSK-042",
"attempt": 2,
"nonce": "9f3c…",
"checks": [
{"criterion": "service returns 200",
"command": "curl -fsS https://…/health",
"exit": 0, "output_hash": "sha256:…",
"verified_at": "2026-10-26T08:00:00Z"}
],
"artifacts": [{"path": "…", "sha256": "…"}]
} Human gates by risk
Complexity alone is the wrong trigger for a human.
| Risk | Examples | Gate |
|---|---|---|
| Low | Draft, research, formatting | Auto-approve after self-audit plus sample review. |
| Medium | Publishing, customer-visible content | Peer review; human spot-check. |
| High | Deploy, spend, delete, credentials | Human approval with evidence and rollback plan. |
| Critical | Money movement, legal, personal data | Two-person rule; Oracle plus human. |
DAG orchestration
- One project, one lock. The orchestrator claims a project with a lease before spawning.
- Cycle detection before execution; a dependency graph with a cycle is a configuration error.
- Idempotent spawn: checklist item + project + attempt is the unique key.
- Workload-aware routing uses live leases, not stale counters.
- Partial failure leaves completed items checked and failed items blocked with evidence.
Watchdog and post-mortem
Watchdog
- Heartbeat from the acting agent; lease expiry, not just “no status change”.
- Distinguish waiting on a human from stuck.
- Tiered escalation with a deadline at each tier.
- Budget guard: time and token ceilings per task.
Post-mortem
- Evidence first: rejection context, decision trace, score history.
- LLM proposes; the evaluation set decides.
- Lessons are structured: trigger, action, evidence, confidence.
- Only evaluated lessons enter the shared brain as trusted.
What to measure
| Metric | Question |
|---|---|
| Lead time | Created → completed, p50/p95, split by task type. |
| First-pass rate | Completed without retry or human reject. |
| Oracle catch rate | Failures found by the Oracle but missed by self-audit. |
| Retry cost | Tokens and time spent per successful task. |
| Human load | Approvals per day and time-to-decision. |
| Post-mortem action rate | Lessons that changed a strategy and passed evaluation. |
Failure modes
| Failure | Cause | Fix |
|---|---|---|
| Double completion | Watchdog + agent finish at the same time | Terminal-state guard, idempotency key, compare-and-set. |
| Context-loop retry | Agent repeats the same failed approach | Structured rejection, strategy switch, fresh session at 3rd failure. |
| Oracle theatre | Agent supplies its own “evidence” | Evidence contract, nonce, independent re-run, signed tool output. |
| DAG race | Two orchestrators spawn the same task | Project lock, lease, cycle check, idempotent spawn key. |
| Peer collusion | Same-pool reviewers approve each other | Blind review, rotation, independent quality sample. |
| Zombie task | Status stuck with no heartbeat | Heartbeat + lease expiry; distinguish waiting from stuck. |