Automated QA system complete reference manual
The full QA system reference on one page.
This document is the consolidated technical manual for the automated QA system in this repository. It brings together system concepts, CLI references, module contracts, the acceptance manifest, maintenance procedures, and troubleshooting into a single document.
1. System overview
The automated QA system stops broken or unverified code from reaching Git commits, pull request merges, and production releases. It provides an independent, software-driven gate before code enters history.
Why this system exists
We are building a tool for employees who need to calculate real driving distances between campuses and retailer locations. If the software swaps a branch campus for a main campus, drops duplicate rows from a customer file, or fabricates a distance when an API fails, employees make bad planning decisions based on bad data.
We use autonomous coding agents to build features. But an agent that just wrote code cannot objectively certify its own work. It will usually assume its solution works.
This QA system solves that problem by separating roles:
- The implementer writes code, stages changes, and writes tests.
- An independent QA agent session reviews the staged changes in an isolated sandbox.
- Deterministic software evaluates the outcome. Code, not an AI model, decides whether tests passed.
How changes get checked
- Staged changes. The pre-commit gate inspects the Git staging area using
git write-tree. It unpacks those exact files into an isolated directory and runs all checks there. - Unstaged changes. The runner rejects unstaged changes. If nothing is staged, it exits with an error asking you to run
git add. Unstaged edits in your working tree never touch the test run. - Committed changes. The CI runner (
pnpm qa:ci) inspects committed history. You can pass explicit commit hashes or branch ranges to verify introduced commits against a base branch.
The auto-run switch
Running an independent AI reviewer on every commit takes time. To keep everyday development fast, a committed configuration file in tooling/qa/policy/switch.json controls automatic hook execution.

- Switch is off (default). Git pre-commit hooks print a notice naming
pnpm qaand exit cleanly. You can commit immediately without waiting for an AI review. - Switch is on. Git pre-commit hooks run the full automated QA assessment before every commit.
- Manual verification (
pnpm qa). You can runpnpm qaanytime. It bypasses the switch and runs the complete pre-commit gate on your staged changes, issuing a signed verification receipt when it passes.
Four rules that govern the design
- Test the staged index, never the dirty working folder. The pre-commit runner calls
git write-treeto capture the exact staged index. It unpacks that tree into a temporary directory outside the working tree and runs all checks there. - Code has the final word, not the AI. Language models are useful reviewers, but they are not truth oracles. The QA agent has zero authority to approve a run. If
pnpm checkexits with code 1, the gate fails immediately. The agent can flag defects and fail the gate, but it can never override a broken test. - Every run leaves a permanent trail. Every test run generates a run folder under
.qa-reports/runs/<runId>/. It stores command outputs, git diffs, agent transcripts, and sha256 checksums. Passing runs receive a signed receipt. - Self-enforcing code growth. Tripwire scripts in
scripts/check-repository.mjsensure that the moment you add code tosrc/app/, the build breaks until you register real application build and test commands inpackage.json.
End to end workflow

