Skip to Content
turbo-12f
Development

Contributing and testing

Build turbo-12f binaries safely, run and author Go and TypeScript tests, and follow repository rules.

How-to guide

Use these procedures to build factory/ binaries, run the unit, e2e, and mutation suites, write compliant tests, and satisfy repository checks before opening a pull request.

Step 1

Build safely

Compile cmd/... without overwriting a running factory/bin/t12.

Step 2

Fast unit checks

Run gofmt, go vet, and -short unit tests on every edit.

Step 3

E2E & mutation

Run -p 2 e2e packages, guard tests, and t12-mutate on a quiet host.

Step 4

PR rules

Keep stdlib-only Go, zero code comments, and a 2-line changelog entry.

Edit, build, and test loop

Build binaries safely

Build all CLI and helper binaries from the repository root:

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

Do not overwrite binaries under a live run

Check pgrep -fl factory/bin/t12 before rebuilding factory/bin/. If a request is active, build into /tmp/t12d/ and point scripts at it via T12_BIN:

go -C factory build -o /tmp/t12d/ ./cmd/...
T12_BIN=/tmp/t12d factory/scripts/demo-bakery.sh ~/t12-demo/run-test

Never place or run a t12 binary inside a state home (absHome in cli.go refuses it). When editing factory/internal/ui/web/, run factory/scripts/build-ui.sh before go build so embedded dist/ assets update.

Run fast unit and guard checks

Run formatting, go vet, and the fast Go unit suite on every edit cycle (< 10 s total; ~100 ms per test):

gofmt -l factory/
go -C factory vet ./...
go -C factory test -short ./tests/unit/... ./internal/... ./cmd/...

Run the Bun guard tests, offline role/seam evals, and the t12 ui Vitest suite when touching harnesses, prompts, or UI code:

bun test factory/adapters
factory/bin/t12 eval run --offline
bun --cwd factory/internal/ui/web run test

Run E2E and mutation checks before opening a PR

Run the e2e suite on a quiet machine (-p 2 avoids CPU contention; aim for < 60 s per package):

go -C factory test -p 2 ./tests/e2e/...

Check per-package timings across both tiers with:

go -C factory test -count=1 -p 2 ./tests/unit/... ./tests/e2e/... 2>&1 | grep -E '^(ok|FAIL|---)'

Use t12-mutate on a quiet tree to find unit coverage gaps (keep mutation-report.json local, never committed). CI runs t12-mutate new-tests -base <REF> (new-tests-kill), requiring every new Test in tests/unit to kill at least one mutant:

go -C factory run ./cmd/t12-mutate -pkg ./internal/store -report mutation-report.json
go -C factory run ./cmd/t12-mutate prune -report mutation-report.json
READY

Ready to open a PR

gofmt -l factory/ prints nothing, go vet and -short unit tests pass, -p 2 e2e passes on a quiet host, and factory/CHANGELOG.md has your entry.

Author Go tests

RuleRequirement
Red-firstBreak production code to observe the test fail before restoring it; write a unit test first for every e2e bug
Tier placementFast mocked tests (t.Parallel(), < 100 ms) go in tests/unit/; full-binary and omprpc tests go in tests/e2e/
Cage safetyCall cagehost.SkipInside (factory/tests/support/cagehost) in tests binding loopback sockets or expecting uncaged runs
Build & git flagsPass -buildvcs=false when building binaries or running go list on main packages; set local user.name/user.email for commits
Temp homes (TestMain)End TestMain with os.Exit(privatetmp.Run(m)) (privatetmp.Setup before hard-linked fixtures); keep out of /dev/shm
Go cache seedAfter t12 init creates a compile-capable verify-home, call gocacheseed.Seed (~38 s saved per run)
Executable fakesWrite fake docker scripts and hooks via exefile.Write (syscall.ForkLock avoids ETXTBSY)
ScopeAssert exported behavior against synthetic repos and fakes; leave factory/PARITY.tsv and factory/REWRITE-LOG.md untouched

Follow repository rules

  • Zero Go dependencies: Keep factory/go.mod free of require, go.sum, and vendor/, and preserve ignore ./docs-site.
  • Offline CLI boundary: Keep internal/cli/ free of net/http, credentials, and model calls; place network/model binaries under factory/cmd/t12-<name>/.
  • Clean API replacements: Keep control flow in internal/model and internal/orchestrator; migrate callers and delete old internal APIs in the same PR.
  • Neutral wording: Keep prompts/, skills/, and catalogue/*.json passing wording_test.go (use harmless inputs like <b>t12-check</b> and O'Brien).
  • No source comments: Keep code comments out of source files (AGENTS.md: "Comments are liability"), leaving only machine directives.
  • Changelog & commits: Add one entry in factory/CHANGELOG.md under ## Unreleased (at most 2 lines of 120 chars, no nested bullets, ending in (#PR)). Use Conventional Commits and merge commits.

Known test quirks (not regressions)

  • macOS jobrun skips: TestACommandJobKeepsPathAndLang and TestACommandThatCannotBeStartedExits1WithOneCheckCommandFinding skip on macOS Docker runs because LANG does not enter containers and missing binaries exit 127.
  • Busy-host flakes: TestTheDeployWaitsForAQuietMergeQueue, TestBootstrapMakesTheRepoAndIsIdempotent, and TestProjectGateBlocksOnAMissingBase can flake under heavy load (green when run alone; devops takes ~10 minutes on Intel Macs).

Next steps

On this page