Request lifecycle and orchestration
End-to-end execution from ask and confirm through Strategist DAG lanes, capacity scheduling, autonomy modes, and failure recovery ladders.
Every feature, fix, or incident moves through turbo-12f as an append-only request under requests/<id>/. The orchestrator splits accepted specs into dependency-ordered lanes, runs deterministic gates and AI steps, merges passing lanes onto staging, and validates the release before merging to main.
Ask & confirm
Lock an OpenSpec change with verbatim quotes, then pass the Project Gate.
Strategist & lanes
Plan dependency-ordered worktrees and run each lane through 11 steps.
Merge to staging
Evaluate merge policy, rebase sequentially, and wait for a quiet queue.
Release & main
Run whole-tree staging checks, bisect failures, sign off, and merge to main.
End-to-end request flow
- Intake (
t12 ask): Starts on--project-diror--repo, collects quoted must-haves, images, and issues viat12 conversation issuesorPOST /api/c/{id}/issues, and clears readiness checks. - Confirmation (
t12 confirm): Binds the request to a new or adopted repository, initializes.t12/, and runsdevops.Gateto verify clean branches, pinned skills, dependencies, and base checks onbranches.staging. - Lane execution (
t12 run): Callsorchestrator.Run(orchestrator.go). Strategist splits the spec into dependency-linked tasks (EvTaskAdded) that run in parallel worktree lanes. - Release lane: Once non-parked lanes merge into
staging,orchestrator.Runlaunches the request-levelreleaselane (ReleaseLane = "release"). - Release checks & bisection: factory.go runs
qc,uicheck,redteam, anddeploy-dry-run(plus optionalqc.explorer) onstaging. Failures triggerfixReleasebisection and<culprit>-rf<N>fix lanes for up to3passes. - Promotion (
t12 release merge): Aftert12 release gateturns green and the acceptor signs off,branches.stagingmerges--no-ffintobranches.main(main,master, orstaging).
From a sentence to main
People decide at start and release; core scripts gate every lane transition through staging, sign-off, and post-deploy SRE watch.
Click any node or press PlayLane plan and sequential vs target execution
Each worktree lane runs an 11-step sequence defined by orchestrator.LanePlan:
| Step | Role | Responsibility |
|---|---|---|
| 1 | analyze (internal/roles/analyzer) | Plans changed files, test specs, and predicted screens on staging |
| 2 | engineer (internal/roles/engineer) | Writes failing tests first, then production code inside a Docker cage |
| 3 | qc (internal/roles/qc) | Runs build, typecheck, lint, comment-ban, test-guard, scenario-text, unit, e2e, and mutation |
| 4 | ui-check (internal/roles/uicheck) | Settles 5s (SettleSeconds), compares PNG SHA-256 baselines, and flags overflow or unpredicted screens |
| 5 | deslop (internal/roles/deslop) | Runs regex, AST, and clone hygiene rules plus a read-only audit |
| 6 | red-team (internal/roles/redteam) | Runs gitleaks, osv-scanner, cross-origin POST checks, and visitor replay probes |
| 7 | code-review (internal/roles/codereview) | Checks unrequested edits, unlisted dependencies, hypotheses, and prior findings |
| 8 | merge-policy (internal/mergepolicy) | Evaluates data-loss, auth, licence, delivery, and review bound to git patch-id --stable |
| 9 | merge (internal/mergequeue) | Takes merge-queue.lock, rebases onto staging, rechecks if tree changed, and fast-forwards |
| 10 | deploy-dry-run (internal/roles/devops) | Validates staging deploy artifact once the quiet window clears |
| 11 | sre (internal/roles/sre) | Watches staging health probes over a short observation window |
Sequential implementation vs. target parallel checks
design.md specifies running E2E, UI check, and Red team in parallel after qc. Today runLane in internal/orchestrator/orchestrator.go runs every step strictly sequentially.
One lane, step by step
Each task runs the ordered 11-step LanePlan backed by step-done checkpoints; any failure hands control to the deterministic Router.
Click any node or press PlayConcurrency, priority, and file locks
slots.go separates LLM concurrency from verification container concurrency using two semaphore pools (slotOf):
| Pool | Steps covered | Default capacity | Priority order |
|---|---|---|---|
agentSlot | analyze, engineer, code-review | 4 (project.DefaultAgentSlots) | Resumed fixes first, longest chain, then FIFO |
checkSlot | qc, ui-check, deslop, red-team, merge, deploy-dry-run, sre | max(1, NumCPU / 2) (DockerCPUs / 2 in Docker) | Same priority{fix, chain, seq} comparator |
| Unslotted | merge-policy | Unbounded | Runs immediately inside runLane |
Three coordination rules in queue.go and slots.go prevent lane collisions:
- File locks (
fileLocks): Active whenoverlapis"wait"(vs. default"parallel"). Engineer locksAnalyzetarget paths in sorted order before editing and releases onMergeor send-back. - Quiet window (
waitQuiet): Delaysdeploy-dry-rununtilqueued == 0(counting lanes betweencode-reviewandmerge) and120s(DefaultQuietWindowS) pass without queue changes. - Live capacity resizing: Every
15s(LiveCapacityEvery), reads.t12/config.jsonand.t12/preferences.jsonfromrefs/heads/<staging>and updates pool limits live.
Strategist task planning and parallel lanes
Before launching lanes, Orchestrator calls strategist.Route (plan.go, dag.go) to build a task DAG, falling back to strategist.Tasks when planning is skipped or invalid.
| Mechanism | How Orchestrator handles it |
|---|---|
| Upfront queue & snapshots | QueueTasks writes EvTaskAdded upfront (Tasks replays on resume); each step snapshots Ctx.Tasks under tasksMu. |
| Dynamic seam splits | Oversized tasks split into <parent.ID>-1..N via checkSplit and strategist.Split. Split children require size_waiver (parking below turbo). |
| Task Gate status | design.md defines a pre-lane Task Gate to drop duplicate/passing work; today Strategist checks DAG partitions and Orchestrator enforces depsDone/pausedDeps. |
See Strategist internals for PlanTimeout and partition rules.
Strategist rules, send-back sync, and fallback decisions
When a step fails or reports blocking findings, orchestrator.route checks deterministic rules (rules.Match) before calling strategist.Decide:
mergesend-back sync (sendback.go):handleSendBackemitsEvSendBackwith"sync_staging": true. At Engineer start,syncWorktreeIfPendingcallsgitio.SyncOntoStaging, squashes ontostaging, blocks on binary/UDconflicts, and leaves text conflict markers with a cleared index for the caged Engineer.- Fallback & rule proposals: Unmatched steps (
analyze) or repeatrootHashhits (state.hashes[hash] == 1) invokestrategist.Decideand feedproposals/strategist-rule-*.json.
Failure routing and budgets
Fix attempts and retry tokens stay on separate budgets; one repeated root cause triggers a free route switch before stopping on a third.
Click any node or press PlayRecovery ladders and autonomy levels
Before spending a retry token or parking a lane, Orchestrator climbs five recovery rungs:
- In-place retry (
StepRetries): Retries infrastructure errors (couldNotRun) with no open questions, appendingEvRetried. - Auto-answer (
AnswerQuestions): CallsanswerForYouwhen questions stop a step, logs"answered-for-you"(EvAnswer), and reruns (i--). - Engineer fix attempts (
FixAttempts, default3): HandlesConflict,turn-cap, andengineer-routed failures at zero request tokens (diff-capchecksgitio.Tree.AddedLineCount). - Analyze retry tokens (
tokenPool, default2): Restarts fromanalyze(ctx.Resume = "analyze").diff-capsend-backs and second hits (state.hashes[hash] == 1) of arootHashrun withfree: true. - Lane pause (
EvProblem): Triggers on a third identicalrootHash(state.hashes[hash] >= 2) or exhausted budgets, settingerrPausedandpausedDepswhile other lanes continue.
autonomy.go resolves four presets via Preferences.ResolveAutonomy(os.Getenv("T12_AUTONOMY")). Selecting a mode in t12 ui writes <home>/access/mode.json and injects T12_AUTONOMY into worker subprocesses; in review (Request Review), every shell command also waits in internal/approvals.
| Level | FixAttempts | RetryTokens per task | StepRetries | AnswerQuestions | Merge-policy and review waits |
|---|---|---|---|---|---|
review | Config value (default 3) | Config value (default 2) | 0 | 0 | PartsWait: true (every lane waits), MatchesWait: true, diff-cap-waiver waits |
default | Config value (default 3) | Config value (default 2) | 0 | 0 | MatchesWait true unless merge_policy.mode is "auto"; diff-cap-waiver waits |
auto | Minimum 4 | Minimum 3 | 2 | 1 | Same match waits as default; diff-cap-waiver waits |
turbo | Minimum 5 | Minimum 5 | 4 | 3 | MatchesWait: false; only "data-loss" waits (diff-cap-waiver waived) |
Five-layer recovery ladder
Every failure starts at the cheapest automatic retry and climbs one layer at a time until a budget stops or a person steps in.
Click any node or press PlayKey takeaway
Orchestrator keeps model judgment out of lane progression: every split, retry, merge lock, and pause is driven by deterministic Go state over requests/<id>/events.jsonl.
Next steps
System overview
How turbo-12f stacks its Go packages, enforces zero external Go dependencies, and separates no-net/http core binaries from HTTP companion and driver processes.
Agent roles
How the thirteen role packages under internal/roles and the internal/observer loop combine deterministic scripts with bounded LLM sessions.