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.
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.
Ask & confirm
Lock an OpenSpec change with verbatim quotes, then pass the Project Gate.
Tech Lead & lanes
Split the spec into dependency-ordered worktrees and run each lane through the flow's steps (six in team).
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.ProjectGateto verify clean branches, pinned skills, dependencies, and base checks onbranches.staging.--acceptornames the person who accepts the conversation. - Lane execution (
t12 run): Callsorchestrator.Run(orchestrator.go).orchestrator.ChooseFlowrecords 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. - Release lane: Once non-parked lanes merge into
staging,orchestrator.Runlaunches the request-levelreleaselane (ReleaseLane = "release"). - Release checks & bisection:
stepRelease(run_release.go) installs dependencies onstaging, then runsqc,uicheck,redteam, anddeploy-dry-run(plus optionalqc.explorer), the same in both flows. The result is stored perstagingtree: 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,fixReleasebisects the merges sincemainand opens<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(defaultmain) 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.Promotethen 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
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 PlayFlows: 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).
| Step | Team member | Responsibility |
|---|---|---|
| 1 | analyze (Tech Lead, internal/roles/analyzer) | Plans changed files, test specs, and predicted screens on staging |
| 2 | engineer (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) |
| 3 | qa (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 |
| 4 | merge-policy (DevOps, internal/mergepolicy) | Evaluates data-loss, auth, licence, delivery, and review bound to git patch-id --stable |
| 5 | merge (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 |
| 6 | deploy-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
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 PlayConcurrency, priority, and 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, qa, code-review | 4 (project.DefaultAgentSlots) | Resumed fixes first, longest chain, then FIFO |
checkSlot | merge, deploy-dry-run, and in classic qc, ui-check, deslop, red-team, sre; the checks an Engineer session runs on its candidates take one too | max(1, NumCPU / 2) (DockerCPUs / 2 in Docker) | Same priority{fix, chain} comparator, then arrival order |
| Unslotted | merge-policy | Unbounded | Runs immediately inside runLane |
Three coordination rules in queue.go and slots.go prevent lane collisions inside one run:
- File locks (
fileLocks): In-process, 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 between the flow's last check andmerge) and120s(DefaultQuietWindowS) pass without queue changes. - Live capacity resizing: Every
15s(LiveCapacityEvery), readscapacity.agent_slotsandcapacity.check_slotsfrom.t12/preferences.jsononrefs/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.
| Lease | Held by | Behavior |
|---|---|---|
req:<kind>:<id> | ask, confirm, context, run, run-merge, release | Waits 10 s, then reports another command holds it; confirm then context then ask order kept |
home:merge-queue | Merge queue | Waits until the lane before it finishes |
activity:<owner> | Every CLI command | t12-ui --drain reports busy (exit 3) while any activity lease is live |
append:<stream> | Event appends that lose a race | Losers 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.
| 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 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 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.
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.
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.- Classic only, Strategist fallback & rule proposals: In
classic, unmatched steps (analyze) or repeatrootHashhits (state.hashes[hash] == 1) invokestrategist.Decideand feedproposaldocuments keyedstrategist-rule-*.t12 runleavesConfig.Strategistunset forteam, so no Strategist session runs.
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, and failures a rule routes to the Developer (qa,qc,merge,deploy-dry-run) at zero request tokens. - Analyze retry tokens (
tokenPool, default2): Sends the lane back toanalyzewith the failure as its resume prompt. Adiff-capfinding (counted bygitio.Tree.AddedLineCount) 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. 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.
| 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 the request:<id> event stream.
Next steps
System overview
How turbo-12f stacks its Go packages on Postgres (the only store), enforces zero external Go dependencies, and separates cage binaries that reach the network only through the database client from HTTP companion and cloud processes.
Agent roles
How the team flow's five members map onto the thirteen role packages under internal/roles and the internal/observer loop, each combining deterministic scripts with bounded LLM sessions.