Skip to Content
turbo-12f
Development

Contributing and testing

Build turbo-12f binaries safely, run Go, TypeScript and database tests (scripts/test-db.sh, T12_TEST_DATABASE_URL), use t12-mutate, and follow repository and changelog rules.

How-to guide

Use these procedures to build the binaries, run the unit, database, e2e, and mutation suites, write compliant tests, and satisfy the repository rules before opening a pull request. Run every command from the repository root; the Go module lives there.

Step 1

Build safely

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

Step 2

Fast unit checks

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

Step 3

Database tests

Start a throwaway PostgreSQL with scripts/test-db.sh.

Step 4

E2E & mutation

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

Step 5

PR rules

Keep stdlib-only Go and add a short changelog entry.

Edit, build, and test loop

Build binaries safely

Build all CLI and helper binaries from the repository root:

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

The toolchain versions (go, node, bun, gh, agy, oh-my-pi) are pinned in mise.toml; mise install fetches them.

Do not overwrite binaries under a live run

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

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

Never place or run a t12 binary inside a state home: t12 refuses to start with refusing: this t12 (...) runs from inside the state home. When editing internal/ui/web/, run scripts/build-ui.sh before go build so the embedded dist/ assets update.

Run fast unit and guard checks

Run formatting, go vet, and the fast Go unit suite on every edit cycle (about 100 ms per test, under 10 s for the tier):

gofmt -l .
go vet ./...
go 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 assets/adapters
bin/t12 eval run --offline
(cd internal/ui/web && bun run test)

Run the database tests

Tests that need Postgres (dbtest.New(t), recordtest.New(t)) read T12_TEST_DATABASE_URL and skip when it is unset. Start a local PostgreSQL behind a Neon-protocol shim, with no Neon account:

scripts/test-db.sh start
eval "$(scripts/test-db.sh env)"
go test ./internal/db/... ./internal/ui/... ./tests/unit/record/...

scripts/test-db.sh needs the postgresql package (initdb, pg_ctl, psql), go and curl. The env verb exports T12_TEST_DATABASE_URL and T12_DB_ENDPOINT; status, stop and destroy manage the cluster.

Keep production credentials out of the test shell

Tests never read DATABASE_URL, and dbtest refuses a test URL that equals it. Run unset DATABASE_URL in the shell you test in. Never put T12_TEST_DATABASE_URL or T12_DB_ENDPOINT in .env.vercel, .env.staging, compose.env or ~/.config/t12/env.

PartWhat it does
cmd/t12-neon-localStandard-library shim that answers Neon's POST /sql from the local PostgreSQL via internal/db/pgwire.
T12_DB_ENDPOINTPoints internal/db at the shim. Honoured only for https://, unix:// or loopback http://; production never sets it.
T12_TEST_PG_PORT / T12_TEST_SHIM_PORTPorts for PostgreSQL (54328) and the shim (54329).
Data folder${XDG_DATA_HOME:-~/.local/share}/t12/pg, with fsync off: disposable, not durable.

The shim is a test double. It cannot reproduce Neon's autosuspend, pooler limits, retryable errors under load or its error texts, so a change to internal/db still needs one run against a real Neon test branch before release.

Run E2E and mutation checks before opening a PR

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

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

Check per-package timings across both tiers with:

go test -count=1 -p 2 ./tests/unit/... ./internal/... ./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). t12-mutate new-tests -base <REF> requires every new Test in tests/unit to kill at least one mutant:

go run ./cmd/t12-mutate -pkg ./internal/store -report mutation-report.json
go run ./cmd/t12-mutate prune -report mutation-report.json
go run ./cmd/t12-mutate new-tests -base origin/main
READY

Ready to open a PR

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

CI workflows

.github/workflows/ holds two workflows, and neither runs tests. t12-worker.yml runs the cloud worker on GitHub Actions. deploy-sites.yml deploys docs-site/ and site/ to Vercel production only when a push to main touches their files, so check docs changes yourself with bun run types:check, bun run verify:diagrams and bun run check:llms in docs-site/. CONTRIBUTING.md names new-tests-kill as the pull request check for t12-mutate new-tests, but no workflow in this tree defines that job, so run the command yourself.

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(), about 100 ms) go in tests/unit/; full-binary and omprpc tests go in tests/e2e/
Database testsCall dbtest.New(t) for a fresh migrated schema per test; never use public, neondb or DATABASE_URL. Without T12_TEST_DATABASE_URL the test skips
Cage safetyCall cagehost.SkipInside (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; it saves about 38 s per fixture
Executable fakesWrite fake docker scripts and hooks via exefile.Write (syscall.ForkLock avoids ETXTBSY)
ScopeAssert exported behavior against synthetic repos and fakes; never call the network or a model

Follow repository rules

  • Zero Go dependencies: Keep go.mod free of require, and keep go.sum and vendor/ out of the tree; ignore ./docs-site stays.
  • One network client in the core: t12, t12-cage and t12-container link no net/http except through internal/db. Direct HTTP code belongs in a cmd/t12-<name>/ binary; tests/e2e/system/naming_test.go enforces it.
  • Clean API replacements: Keep control flow in internal/model and internal/orchestrator; migrate callers and delete old internal APIs in the same PR.
  • State lives in the database: A new store takes a *db.Client and ships a numbered migration; see Extend the factory. Never add a file store under the state home.
  • Neutral wording: Keep assets/prompts/, assets/skills/ and catalogue/*.json passing tests/unit/skillmap/wording_test.go (use harmless inputs like <b>t12-check</b> and O'Brien).
  • Changelog & commits: Add one entry under ## Unreleased in CHANGELOG.md, in a ### Breaking, Added, Changed, Fixed, Removed or Security group: at most 2 lines of 120 characters, no nested bullets (tests/unit/changelog). Use Conventional Commits and merge commits.
  • Docs travel with behaviour: Update README.md, docs-site/ and llms.txt (bun run sync:llms in docs-site/) in the same PR when behaviour changes.

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 about 10 minutes on Intel Macs).

Next steps

On this page