Testing guide
How aitp-rs is tested, layer by layer, and the command to run each.
The one-shot local gauntlet is make test (fmt + clippy + workspace
tests). make ci adds the lockstep-version check (check-versions), the
doc build, cargo-deny and cargo-audit. The other CI jobs need extra
tools or a sibling checkout, so you run them separately. They are listed
below.
Layers at a glance
| Layer | What it covers | Run it |
|---|---|---|
| Unit + integration | #[test] modules and tests/ dirs across the workspace | cargo test --workspace --all-features (CI uses cargo nextest run) |
| Doctests | Runnable /// examples on the public API (nextest skips these) | cargo test --doc --workspace --all-features |
| Property tests | proptest over JCS canonicalization and envelope/manifest parsing | part of the workspace test run (crates/aitp/tests/*_prop*.rs) |
| Fuzzing | libFuzzer targets over every untrusted-byte entry point | cd fuzz && cargo +nightly fuzz run <target> |
| Miri | UB / provenance checks on the pure modules | cargo +nightly miri test -p aitp --no-default-features --lib -- core:: (and crypto::) |
| Conformance | The spec's fixture corpus, driven through the NDJSON adapter | see Conformance below |
| Bindings | Node (node --test) and Python (pytest) SDK suites | see Language bindings |
| Cross-language interop | A real Python ↔ Node handshake through the native bindings | make interop |
| Cross-implementation acceptance | aitp-rs-minted artifacts verified by the independent aitp-verifier-py and aitp-verifier-ts, and the reverse on committed bytes | see xcheck |
| Vendored schemas | tests/schemas/ is byte-identical to the pinned spec commit | make schemas-check (needs a sibling spec checkout) |
| Fixture / KAT minting tools | tools/mint-conformance-fixtures, tools/mint-signed-examples | see Minting tools |
| Release hygiene | Lockstep versions, public-API semver, MSRV, bench build | make check-versions, make semver, make msrv, cargo bench … --no-run |
| End-to-end (LLM) | Two agents driven by live LLM calls (opt-in, networked) | AITP_RUN_LLM_TESTS=1 in tests/e2e-llm/ |
Unit and integration tests
Every crate carries #[cfg(test)] unit tests plus a tests/ directory
for integration coverage; in crates/aitp/tests/ each file is prefixed
with its module (tct_round_trip.rs, handshake_schema.rs). The workspace run is the default gate:
cargo test --workspace --all-features # or: make test
cargo nextest run --workspace --all-features # what CI runs (faster)cargo nextest runs each test in its own process and gives clearer
output, but it does not run doctests — CI runs cargo test --doc
separately, and you should too when you touch a /// example.
Known-answer tests, and the two ways they go blind
A known-answer test pins a value the spec publishes and checks the implementation reproduces it. That only works if the test can actually fail. Two patterns silently guarantee it cannot, and this repo shipped both — for a full release, with two implementations and a green conformance pack. Recognising them is the point of this section.
Blindness 1 — deriving the question from the answer
crates/aitp/tests/core_kat.rs used to decide which JSON shape to
canonicalize by searching for the artifact's wrapper key inside the
pinned answer hex. If the pin looked wrapped it canonicalized the wrapped
form; otherwise the inner one. It therefore agreed with whatever shape the
vector happened to carry and could not fail in either direction.
The rule now: a vector must declare its signing_input, the test
hard-codes the expected declaration per artifact, and an absent
declaration is a panic! rather than a default. A vector may not
self-certify its own convention, and the harness may not infer one.
Blindness 2 — re-minting before verifying
A test that signs an artifact and then verifies its own output proves only that the implementation agrees with itself. It passes identically whether the convention is right or wrong.
This is subtler than it sounds because the conformance pack does it
structurally: fixtures carry __VALID_*_SIG__ placeholders that
crates/aitp-conformance/src/fixture/placeholder.rs mints with the
harness's own key before handing them to the adapter. So aitp-rs and
aitp-verifier-py each minted under their own convention, verified their
own output, and both reported 51/51 — while a revocation snapshot minted
by one could never verify against the other. See
conformance.md.
The rule now: verify committed bytes as committed. The spec's
signed-examples/ exist for exactly this, and its README says so — those
files "MUST verify under any conformant AITP v0.3 implementation,
byte-for-byte, without any placeholder substitution."
What every JCS-profile artifact must have
Three cells, not one. A positive test alone pins nothing, because a signature valid over both shapes satisfies it:
| Manifest | Revocation snapshot | Session bundle | |
|---|---|---|---|
| canonical bytes vs the pinned vector | ✓ | ✓ | ✓ |
| pinned signature verifies over committed bytes | ✓ | ✓ | ✓ |
| negative: fails over the wrong shape | ✓ | ✓ | ✓ |
Drive the canonical-bytes test through the production signing-input
helper (revocation_signing_bytes, bundle_signing_bytes), never a
re-implementation in the test. A test that canonicalizes locally can stay
green while the production path signs something else — measured: before
that was fixed, a regression in bundle_signing_bytes was caught by a
single test in the entire workspace.
The only acceptance criterion that means anything
Mutate the vector and confirm the suite goes red. Not a corrupted digest —
a self-consistent re-wrap: object, canonical hex, byte length and both
digests all updated together, so the file is internally coherent in the
wrong convention. That is precisely the state the spec shipped before
commit 5f8e588. If the suite stays green, the harness is still adaptive
and the tests are decoration.
Property tests
proptest (a workspace dev-dependency) drives generator-based tests
where a single example can't cover the input space:
crates/aitp/tests/core_jcs_properties.rs— JCS idempotence, order invariance, whitespace-free output.crates/aitp/tests/delegation_attenuation_props.rs— delegated scope is always a subset; delegated expiry never exceeds the voucher.crates/aitp/tests/envelope_envelope_props.rsandcrates/aitp/tests/manifest_manifest_props.rs— parsing arbitrary input never panics, and a valid instance round-trips. These mirror theenvelope_parse/manifest_parsefuzz targets so the invariant is checked on every CI run, not only in the nightly fuzz window.
Fuzzing
Fourteen libFuzzer targets under fuzz/fuzz_targets/ cover every point
where an untrusted byte stream first meets a parser or verifier.
fuzz/README.md lists them and covers seeding,
reproducing crashes and adding a target.
cd fuzz
cargo +nightly fuzz run tct_verify -- -max_total_time=60CI runs a 30 s gate per target on pull requests
(.github/workflows/fuzz-pr.yml) and a 5-minute nightly sweep
(fuzz.yml) seeded from the spec fixtures, which files an issue on a
crash. The fuzz/corpus/ directory is git-ignored; the nightly job
uploads corpus deltas as build artifacts.
Miri
.github/workflows/miri.yml runs weekly (and on demand) against the
two pure modules most likely to harbor UB — aitp::core (JCS, AID
parsing) and aitp::crypto — under tree-borrows + strict-provenance,
one matrix leg per module.
cargo +nightly miri test -p aitp --no-default-features --lib -- core::
cargo +nightly miri test -p aitp --no-default-features --lib -- crypto::WASM portability
The pure verify/protocol modules must not pull in a native-only syscall
dependency. CI checks this with cargo check --target wasm32-wasip1 on
aitp without the HTTP features and on aitp-experimental:
cargo check -p aitp --no-default-features --features pinned-admission --target wasm32-wasip1
cargo check -p aitp-experimental --target wasm32-wasip1A full browser build for wasm32-unknown-unknown also needs a uuid
randomness feature. That is
not wired up yet.
Conformance
The v0.2 conformance corpus lives in the spec repo
(agentidentitytrustprotocol/schemas/conformance/), pinned to the
commit in ../tests/schemas/SPEC_VERSION.
The aitp-conformance runner drives fixtures through an adapter that
speaks the NDJSON protocol described in conformance.md;
the aitp-rs-adapter binary (also in the aitp-conformance package) is
the canonical Rust adapter.
cargo build -p aitp-conformance
./target/debug/aitp-conformance run \
--target ./target/debug/aitp-rs-adapter \
--fixtures-dir ../agentidentitytrustprotocol/schemas/conformance \
--feature experimental-multihop-delegation \
--feature experimental-session-bundleThe conformance job in ci.yml runs exactly this against the pinned
spec commit. The expected pass/fail/skip counts are given once, in the
conformance matrix summary. That
section also explains why del-004 and del-007 are skipped when the
draft features are enabled, and covers the known gap in the runner's exit
code
(#194).
Cross-implementation acceptance (xcheck)
Conformance and make interop are both Rust checking Rust. Conformance
re-mints fixtures with the harness's own key. The interop test drives two
bindings that wrap the same core. The xcheck job in ci.yml closes that
gap with an implementation that shares no code with this repo:
# Requires aitp-verifier-py installed at the commit in tests/AITP_VERIFIER_PY_VERSION.
cargo run --quiet -p mint-signed-examples --bin xcheck-mint \
| python3 scripts/xcheck-verify.pyxcheck-mint mints artifacts with aitp-rs.
aitp-verifier-py
then verifies those exact bytes, without re-signing anything. The reverse
direction is the committed session bundle in
tests/xcheck-fixtures/session-bundle/. aitp-verifier-py minted it, and
crates/aitp-experimental/tests/session_bundle_xcheck_committed.rs verifies it.
The verifier pin in tests/AITP_VERIFIER_PY_VERSION is a commit SHA, never
a branch, so an upstream change cannot break merges here unannounced. To keep
it from going stale, .github/workflows/bump-verifier-py.yml runs every
Monday (and on demand from the Actions tab, with a dry-run option). It
compares the pin with aitp-verifier-py main. When main is ahead, it
opens one PR on deps/verifier-py-<sha> that bumps the pin, so that PR's
xcheck job runs against the new verifier. It closes older bump PRs it
supersedes, and does nothing if the branch for the current main already
exists. The PR is never auto-merged, and the workflow is not a required
check.
The verifier's adapter through aitp-conformance
The same job also runs the conformance fixtures through aitp-conformance
twice, against aitp-rs-adapter and against the verifier's own adapter,
python -m aitp_verifier.adapter. That adapter is the first non-Rust one
through the runner. It is installed from PyPI at the exact version in
tests/xcheck-verifier-requirements.txt, so bumping it takes a PR.
scripts/xcheck-compare-reports.py then gates the job on two conditions:
- the verifier passes the
AITP v0.3core claim; - every fixture has the same outcome under both adapters.
A divergence the verifier cannot fix yet can be listed with
--known-divergence <id> in ci.yml, with a comment citing the verifier
bug. An entry that stops diverging also fails the job, so the list can only
shrink. The list is empty: aitp-verifier 0.1.2 agrees with aitp-rs on every
fixture. Both reports are uploaded as the
xcheck-py-report artifact. To run it locally:
python3.11 -m venv vpy && vpy/bin/pip install -r tests/xcheck-verifier-requirements.txt
printf '#!/bin/sh\nexec %s/vpy/bin/python -m aitp_verifier.adapter\n' "$PWD" > vpy-adapter && chmod +x vpy-adapter
cargo build -p aitp-conformance
for t in rs:./target/debug/aitp-rs-adapter py:./vpy-adapter; do
./target/debug/aitp-conformance run --target "${t#*:}" \
--fixtures-dir ../agentidentitytrustprotocol/schemas/conformance \
--report "${t%%:*}-report.json" --output tap > /dev/null
done
python3 scripts/xcheck-compare-reports.py rs-report.json py-report.jsonThe TypeScript verifier (xcheck-ts)
The xcheck-ts job runs both checks again against
aitp-verifier-ts,
a third implementation that shares no code with this repo or with
aitp-verifier-py, on Node 22. Like xcheck, it pins its two halves
separately:
- The adapter comes from npm as
@agentidentitytrustprotocol/verifier, at the exact version intests/xcheck-verifier-ts/package.json, installed withnpm cifrom the committed lockfile into its own directory. Dependabot opens the PR that bumps it. The job runs the fixtures throughaitp-conformanceagainst the package'saitp-verifier-adapterbin and againstaitp-rs-adapter, and gates onscripts/xcheck-compare-reports.py --verifier aitp-verifier-ts, under the same rules as the Python verifier. There are no known divergences. - The mint → verify step pipes
xcheck-mintinto the verifier'sscripts/xcheck-verify.mjs, which the npm package does not ship. It runs from a checkout pinned by commit SHA intests/AITP_VERIFIER_TS_VERSION, built withnpm ci && npm run build..github/workflows/bump-verifier-ts.ymlkeeps that pin current the same waybump-verifier-py.ymldoes: every Monday (and on demand, withdry-run) it opens one held PR ondeps/verifier-ts-<sha>whenaitp-verifier-tsmainis ahead of the pin.
Both reports are uploaded as the xcheck-ts-report artifact. Like
xcheck, the job is a required check on main. To run it locally from a
sibling checkout:
(cd ../aitp-verifier-ts && git checkout "$(cat ../aitp-rs/tests/AITP_VERIFIER_TS_VERSION)" && npm ci && npm run build)
cargo run --quiet -p mint-signed-examples --bin xcheck-mint \
| node ../aitp-verifier-ts/scripts/xcheck-verify.mjs
mkdir -p /tmp/vts-npm && cp tests/xcheck-verifier-ts/package*.json /tmp/vts-npm/
(cd /tmp/vts-npm && npm ci --ignore-scripts)
cargo build -p aitp-conformance
for t in rs:./target/debug/aitp-rs-adapter ts:/tmp/vts-npm/node_modules/.bin/aitp-verifier-adapter; do
./target/debug/aitp-conformance run --target "${t#*:}" \
--fixtures-dir ../agentidentitytrustprotocol/schemas/conformance \
--report "${t%%:*}-report.json" --output tap > /dev/null
done
python3 scripts/xcheck-compare-reports.py rs-report.json ts-report.json --verifier aitp-verifier-tsThe Go verifier (xcheck-go)
The xcheck-go job runs both checks against
aitp-verifier-go,
written from the RFCs and schemas on the Go standard library alone. It is
by the same author as this repo, so it does not count toward the
different-authorship criterion. tests/AITP_VERIFIER_GO_VERSION pins a
commit SHA, and the job builds cmd/aitp-verifier-adapter and
cmd/xcheck-verify from that checkout with the Go version its go.mod
names. The job then:
- pipes
xcheck-mintintoxcheck-verify. The Go verifier does not implement Session Trust Bundles, so it skips those artifacts; - runs the fixtures through
aitp-conformanceagainstaitp-verifier-adapterand againstaitp-rs-adapter, and gates onscripts/xcheck-compare-reports.py --verifier aitp-verifier-go, under the same rules as the other verifiers. There are no known divergences.
The adapter embeds the OIDC test-issuer keys, so it needs no spec files.
Both reports are uploaded as the xcheck-go-report artifact. Like
xcheck, the job is a required check on main.
.github/workflows/bump-verifier-go.yml keeps the pin current the same
way bump-verifier-ts.yml does: every Monday (and on demand, with
dry-run) it opens one held PR on deps/verifier-go-<sha> when
aitp-verifier-go main is ahead of the pin. In the other direction,
.github/workflows/notify-verifiers.yml sends aitp-released to both
aitp-verifier-ts and aitp-verifier-go on every aitp-v* tag, and
their bump-aitp-rs.yml opens a held PR that moves AITP_RS_COMMIT to
the release. To run it locally from a sibling checkout:
(cd ../aitp-verifier-go && git checkout "$(cat ../aitp-rs/tests/AITP_VERIFIER_GO_VERSION)" \
&& go build -o bin/ ./cmd/aitp-verifier-adapter ./cmd/xcheck-verify)
cargo run --quiet -p mint-signed-examples --bin xcheck-mint | ../aitp-verifier-go/bin/xcheck-verify
cargo build -p aitp-conformance
for t in rs:./target/debug/aitp-rs-adapter go:../aitp-verifier-go/bin/aitp-verifier-adapter; do
./target/debug/aitp-conformance run --target "${t#*:}" \
--fixtures-dir ../agentidentitytrustprotocol/schemas/conformance \
--report "${t%%:*}-report.json" --output tap > /dev/null
done
python3 scripts/xcheck-compare-reports.py rs-report.json go-report.json --verifier aitp-verifier-goMinting tools
tools/mint-signed-examples(binarymint-signed-examples) mints the spec'sknown-answer/signed-examples/files from the pinned KAT keypairs. Its second binary,xcheck-mint, feeds the xcheck job above.tools/mint-conformance-fixtureswrites real signed values into the spec's conformance fixtures, following the placeholder rules.
Both are workspace tools for keeping the spec's vectors reproducible, not
tests. make coverage leaves them out.
Other CI jobs
The jobs below are in .github/workflows/ci.yml and are not part of make test:
| Job | What it checks | Local equivalent |
|---|---|---|
spec-schemas | Vendored schemas match the pinned spec commit, and the spec's own known-answer verifier passes | make schemas-check |
versions | Crate and binding versions move in lockstep | make check-versions |
semver | cargo-semver-checks against the PR base (PRs only) | make semver |
msrv | The pinned MSRV still builds the aitp crate | make msrv |
bench-check | The criterion benches compile | cargo bench -p aitp --no-run |
features | Each feature of aitp and aitp-experimental builds, lints and tests on its own (cargo hack --each-feature), and the small-dependency feature sets stay small (scripts/check-dep-surface.sh) | scripts/check-dep-surface.sh; cargo hack test -p aitp -p aitp-experimental --each-feature |
wasm | The pure modules build for wasm32-wasip1 | see WASM portability |
e2e-llm-build | tests/e2e-llm formats, lints, and runs with the skip gate engaged (no provider calls) | see End-to-end (LLM) |
docs-check (not required) | Doc links and anchors, RFC-AITP-NNNN §x.y citations against the pinned spec, protected inbound anchors, banned stale strings | make docs-check |
Language bindings
Both SDKs are excluded from the Cargo workspace and built with their native toolchains. Their test-file sets are kept at parity.
Node (bindings/aitp-node, NAPI-rs):
cd bindings/aitp-node
npm install
npm run build:debug # the binding must be built with default features
npm test # node --test tests/*.mjsPython (bindings/aitp-py, PyO3/maturin):
cd bindings/aitp-py
python -m venv .venv && . .venv/bin/activate
pip install maturin pytest httpx 'pyjwt[crypto]' cryptography
maturin develop # add --features experimental for the experimental tests
pytest tests/ -vA stale
aitp*.soleft in the Python package dir by an earlier build can shadow a freshmaturin developbuild. These files are git-ignored (bindings/**/*.so), sogit statuswill not show them. Remove the file if pytest imports an old binding.
Cross-language interop
make interop (scripts/interop.sh) builds both bindings and runs a
real four-message Python ↔ Node handshake in both directions through the
native SDKs (bindings/interop/), plus third-party JOSE acceptance of
the spec's signed-example KATs. CI runs it in bindings.yml.
End-to-end (LLM)
tests/e2e-llm/ is a separate, workspace-excluded crate: two agents
handshake and then delegate, driven by live OpenAI/Anthropic calls. It
is opt-in and networked — run it by hand:
cd tests/e2e-llm
AITP_RUN_LLM_TESTS=1 cargo testTo run it in a container on a stock Linux toolchain, use
docker-compose.e2e-llm.yml at the repo root. It reads the provider keys
from the git-ignored tests/e2e-llm/.env (copy it from .env.example):
docker compose -f docker-compose.e2e-llm.yml run --rm e2e-llm \
cargo test --test handshake_then_delegate -- --nocaptureCI never calls a provider. The e2e-llm-build job compiles and lints the
crate, then runs it with AITP_RUN_LLM_TESTS=0, so every test takes its
skip branch.
Coverage
CI measures line coverage with cargo-tarpaulin and enforces a floor
(--fail-under in the coverage job of ci.yml); the report is
uploaded as a build artifact. Locally:
make coverage # tarpaulin over the workspace, prints to stdoutThe floor is a ratchet — raise it as coverage climbs, never lower it to make a red run pass.