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). Orchestrator schedules lanes across slot pools while deterministic Go checks enforce every boundary.
Strategist
Split confirmed specs into parallel DAG lanes and route failed steps.
Analyzer
Investigate staging, write failing repro tests, and scope files within diff caps.
Engineer
Write tests first and implement fixes inside a persistent offline Docker cage.
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.
- Read-only boundary:
Plan(plan.go) andDecide(agent.go) runreadonlysession.Run(NoCommands: true,3m) on<home>/worktrees/<req>@strategist. - DAG planning (
Route&Tasks): WhenShouldPlansees at least2non-quality capabilities or3non-quality requirements,Planemits parallel lanes; invalid outputs fall back to deterministicstrategist.Tasks. - Static routing & proposals: Failures match rules.json plus
.t12/preferences.jsonstrategist.rulesfirst (qc/merge/deploy-dry-run→engineerat0tokens;engineer/code-review/deslop/red-team/ui-check→analyzerat1token;should-fix→chore;note→ report only). Unmatched or repeat failures callDecideand emitproposals/strategist-rule-*.json.
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.
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. It inspects staging, proves bug repros fail on base, and produces the schema-validated plan Engineer executes via analyzer_plan or escalate {question}.
Analyzer runs a 15m (DefaultSessionTimeout) caged session 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 EstimatedLines cap; oversized tasks require acyclic seam split or child size_waiver |
Engineer (internal/roles/engineer)
internal/roles/engineer is step 2 of every lane. It writes tests first and production code second inside a persistent Docker cage (sandbox.StartLane, DefaultSessionTimeout = 20m, DefaultCommandTimeout = 10m, DefaultMaxTurns = 60, DefaultFixAttempts = 3).
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.
Deterministic verification gates (verify.go)
Go enforces CheckTurnCap (turn-cap) inside loop(), then commits and runs seven gates in verify.go:
| Gate | Script check | Failure behavior |
|---|---|---|
new-test | Requires at least one newly added test file matching TestGlobs | Refuses engineer_done inside session |
fails-on-base | Runs new test files (and new .feature E2E scenarios) on Base; must exit non-zero | Refuses engineer_done (proves nothing) |
passes-on-candidate | Runs UnitFiles (ExpandFiles) on the candidate worktree | Refuses engineer_done |
no-comments | Rejects added comments in JS/TS, Go, Python (.py, .pyi), Rust (.rs), CSS, and SCSS outside allowlisted directives | Refuses engineer_done with line numbers |
diff-cap | Sums added source lines (gitio.Tree.AddedLineCount) against budgets.diff_cap_lines (800) | Sets res.DiffCap = true, resets to base, splits at Analyzer |
build | Runs commands.build inside verification cage | Refuses or consumes fix attempt |
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: Strategist partitions work, Analyzer proves failures first, and Engineer cannot commit past seven deterministic gates.
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, 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.