Record and evidence
How turbo-12f maintains tamper-evident hash-chained event logs, typed evidence reports, read-side rollups, and legacy v1 state models.
Every state transition, test verdict, decision, and token count under a request home appends to an immutable trail in requests/<id>/. Read models in internal/rollup fold that log into UI pages and CLI summaries with no separate mutable state files.
Append-only event log
Canonical JSON entries chained by SHA-256 under exclusive file locks.
Typed immutable blobs
Sequenced RoleReport, Decision, and Session records verified by digest.
Read-only rollups
Single-pass projections for lane states, flow graphs, quality, and scorecards.
Hash-chained event logs
internal/record (record.go) chains events under requests/<id>/events.jsonl using canonical JSON from internal/store:
- Genesis & chaining: Sequence
0anchors onSHA256("t12-request-genesis:" + req). Each event stripshash, encodes viastore.Canonical, writes its SHA-256 intohash, and links the prior digest inprev. - Crash-safe appending:
appendLockedholds an exclusiveflockonevents.lockand truncates any torn trailing line without a newline before writing. - Sequenced blobs & fast statting:
freshNameprefixes evidence and reports with a 4-digit sequence (0001-...);EventsStatchecks(size, modNano)for SSE ticks;StatusTrackerreads state in one pass. - Full verification (
Home.Verify): ReplaysSeq,Request,Prev, andHash, verifies every blob digest viaVerifyRef, and rejects symlinks or path traversal.
| Lock / file | Scope and ordering |
|---|---|
<home>/active.lock (Home.WithActivity) | Shared flock held by mutating CLI verbs so t12-ui --drain waits for idle |
Per-request flock files | Typed locks (LockContext, LockAsk, LockConfirm, LockRun, LockRunMerge, LockRelease), nested LockConfirm -> LockContext -> LockAsk and LockRelease -> LockRunMerge -> LockRun |
IsLocked / RequestLocked | Exposes active external CLI work to t12-ui and Observer |
<home>/projects.json (projects.lock) | Connected GitHub repository registry managed via Home.ConnectedProjects (projects.go) |
Design target vs. current writers
design.md restricts event appends to the orchestrator alone. Today, approve, bugbash, confirm, release, and internal/roles/context also call Home.Append directly.
Typed evidence records
| Record type | What it captures |
|---|---|
RoleReport | Step execution (Did, Done, NotDone, Next), Verdict, Findings, Checks (CheckCoverage: ran/skipped/noop-true), Cost, Context, Cage, Preferences, and Context7 Docs |
Decision | Strategist rules, "answered-for-you", Observer actions (observer-<kind>, By: "observer"), and rule proposals (plus observer/log.jsonl & inflight.json) |
Session (EvSession) | Harness runs, SessionTool calls, SessionUsage tokens, numbered TranscriptRef links (transcript-<id>[-N].jsonl), plus approval-asked / approval-decided outcomes from approvals.EndSession |
FactoryBench (internal/benchreport) | Maps events.jsonl to attempt.started (+autonomy:<level>), usage, activity, gate, send_back, check_coverage, noop_checks, and human.waiting/resumed |
Read-side projections in internal/rollup
internal/rollup derives all status views, flow graphs, and scorecards directly by folding events, reports, and decisions:
- Twelve lane states:
StateWaiting,StateBuilding,StateChecking,StateFixing,StateYourOK,StateOnTest,StateHeldBack,StateStuck,StateLive,StateUndone,StateLiveFixes, andStateSplitpower UI and CLI summaries via single-pass helpers (TasksFromEvents,Summarize,NowFromEvents,PlanFromEvents,QualityFromEvents). - Flow graph (
GraphOf&ApplyLiveJobin graph.go): Folds events intoFlowGraph; onlyEvStepDonewithDetail["by"] == "orchestrator"advances lane steps, andEvSendBackemitsReworkEdgeonly whenfromexists instepIndex. - Acceptance & quality:
Acceptancemaps scenarios to tests and files;QualityOfcomputes catch rate from pre-merge versus escaped bugs. - Scorecards & outcomes:
Score/OutcomesrunRecordOutcomesForont12 runandt12 release merge, aggregateCheckCoverage, and proposeguardrail-*.jsonafterEscapedGuardrailMin = 2escaped bugs.
Legacy v1 model contrast
Before internal/record introduced request-scoped streams, turbo-12f v1 stored per-task state in internal/model (Version = 8).
| Aspect | v2 (internal/record and internal/rollup) | Legacy v1 (internal/model) |
|---|---|---|
| Primary log layout | requests/<id>/events.jsonl + immutable blobs | runs/<task-id>.json + runs/<task-id>.events.jsonl |
| Integrity hash | prev and hash chain over store.Canonical JSON | state_sha chained across snapshots and event rows |
| Concurrency safety | Exclusive events.lock and request worktrees | Fixed lock order lane -> integration -> run |
| State updates | Append events and fold projections in rollup | Three-way JSON merge (ApplyChanges) with runMoved guards |
| Crash recovery | Automatic torn-tail truncation in appendLocked | Explicit t12 repair CLI pass |
One hash-chained log, every view derived from it
Every t12 command and Observer decision appends through one locked log; rollup derives snapshots for t12-ui while host control stores and secrets stay separate.
Click any node or press PlayKey takeaway
Because every view in t12 and t12 ui is folded from one hash-chained log, there is no split-brain status database to repair. If t12 conversation verify passes, the history is intact.
Next steps
Delivery, operations, and Observer
How DevOps manages bootstraps and dry-run promotions, Release gates and bisects staging, SRE watches live URLs, and Observer resolves waiting items.
Sandbox and harnesses
How Landlock, Docker cages, Request Review command approvals, read-only guards, prompt budgets, and Context7 socket forwarding isolate execution.