← All essays

Essay · Kiroween 2026

Why a real passing test run still shipped a broken auth check

SpecCoven editorial diagram showing how one edited operator turns a prior passing test run into STALE_EVIDENCE
A passing test run proves only the bytes that were on disk when the check ran—never the cleanup edit made thirty seconds later.

Every coding agent has the same blind spot. It finishes implementing a feature, runs the test suite, and sees four clean passing assertions in stdout. Before marking the task complete, it performs one tiny cleanup edit inside src/auth.js:

src/auth.js — canDeleteBilling(user)
- return user.role === 'admin' && user.mfa; + return user.role === 'admin' || user.mfa;

Those green test logs in the agent’s context window are completely real. Nothing was fabricated. They just belong to the bytes that existed before && became ||. Trusting memory instead of cryptographic state, the agent checks - [x] T-01 done, hands work to the next task, and any viewer with MFA enabled can now delete billing.

SpecCoven stops that failure mode at the byte level. Every recorded check is pinned to the exact SHA-256 digests of its declared repository scope. Change one character anywhere inside src/auth.js after the suite runs, and SpecCoven invalidates the proof immediately:

SPECCOVEN · STALE_EVIDENCE EXIT 1
Task: T-01 · code · [ ] open Check: test -> STALE (node test/auth.js) Drift: src/auth.js / before f90711ea8ca8 -> after 5850cdd7f2ae Gate: Kiro PreToolUse blocks [x] (exit 2) until rerun

Four components on one pure TypeScript core

Instead of wiring brittle wrapper scripts around an LLM prompt, SpecCoven puts one zero-dependency TypeScript verification core (verifyEvidence() plus SHA-256 hashing) behind four interfaces that agree down to the digest:

SpecCoven Browser Specimen Lab displaying auth guard drift, provenance ledger, and frozen T-01 to T-02 task handoff
The interactive Browser Specimen Lab at pauljones0.github.io/speccoven: flipping one operator freezes downstream task handoff until checks actually pass again.
  • Git plumbing CLI (src/cli.ts, src/local/repository.ts): Inspects repository files directly via git ls-files -v and git cat-file, isolates documentation-only checkbox toggles with maskCheckboxes() so flipping [ ] to [x] inside tasks.md does not falsely invalidate passing code evidence, renders human-readable proof cards with --pretty, and replays archived receipts offline with speccoven replay.
  • Kiro hooks & stdio MCP (src/local/kiro-hook.ts, src/mcp.ts): Enforces task gates inside Kiro via a fail-closed PreToolUse hook returning exit code 2 on str_replace, fs_write, edit_file, write_file, execute_bash, bash, and shell—preventing both checkbox edits and quick shell sed bypasses—paired with a 7-tool, 2-resource JSON-RPC 2.0 MCP server.
  • Browser Specimen Lab (web/lab.js): Runs real JavaScript assertions inside an ES-module Web Worker under strict Content Security Policy (zero unsafe-eval) with Web Crypto SHA-256 hashing, letting anyone watch STALE_EVIDENCE, MISSING_EVIDENCE, and T-01 → T-02 handoff gating live in the browser.
  • SVG notary seals & EARS fuzzer (src/core/seal.ts, web/pbt.js): Exports standalone .svg notary seals embedding canonical receipt payloads inside <metadata id="speccoven-proof"> so any receipt stays verifiable offline without servers, alongside a browser fuzzer exercising properties P1–P5 across 1,250 randomized mutation trials in under 200 ms.

The Kiro hook bug that shaped the architecture

SpecCoven was built spec-first inside Kiro from 8 EARS requirements (34 acceptance criteria), design.md, and an 18-task implementation plan tracked in .kiro/specs/speccoven-core/. Early in Phase 2, testing on kiro-cli 3.7.1 surfaced an unexpected harness limitation: PostFileSave hooks had their stdout and stderr suppressed even when exiting non-zero (exit 1), making post-save warnings invisible to the active agent session. We documented the reproduction in SPIKE_LOG.md and designed a fail-closed architecture around it rather than trusting silent advisory hooks:

{
  "trigger": "PreToolUse",
  "matcher": "^(str_replace|fs_write|fs_append|edit_file|write_file|execute_bash|bash|shell)$",
  "command": "node bin/kiro-hook.js",
  "timeout": 10
}

That .kiro/hooks/speccoven.json contract drives three deliberate architectural boundaries, verified live on kiro-cli 3.8.1:

  1. Out-of-band diagnostics + steering rules: Post-save audit summaries are persisted to .speccoven/out/last-save-report.json and surfaced alongside rules in .kiro/steering/epistemic-rules.md so neither agent nor user flies blind.
  2. Fail-closed PreToolUse interception: bin/kiro-hook.js inspects proposed file edits and shell commands before execution, returning exit 2 whenever a checked task lacks fresh passing evidence for its current file hashes.
  3. Structured MCP inspection: Agents query verification state, task handoffs, and saved receipts cleanly over 7 MCP tools and 2 resources configured in .kiro/settings/mcp.json.

When we attempted to mark T-01 complete in a live kiro-cli 3.8.1 session while src/auth.js carried unverified edits, Kiro stopped the tool call cold:

[tool] Read File
[tool] status: Completed
[tool] Replace in File
[tool] status: Failed: Replace in File
A hook blocked the edit. Here is the verbatim output:

SpecCoven blocked T-01: {"task_id":"T-01","task_type":"code","task_checked":false,"verdict":"STALE_EVIDENCE","checks":[{"check_id":"test","command":"node test/auth.js","exit_code":0,"status":"STALE","file_drift":[{"path":"src/auth.js","recorded":{"sha256":"f90711ea8ca88eef74cf8c597d97c2fa351db0c7dd8df7bb89d9c6be883c3e9f","mode":"100644"},"current":{"sha256":"5850cdd7f2ae69bd203d6309de3fd79d76a3dae5be915326f45d3b185aba0748","mode":"100644"}}]}],"changed_paths":["src/auth.js"],"unscoped_paths":[]}

Self-verification, benchmarks, and limits

Rather than relying solely on synthetic examples, SpecCoven verified its own development commits across 14 archived evidence pairs in .kiro/specs/speccoven-core/evidence/. Every invariant is exercised across both Node.js and the browser Web Worker:

34 / 34 Integration checks + 5 fast-check suites (5,000 Node + 1,250 browser cases)
0.00985 ms Median pure core verifyEvidence() latency (n = 5,000)
33.71 ms Median full CLI speccoven verify invocation (n = 40)

You can reproduce the entire suite and replay an archived SpecCoven self-verification pair locally from the repository root:

npm ci && npm test
node bin/speccoven.js replay \
  --bundle .kiro/specs/speccoven-core/evidence/phase-2/T-01/evidence-bundle.json \
  --manifest .kiro/specs/speccoven-core/evidence/phase-2/T-01/current-state-manifest.json \
  --pretty

Honest v1 boundary: SpecCoven v1 binds test receipts to Git commits, file modes, and SHA-256 content hashes for local determinism and offline replay. It does not claim asymmetric hardware signing or CI identity attestation—adding Sigstore or GitHub OIDC provenance on top of the exact same receipt schema is the natural next step for shared CI pipelines.

Try it live

Nothing in the workflow requires trusting slides. You can open the live Specimen Lab, break src/auth.js yourself, inspect all 14 self-verification receipts, or load a pre-generated STALE_EVIDENCE snapshot directly via URL fragment: