# turbo-12f

> A software factory that turns a plain-language request into a confirmed
> spec, builds and checks it in isolated lanes, and keeps verifiable evidence
> for every step.

turbo-12f is built on [12-Factor Agents](https://github.com/humanlayer/12-factor-agents).
A person describes a project or change in `t12 ui` or with `t12 ask`. The
Context creator clarifies the request and writes a confirmed spec on `staging`.
`t12 run` then drives Strategist planning, parallel Orchestrator lanes
(Analyzer, Engineer, QC, UI check, Red team, Deslop, Code review), merges
passing work into `staging`, and prepares a release PR for human sign-off and
merge to `main`. Every pass rule is a deterministic script, and every step
writes to a hash-chained event log.

All durable state (accounts, conversations, event logs, evidence, metrics)
lives in one Neon Postgres database ([ADR 0005](docs/adr/0005-neon-source-of-truth.md)).
The state home (`~/t12/home`) is scratch: worktrees, caches and cages that can
be rebuilt from GitHub and the database.

For the full architecture, role catalogue, and CLI reference, read
[`llms.txt`](llms.txt) or the documentation site in [`docs-site/`](docs-site/).

> [!NOTE]
> The Go module has zero external dependencies (`go.mod` uses the Go standard
> library only). `cmd/t12`, `cmd/t12-cage`, and `cmd/t12-container` reach the
> network only through the database client `internal/db`
> (`TestTheCoreAndTheCageProgramsLinkNoNetworkCodeButTheDatabaseClient` in
> `tests/e2e/system`). Model harnesses (`agy`,
> `omp`) run as subprocesses, and direct HTTP servers and API clients live in
> `t12-ui`, `t12-adapter`, and the other helper binaries.

## Run the factory

From a clean Linux machine (amd64 or arm64) or Mac (macOS 26 or later) with a
Docker daemon to a running factory in five steps:

1. **Clone.** `gh repo clone cone-labs/turbo-12f`.
2. **Install.** `turbo-12f/scripts/setup.sh` installs the pinned toolchain
   (`go`, `node`, `bun`, `gh`, `agy`, `omp`) without Homebrew. It signs you in to
   GitHub and `agy`, checks the Docker cage (on a Mac it starts Colima), pulls
   the cage and scanner images, builds `bin/`, and runs the unit tests.
   It stops with instructions when a step needs you; rerun it afterwards.
3. **Database and credentials.** Keys and host settings live in
   `~/.config/t12/env` (mode 600), created by `setup.sh`. Factory programs load
   it; agent sessions never see it. Set `DATABASE_URL` (the pooled Neon
   connection string; every `t12` command stops without it) and
   `T12_PROJECT_ENV_KEY` (`openssl rand -base64 32`), then run
   `bin/t12 db migrate`. Optional: `CONTEXT7_API_KEY` for library docs,
   `T12_SMTP_*` for email sign-in links, `T12_GITHUB_CLIENT_ID` and
   `T12_GITHUB_CLIENT_SECRET` for Sign in with GitHub, and `T12_UNIT_LIMIT_S=30`
   on an Intel Mac.
4. **Open the app.** `bin/t12 ui` (scratch home `~/t12/home`; `T12_HOME` or
   `--home` overrides it). Sign-up is open: with GitHub, or with an email proved
   by a one-time link. The first account on the machine becomes the Operator.
   Each person connects their own GitHub and an AI (`agy` or `omp`) under
   **Connections**; runs use the requester's own credentials.
5. **Share it (optional).** For a team, run `t12 ui` on an always-on host behind
   a tunnel, or on Vercel with a GitHub Actions worker
   ([`docs/hosting.md`](docs/hosting.md), [`docs/cloud-hosting.md`](docs/cloud-hosting.md)),
   and configure email ([`docs/smtp.md`](docs/smtp.md)).

### CLI workflow (`t12`)

```sh
go build -o bin/ ./cmd/...
bin/t12 db migrate
bin/t12 ask --draft "I want a blog for my bakery"    # or --project-dir DIR / --repo OWNER/REPO
bin/t12 ask --conversation C --answer "..."
bin/t12 confirm --conversation C --acceptor Lan \
  --name bakery-blog --github OWNER/bakery-blog
bin/t12 run --conversation C
bin/t12 run --conversation C --answer "..."
bin/t12 conversation status|reports|decisions|report|verify --conversation C
bin/t12 preview --conversation C
bin/t12 config check|explain --repo ~/t12/bakery-blog
```

`t12 ask` prints the conversation id (`conversation: C`). `t12 run` resumes
after the last finished step. `t12 preview` serves a built project locally on
port `8800` (`t12 ui` uses `8790`). Releases deploy as dry runs without a
Cloudflare account. `scripts/demo-bakery.sh WORKDIR` runs the bakery proof end
to end from the shell.

## Binaries (`cmd/*`)

Build all 13 binaries into `bin/` (not committed):

```sh
go build -o bin/ ./cmd/...
```

| Binary | Role | Network |
|---|---|---|
| `t12` | Main CLI for v2 conversations (`ask`, `confirm`, `run`, `ui`, `preview`, `release`, `config`, `access`, `db`, `sre`) and v1 state verbs (`prepare`, `act`, `tdd-step`, `qc`, `review`, `check`, `verify`, `deliver`) | Database client; spawns harnesses and subprocess adapters |
| `t12-ui` | Web UI server (`internal/ui`, embedded React SPA in `internal/ui/web/`) | Yes |
| `t12-cloud-worker` | Cloud worker run by the GitHub Actions workflow `.github/workflows/t12-worker.yml` | Yes |
| `t12-adapter` | Direct HTTP adapters for GitHub, GitLab, Bitbucket, Asana, Context7, SRE probes, and skill sync | Yes |
| `t12-neon-local` | Test shim answering Neon's `POST /sql` from a local PostgreSQL (`scripts/test-db.sh`) | Yes |
| `t12-runner` | v1 autonomous loop driving `omp` workers across queued runs and parallel lanes | Yes |
| `t12-queue` | v1 queue admission controller (`t12 prepare` over a task directory) | Yes |
| `t12-job` | Standalone job runner helper | Yes |
| `t12-cc` | Standalone Context creator CLI (`start`, `reply`, `chat`, `confirm`, `archive`) | Yes |
| `t12-cage` | Linux Landlock plus PID and user namespace sandbox helper | Database client only |
| `t12-container` | Docker container sandbox helper; reaches the database through a host unix-socket broker | Database client only |
| `t12-mutate` | Local and CI Go mutation testing and test-pruning tool | No |
| `t12-wizard` | Interactive workspace setup helper | Database client only |

## Prerequisites and supported platforms

- Go (the version in [`go.mod`](go.mod)) and `git`
- A Neon Postgres database (`DATABASE_URL`)
- One signed-in model harness: `agy` (default) or `omp`
- `node`, `npm`, and `bun` (for web projects, the guard tests, and `docs-site/`)
- A verification sandbox (see table below)

### Supported platforms

| Platform | Sandbox | Requirements |
|---|---|---|
| Linux (`amd64`, `arm64`) | Landlock (kernel ABI 5+; ABI 9 confines unix sockets) and Docker (required for v2 lane cages) | A kernel with Landlock and a running Docker daemon |
| macOS 26 or later (Apple Silicon and Intel) | Docker only (macOS has no Landlock) | Docker Desktop, Colima, or OrbStack with the daemon running (`docker info` answers) and the local cage image |

On macOS, `prepare` refuses a task when the macOS version is older than 26,
when the Docker daemon does not answer, or when the image is missing.

## v1 TDD lane and standalone helpers

The v1 task-file flow (`t12 prepare`, `t12 act`, `t12 tdd-step`, `t12 qc`,
`t12 review`, `t12 check`, `t12 deliver`), `t12-runner`, `t12-queue`, and
`t12-cc` still live alongside v2 until cutover:

- **TDD lane:** Analyzer produces a test list; Red writes one failing test at a
  time; Green and Refactor work in a blind worktree with test files removed;
  Final runs the unit tier, lint, and a mutation check.
- **QC:** `t12 qc` runs static checks and the e2e tier in a fresh checkout; the
  verifier runs the project's verify skill; `reviewer-bugs` and
  `reviewer-quality` must both approve before `t12 check` marks the run
  `local-verified`.
- **Standalone Context creator (`t12-cc`):** Runs a multi-turn spec conversation
  in the terminal or on a GitHub issue, checks the change folder across four
  gates, and writes task files for `t12-queue`.

> [!IMPORTANT]
> `local-verified` means the configured evidence chain was observed and is
> internally consistent. It is not acceptance and not permission to merge. A
> human merges.

<details>
<summary>v1 quick start commands</summary>

```sh
bin/t12 init --repo /path/to/project --home /path/to/state-home
bin/t12 prepare --home /path/to/state-home --task examples/task.json
bin/t12-runner --home /path/to/state-home --queue /path/to/queue
bin/t12 board --home /path/to/state-home
bin/t12-adapter github create-pr --home /path/to/state-home \
  --task-id demo-1 --out delivery.json
bin/t12 deliver --home /path/to/state-home --task-id demo-1 \
  --adapter github --report delivery.json
```

</details>

## Documentation

| Document | What it covers |
|---|---|
| [`llms.txt`](llms.txt) | Generated concise architecture and CLI guide for agents and contributors |
| [`docs-site/`](docs-site/) | Full v2 documentation site with interactive architecture diagrams and reference pages |
| [`docs/handover.md`](docs/handover.md) | Operating and maintaining the v2 factory: commands, packages, troubleshooting |
| [`docs/hosting.md`](docs/hosting.md) | Solo and team hosting, sign-up, connections, tunnels, idle-safe updates, Docker Compose stack |
| [`docs/cloud-hosting.md`](docs/cloud-hosting.md) | Vercel function, GitHub Actions worker, and Neon; staging and production databases |
| [`docs/connections-security.md`](docs/connections-security.md) | How each person's GitHub, agy and omp connections are stored and used |
| [`docs/metrics.md`](docs/metrics.md) | Agent spans, human waits, and sloppiness metrics |
| [`docs/smtp.md`](docs/smtp.md) | SMTP setup for email sign-in links |
| [`docs/spec-standard.md`](docs/spec-standard.md) | Issue and task specification contract enforced by `t12-adapter spec-check` |
| [`docs/adr/`](docs/adr/) | Architecture Decision Records (0001 through 0005) |
| [`assets/adapters/README.md`](assets/adapters/README.md) | HTTP adapters, intake, delivery report schema, `t12-runner`, and pinned skills |
| [`GLOSSARY.md`](GLOSSARY.md) | Canonical vocabulary for factory concepts |
| [`CONTEXT.md`](CONTEXT.md) | Truth boundaries: what each guarantee covers and what the factory does not claim |
| [`CONTRIBUTING.md`](CONTRIBUTING.md) | Coding rules, test tiers, mutation testing, and PR workflow |
| [`SECURITY.md`](SECURITY.md) | Security policy and scope of claims |

## Tests

From the repository root:

```sh
go vet ./...
go test ./tests/unit/... ./internal/... ./cmd/...   # under 10 s
go test -p 2 ./tests/e2e/...                        # no limit; run on a quiet machine
bun test assets/adapters
```

Tests run offline against synthetic repos, fake HTTP servers, a fake `docker`,
and fake harnesses. Tests that need the database skip unless
`T12_TEST_DATABASE_URL` is set; `scripts/test-db.sh start` runs a local
PostgreSQL behind `t12-neon-local` and prints the variables to export. Docker
adapter tests also run against a real daemon when Docker answers and
`debian:stable-slim` (or `T12_REAL_DOCKER_IMAGE`) is present locally. See
[`CONTRIBUTING.md`](CONTRIBUTING.md) for tier rules.
