State home layout
What stays on disk under --home (scratch only), where durable state lives in Postgres (tables, document kinds, leases), and how t12 db import loads an older file-based home.
Neon Postgres is the only durable store (ADR 0005). Every process needs DATABASE_URL, and there is no local file mode.
--home (default $T12_HOME or ~/t12/home) is disposable scratch: git worktrees, caches, and cages that GitHub plus the database can rebuild. It must resolve outside any project repository (record.Open).
Scratch only
worktrees/, checkouts/, caches, and cages under <home> can be deleted at any time.
Durable state
Accounts, conversations, event logs, evidence, runs, and metrics live in Postgres tables.
No lock files
Locks are rows with a time to live; a holder that dies frees its lease on its own.
Old homes
t12 db import --home DIR loads a file-based home into the database once.
What stays on disk under <home>
| Path | Owner | Purpose |
|---|---|---|
worktrees/ | orchestrator, strategist, t12 preview, t12 run | Git worktrees for lanes (@<lane>), @release, @strategist, and preview-<project>-<port>. |
merge-scratch/ | internal/mergequeue | Scratch worktree (<request-id>-<lane>) for rebasing onto staging. |
checkouts/ | devops, sandbox, t12-ui | Detached checkouts (<request-id>/<step>) plus MountScratch dirs (engineer-*, ui-base-*, gitleaks-*, job-checkout-*); 24h sweep on MountScratch/t12-ui start. |
artifacts/<project>/<tree>/dist | internal/roles/devops | Rebuildable copy of a staging build. Its record is an artifact document. When dist/ is gone, t12 promote refuses with promote.no-build (a connected hosting account) or promote.no-account (none); t12 release merge rebuilds it first when a hosting account is connected. |
Where durable state lives
Each table or document kind replaces a file the factory once kept under <home>. Full inventory: ADR 0005.
| Data | Where |
|---|---|
| Request event log (hash-chained) | events, stream request:<id>; a trigger refuses updates and deletes. |
v1 run event log | events, stream run:<name>. |
| Evidence, reports, decisions, lane files | blobs + blob_chunks (1 MiB chunks) named in files (scope request:<id>, run:<id>, job:<id>, context:<id>); structured copies in role_reports and decisions. |
| Read caches (rebuildable) | documents kinds log-snapshot and log-blobs (a log's events and the blobs of one event type, so a cold process reads only what came after), rollup-derived and ui-gate-facts (values derived from a log, stamped with its position and the build). |
Conversation index (title, phase, last_seq) | conversations; the person's own title, pin, and archive flags live in its doc. |
| Role-context state | documents kind context-state, key <id>. |
Standalone Context creator (t12-cc) | documents kind context-creator; streams context:<id>:transcript and context:<id>:events in log_entries. |
v1 run records and lanes | runs and lanes; a home binding is the home-config document. |
A lease is a row in leases with a time to live. The holder renews it every third of the TTL and deletes it when done.
| Old lock file | Lease name |
|---|---|
runs/<id>.lock | run:<id> |
runs/<id>/lanes/<unit>.lock | lane:<id>:<unit> |
runs/<id>/integration.lock | integration:<id> |
requests/<id>/<kind>-<id>.lock (context, ask, confirm, run, run-merge, release) | req:<kind>:<id> |
active.lock (shared by every command) | activity:<owner>; t12 ui --drain waits for none to be live |
merge-queue.lock, deps-cache-*, ui-baseline-* | home:merge-queue, home:deps-cache-<key>, home:ui-baseline-<hash> |
queue.lock, runner.lock | queue:admission, runner:<id> |
context/<id>/lock | context:<id> |
| Import | db-import |
Event appends need no lock: AppendChained checks the sequence number and previous hash in one INSERT. projects.json, project-env, and access files are row operations or compare-and-swap on a rev column.
Two consumers run where Postgres is not reachable, and each has a host-side bridge.
- Sandboxed guard hooks. The hook writes asks to the spool under
approvals/. A per-session bridge on the host inserts them into theapprovalstable and writes decisions back. t12-container. The host runs a database broker on a unix socket and mounts it into the--network nonecontainer (T12_DB_BROKER).DATABASE_URLstays outside, but the container has the host's database access for the run.
Importing an older home
Homes written before the database kept their records as files. t12 db import --home DIR reads that layout once and writes it into Postgres; the old tree is not used afterwards.
bin/t12 db import --home ~/t12/home --dry-run # read and verify, write nothing
bin/t12 db import --home ~/t12/homeImport once, before cutover
Stop the factory first and do not import again afterwards: a second run would overwrite newer rows with the old files. Hash-chained logs are copied byte for byte after each chain is verified; a log that fails verification is reported and skipped.
The import runs steps in order. A failing step is reported and the others still run; the command exits 1 if any failed. Re-running is idempotent, and --only takes a comma-separated list of step names.
| Old path | Step | Target |
|---|---|---|
requests/<id>/events.jsonl, runs/<name>.events.jsonl | events | events (verified, verbatim lines). |
requests/<id>/**, evidence/<name>/** | files | blobs + files; hashes unchanged, so every reference still verifies. |
runs/<id>.json, runs/<id>/lanes/<unit>.json, config.json | runs, run-upgrade | runs, lanes, home-config; live version 7 runs move to version 8. |
access/access.json, access/log.jsonl, notifications, profiles | identity | Identity tables, log_entries, documents. |
projects.json (and the older products.json) | projects | projects. |
project-env/<project>.json | projectenv | project_env_vars. Set T12_PROJECT_ENV_KEY to the base64 of the old project-env/key first. |
requests/<id>/context/state.json, reports, decisions | conversations, context-state, conversation-projects | conversations, role_reports, decisions, documents. |
context/<id>/ | context-creator | documents, log_entries, files. |
access/inbox-sent.json, access/agent.json | ui | documents. |
access/observer.json, observer/, approvals/, access/mode.json | observer, approvals | documents, log_entries, approvals. |
cloud/jobs/, cloud/tasks/, projects/<project>/ | cloud | cloud_jobs, cloud_tasks, project_snapshots. |
release/, artifacts/, sre/, deslop/, proposals/, limits.json | release, artifacts, sre, deslop, limits | Ledger streams and documents. |
| Old cost and duration data in reports | metrics | Metric tables. |
Old homes named the domain product. The import reads products.json and upgrades version 7 run records to the project keys. Event logs are never rewritten, and readers still accept the legacy product-bound event type.
Readers also stay tolerant of these older names:
.t12/product.json, read when.t12/config.jsonis absent and moved to.t12/config.jsonwhen the repository is adopted- the
productskey of the profile (.t12/project.json) - the
product:<name>Asana tag prefix, next toproject:<name>
Re-copy the cloud worker workflow
The cloud worker workflow input product is now project, and the action init-product is now init-project. Copy .github/workflows/t12-worker.yml from this repository into the worker repository again, so its inputs match what the updated handler dispatches.
Legacy v1 scratch
t12 init and the legacy v1 commands keep their run records in the database (runs, lanes, events), but still use a few scratch folders under --home.
| Path | Owner | Purpose |
|---|---|---|
worktrees/ and verify/ | internal/model | Legacy run worktrees and detached verification checkouts. |
runs/runner.log | t12-runner | Runner diagnostics (the process log, not a record). |
jobs/ | t12-job, t12-adapter | Trunk analysis state (jobs/<name>/cubic-last.json). |
queue/ | t12-queue, t12-wizard | Pending intake task JSON files. |
adapters/ | t12-job | Optional per-home executable adapters (adapters/<name>). |