# zat deterministic testing campaign Hegel is pinned in `build.zig.zon`. Baseline zat: `9f4fe9a`. ```sh scripts/campaign list scripts/campaign run xrpc --out /tmp/zat-xrpc # one campaign, seeds 1 and 2 scripts/campaign calibrate calibration --out /tmp/zat-mutants scripts/campaign replay /tmp/zat-xrpc/replay-0.json --out /tmp/zat-replay HEGEL_SEED=1 HEGEL_TEST_CASES=100 zig build pbt -Dhegel # every campaign, directly HEGEL_SEED=2 HEGEL_TEST_CASES=1000 zig build pbt-mst -Dhegel PBT_TARGET=structured HEGEL_SEED=2 HEGEL_TEST_CASES=100 zig build pbt-codecs -Dhegel HEGEL_SEED=1 HEGEL_TEST_CASES=100 zig build pbt-runtime -Dhegel HEGEL_SEED=1 HEGEL_TEST_CASES=300 zig build pbt-xrpc -Dhegel HEGEL_SEED=1 HEGEL_TEST_CASES=300 zig build pbt-identity -Dhegel HEGEL_SEED=1 HEGEL_TEST_CASES=300 zig build pbt-firehose -Dhegel HEGEL_SEED=1 HEGEL_TEST_CASES=300 zig build pbt-oauth -Dhegel ``` `pbt/campaigns.zon` runs each campaign through the pinned hegel-campaign runner in a disposable worktree, with separate outcomes and a replay bundle per minimized failure. Commit first; the runner refuses tracked changes. Each campaign declares the events both seeds must reach; a seed that misses one is `unreached`, not a pass. Events prefixed `known:` count divergences and are not required. `calibration` plants each entry of `mutants.zon` and runs every campaign (`scripts/pbt-all`) under ten seeds. Entries prefixed `finding:` undo a fix found here. Use `HEGEL_ZIG_REPLAY` with the same executable, target, dependency revision, and generator to replay a failure. Use `HEGEL_ZIG_ECHO=1` for histories preceding panics. Rule tallies include shrink and replay executions; Hegel statistics report exploration cases separately. A seed is not a substitute for the replay blob when the generator changes. | Surface | Current checks | Remaining work | | --- | --- | --- | | MST | Map oracle, mutation, copies, eager/lazy/partial reload, block hashes, refused-operation atomicity, one-shot block reader failures during lazy reads (paused for oracle reads) | Reader faults are one-shot errors; slow or corrupt blocks are not injected | | CBOR/CAR/CID/multibase/base64 | Roundtrips, canonical encoding, arbitrary malformed inputs | Allocation failure paths; independent codec vectors | | Syntax | TID, datetime and space URI roundtrips, malformed identifier inputs and mutations of canonical space URIs | Generated valid identifiers and independent syntax oracle | | Crypto/repo | Both ECDSA curves, tampered messages, signed commits, wrong DID | Commit diff histories and malformed proofs | | STAR/firehose/labels/Jetstream | Chunked STAR values, label and commit roundtrips, structured mutations | | | Firehose subscription | Real FirehoseClient and websocket.zig over simulated relays: refused connects, rejected upgrades, streams ended by EOF or close frame, undecodable frames; cursor on each reconnect, exact delivered sequence, backoff and its reset and cap, host rotation, Host header | `idle_timeout_ms` needs a concurrent simulated Io; Jetstream and label subscriptions not yet simulated; wss needs simulated TLS | | Identity | Real DID and handle resolvers over simulated PLC and DoH hosts: document id binding, did:web DoH preflight against an independent IANA address classification, non-literal answers, TXT `did=` selection, transport faults | HTTPS well-known and did:web document fetches need simulated TLS | | XRPC | Real client, zttp, and std.http over a simulated network: wire encoding, auth, retry and replay model, Retry-After and reset hints, refused/reset/truncated connections, keep-alive reuse | Deadline and stall guards need a concurrent simulated Io | | OAuth | Virtual clocks, seeded entropy, retry timing/cancellation, proof and assertion generation; resource and refresh requests over simulated servers: nonce challenges in body and header, missing nonces, retry exhaustion, per-proof htm/htu/nonce/ath/iat/jti, returned nonce, leaks under a checking allocator | PAR and code exchange share the same retry helper but are not driven directly; https issuers need simulated TLS | `SimIo` starts from `std.Io.failing`, overriding time, sleep, randomness, and, when a `Network` is attached, DNS lookup, connect, socket reads and writes. Hosts are in-process handlers that see parsed requests and script responses and faults; reads return random partial lengths. It performs no real network or filesystem operations. `async` runs inline and `concurrent` is unavailable, so zttp runs without its deadline and stall guards; TLS is not simulated. Seeds are test entropy, never suitable for production keys. Parser fuzzing and pure properties are listed separately from simulations; this table is not a claim of exhaustive coverage. Prior art: the existing `zat.hegel` MST and codec harnesses, Hegel's walkthrough, Burner Redis's real Redis oracle, and Prefect Server's virtual clock/fault world. The codec harness initially assumed full-u64 canonical CID varints and exact empty-block preservation in firehose encoding. Those assumptions were wrong: minimal CID varints are 63-bit; empty commit blocks request CAR generation. ## OAuth permissions Run the scope campaign and the separate mutation matrix with the repository runner. ```sh scripts/campaign run permissions --out /tmp/zat-permissions scripts/campaign calibrate permission-calibration --out /tmp/zat-permission-mutants ``` The permission campaign uses independent finite repo, RPC, MIME and account relations, plus encoding-equivalence, rejection and arbitrary-byte properties. The rejection generator pairs each mutation with a valid control and varies the field, spelling, and value across malformed escapes, double decoding, escaped delimiters, duplicate singleton fields, positional/named collisions, unknown attenuators, and invalid wildcard combinations. CI checks reachability for every mutation family. The wire corpus is shared by the Zig unit tests and the independent `@atproto/oauth-scopes@0.5.16` checker. Reproduce the reference comparison in a scratch directory. ```sh scratch=$(mktemp -d) npm install --prefix "$scratch" --no-audit --no-fund --ignore-scripts --save-exact \ @atproto/oauth-scopes@0.5.16 @atproto/did@0.5.6 @atproto/syntax@0.7.9 zod@3.25.76 node scripts/check-permission-reference.mjs "$scratch/node_modules/@atproto/oauth-scopes/dist/index.js" ``` ## calibration On 2026-11-16 each of the 21 entries in `mutants.zon` ran through `scripts/campaign calibrate calibration` at zat `4660bc8` with hegel-zig `6840302`: ten seeds at 100 cases across all seven campaigns, each mutant on its own Fly `performance-2x` machine after its own unmutated baseline. Every baseline passed on all ten seeds, and every mutant, including the nine `finding:` entries that undo a fix and the pinned-address mutant, failed a property on 10 of 10 seeds with no crash, timeout or unreached outcome. A clean sweep says the planted bugs are reachable at this budget, not that the campaigns are complete; the surface table above lists what they do not cover.