Rules for agents that edit harness. Also read the AGENTS.md in each directory you change.
- The architecture is docs/architecture.md. New code follows it.
- Design each interface from its consumer's need. Nothing is kept because it exists. There is no backward compatibility.
- One owner and one source of truth for each piece of state.
- Build session state from the event log with one
Applyfunction, live and on replay. - Give one goroutine each session's state. Other code sends it commands and reads immutable views.
- An interface lives in the package that consumes it. Never branch on a provider or backend name.
- Imports are one-way. Internal packages never import
cmd.
- A session is an append-only log of canonical messages, never provider wire objects.
- A repair of live or persisted history is additive-only. Never delete a real tool result.
- An empty tool result never serializes as
null. ReadToolResult.SafeContent. - Model references use
provider/model. Aliases resolve before a request reaches a provider. - Only the runtime creates
message.EngineContext. User text never gains that trust.
docs/architecture.mdis the binding spec. Cite the sections a change implements in the PR body. When the spec is silent or unclear, stop and ask; do not invent.- A difference from the spec is a blocker. A spec change needs an Andy decision, and the same PR or a docs PR edits the spec to describe the system as it is. The spec holds no history: no phases, no earlier-system comparison, no dated notes.
- Add no feature the spec does not list.
- Judge a change against the architecture as a whole, not the diff: answer the installed
.agents/skills/architecture-review/SKILL.mdand then.github/skills/harness-architecture-review/SKILL.mdfor every review. - Follow the installed
.agents/skills/go-guide/SKILL.mdfor Go layout, API design, concurrency, tests, and comments. Where it differs from this file, this file wins. - One concern per PR. Describe the change in the PR body: problem, design, semantic change, verification. Do not hard-wrap a PR body.
- Never resolve a review thread without a reply: fix it and say how, or say why you decline.
- Routes: the route table, its read routes, and the mounts of
httpapi.Handlerandhttpapi.ReadHandlerequal the spec's route list. - Errors: every code is a
protocolconstant, aprotocol.HTTPStatusentry, a row of the specErrorstable with the same status, and a value of theopenapi.jsonError.codeenum.internal,payload_too_large, andunauthorizedneed no sentinel error (docs/architecture.mdErrors). - Structure:
internal/gates/structure.golists the one owner of each concept (for example the context window,Store.Append,State.Apply,message.EngineContext) and bans provider-name branches outsideconfig, the router, and provider wires. An allow-list entry carries a date and a reason; a stale entry fails. - Wire: a test double emits only what
testdata/wireholds; a recording holds no secret or id.testdata/wire/allowed.txtlists exceptions with reasons;HARNESS_RECORD_WIRE=1 go run ./internal/wirerecord -out testdata/wirerefreshes recordings with real model calls. Everye2e/HTTP client comes fromwireClient.
Add none of these without a new design decision:
- A permission or approval system for tool calls, or a plan mode.
- A JavaScript runtime, an opencode compatibility layer, or plugin auth hooks.
- A2A support without a concrete cross-organization use case.
- A web UI.
majorcontext/baileyowns that surface.
- Keep
harness versionand the time to theinitializeresponse ofharness acpinside the budget of theStartup budgetstep in.github/workflows/ci.yml. - Keep stdout of
harness acpfor ACP frames only. Log to stderr. - Before first output, read only the user and project config files. For
harness runandharness acponly (neverserveor the Go API), the default model of a config with nomodelalso checks the API key variable, stats the Codex login file thatcodex_auth_filenames (state of the user, like the config) and looks upclaudeonPATH. It reads no content and starts no process. - Make no network call and start no subprocess before a command needs it.
- Add no
init()side effects. Keep production Go free of cgo. - Validate credentials on first use. Keep model catalogs static. The one exception is the model list of a provider with
authchatgpt: it is fetched on first use, cached, and falls back to the static list.
- Keep files at most 800 lines. Keep each function's closing brace at most 80 lines below its opening brace.
internal/gatescompares each changed file with its merge-base version, follows renames, and never blocks a change that only deletes code. - Write no comment by default. A comment states a constraint, a hazard, or a non-obvious reason.
- A comment never states history: no issue numbers, dates, "previously", or "no longer".
- An exported identifier gets a one-line doc comment.
- Use ASD-STE100 Simplified Technical English for prose. Never print or log a secret value.
- Write tooling in Go (a test helper or
go run ./internal/...), not shell scripts. - After a change to a
protocoltype or tointernal/serverTable, commit thego generate ./protocoloutput (protocol/openapi.json,protocol/protocol.ts). CI fails on a diff.
- TDD means: write the failing contract test first, see it fail for the named reason, then implement. A contract test is a scenario row in
e2e/; a row runs on both drivers withHARNESS_E2E_RUNTIME=1, except a row markedrowDeleted(the contract has no such behavior). A behavior change adds a row; a bug fix adds one row to the nearest table. - Write no other test unless the code is pure:
internal/eventlogApply,internal/acp, wire transcoders (internal/provider/*/,internal/backend/modelapi/convert_test.go,internal/backend/claudecode/frames_test.go),config,internal/message,internal/gates. Otherwise list the file with a one-line reason intestdata/test-exceptions.txt(path, space, reason).internal/gatesfails a change that nets new lines inside Test, Benchmark, Fuzz, or Example functions or package-level vars elsewhere. Top-level helpers, fakes, and types do not count. A listed file still meets the 1.5 test:code ratio of its package. - Name a test by its behavior, never by an incident. No test reads another package's unexported state.
- No
time.Sleeportime.Afterin tests. Usetesting/synctestor channels. Useinternal/testpollonly for cross-process waits. - Run Go tests with
-race.gofmtoutput differs across Go minor versions; CI reads the version fromgo.mod.
go build ./... && go vet ./... && go test -race ./... && test -z "$(gofmt -l .)"
- Use Conventional Commit subjects.
- The body states the problem, the design, the semantic change, and the verification. Incident detail goes in the body, never in code.
- No AI attribution.
- Add a
CHANGELOG.mdentry under the unreleased heading for each user-visible change.