AGENT SKILL

conformance-test-authoring

How to add or extend a test in the cross-edition conformance suite under test/conformance, covering which class a behaviour belongs to, the three test shapes with their support helpers, the harness components to reuse, the determinism rules, and the adversarial posture a reviewer brings. Use when writing, extending or reviewing a conformance test or a harness component.

License 许可
Apache-2.0
所属仓库
stigmer/stigmer
最近更新
2026-11-15
Stars
★ 9
Forks
6

01 前言 Front Matter

name
conformance-test-authoring
paths
[ "test/conformance/**" ]
description
How to add or extend a test in the cross-edition conformance suite under test/conformance, covering which class a behaviour belongs to, the three test shapes with their support helpers, the harness components to reuse, the determinism rules, and the adversarial posture a reviewer brings. Use when writing, extending or reviewing a conformance test or a harness component.

02 资源文件 2

03 SKILL.md 正文

Authoring conformance tests

test/conformance/README.md is the reference: how to run each class, the design, the layout, and the two "Adding a ..." procedures. The package guide (test/conformance/AGENTS.md) carries the laws. This skill carries the shapes a new test takes, so that it looks like the suite it joins, and the posture that makes a test worth having. The discipline shared with every test in the repository is in references/test-discipline.md.

Which class, which file

  • A cross-edition contract (an RPC's behaviour every edition must share) is a Class A test under test/conformance/src/suites/, run by make test-conformance against the OSS server built from source; the local-postgres target runs the same files over the Postgres driver, and the enterprise target against a licensed Enterprise server (make test-conformance-enterprise). An arm that holds only where open source's posture holds gates on its capability flag.
  • A runner behaviour read through run status is an execution-class test under test/conformance/src/suites-execution/, run by make test-conformance-execution (Temporal, the server and the runner from source; every model turn scripted on the mock LLM).
  • A cloud capability is a cloud-class test, connect-only against a pre-provisioned composition, tagged with its inventory rows.
  • A server or runner unit belongs beside its module in a __tests__ folder, not here. A unit of a conformance-only harness component belongs in test/conformance/src/harness/__tests__/; one of the shared machinery in test/support/src/__tests__/.

Extend the existing <domain>-<facet>.conformance.test.ts when the facet exists; the execution class has one file per facet (run-approval, run-file-review, routine-firing, and the rest), and a new file is a new facet, opened with an intent header that states the contract it pins and what is deliberately out of scope.

The three shapes

A runner behaviour, read through run status. Script the model's turns, create the run, await the terminal phase, assert on the phase and on what the mock consumed:

mock.enqueue(anthropicToolUse("call_1", ECHO_TOOL_NAME, { text: "ping" }));
mock.enqueue(anthropicText("Done."));
const run = await clients.agentExecutionCommand.create(
  makeAgentExecution({ org, name, agentId, autoApproveAll: true }),
);
const final = await awaitTerminal(clients, run.metadata!.id);
expect(final.status?.phase).toBe(RunPhase.RUN_COMPLETED);
expect(mock.consumed(), "exactly the scripted turns").toBe(2);

anthropicText, anthropicToolUse and the other turn builders live in test/support/src/llm-wire.ts; makeAgentExecution and awaitTerminal in test/conformance/src/support/runs.ts.

An approval gate. Wait for the ask with awaitRequiresAction, then answer through confirmPerContract (test/conformance/src/support/answers.ts): it gives the answer (the session's confirmToolUse or grantPermission) and asserts how many of the turn's asks the session's log still holds open. Never a bare answer followed by an expectation on what waits: that shape passed while the contract was broken, which is why the helper exists. answersOf reads the answers the log recorded.

A file-review turn. Attach a GitWorkspace (test/conformance/src/harness/git-workspace.ts) as the session's local workspace, script write and edit turns, awaitFileReview, decide through the session's reviewFileChanges with reviewFileByPath or reviewChangeSet, read the decisions back from the log with readFileReviewLog and reviewSetNow, then read the tree back (test/conformance/src/support/file-review.ts).

For a routine: makeRoutine in test/conformance/src/support/routines.ts. For anything else that advances on its own: pollUntil in test/conformance/src/support/run-poll.ts, never a fixed sleep.

Reuse the harness

One file per component. The machinery other suites share lives in test/support/src/ (@stigmer/test-support): the server build and process, the Temporal dev server, the runner build and process, the mock LLM (mock-llm.ts with the wire builders in llm-wire.ts), the fake upstream and the identity fixtures. The suite's own components stay under test/conformance/src/harness/: the manager-mode runner, the MCP tool fixture (mcp-server.ts), the git workspace, the model registry reader, the raw Connect clients, and the cloud fixtures with their fakes. Read a component's header before using it. When a new pattern is needed, add the utility to the harness so the next suite reuses it; a suite that boots its own infrastructure is a second harness that will drift.

Edition differences are CapabilityFlags on the target (test/conformance/src/targets/target.ts), each with a rationale, gated with describe.skipIf so the run reports SKIPPED; never a target-name check and never a silent return.

Determinism, in the suite's own terms

  • Poll with a timeout (awaitTerminal, awaitTaskStatus); never sleep.
  • Unique resource names per test (test/conformance/src/support/naming.ts); no shared mutable state; no order dependence.
  • Temp directories only; the harness owns cleanup in reverse order.
  • Assertions on LLM-dependent behaviour read structure and side effects, never prose.
  • The assertion message says what went wrong in terms a reader can act on: the run id, the expected and observed phase, the elapsed time.

Live vendors

A test that needs a live vendor credential has no offline arm and says so in its header. It is not a conformance test: it belongs to the live class (*.live.test.ts, test/README.md), which only a package with a vitest.live.config.ts may hold (scripts/test-integrity.mjs refuses one anywhere else). Today that is backend/services/runner, whose live suites run by hand and in ci.live.yaml after each release, with the keys from the provider-integration environment. A new vendor's key needs its name in LiveSecretName (backend/services/runner/src/__test-utils__/live-gate.ts), a secret in that environment, and a line in the live step's env:.

The package's own gates

From test/conformance: npm run typecheck (vitest does not typecheck), npm run test:unit for the harness units, npm run inventory:check when a cloud suite or test/conformance/inventory/cloud-capabilities.yaml changes. In a fresh worktree, make build-ts-stubs first or the package cannot resolve @stigmer/apis.

npm run inventory:check also holds the RPC contract: a new test that pins an RPC carries its [rpc:<Service>.<method>] tag at the front of its title, and a new RPC with no such test is waived in test/conformance/inventory/rpc-waivers.yaml (a gap naming its open issue, or proven-elsewhere naming a tagged test file), and the pull request that adds the waiver declares it (RPC-waiver: <Service>.<method> -- <reason> in its body). Tag only an RPC the test's own clients send: a tagged test that never sends it fails by name, one that sends nothing included. The placement rules are in test/conformance/README.md, "The RPC contract".

04 同仓库更多 Skills