# turbo-12f

> A local 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 in the state home.

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` link no
> `net/http` (checked by `TestTheCoreAndTheCageProgramsLinkNoNetworkCode`).
> v2 `t12` commands invoke local model harnesses (`agy`, `omp`, `claude`) and
> local subprocess adapters (`ghcli`, `ghissue`, `ghrepo`, `fbreport`), while
> direct HTTP servers and API clients live in `t12-adapter`, `t12-ui`, and the
> standalone 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.** The repository is private: `gh repo clone All-Chat-Bridge-for-CRM/ConvoRelay`.
2. **Install.** `ConvoRelay/factory/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 `factory/bin`, and runs the unit tests.
   It stops with instructions when a step needs you; rerun it afterwards.
3. **Credentials.** Keys and host settings live in `~/.config/t12/env` (mode 600),
   created by `setup.sh` with optional keys commented. Factory programs load it;
   agent sessions never see it. Uncomment what you use: `CONTEXT7_API_KEY` for
   library docs, `T12_SMTP_*` for email sign-in links, and `T12_UNIT_LIMIT_S=30`
   on an Intel Mac.
4. **Open the app.** `factory/bin/t12 ui` uses `~/t12/home` by default
   (`T12_HOME` or `--home` overrides it, and project repos and caches live under
   `~/t12/`). Sign in with email and password (`t12 access set-password`),
   Tailscale auto-login (`--url https://*.ts.net` or `--trust-tailscale`), or
   the printed one-time link. Start a request from the home page or from the
   shell.
5. **Share it (optional).** For a team, run `t12 ui` on an always-on Linux host
   behind a tunnel ([`docs/hosting.md`](docs/hosting.md)) and configure email
   ([`docs/smtp.md`](docs/smtp.md)).

### CLI workflow (`t12`)

```sh
go -C factory build -o bin/ ./cmd/...
factory/bin/t12 ask "I want a blog for my bakery"
factory/bin/t12 ask --request R --answer "..."
factory/bin/t12 confirm --request R --acceptor Lan \
  --name bakery-blog --github OWNER/bakery-blog
factory/bin/t12 run --request R
factory/bin/t12 run --request R --answer "..."
factory/bin/t12 request status|reports|decisions|report|verify --request R
factory/bin/t12 preview --request R
factory/bin/t12 config check|explain --repo ~/t12/bakery-blog
```

`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. `factory/scripts/demo-bakery.sh WORKDIR`
runs the bakery proof end to end from the shell.

## Binaries (`cmd/*`)

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

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

| Binary | Role | Links `net/http` |
|---|---|---|
| `t12` | Main CLI for v2 requests (`ask`, `confirm`, `run`, `ui`, `preview`, `release`, `config`, `access`, `sre`) and v1 state verbs (`prepare`, `act`, `tdd-step`, `qc`, `review`, `check`, `verify`, `deliver`) | No (invokes local harnesses and subprocess adapters `ghcli`, `ghissue`, `ghrepo`, `fbreport`) |
| `t12-ui` | Web UI server (`internal/ui`, embedded React SPA in `internal/ui/web/`) | Yes |
| `t12-adapter` | Direct HTTP adapters for GitHub, GitLab, Bitbucket, Asana, Context7, SRE probes, and skill sync | Yes |
| `t12-runner` | v1 autonomous loop driving `omp` workers across queued runs and parallel lanes | Yes (transitively via `internal/adapters/common` and `internal/skills`) |
| `t12-queue` | v1 queue admission controller (`t12 prepare` over a task directory) | Yes (transitively via `internal/adapters/common`) |
| `t12-job` | Standalone job runner helper | Yes (transitively via `internal/adapters/common`) |
| `t12-cc` | Standalone Context creator CLI (`start`, `reply`, `chat`, `confirm`, `archive`, `bench-turn`) | Yes (transitively via `internal/adapters/common`, `internal/adapters/intake`, and `internal/skills`) |
| `t12-cage` | Linux Landlock plus PID and user namespace sandbox helper | No |
| `t12-container` | Docker container sandbox helper | No |
| `t12-mutate` | Local and CI Go mutation testing and test-pruning tool | No |
| `t12-wizard` | Interactive workspace setup helper | No |

## Prerequisites and supported platforms

- Go (the version in [`go.mod`](go.mod)) and `git`
- One signed-in model harness: `agy` (default), `omp`, or `claude`
- `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. CI
cross-compiles both Mac targets on every push and runs unit tests on macOS 26
weekly (`.github/workflows/macos.yml`); end-to-end tests run on Linux.

## 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
factory/bin/t12 init --repo /path/to/project --home /path/to/state-home
factory/bin/t12 prepare --home /path/to/state-home --task factory/examples/task.json
factory/bin/t12-runner --home /path/to/state-home --queue /path/to/queue
factory/bin/t12 board --home /path/to/state-home
factory/bin/t12-adapter github create-pr --home /path/to/state-home \
  --task-id demo-1 --out delivery.json
factory/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, on-disk layout, packages, troubleshooting |
| [`docs/hosting.md`](docs/hosting.md) | Solo and team hosting, tunnels, Tailscale auto-login, idle-safe updates, Docker Compose stack |
| [`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 0004) |
| [`adapters/README.md`](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 |
| [`../docs/factory/design.md`](../docs/factory/design.md) | Original v2 target design and linked design tickets |
| [`../docs/factory/handoff.md`](../docs/factory/handoff.md) | Operational handoff notes and build-plan status |

## Tests

From the repository root:

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

All tests run offline against synthetic repos, fake HTTP servers, a fake
`docker`, and fake harnesses. 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.
