Architecture decisions and status
Why turbo-12f keeps host tools, replaces the v1 QC stage, gates features on stored run metrics, budgets per-test CPU, keeps all state in Neon Postgres, runs as a small team by default, and what remains open.
Architecture Decision Records under docs/adr/ capture empirical measurements and structural boundaries for turbo-12f. The 22 Nov 2026 target redesign kept three of the first four decisions, amended two of them, and superseded the v1 QC structure. ADR 0005 later moved all state into Neon Postgres, and ADR 0006 made the small-team flow the default.
Decisions at a glance
| ADR | Decision | Current status |
|---|---|---|
| ADR 0001 | Keep Go host tools instead of BAML parsing | Active |
| ADR 0002 | Order QC by trust pyramid; drop t12-tia and integration tier | Superseded by v2 11-role split (pyramid and no-integration rule kept) |
| ADR 0003 | Require factory features to beat the baseline factory | Active, amended for v2 cutover parity ($60 spend cap) and, on 2026-12-01, to compare by stored run metrics |
| ADR 0004 | Replace 10 s wall-clock tier kill with ~100 ms per-test CPU budgets + mutation | Active, amended to run baseline timing in DevOps Project Gate |
| ADR 0005 | Neon Postgres is the only source of truth; local disk is scratch | Accepted; implemented |
| ADR 0006 | A small-team flow (Tech Lead, Developer, QA, DevOps) next to the classic one, measured before it replaces it | Accepted; team is the default flow since 2026-12-01 |
Accepted and superseded decisions
ADR 0001 keeps host tools over BAML
Active decision (issue #97)
Production code stays free of baml-py; structured JSON calls run through Go internal/tools and tools.Parse.
- Context: Tested replacing host tools with BAML (
baml-py0.226.3), where the model writes the final call as text and BAML parses it. - Evidence: Across
5runs per cell onanalyzer,red(sonnet and haiku) andreviewer(opus, high thinking), host tools hit5/5accepted calls with0refusals. BAML added~45%output tokens and20%–25%cost onanalyzer. Its4reviewer refusals were mostly the test harness, not BAML. - Consequence: The experiment code is off
mainand lives on theexperiments/bamlbranch. Nothing depends onbaml-py. - Reopen rule: Reopens only if a weaker model raises the recorded refused-call count per session.
ADR 0002 replaced v1 gates before v2 superseded it
Superseded by v2 11-role redesign
Trust-pyramid ordering and dropping tests/integration carry forward; separate v1 review and verifier sessions were replaced.
- Context: ADR 0002 ordered v1 QC into
static,verification(verifyskills), and parallelreviewer-bugs/reviewer-qualityClaude Opus 5.5 reviews while deletingt12-tiaandtests/integration. - Outcome: In v2,
QCruns deterministicstatic,E2E, andui-checkscripts only, whileRed team,Deslop, andCode reviewrun as dedicated lane roles (plus optional releaseqc.explorer).
ADR 0003 requires features to beat the baseline
Active, amended for v2 cutover
Every kept or new v2 component must match or beat a single deep Claude Code + pstack baseline on stored run metrics of the same request and model (docs/evidence/; $60 cap under H8/Q10). FactoryBench, the earlier home of this comparison, was retired on 2026-12-01.
- Context: Enforced after
turbo-12freached29kGo lines across10programs without comparative benchmarks. Hash-chained logs and locked tests remain exempt as integrity invariants. - v2 amendment: Features replaced by the 11-role catalogue (TDD mode, frozen lanes, the two v1 reviewers and verifier,
prepare,touches, intake, the wizard) are cut by design without benchmark runs, in one cutover change. Until then they stay in the tree.
ADR 0004 replaces the 10 s kill with per-test CPU budgets
Active, amended for DevOps Project Gate
Local ~100 ms per-added-test CPU budgets, 3-run median checks, ~3x runaway kills, and t12-mutate replace the brittle 10 s wall-clock tier kill.
- Context: Killing an entire unit suite at
10 swall time penalized correct changes for host load and suite growth. Hardware-dependent wall limits (100 ms/10 s/60 s) report locally rather than gating CI. - v2 amendment: Baseline timing moves from
prepareto the DevOps Project Gate, and tier budgets are recorded at bootstrap; going over one is ashould-fix. - Implementation:
t12-mutate new-testsenforces the mutation-kill rule. QC's own list of work not done names per-test CPU: the whole unit tier runs every time, and the unit limit stays10 sunlessT12_UNIT_LIMIT_S(1..300) sets it.
ADR 0005 makes Neon the only source of truth
Accepted; applies to every store
A process without DATABASE_URL stops at startup with db.ErrNoDatabaseURL. There is no local file mode.
- Context: State used to live in a directory guarded by
flockfiles, mirrored to a GitHub repository in the cloud build. That tied a conversation to one machine and let the cloud worker and the Vercel function disagree about what exists. - Decision: Accounts, teams, projects, conversations, run records, hash-chained event logs, evidence blobs, approvals, observer state, project variables (still encrypted), cloud jobs, board issues and metrics live in Neon Postgres. Local disk holds worktrees, caches and cages, all rebuildable from GitHub plus the database.
- Access:
internal/dbcalls Neon's HTTPS SQL API with the standard library only (POST https://<host>/sql).DATABASE_URLis the pooled endpoint for every process. - Locks: File locks became leases (
leasestable), optimisticrevchecks and unique constraints. A lease expires by itself when its holder dies. - Schema: Numbered migrations in
internal/db/schema/migrations(currently0001to0018) are embedded and applied under an advisory lock. A merged migration is never edited. - Import:
t12 db import --home DIR [--dry-run] [--only a,b]loads an old home once. Event logs are verified and copied byte-exact, so every hash still checks. - Tests:
T12_TEST_DATABASE_URLselects the test database;scripts/test-db.shprovides a local PostgreSQL behindcmd/t12-neon-local, reached withT12_DB_ENDPOINT.
| Old state | Now |
|---|---|
requests/<id>/events.jsonl, runs/<id>.events.jsonl | events rows, streams request:<id> and run:<name>; a trigger refuses UPDATE, DELETE and TRUNCATE |
| Evidence, reports, decisions | blobs in 1 MiB chunks plus files, role_reports, decisions |
access/access.json and logs | users, sessions, team_members, workspaces and log_entries stream access |
projects.json, project-env/ | projects, and project_env_vars sealed with T12_PROJECT_ENV_KEY |
| Approvals, observer, proposals | approvals, and documents kinds such as observer-setting and proposal |
Cloud state repo (ghstate) | Deleted; the Vercel function and the worker share the database |
*.lock files | Leases named run:<id>, lane:<id>:<unit>, home:merge-queue and others |
- Client, not path: A store takes a
*db.Clientfromschema.Open(ctx); there is no global client. - Clean cutover: Delete the file store in the same change: no dual write and no
if file exists. - No locks: Use
UpdateDocor arevcompare-and-swap,AppendChained,Batch, orWithLease. - Retries: Only
Query,QueryRow,IdemandExecIdemstatements are retried;Execnever is. - Typed errors:
errors.Isagainstdb.ErrUnique,ErrNotFound,ErrChainConflict,ErrRevMismatch,ErrLeaseHeld,ErrLeaseLostand others. - Small documents:
documents.docholds records of a few KB; unbounded data is a table or log stream, hashed or binary data a blob.
The step-by-step recipe is in Extend the factory.
- Body size: Request and response bodies over Neon's HTTP API are limited to
64 MB;byteatravels as hex, so it costs twice its size. - Chunking: Evidence blobs are chunked at
1 MiB(db.BlobChunkSize), andReadEventspages500rows per request. - Timeout: One client attempt times out at
30 s(Config.Timeout), because a Vercel function has its own deadline. - Batches: A
Batchis one transaction; keep it under about8 MiBof parameters.
- Guard hooks: The hook that gates an agent's shell commands runs in the harness sandbox. It talks to a scratch spool directory, and
approvals.GuardForruns a bridge that copies asks into theapprovalstable and decisions back. t12-container: The container keeps--network none. The host runsdb.Brokeron a unix socket (T12_DB_BROKER), adds the connection string and forwards to Neon, soDATABASE_URLnever enters the cage.
ADR 0006 makes the small team the default flow
Accepted; team is the default since 2026-12-01
A project chooses its flow with the flow preference: team (the default) or classic. A conversation records its flow in a flow-chosen event before its first part starts and keeps it.
- Context: The classic flow runs eleven steps per part, each check in its own session, and asks a Strategist session where a failed check goes. Nothing showed that all of it pays for itself (ADR 0003), and the role names were hard to explain to a client or a new maintainer.
- Decision: The
teamflow keeps what a small development team does. The Product Owner (Context creator) writes the spec; the Tech Lead splits the work and plans each part (analyze); the Developer builds it (engineer); QA runs the tests, the screens, and one review (qa), stopping at the first that fails; DevOps runs the merge policy, merge, and deploy dry run. A part costs three agent sessions instead of five, and a QA finding goes straight back to the Developer as a fix attempt. - Shared: The record, the cage, the merge queue, the release checks, the release gate, and sign-off are the same in both flows. Deslop, Red team, and SRE do not run per part in
team. - Evidence: The same request, model, and answers ran once in each flow on the production cloud (
docs/evidence/flow-comparison-2026-12-01/):
| Classic | Team | |
|---|---|---|
| Parts merged, release checks | 7 of 7, pass | 6 of 6, pass |
| Model fees | $16.64 | $8.21 |
| Tokens | 31.0 M | 15.5 M |
| Session time | 2 h 57 min | 2 h 15 min |
| Extra tries | 8 | 1 |
| Agent sessions | 103 | 50 |
| Problems the checks caught | 15 | 1 |
- Reopen rule: A classic step comes back only when a stored comparison like this one, on the same request and model, shows it wins. The rule "No role can be switched off" now reads "No step of the conversation's flow can be switched off".
- Learned from the team run: 150 of its 809 tool calls failed (129 reads of files that do not exist, 19 commands the sandbox policy refused), so every session now starts with the worktree's file list, the Developer's prompt names the three mistakes half the first in-session checks failed on, and the release red team starts on a whole-app budget.
- Changing a flow: A step is a constant in
internal/orchestrator, aStepFunc, an entry in the flow'sSteps(andOwners), afound_byrule and a web label; the recipe is in Extend the factory.
Current build status and open gaps
Through late Nov 2026, walking skeleton items S1–S14, v2 core roles, factory controls, and the Neon cutover are merged:
- Core lane execution & planning:
H1,H2, spec gateD7(#227,#229), cataloguesD8, DeslopD13–D14, Red teamD15–D16, UI baselinesD17–D18, Context7 proxyD30, skill mapD29, and Strategist DAG +gitio.SyncOntoStaging(#224). - Operations & delivery:
D28config proposals, CLI reporting (D23,D24,D31), release gates (D19,D26), SRE watch/triage (D21,D22), andweb-reactstarter (A27–A29). - UI pages:
t12 ui(D33–D37,E8) adds/c/:id,/onboarding,/connections,/observer, and/settings. - UI controls: Conversation permission, command approvals, scoped Observer (
#216,#225,#451,#465), and live SSE canvas (#226,#466). - Evaluation & benchmarks: Evaluation profile
E5, andt12 eval(run/seams/capture). - Cloud and teams: Neon as the only store (ADR 0005), open sign-up, per-user connections, team roles, the project board, and metrics (see
## UnreleasedinCHANGELOG.md).
| Area | Current state | Blocked on |
|---|---|---|
Cloud deploys (H10, D42) | Production deploys to the requesting person's own Cloudflare or Vercel account when one is connected under Your connections; with none, devops.Promote falls back to DryRunOnly and refuses production | A hosting account connected by the person who releases |
Baseline parity (D38–D41, E9–E10, F1–F3) | Pending comparative runs | Stored run metrics under docs/evidence/, multi-family model keys beyond Gemini, CI runner keys, and human trials |
Legacy v1 cutover (G1) | v1 flows coexist (TestTheCoreAndTheCageProgramsLinkNoNetworkCodeButTheDatabaseClient already passes) | Baseline parity completion |
Key takeaway
Every architectural boundary in turbo-12f is empirical: host tools beat BAML on cost and reliability, mutation kills replace brittle wall timers, the small-team flow halved the cost of the same request, baseline parity on stored run metrics gates the final v1 cutover, and one database, not a folder, is the record.
Next steps
Extend the factory
Step-by-step recipes to add CLI verbs, UI actions, database stores, project settings, flow steps, prompts, role skills, review rules, catalogues, and diagrams.
Troubleshoot host and run issues
Diagnose and fix missing DATABASE_URL, a spent Neon quota, held leases, broken event chains, missing AI or GitHub connections (409), GitHub App permission errors, agy sign-in files, macOS and Colima cage problems, approvals, paused conversations, production dry runs, mail, and Operator lockout.