Skip to Content
turbo-12f
Architecture

Request lifecycle and orchestration

End-to-end execution from ask and confirm through the team flow's dependency-ordered lanes, capacity scheduling, autonomy modes, and failure recovery ladders.

Explanation

Every feature, fix, or incident moves through turbo-12f as an append-only request: a hash-chained event stream request:<id> in Postgres. 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.

Stage 1

Ask & confirm

Lock an OpenSpec change with verbatim quotes, then pass the Project Gate.

Stage 2

Tech Lead & lanes

Split the spec into dependency-ordered worktrees and run each lane through the flow's steps (six in team).

Stage 3

Merge to staging

Evaluate merge policy, rebase sequentially, and wait for a quiet queue.

Stage 4

Release & main

Run whole-tree staging checks, bisect failures, sign off, and merge to main.

End-to-end request flow

  1. Intake (t12 ask): Starts on --project-dir or --repo, collects quoted must-haves, images, and issues via t12 conversation issues or POST /api/c/{id}/issues, and clears readiness checks.
  2. Confirmation (t12 confirm): Binds the request to a new or adopted repository, initializes .t12/, and runs devops.ProjectGate to verify clean branches, pinned skills, dependencies, and base checks on branches.staging. --acceptor names the person who accepts the conversation.
  3. Lane execution (t12 run): Calls orchestrator.Run (orchestrator.go). orchestrator.ChooseFlow records the conversation's flow, then the Tech Lead's split (strategist.Route) turns the spec into dependency-linked tasks (EvTaskAdded) that run in parallel worktree lanes.
  4. Release lane: Once non-parked lanes merge into staging, orchestrator.Run launches the request-level release lane (ReleaseLane = "release").
  5. Release checks & bisection: stepRelease (run_release.go) installs dependencies on staging, then runs qc, uicheck, redteam, and deploy-dry-run (plus optional qc.explorer), the same in both flows. The result is stored per staging tree: a passed tree is not checked again, and a failed one is run again by a newer factory build. When Red team or the explorer proves a finding, fixRelease bisects the merges since main and opens <culprit>-rf<N> fix lanes for up to 3 passes.
  6. Promotion (t12 release merge): After t12 release gate turns green and the acceptor signs off, branches.staging merges --no-ff into branches.main (default main) once every request's hash chain verifies, and the merge is pushed to GitHub. On a team project the acceptor is any owner, member or Operator (a client only on their own requests); otherwise the opener. devops.Promote then deploys the artifact that staging built to the person's own Cloudflare or Vercel account, checks the site answers, and rolls back if it does not; with no account connected, production stays a dry run and is refused.

From a sentence to main

Flow
100%
Specification to stagingRelease, promotion & SREstaging treenew ask1. AskContext creator2. Confirmspec + DevOps gate3. Tech Leadsplit to parts4. Part lanesplan · build · QA5. Stagingmerge queue tip6. Release gatetree-hash checks7. Sign-offbug bash · sign-off8. Main branchpromote dry-run9. SRE watchprobes · triageNew requestSRE defect ask

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 Play

Flows: the steps every lane runs

Each worktree lane runs the steps of the conversation's flow (flow.go). ChooseFlow reads the project's flow preference once and records it as a flow-chosen event before the first part starts, so a conversation keeps its flow when the preference changes later; a conversation whose lanes ran before flows existed keeps classic. t12 run prints the choice, for example flow: team (analyze, engineer, qa, merge-policy, merge, deploy-dry-run).