Three execution profiles
- Commit profile. Runs locally before commits (via
pnpm qamanually, orpnpm qa:commitvia hooks when auto-run is on). Focuses on fast deterministic tests, index concurrency, and agent code review. - CI profile. Runs on pull requests via
pnpm qa:ci. Verifies commit receipts, validates merge candidates against their base branch, and runs live checks. - Release profile. Runs before deployment via
pnpm qa:release. Evaluates build artifacts and checks all 28 accepted criteria intooling/qa/manifest/acceptance-manifest.json.
2. CLI commands
Everyday commands
| Command | Lifecycle stage | Primary file |
|---|---|---|
pnpm qa | Manual pre-commit assessment | scripts/qa-commit.mjs |
pnpm qa:commit | Automatic pre-commit hook runner | scripts/qa-commit.mjs |
pnpm qa:ci | Continuous integration and pull requests | scripts/qa-ci.mjs |
pnpm qa:release | Staging and production release checks | scripts/qa-release.mjs |
pnpm qa:setup | Machine and repository setup | scripts/qa-setup.mjs |
pnpm check | Fast deterministic code and QA checks | package.json |
pnpm test:qa | QA system self-test suite | tests/qa/ |
pnpm qa
The primary command you run locally to verify changes before committing.
- Script:
scripts/qa-commit.mjs --manual - Usage:
pnpm qa [--verbose] [--dry-run] [--repair] - Behavior: Bypasses the
"off"switch inswitch.jsonand executes the full commit assessment on currently staged files. - Flags:
--verbose. Prints candidate tree hashes, staged file lists, and real-time suite execution updates.--dry-run. Displays the planned test suites and agent tasks without running tests or calling the reviewer agent.--repair. Automatically runs up to two repair cycles to fix staged formatting issues before failing the gate.
- Exit codes:
0: Gate passed. Staged files are clean and a receipt is issued.1: Demonstrated failure. A test failed, linting broke, or the QA agent filed a critical finding.2: Blocked. Index was modified during testing, a tool timed out, or prerequisites were missing.
pnpm qa:commit
Executed by Git hooks when committing.
- Script:
scripts/qa-commit.mjs - Behavior: When
tooling/qa/policy/switch.jsonhasautoRun: "off", it prints a notice pointing topnpm qaand exits cleanly. When the switch is"on", it runs the full pre-commit gate.
pnpm qa:ci
Evaluates incoming commits and pull request merges in continuous integration.
- Script:
scripts/qa-ci.mjs - Usage:
pnpm qa:ci [--base=<sha>] [--head=<sha>] [--require-receipts] - Flags:
--base=<sha>. The base branch or commit hash to compare against. Defaults toorigin/main, then to the initial empty tree.--head=<sha>. The tip commit of the pull request. Defaults toHEAD.--require-receipts. Fails if any introduced commit lacks a valid pre-commit receipt.
- Behavior: Checks
.qa-reports/receipts/<commitSha>.jsonfor each commit in the range. Valid receipts allow CI to verify that commits were already assessed.
pnpm qa:release
Verifies that an application build artifact meets all release requirements.
- Script:
scripts/qa-release.mjs - Usage:
pnpm qa:release --artifact=<sha256> --env=<staging|production> - Behavior: Fails closed with exit code 2 (blocked) until all 28 product criteria in
acceptance-manifest.jsonare implemented and verified by automated tests.
pnpm qa:setup
Validates tool prerequisites (Node.js 26.8.2+, pnpm 12.3.4+, git 2.0.0+, agy 1.1.9+) and configures Git hooks without destroying existing custom hook scripts.
pnpm check
Runs deterministic code checks: formatting, ESLint, TypeScript types, architecture rules, knip unused file checks, repository policies, and all unit and QA test suites.
pnpm test:qa
Executes all 18 adversarial test files in tests/qa/ that validate the QA system itself.
3. Architecture and module contracts
Directory layout
tooling/qa/
├── candidate/
│ ├── capture.mjs # Calls git write-tree and captures staged files
│ └── materializer.mjs # Unpacks git trees into isolated folders
├── policy/
│ ├── resolver.mjs # Resolves required test suites and agent tasks
│ ├── switch.json # Controls whether pre-commit hooks run automatically
│ ├── switch.mjs # Reads and validates the switch configuration
│ ├── case-catalog.mjs # Catalogs acceptance cases and impact maps
│ ├── intent.mjs # Formulates product-intent review context
│ └── schemas.mjs # Data validation schemas for records and reports
├── agent/
│ ├── runner.mjs # Spawns isolated reviewer sessions and tracks budgets
│ ├── prompt.mjs # Builds prompts and validates structured findings
│ ├── browser-qualification.mjs # Validates browser automation safety rules
│ ├── mcp-server.mjs # Exposes tool capabilities to reviewer sessions
│ └── repair.mjs # Executes the automated format repair loop
├── executor/
│ └── subprocess.mjs # Runs commands in sandboxed child processes
├── evidence/
│ ├── collector.mjs # Collects logs, diffs, and computes sha256 digests
│ └── probes.mjs # Evaluates runtime assertions and logs
├── gate/
│ ├── evaluator.mjs # Evaluates test exit codes, findings, and criteria
│ └── receipt.mjs # Signs and verifies cryptographic proof tokens
├── manifest/
│ └── acceptance-manifest.json # Tracks all 28 product criteria
├── reporter/
│ └── writer.mjs # Writes gate-result.json, receipt.json, and summary.md
└── evaluation/
└── reviewer-eval.mjs # Benchmarks agent defect detection on test corpora

Module responsibilities
- Candidate capture and materialization (
candidate/).capture.mjs: Runsgit write-treeto generate a 40-character SHA of the staging index without creating commits or altering refs. Parses staged files and verifies index concurrency.materializer.mjs: Unpacks the candidate tree into an isolated folder, binds Git alternates for object sharing without history duplication, and checks for symlink directory escapes.
- Policy, resolver, and switch (
policy/).resolver.mjs: Freezes execution plans before test execution, mapping staged file diffs to required suites and agent tasks. Computes composite digests of policies and configurations.switch.json&switch.mjs: Governs automatic hook execution ("off"or"on").case-catalog.mjs&intent.mjs: Catalogs acceptance IDs and prepares product-intent review assignments when material features change.schemas.mjs: Enforces schemas for execution records, receipts, and reviews.
- Command execution (
executor/).subprocess.mjs: Runs allowlisted test commands inside the clean candidate folder, strips sensitive environment tokens, enforces timeouts, and streams output.
- Agent harness and tools (
agent/).runner.mjs: Starts fresh, unattended sessions with the Google Antigravity CLI (agy), monitors token usage, and manages execution budgets.prompt.mjs: Generates reviewer instructions and validates structured JSON findings.mcp-server.mjs: Exposes browser tools to agent sessions.repair.mjs: Runs the automated format repair loop.
- Evidence collection (
evidence/).collector.mjs: Stores test logs, command outputs, diffs, and agent transcripts outside the candidate folder. Verifies integrity by comparing saved files to recorded SHA256 checksums.
- Gate evaluation and receipts (
gate/).evaluator.mjs: Executes the decision engine across exit codes, index concurrency, snapshot immutability, agent defect severities, and release criteria.receipt.mjs: Signs and verifies cryptographic proof receipts.
- Acceptance manifest and reporter (
manifest/andreporter/).acceptance-manifest.json: Single source of truth tracking all 28 criteria.writer.mjs: Formats and outputsgate-result.jsonand human-readablesummary.md.
4. Acceptance manifest
The manifest at tooling/qa/manifest/acceptance-manifest.json tracks all 28 accepted criteria:
| Acceptance ID | Area | Spec | Summary |
|---|---|---|---|
ACCESS-01 | access | 03 | Approved employee sign-in succeeds; unapproved sessions rejected. |
ACCESS-02 | access | 03 | Employee data isolation holds. |
IMPORT-01 | import | 04 | CSV, XLSX, Sheets, and paste import preview cleanly. |
IMPORT-02 | import | 04 | Duplicate rows and leading zeros survive the pipeline. |
RETAILER-01 | lookup | 06 | Any retailer name accepted as run input. |
LOCATION-01 | lookup | 06 | Specific address wins over general university name. |
LOCATION-02 | input | 05 | Ambiguous campus names flagged for employee review. |
LOCATION-03 | lookup | 06 | Outlets filtered accurately to eliminate distribution centers. |
LOCATION-04 | lookup | 06 | Measures driving routes rather than straight lines across rivers. |
LOCATION-05 | lookup | 06 | Shortest valid driving distance selected. |
MODEL-01 | input | 05 | Neutralize prompt injections embedded in raw rows. |
RUN-01 | lookup | 06 | Durable batch processing in original order. |
RUN-02 | lookup | 06 | Queue delivery reconciliation without duplicate rows. |
RUN-03 | recovery | 07 | Revision fencing stops older retries from overwriting fixes. |
RUN-04 | recovery | 07 | Respect retry budgets when external providers fail. |
RUN-05 | recovery | 07 | Cancellation state settles background workers safely. |
REPORT-01 | reports | 08 | Summary math matches the independent calculation oracle. |
REPORT-02 | reports | 08 | Filtering and sorting operations preserve underlying rows. |
REPORT-03 | reports | 08 | Refresh expired provider cache data only through approved paths. |
OUTPUT-01 | export | 10 | File export preserves row order, columns, and units. |
OUTPUT-02 | export | 11 | Google Sheets writes reconcile idempotently. |
OUTPUT-03 | export | 10 | Neutralize spreadsheet formula injections. |
EXPERIENCE-01 | UI | 03 | Clear loading, empty, review, and error states. |
EXPERIENCE-02 | a11y | 03 | Accessible keyboard navigation, labels, and focus rings. |
OPERATIONS-01 | ops | 06 | Queue admission limits hold under heavy batch load. |
OPERATIONS-02 | ops | 12 | Deployment and rollback rehearsal with zero data loss. |
ADMIN-01 | admin | 13 | Only explicit administrators can access the admin dashboard. |
ADMIN-02 | admin | 13 | Request and token usage attributed accurately to runs. |
5. Maintenance procedures
When adding new product code under src/:
- Implement feature and unit tests. Write business logic and corresponding unit or integration tests under
tests/. - Handle build tripwires. If adding the first file to
src/app/, updatepackage.jsonto include"build"and"test:app"inpnpm check. - Update manifest status. When a feature is completed, flip its status in
acceptance-manifest.jsonfromunimplementedtoimplementedand add test file paths. - Update execution plan resolver. Map newly added feature paths to their corresponding agent tasks in
tooling/qa/policy/resolver.mjs. - Verify locally. Stage changes with
git addand runpnpm qato confirm the gate passes.
6. Troubleshooting and failure recovery
Quick diagnostic table
| Exit code | Status | Meaning | First action |
|---|---|---|---|
0 | Pass | All checks and agent tasks passed. | Proceed with commit or merge. |
1 | Fail | A test failed, linting broke, or the QA agent found a critical defect. | Inspect test logs or agent findings in summary.md. |
2 | Blocked | Environmental issue, concurrency conflict, timeout, or missing release criteria. | Check whether the index changed, tools are missing, or release criteria are incomplete. |
Where to find evidence on disk
Every QA run saves its full context under .qa-reports/runs/<runId>/:
.qa-reports/runs/qa-run-1773729900000-a1b2c3d4/
├── gate-result.json # Full JSON payload with timings, hashes, and findings
├── summary.md # Readable Markdown summary of the gate decision
├── receipt.json # Signed token (present only on passing runs)
└── evidence/
├── ev-qa-run-1-check-output.txt # Captured stdout and stderr from tests
├── ev-qa-run-2-candidate-staged.diff # The exact git diff tested
└── ev-qa-run-3-agent-session-transcript.txt # Full conversation log with the QA agent
Common failure scenarios
- No staged changes: The pre-commit runner tests the Git staging index. Stage candidate files with
git addbefore runningpnpm qa. - Auto-run is OFF notice: The hook prints a notice pointing to
pnpm qabecauseswitch.jsonhasautoRun: "off". Runpnpm qamanually to assess staged changes, or change"autoRun": "on". - Formatting failures: Run
pnpm qa --repairto automatically fix Prettier formatting on staged files. - Concurrent index modification: Avoid modifying Git staging or running
git addwhilepnpm qais executing. - Missing Antigravity CLI: Verify that
agyis installed and accessible in yourPATH. - Agent critical or major findings: Open
.qa-reports/runs/<runId>/summary.md, review expected versus actual behavior, fix the defect insrc/, stage, and re-run. - Release gate blocked:
pnpm qa:releasepurposefully blocks until all 28 acceptance criteria inacceptance-manifest.jsonare implemented.