Planning and build roles
Deep dive into Strategist DAG lane planning and routing, Analyzer repro creation and split plans, and Engineer caged edits, turn limits, and verify gates.
After Context creator confirms an OpenSpec change on staging, three roles turn requirements into verified lane commits (strategist, analyzer, and engineer). In the default team flow they are the Tech Lead's split, the Tech Lead's plan step and the Developer's build; the classic flow names them Strategist, Analyzer and Engineer. Orchestrator schedules lanes across slot pools while deterministic Go checks enforce every boundary.
Strategist
Split confirmed specs into parallel DAG lanes (the Tech Lead's split in the team flow) and, in classic only, route failed steps.
Analyzer
Investigate staging, write failing repro tests, and scope files within diff caps. The Tech Lead's plan step in the team flow.
Engineer
Write tests first and implement fixes inside a persistent offline Docker cage. The Developer in the team flow.
Strategist (internal/roles/strategist)
internal/roles/strategist handles pre-lane DAG planning and post-failure routing, pairing deterministic rule tables with 3m read-only sessions. Planning (Route) runs in both flows, as the Tech Lead's split of the conversation into parts. The routing agent (Decide) runs only in the classic flow: the team flow routes every failure by rules.json alone.
- Read-only boundary:
Plan(plan.go) runsreadonlysession.Run(NoCommands: true,3m) on a detachedstagingcheckout at<home>/worktrees/<req>@strategist.Decide(agent.go) runs a3mread-only session in the lane's own cage, in theclassicflow only. - DAG planning (
Route&Tasks): WhenShouldPlansees at least2non-quality capabilities or3non-quality requirements,Planemits parallel lanes; invalid outputs fall back to deterministicstrategist.Tasks. The planner is told to size each lane at about half ofbudgets.diff_cap_lines, because estimates run low and a lane that lands over the cap is thrown away after an expensive build. Both assign dependency-orderedSprintwaves, andt12 run --sprint Nruns only tasks up to waveN. - Static routing & proposals: Failures match rules.json plus
.t12/preferences.jsonstrategist.rulesfirst (qc/qa/merge/deploy-dry-run→engineerat0tokens;engineer/code-review/deslop/red-team/ui-check→analyzerat1token;should-fix→chore;note→ report only). In theclassicflow, unmatched or repeat failures callDecide, which can write aproposaldocument namedstrategist-rule-*.json; theteamflow never calls it.
validatePlannedTasks: Verifies non-emptyreason, validTaskTypes,dag.Orderacyclicity, zero dependencies onquality,1capability perbuglane, an isolatedqualityleaf lane, and an exact 1:1 requirement/scenario partition.- Parallel context & splits:
ParallelContext(all, current)injects## Parallel lanes(Strategist notes,Running in parallel with,Waiting on this lane) into Analyzer and Engineer prompts;strategist.Splitspawns<parent.ID>-1..N. - Rule proposals: After
ProposalRepeats(2) fallback decisions withinProposalWindow(30days) share(step, route),proposewrites a rule proposal for Operator approval witht12 rules approveorreject. Proposals are rows in thedocumentstable (kindproposal), not files under<home>.
Open gap in Strategist
Both Tasks and Plan currently log NotDone: "Entry steps for security, devops and incident tasks (D15)".
Analyzer (internal/roles/analyzer)
internal/roles/analyzer is step 1 of every lane in both flows (the Tech Lead's plan step in the team flow). It inspects staging, proves bug repros fail on base, and produces the schema-validated plan Engineer executes via analyzer_plan or escalate {question}. An escalated question goes to a person, or the orchestrator answers it itself when the project's autonomy level says so.
Analyzer runs a 15m (DefaultSessionTimeout) caged session of at most 40 turns inside in.Cage with approvals.GuardFor (DefaultCommandTimeout = 5m) using analyzer-v2.md. Its policy confines writes strictly to in.TestGlobs (confine: true, read_only: in.ProtectedPaths).
| Plan field / check | Go validation in plan.go |
|---|---|
| Root cause & repro | evidence, root_cause (required on bugs/send-backs), repro {test, name} (reproFailsOnBase), cause_class |
| Files & criteria | approach, files (add/edit/delete), criteria mapping IDs to unit or e2e .feature files, screens for "ui" tags |
| Source line estimate | estimated_lines counts added production source lines only (excludes tests, E2E, lockfiles, deletions, binaries) |
| Diff cap & splits | Enforces FinalSchema(), protected paths, and the EstimatedLines limit: an estimate above two thirds of budgets.diff_cap_lines (SplitAbove) requires an acyclic seam split, or a size_waiver for a single-requirement task that cannot split by criteria. A split part with one requirement may use the whole cap, and cannot split again |
Engineer (internal/roles/engineer)
internal/roles/engineer is step 2 of every lane in both flows (the Developer in the team flow). It writes tests first and production code second inside a persistent Docker cage (sandbox.StartLane, DefaultSessionTimeout = 20m, DefaultCommandTimeout = 10m, DefaultMaxTurns = 60, DefaultFixAttempts = 3). The session's real time limit adds 15m (CheckAllowance) for each of the FixAttempts + 1 candidates it may hand over, because the session waits while the factory builds and tests what it handed over.
On merge send-backs, orchestrator/sendback.go runs gitio.SyncOntoStaging on the host and internal/cli/factory.go refreshes .feature files and e2e/t12/capture.ts. Engineer never runs git add or git commit, never edits e2e/features/*.feature, and exits via engineer_done or escalate. Its prompt ends with the worktree's file list (up to 400 paths, then a count per folder), so it opens files by path instead of listing folders.
Escalated questions and need-decision issues
Both Analyzer and Engineer may escalate a question, and the orchestrator records it as a question event. At autonomy.level auto the factory answers a lane's question itself once (turbo: up to 3 times) with the smallest change that satisfies the spec, and records an answered-for-you decision. Otherwise the lane waits for a person; in the cloud build the worker opens a GitHub issue labelled need-decision with the options and resumes the lane when someone replies. See Cloud hosting.
Checks inside the session (verify.go)
engineer_done does not end the session. The factory commits what the session handed over, runs the seven gates in verify.go, and, when they pass, runs QC, the screen check and Red team's origin check on that candidate. A refusal comes back as the answer to engineer_done, so the same warm session fixes it with everything it has read still in context; a new session starts only when one ends with its candidate still refused, for example out of turns. A check that could not run at all (Blocked) is not the Developer's to fix: the candidate goes through and the lane's own step reports it. When every check passes, the lane's qc and ui-check steps (or the first two parts of qa) reuse those results while the worktree still holds that candidate. Checks running at once across lanes are bounded by the run's check slots. Go enforces CheckTurnCap (turn-cap) when a session ends without finishing.
| Gate | Script check | Failure behavior |
|---|---|---|
new-test | Requires at least one added or updated test file matching TestGlobs | Refuses engineer_done inside session |
fails-on-base | Runs each added or updated test file (and new .feature E2E scenarios) on Base; must exit non-zero (skipped for guard-only lanes) | Refuses engineer_done (proves nothing) |
passes-on-candidate | Runs UnitFiles (ExpandFiles) on the added or updated test files in a checkout of the candidate | Refuses engineer_done |
no-comments | Rejects added comments in JS/TS, Go, Python (.py, .pyi), Rust (.rs), CSS, and SCSS or Less outside allowlisted directives | Refuses engineer_done with line numbers |
diff-cap | Sums added source lines (gitio.Tree.AddedLineCount) against budgets.diff_cap_lines (800); every refusal states the lines used and warns at 80% | Refused once so the session can trim; finishing again unchanged sets res.DiffCap = true and hands the task to the Analyzer's split. The candidate is kept on t12/<req>/<lane>--oversize first, and each part's Engineer starts from that attempt's version of the files its plan lists |
build | Runs commands.build in a checkout of the candidate | Refuses engineer_done |
protected-path | Blocks edits to .github/workflows/**, .t12/**, .agents/**, and unsafe symlinks | Refuses engineer_done |
Key takeaway
Planning and build roles keep every change small and testable: the split partitions work, Analyzer proves failures first, and Engineer cannot commit past seven deterministic gates. Both flows run all three; only classic adds the Strategist's failure routing.
Next steps
Context and specs
How Context creator decides readiness via a 3-part Go gate, ingests existing GitHub repositories, multi-issue tickets, and image attachments, draws the mock UI, enforces 25 lint rules, and exports OpenSpec files plus SRS, Plain, and UAT views.
Quality, hygiene, and review roles
Deterministic checks and read-only audits across QC, UI check, Explorer, Deslop, Red team, and Code review before merge policy evaluates a lane.