Skip to content

[ci] Add parallel fixture Lean checker and MIR preflight linter - #758

Draft
joshlf wants to merge 1 commit into
mainfrom
joshlf/ci-mir-preflight-and-fixture-lean
Draft

joshlf wants to merge 1 commit into
mainfrom
joshlf/ci-mir-preflight-and-fixture-lean

Conversation

@joshlf

@joshlf joshlf commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Add two standalone, zero-TCB developer and pre-review checks under ci/ so downstream proof regressions and recurring MIR/rustc defects fail fast before full Cargo/CI runs:

  • ci/check_fixtures_lean.py + ci/test_check_fixtures_lean.py: discovers downstream Proof.lean (and named companion *Proof.lean) fixtures under tests/cargo-anneal/tests/fixtures/, reuses a provided --prebuilt-dir or invokes ci/prebuild_bundled_oleans.py, stages Captured.lean (+ shards), Spec.lean, Expected.lean, and proof modules, and elaborates every fixture DAG in parallel across --jobs N under pinned Lean 4.35 (-DwarningAsError=true -DElab.async=false -Ddebug.skipKernelTC=false). Supports optional --capture-cache-dir and --no-capture for fast Lean-only retries.
  • ci/mir_preflight_checks.py + ci/test_mir_preflight_checks.py: fast (<30s) pre-review linter checking newly added CoreCallOp variants for ci/stdlib_intrinsics.toml classification, dead/gated Lean arms, and ci/guard_mutation/*.toml coverage; CLI-rejected --exclude-trait=core::ops::Drop or reasonless "unsupported" assertions in added Rust negative tests; RUSTC-WORKAROUND(#NNNN) anchors near added LocalExpnId::fresh calls; the 5 fast lockstep scripts; and Option-C non-test trusted/ LOC and trusted/audit/ awareness warnings.
  • ci/pr_preflight.py: update stale docstring repo slug example from google/zerocopy to google/anneal.

No existing workflow, build, or trusted files are modified.

Authored by an AI agent acting on joshlf's behalf.

Add two standalone, zero-TCB developer and pre-review checks under
`ci/` so downstream proof regressions and recurring MIR/rustc defects
fail fast before full Cargo/CI runs:

- `ci/check_fixtures_lean.py` + `ci/test_check_fixtures_lean.py`:
  discovers downstream `Proof.lean` (and named companion `*Proof.lean`)
  fixtures under `tests/cargo-anneal/tests/fixtures/`, reuses a
  provided `--prebuilt-dir` or invokes `ci/prebuild_bundled_oleans.py`,
  stages `Captured.lean` (+ shards), `Spec.lean`, `Expected.lean`, and
  proof modules, and elaborates every fixture DAG in parallel across
  `--jobs N` under pinned Lean 4.35 (`-DwarningAsError=true
  -DElab.async=false -Ddebug.skipKernelTC=false`). Supports optional
  `--capture-cache-dir` and `--no-capture` for fast Lean-only retries.
- `ci/mir_preflight_checks.py` + `ci/test_mir_preflight_checks.py`:
  fast (<30s) pre-review linter checking newly added `CoreCallOp`
  variants for `ci/stdlib_intrinsics.toml` classification, dead/gated
  Lean arms, and `ci/guard_mutation/*.toml` coverage; CLI-rejected
  `--exclude-trait=core::ops::Drop` or reasonless `"unsupported"`
  assertions in added Rust negative tests; `RUSTC-WORKAROUND(#NNNN)`
  anchors near added `LocalExpnId::fresh` calls; the 5 fast lockstep
  scripts; and Option-C non-test `trusted/` LOC and `trusted/audit/`
  awareness warnings.
- `ci/pr_preflight.py`: update stale docstring repo slug example from
  `google/zerocopy` to `google/anneal`.

No existing workflow, build, or trusted files are modified.

Agent-authored-by: AI agent acting on joshlf's behalf
@joshlf

joshlf commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

🤖 Review Receipt

  • Target base: 8b73d98158e8fe0863777855ca01f4c4721d0364
  • Merge base: 65b5d332dff8180c774115256f33e5edd9d2fa85
  • HEAD: 9517ffcc9a4018fcc99fd022d01c6fe6767484cd
  • Tree: a124cef423f1baecd050494372125fd8166518c6
  • Diff size: 5 files changed, 1 commit (9517ffcc9)

Human review surface

  • CI scripts and tests (5 files): ci/check_fixtures_lean.py,
    ci/mir_preflight_checks.py, ci/pr_preflight.py (docstring repo slug
    update only), ci/test_check_fixtures_lean.py, and
    ci/test_mir_preflight_checks.py.
  • Zero edits to trusted/, correspondence/, theory/, .github/,
    ci/checks.toml, or ci/run_anneal_check.sh. No policy relaxations (none).

Verification Summary

  • Deterministic preflight and repo checks (HEAD 9517ffcc9):
    • python3 -I -B ci/check_pr_hygiene.py --repo . --base origin/main --head HEAD --expected-author "Josh Liebow-Feeser <joshlf@google.com>" — PASS.
    • python3 -I -B ci/pr_preflight.py --repo . --base origin/main --head HEAD — PASS (files=5, lines=4392, overlaps=0).
    • python3 -I -B ci/mir_preflight_checks.py --repo . --base origin/main --head HEAD — PASS (errors=0, warnings=0, trusted_nontest_added_loc=0/1500, lockstep=5/5).
    • ./ci/check_todo.sh, ./ci/check_non_stable_version.sh, ./ci/check_actions.sh, ./ci/check_job_dependencies.sh, and python3 -I -B ci/run_fast_checks.py (3/3) — PASS.
  • CI Python unit tests (292 tests across 13 modules, HEAD 9517ffcc9):
    • test_check_fixtures_lean.py (8), test_mir_preflight_checks.py (13),
      test_pr_preflight.py (11), test_ci_workflow.py (27),
      test_fast_checks.py (9), test_check_pr_hygiene.py (141),
      test_gen_stdlib_intrinsics.py (15), test_check_taxonomy_lockstep.py
      (4), test_generate_semantics_profile_card.py (4),
      test_audit_rustc_workarounds.py (20), test_run_py_tests.py (13),
      test_anneal_ci_lib.py (13), test_workflow_yaml.py (14) — all PASS.
  • Live fixture Lean check on remote x86_64 Linux builder (-j 21, HEAD 9517ffcc9):
    • Cold run (--cache-dir, pinned Lean 4.35 + anneal-rustc-capture):
      29/29 local fixtures PASS (3 external profile_v2_zerocopy /
      starnix fixtures cleanly SKIP due to absent external source dirs),
      prebuild=208.42s, wall=253.83s (45.41s capture + Lean).
    • Warm cached --no-capture run (--capture and --sysroot omitted):
      29/29 local fixtures PASS with [cap-hit], prebuild=5.17s,
      wall=49.96s (0 failed, 3 external skipped).
  • Independent Gate-1 review (HEAD 9517ffcc9): 0 P0, 0 P1, 0 P2
    findings (verdict: "clean").

Authored by an AI agent acting on joshlf's behalf.

@joshlf joshlf left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Authored by an AI agent acting on joshlf's behalf.

Gate 2 Independent Cross-Family Review — FINDINGS (tier2b_cli_policy, Round 1)

  • Identity: multi:8b73d98158e8fe0863777855ca01f4c4721d0364:9517ffcc9a4018fcc99fd022d01c6fe6767484cd (base=8b73d98158e8, head=9517ffcc9a40, tree=a124cef423f1)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 5 inspected, 0 inapplicable, 0 blocked (of 5 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking policy_and_cli_critic completed findings 2 562s
seat2 gemini-frontier-thinking policy_and_spec_critic completed findings 2 766s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 483s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R1-01 P1 2 (seat1, seat2) probe_confirmed ci/mir_preflight_checks.py:1388 The 'pre-Gate-1/Gate-2' linter runs the target head's own ci/*.py lockstep scripts, extracted via git archive, outside any sandbox and with the full inherited environment whenever --head differs from the checked-out commit. Nothing in the docstring or help discloses this.
G2-R1-02 P2 1 (seat2) probe_confirmed ci/check_fixtures_lean.py:1140 --prebuilt-dir accepts any directory containing manifest.json and lib/ without verifying bundled source or Lean toolchain digests, allowing stale .olean files to silently shadow local trusted/lean/ and theory/ edits.
G2-R1-03 P2 1 (seat1) static_verified ci/test_check_fixtures_lean.py:30 The commit/PR body describes the change as 'standalone, zero-TCB' checks. Under base rules, ci/.py is a declared TCB executable and human-review surface, and both new ci/test_.py modules are automatically executed by the required anneal-ci-tests check, so the PR adds code to required CI.

G2-R1-01 [P1] (ci/mir_preflight_checks.py:1388, Pass 2 §5 (ci & workflows), probe_confirmed): The 'pre-Gate-1/Gate-2' linter runs the target head's own ci/*.py lockstep scripts, extracted via git archive, outside any sandbox and with the full inherited environment whenever --head differs from the checked-out commit. Nothing in the docstring or help discloses this.

  • Invariant: AGENTS.md Standing rules / Code Review Rules (Execution, isolation, and probes): reviewers and coordinators must run untrusted reviewed-candidate, worker, or third-party code only inside an OS-level sandbox without credentials. Sibling ci/pr_preflight.py (whose helpers this module imports) documents that it never checks out or executes candidate code.
  • Evidence: At ci/mir_preflight_checks.py:1393-1468, check_lockstep_suite exports head_sha to scan_dir via git archive (or uses repo_dir) and builds all 5 subprocess commands from scan_dir / 'ci/<script>.py' (lines 1404, 1420, 1434, 1450, 1463), then executes them at line 1490 with env = dict(os.environ) (line 1472) without stripping ACTIONS_CACHE_URL, ACTIONS_RESULTS_URL, ACTIONS_RUNTIME_TOKEN, or OIDC tokens. Contrast with ci/pr_preflight.py:806-808, which invokes Path(file).resolve().parent / 'check_pr_hygiene.py'. Running the trusted base copy of mir_preflight_checks.py --head <untrusted_candidate> executes arbitrary unreviewed Python from <untrusted_candidate> outside any sandbox with full ambient credentials and lets a candidate PR bypass all 5 lockstep checks by modifying those scripts to exit 0. All 5 base lockstep scripts already take --repo-root/--root/--repo as pure data arguments (verified on base), so invoking _CI_DIR / '<script>.py' against scan_dir with strip_actions_env(os.environ, include_oidc=True) avoids executing candidate code entirely (tests can inject a ci_dir override).

G2-R1-02 [P2] (ci/check_fixtures_lean.py:1140, Pass 2 §5 (ci & workflows), probe_confirmed): --prebuilt-dir accepts any directory containing manifest.json and lib/ without verifying bundled source or Lean toolchain digests, allowing stale .olean files to silently shadow local trusted/lean/ and theory/ edits.

  • Invariant: Pass 2 §5 (AGENTS.md / trust-review): caches in ci/ scripts must not shadow source changes; reused bundled .olean directories must match current trusted/lean/ and theory/ source hashes and pinned Lean toolchain identity (as enforced by ci/prebuild_bundled_oleans.py --cache-dir).
  • Evidence: At ci/check_fixtures_lean.py:1140-1150, when prebuilt_dir is provided, run_fixtures checks only (pb_dir / 'manifest.json').is_file() and (pb_dir / 'lib').is_dir() (and omits symlink checks), then adds pb_dir / 'lib' directly to LEAN_PATH at line 999 without parsing manifest.json or verifying lean_sha256, sysroot_manifest_sha256, or bundled Trusted./Anneal. source_sha256 entries against repo_root. ci/test_check_fixtures_lean.py:173 confirms this by passing with an empty '{}' manifest.json. If a developer or CI step modifies trusted/lean/ or theory/ in a way that breaks downstream proofs and passes an earlier --prebuilt-dir, Lean elaborates against stale .olean artifacts and reports false-positive PASS.

G2-R1-03 [P2] (ci/test_check_fixtures_lean.py:30, Pass 2 §5 (ci & workflows), static_verified): The commit/PR body describes the change as 'standalone, zero-TCB' checks. Under base rules, ci/.py is a declared TCB executable and human-review surface, and both new ci/test_.py modules are automatically executed by the required anneal-ci-tests check, so the PR adds code to required CI.

  • Invariant: AGENTS.md Code Review Rules (Human review surface): relevant commit bodies must explain what changed and why, and any omission or mischaracterization of a changed surface blocks merge or ready-for-review. ci/ is listed in the Human review surface and triggers Pass 2.
  • Evidence: Commit 9517ffc body: 'Add two standalone, zero-TCB developer and pre-review checks under ci/'. Base ci/checks.toml [tcb] extra_executable_paths = ["ci/.py", ...] makes ci/.py TCB executables for ci-core. Base ci/run_anneal_check.sh ci-tests mode runs "$PY_BIN" -I -B -m unittest discover -s ci -p 'test_*.py' -v under ANNEAL_CI_STRICT=1, and checks.toml id=anneal-ci-tests (gated by ci-core / gate) runs it. TestCheckFixturesLean (L30) and TestMirPreflightChecks (test_mir_preflight_checks.py L116), including the live-repo test_discover_fixtures_on_live_repo, therefore become part of required CI. The body should disclose this and drop the 'zero-TCB' label.

Non-blocking advisories (P3, not Gate 2 findings)

These notes do not block merge and do not require another Gate 2 round.

  • G2-R1-A01 [P3] (ci/check_fixtures_lean.py:23): The tool reports PASS / 'verify cleanly' after only Lean-compiling the module DAG. It never checks that the proof declares Proof.verify : Expected.claim and never runs anneal-audit or an axiom check, so an axiom or a theorem-less Proof.lean reports PASS.
  • G2-R1-A02 [P3] (ci/check_fixtures_lean.py:148): _FIXTURE_OVERRIDES copies per-fixture compile metadata from tests/cargo-anneal/tests/*.rs and ci/verify_starnix_e2e.py with no lockstep check, so future drift silently desyncs the checker. --allow-unpinned-lean (L1082) also emits no user-visible warning in the human output.
  • G2-R1-A03 [P3] (ci/check_fixtures_lean.py:548): Under --no-capture without an explicit --capture/--sysroot, cache entries from any capture-tool build are accepted. --prebuilt-dir is accepted if manifest.json and lib/ merely exist. Both allow stale captures or .oleans to produce misleading PASS/FAIL.
  • G2-R1-A04 [P3] (ci/check_fixtures_lean.py:1082): Lean version pinning check uses unanchored substring containment (pinned_tag not in lean_ver), which would accept prerelease or longer version strings containing 4.35.0.
  • G2-R1-A05 [P3] (ci/mir_preflight_checks.py:29): The warnings assert an 'Option-C auto-merge' policy (1,500 non-test trusted/ LOC cap, trusted/audit excluded) that no governing doc in the repo defines.
  • G2-R1-A06 [P3] (ci/mir_preflight_checks.py:520): extract_lean_match_arms rejects qualified CoreCallOp. patterns due to (?<![A-Za-z0-9]). (unlike _ctor_has_guard_mutation at line 700), and TEST_ATTR_RE at line 103 is unused.
  • G2-R1-A07 [P3] (ci/test_check_fixtures_lean.py:432): test_run_fixtures_prebuilt_cache_and_failures is not hermetic. It fails when ANNEAL_ZEROCOPY_ROOT points at a zerocopy checkout or /opt/zerocopy-dogfood/zerocopy exists (anneal-tc/anneal-rust images, dev shells). The anneal-lean-lite CI image is unaffected.

Executed Sandbox Probes

  • seat3 bwrap_unit_test_check_fixtures_lean: Ran python3 -I -B /work/ci/test_check_fixtures_lean.py -v in unshared bwrap: 8/8 tests passed in 3.801s. (rc=0)
  • seat3 bwrap_unit_test_mir_preflight_checks: Ran python3 -I -B /work/ci/test_mir_preflight_checks.py -v in unshared bwrap: 13/13 tests passed in 7.934s. (rc=0)
  • seat3 bwrap_unit_test_pr_preflight: Ran python3 -I -B /work/ci/test_pr_preflight.py -v in unshared bwrap: 11/11 tests passed in 15.889s. (rc=0)
  • seat3 bwrap_discover_fixtures_live_repo: Verified check_fixtures_lean.discover_fixtures on candidate tree: 32 fixtures discovered, 0 missing proof/spec/helper/local-source files. (rc=0)
  • seat3 bwrap_core_call_op_real_repo_parse: Verified mir_preflight_checks Lean/Rust parsers on real candidate Terminators.lean, terminators.rs, MirSemantics/*.lean, CallsTermV2.lean: 65/65 variants parsed (rc=0)
  • seat3 bwrap_run_mir_preflight_lockstep_live: Ran run_mir_preflight(..., skip_lockstep_suite=False) on a sandboxed git repo initialized from candidate tree: rc=0, all 5 lockstep scripts passed, 0 errors/war (rc=0)
  • seat3 bwrap_cli_entrypoints_fail_closed: Verified --help and fail-closed JSON rc=2 exits for check_fixtures_lean.py (--no-capture missing Lean) and mir_preflight_checks.py (--repo /nonexistent). (rc=0)
  • seat3 bwrap_unittest_discover_all_ci: Full unittest discover -s /work/ci -p 'test_*.py' timed out at 30s inside unrelated redteam/alpha_release suites (unrelated LiveToolIntegrationTests skipped due (rc=124)
  • seat3 seat1-probe-1-test-hermeticity: outcome=confirmed
  • seat3 seat1-probe-2-mir-preflight-head-exec: outcome=confirmed

status_res = _run_git(repo_dir, ["status", "--porcelain=v1", "-z"])
dirty_tree = status_res.returncode == 0 and bool(status_res.stdout)

need_export = (not working_tree) and (

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G2-R1-01 [P1] (probe_confirmed): The 'pre-Gate-1/Gate-2' linter runs the target head's own ci/*.py lockstep scripts, extracted via git archive, outside any sandbox and with the full inherited environment whenever --head differs from the checked-out commit. Nothing in the docstring or help discloses this.

At ci/mir_preflight_checks.py:1393-1468, check_lockstep_suite exports head_sha to scan_dir via git archive (or uses repo_dir) and builds all 5 subprocess commands from scan_dir / 'ci/<script>.py' (lines 1404, 1420, 1434, 1450, 1463), then executes them at line 1490 with env = dict(os.environ) (line 1472) without stripping ACTIONS_CACHE_URL, ACTIONS_RESULTS_URL, ACTIONS_RUNTIME_TOKEN, or OIDC tokens. Contrast with ci/pr_preflight.py:806-808, which invokes Path(file).resolve().parent / 'check_pr_hygiene.py'. Running the trusted base copy of mir_preflight_checks.py --head <untrusted_candidate> executes arbitrary unreviewed Python from <untrusted_candidate> outside any sandbox with full ambient credentials and lets a candidate PR bypass all 5 lockstep checks by modifying those scripts to exit 0. All 5 base lockstep scripts already take --repo-root/--root/--repo as pure data arguments (verified on base), so invoking _CI_DIR / '<script>.py' against scan_dir with strip_actions_env(os.environ, include_oidc=True) avoids executing candidate code entirely (tests can inject a ci_dir override).

Comment thread ci/check_fixtures_lean.py

with tempfile.TemporaryDirectory(prefix="anneal-fixtures-prebuilt-") as td:
t_pre = time.monotonic()
if prebuilt_dir is not None:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G2-R1-02 [P2] (probe_confirmed): --prebuilt-dir accepts any directory containing manifest.json and lib/ without verifying bundled source or Lean toolchain digests, allowing stale .olean files to silently shadow local trusted/lean/ and theory/ edits.

At ci/check_fixtures_lean.py:1140-1150, when prebuilt_dir is provided, run_fixtures checks only (pb_dir / 'manifest.json').is_file() and (pb_dir / 'lib').is_dir() (and omits symlink checks), then adds pb_dir / 'lib' directly to LEAN_PATH at line 999 without parsing manifest.json or verifying lean_sha256, sysroot_manifest_sha256, or bundled Trusted./Anneal. source_sha256 entries against repo_root. ci/test_check_fixtures_lean.py:173 confirms this by passing with an empty '{}' manifest.json. If a developer or CI step modifies trusted/lean/ or theory/ in a way that breaks downstream proofs and passes an earlier --prebuilt-dir, Lean elaborates against stale .olean artifacts and reports false-positive PASS.

import check_fixtures_lean as cfl # noqa: E402


class TestCheckFixturesLean(unittest.TestCase):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G2-R1-03 [P2] (static_verified): The commit/PR body describes the change as 'standalone, zero-TCB' checks. Under base rules, ci/.py is a declared TCB executable and human-review surface, and both new ci/test_.py modules are automatically executed by the required anneal-ci-tests check, so the PR adds code to required CI.

Commit 9517ffc body: 'Add two standalone, zero-TCB developer and pre-review checks under ci/'. Base ci/checks.toml [tcb] extra_executable_paths = ["ci/.py", ...] makes ci/.py TCB executables for ci-core. Base ci/run_anneal_check.sh ci-tests mode runs "$PY_BIN" -I -B -m unittest discover -s ci -p 'test_*.py' -v under ANNEAL_CI_STRICT=1, and checks.toml id=anneal-ci-tests (gated by ci-core / gate) runs it. TestCheckFixturesLean (L30) and TestMirPreflightChecks (test_mir_preflight_checks.py L116), including the live-repo test_discover_fixtures_on_live_repo, therefore become part of required CI. The body should disclose this and drop the 'zero-TCB' label.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant