This is a concise, fully automated QA framework for compiler codebases. It is designed for AI coding agents, not humans. Human review is optional and used only for policy overrides.
Applies to:
- New changes (features, refactors, fixes).
- Historical code (legacy modules, regressions, untested paths).
- Evidence or reject: If required checks are missing, the change is blocked.
- Fail closed: Unknown risk defaults to highest risk.
- Self-correcting: The agent must repair failures and re-run.
- No silent behavior change: All behavior changes must be declared and tested.
- Classify risk:
low | medium | high - Select gates based on impacted compiler work and artefacts.
- Run gates via the unified entrypoint:
scripts/qa_local.sh --risk <risk> - Collect evidence under
qa/evidence/and finalize the decision.
Notes:
scripts/qa_local.shis the primary local gate runner. It orchestrates work-appropriate checks and is the default path for both CI and local verification.- Evidence is mandatory: if an applicable gate is missing or evidence is missing, the change is blocked.
Use these scripts as the canonical entrypoints for QA gates:
scripts/qa_local.sh --risk <low|medium|high>— Primary local/CI gate runner. Always use this for formal validation.scripts/verify_semantics_matrix.sh— Semantic contract gate (IR snapshots + hash guard). Called byqa_local.shat medium+.scripts/verify_prod.sh— High-risk supplemental checks (risk inventory + rust-ui + jit e2e). This is not a full release gate by itself.
Production releases must satisfy all of the following:
scripts/qa_local.sh --risk highpasses.- Evidence record exists under
qa/evidence/for the release change set. - Semantic matrix gate evidence (
qa/ir_snapshots/+qa/ir_snapshots/ir_hashes.json) is captured and referenced.
scripts/verify_prod.sh is a subset of high-risk checks; it does not replace qa_local.sh --risk high.
| Risk | Required Gates |
|---|---|
| Low | Build + lint + unit tests |
| Medium | Low + integration + compiler-work gates |
| High | Medium + runtime fixtures + bootstrap + perf |
If risk is unknown, treat as High. Evidence must reflect the chosen risk level and its required gates.
Select only the gates that match the change:
- Parsing/AST: parser tests, AST artefacts, round-trip tests.
- Typing: inference tests, negative cases, ambiguity checks.
- Requests/comptime:
CompileTimeNeed,RequestId, generated AST, and parity vs runtime where constructs overlap. - Lowering (typed AST -> HIR -> MIR -> LIR): IR artefacts, structural invariants, dependency invalidation.
- Diagnostics: UI/artefact tests for messages, spans, request ids, and codes.
- Codegen/Backend: IR/ASM artefacts, executable fixtures.
- Optimization: pass unit tests, semantic equivalence checks.
- Bootstrap: self-host build if supported.
- Performance: compile‑time and runtime benchmarks for hot paths.
If a gate is applicable but missing, the agent must add tests or block.
Changes that can affect observable semantics must run the semantic matrix gate:
scripts/verify_semantics_matrix.sh- Runs
scripts/snapshot_ir.shto generate IR snapshots fromtests/fixtures/semantic. - Enforces
qa/ir_snapshots/ir_hashes.jsonviascripts/ir_hash_guard.py.
- Runs
UPDATE_IR_HASHES=1 is only allowed when the semantic change is declared:
- The semantic matrix entry must be updated with a rationale and expected delta.
- The baseline suite mapping must be updated (or explicitly marked as new coverage).
- The evidence record must include the change justification and updated artifacts.
If the change is not intentional or not declared, UPDATE_IR_HASHES must remain unset and the gate must fail.
Each change produces a single evidence record. Use the template and generator:
- Template:
qa/evidence/template.md - Generator:
scripts/qa_evidence.sh
The evidence file must align with the selected risk level and the gates actually executed by scripts/qa_local.sh.
For any semantic or lowering change (including IR-affecting refactors), attach:
qa/ir_snapshots/(generated byscripts/snapshot_ir.sh).qa/ir_snapshots/ir_hashes.json(baseline hash file enforced byscripts/ir_hash_guard.py).- Any delta summary produced by
scripts/verify_semantics_matrix.sh(stdout/stderr logs).
Each change produces a single file:
qa/evidence/<change-id>.yaml
change_id: <unique id>
intent: <short description>
risk: <low|medium|high>
work: [parser, typing, lowering, ...]
invariants: [ ... ]
expected_behavior: [ ... ]
checks:
build: pass
lint: pass
unit: pass
integration: pass
compiler_work_gates: pass
runtime_fixtures: pass
bootstrap: pass
perf: pass
artifacts:
logs: [ ... ]
reports: [ ... ]
Missing fields or failed checks are hard failures.
- Reject broad refactors unless explicitly requested.
- Reject any new
unwrap/panic on user-controlled inputs. - Require stable IR/diagnostic snapshots unless the change declares deltas.
- Require regression tests for all fixed bugs.
When the agent is asked to review code quality or historical code, it performs a deterministic one-by-one read of each relevant source file (in repo order), not just pattern matching. Each file gets a short, explicit reasoning note from the source file, not individual lines.
- Enumerate files in a stable order (lexicographic), excluding
target/,.git/, and anytests/paths unless explicitly requested. - Read the entire file top to bottom; do not stop at the first match.
- Summarize file intent from module docs, public APIs, and main types.
- Identify concerns with explicit reasoning:
- Correctness gaps (incomplete lowering, missing invariants, undefined behavior).
- Confusing semantics (implicit fallbacks, silent behavior changes).
- Reliability risks (panic/unwrap in user paths, unsafe without invariants).
- Each finding must include why it is a problem in this file, not just a label.
- Record findings with:
- File path and key lines.
- Why it is risky/confusing (explicit reasoning tied to actual code flow).
- Suggested remediation class (diagnostic, refactor, test, or guard).
File: <path>
Intent: <short statement>
Findings:
- <issue> — <reasoning> — <remediation>
Notes:
- <any follow-ups>
The agent must keep a cumulative report and never skip files unless told to.
When touching legacy areas:
- Add a baseline gate first (snapshot or fixture) to lock current behavior.
- Then change code and re-run gates.
- Any change must be explicitly declared in the evidence file.
This prevents accidental regressions while enabling safe modernization.
- CI pipeline runs all selected gates.
- Agent loop:
- Run gates.
- Fix failures.
- Re-run until pass or block.
- Evidence stored under
qa/evidence/.
This framework is intentionally strict: the agent must prove correctness.