No worktree?
Factory asks before working in place and records whose consent allowed it.
Factory run map / public operating contract
Factory is not a swarm that runs until it feels finished. It is a bounded delivery system: one phase per fresh session, one executable gate after every phase, and a deliberate stop whenever the next decision belongs to you.
scripts/run.sh <slug>Execution contract
scripts/run.sh <slug> runs exactly one phase, gates the phase that just closed, and stops whenever the next decision belongs to you.
One phase per fresh session
Compact state and run artifacts cross sessions
Every closed phase must pass its gate
Phase map / 0 → 6
gate.py --phase 0Classify a ticket, Sentry URL, or written request. Separate the reported symptom from evidence and turn the ask into criteria that can fail.
gate.py --phase 0bCreate a worktree and branch from a recorded baseline. If isolation is impossible, Factory asks before touching the active checkout.
gate.py --phase 1Reproduce the problem, trace the cause, and use at most two leaf-agent attempts. Light-depth runs move from a proven baseline directly to planning.
NEEDS-YOUReview the acceptance criteria, milestone demonstrations, release targets, and open decisions. Revise the plan until it is clear.
gate.py --phase 2bFacts go to one leaf agent per round. Decisions come back to you one question at a time. Three rounds are allowed before an honest blocked state.
gate.py --phase 3Translate the human plan into bounded milestones. The equivalence review checks scope, then Factory seals both plans against unreviewed edits.
gate.py --phase 4Test and review one stage at a time. Defer optional ideas, demonstrate the result, and verify any authorized preview before continuing.
gate.py --phase 5Scan full changed files and callers, rerun the acceptance matrix, and use independent reviewers to challenge invariants and the whole change.
Terminal gateReport tokens, sessions, receipts, and the draft PR. The record permits delivered, delivered-with-gaps, blocked, or intentionally-unchanged.
Human boundary
Isolation consent, scope revisions, preview publication, unanswered product questions, and the final claim remain explicit human boundaries.
Factory asks before working in place and records whose consent allowed it.
The grill returns one decision at a time. Code waits until the blocking frontier is empty.
The loop stops, names the cap, and reports what remains instead of quietly retrying.
Factory records it for the handoff. The approved milestone continues unless an existing criterion requires a revised plan.
Bounded autonomy
| Signal | run.sh does |
|---|---|
| Approved plan changes | Block the next milestone until human review and a new scope lock. |
| Preview awaits publication | Print NEEDS-YOU; an unattended run cannot publish. |
| Next phase is 2, 2b, or 6 | Print NEEDS-YOU and exit 0. Run /factory resume <slug>, then rerun. |
| The closed phase gate says BLOCKED | Print the reasons and exit 1. Nothing starts on an unpassed predecessor. |
| state.terminal is set | Exit 0. The run is over. |
| sessions_used reaches sessions_max | Exit 0 and name the cap. |
| Two sessions change neither phase nor milestone | Rerun the gate for the reasons, then exit 1. |
| leaves_used exceeds leaves_max | Block at the gate. Only a blocked terminal may still close. |
Terminal gate
deliveredEvery acceptance criterion is proven.
delivered-with-gapsNamed gaps were explicitly accepted by you.
blockedA fact, decision, gate, or budget prevents correct delivery.
intentionally-unchangedEvidence shows that changing code is not the right treatment.
Keep the map
The long edition keeps the whole system on one canvas. The A4 edition splits the flow only at a phase boundary and repeats the reading context.