StepTeam memberResponsibility
1analyze (Tech Lead, internal/roles/analyzer)Plans changed files, test specs, and predicted screens on staging
2engineer (Developer, internal/roles/engineer)Writes failing tests first, then production code inside a Docker cage; each candidate it hands over is checked in its session (qc, ui-check, Red team's origin check)
3qa (QA, stepQA)Runs qc, then ui-check, then one code-review session, stopping at the first that fails; reuses a qc or ui-check pass the Developer's session earned on the same commit
4merge-policy (DevOps, internal/mergepolicy)Evaluates data-loss, auth, licence, delivery, and review bound to git patch-id --stable
5merge (DevOps, internal/mergequeue)Verifies the request's hash chain, takes the home:merge-queue lease, rebases onto staging, rechecks if tree changed, and fast-forwards
6deploy-dry-run (DevOps, internal/roles/devops)Validates staging deploy artifact once the quiet window clears

A part costs three agent sessions (plan, build, review). QA's one review stands in for Code review, Deslop, and Red team, so it gets three times a single reviewer's cost budget. A blocking qa finding goes back to the Developer as a fix attempt, and no Strategist session is asked. Deslop, Red team, and SRE do not run per part; Red team still runs in the release checks.

In both flows the step right before merge-policy is the lane's last check (Flow.Review): qa in team, code-review in classic. Adding a step means a constant in internal/orchestrator, a StepFunc in cli.runSession.steps, an entry in the flow's Steps (and Owners), a found_by rule in assets/strategist/rules.json, and a label in the web's lib/steps.ts; TestEveryFlowStepIsWiredAndOwned fails until it is wired, owned, and routed.

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

Flow
100%
team flow · 6 steps · sequential per lane · step-done checkpointspassfailfindingconflictfixreplanpolicy park1. AnalyzeTech Lead · plan · split2. EngineerDeveloper · tests first3. QA: tests & screensqc · ui-check · 5s settle3. QA: one reviewcode-review · last check4. Merge policyDevOps · risk & paths5. Merge queuecheck slot · staging tip6. Deploy dry runDevOps · quiet windowRules routerRulesDeveloper fix or Tech Lead replanParked lanewaits for t12 approve

Each part runs the six steps of the team flow (Tech Lead, Developer, QA, DevOps) backed by step-done checkpoints; any failure goes to the rules router, which asks no model.

Click any node or press Play

Concurrency, priority, and locks

slots.go separates LLM concurrency from verification container concurrency using two semaphore pools (slotOf):

PoolSteps coveredDefault capacityPriority order
agentSlotanalyze, engineer, qa, code-review4 (project.DefaultAgentSlots)Resumed fixes first, longest chain, then FIFO
checkSlotmerge, deploy-dry-run, and in classic qc, ui-check, deslop, red-team, sre; the checks an Engineer session runs on its candidates take one toomax(1, NumCPU / 2) (DockerCPUs / 2 in Docker)Same priority{fix, chain} comparator, then arrival order
Unslottedmerge-policyUnboundedRuns immediately inside runLane

Three coordination rules in queue.go and slots.go prevent lane collisions inside one run:

  • File locks (fileLocks): In-process, active when overlap is "wait" (vs. default "parallel"). Engineer locks Analyze target paths in sorted order before editing and releases on Merge or send-back.
  • Quiet window (waitQuiet): Delays deploy-dry-run until queued == 0 (counting lanes between the flow's last check and merge) and 120s (DefaultQuietWindowS) pass without queue changes.
  • Live capacity resizing: Every 15s (LiveCapacityEvery), reads capacity.agent_slots and capacity.check_slots from .t12/preferences.json on refs/heads/<staging> and updates pool limits live.

Locks between processes are database leases, not lock files: a holder renews its lease while it works and a dead holder's lease expires on its own.

LeaseHeld byBehavior
req:<kind>:<id>ask, confirm, context, run, run-merge, releaseWaits 10 s, then reports another command holds it; confirm then context then ask order kept
home:merge-queueMerge queueWaits until the lane before it finishes
activity:<owner>Every CLI commandt12-ui --drain reports busy (exit 3) while any activity lease is live
append:<stream>Event appends that lose a raceLosers append one at a time; the chain check in the INSERT still guards it

Task planning (the Tech Lead's split) 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. This split runs in both flows; in team it is the Tech Lead's first job.

MechanismHow Orchestrator handles it
Upfront queue & snapshotsQueueTasks writes EvTaskAdded upfront (Tasks replays on resume); each step snapshots Ctx.Tasks under tasksMu.
Dynamic seam splitsOversized tasks split into <parent.ID>-1..N via the Tech Lead's split plan (checkSplit) and strategist.Split; the over-size candidate is kept on the t12/<request>/<lane>--oversize branch so the parts start from its code. A split part that is still over the limit cannot split again and needs a size_waiver, which waits for a person below turbo.
Task Gate statusdesign.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.

Failure routing rules, send-back sync, and the classic Strategist

When a step fails or reports blocking findings, orchestrator.route matches the deterministic rules in rules.json (rules.Match). In the team flow that is the whole decision: a qa finding goes to the Developer as a fix attempt (tokens: 0), and an engineer failure goes to the Tech Lead's analyze on a retry token.

  • merge send-back sync (sendback.go): handleSendBack emits EvSendBack with "sync_staging": true. At Engineer start, syncWorktreeIfPending calls gitio.SyncOntoStaging, squashes onto staging, blocks on binary/UD conflicts, and leaves text conflict markers with a cleared index for the caged Engineer.
  • Classic only, Strategist fallback & rule proposals: In classic, unmatched steps (analyze) or repeat rootHash hits (state.hashes[hash] == 1) invoke strategist.Decide and feed proposal documents keyed strategist-rule-*. t12 run leaves Config.Strategist unset for team, so no Strategist session runs.

Failure routing and budgets

Flow
100%
mechdesignyescap hitnew2nd3rdyes0 leftretryStep failsany lane stepPick routerules or conflictFixes < 3?mech budgetSeen cause?root hashToken left?pool: 2/taskSend backlane retries2nd repeat freeswitches routeProblem pausepauses this lane

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 Play

Recovery ladders and autonomy levels

Before spending a retry token or parking a lane, Orchestrator climbs five recovery rungs:

  1. In-place retry (StepRetries): Retries infrastructure errors (couldNotRun) with no open questions, appending EvRetried.
  2. Auto-answer (AnswerQuestions): Calls answerForYou when questions stop a step, logs "answered-for-you" (EvAnswer), and reruns (i--).
  3. Engineer fix attempts (FixAttempts, default 3): Handles Conflict, turn-cap, and failures a rule routes to the Developer (qa, qc, merge, deploy-dry-run) at zero request tokens.
  4. Analyze retry tokens (tokenPool, default 2): Sends the lane back to analyze with the failure as its resume prompt. A diff-cap finding (counted by gitio.Tree.AddedLineCount) and second hits (state.hashes[hash] == 1) of a rootHash run with free: true.
  5. Lane pause (EvProblem): Triggers on a third identical rootHash (state.hashes[hash] >= 2) or exhausted budgets, setting errPaused and pausedDeps while other lanes continue. A person's answer after a Problem (the UI's "Try again" sends one) reopens the lane with fresh fix attempts and hashes.

autonomy.go resolves four presets via Preferences.ResolveAutonomy(os.Getenv("T12_AUTONOMY")). Selecting a mode in t12 ui writes the approval-mode document and injects T12_AUTONOMY into worker subprocesses; in review (Request Review), every shell command also waits in internal/approvals.

LevelFixAttemptsRetryTokens per taskStepRetriesAnswerQuestionsMerge-policy and review waits
reviewConfig value (default 3)Config value (default 2)00PartsWait: true (every lane waits), MatchesWait: true, diff-cap-waiver waits
defaultConfig value (default 3)Config value (default 2)00MatchesWait true unless merge_policy.mode is "auto"; diff-cap-waiver waits
autoMinimum 4Minimum 321Same match waits as default; diff-cap-waiver waits
turboMinimum 5Minimum 543MatchesWait: false; only "data-loss" waits (diff-cap-waiver waived)

Five-layer recovery ladder

Flow
100%
Escalation hierarchy · cheapest at bottomcaptuneL5 · Person or ObserverPersont12 run --answer or t12 approve --send-backL4 · Problem raisedLane stopsPaused lane isolates fault; sibling lanes keep runningL3 · Retry token1 TokenAnalyzer re-plans task · pool = tokens x top-level tasksL2 · Fix attempt1 FixEngineer repairs code or merge conflict · cap 3 (1 to 5)L1 · Transient retryFreeDeploy network and 5xx glitches retry up to 3 timesSafety boundscaps 1-5 · modeEscalationcap spent climbs +1

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 Play

Key takeaway

Orchestrator keeps model judgment out of lane progression: every split, retry, merge lock, and pause is driven by deterministic Go state over the request:<id> event stream.

Next steps

On this page