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.
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.
Build safely
Compile cmd/... without overwriting a running bin/t12.
Fast unit checks
Run gofmt, go vet, and -short unit tests on every edit.
Database tests
Start a throwaway PostgreSQL with scripts/test-db.sh.
E2E & mutation
Run -p 2 e2e packages and t12-mutate on a quiet host.
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-testNever 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.
| Part | What it does |
|---|---|
cmd/t12-neon-local | Standard-library shim that answers Neon's POST /sql from the local PostgreSQL via internal/db/pgwire. |
T12_DB_ENDPOINT | Points internal/db at the shim. Honoured only for https://, unix:// or loopback http://; production never sets it. |
T12_TEST_PG_PORT / T12_TEST_SHIM_PORT | Ports 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/mainReady 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
| Rule | Requirement |
|---|---|
| Red-first | Break production code to observe the test fail before restoring it; write a unit test first for every e2e bug |
| Tier placement | Fast mocked tests (t.Parallel(), about 100 ms) go in tests/unit/; full-binary and omprpc tests go in tests/e2e/ |
| Database tests | Call 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 safety | Call cagehost.SkipInside (tests/support/cagehost) in tests binding loopback sockets or expecting uncaged runs |
| Build & git flags | Pass -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 seed | After t12 init creates a compile-capable verify-home, call gocacheseed.Seed; it saves about 38 s per fixture |
| Executable fakes | Write fake docker scripts and hooks via exefile.Write (syscall.ForkLock avoids ETXTBSY) |
| Scope | Assert exported behavior against synthetic repos and fakes; never call the network or a model |
Follow repository rules
- Zero Go dependencies: Keep
go.modfree ofrequire, and keepgo.sumandvendor/out of the tree;ignore ./docs-sitestays. - One network client in the core:
t12,t12-cageandt12-containerlink nonet/httpexcept throughinternal/db. Direct HTTP code belongs in acmd/t12-<name>/binary;tests/e2e/system/naming_test.goenforces it. - Clean API replacements: Keep control flow in
internal/modelandinternal/orchestrator; migrate callers and delete old internal APIs in the same PR. - State lives in the database: A new store takes a
*db.Clientand ships a numbered migration; see Extend the factory. Never add a file store under the state home. - Neutral wording: Keep
assets/prompts/,assets/skills/andcatalogue/*.jsonpassingtests/unit/skillmap/wording_test.go(use harmless inputs like<b>t12-check</b>andO'Brien). - Changelog & commits: Add one entry under
## UnreleasedinCHANGELOG.md, in a### Breaking,Added,Changed,Fixed,RemovedorSecuritygroup: 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/andllms.txt(bun run sync:llmsindocs-site/) in the same PR when behaviour changes.
Known test quirks (not regressions)
- macOS
jobrunskips:TestACommandJobKeepsPathAndLangandTestACommandThatCannotBeStartedExits1WithOneCheckCommandFindingskip on macOS Docker runs becauseLANGdoes not enter containers and missing binaries exit127. - Busy-host flakes:
TestTheDeployWaitsForAQuietMergeQueue,TestBootstrapMakesTheRepoAndIsIdempotent, andTestProjectGateBlocksOnAMissingBasecan flake under heavy load (green when run alone;devopstakes about10minutes on Intel Macs).
Next steps
LLMs and agents (llms.txt & AGENTS.md)
Machine-readable docs endpoints (/llms.txt, /llms-full.txt, /llms.mdx/*, /agents.md) and coding-agent setup for turbo-12f.
Extend the factory
Step-by-step recipes to add CLI verbs, UI actions, database stores, project settings, flow steps, prompts, role skills, review rules, catalogues, and diagrams.