Skip to content

[anneal][audit] Add dual-kernel NDJSON comparator and SpecPreflight - #4147

Queued
joshlf wants to merge 1 commit into
mainfrom
joshlf-anneal-ndjson-comparator
Queued

joshlf wants to merge 1 commit into
mainfrom
joshlf-anneal-ndjson-comparator

Conversation

@joshlf

@joshlf joshlf commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Verify target theorems on Lean v4.35.0+ (when --allow-unpinned-lean is enabled and <sysroot>/bin/ provides leanexport, nanoda_bin, and con-ron) without any Lean process producing the verdict and without loading Proof .olean files outside the sandboxed exporter. cargo-anneal routes those runs through the pure-Rust Universal NDJSON Comparator (trusted/cargo-anneal/src/ndjson_comparator.rs) backed by dual independent kernels (nanoda_bin and con-ron), plus optional 4-kernel --paranoid-quorum (con-leche, lean4lean --import). Pinned admission sets ndjson_tools: None until v4.35.0+ comparator tool digests are pinned, so the repository's pinned Lean v4.34.1 toolchain keeps using TrustedBoundary.lean for every mode.

The comparator route runs these actions:

  • 5-init: clean-sysroot export of the 39 kernel-accelerated and elaborator Init primitives, the 3 standard axioms, and the admitted System.Platform declarations.
  • target-consts: SpecPreflight validates the compiled Model, Capture, Specification, and Expected .oleans with the same pre-import header, companion, and isModule checks as the legacy "target-audit", imports them with the admitted sysroot (never a Proof .olean; loadExts := false), and reports each module's exact constant inventory from its ModuleData. Compiler-generated constants (anonymous and deriving instances, constructors and projections, where/let rec auxiliaries) are thus attributed to their defining module instead of being reconstructed from source syntax. Lean's import keeps the later of two equal-header theorems under the earlier module's index, so each target constant must equal the stored constant, and a constant another loaded module also declares is rejected unless it is a realized equation-style theorem equal to the owner's. It also rejects any unsafe target constant and reports the targets' @[implemented_by], @[extern], and @[csimp] subjects.
  • 5b: sandboxed export of proof_full.ndjson.
  • 5a: export from the trusted modules alone of the expected declaration, every Specification constant (except the partial _unsafe_rec auxiliaries Lean pairs with well-founded definitions), and every target-module constant proof_full contains. --ignore-missing is no longer passed, so an absent root or dependency aborts the export.
  • 5-pin: clean-sysroot re-export, with zero target .oleans mounted, of every sysroot-named constant either export contains.
  • 5c: the pure-Rust checks, then the kernels.

5c requires every export to declare each constant's dependencies before the constant (other than the names-only mutual-block peers leanexport records for definitions, and references within one inductive record), so a missing, forward, or cyclic reference fails closed. Each inductive record must be one consistent mutual block whose types, constructors, and recursors agree on its membership. It requires each sysroot-named constant to equal its clean 5-init/5-pin definition, so sysroot status is never granted by name alone; a proof module that redeclares a sysroot name (or a kernel-accelerated one) with different content is rejected. Each target-module constant in proof_full must appear identically in the trusted export, and each trusted-export constant must have a sysroot or target-module origin. Proof-origin constants may not use the Trusted root, a reserved kernel root, or a kernel-accelerated name (generated equation and splitter helpers of a pinned parent excepted); this replaces the name-prefix check that let a registered Trusted model module admit any Trusted.* constant. Compiled declaration edges between target modules must satisfy TargetRole::allows, and sysroot constants in either export may not reference target constants. Canonical inputs must come from their designated roles, the canonical root must be CrateTheorem or UnitTheorem applied to Crate.mk or a Profile v2 counterpart applied to CrateV2.mk, the target theorem must be proof-origin, no reached target declaration may carry a compiler override, and the direct and transitive specification bans apply to every module-indexed Specification constant. .opaqueInfo is admitted only for non-unsafe, content-pinned sysroot constants such as System.Platform.getNumBits. The comparator also interns names structurally, rejects duplicate NDJSON keys, and requires export metadata to match the admitted toolchain's exact version and commit. Kernels re-hash their private copy of proof_full.ndjson against the digest the comparator verified, and every kernel's stderr is checked for Lean panic markers. con-ron and con-leche run in --verified mode with a capped --jobs; by default each starts a worker per hardware thread and exhausts address-space limits on many-core hosts. A test feeds every kernel, in its configured invocation, an export whose target theorem is ill-typed but structurally intact, and requires each to reject it while accepting the well-typed original; that test needs a v4.35.0 install, so a CI test also runs the comparator route with stub kernels and requires it to fail closed when either kernel exits nonzero or panics. The process-wide caches of the clean sysroot export and the sysroot constant index are keyed by the pinned manifest digest or, unpinned, by every admitted sysroot module's artifact digests.

SpecPreflight.lean duplicates TrustedBoundary.lean's header and specification admission guards (including module-mode specifications) and its pre-import .olean validation; ci/test_check_guard_mutation.py requires every shared definition, and preflightSpecs apart from its header check, to stay identical, and tests/audit/tests/target_audit.rs exercises "sysroot-consts", "target-consts", and (through a test hook that routes it to SpecPreflight) "spec-preflight" on the pinned toolchain. In both files the specification namespace guard keeps the isForbiddenPureNamespace checks (_root_ stripping and the Init.System/Internal.UV/Dynlib sub-scopes) and additionally reserves Trusted, Anneal, Proof, and every reservedKernelRoots root, including Init and Std.

As in TrustedBoundary.lean's "target-audit", the comparator verdict carries the admitted module import graph, which verify needs to check bundled-model trust tiers, and its subject, model, and specification closures list only reached declarations, each with its defining module, so candidate:* features come only from reached Model modules. Receipts record sysrootPinsSha256 and the comparator and kernel binary digests. cargo anneal inspect validates those digests, the fixed timingMs schema, and the kernel and quorum invariants the comparator enforces, reads skipped kernels recorded as {kernel, reason}, does not require checkedAlternateProofs from the comparator route, and ranks a change from the comparator to the default audit as a regression. The comparator route does not run the anti-vacuity specification lint, and it does not inspect compiler-override attributes on Proof declarations (their .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction). Its receipts therefore omit spec_warnings and list both under deferred. stage.rs, sandbox.rs, and verify.rs reserve SpecPreflight, copy NDJSON sinks read-only into ExecSeal inputs, and precompile and cache SpecPreflight.olean (ci/prebuild_bundled_oleans.py, flake.nix, ci/run_anneal_check.sh, ci/check_bundle_tree.py, trusted/root-manifest.sha256). The anneal-guard-mutation ci-core check takes SpecPreflight.lean as an input, and the anneal-tc image seeds it for the flake evaluation.

Part of #4016
Part of #4109

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

@joshlf joshlf added the anneal Primary scope: Anneal verification stack (`anneal/` and `exocrate/`) label Nov 23, 2026
@joshlf

joshlf commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Human review surface

  • anneal/trusted/audit/SpecPreflight.lean (1,184 lines vs 5,444 in TrustedBoundary.lean): minimal parser-only preflight (Lean.Elab.Import, Lean.Parser.Tactic) scoped strictly to "headers", "spec-preflight", and "resolve-imports" (trustLevel := 0, plugins := #[], loadExts := false), loading zero target .olean files.
  • anneal/trusted/audit/TrustedBoundary.lean: documentation framing only ("target-export" / "target-audit" retained strictly as transitional Lean v4.34.1 support).
  • anneal/trusted/cargo-anneal/src/ndjson_comparator.rs (3,018 lines, #[forbid(unsafe_code)]): pure-Rust NDJSON structural comparator (5a/5b/5c), NdjsonAuditVerdict schema, axiom allowlist (STANDARD_PERMITTED_AXIOMS), init_primitives checking, and multi-kernel invocation (nanoda_bin, con-ron, and optional 4-kernel --paranoid-quorum with con-leche and lean4lean --import).
  • anneal/trusted/cargo-anneal/src/{sandbox.rs,stage.rs,target.rs,toolchain.rs,verify.rs,bundle.rs,bundled_resources.rs,lib.rs}:
    • Preserves #4128 (invoke_inspector_typed, invoke_inspector_direct_text, "target-export"/"target-audit" Proof .olean isolation) and #4130 (resolve_static_toolchain, pinned ExecSeal probes, linux::run_bwrap seccomp_read_fd + --disable-userns, RESERVED_TOOLCHAIN_MODULE_ROOTS extended with "SpecPreflight").
    • Bounded 0o600 + libc::O_NOFOLLOW drain_to_bounded_file stdout sinks and sha256_file_deref re-checks before and after NDJSON kernel execution.
  • anneal/ci/alpha_release.py and anneal/trusted/cargo-anneal/tests/ndjson_comparator_e2e.rs (438 lines): release bundle registration for SpecPreflight.lean and Linux Tier-1 ActiveSandbox::LinuxBwrap + Lean v4.35.0 e2e tests.
  • Intentional policy relaxations: none.

Gate-1 Trust Review (5711804469)

  • Verdict: 0 P0 / 0 P1 (23 diff files inspected across 74d509c852..HEAD: 0 symlinks, 0 bidi/invisible Unicode codepoints, check_todo clean, valid Fuchsia 2026 headers, 0 external/internal leaks, clean git merge-tree against 44be835771 on main).
  • TCB impact: On Lean v4.35.0+, runtime Lean execution drops from TrustedBoundary.lean (5,444 lines) to parser-only SpecPreflight.lean (1,184 lines; -4,260 lines / -78.3%) while eliminating in-process target .olean deserialization during target theorem verification.

Verification Receipt ([real measurement], executed on commit 5711804469)

  • sha256sum --check --strict anneal/trusted/root-manifest.sha256: 4/4 OK
  • cargo run --locked -p cargo-anneal --example regenerate_bundle -- --root . --check: OK
  • ./ci/check_todo.sh, ./anneal/ci/check_todo.sh, ./anneal/ci/check_job_dependencies.sh, ./anneal/ci/check_non_stable_version.sh (0.2.0-alpha.7), python3 -I -B ci/check_skills.py: all OK
  • python3 -B -m unittest discover -s anneal/ci -p "test_*.py": 97 passed; 0 failed
  • cargo +stable clippy --locked -p cargo-anneal -p anneal-audit --all-targets -- -A clippy::type_complexity -D warnings: OK
  • cargo +stable clippy --locked --no-deps -p cargo-anneal --no-default-features --lib --bins --test cli -- -A clippy::type_complexity -D warnings: OK
  • cargo test --locked -p cargo-anneal --lib --bin cargo-anneal --test cli: 99 passed (--lib), 53 passed (--bin), 20 passed (--test cli); 0 failed
  • cargo test --locked -p cargo-anneal --no-default-features --lib --bin cargo-anneal --test cli: 99 passed (--lib), 27 passed (--bin), 16 passed (--test cli); 0 failed
  • cargo test --locked -p cargo-anneal --test sandbox_escape -- --test-threads=1: 7 passed; 0 failed (50.40s)
  • cargo test --locked -p cargo-anneal --test ndjson_comparator_e2e -- --test-threads=1 --nocapture (debug): 3 passed; 0 failed (299.25s, LinuxBwrap Tier-1 containment + Lean v4.35.0 preflight/module reservation)
    • scalar dual-kernel (nanoda_bin + con-ron): full 51,353 ms, comparator 5a+5b+5c 5,678 ms (initPrimitives=1092, exportExpected=557, exportProof=706, nanoda=277, conRon=1071, rustCompare=1972)
    • scalar --paranoid-quorum (4 kernels): full 45,836 ms, comparator 5a+5b+5c 8,150 ms (exportExpected=598, exportProof=901, nanoda=187, conRon=831, paranoidQuorum=3747, rustCompare=1885)
  • cargo test --locked --release -p cargo-anneal --test ndjson_comparator_e2e -- --test-threads=1 --nocapture (release): 3 passed; 0 failed (285.84s)
    • scalar dual-kernel (nanoda_bin + con-ron): full 32,139 ms, comparator 5a+5b+5c 2,347 ms (initPrimitives=744, exportExpected=392, exportProof=391, nanoda=89, conRon=548, rustCompare=179)
    • scalar --paranoid-quorum (4 kernels): full 31,285 ms, comparator 5a+5b+5c 3,626 ms (exportExpected=599, exportProof=444, nanoda=87, conRon=445, paranoidQuorum=1849, rustCompare=200)
  • cargo test --locked -p anneal-audit --lib --test boundary_audit --test target_audit: 6 passed (--lib), 53 passed (boundary_audit, 525.25s), 32 passed (target_audit, 170.27s); 0 failed

Coordination Notes

  • Clean git merge-tree against main (44be835771).
  • Note in-flight PR #4145 (prebuild static .olean cache) modifies overlapping files stage.rs, toolchain.rs, verify.rs, and lib.rs, and PR #4139 introduces .olean.server/.olean.private module artifacts on Pass-1/theory .olean outputs (export_ndjson_expected may need to follow PARTS companions if #4139 lands before this PR).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-23T05:30:43.821900Z
We couldn’t complete this review. Comment @codex review to try again.
5711804 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 5711804 to e8c9b27 Compare November 23, 2026 10:14
@joshlf

joshlf commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Human review surface

  • anneal/trusted/audit/SpecPreflight.lean (1,184 lines vs 6,023 in TrustedBoundary.lean): minimal parser-only preflight (Lean.Elab.Import, Lean.Parser.Tactic) scoped strictly to "headers", "spec-preflight", and "resolve-imports" (trustLevel := 0, plugins := #[], loadExts := false), loading zero target .olean files.
  • anneal/trusted/audit/TrustedBoundary.lean: documentation framing only ("target-export" / "target-audit" retained strictly as transitional Lean v4.34.1 support).
  • anneal/trusted/cargo-anneal/src/ndjson_comparator.rs (3,119 lines, #[forbid(unsafe_code)]): pure-Rust NDJSON structural comparator (5a/5b/5c), NdjsonAuditVerdict schema, LegacyTargetAuditVerdict + LegacySpecWarning (preserving #4151 specWarnings validation), axiom allowlist (STANDARD_PERMITTED_AXIOMS), init_primitives checking, and multi-kernel invocation (nanoda_bin, con-ron, and optional 4-kernel --paranoid-quorum with con-leche and lean4lean --import).
  • anneal/trusted/cargo-anneal/src/{sandbox.rs,stage.rs,target.rs,toolchain.rs,verify.rs,bundle.rs,bundled_resources.rs,lib.rs}:
    • Preserves #4128 (invoke_inspector_typed, invoke_inspector_direct_text, "target-export"/"target-audit" Proof .olean isolation), #4130 (resolve_static_toolchain, pinned ExecSeal probes, linux::run_bwrap seccomp_read_fd + --disable-userns, RESERVED_TOOLCHAIN_MODULE_ROOTS extended with "SpecPreflight"), #4145 (OleanCache keying on actual module stem SpecPreflight vs TrustedBoundary and passing stem to materialize_cached_inspector_olean), #4158 (runtime_libs_verified preservation), and #4161 (fail-closed olean_cache error probing).
    • Bounded 0o600 + libc::O_NOFOLLOW drain_to_bounded_file stdout sinks and sha256_file_deref re-checks before and after NDJSON kernel execution.
  • anneal/ci/{alpha_release.py,check_bundle_tree.py,prebuild_bundled_oleans.py,test_prebuild_bundled_oleans.py}, anneal/flake.nix, .github/workflows/anneal-current.yml, anneal/trusted/root-manifest.sha256, and anneal/trusted/cargo-anneal/tests/ndjson_comparator_e2e.rs (438 lines): integrates SpecPreflight.lean and prebuilt/SpecPreflight.olean into the omnibus prebuild pipeline (preserving #4157 isModule parity) and exercises Linux Tier-1 ActiveSandbox::LinuxBwrap + Lean v4.35.0 e2e tests.
  • Intentional policy relaxations: none.

Rebase & Gate-1 Security Invariant Check (e8c9b27a98 on origin/main 6f262351a9)

  • 19 changed files, 0 symlinks, 0 bidi/invisible Unicode codepoints, clean git diff --check, valid Fuchsia headers, check_todo clean on root and anneal/, 0 non-public leaks, clean git merge-tree --write-tree against current origin/main (e8dcb7f08e).
  • TCB impact: On Lean v4.35.0+, runtime Lean execution drops from TrustedBoundary.lean (6,023 lines) to parser-only SpecPreflight.lean (1,184 lines) while eliminating in-process target .olean deserialization during target theorem verification.

Verification Receipt (Commit e8c9b27a98)

  • Static, Manifest & Python CI:
    • sha256sum --check --strict trusted/root-manifest.sha256: 4/4 OK
    • cargo +stable run --locked -p cargo-anneal --example regenerate_bundle -- --root . --check: OK
    • ./ci/check_todo.sh (root and anneal/), python3 -I -B ci/check_skills.py, ./ci/check_job_dependencies.sh, ./ci/check_non_stable_version.sh (0.2.0-alpha.9): all OK
    • python3 -B -m unittest discover -s ci -p 'test_*.py': 134 passed; 0 failed (95.474s)
  • Clippy (-A clippy::type_complexity -D warnings):
    • cargo +stable clippy --locked -p cargo-anneal -p anneal-audit --all-targets: OK
    • cargo +stable clippy --locked --no-deps -p cargo-anneal --no-default-features --lib --bins --test cli: OK
  • Audit & Sandbox Suites:
    • cargo +stable test --locked -p anneal-audit --lib: 9/9 passed (0.29s)
    • cargo +stable test --locked -p anneal-audit --test cli_environment: 4/4 passed (0.01s)
    • cargo +stable test --locked -p anneal-audit --test target_audit -- --test-threads=6: 33/33 passed (494.31s)
    • cargo +stable test --locked -p anneal-audit --test boundary_audit -- --test-threads=6: 53/53 passed (1037.18s)
    • cargo +stable test --locked -p cargo-anneal --test sandbox_escape -- --test-threads=1: 7/7 passed (53.42s)
  • cargo-anneal Bin, CLI & NDJSON Unit + E2E Suites (LinuxBwrap Tier-1 containment + Lean v4.35.0):
    • cargo +stable test --locked -p cargo-anneal --lib ndjson_comparator -- --test-threads=1: 12/12 passed (0.02s)
    • cargo +stable test --locked -p cargo-anneal --no-default-features --lib ndjson_comparator -- --test-threads=1: 12/12 passed (0.03s)
    • cargo +stable test --locked -p cargo-anneal --bin cargo-anneal --test cli (default): 55/55 (--bin, 22.09s), 20/20 (--test cli, 0.29s)
    • cargo +stable test --locked -p cargo-anneal --no-default-features --bin cargo-anneal --test cli: 29/29 (--bin, 23.71s), 16/16 (--test cli, 0.26s)
    • cargo +stable test --locked -p cargo-anneal --test ndjson_comparator_e2e -- --test-threads=1 --nocapture (debug): 3/3 passed (165.85s)
      • scalar dual-kernel (nanoda_bin + con-ron): full 14,886 ms, comparator 5a+5b+5c 4,057 ms (initPrimitives=585, exportExpected=606, exportProof=559, conRon=616, nanoda=155, rustCompare=1533)
      • scalar --paranoid-quorum (4 kernels): full 15,986 ms, comparator 5a+5b+5c 6,257 ms (exportExpected=518, exportProof=524, conRon=556, nanoda=129, paranoidQuorum=3229, rustCompare=1299)
    • cargo +stable test --locked --release -p cargo-anneal --test ndjson_comparator_e2e -- --test-threads=1 --nocapture (release): 3/3 passed (54.64s)
      • scalar dual-kernel (nanoda_bin + con-ron): full 4,929 ms, comparator 5a+5b+5c 2,037 ms (initPrimitives=491, exportExpected=392, exportProof=422, conRon=445, nanoda=88, rustCompare=197)
      • scalar --paranoid-quorum (4 kernels): full 6,226 ms, comparator 5a+5b+5c 3,261 ms (exportExpected=420, exportProof=445, conRon=446, nanoda=90, paranoidQuorum=1680, rustCompare=177)
  • Pre-0.2.0-alpha.9-bump full cargo-anneal --lib and mvp_e2e anti_vacuity on af6ada136d (0 non-version/manifest diff vs e8c9b27a98):
    • cargo +stable test --locked -p cargo-anneal --lib -- --test-threads=1: 109/109 passed (725.01s)
    • cargo +stable test --locked -p cargo-anneal --no-default-features --lib -- --test-threads=1: 109/109 passed (684.76s)
    • cargo +stable test --locked -p cargo-anneal --test mvp_e2e anti_vacuity -- --test-threads=1: 2/2 passed (300.04s)

Coordination Notes

  • If #4154 (moving trusted/cargo-anneal/tests/ to tests/cargo-anneal/tests/ and fixtures/scalar to assets/scalar) lands ahead of #4147, relocate ndjson_comparator_e2e.rs into anneal/tests/cargo-anneal/tests/ and update its include_str! paths to ../../../trusted/cargo-anneal/assets/scalar/{Spec,Proof}.lean (similarly coordinate with #4139 module artifacts and #4176 in stage.rs/target.rs if those land first).

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.99%. Comparing base (706acd8) to head (b6fc48c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4147   +/-   ##
=======================================
  Coverage   92.99%   92.99%           
=======================================
  Files          16       16           
  Lines        2469     2469           
=======================================
  Hits         2296     2296           
  Misses        173      173           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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 (tier2_tcb, Round 1)

  • Identity: multi:e8dcb7f08edbc19485c9e7980333607ebbff5f48:e8c9b27a98875d2c32051beba99e3193abbb7560 (base=e8dcb7f08edb, head=e8c9b27a9887, tree=f66c02b46015)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 19 inspected, 0 inapplicable, 0 blocked (of 19 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 12 1946s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 9 1089s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 4 920s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R1-01 P0 2 (seat1, seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:433 Security-relevant name lookups go through a dot-joined string map that later names overwrite, so distinct Lean names that render identically are conflated and an untrusted export can redirect the lookups.
G2-R1-02 P0 2 (seat1, seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2345 The comparator admits the three permitted axioms by name only and never pins their statements to the clean sysroot, so an untrusted proof export can redeclare Classical.choice or Quot.sound with an arbitrary type.
G2-R1-03 P1 3 (seat1, seat2, seat3) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2194 The specification-constant scan attributes declarations to Specification modules by dotted-name prefix and checks only direct dependencies, so it is weaker than the legacy check it claims to mirror.
G2-R1-04 P1 2 (seat2, seat3) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2480 build_closure_entries drops all Init/Std sysroot modules (and non-namespaced or _private.* declarations), stripping sysroot moduleIdentities from Receipt v3 and making target.rs's post-run unpinned sysroot TOCTOU verification unreachable dead code.
G2-R1-05 P1 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/toolchain.rs:312 discover_ndjson_comparator_tools activates unpinned leanexport/nanoda_bin/con-ron binaries even in pinned (!allow_unpinned_lean) mode without SHA-256 lock verification, and Receipt v3 omits all comparator/kernel binary digests from toolchain_identity and assumptions.
G2-R1-06 P2 2 (seat1, seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:740 NDJSON records with repeated JSON keys are silently accepted with last-value-wins semantics and export metadata is never cross-checked, leaving a parser-differential question against the external kernels.
G2-R1-07 P2 2 (seat1, seat2) static_verified anneal/trusted/cargo-anneal/src/stage.rs:2974 SpecPreflight routing is not gated on the toolchain, so on the pinned v4.34.1 toolchain headers, spec-preflight, and resolve-imports now run through SpecPreflight.lean, contrary to the commit message, in-tree docs, and Review Receipt.
G2-R1-08 P2 1 (seat1) static_verified anneal/trusted/audit/SpecPreflight.lean:270 SpecPreflight.lean duplicates TrustedBoundary.lean's header and specification admission guards without guard-mutation catalog entries, new negative tests, or a lockstep check, so the guards cargo-anneal verify now runs are no longer protected by the mutation gate.
G2-R1-09 P2 1 (seat3) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2154 is_forbidden_expected_const fails to strip _private.<mod>.<idx> prefixes, letting _private.<SpecOrCapture>.0.{Anneal,Proof}.* bypass expected-cone isolation.
G2-R1-10 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/stage.rs:1847 Pinned-mode toolchain admission adopts leanexport, nanoda_bin, and con-ron from the sysroot bin directory as verdict-producing kernels with no locked digest, taint, warning, or receipt binding.
G2-R1-11 P2 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/stage.rs:3602 run_sandboxed_leanexport misclassifies clean-sysroot 5-init failures as policy proof_failed (exit 1), and stage.rs hardlinks writable 0o600 proof_full.ndjson into runs//in/.
G2-R1-12 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/verify.rs:223 The change ships a default verdict path, a new --paranoid-quorum flag, and new report fields without updating any documentation, leaving several docs stale or contradicted by the code.
G2-R1-13 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/tests/ndjson_comparator_e2e.rs:218 All three end-to-end tests return early and pass when no Lean v4.35.0 toolchain is discoverable, so in CI the new default verdict path and its adversarial cases execute zero assertions.
G2-R1-14 P3 3 (seat1, seat2, seat3) static_verified anneal/trusted/audit/SpecPreflight.lean:88 Doc comments copied into SpecPreflight.lean describe inspector modes the file does not implement, and load-bearing upstream claims in the comparator lack pinned citations.
G2-R1-15 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1651 The new legacy verdict validator duplicates checks the legacy audit already performs and the comparator verdict validator checks constants it was just handed, adding trusted code whose doc comments misstate what it does.
G2-R1-16 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2324 The comparator rejects every opaque declaration including Init opaques that spec-preflight explicitly admits, so specifications reaching System.Platform.numBits verify on the legacy path but cannot verify on the comparator path.

G2-R1-01 [P0] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:433, Pass 2 §3 (trusted/cargo-anneal), static_verified): Security-relevant name lookups go through a dot-joined string map that later names overwrite, so distinct Lean names that render identically are conflated and an untrusted export can redirect the lookups.

  • Invariant: Canonical name identity must be injective; allowlist, theorem, and primitive lookups must resolve to the exact structural Lean name regardless of what an untrusted stream interns.
  • Evidence: intern_name inserts every newly interned structural name into string_to_name under its dot-joined rendering, overwriting earlier entries (ndjson_comparator.rs:419-434); parse_record accepts any string component (1013-1017) or numeric component (1018-1022). A single-component name whose string is 'Classical.choice' renders identically to the two-component Classical.choice, and a numeric component 0 renders identically to the string component '0'. intern_dotted_name returns the map hit first (439-442), and the untrusted proof stream is parsed last (target.rs:1357-1358), so lookups for the axiom allowlist (2272-2275), theorem (2224), Quot.sound (2063), and the 39 primitives (1963-1965) resolve to whichever colliding name was interned last. Concretely, an export containing the single-component name gets an axiom of arbitrary type under that name admitted and reported as Classical.choice (2344-2358) while the genuine axiom would be rejected; lookups against init_primitives and expected_cone fail closed. The unit test at 2969-2992 already builds a private name with string component '0' where Lean emits a numeric component. End-to-end impact depends on how the external kernels match permitted axiom names, which was not verifiable here.

G2-R1-02 [P0] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2345, Pass 2 §3 (trusted/cargo-anneal), static_verified): The comparator admits the three permitted axioms by name only and never pins their statements to the clean sysroot, so an untrusted proof export can redeclare Classical.choice or Quot.sound with an arbitrary type.

  • Invariant: Action 5c must enforce a strict 3-axiom ceiling against a hostile proof_full stream; the legacy path binds each permitted axiom to its defining Init module and forbids target declarations under the Classical and Quot roots.
  • Evidence: Trigger: a hostile proof_full.ndjson (the stream this module is specified to distrust) contains an axiom record named Classical.choice or Quot.sound whose type is, for example, False. Mechanism: PINNED_INIT_PRIMITIVES (ndjson_comparator.rs:90-130) omits the three axioms and step 1 (1963-1971) never requires them in init_primitives; step 3 (2000-2020) compares only names present in expected_cone; step 4 (2027-2040) pins only names present in init_primitives; step 7 (2272-2275, 2344-2356) admits any axiom whose name id is in the allowlist; build_nanoda_config_json (2526-2544) likewise passes names only. Read-only probe on the pinned Lean 4.34.1 sysroot: '#print axioms' over all 39 pinned primitives reports only propext (via Nat.land, Nat.lor, Nat.xor), so the 'leanexport Init -- <39 names>' cone (stage.rs:3648-3650) contains neither Classical.choice nor Quot.sound, and trusted/lean has no textual reference to either. Legacy binding: toolchain.rs:46-50 (FOUNDATION_AXIOMS name-to-module pairs), TrustedBoundary.lean:5749-5752 (axiom policy check), TrustedBoundary.lean:2282-2289 (reservedKernelRoots includes Classical and Quot). No unit test forges an axiom type. Remaining uncertainty: whether 'con-ron --verified' independently pins axiom statements, and whether the v4.35.0 cone differs from 4.34.1. Resolving check: add the three axioms to the pinned init targets, require their presence and DAG identity, and add a negative unit test with a forged axiom type.

G2-R1-03 [P1] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2194, Pass 2 §3 (trusted/cargo-anneal), static_verified): The specification-constant scan attributes declarations to Specification modules by dotted-name prefix and checks only direct dependencies, so it is weaker than the legacy check it claims to mirror.

  • Invariant: Checks described as mirroring the legacy specification constant ban should cover the same declarations: those defined by Specification modules, including the transitive ban.
  • Evidence: At ndjson_comparator.rs:2193-2220, is_spec_const checks arena.belongs_to_module(cid, m) (string prefix match on <SpecModule>.* or _private.<SpecModule>.<idx>.*). SpecPreflight.lean permits Spec.lean to declare constants outside namespace Spec (e.g. top-level def helper or namespace Helper), for which belongs_to_module returns false, bypassing the direct Lean.Syntax*/panic* ban. Additionally, verify_ndjson_structure completely omits TrustedBoundary.lean's isForbiddenSpecTransitiveConst traversal (allowing Spec.lean to call an admitted Init/Std helper that transitively reaches IO, dbgTrace, System.Platform.isWindows, or Lean.version), stage.rs:660-664 exports only Expected.claim's cone rather than all Specification declarations, and no check forbids Spec.lean from declaring constants in Trusted.* or Init./Std..

G2-R1-04 [P1] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2480, Pass 2 §3 (trusted/cargo-anneal), static_verified): build_closure_entries drops all Init/Std sysroot modules (and non-namespaced or _private.* declarations), stripping sysroot moduleIdentities from Receipt v3 and making target.rs's post-run unpinned sysroot TOCTOU verification unreachable dead code.

  • Invariant: PRINCIPLES.md / THREAT_MODEL.md §1 TCB audit log completeness and target.rs:1160-1220 post-audit sysroot provenance and TOCTOU invariant.
  • Evidence: Because leanexport NDJSON records omit module origins, ndjson_comparator.rs:2194 and build_closure_entries (:2480-2519) match constants solely by string name prefix against model_modules (["Trusted.MirSemantics", ...]) and specification_modules. SpecPreflight.lean:360 and :823 permit namespace Trusted in Specification files, and verify_ndjson_structure omits both non-Model Trusted.* ownership checks and reservedKernelRoots checks outside the 39 PINNED_INIT_PRIMITIVES. Consequently, def Trusted.MirSemantics.Custom inside Spec.lean passes preflight and Action 5c while appearing inside modelClosure instead of specificationClosure, helpers in custom namespaces (namespace Helper) are missed by :2194 and :2495, and Proof modules can declare arbitrary Trusted.*/Std.*/Lean.*/System.* constants.

G2-R1-05 [P1] (anneal/trusted/cargo-anneal/src/toolchain.rs:312, Pass 2 §3 (trusted/cargo-anneal), static_verified): discover_ndjson_comparator_tools activates unpinned leanexport/nanoda_bin/con-ron binaries even in pinned (!allow_unpinned_lean) mode without SHA-256 lock verification, and Receipt v3 omits all comparator/kernel binary digests from toolchain_identity and assumptions.

  • Invariant: PRINCIPLES.md / THREAT_MODEL.md §1 and trust-review Pass 2 §3: pinned untainted runs must never silently execute unpinned toolchain verdict binaries, and Receipt v3 must accurately record every trusted tool's digest and assumption.
  • Evidence: stage.rs:1847 calls discover_ndjson_comparator_tools(&prefix)? unconditionally during pinned tool_admission(), and target.rs:1117 switches auditing to audit_target_ndjson whenever ndjson_tools.is_some(). toolchain.rs:312-378 checks only .is_file() and computes runtime hashes for pre/post TOCTOU without verifying any pinned SHA-256 lock. Thus placing leanexport, nanoda_bin, and con-ron in a pinned sysroot's bin/ silently replaces TrustedBoundary.lean with unpinned binaries while issuing an untainted Receipt v3. Furthermore, even under --allow-unpinned-lean, target.rs:1426-1460 and verify.rs:1912-1977 never emit leanexport_sha256, nanoda_bin_sha256, con_ron_sha256, con_leche_sha256, or lean4lean_sha256 into NdjsonAuditVerdict, toolchain_identity, or assumptions.

G2-R1-06 [P2] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:740, Pass 2 §3 (trusted/cargo-anneal), static_verified): NDJSON records with repeated JSON keys are silently accepted with last-value-wins semantics and export metadata is never cross-checked, leaving a parser-differential question against the external kernels.

  • Invariant: The comparator and the independent kernels must interpret each exported record identically; ambiguous encodings should be rejected.
  • Evidence: Each line is parsed with serde_json::from_str into a generic Value (ndjson_comparator.rs:740); map deserialization keeps the last value for a repeated key, and the key-count checks (998, 1035, 1128, 1262) run after that collapse, so a declaration object with two 'type' members is accepted using the last one. If a kernel resolves duplicates differently, the comparator and that kernel check different declarations. ExportMeta fields are parsed (839-845) but never compared across the three streams or with the admitted toolchain. Open question: duplicate-key behavior of nanoda_bin and con-ron is not verifiable here. Resolving check: reject duplicate keys during parsing and add a negative test.

G2-R1-07 [P2] (anneal/trusted/cargo-anneal/src/stage.rs:2974, Pass 1 (Human review surface accuracy) / Pass 2 §3, static_verified): SpecPreflight routing is not gated on the toolchain, so on the pinned v4.34.1 toolchain headers, spec-preflight, and resolve-imports now run through SpecPreflight.lean, contrary to the commit message, in-tree docs, and Review Receipt.

  • Invariant: Commit bodies, trusted/ documentation, and the Human review surface must accurately describe what changed; mischaracterization of a trusted surface blocks ready-for-review.
  • Evidence: uses_spec_preflight returns true for the three modes whenever SpecPreflight.lean was staged (stage.rs:2974-2977), and tool_admission stages it whenever the bundled file exists (stage.rs:1497-1521; bundle.rs:39) with no version or ndjson_tools condition. TrustedBoundary.lean's copies of those modes therefore become unreachable from cargo-anneal verify on every toolchain. This contradicts the commit message ('Target preflight on v4.35.0+ drops to SpecPreflight.lean'), the new TrustedBoundary.lean header (17-39: v4.35.0+ runtime verification does not execute this file; legacy v4.34.1 cargo-anneal verify invokes it across ten modes), SpecPreflight.lean:15-19, and target.rs:1111-1116. The Review Receipt's Human review surface additionally describes SpecPreflight's three modes with 'loadExts := false', but spec-preflight imports with extensions := true and enableInitializersExecution (SpecPreflight.lean:110-117, 1109-1113). Functional behavior is equivalent today because the copied code is identical.

G2-R1-08 [P2] (anneal/trusted/audit/SpecPreflight.lean:270, Pass 2 §3 (trusted/audit) and §5 (ci guard mutation), static_verified): SpecPreflight.lean duplicates TrustedBoundary.lean's header and specification admission guards without guard-mutation catalog entries, new negative tests, or a lockstep check, so the guards cargo-anneal verify now runs are no longer protected by the mutation gate.

  • Invariant: Every added or modified admission or syntax guard needs negative tests verified to fail when the guard is disabled; cataloged header guards must be live and exercised by guard-mutation CI.
  • Evidence: validateTargetImports (SpecPreflight.lean:270-283), inspectHeader (289-302), and 50 of the file's 55 declarations are byte-identical copies of TrustedBoundary.lean declarations (mechanical declaration-level comparison); after the routing change they are the guards executed at run time. ci/check_guard_mutation.py:1031-1058 (AUDIT_HEADER_GUARDS) still mutates trusted/audit/TrustedBoundary.lean and runs TrustedBoundary in 'headers' mode (1232-1255), so disabling the Lean or Lake import ban in SpecPreflight.lean survives the 100% kill-rate gate. The change adds no catalog entry, no file under trusted/audit/tests, and no check that keeps the two copies identical, so a future fix applied to one copy can silently diverge.

G2-R1-09 [P2] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2154, Pass 2 §3 (trusted/cargo-anneal statement-origin isolation), static_verified): is_forbidden_expected_const fails to strip _private.<mod>.<idx> prefixes, letting _private.<SpecOrCapture>.0.{Anneal,Proof}.* bypass expected-cone isolation.

  • Invariant: Statement-origin isolation requires that no declaration in Anneal.* or Proof.* (public or private) appears in expected_cone, matching TrustedBoundary.privateToUserName semantics.
  • Evidence: ndjson_comparator.rs:2154-2162 checks req.forbidden_expected_roots.contains(arena.name_root(cid)) ({"Anneal", "Proof"}) and arena.belongs_to_module(cid, m) over forbidden_expected_modules (TargetRole::Proof modules only), without stripping _private.<mod>.<idx>. via arena.strip_private_and_root(cid) (ndjson_comparator.rs:457-495, already used at line 2201). Because SpecPreflight.lean:360 and :823 do not forbid Anneal or Proof namespaces in TargetRole::Specification modules, private def Anneal.foo in Spec.lean compiles as _private.Spec.0.Anneal.foo (name_root == "_private"), passing verify_ndjson_structure. Unit test ndjson_comparator.rs:2967-2991 only checks _private.Proof.0.Proof.helper, which hits forbidden_expected_modules.

G2-R1-10 [P2] (anneal/trusted/cargo-anneal/src/stage.rs:1847, Pass 2 §3 and §4 (trusted/cargo-anneal, toolchain provenance), static_verified): Pinned-mode toolchain admission adopts leanexport, nanoda_bin, and con-ron from the sysroot bin directory as verdict-producing kernels with no locked digest, taint, warning, or receipt binding.

  • Invariant: cargo-anneal must not let ambient state silently substitute unverified toolchain components; in pinned mode, executed and loaded sysroot code is digest-verified, and the comparator design specifies a digest-locked init primitive cone.
  • Evidence: Pinned tool_admission calls discover_ndjson_comparator_tools (stage.rs:1847; the same struct sets unpinned: false), which only records self-computed SHA-256 digests (toolchain.rs:312-378); run_target switches the verdict path on presence alone (target.rs:1117). No LOCKED_* constant, taint reason, or warning covers these executables; NdjsonAuditVerdict (ndjson_comparator.rs:1601-1626) records no kernel-binary digests; the init cone is regenerated at run time by the same unlocked leanexport (stage.rs:3622-3656) although docs/auditing-and-comparator.md:119-120 specifies a cone locked by digest in the toolchain manifest. Pinned sysroot verification allowlists runtime libraries and rejects dynamic libraries in bin/ but accepts extra executables (toolchain.rs:1805-1828), and default lean discovery follows ambient XDG_CACHE_HOME and HOME (toolchain.rs:896-900). Trigger: three executables with those names beside a digest-matching lean binary. Result: an untainted pinned result whose verdict was produced by unlocked, unrecorded binaries. Exploitation requires control of the toolchain directory or environment, which THREAT_MODEL.md assumes away, so this is rated as a trust-policy regression rather than a break of the stated threat model.

G2-R1-11 [P2] (anneal/trusted/cargo-anneal/src/stage.rs:3602, Pass 2 §3 (trusted/cargo-anneal), static_verified): run_sandboxed_leanexport misclassifies clean-sysroot 5-init failures as policy proof_failed (exit 1), and stage.rs hardlinks writable 0o600 proof_full.ndjson into runs//in/.

  • Invariant: docs/elaborator-containment-design.md §3.2 (in/ receives 0o444 physical copies, never hardlinks) and §4 (exit 1 is reserved for policy/proof failures while toolchain/sysroot failures must return exit 2 tool_failed).
  • Evidence: At stage.rs:3602-3612, run_sandboxed_leanexport returns Failure::policy (exit code 1) on any non-zero leanexport exit, including when called from export_ndjson_init_primitives (line 3650) over only the clean sysroot Init module (and verify.rs:2285 treats err.code == 1 as proof_failed, triggering partial --export-lean-lib export). Separately, sandbox.rs:1972 creates NDJSON stdout sinks with mode 0o600, and stage.rs:3760 and 3857 hardlink proof_full.ndjson directly into in_dir rather than copying as 0o444 (and stage.rs:3687 hardlinks stage/lib/*.olean into expected_lib). In addition, init_primitives_cache (stage.rs:60-75, 3622-3645) keys only on (prefix, leanexport_sha256) without the sysroot manifest digest.

G2-R1-12 [P2] (anneal/trusted/cargo-anneal/src/verify.rs:223, General (documentation review), static_verified): The change ships a default verdict path, a new --paranoid-quorum flag, and new report fields without updating any documentation, leaving several docs stale or contradicted by the code.

  • Invariant: Standing documentation rule: affected docs, examples, and links must be added or updated in the same PR; undisclosed deviations from documented contracts must be stated.
  • Evidence: No documentation path is in the diff. docs/auditing-and-comparator.md:11-28 still labels the comparator an unshipped target architecture, and the code deviates from its contract without updating it: the init cone is not digest-locked (119-120 versus stage.rs:3622-3656); con-ron and con-leche are skipped when sorryAx is admitted (151-155 'Both checkers must exit 0' versus target.rs:1396-1406 and 1421-1425); every opaque is banned rather than non-Init opaque (143-144); paranoid mode runs two extra kernels directly rather than the described multi-kernel comparator set (165-175). docs/elaborator-containment-design.md:105 still attributes header and specification admission to TrustedBoundary.lean, docs/alpha.md:138-154 omits --paranoid-quorum, and the Review Receipt lists intentional policy relaxations as none.

G2-R1-13 [P2] (anneal/trusted/cargo-anneal/tests/ndjson_comparator_e2e.rs:218, Pass 2 §3 (test sensitivity) / General, static_verified): All three end-to-end tests return early and pass when no Lean v4.35.0 toolchain is discoverable, so in CI the new default verdict path and its adversarial cases execute zero assertions.

  • Invariant: Negative security tests must fail if their target guard is disabled; new trust-critical paths need non-vacuous executed coverage.
  • Evidence: Each test begins with 'let Some(lean) = discover_v435_lean() else { eprintln!(...); return; }' (ndjson_comparator_e2e.rs:218-221, 296-299, 378-381); discover_v435_lean (47-62) consults only the ANNEAL_LEAN_V435 variable and a fixed elan toolchain directory under HOME. No workflow, flake input, or CI script provides either, and the repository pin is v4.34.1, so the export, comparator-driver, and kernel-invocation code (stage.rs:3506-4016; target.rs:1279-1484) has no CI-executed integration coverage and these tests would still pass with every comparator guard removed. The unit tests in ndjson_comparator.rs cover only synthetic structural cases.

G2-R1-14 [P3] (anneal/trusted/audit/SpecPreflight.lean:88, Pass 2 §3 (trusted/ comment accuracy), static_verified): Doc comments copied into SpecPreflight.lean describe inspector modes the file does not implement, and load-bearing upstream claims in the comparator lack pinned citations.

  • Invariant: trusted/ comments must give accurate rationale and contracts; upstream behavior relied on for soundness should be cited at a pinned source.
  • Evidence: importEnv's comment documents preflight, audit, and target-audit modes (SpecPreflight.lean:88-109); importCorrEnv's comment documents the correspondence modes although its only caller here is resolve-imports (119-137, 1153-1161); validateGraph (146-147) and initHermeticSearchPath (153-155, bootstrap of the precompiled TrustedBoundary.olean) are likewise stale. In ndjson_comparator.rs the claims about the upstream primitive target lists (82-89), Expr.eqv semantics (186-194), the axiom-collection traversal (38-41), and the export parser's handling of isUnsafe (1340-1341) carry no repository, commit, or line citation, unlike the pinned-commit URLs used in TrustedBoundary.lean, and refer to Lean v4.35.0 sources outside the repository's v4.34.1 pin. Minor: seven comment lines in ndjson_comparator.rs exceed 80 columns.

G2-R1-15 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1651, General (maintainability, comment accuracy), static_verified): The new legacy verdict validator duplicates checks the legacy audit already performs and the comparator verdict validator checks constants it was just handed, adding trusted code whose doc comments misstate what it does.

  • Invariant: trusted/ code should stay minimal and its comments should accurately state rationale and contracts.
  • Evidence: inspect_target already deserializes into the deny_unknown_fields TargetAuditReport and runs validate_target_audit_report (target.rs:388-566, 640-652); run_target then re-parses the re-serialized value into the near-identical LegacyTargetAuditVerdict and repeats the same checks (target.rs:1128-1139; ndjson_comparator.rs:1651-1764), so the comment about replacing untyped map inspection (1646-1648) is inaccurate. validate_ndjson_verdict (1768) is documented as validating a verdict round-tripped through JSON but is called on the struct built immediately above it with replay and exact_type hard-coded to true (target.rs:1437-1478). NdjsonComparatorTools.lake (toolchain.rs:303) is populated but never read.

G2-R1-16 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2324, General (cross-file contract), static_verified): The comparator rejects every opaque declaration including Init opaques that spec-preflight explicitly admits, so specifications reaching System.Platform.numBits verify on the legacy path but cannot verify on the comparator path.

  • Invariant: Admission layers should agree: constructs explicitly allowed by spec-preflight and by the documented non-Init opaque ban should not be unconditionally rejected downstream.
  • Evidence: The scans reject any CanonConstInfo::Opaque with no Init exemption (ndjson_comparator.rs:2282-2291, 2324-2333), while docs/auditing-and-comparator.md:143-144 scopes the ban to non-Init opaque declarations and SpecPreflight.lean:369-373 admits System.Platform numBits, getNumBits, and numBits_eq in specifications. Read-only probe on the pinned 4.34.1 sysroot: '#print System.Platform.getNumBits' prints an opaque declaration. The failure is fail-closed (false rejection), not unsound.

Executed Sandbox Probes

  • seat1 axioms-of-pinned-primitives: outcome=Only propext appears (Nat.land, Nat.lor, Nat.xor); Classical.choice and Quot.sound appear for none of the 39 names; exit 0
  • seat1 getnumbits-is-opaque: outcome=Printed as an opaque declaration; exit 0
  • seat3 test_prebuild_bundled_oleans.py, test_alpha_release.py, test_check_bundle_tree.py in bwrap: outcome=pass
  • seat3 test_ci_workflow.py in bwrap (split run): outcome=partial_timeout
  • seat3 sha256sum --check --strict trusted/root-manifest.sha256 paired probe in bwrap: outcome=pass
  • seat3 check_bundle_tree.py SpecPreflight sensitivity & prebuild missing-SpecPreflight probe in bwrap: outcome=pass
  • seat3 bundled_resources.rs TRUSTED_BUNDLE_SOURCES parity & PR diff TODO check in bwrap: outcome=pass
  • seat3 Lean elaboration & cargo test execution check: outcome=skipped_light_or_env_limit

Comment thread anneal/trusted/audit/SpecPreflight.lean Resolved
@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from e8c9b27 to bdd3341 Compare November 24, 2026 02:38
@joshlf

joshlf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Addressed all 16 Gate-2 Round-1 review findings (G2-R1-01..G2-R1-16), ported the #4176 pure-signature specification bans / check_lean_stderr_panic / 4-tree LibraryLock invariants cleanly onto 5d5e9df80bb04a8e258988d25e215dfedd75ec3b (git merge-tree clean against origin/main e05af9265ec8521e8c187dfde4e1bf5650b9d800), and pushed updated commit bdd33415682feff42fce43b39872f5cd6709c9ed.

Gate-2 Round-1 Finding Dispositions

  • G2-R1-01 [P0] (PRRT_kwDOH9mcF867CuTT) — Fixed: CanonicalArena (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:430) now interns and resolves names strictly structurally via name_ids: HashMap<CanonName, CanonNameId>, encode_canon_name (:564), and intern_encoded_name (:515); name_strings is display-only (removed string_to_name). Covered by ndjson_comparator::tests::rejects_flat_string_name_collision_and_duplicate_json_keys.
  • G2-R1-02 [P0] (PRRT_kwDOH9mcF867CuTc) — Fixed: export_ndjson_init_primitives (stage.rs:3772) now exports STANDARD_PERMITTED_AXIOMS (Classical.choice, Quot.sound, propext) and PINNED_SYSTEM_PLATFORM_DECLS alongside PINNED_INIT_PRIMITIVES. verify_ndjson_structure verifies axiom existence/non-unsafety in Step 1 (:2347-2376) and pins every init_primitives constant to exact canonical DAG identity across expected_cone and proof_full in Step 4 (:2450-2463). Covered by rejects_unpermitted_axiom_and_sorry_unless_explicitly_allowed (case 3: forged Classical.choice with Sort 1 vs sysroot Sort 0).
  • G2-R1-03 [P1] (PRRT_kwDOH9mcF867CuTf) — Fixed: SpecPreflight.lean:1301-1324 emits declaredConsts triples (module, encodedName, displayName); export_ndjson_expected (stage.rs:3917) exports Expected plus all Spec.* roots; verify_ndjson_structure (:2673-2723) runs spec_bfs and is_forbidden_spec_transitive_const (:769, aligned with #4176 Init.System, Std.Internal.UV, Lean.LoadDynlib, lean_dbg_*, includeStr, and non-Platform System.*). Covered by rejects_spec_referencing_panic_core_and_private_proof_helpers, enforces_spec_declared_custom_namespace_and_private_root_isolation, and ndjson_comparator_e2e.
  • G2-R1-04 [P1] (PRRT_kwDOH9mcF867CuTk) — Fixed: SpecPreflight.lean:1329 (collectSysrootConsts) + stage.rs:3817 (collect_sysroot_consts_cached) populate sysroot_const_to_module with zero target .oleans loaded; verify_ndjson_structure enforces Trusted.*, KERNEL_ACCELERATED_NAMES, and RESERVED_KERNEL_ROOTS ownership via user_name_root (:655) and check_namespace_ownership (:2589-2634), and build_closure_entries (:3009) restores sysroot attribution for target.rs:1293-1353 moduleIdentities.
  • G2-R1-05 [P1] (PRRT_kwDOH9mcF867CuTo) & G2-R1-10 [P2] (PRRT_kwDOH9mcF867CuT7) — Fixed: Pinned tool_admission() sets ndjson_tools: None (stage.rs:1972), keeping TrustedBoundary.lean on pinned v4.34.1 until v4.35.0+ comparator tools are digest-locked. Under --allow-unpinned-lean, NdjsonAuditVerdict (:1996), toolchain_identity (verify.rs:1960-1978), and assumptions (verify.rs:2010-2016) bind leanexportSha256, nanodaBinSha256, conRonSha256, and quorum digests.
  • G2-R1-06 [P2] (PRRT_kwDOH9mcF867CuTs) — Fixed: parse_json_no_duplicate_keys (:1115-1195) rejects repeated JSON object keys at any depth; verify_export_meta_matches_toolchain (target.rs:1657) and cross-stream ExportMeta equality checks reject mismatched exporter/Lean headers.
  • G2-R1-07 [P2] (PRRT_kwDOH9mcF867CuTv) — Fixed: uses_spec_preflight (stage.rs:3115) gates on adm.ndjson_tools.is_some(), preserving TrustedBoundary.lean across all modes on pinned v4.34.1; docs and commit/PR text distinguish extensions := true ("spec-preflight") vs extensions := false ("headers"/"resolve-imports"/"sysroot-consts").
  • G2-R1-08 [P2] (PRRT_kwDOH9mcF867CuTx) — Fixed: Added spec_preflight_reject_{lean,lake,init_system,std_uv}_import to AUDIT_HEADER_GUARDS (anneal/ci/check_guard_mutation.py:1076-1112) and test_spec_preflight_parity_with_trusted_boundary (anneal/ci/test_check_guard_mutation.py:415).
  • G2-R1-09 [P2] (PRRT_kwDOH9mcF867CuT3) — Fixed: is_forbidden_expected_const (:2635-2643) checks arena.user_name_root(cid) (stripping _private.<mod>.<idx> and _root_), covered by _private.Spec.0.Anneal.foo (:3532-3549).
  • G2-R1-11 [P2] (PRRT_kwDOH9mcF867CuUE) — Fixed: run_sandboxed_leanexport (stage.rs:3658) returns Failure::operational (exit 2) for trusted 5-init / 5a failures (with check_lean_stderr_panic), NDJSON/stage copies use copy_readonly_file (0o444, sandbox.rs:1348, stage.rs:3942, 4025, 4120), and init_primitives_cache (stage.rs:94, 3790) keys on (prefix, leanexport_sha256, sysroot_key).
  • G2-R1-12 [P2] (PRRT_kwDOH9mcF867CuUH) — Fixed: Updated anneal/docs/{alpha,auditing-and-comparator,elaborator-containment-design}.md to match shipped --allow-unpinned-lean routing, --paranoid-quorum, sorryAx checker policy, authenticated sysroot opaques, and 5-init caching.
  • G2-R1-13 [P2] (PRRT_kwDOH9mcF867CuUP) — Fixed: Added ANNEAL_REQUIRE_V435 fail-closed enforcement (ndjson_comparator_e2e.rs:62-64) and synthetic_ndjson_comparator_runs_full_target_audit_pipeline_without_v435_install (:550-791) running unconditionally without v4.35.0.
  • G2-R1-14 [P3] (PRRT_kwDOH9mcF867CuUU) — Fixed: Scoped SpecPreflight.lean doc comments to its 4 runtime modes, pinned upstream citations (lean4@eb6cafb7290e8bd5f2937522d8d804f58f02bafc), and wrapped comments/docs to <=80 columns.
  • G2-R1-15 [P3] (PRRT_kwDOH9mcF867CuUZ) — Fixed: Removed unused LegacyTargetAuditVerdict, LegacySpecWarning, and NdjsonComparatorTools.lake; updated validate_ndjson_verdict (:2078) and AdmittedToolchain.ndjson_tools (toolchain.rs:551) docs.
  • G2-R1-16 [P3] (PRRT_kwDOH9mcF867CuUe) — Fixed: Admitted non-unsafe authenticated sysroot Opaque declarations (expected_cone :2792-2807, proof_full :2840-2857), verified via System.Platform.getNumBits unit + v4.35.0 e2e tests.

Review & Verification Receipt (on bdd33415682feff42fce43b39872f5cd6709c9ed)

  • Internal Gate-1 Read-Only Review: PASS (0 P0 / 0 P1 / 0 P2 / 0 P3).
  • [real measurement] Post-final-edit checks on bdd33415682feff42fce43b39872f5cd6709c9ed:
    • cargo +stable run --locked -p cargo-anneal --example regenerate_bundle -- --root . --check: pass
    • cargo +stable clippy --locked --no-deps -p cargo-anneal -p cargo-anneal-tests -p anneal-audit --all-targets -- -A clippy::type_complexity -D warnings (plus --no-default-features on cargo-anneal and cargo-anneal-tests --test cli): 0 warnings
    • cargo +stable test --locked -p cargo-anneal --lib --bins: 179 passed; 0 failed (lib) + 0 passed; 0 failed (bin)
    • cargo +stable test --locked -p cargo-anneal --no-default-features --lib: 152 passed; 0 failed
    • cargo +stable test --locked -p anneal-audit --lib: 12 passed; 0 failed
    • ANNEAL_REQUIRE_V435=1 cargo +stable test --locked -p cargo-anneal-tests --test ndjson_comparator_e2e: 5 passed; 0 failed (live Lean v4.35.0 + synthetic fallback)
    • cargo +stable test --locked -p cargo-anneal-tests --test cli --test sandbox_escape --test harness --test support_paths --test support_regressions --test support_signals: cli 24 passed, harness 7 passed (1 ignored), sandbox_escape 7 passed, support_paths 20 passed (2 ignored), support_regressions 12 passed (2 ignored), support_signals 3 passed (0 failed across all 6 binaries)
    • cargo +stable test --locked -p anneal-audit-tests --test boundary_audit -- --test-threads=12: 57 passed; 0 failed
    • cargo +stable run --locked -p anneal-audit -- --anneal-root . --json: replay: true (12361 decls), correspondenceReplay: true (2680 decls), miriReplay: true (39088 decls), axioms: ["propext", "Classical.choice", "Quot.sound"]
    • python3 -I -B ci/check_guard_mutation.py --suite audit_headers --jobs 4: 8/8 killed (100.0%), 0 survived
    • (cd anneal && sha256sum --check --strict trusted/root-manifest.sha256 && python3 -B -m unittest discover -s ci -p 'test_*.py'): 4/4 OK, 186 Python tests OK
    • ./ci/check_todo.sh, ./anneal/ci/check_todo.sh, ./ci/check_actions.sh, ./anneal/ci/check_actions.sh, ./anneal/ci/check_job_dependencies.sh, ./anneal/ci/check_non_stable_version.sh, ./ci/check_fmt.sh, python3 -B ci/check_skills.py, git diff --check: exit 0
  • Not executed locally in this run (left to PR/merge-queue CI): cargo-anneal-tests --test suite, --test inspect, --test installed_smoke, --test verify_starnix_e2e; anneal-audit-tests --test target_audit, --test cli_environment; and check_guard_mutation.py --suite all (audit_headers ran; lean-miri semantics suite unrun).

Human review surface

target_base = 5d5e9df80bb04a8e258988d25e215dfedd75ec3b, merge_base = 5d5e9df80bb04a8e258988d25e215dfedd75ec3b, head = bdd33415682feff42fce43b39872f5cd6709c9ed:

  • anneal/trusted/audit/SpecPreflight.lean, anneal/trusted/audit/TrustedBoundary.lean: runtime parser-only preflight (headers, spec-preflight emitting declaredConsts, resolve-imports, sysroot-consts) for --allow-unpinned-lean v4.35.0+ and forbiddenSpecDeclRootNamespaces parity across both inspectors.
  • anneal/trusted/cargo-anneal/src/{lib,bundle,bundled_resources,ndjson_comparator,sandbox,stage,target,toolchain,verify}.rs: pure-Rust 5-init/5a/5b/5c NDJSON comparator, dual-kernel (nanoda_bin, con-ron) + optional --paranoid-quorum (con-leche, lean4lean) ExecSeal execution, bounded 0o600->0o444 staging, and Receipt v3 digest/provenance wiring (TrustedBoundary.lean retained across all modes on pinned v4.34.1).
  • anneal/flake.nix, anneal/trusted/root-manifest.sha256, .github/workflows/anneal-current.yml, anneal/ci/{alpha_release,check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py: omnibus archive, Nix cache key, prebuilt SpecPreflight.olean packaging, audit_headers guard-mutation entries, and parity tests.
  • anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs, anneal/docs/{alpha,auditing-and-comparator,elaborator-containment-design}.md: v4.35.0+ + unconditional synthetic fallback e2e tests and dual-engine documentation.
  • Policy relaxations: none.

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

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from bdd3341 to c9f43a0 Compare November 24, 2026 06:28
@joshlf

joshlf commented Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

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

Fixed the Current Anneal / Workspace tests failure (anneal/tests/audit/tests/target_audit.rs::rejects_crate_constructor_outside_model) on bdd3341568 and force-pushed c9f43a0f1b568d076f845e4976685c214906a6ef (tree: 0a3aa8420e8773f41cece252e8acb0f07516bd0b).

CI Fix (bdd3341568 -> c9f43a0f1b)

  • anneal/tests/audit/tests/target_audit.rs (rejects_crate_constructor_outside_model): Because #4147 adds Trusted to forbiddenSpecDeclRootNamespaces in both SpecPreflight.lean and TrustedBoundary.lean, defining structure Trusted.MirSemantics.Crate in TargetRole::Specification is now refused earlier during "spec-preflight" (cannot declare in reserved namespace Trusted in specification). Updated the test to assert that early "spec-preflight" rejection on Spec, plus a second fixture defining Trusted.MirSemantics.Crate in TargetRole::Expected (reject_audit, "target-audit" phase) so both defense-in-depth layers stay covered.

Gate-1 & Verification Receipt (c9f43a0f1b568d076f845e4976685c214906a6ef, post-final-edit [real measurement])

  • Read-only Gate-1 delta review: PASS (0 P0 / 0 P1).
  • Static & Python checks:
    • ./anneal/ci/check_todo.sh, ./ci/check_todo.sh, git diff --check origin/main..HEAD: exit 0
    • (cd anneal && sha256sum --check --strict trusted/root-manifest.sha256): 4/4 OK
    • python3 -m unittest discover -s anneal/ci -p "test_*.py": 186 tests OK (206.676s)
    • cargo +stable run --manifest-path anneal/Cargo.toml --locked -p cargo-anneal --example regenerate_bundle -- --root anneal --check: exit 0
    • cargo +stable clippy --manifest-path anneal/Cargo.toml --locked --no-deps -p cargo-anneal -p cargo-anneal-tests -p anneal-audit -p anneal-audit-tests --all-targets -- -A clippy::type_complexity -D warnings: exit 0
  • Cargo test suites:
    • cargo-anneal --no-default-features --lib --bin cargo-anneal: 152 passed; 0 failed (371.69s)
    • cargo-anneal --lib --bin cargo-anneal (default setup feature): 179 passed; 0 failed (243.89s)
    • anneal-audit: 12 passed; 0 failed (0.53s)
    • anneal-testkit: 16 passed; 0 failed (0.48s)
    • anneal-audit-tests: cli_environment (4 passed; 0 failed, 0.66s), target_audit (38 passed; 0 failed, 1476.11s), boundary_audit (57 passed; 0 failed, 1597.70s)
    • cargo-anneal-tests --no-default-features --test cli: 20 passed; 0 failed (0.47s)
    • cargo-anneal-tests (default features): cli (24/24), harness (7 passed; 1 ignored), sandbox_escape (7/7), support_paths (20 passed; 2 ignored), support_regressions (12 passed; 2 ignored), support_signals (3/3), ndjson_comparator_e2e with ANNEAL_REQUIRE_V435=1 (5/5, 133.03s), installed_smoke (0 passed; 2 ignored), and 28/29 suite tests (22 passed; 7 failed under --test-threads=6 where all 7 failures were 180s subprocess timeouts under host load, followed by 3/3 passing at --test-threads=1 for anti_vacuity_lint_clean_spin_and_unsafe_identity, verifies_crate_with_over_100_long_identity_bodies_at_default_max_rec_depth, and declared_cfg_cannot_expand_compiler_response_files, and 3/3 passing at --test-threads=2 for ignores_tampered_or_spoofed_files_in_dot_anneal_and_proof_olean, verifies_under_hostile_environment_and_cargo_configs, and canonicalizes_symlinked_temporary_directory_source_bindings).
    • cargo +nightly-2026-05-31 test --locked -p anneal-rustc-capture -p anneal-rustc-capture-tests: anneal-rustc-capture (44/44), compiler_session (23/23), typed_capture (59/59, 413.59s)
  • Not verified locally on c9f43a0f1b (left to CI): suite::corpora_runner::verifies_scalar_spec_corpus (timed out at 180s per-invocation test harness cap under --test-threads=6/--test-threads=2 host contention, and sequential --test-threads=1 queued without completing before cleanup), installed_smoke --ignored against the full omnibus archive, nix build .#omnibus-archive, and +nightly clippy lints.

Human review surface

  • Comparison tuple: (target_base=7527dd2b9ae90b60d2ae8258ffd44bd0ee1e4d82, merge_base=5d5e9df80bb04a8e258988d25e215dfedd75ec3b, head=c9f43a0f1b568d076f845e4976685c214906a6ef), tree=0a3aa8420e8773f41cece252e8acb0f07516bd0b, 0 unresolved review threads.
  • Trusted TCB & pinned manifests (12 files): anneal/trusted/audit/{SpecPreflight,TrustedBoundary}.lean, anneal/trusted/cargo-anneal/src/{bundle,bundled_resources,lib,ndjson_comparator,sandbox,stage,target,toolchain,verify}.rs, anneal/trusted/root-manifest.sha256.
  • CI, Nix, & packaging (8 files): .github/workflows/anneal-current.yml, anneal/flake.nix, anneal/ci/{alpha_release,check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py.
  • Tests & docs (5 files): anneal/tests/audit/tests/target_audit.rs, anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs, anneal/docs/{alpha,auditing-and-comparator,elaborator-containment-design}.md.
  • Policy relaxations: None (TrustedBoundary.lean stays active on pinned v4.34.1, and SpecPreflight + the dual-kernel NDJSON comparator apply only under --allow-unpinned-lean on v4.35.0+ when comparator tools are present).

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from c9f43a0 to 8b4844d Compare November 24, 2026 09:22
@joshlf

joshlf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

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

Rebased onto origin/main (c84e2ce336f020d710a0bbf0be35a8bd62aa8260, incl. #4177, #4238, #4256) at commit 8b4844d1d0dbb8ef457ce6e215b22fbafb20df47 (tree = 05848ebb7027f4c9b8a94eab116b5d587c2b4404). Resolved rebase overlaps in anneal/trusted/cargo-anneal/src/stage.rs (migrating #4238's bundled_olean_cache_invalidates_downstream_through_unchanged_barrel callers to 3-arg ensure_inspector_compiled("headers", true, false) while retaining spec_preflight_uses_distinct_inspector_cache_key_and_supports_no_rebuild) and anneal/ci/test_prebuild_bundled_oleans.py (including SpecPreflight.lean in #4238's test_prebuild_barrel_transitive_sha256_tracks_indirect_leaf_changes).

Verification Receipt (8b4844d1d0dbb8ef457ce6e215b22fbafb20df47)

  • anneal-audit-tests (--test target_audit -- --test-threads=4): 38 passed; 0 failed (1402.93s) [real measurement]
  • cargo-anneal-tests (--test ndjson_comparator_e2e -- --test-threads=2): 5 passed; 0 failed (296.57s) [real measurement]
  • cargo-anneal --lib --bin: 156 passed; 0 failed (293.50s lib, 0.00s bin) [real measurement]
  • anneal-audit --lib --bin: 12 passed; 0 failed (1.16s lib, 0.00s bin) [real measurement]
  • regenerate_bundle --root . --check & workspace cargo clippy: exit 0 [real measurement]
  • anneal/ci/test_*.py full Python suite (test_prebuild_bundled_oleans.py, test_check_guard_mutation.py, etc.): 188 passed; 0 failed (279.045s) [real measurement]
  • Static checks: ./anneal/ci/check_todo.sh, ./ci/check_todo.sh, ./anneal/ci/check_flake_eval.sh, (cd anneal && sha256sum --check --strict trusted/root-manifest.sha256) (4/4 OK), and git diff --check origin/main..HEAD: all exit 0 [real measurement]
  • Cross-family Gate-1 rebase-delta review (PASS): 0 P0 / 0 P1 / 0 P2 / 0 P3 on tuple (c84e2ce336f020d710a0bbf0be35a8bd62aa8260, c84e2ce336f020d710a0bbf0be35a8bd62aa8260, 8b4844d1d0dbb8ef457ce6e215b22fbafb20df47) (25/25 files inspected).
  • CI note: Full GitHub Actions matrix (including boundary_audit, installed_smoke, ci_workflow, and Nix archive build) runs on PR CI.

Human review surface

  • Comparison tuple: target_base = merge_base = c84e2ce336f020d710a0bbf0be35a8bd62aa8260, head = 8b4844d1d0dbb8ef457ce6e215b22fbafb20df47 (tree = 05848ebb7027f4c9b8a94eab116b5d587c2b4404).
  • Touched TCB & repository surfaces (25 files, +8053/-283; only the stage.rs 3-arg call adaptation +6/-6 and test_prebuild_bundled_oleans.py +3 setup changed during rebase vs c9f43a0f1b56):
    • anneal/trusted/audit/SpecPreflight.lean (+1398) & anneal/trusted/audit/TrustedBoundary.lean (+46/-8)
    • anneal/trusted/cargo-anneal/src/{ndjson_comparator.rs (+3870), stage.rs (+941/-81), target.rs (+375/-4), sandbox.rs (+142/-25), toolchain.rs (+116/-1), verify.rs (+44/-15), lib.rs (+13/-6), bundle.rs (+1), bundled_resources.rs (+5/-1)}
    • anneal/trusted/root-manifest.sha256, anneal/flake.nix (+6), .github/workflows/anneal-current.yml
    • anneal/ci/{prebuild_bundled_oleans.py, check_guard_mutation.py, check_bundle_tree.py, alpha_release.py}, tests, and docs (anneal/docs/{alpha,auditing-and-comparator,elaborator-containment-design,testing-architecture}.md)
  • Policy relaxations: none (pinned mode retains TrustedBoundary.lean with ndjson_tools: None; v4.35.0+ unpinned mode routes through pure-Rust dual-kernel ndjson_comparator + SpecPreflight enforcing whole-spec bans, pinned primitives, and binary digest recording).

@joshlf

joshlf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

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

Rebased cleanly onto origin/main (706acd8761d7d8da4be9fc72f280931f75f7d837, #4259) at commit b6fc48c1b85dc7269e4f4932380bb72b3abb66d3 (tree = 3ebda64311970d5e9db1694f62d30255cffbd475). git range-diff vs prior 8b4844d1d0db shows only the single-line anneal/trusted/root-manifest.sha256 context update for Cargo.lock (#4259).

Rebase Verification Receipt (b6fc48c1b85dc7269e4f4932380bb72b3abb66d3)

  • (cd anneal && sha256sum --check --strict trusted/root-manifest.sha256) (4/4 OK), ./ci/check_todo.sh, ./anneal/ci/check_todo.sh, ./anneal/ci/check_flake_eval.sh, git diff --check origin/main..HEAD: all exit 0 [real measurement]
  • test_prebuild_bundled_oleans.py: 6 passed; 0 failed (0.995s) [real measurement]
  • test_check_guard_mutation.py: 10 passed; 0 failed (6.591s) [real measurement]
  • cargo-anneal --lib setup::tests:: -- --test-threads=1: 26 passed; 0 failed (0.20s) [real measurement]
  • anneal-audit --lib --bins: 12 passed; 0 failed (0.31s) [real measurement]
  • Cross-family Gate-1 #4259 rebase-delta review (PASS, 0 P0 / 0 P1 / 0 P2 / 0 P3) on (706acd8761d7d8da4be9fc72f280931f75f7d837, 706acd8761d7d8da4be9fc72f280931f75f7d837, b6fc48c1b85dc7269e4f4932380bb72b3abb66d3).
  • Full workspace/e2e/Python suites run on PR CI (preceding identical-patch commit 8b4844d1d0db passed target_audit 38/38, ndjson_comparator_e2e 5/5, cargo-anneal --lib --bin 156+0, anneal-audit 12+0, and anneal/ci/test_*.py 188/188).

Human review surface

  • Unchanged vs 8b4844d1d0db (#issuecomment-7127318688), rebased to (706acd8761d7d8da4be9fc72f280931f75f7d837, 706acd8761d7d8da4be9fc72f280931f75f7d837, b6fc48c1b85dc7269e4f4932380bb72b3abb66d3); Policy relaxations: none.

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 8b4844d to b6fc48c Compare November 24, 2026 09:34

@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 (tier2_tcb, Round 2)

  • Identity: one:b56d8040df1d2d0cfe3f43b804ba6548d31189df:3ebda64311970d5e9db1694f62d30255cffbd475:8e612dd5c3e8e8acdb15f007c22257d78dd6445f4f18f715c807f719c599b2b7 (base=706acd8761d7, head=b6fc48c1b85d, tree=3ebda6431197)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 25 inspected, 0 inapplicable, 0 blocked (of 25 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 13 3705s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 5 2815s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 2 1242s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R2-01 P1 3 (seat1, seat2, seat3) static_verified anneal/trusted/audit/SpecPreflight.lean:1213 collectDeclaredSpecConsts emits only names the user wrote, omitting auto-generated spec constants (anonymous instances, deriving instances, constructors/projections, where/let-rec auxiliaries). Such constants escape the comparator's direct spec-dependency checks unless they carry the module prefix.
G2-R2-02 P1 2 (seat1, seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2977 Closedness of the expected cone is never checked: bfs_cone silently skips dependencies absent from the trusted export, so an export omission (5a runs leanexport --ignore-missing) would let proof_full supply that dependency with arbitrary content.
G2-R2-03 P1 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2597 Open trust question: the reserved-root and kernel-accelerated-name exemptions trust a constant's sysroot status by name alone, so a proof export may redeclare existing sysroot names whose content is never pinned. It is unverified whether any kernel evaluates such a name natively.
G2-R2-04 P1 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2622 check_namespace_ownership makes Trusted.* namespace isolation vacuous on proof_full whenever Trusted is a model module and skips non-model Trusted.* and canonical-input origin enforcement on expected_cone.
G2-R2-05 P2 2 (seat1, seat2) static_verified anneal/trusted/audit/TrustedBoundary.lean:1888 rejectForbiddenSpecDeclNamespace replaces isForbiddenPureNamespace for the spec namespace 'enter' and 'declare in' checks, dropping root stripping and the Init.System / Std.Internal.UV / Internal.UV / Dynlib prefix rejections. The weakening is not disclosed, and the doc comment falsely claims the list includes the reservedKernelRoots entries (Init/Std are omitted).
G2-R2-06 P2 1 (seat1) static_verified anneal/tests/audit/tests/target_audit.rs:451 The modified spec namespace guards lack negative tests: only the 'Trusted' declaration case is asserted, and boundary_audit.rs is unchanged.
G2-R2-07 P3 1 (seat1) static_verified anneal/ci/test_check_guard_mutation.py:415 The SpecPreflight/TrustedBoundary parity test compares only 12 header/namespace definitions, omitting the spec allowlists, validators and namespace guard functions, so drift there goes undetected.
G2-R2-08 P3 1 (seat1) static_verified anneal/docs/auditing-and-comparator.md:18 Docs say the NDJSON comparator runs whenever the v4.35 binaries exist under /bin/, omitting that it activates only under --allow-unpinned-lean; trusted comments say 'by default everywhere'.
G2-R2-09 P3 1 (seat1) static_verified anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:312 Every test that needs real Lean v4.35 returns as passing when the toolchain is absent (unless ANNEAL_REQUIRE_V435=1), and the only always-on test uses exit 0 kernel stubs, so CI exercises no real comparator negative cases end to end.
G2-R2-10 P3 1 (seat3) probe_confirmed anneal/trusted/audit/SpecPreflight.lean:435 forbiddenSpecDeclRootNamespaces in SpecPreflight.lean and TrustedBoundary.lean omits Init and Std despite its docstring claiming to include all reservedKernelRoots, allowing namespace Init / namespace Std and Init.* / Std.* declarations past preflight.
G2-R2-11 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:38 Module and function docs claim every .opaqueInfo is banned, but the code admits any non-unsafe opaque whose name is in the sysroot inventory.
G2-R2-12 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/stage.rs:4038 Kernels receive a fresh copy of proof_full.ndjson that is not re-hashed against the digest the Rust comparator verified.
G2-R2-13 P3 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/stage.rs:4167 run_ndjson_standalone_kernel omits check_lean_stderr_panic when invoking lean4lean, inconsistent with run_sandboxed_leanexport.
G2-R2-14 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/target.rs:1098 A missing declaredConsts key in the spec-preflight response is silently treated as an empty list rather than failing closed on the NDJSON route.
G2-R2-15 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/target.rs:1604 The NDJSON route skips validate_target_audit_report (closure/import-graph cross-checks and the specWarnings anti-vacuity lint), so receipts show an empty spec_warnings list that is indistinguishable from 'lint ran clean'.
G2-R2-16 P3 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/target.rs:1661 verify_export_meta_matches_toolchain returns Ok without checking anything when the admitted version string is not in the expected 'Lean (version ...' / 40-hex-commit format.

G2-R2-01 [P1] (anneal/trusted/audit/SpecPreflight.lean:1213, Pass 2 §3 (trusted/audit), static_verified): collectDeclaredSpecConsts emits only names the user wrote, omitting auto-generated spec constants (anonymous instances, deriving instances, constructors/projections, where/let-rec auxiliaries). Such constants escape the comparator's direct spec-dependency checks unless they carry the module prefix.

  • Invariant: declaredConsts must cover every constant a specification module introduces so that per-declaration spec restrictions apply.
  • Evidence: SpecPreflight.lean:405 admits Parser.Command.instance and line 381 admits Parser.Command.deriving, yet declarationIdent? (SpecPreflight.lean:244-249) returns none for anonymous instances and collectDeclaredSpecConsts (SpecPreflight.lean:1213-1231) returns #[] for none and Parser.Command.deriving while also omitting compiler-generated constructors/projections/defaults/matchers under custom namespaces. Action 5a (stage.rs:3963) exports only Expected.claim plus spec_declared_lean_names via leanexport --ignore-missing, and Action 5c (ndjson_comparator.rs:2687-2723) checks only constants present in expected_cone matching spec_decl_modules or specification_modules. Thus: (1) an unreferenced anonymous instance in Spec calling runST (fun _ => pure 0) (which passes SpecPreflight, per ndjson_comparator_e2e.rs:515-531) is never exported into expected_cone.ndjson and evades Action 5c's transitive ST ban; (2) because SpecPreflight.lean:460-462 does not ban the identifier sorryAx, an anonymous instance in Spec using sorryAx passes if unreferenced, and if used by Proof under --allow-sorry-in-proof, it is absent from expected_cone_set (ndjson_comparator.rs:2575) so ndjson_comparator.rs:2888 permits sorryAx inside a specification declaration; (3) custom-namespace anonymous instances and generated helpers fail is_spec_const (ndjson_comparator.rs:2688-2692), skipping direct is_lean_syntax_const/is_panic_spec_const checks and dropping out of specification_closure.

G2-R2-02 [P1] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2977, Pass 2 §3 (trusted/cargo-anneal), static_verified): Closedness of the expected cone is never checked: bfs_cone silently skips dependencies absent from the trusted export, so an export omission (5a runs leanexport --ignore-missing) would let proof_full supply that dependency with arbitrary content.

  • Invariant: Every constant transitively reachable from Expected.claim must come from the trusted 5a export and be DAG-identical in proof_full.
  • Evidence: bfs_cone (ndjson_comparator.rs:2962-2984, line 2977) guards if env.constants.contains_key(&dep) and silently ignores dependencies absent from env.constants. Action 5a invokes leanexport --ignore-missing (stage.rs:3963), and verify_ndjson_structure (ndjson_comparator.rs:2408-2443) never checks that every dependency returned by collect_const_deps for expected_bfs.visited or spec_bfs.visited exists in expected_cone.constants, nor that the four canonical inputs exist in expected_cone.constants (line 2684 silently guards if expected_cone.constants.contains_key(&spec_id), and build_closure_entries at 3037-3042 synthesizes missing root entries). If any transitive dependency D of Expected.claim (including Spec.specs) is missing from expected_cone.ndjson, Step 3 skips comparing D against proof_full, allowing a compromised 5b export to supply an arbitrary definition of D in proof_full.ndjson and pass both verify_ndjson_structure and the external kernels.

G2-R2-03 [P1] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2597, Pass 2 §3 (trusted/cargo-anneal), static_verified): Open trust question: the reserved-root and kernel-accelerated-name exemptions trust a constant's sysroot status by name alone, so a proof export may redeclare existing sysroot names whose content is never pinned. It is unverified whether any kernel evaluates such a name natively.

  • Invariant: Non-sysroot modules must not declare constants beneath reserved kernel/sysroot roots or under names the kernels special-case (doc comments at lines 160-164 and 174-175 claim this); every name a kernel evaluates natively must be content-pinned to the clean sysroot.
  • Evidence: check_namespace_ownership computes is_sysroot = sysroot_const_to_module.contains_key(encoded) (line 2597) and skips the KERNEL_ACCELERATED_NAMES (2599) and RESERVED_KERNEL_ROOTS (2608) checks when it is true. Content is pinned only for names in init_primitives (step 4, lines 2450-2463) or in expected_cone (lines 2410-2443). A prelude-only proof module that does not import the sysroot module defining e.g. Nat.log2 can declare its own Nat.log2 with arbitrary content. PINNED_INIT_PRIMITIVES (lines 107-147) and KERNEL_ACCELERATED_NAMES omit Nat.log2. If nanoda_bin, con-ron, con-leche or lean4lean evaluates Nat.log2 (or another unlisted name) natively, the mismatch between native reduction and the attacker's definition can yield False, and with it any claim. Resolving check: compare each kernel's native-evaluation name set against the pinned set, or require every proof_full constant whose name is in the sysroot inventory to equal a clean sysroot export.

G2-R2-04 [P1] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2622, Pass 2 §3 (trusted/cargo-anneal), static_verified): check_namespace_ownership makes Trusted.* namespace isolation vacuous on proof_full whenever Trusted is a model module and skips non-model Trusted.* and canonical-input origin enforcement on expected_cone.

  • Invariant: Non-model target modules (Proof, Expected, Capture, Specification) must not declare constants in the Trusted.* namespace (except compiler-generated helpers on authenticated Model parents), and canonical inputs (canonical_root, Crate.mk, subject_declaration, specification_declaration, expected_declaration, theorem_name) must originate from their designated TargetRole modules (TrustedBoundary.lean:6223-6226, 6273-6277, 6326-6354).
  • Evidence: At ndjson_comparator.rs:2620-2632, in_expected_or_model evaluates req.model_modules.iter().any(|m| arena.belongs_to_module(cid, m)) (likewise is_model_parts at 2580-2588). Because trusted/lean/Trusted.lean (bundle.rs:36-45, ndjson_comparator_e2e.rs:81-95) registers 'Trusted' in req.model_modules, belongs_to_module(cid, 'Trusted') (675-698) matches every Trusted.* constant (and 'Trusted.MirSemantics' matches every Trusted.MirSemantics.* constant), making the Trusted namespace rejection on proof_full vacuous so Proof can declare arbitrary new constants in Trusted.. Furthermore, line 2654 passes allow_trusted_outside_model = true for expected_cone without checking per-role declaration origins, so a non-model module such as Expected or Captured declaring Trusted.MirSemantics.Crate (explicitly rejected in tests/audit/tests/target_audit.rs:286-302) or Spec.specs passes verify_ndjson_structure. Additionally, belongs_to_module_parts (675-698) does not strip root, so is_forbidden_expected_const (2635-2643) would not match root.. against forbidden_expected_modules.

G2-R2-05 [P2] (anneal/trusted/audit/TrustedBoundary.lean:1888, Pass 2 §3 (trusted/audit), static_verified): rejectForbiddenSpecDeclNamespace replaces isForbiddenPureNamespace for the spec namespace 'enter' and 'declare in' checks, dropping root stripping and the Init.System / Std.Internal.UV / Internal.UV / Dynlib prefix rejections. The weakening is not disclosed, and the doc comment falsely claims the list includes the reservedKernelRoots entries (Init/Std are omitted).

  • Invariant: Preserve TrustedBoundary.lean admission checks (pushSpecScopes / checkSpecDeclNamespace); any weakening must be disclosed and justified in the commit body.
  • Evidence: TrustedBoundary.reservedKernelRoots (TrustedBoundary.lean:2557-2561) and RESERVED_KERNEL_ROOTS (ndjson_comparator.rs:169) include Init and Std, but forbiddenSpecDeclRootNamespaces (TrustedBoundary.lean:1547-1557, duplicated at SpecPreflight.lean:435-443) omits both Init and Std despite its doc comment claiming inclusion of reservedKernelRoots. In addition, pushSpecScopes (TrustedBoundary.lean:2046, SpecPreflight.lean:941) and checkSpecDeclNamespace (TrustedBoundary.lean:2070, 2075, SpecPreflight.lean:965, 970) switched from rejectForbiddenSpecNamespace (isForbiddenPureNamespace) to rejectForbiddenSpecDeclNamespace (TrustedBoundary.lean:1888-1890, SpecPreflight.lean:783-785), which checks only forbiddenSpecDeclRootNamespaces.contains ns.getRoot. Consequently, namespace Init / namespace Std (activating scoped parser extensions via Parser.parserExtension.activateScoped at TrustedBoundary.lean:2050 and SpecPreflight.lean:945) and declarations under Init.* / Std.* pass spec-preflight, and pushSpecScopes/checkSpecDeclNamespace no longer enforce forbiddenSysUvPrefixes directly.

G2-R2-06 [P2] (anneal/tests/audit/tests/target_audit.rs:451, Pass 2 §3 (trusted/audit negative tests), static_verified): The modified spec namespace guards lack negative tests: only the 'Trusted' declaration case is asserted, and boundary_audit.rs is unchanged.

  • Invariant: Every added or modified admission guard requires negative tests asserting exit 1 and the target diagnostic, verified to fail if the guard is disabled.
  • Evidence: The only new assertion (lines 451-460) checks 'cannot declare in reserved namespace Trusted in specification'. There are no tests for entering namespace Nat/Anneal/Proof, for a bare def Nat (new .str .anonymous branch, TrustedBoundary.lean lines 2074-2076), or regression tests that Init.System / Std.Internal.UV / Dynlib / root.IO namespaces are still rejected after the guard change. tests/audit/tests/boundary_audit.rs is unchanged.

G2-R2-07 [P3] (anneal/ci/test_check_guard_mutation.py:415, Pass 2 §5 (ci/), static_verified): The SpecPreflight/TrustedBoundary parity test compares only 12 header/namespace definitions, omitting the spec allowlists, validators and namespace guard functions, so drift there goes undetected.

  • Invariant: Duplicated trusted admission logic needs a mechanical drift check covering every security-relevant definition.
  • Evidence: Lines 431-444 list allowedHeaderKinds ... forbiddenSpecDeclRootNamespaces only. Missing: allowedSpecCommandKinds, allowedSpecDeclModifierKinds, forbiddenSpecModifierKinds, allowedSpecTacticKinds, forbiddenSpecTermKinds, validateSpec*, rejectForbiddenSpec*Namespace, pushSpecScopes, checkSpecDeclNamespace, inspectSpecSyntax. extract_def_block uses text.index(f"def {name}") (line 422), which can match a longer definition name that starts with the same prefix.

G2-R2-08 [P3] (anneal/docs/auditing-and-comparator.md:18, General (documentation), static_verified): Docs say the NDJSON comparator runs whenever the v4.35 binaries exist under /bin/, omitting that it activates only under --allow-unpinned-lean; trusted comments say 'by default everywhere'.

  • Invariant: Docs and trusted comments must match the code's gating.
  • Evidence: Pinned admission hard-codes ndjson_tools: None (stage.rs line 1979); only tool_admission_unpinned calls discover_ndjson_comparator_tools (stage.rs line 2070). docs line 18, toolchain.rs line 374 and target.rs line 1253 describe default activation without the opt-in. alpha.md and the commit body state the requirement correctly.

G2-R2-09 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:312, General (test adequacy), static_verified): Every test that needs real Lean v4.35 returns as passing when the toolchain is absent (unless ANNEAL_REQUIRE_V435=1), and the only always-on test uses exit 0 kernel stubs, so CI exercises no real comparator negative cases end to end.

  • Invariant: Negative security tests must be non-vacuous in CI.
  • Evidence: Lines 223-226, 312-315, 394-397 and 458-461 return early on discover_v435_lean() == None. The synthetic test (550-791) writes nanoda_bin and con-ron as #!/bin/sh exit 0 (733-737) and only checks plumbing. None of the tests simulates a hand-crafted proof_full NDJSON that redefines sysroot or pinned names.

G2-R2-10 [P3] (anneal/trusted/audit/SpecPreflight.lean:435, Pass 2 (anneal/trusted/audit/SpecPreflight.lean / TrustedBoundary.lean), probe_confirmed): forbiddenSpecDeclRootNamespaces in SpecPreflight.lean and TrustedBoundary.lean omits Init and Std despite its docstring claiming to include all reservedKernelRoots, allowing namespace Init / namespace Std and Init.* / Std.* declarations past preflight.

  • Invariant: forbiddenSpecDeclRootNamespaces must forbid entering namespace <Root> or declaring constants beneath every root in reservedKernelRoots, as stated at SpecPreflight.lean:430-434 and TrustedBoundary.lean:1542-1546.
  • Evidence: A bwrap cross-check comparing TrustedBoundary.reservedKernelRoots against SpecPreflight.forbiddenSpecDeclRootNamespaces (SpecPreflight.lean:435-443) union forbiddenSpecRootNamespaces (SpecPreflight.lean:427-428) reported ['Init', 'Std'] missing (likewise in TrustedBoundary.lean:1547-1555). While named Init.*/Std.* declarations are caught later by TrustedBoundary.reservedKernelRoots and ndjson_comparator.rs:165-172 (RESERVED_KERNEL_ROOTS), spec-preflight fails to reject them early, and an unreferenced anonymous instance inside namespace Init never reaches 5a.

G2-R2-11 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:38, General (trusted/ comment accuracy), static_verified): Module and function docs claim every .opaqueInfo is banned, but the code admits any non-unsafe opaque whose name is in the sysroot inventory.

  • Invariant: Trusted-code comments must accurately state invariants for human auditors.
  • Evidence: Lines 38-41 ('banning every .opaqueInfo') and 2305-2306 ('zero .opaqueInfo declarations') contradict lines 2792-2796, which permit non-unsafe opaques whose names are in the sysroot inventory (and the proof_full counterpart, ~2840-2846). The comment at 2783-2784 is accurate. The design looks sound because axioms are scanned across the whole export, but the stated invariant is false.

G2-R2-12 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:4038, Pass 2 §3 (trusted/cargo-anneal), static_verified): Kernels receive a fresh copy of proof_full.ndjson that is not re-hashed against the digest the Rust comparator verified.

  • Invariant: The structural comparator and the kernels should provably check the same bytes.
  • Evidence: copy_readonly_file(proof_ndjson_host, &in_ndjson, phase) at line 4038 (nanoda) and line 4133 (standalone kernels) re-reads the host file after target.rs lines 1499-1506 verified proof_ndjson_sha256; the copy is never compared with that digest. The stage directory is 0o700, so only a same-uid process could swap the file; hardening only.

G2-R2-13 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:4167, Pass 2 §3 (trusted/cargo-anneal), static_verified): run_ndjson_standalone_kernel omits check_lean_stderr_panic when invoking lean4lean, inconsistent with run_sandboxed_leanexport.

  • Invariant: Lean 4 binaries executed inside ExecSeal should check stderr for Lean runtime panic/internal-exception markers (check_lean_stderr_panic) in addition to setting LEAN_ABORT_ON_PANIC=1 (stage.rs:195-211, 3749).
  • Evidence: run_sandboxed_leanexport (stage.rs:3748-3749) sets LEAN_ABORT_ON_PANIC=1 and calls check_lean_stderr_panic(phase, &output)?, whereas run_ndjson_standalone_kernel (stage.rs:4113-4195, invoked by run_ndjson_lean4lean for the Lean 4-compiled lean4lean kernel under --paranoid-quorum) sets LEAN_ABORT_ON_PANIC=1 (stage.rs:4151) but does not call check_lean_stderr_panic after let output = output?; (stage.rs:4167).

G2-R2-14 [P3] (anneal/trusted/cargo-anneal/src/target.rs:1098, Pass 2 §3 (trusted/cargo-anneal), static_verified): A missing declaredConsts key in the spec-preflight response is silently treated as an empty list rather than failing closed on the NDJSON route.

  • Invariant: Inspector outputs that feed security checks must be required when the consuming path is active.
  • Evidence: Line 1098 if let Some(arr) = spec_pf.get("declaredConsts").and_then(Json::as_array) has no else branch. declaredConsts feeds the spec roots in ndjson_comparator.rs lines 2677-2709 and the extra 5a export roots. SpecPreflight emits the key today, so this matters only if the inspector regresses. stage.rs line 1642 also tolerates a missing SpecPreflight.lean; that case currently still fails closed via the unknown sysroot-consts mode.

G2-R2-15 [P3] (anneal/trusted/cargo-anneal/src/target.rs:1604, General (receipt fidelity), static_verified): The NDJSON route skips validate_target_audit_report (closure/import-graph cross-checks and the specWarnings anti-vacuity lint), so receipts show an empty spec_warnings list that is indistinguishable from 'lint ran clean'.

  • Invariant: Receipts should honestly represent which checks ran; switching audit engines should not silently drop advisory checks.
  • Evidence: NdjsonAuditVerdict (constructed at 1604-1642, validated by validate_ndjson_verdict) has no specWarnings field. verify.rs lines 2109-2114 call extract_spec_warnings, which returns [] when the key is absent (2265). The legacy path validates spec_warnings and closures against expected_graph (target.rs ~565-581).

G2-R2-16 [P3] (anneal/trusted/cargo-anneal/src/target.rs:1661, Pass 2 §3 (trusted/cargo-anneal), static_verified): verify_export_meta_matches_toolchain returns Ok without checking anything when the admitted version string is not in the expected 'Lean (version ...' / 40-hex-commit format.

  • Invariant: Toolchain cross-checks should fail closed on unrecognised input.
  • Evidence: Line 1661 if let Some(after) = toolchain_version.strip_prefix("Lean (version ") with no else branch. An empty reported version is skipped (1663), and a commit that isn't 40 hex characters is skipped (1674-1676). In unpinned mode the version string comes from the operator's binary. Defense in depth only: expected and proof metas are still compared against the init meta (ndjson_comparator.rs lines 2322-2333).

Executed Sandbox Probes

  • seat3 pass1_hygiene_and_bundled_resources: outcome=passed
  • seat3 root_manifest_sha256: outcome=passed
  • seat3 python_ci_unit_tests: outcome=passed
  • seat3 guard_mutation_catalog_list: outcome=passed
  • seat3 spec_preflight_and_comparator_parity_probe: outcome=finding

Comment thread anneal/trusted/audit/SpecPreflight.lean Resolved
@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from b6fc48c to 32c0a5f Compare November 24, 2026 14:29
@joshlf

joshlf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

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

Fixed all 16 Gate-2 Round 2 findings and rebased onto origin/main (a3bdc4f43ce3, #4226). All 16 R2 threads are replied to and resolved.

Gate 2 Round 2 dispositions (32c0a5f40bd3)

  • G2-R2-01 [P1] (generated spec constants): Fixed. The parser-derived declared-constant list is gone. A new SpecPreflight mode, target-consts, builds a module index from the compiled Model, Capture, Specification, and Expected oleans (with loadExts := false; Proof oleans are never mounted), fails closed on any unsafe target constant, and flags paired well-founded _unsafe_rec auxiliaries. Step 5a exports every Spec constant, and 5c requires each one to be in the expected cone and applies the direct and transitive bans by exact origin. Tests reject an anonymous instance using runST, a custom-namespace instance referencing panicCore, and a missing generated constant; a positive e2e with structures, deriving, anonymous instances, where, and let rec passes.
  • G2-R2-02 [P1] (cone closedness): Fixed. check_export_closed runs on all four exports, bfs_cone is strict, and 5a no longer passes --ignore-missing. Only the names-only mutual all peers that leanexport records for definitions, theorems, and opaques may be absent (collect_required_deps). A negative test rejects an open trusted export whose missing dependency proof_full supplies.
  • G2-R2-03 [P1] (sysroot trusted by name): Fixed. A new 5-pin action re-exports, from the clean admitted sysroot only, every sysroot-named constant either export uses; each must be DAG-identical to its clean definition, and the digest is recorded as sysrootPinsSha256. Negative tests reject a spoofed Nat.log2, a sysroot name absent from the clean export, and a private _private.*.Nat.add.
  • G2-R2-04 [P1] (Trusted.* isolation): Fixed. A Trusted.* constant must be declared by a Model module (or be a generated equation/splitter helper of a Model parent) on both exports; target-module constants in proof_full must appear identically in 5a; every expected-cone constant needs a sysroot or target origin; canonical inputs are checked by role; and the target theorem must be proof-origin. Negative tests cover each case, and the Trusted.* case also passes against a real Lean v4.35 toolchain.
  • G2-R2-05 [P2] / G2-R2-16 [P3]: Fixed. rejectForbiddenSpecDeclNamespace calls rejectForbiddenSpecNamespace first, restoring the pure-namespace checks, _root_ stripping, and the Init.System/Internal.UV/Dynlib rejections; Init and Std are added to the reserved list. Both changes are in both Lean files, so nothing is weakened.
  • G2-R2-06 [P2]: Fixed. 13 new namespace vectors in target_audit.rs and 6 in the v4.35 SpecPreflight e2e.
  • Remaining P3s: the parity test requires every definition shared between SpecPreflight.lean and TrustedBoundary.lean to stay identical (explicit allowlists, mutation-checked); docs and trusted comments state the --allow-unpinned-lean gating; always-on adversarial unit tests in pure Rust (all 5 new guards mutation-killed); .opaqueInfo docs corrected; kernels re-hash their input copy against the verified digest; check_lean_stderr_panic runs for all kernels; the targetConsts response is validated strictly; NDJSON receipts omit spec_warnings and list the anti-vacuity lint under deferred; verify_export_meta_matches_toolchain fails closed on an unrecognized version or commit.

Verification Receipt

  • Comparison tuple: target_base = merge_base = a3bdc4f43ce3b993354526116e9269a3658dee5a, head = 32c0a5f40bd30aa3175d8b548905b83c72c07504, tree = a0df0bcad2f47ff57c3c48f213af1de34a0d215e.
  • Rebase: .github/workflows/anneal-current.yml keeps #4243's cache key verbatim (this PR's hash-input change there was dropped); the flake.nix digest in trusted/root-manifest.sha256 is recomputed after #4226's flake.nix edits auto-merged; #4214/#4218 composed cleanly.
  • On the final tree: anneal-audit --require-correspondence (replay, correspondenceReplay, miriReplay all true; axioms [propext, Classical.choice, Quot.sound]); boundary_audit 58/58; anneal/ci unittest 188/188; regenerate_bundle --check, sha256sum --check --strict trusted/root-manifest.sha256 (4/4 OK), both check_todo.sh, both check_actions.sh, git diff --check: OK
  • On the pre-rebase tree 09243069c354: ndjson_comparator_e2e 5/5 against a real Lean v4.35.0 toolchain (including --paranoid-quorum with 4 kernels); cargo-anneal --lib 194/194; target_audit 38/38
  • After the final clippy-only refactor: clippy -D warnings on cargo-anneal, cargo-anneal-tests, and anneal-audit-tests (all targets); comparator, stage::, and export_meta tests 47/47
  • SpecPreflight.lean compiles on v4.35.0 and v4.34.1.
  • Not run: rustfmt --check (the anneal crates fail it at base and CI does not run it); real zerocopy items on the NDJSON route (needs an unpinned v4.35 toolchain); the v4.35 e2e is not in CI, so the unit tests stand in for it.
  • Cross-family Gate-1 (gemini-4-neon-xhigh): PASS (0 P0 / 0 P1 / 0 P2 / 0 P3) on 09243069c354, plus a rebase/mechanical-delta Gate-1 on the final head: PASS (0 P0 / 0 P1 / 0 P2 / 0 P3), confirming the only changes beyond the clean rebase are the recomputed manifest digest and two behavior-preserving clippy refactors.

Human review surface

  • Comparison tuple: (a3bdc4f43ce3b993354526116e9269a3658dee5a, a3bdc4f43ce3b993354526116e9269a3658dee5a, 32c0a5f40bd30aa3175d8b548905b83c72c07504) (tree = a0df0bcad2f47ff57c3c48f213af1de34a0d215e).
  • anneal/trusted/cargo-anneal/src/ndjson_comparator.rs (new): verify_ndjson_structure (closed exports, 5-pin sysroot pinning, target-consts origins, Trusted/reserved/kernel-name isolation, canonical-input roles, spec bans, opaque/unsafe/axiom bans), plan_expected_export, plan_sysroot_pin_export, subset_roots, render_leanexport_name, collect_required_deps.
  • anneal/trusted/cargo-anneal/src/{stage,target,verify,toolchain,sandbox,lib,bundle}.rs: the 5-init/target-consts/5b/5a/5-pin/5c pipeline, no --ignore-missing, kernel input re-hash and stderr panic checks, target-consts artifact staging (non-Proof oleans only), strict metadata cross-check, receipt spec_warnings deferral.
  • anneal/trusted/audit/SpecPreflight.lean (new): headers, spec preflight, import resolution, sysroot and target constants; shared admission definitions byte-identical to TrustedBoundary.lean (parity test).
  • anneal/trusted/audit/TrustedBoundary.lean: the spec namespace guard is strictly stronger (adds Trusted/Anneal/Proof/reserved kernel roots including Init/Std).
  • Policy relaxations: none. New trust input: target-consts loads non-Proof target oleans into a sandboxed SpecPreflight (loadExts := false); its output only strengthens checks.

@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 (tier2_tcb, Round 3)

  • Identity: one:e29a7c66c216a55091e0b2314ea2adcfb175c788:a0df0bcad2f47ff57c3c48f213af1de34a0d215e:9e846fa782e32b58553cef50c406f0f5e5c60e54fc60465f3d66a6df54b1efd8 (base=a3bdc4f43ce3, head=32c0a5f40bd3, tree=a0df0bcad2f4)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 25 inspected, 0 inapplicable, 0 blocked (of 25 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 3 1092s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 4 2994s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 1 1385s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R3-01 P1 2 (seat1, seat2) static_verified anneal/trusted/audit/SpecPreflight.lean:1382 The new SpecPreflight admission guard (reject unsafe constants in target modules) and the target-consts/sysroot-consts modes have no negative or functional test that actually runs in CI.
G2-R3-02 P2 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2875 verify_ndjson_structure omits compiled declaration-edge TargetRole::allows enforcement required by target.rs's two-point authority contract.
G2-R3-03 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/target.rs:1217 The NDJSON comparator route replaces old target-audit but silently drops its compiler-override rejection and pre-import .olean validation; only the anti-vacuity lint omission is disclosed.
G2-R3-04 P3 2 (seat2, seat3) probe_confirmed anneal/docs/testing-architecture.md:911 Renaming the paranoid-mode heading in auditing-and-comparator.md broke two relative anchor links in testing-architecture.md.
G2-R3-05 P3 1 (seat2) static_verified anneal/trusted/audit/SpecPreflight.lean:206 inspectHeaderSyntax's requirePrelude branch checks args[1]!.isOfKind ``Parser.Module.prelude directly instead of unwrapping the optional nullKind node, so it always fails if requirePrelude is enabled.
G2-R3-06 P3 1 (seat1) static_verified anneal/trusted/audit/TrustedBoundary.lean:35 Trusted module header calls SpecPreflight a minimal parser-only inspector and lists only headers/spec-preflight/resolve-imports, but it also serves sysroot-consts and target-consts, which import compiled sysroot and target .olean files.

G2-R3-01 [P1] (anneal/trusted/audit/SpecPreflight.lean:1382, Pass 2 §3 (trusted/audit) / General test adequacy, static_verified): The new SpecPreflight admission guard (reject unsafe constants in target modules) and the target-consts/sysroot-consts modes have no negative or functional test that actually runs in CI.

  • Invariant: Code Review Rules Pass 2: every added admission guard needs a negative test asserting exit 1 and the diagnostic, verified to fail if the guard is disabled. Core invariant: do not present skipped or stubbed tests as real coverage.
  • Evidence: In Lean 4's finalizeImport (Lean/Environment.lean), when two independent modules declare a .thmInfo with identical (name, type, levelParams, all) (subsumesInfo), importModules succeeds without error, overwrites privateConstantMap with the later module's ConstantInfo, and retains the earlier module in const2ModIdx via insertIfNew. Because collectTargetConsts (SpecPreflight.lean:1373-1388) imports (foundation ++ libraries ++ targets) and only loops over env.constants checking env.getModuleIdxFor? constName against targets: (1) a Specification module declaring a theorem colliding with an imported Init/Std theorem under an unreserved root (e.g., Function, WellFounded, Add, Vector—absent from forbiddenSpecDeclRootNamespaces) whose proof invokes runST (which passes SpecPreflight, see ndjson_comparator_e2e.rs:558-595) maps to the sysroot module index and is silently omitted from targetConsts, 5a, and 5c; (2) between two independent Specification modules SpecA (invoking runST) and SpecB (clean), SpecB overwrites privateConstantMap so both collectTargetConsts and 5a export only SpecB's clean proof, erasing SpecA's banned ST dependency. Unlike TrustedBoundary.lean:6167-6182, collectTargetConsts also never inspects env.header.moduleData for data.constNames == data.constants.map ConstantInfo.name, intra-module duplicates, or data.isModule.

G2-R3-02 [P2] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2875, Pass 2 §3 (trusted/cargo-anneal), static_verified): verify_ndjson_structure omits compiled declaration-edge TargetRole::allows enforcement required by target.rs's two-point authority contract.

  • Invariant: TargetRole::allows (anneal/trusted/cargo-anneal/src/target.rs:79-85) requires checking authority directionality (Model -> {Model}, Capture -> {Model, Capture}, Specification -> {Model, Specification}, Expected -> !Proof) both before elaboration and again over actual compiled declaration edges, matching TrustedBoundary.lean:450-466 and 6434-6443.
  • Evidence: In verify_ndjson_structure (ndjson_comparator.rs:2577-3251), req.target_const_origins carries each non-Proof constant's TargetOriginRole, yet no check iterates declaration edges in expected_cone or proof_full to verify src_role.allows(dst_role). Cross-role edges such as Specification -> Capture, Capture -> Specification, or Model -> Specification/Capture in expected_cone (where Action 5a mounts all non-Proof roles together in one leanexport invocation) or in standalone calls to public verify_ndjson_structure are accepted without error, dropping the second enforcement layer documented at target.rs:79-83.

G2-R3-03 [P2] (anneal/trusted/cargo-anneal/src/target.rs:1217, Pass 2 §3 (trusted/cargo-anneal, trusted/audit), static_verified): The NDJSON comparator route replaces old target-audit but silently drops its compiler-override rejection and pre-import .olean validation; only the anti-vacuity lint omission is disclosed.

  • Invariant: Code Review Rules: any undisclosed weakening blocks merge; Human review surface and commit body must list every intentional policy relaxation. Pass 2 section 3 asks reviewers to preserve the auditor's checks.
  • Evidence: Trigger: --allow-unpinned-lean with leanexport/nanoda_bin/con-ron under /bin sets use_ndjson_comparator (target.rs:1217), which calls audit_target_ndjson (target.rs:1374) instead of inspect_target. Old target-audit rejects @[implemented_by]/@[extern]/@[csimp] on reached declarations authored by target modules (TrustedBoundary.lean:6521-6531) and runs validateTargetArtifactPreImport before loading non-Proof target .olean files (TrustedBoundary.lean:5125, 6122). The new route has no equivalent: NDJSON carries no attribute data (ndjson_comparator.rs parse_record), SpecPreflight collectTargetConsts calls importEnv on target modules without pre-import validation (SpecPreflight.lean:1373), and 5a leanexport loads the same files unvalidated (stage.rs export_ndjson_expected). The receipt's deferred list adds only the anti-vacuity lint (verify.rs:2332) and the commit body mentions only that lint. Kernel soundness is unaffected (compiler attributes do not change kernel reduction; the loads run sandboxed), hence P2, but it is a behavioral relaxation versus base unpinned verification that must be disclosed or restored.

G2-R3-04 [P3] (anneal/docs/testing-architecture.md:911, General (Documentation), probe_confirmed): Renaming the paranoid-mode heading in auditing-and-comparator.md broke two relative anchor links in testing-architecture.md.

  • Invariant: Documentation changes must keep relative Markdown links and heading anchors valid across affected docs (anneal/AGENTS.md Standing rules and Documentation review).
  • Evidence: anneal/docs/testing-architecture.md:911 links to auditing-and-comparator.md#optional-paranoid-multi-kernel-ci-mode, which matched base auditing-and-comparator.md:165 (### Optional paranoid multi-kernel CI mode) but was broken when this change renamed the heading at auditing-and-comparator.md:210 to ### Optional --paranoid-quorum multi-kernel mode; confirmed by bwrap doc-link probe.

G2-R3-05 [P3] (anneal/trusted/audit/SpecPreflight.lean:206, Pass 2 §3 (trusted/audit), static_verified): inspectHeaderSyntax's requirePrelude branch checks args[1]!.isOfKind ``Parser.Module.prelude directly instead of unwrapping the optional nullKind node, so it always fails if requirePrelude is enabled.

  • Invariant: Header syntax inspection must match Lean 4's Parser.Module.header AST layout ($[module]? $[prelude]? $imports*, Lean/Parser/Module.lean:84), as implemented in TrustedBoundary.lean:946.
  • Evidence: In SpecPreflight.lean:205-208, if requirePrelude && k == ``Parser.Module.header then unless args.size >= 2 && args[1]!.isOfKind ``Parser.Module.prelude tests args[1]! directly, whereas Lean 4 wraps optional prelude in a nullKind node whose child is Parser.Module.prelude (compare TrustedBoundary.lean:946: !(args[1]?.map Syntax.getArgs |>.getD #[]).isEmpty). Latent because current callers pass requirePrelude := false, but any future caller enabling requirePrelude := true will unconditionally reject valid prelude headers.

G2-R3-06 [P3] (anneal/trusted/audit/TrustedBoundary.lean:35, Pass 2 §3 (trusted/audit) / General documentation, static_verified): Trusted module header calls SpecPreflight a minimal parser-only inspector and lists only headers/spec-preflight/resolve-imports, but it also serves sysroot-consts and target-consts, which import compiled sysroot and target .olean files.

  • Invariant: AGENTS.md 'Commenting in trusted/': trusted comments must give reviewers accurate rationale and contracts; trusted/ comment edits are never inapplicable.
  • Evidence: TrustedBoundary.lean:33-41 says v4.35.0+ verification 'uses the minimal parser-only trusted/audit/SpecPreflight.lean ("headers", "spec-preflight", "resolve-imports")'. SpecPreflight.lean:42-54 and 1312-1392 add sysroot-consts and target-consts, which importModules the admitted sysroot plus the Model/Capture/Specification/Expected .olean files; stage.rs routes all five modes to SpecPreflight (uses_spec_preflight). The routing also applies only with --allow-unpinned-lean plus bundled binaries, not to every v4.35.0+ run. docs/auditing-and-comparator.md:229-233 still describes SpecPreflight as parser-only with zero .olean loading; docs/testing-architecture.md was updated to 'runtime preflight + module index'.

Executed Sandbox Probes

  • seat3 bwrap root-manifest sha256sum --check --strict: outcome=passed
  • seat3 bwrap static hygiene and bundled_resources byte-parity check: outcome=passed
  • seat3 bwrap Python CI unittest suite (prebuild_bundled_oleans, check_guard_mutation, check_bundle_tree): outcome=passed
  • seat3 bwrap test_alpha_release.py + ARCHIVE_INPUTS path check: outcome=partial
  • seat3 bwrap Markdown relative link & heading anchor validator: outcome=failed
  • seat3 bwrap SpecPreflight vs TrustedBoundary decl parity & Rust/Lean constant table cross-check: outcome=passed
  • seat3 bwrap standalone rustc (--edition 2024 -O) CanonicalArena & BFS falsification probe: outcome=passed

Comment thread anneal/trusted/audit/SpecPreflight.lean Resolved
Comment thread anneal/trusted/audit/SpecPreflight.lean Resolved
@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch 2 times, most recently from 265085f to 511f61c Compare November 24, 2026 21:53
@joshlf

joshlf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R3 fixes and rebase

Gate-2 R3 dispositions

ID Sev Disposition
R3-01 P1 Fixed. target-consts validates each target .olean before import and takes inventories from ModuleData (constNames == constants.map name, no duplicates). It rejects unsafe target constants and requires each target constant to equal the stored constant structurally (sameConstantInfo). This closes the case where a later equal-header theorem overwrites an earlier module's proof while const2ModIdx keeps the first owner. A collision is admitted only for a realized equation-style theorem that equals the owner's ModuleData entry. implemented_by/extern/csimp subjects are reported. New pinned-toolchain CI tests in target_audit.rs cover attribution, unsafe and colliding constants (including a differing-proof eq_1 collision), and compiler overrides.
R3-02 P2 Fixed. TargetOriginRole::allows is enforced over compiled edges in both expected_cone and proof_full; sysroot-to-target references are rejected; a reached target compiler override fails closed (enforces_target_role_edges_and_reached_compiler_overrides).
R3-03 P2 Fixed. Pre-import .olean validation and target override rejection are restored on the NDJSON route. Proof-module overrides are not inspected; those .oleans load only in the sandboxed proof-export step, and the attributes cannot change kernel reduction. This is disclosed in the receipt deferred list, auditing-and-comparator.md and the commit body.
R3-04 P3 Fixed: the ### Optional paranoid multi-kernel CI mode heading is restored, so both testing-architecture.md anchors resolve.
R3-05 P3 Fixed: inspectHeaderSyntax unwraps the optional nullKind in the requirePrelude branch.
R3-06 P3 Fixed: the TrustedBoundary.lean header describes all five SpecPreflight modes and their gating.

Verification

Rust and Lean suites ran on a head whose anneal/ tree is identical to this one apart from the later release-version bump:

  • clippy -D warnings: 0
  • cargo-anneal --lib: 199/199
  • ndjson_comparator_e2e (v4.35 required): 5/5
  • target_audit: 42/42
  • boundary_audit: 60/60
  • anneal-audit --require-correspondence: replay true, 14982 declarations / 1760 kernel, correspondence 2680, axioms {propext, Classical.choice, Quot.sound}
  • regenerate_bundle --check: 0

On 265085f2608f (which differs from this head only by rewrapping two added comments): regenerate_bundle --check 0, cargo build 0, anneal/ci unittest 201 OK (including the SpecPreflight parity test), check_todo and check_actions OK, root-manifest.sha256 4/4, git diff --check clean.

Mutation checks: removing the unsafe guard, the collision guard, the stored/owner equality check, or override extraction each makes its test fail.

Not exercised: real zerocopy items on the NDJSON route (the end-to-end tests use synthetic fixtures). rustfmt is not clean at base for the touched pre-existing files; the new hunks are fmt-clean.

Human review surface

Human review surface (base=9be5762cf8b1c31cae6ba72b4e99fdb01a7a60a1, merge_base=9be5762cf8b1c31cae6ba72b4e99fdb01a7a60a1, head=511f61c0fb5ea45c3840f84ea1048d436f83c7ff):

  • trusted/audit/SpecPreflight.lean: collectTargetConsts, sameConstantInfo, isRealizedTheoremName, the pre-import validation helpers, and the module-mode admission port.
  • trusted/cargo-anneal/src/ndjson_comparator.rs: role-edge and override checks, TargetOriginRole::allows, TargetConstIndex.
  • trusted/cargo-anneal/src/target.rs: collect_target_consts, audit_target_ndjson(is_module).
  • trusted/cargo-anneal/src/stage.rs: uses_spec_preflight routing.
  • trusted/cargo-anneal/src/verify.rs: the deferred receipt entry.
  • trusted/audit/TrustedBoundary.lean: header only.
  • ci/test_check_guard_mutation.py: spec_preflight_only.
  • Tests: tests/audit/tests/target_audit.rs, ndjson_comparator_e2e.rs.
  • ci/check_guard_mutation.py: SpecPreflight header-guard mutations.
  • ci/prebuild_bundled_oleans.py, ci/test_prebuild_bundled_oleans.py: precompile and cache SpecPreflight.olean.
  • ci/check_bundle_tree.py, ci/alpha_release.py: ship SpecPreflight.lean in the bundle and release.
  • flake.nix: stage SpecPreflight.lean into the distribution.
  • trusted/cargo-anneal/src/lib.rs: export the comparator module.
  • trusted/cargo-anneal/src/sandbox.rs: read-only NDJSON sinks in ExecSeal inputs.
  • trusted/cargo-anneal/src/toolchain.rs: ndjson_tools and SpecPreflight admission fields.
  • trusted/cargo-anneal/src/trusted_bundle.rs: add SpecPreflight.lean to TRUSTED_BUNDLE_SOURCES.
  • trusted/root-manifest.sha256: recomputed flake.nix digest.

@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 — CLEAN (tier2a_core_tcb, Round 4)

  • Identity: one:879a6280327263572adae4ab62f78c894906a7d3:136d3bbfe3e5d50860c2507c97f44fbcc20ae099:202854b3f475382bb8f3744c834d5ccc39fe3b0055bee2e6cfd21604ed36efc6 (base=9be5762cf8b1, head=511f61c0fb5e, tree=136d3bbfe3e5)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 24 inspected, 0 inapplicable, 0 blocked (of 24 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 2113s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1660s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 1488s

No unresolved P0-P2 findings raised across completed seats.

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

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

  • G2-R4-A01 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:3863): The unpinned init-primitives cache key falls back to lean_sha256 without hashing sysroot .olean content.
  • G2-R4-A02 [P3] (anneal/ci/test_check_guard_mutation.py:421): The parity test compares only def blocks, so structure/abbrev/instance definitions escape comparison.
  • G2-R4-A03 [P3] (anneal/docs/testing-architecture.md:119): Repository layout comment for check_guard_mutation.py still says (48 guards) after adding 4 SpecPreflight.lean guards.
  • G2-R4-A04 [P3] (anneal/docs/trust-model.md:230): The trust-model doc still describes unpinned runs as target-audit replay only.
  • G2-R4-A05 [P3] (anneal/tests/audit/tests/target_audit.rs:2197): No reserved-namespace vectors for instance/structure/mutual/open ... in declaration forms.
  • G2-R4-A06 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:10): Docs say 'default-ON on v4.35.0+', but the route needs --allow-unpinned-lean; live tests self-skip and CI installs no v4.35.
  • G2-R4-A07 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1071): The parser silently skips empty lines, widening comparator-versus-kernel parse divergence surface.
  • G2-R4-A08 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1809): Inductive records are flattened, so mutual-block grouping and order are never compared; the inductive parser branch has no unit test.
  • G2-R4-A09 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:4168): Kernels are accepted on exit status alone; replayedDeclarations is comparator-derived.
  • G2-R4-A10 [P3] (anneal/trusted/cargo-anneal/src/verify.rs:2319): The unpinned receipt's unhashed list omits the comparator and kernel binaries' shared libraries.

Executed Sandbox Probes

  • seat3 repo_hygiene_and_diff_scan: outcome=passed
  • seat3 workflow_permissions_auth_secret_containment_checklist: outcome=inapplicable
  • seat3 bwrap_root_manifest_sha256: outcome=passed
  • seat3 bwrap_python_ci_unittests: outcome=passed
  • seat3 bwrap_guard_mutation_catalog_and_bundle_check: outcome=passed
  • seat3 bwrap_lean_v4_34_1_spec_preflight_compile: outcome=passed
  • seat3 bwrap_spec_preflight_adversarial_vectors: outcome=passed
  • seat3 bwrap_module_header_and_target_consts_equations: outcome=passed
  • seat3 bwrap_specwf_unsafe_rec_and_sysroot_semantics: outcome=passed
  • seat3 rust_tests_and_live_v4_35_comparator: outcome=not_run

@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: rebase onto main after #4237

  • Comparison tuple: (0fd98bf034e14dfcba33b171c43ea1c1517ccdf0, 0fd98bf034e14dfcba33b171c43ea1c1517ccdf0, 8e3f09c4fc64439944b75b58d3b926bba3048599) (tree a9ddc8c4af91; one commit). git merge-tree against current main d94f400cd is clean, and no file overlaps.
  • Previously reviewed head: 511f61c0fb5e on 9be5762cf8b1 (Gate-2 R4 CLEAN).

Changes since the reviewed head

Verification

Run on 297aa48e2a50, which differs from this head only by a doc-comment rewording in ndjson_comparator.rs and a line wrap in lib.rs:

  • clippy -D warnings: 0
  • cargo-anneal --lib: 215/215
  • ndjson_comparator_e2e (v4.35 required): 5/5
  • target_audit: 43/43
  • boundary_audit: 60/60
  • anneal-audit --require-correspondence: replay true, 15734 declarations / 2191 kernel, correspondence 3039, Miri 39088, axioms {propext, Classical.choice, Quot.sound}
  • anneal/ci unittest: 320 OK
  • regenerate_bundle --check: 0. check_todo/check_actions (root and anneal/) OK, root-manifest.sha256 4/4, git diff --check clean.

On this head: clippy -D warnings 0, comparator unit tests 22/22, check_pr_hygiene.py passes, git diff --check clean.

Gate-1 (cross-family, read-only) on the delta: PASS, 0 P0/P1/P2, 2 P3. Both P3s are fixed in this head: the stale verify_ndjson_structure doc comment and the over-long lib.rs line.

Not exercised: real zerocopy items on the NDJSON route; the end-to-end tests use synthetic fixtures. Compiler-override attributes on Proof declarations are still not inspected, as disclosed in the receipt deferred list, the docs and the commit body.

Human review surface

  • trusted/cargo-anneal/src/ndjson_comparator.rs: CANONICAL_ROOTS, canonical_crate_ctor, build_canonical_claim_expr, step 5 of verify_ndjson_structure, and the new test.
  • ci/run_anneal_check.sh: SpecPreflight archive parity with flake.nix.
  • Conflict resolutions: trusted/cargo-anneal/src/lib.rs, trusted/cargo-anneal/src/stage.rs, tests/audit/tests/target_audit.rs, trusted/root-manifest.sha256.
  • docs/auditing-and-comparator.md and the commit body.
  • Everything else matches the R4-CLEAN head 511f61c0fb5e line for line.

@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 (tier2a_core_tcb, Round 5)

  • Identity: multi:d94f400cdfaa0ec820522d30ed7647af5b4ca509:8e3f09c4fc64439944b75b58d3b926bba3048599 (base=d94f400cdfaa, head=8e3f09c4fc64, tree=a9ddc8c4af91)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 24 inspected, 0 inapplicable, 0 blocked (of 24 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 2 672s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 3 1514s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 1678s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R5-01 P1 1 (seat2) static_verified anneal/ci/check_guard_mutation.py:1584 Adding SpecPreflight.lean guard targets to check_guard_mutation.py without adding anneal/trusted/audit/SpecPreflight.lean to anneal-guard-mutation inputs in ci/checks.toml breaks the hermetic ci-core check and omits SpecPreflight.lean from its cache key.
G2-R5-02 P1 1 (seat2) static_verified anneal/flake.nix:338 Adding targetSpecPreflight = ./trusted/audit/SpecPreflight.lean to anneal/flake.nix without seeding it in ci/docker/anneal-tc.Dockerfile breaks anneal-tc image builds during nix eval.
G2-R5-03 P2 1 (seat1) static_verified anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:333 No test shows that any external kernel (nanoda_bin, con-ron, con-leche, lean4lean) rejects an ill-typed proof export in its configured invocation, although these kernels are the sole type checkers on the comparator route.
G2-R5-04 P2 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/stage.rs:3961 Unpinned-mode process-global caches init_primitives_cache and sysroot_consts_cache omit sysroot .olean part_hashes from their cache keys, allowing stale trusted sysroot pins and inventories across multi-run callers in one process.
G2-R5-05 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/verify.rs:2454 The Review Receipt's Human review surface reports 'Policy relaxations: none', but on Lean v4.35+ with --allow-unpinned-lean the comparator route drops the legacy fail-closed rejection of compiler overrides on reached Proof-module declarations and the anti-vacuity specification lint.

G2-R5-01 [P1] (anneal/ci/check_guard_mutation.py:1584, Pass 2 §5 (CI scripts and ci-core input/cache manifest), static_verified): Adding SpecPreflight.lean guard targets to check_guard_mutation.py without adding anneal/trusted/audit/SpecPreflight.lean to anneal-guard-mutation inputs in ci/checks.toml breaks the hermetic ci-core check and omits SpecPreflight.lean from its cache key.

  • Invariant: ci/checks.toml inputs must mount and hash every file read by a check so ci-core neither fails on missing mounted files nor serves stale cached passes for unmonitored TCB edits.
  • Evidence: anneal/ci/check_guard_mutation.py:1584-1627 adds four AuditHeaderGuard entries with target_file='trusted/audit/SpecPreflight.lean', and run_guard_mutation_suite (anneal/ci/check_guard_mutation.py:2317-2332) compiles trusted/audit/SpecPreflight.lean. However, ci/checks.toml:1052-1077 ([[checks]] id = 'anneal-guard-mutation') lists 'anneal/trusted/audit/TrustedBoundary.lean' at line 1068 and omits 'anneal/trusted/audit/SpecPreflight.lean'. Because ci-core mounts only declared inputs and keys caching on inputs, anneal-guard-mutation cannot access SpecPreflight.lean at runtime and future SpecPreflight.lean-only edits would not invalidate its cache.

G2-R5-02 [P1] (anneal/flake.nix:338, Pass 2 §4/§5 (flake.nix and ci-core image build), static_verified): Adding targetSpecPreflight = ./trusted/audit/SpecPreflight.lean to anneal/flake.nix without seeding it in ci/docker/anneal-tc.Dockerfile breaks anneal-tc image builds during nix eval.

  • Invariant: Every ./ path literal referenced by anneal/flake.nix derivations evaluated by nix eval must exist in ci/docker/anneal-tc.Dockerfile's synthetic /tmp/anneal-seed/anneal/ seed tree.
  • Evidence: anneal/flake.nix:338 adds targetSpecPreflight = ./trusted/audit/SpecPreflight.lean inside packages.${system}.omnibus-archive. Because anneal/flake.nix is listed in [images.anneal-tc].context (ci/checks.toml:141), this PR triggers rebuilding ci/docker/anneal-tc.Dockerfile, which touches synthetic seed files at ci/docker/anneal-tc.Dockerfile:88-104 (including trusted/audit/TrustedBoundary.lean at line 90) without SpecPreflight.lean, and then evaluates all packages and devShells via nix eval --apply 'builtins.mapAttrs (: builtins.mapAttrs (: pkg: pkg.drvPath))' (ci/docker/anneal-tc.Dockerfile:129-132). Static scan confirmed ./trusted/audit/SpecPreflight.lean is the only flake.nix seed literal absent from ci/docker/anneal-tc.Dockerfile, causing nix eval to fail on the missing path.

G2-R5-03 [P2] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:333, Pass 2 §3 (trusted/cargo-anneal) test sensitivity, static_verified): No test shows that any external kernel (nanoda_bin, con-ron, con-leche, lean4lean) rejects an ill-typed proof export in its configured invocation, although these kernels are the sole type checkers on the comparator route.

  • Invariant: trust-review Pass 2 §3 mandatory negative tests and anti-vacuity: every negative security test must fail if its target guard is disabled; the comparator route must not record a kernel as passed without evidence that it checks the export.
  • Evidence: verify_ndjson_structure (target.rs:1541) checks only structure and identity. Type-correctness of proof_full rests on run_ndjson_nanoda, run_ndjson_con_ron and the quorum kernels (target.rs:1557-1595; invocation flags stage.rs:4396 '--verified', stage.rs:4476 '--import'). Every adversarial case in scalar_ndjson_comparator_rejects_adversarial_proofs (wrong statement, custom axiom, opaque, partial, sorry, Trusted.*) is rejected by the Rust comparator before any kernel runs. The synthetic test writes '#!/bin/sh\nexit 0' for nanoda_bin and con-ron (lines 843-845) and asserts kernelsPassed == [nanoda_bin, con-ron] (line 897). Replacing any kernel with /bin/true, or misconfiguring its CLI so it checks nothing, would pass the whole suite while receipts claim dual- or four-kernel coverage. Fix: add a negative test with a hand-crafted ill-typed but structurally valid proof_full fed to each kernel, expecting rejection.

G2-R5-04 [P2] (anneal/trusted/cargo-anneal/src/stage.rs:3961, Pass 2 §3 (trusted/cargo-anneal caching & sysroot integrity), static_verified): Unpinned-mode process-global caches init_primitives_cache and sysroot_consts_cache omit sysroot .olean part_hashes from their cache keys, allowing stale trusted sysroot pins and inventories across multi-run callers in one process.

  • Invariant: Cached trusted sysroot NDJSON exports (init_primitives_cone.ndjson) and sysroot constant-to-module inventories (sysrootConsts) must bind their cache key to the cryptographic digests of the actual .olean* artifacts imported by leanexport and SpecPreflight.
  • Evidence: Both caches execute in unpinned mode (adm.sysroot_manifest_sha256 is None because ndjson_tools is only populated under --allow-unpinned-lean). In export_ndjson_init_primitives (anneal/trusted/cargo-anneal/src/stage.rs:3961-3965), sysroot_key falls back to adm.lean_sha256 alone and ignores adm.unpinned_records completely. In collect_sysroot_consts_cached (anneal/trusted/cargo-anneal/src/stage.rs:4005-4016), sysroot_fp hashes only rec.source_sha256 (an Option that is None when src/lean is absent and is never read by SpecPreflight's 'sysroot-consts' .olean import) while omitting rec.part_hashes (which unpinned_sysroot_modules_sha256 in anneal/trusted/cargo-anneal/src/target.rs:1881-1906 already hashes). If sysroot .olean* files are modified under the same prefix and lean binary between Checker runs in the same process, both static caches return stale sysroot data.

G2-R5-05 [P2] (anneal/trusted/cargo-anneal/src/verify.rs:2454, Pass 1 / Human review surface; Pass 2 §3 (trusted/cargo-anneal), static_verified): The Review Receipt's Human review surface reports 'Policy relaxations: none', but on Lean v4.35+ with --allow-unpinned-lean the comparator route drops the legacy fail-closed rejection of compiler overrides on reached Proof-module declarations and the anti-vacuity specification lint.

  • Invariant: AGENTS.md Code Review Rules: every PR's Review Receipt Human review surface must list every intentional policy relaxation (or none); any omission or mischaracterization blocks merge or ready-for-review.
  • Evidence: Legacy target-audit rejects @[implemented_by]/@[extern]/@[csimp] on any logically reached declaration, including those authored by Proof modules via proofExport.overrides (TrustedBoundary.lean:6630-6640, 'Reject authored changes nevertheless'). The comparator only rejects overrides on retained non-Proof target modules (ndjson_comparator.rs:3297-3312; target-consts never loads Proof oleans). verify.rs:2450-2460 defers both the anti-vacuity lint and Proof-module override inspection and omits spec_warnings on this route. The same unpinned flag previously ran both checks via TrustedBoundary. The commit body discloses this, but every Human review surface block in the PR's Review Receipt comments (including the R4 receipt the latest delta receipt defers to) says 'Policy relaxations: none'.

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

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

  • G2-R5-A01 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:48): The live v4.35 comparator e2e tests skip silently unless a v4.35 toolchain is found, and no CI script or workflow sets ANNEAL_REQUIRE_V435 or installs v4.35, so CI never exercises the live leanexport, kernel or SpecPreflight path.
  • G2-R5-A02 [P3] (anneal/trusted/audit/SpecPreflight.lean:1551): Post-import collectTargetConsts does not re-check validateTargetModuleIsModuleConsistency against deserialized data.isModule.
  • G2-R5-A03 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1086): The NDJSON parser accepts empty lines, CRLF and unknown keys inside declaration records, none of which leanexport emits, which leaves room for the Rust comparator and the kernels to read the same bytes differently under a compromised 5b exporter.
  • G2-R5-A04 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1446): NDJSON record parser rejects duplicate keys and unknown top-level keys but allows unexpected extra keys inside nested JSON objects.
  • G2-R5-A05 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:3885): run_sandboxed_leanexport joins mapped paths with ':' in LEAN_PATH, which splits host paths containing ':' under non-bwrap execution tiers.

Executed Sandbox Probes

  • seat3 Pass 1 static hygiene across candidate tree and diff_raw.txt (bwrap --unshare-all): outcome=passed
  • seat3 Root manifest & version/action checks (bwrap --unshare-all): outcome=passed
  • seat3 Mandatory CI workflow permissions/auth/secret-containment checklist: outcome=inapplicable
  • seat3 Python CI unittest suites in bwrap (test_check_bundle_tree, test_check_guard_mutation, test_prebuild_bundled_oleans, test_update_root_manifest, test_workflow_yaml, test_run_anneal_check, test_flake_lock, test_check_non_stable_version, test_ci_workflow, test_perf_tracking): outcome=passed
  • seat3 SpecPreflight vs TrustedBoundary compilation, parity, and adversarial target-consts probes on Lean v4.34.1 in bwrap: outcome=passed
  • seat3 Offline Rust Cargo test check in bwrap: outcome=skipped_missing_prereqs

Comment thread anneal/ci/check_guard_mutation.py Resolved
Comment thread anneal/flake.nix Resolved
@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 8e3f09c to f44bab7 Compare November 25, 2026 10:23
@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R5 fixes and rebase

Gate-2 R5 dispositions

ID Sev Disposition
G2-R5-01 P1 Fixed: ci/checks.toml anneal-guard-mutation declares anneal/trusted/audit/SpecPreflight.lean as an input. Every other check that reads it declares anneal/** or anneal/trusted/**. ci-core verify-repo passes.
G2-R5-02 P1 Fixed: ci/docker/anneal-tc.Dockerfile seeds trusted/audit/SpecPreflight.lean. Every ./ path literal in anneal/flake.nix is now seeded.
G2-R5-03 P2 Fixed: ndjson_kernels_reject_ill_typed_proof_export takes the real proof_full.ndjson from a passing run. All four kernels (nanoda_bin, con-ron, con-leche, lean4lean), invoked exactly as "target-audit" invokes them (through the #[doc(hidden)] hook Checker::run_ndjson_kernels), must accept it. The test then rewrites Proof.verify's value to its own type, which is structurally intact but ill-typed, and all four must reject it. nanoda_bin reports the failed def_eq, and con-ron/con-leche report type mismatch in theorem. lean4lean currently fails while reporting the error, and the runner's panic-marker check turns that into a rejection.
G2-R5-04 P2 Fixed: sysroot_content_key keys both process-wide sysroot caches. It is the pinned manifest digest when one exists; otherwise it hashes the Lean digest plus every admitted unpinned module's .olean*/.ir part digests and source digest. Unit test sysroot_content_key_binds_unpinned_olean_part_digests; with the part digests dropped from the key, the test fails [real measurement].
G2-R5-05 P2 Fixed: the policy relaxations are listed in the Human review surface below.

Verification

Run on 75ec074f994d, which differs from this head only by a type alias that fixes a clippy type_complexity lint:

  • cargo-anneal --lib: 216/216
  • ndjson_comparator_e2e (v4.35 required): 6/6, including the new kernel test
  • target_audit: 43/43
  • boundary_audit: 60/60
  • anneal-audit --require-correspondence: replay true, 18231 declarations / 2191 kernel, correspondence 3039, Miri 39088, axioms {propext, Classical.choice, Quot.sound}
  • regenerate_bundle --check: 0. ci-core verify-repo (190 checks) passed, and root ci unittest OK.

Also on 75ec074f994d: anneal/ci unittest 428 OK; check_todo and check_actions (root and anneal/) OK; root-manifest.sha256 4/4; git diff --check clean. On this head: clippy -D warnings passes and check_pr_hygiene.py passes.

Gate-1 (cross-family, read-only) on the delta: PASS, 0 P0/P1/P2/P3.

Not exercised: real zerocopy items on the NDJSON route (the end-to-end tests use synthetic fixtures). CI does not run the live v4.35 tests because no v4.35 toolchain is installed there.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • R5 delta:
    • trusted/cargo-anneal/src/stage.rs: sysroot_content_key and its two call sites.
    • trusted/cargo-anneal/src/target.rs: Checker::run_ndjson_kernels, a test hook with no production callers.
    • ci/checks.toml and ci/docker/anneal-tc.Dockerfile.
    • tests/cargo-anneal/tests/ndjson_comparator_e2e.rs.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 — CLEAN (tier2a_core_tcb, Round 6)

  • Identity: multi:120fe613cd50a89a3956ca90a2ae43fa47ae5ee0:f44bab78c3bd3072e0cc0ab2c70a2da74f52d872 (base=120fe613cd50, head=f44bab78c3bd, tree=bf9c7bc08be2)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 26 inspected, 0 inapplicable, 0 blocked (of 26 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 2073s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1252s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 2778s

No unresolved P0-P2 findings raised across completed seats.

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

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

  • G2-R6-A01 [P3] (anneal/docs/auditing-and-comparator.md:73): Doc cites crate-inner #![forbid(unsafe_code)], whereas enforcement is module-scoped #[forbid(unsafe_code)] on pub mod ndjson_comparator.
  • G2-R6-A02 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:237): Comparator e2e and kernel-rejection tests return early (pass) when no v4.35.0 toolchain is found, and no CI check sets ANNEAL_REQUIRE_V435, so kernel-level negative tests never run in CI.
  • G2-R6-A03 [P3] (anneal/trusted/audit/SpecPreflight.lean:1573): Identical realized equation theorems declared by two sibling non-Proof modules of incompatible roles are attributed solely to the earlier-loaded module.
  • G2-R6-A04 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2419): render_leanexport_name emits unquoted ASCII words that could collide with Lean reserved keywords if a module declared a keyword-named constant.
  • G2-R6-A05 [P3] (anneal/trusted/cargo-anneal/src/sandbox.rs:1780): If the stdout-sink drain thread disconnects without sending (for example, it panics), stdout is treated as an empty success while the NDJSON sink file may be partial.
  • G2-R6-A06 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:3394): Process-wide compiled_inspector_cache omits inspector stem from its key tuple.

Executed Sandbox Probes

  • seat3 Verified 0 symlinks (120000), 0 submodules (160000), 0 hardlinks, 0 bidi/control characters, 0 TODO tokens, valid Fuchsi: outcome=passed
  • seat3 sha256sum --check --strict trusted/root-manifest.sha256 inside bwrap passed 4/4 entries (Cargo.toml, Cargo.lock, flake.n: outcome=passed
  • seat3 Inside bwrap: ci/check_skills.py exited 0; discover ci/test_*.py passed 32/32; test_check_guard_mutation.py passed 10/10: outcome=passed
  • seat3 Inside bwrap: SpecPreflight.lean and TrustedBoundary.lean matched identically across 70/70 non-divergent shared defs plu: outcome=passed
  • seat3 Inside bwrap: 0 broken relative Markdown links or missing anchors across the 4 changed docs; documented CLI flags, JSON : outcome=passed
  • seat3 Cargo workspace compilation/tests (ndjson_comparator, stage, target, verify, target_audit, ndjson_comparator_e2e), lake : outcome=not_run
  • seat3 No .github/workflows/*.yml files were modified in the 26-file diff.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files were modified in the 26-file diff.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files were modified; ci/checks.toml and ci/docker/anneal-tc.Dockerfile introduce no secrets o: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files or release jobs were modified.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files or third-party Actions references were added or modified.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files were modified.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files or workflow caches/artifacts were modified.: outcome=inapplicable
  • seat3 No .github/workflows/*.yml files were modified; ci/checks.toml adds SpecPreflight.lean to anneal-guard-mutation.inputs a: outcome=inapplicable
  • seat3 seat1-spec-preflight-parity: outcome=confirmed

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch 2 times, most recently from e7c9532 to 564bdbd Compare November 25, 2026 14:06
@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: rebase onto main after #4156

Gate-2 R5 dispositions

ID Sev Disposition
G2-R5-01 P1 Fixed: ci/checks.toml anneal-guard-mutation declares anneal/trusted/audit/SpecPreflight.lean as an input. Every other check that reads it declares anneal/** or anneal/trusted/**. ci-core verify-repo passes.
G2-R5-02 P1 Fixed: ci/docker/anneal-tc.Dockerfile seeds trusted/audit/SpecPreflight.lean. Every ./ path literal in anneal/flake.nix is now seeded.
G2-R5-03 P2 Fixed: ndjson_kernels_reject_ill_typed_proof_export takes the real proof_full.ndjson from a passing run. All four kernels (nanoda_bin, con-ron, con-leche, lean4lean), invoked exactly as "target-audit" invokes them (through the #[doc(hidden)] hook Checker::run_ndjson_kernels), must accept it. The test then rewrites Proof.verify's value to its own type, which is structurally intact but ill-typed, and all four must reject it. nanoda_bin reports the failed def_eq, and con-ron/con-leche report type mismatch in theorem. lean4lean currently fails while reporting the error, and the runner's panic-marker check turns that into a rejection.
G2-R5-04 P2 Fixed: sysroot_content_key keys both process-wide sysroot caches. It is the pinned manifest digest when one exists; otherwise it hashes the Lean digest plus every admitted unpinned module's .olean*/.ir part digests and source digest. Unit test sysroot_content_key_binds_unpinned_olean_part_digests; with the part digests dropped from the key, the test fails [real measurement].
G2-R5-05 P2 Fixed: the policy relaxations are listed in the Human review surface below.

Verification

Run on this head [real measurement]: clippy -D warnings 0, regenerate_bundle --check 0, cargo-anneal --lib 220/220, ndjson_comparator_e2e (v4.35 required) 6/6, anneal/ci unittest 482 OK (with CARGO_TARGET_DIR unset; see below), check_todo OK, root-manifest.sha256 4/4, git diff --check clean, check_pr_hygiene.py passes.

The heavy suites ran on e7c9532b9816, whose patch is identical apart from the lib.rs re-export merge above: target_audit 43/43, boundary_audit 60/60, and anneal-audit --require-correspondence (replay true, 18231 declarations / 2191 kernel, correspondence 3083, Miri 39088, axioms {propext, Classical.choice, Quot.sound}). The same patch on #4156's pre-merge head passed clippy, cargo-anneal --lib 220/220 and the e2e tests 6/6.

anneal/ci: with CARGO_TARGET_DIR set, #4334's test_discover_tools_and_resolve_cli_tools resolves the developer's build directory instead of its fixture. Neither file is touched by this PR.

Not exercised: real zerocopy items on the NDJSON route (the end-to-end tests use synthetic fixtures). CI does not run the live v4.35 tests because no v4.35 toolchain is installed there.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R5 (unchanged by this rebase):
    • trusted/cargo-anneal/src/stage.rs: sysroot_content_key and its two call sites.
    • trusted/cargo-anneal/src/target.rs: Checker::run_ndjson_kernels, a test hook with no production callers.
    • ci/checks.toml and ci/docker/anneal-tc.Dockerfile.
    • tests/cargo-anneal/tests/ndjson_comparator_e2e.rs.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 (tier2a_core_tcb, Round 7)

  • Identity: one:e4296c20d0f485f9b3ff89ee503c6c1e61d66234:4662c12bf5d7474e4719a41c61dc9b956d41e98a:860053d7da41cd8ab539f2a42d0f8f076f79cc48b22008803ebd5b139df1f184 (base=5ef98a084341, head=564bdbd25c85, tree=4662c12bf5d7)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 26 inspected, 0 inapplicable, 0 blocked (of 26 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 520s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 2 2145s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 1 1091s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R7-01 P1 2 (seat2, seat3) static_verified anneal/trusted/cargo-anneal/src/target.rs:1244 NDJSON comparator audit reports omit audit.graph, causing every cargo anneal verify run on the NDJSON route to fail unconditionally with tool_failed (missing or malformed audit.graph metadata).
G2-R7-02 P2 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:3456 build_closure_entries appends synthetic entries for every unreached retained Model module into modelClosure, causing verify.rs to over-report unreached candidate:* features and mark vetted-only or partial-feature receipts as experimental: true.

G2-R7-01 [P1] (anneal/trusted/cargo-anneal/src/target.rs:1244, Pass 2 §4 (trusted/cargo-anneal), static_verified): NDJSON comparator audit reports omit audit.graph, causing every cargo anneal verify run on the NDJSON route to fail unconditionally with tool_failed (missing or malformed audit.graph metadata).

  • Invariant: Every Checker::run_target report consumed by verify.rs must provide audit.graph so validate_and_extract_candidate_features (verify.rs:2306-2308, 2601-2657) can enforce the vetted -/-> candidate:* bundled-model import boundary and emit a receipt, matching TrustedBoundary.lean:6660.
  • Evidence: verify::run calls checker.run_target(&audit_request) at anneal/trusted/cargo-anneal/src/verify.rs:2244 and immediately calls validate_and_extract_candidate_features(&audit, &model_tiers, &model_modules) at lines 2306-2308. At lines 2606-2608, validate_and_extract_candidate_features returns Err(error("tool_failed", "audit", "missing or malformed audit.graph metadata")) unless audit.get("graph") is a JSON object. When self.admitted()?.ndjson_tools.is_some() (target.rs:1242-1244), audit_target_ndjson serializes NdjsonAuditVerdict (ndjson_comparator.rs:2034-2072, target.rs:1628-1680), which omits graph, and run_target (target.rs:1267-1371) only inserts moduleIdentities, bindings, sources, toolchain, and unpinnedLean. Although verify.rs:2464 detects auditMode == "ndjson_comparator" to skip extract_spec_warnings at lines 2538-2542, it does not guard line 2307 or populate audit.graph in target.rs. In anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs, every test invokes Checker::run_target directly without calling verify::run.

G2-R7-02 [P2] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:3456, Pass 2 §4 (trusted/cargo-anneal), static_verified): build_closure_entries appends synthetic entries for every unreached retained Model module into modelClosure, causing verify.rs to over-report unreached candidate:* features and mark vetted-only or partial-feature receipts as experimental: true.

  • Invariant: audit.modelClosure must contain only declarations logically reached from the claim's model roots (TrustedBoundary.lean:6642-6654), because verify.rs:2599-2600, 2658-2679 (tested at verify.rs:4878-4921) computes receipt candidate_features, experimental, and assumptions (verify.rs:2444-2446) directly from modules appearing in audit.modelClosure while excluding unreached candidate modules.
  • Evidence: anneal/trusted/cargo-anneal/src/verify.rs:2050-2065 registers every bundled trusted/lean/*.lean module with TargetRole::Model, and anneal/trusted/cargo-anneal/src/target.rs:220 (reachable_target_modules) retains all non-Proof modules as seeds, so target.rs:1414-1415 puts all bundled Model modules (both vetted and all candidate:* modules, including unreached modules such as Trusted.MirSemantics.CanaryFixtures and any future candidate:<feature> modules) into req.model_modules. anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:3325-3331 passes req.model_modules into build_closure_entries, whose loop at lines 3456-3460 unconditionally inserts ClosureEntry { name: m.clone(), module: m.clone() } for every m not in covered_modules. This pollutes audit.modelClosure with synthetic non-declaration entries for unreached modules, drags those modules into moduleIdentities (target.rs:1275-1334), and causes validate_and_extract_candidate_features (verify.rs:2658-2679) to report every bundled candidate:* tier as reached.

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

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

  • G2-R7-A01 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:373): The only test that each external kernel, as invoked, rejects an ill-typed proof export (plus all other live-kernel e2e tests) returns early unless a v4.35 toolchain exists, and no CI job sets ANNEAL_REQUIRE_V435.
  • G2-R7-A02 [P3] (anneal/trusted/audit/TrustedBoundary.lean:2091): The new specification namespace guard now also rejects root-level declarations and namespace entry under Nat/List/Option/etc. on the pinned v4.34.1 path; specs that opened those namespaces will now be rejected.
  • G2-R7-A03 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2412): render_leanexport_name writes numeric components as bare digits (e.g. _private.Spec.0.helper); if leanexport does not decode them back to Name.num, honest specs using private def fail closed on the comparator route.

Executed Sandbox Probes

  • seat3 git_mode_unicode_todo_fuchsia_header_scan: outcome=passed
  • seat3 root_manifest_sha256_check_bwrap: outcome=passed
  • seat3 anneal_ci_python_unittests_bwrap: outcome=passed
  • seat3 spec_preflight_compile_v434_and_v435_bwrap: outcome=passed
  • seat3 check_guard_mutation_spec_preflight_mutants_bwrap: outcome=passed
  • seat3 spec_preflight_reserved_namespace_and_target_consts_bwrap: outcome=passed
  • seat3 ndjson_four_kernel_valid_and_ill_typed_probe_bwrap: outcome=passed
  • seat3 check_pr_hygiene_bwrap: outcome=passed
  • seat3 check_bundle_tree_lean_only_source_tree_probe: outcome=inapplicable
  • seat3 github_workflows_security_checklist: outcome=inapplicable
  • seat3 verify_run_audit_graph_static_falsification: outcome=failed

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 564bdbd to 42f989d Compare November 25, 2026 17:48
@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R7 fixes, rebased onto main after #4184

Gate-2 R7 dispositions

ID Sev Disposition
G2-R7-01 P1 Fixed: NdjsonAuditVerdict now carries graph, the admitted module import graph (adm.graph). TrustedBoundary.lean's "target-audit" report must equal that same graph (validate_target_audit_report). validate_ndjson_verdict also requires every closure module to be a node of the graph. The live v4.35 e2e passes the comparator report to verify's own audit-metadata checks: validate_and_extract_candidate_features (via the new check_bundled_model_audit hook) and validate_sorry_declarations. It requires Ok(["mir_ast", "mir_semantics"]) rather than tool_failed, and it checks every unpinnedLean field that verify reads. With an empty graph, the synthetic CI-run e2e is rejected [real measurement].
G2-R7-02 P2 Fixed: the synthetic per-module closure entries are gone, along with the now-unused capture_modules/model_modules/specification_modules request fields. The closures follow TrustedBoundary.lean: the model and specification closures start from that role's declarations reached by the expected claim, and the subject closure starts from the subject. Every reached constant is attributed to its defining module, and a missing origin fails closed. Tests: the unit test reports_only_reached_declarations_in_role_closures adds an unreached model module. The synthetic e2e adds an unreached TargetRole::Model module Trusted.Unused and checks that it is absent from every closure and from moduleIdentities. The live e2e checks the same for the imported but unreached Trusted.MirSemantics.CanaryFixtures. With the synthetic entries restored, both the unit test and the synthetic e2e fail [real measurement].
G2-R7-A01 P3 Partly addressed: CI still has no v4.35 toolchain, but the CI-run synthetic e2e now covers the graph and closure shape.
G2-R7-A02, A03 P3 Not changed. A02 is the intended stricter namespace guard. A03 fails closed: a mis-rendered numeric name component makes the export abort.

Verification

All of the following are [real measurement].

  • On 42f989d4b:
    • regenerate_bundle --check: 0.
    • clippy -D warnings: 0.
    • cargo-anneal --lib: 221/221.
    • ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e: 6/6.
    • target_audit: 43/43.
    • anneal/ci unittest: 482 OK.
    • ci-core verify-repo: passed (191 checks).
    • boundary_audit and anneal-audit are still running on this head; I'll post their results as a follow-up.
  • On da7e40bdc, the same patch on 5fb7723f3:
    • ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e: 6/6.
    • clippy -D warnings: 0.
    • The suite below ran on 5c76756b1, whose non-test sources equal da7e40bdc's: cargo-anneal --lib 221/221, regenerate_bundle --check 0, target_audit 43/43, and boundary_audit 60/60.
    • anneal-audit --require-correspondence: replay true; 19060 declarations (2191 kernel); correspondence 3083; Miri 39088; axioms {propext, Classical.choice, Quot.sound}.
    • anneal/ci unittest: 482 OK.
    • ci-core verify-repo: passed (191 checks).
    • check_todo ×2 and check_actions ×2: 0.
    • root-manifest.sha256: 4/4 OK.
    • git diff --check: clean.
  • Gate-1: a cross-family read-only reviewer on da7e40bdc returned PASS P0=0 P1=0 P2=0 P3=0.

Not exercised: real zerocopy items on the NDJSON route, since the e2e tests use the scalar and synthetic fixtures. A full cargo anneal verify CLI run on v4.35 was not exercised either; the e2e covers verify's audit-metadata checks through the hook.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R7 (564bdbd25c85):
    • trusted/cargo-anneal/src/ndjson_comparator.rs: NdjsonAuditVerdict.graph, the closure-module graph check in validate_ndjson_verdict, build_closure_entries, the closure roots in verify_ndjson_structure, and the removed StructuralCompareRequest role-module fields.
    • trusted/cargo-anneal/src/target.rs: the verdict's graph and the removed role-module vectors.
    • trusted/cargo-anneal/src/verify.rs: bundled_model_tier (shared with run) and the #[doc(hidden)] test hook check_bundled_model_audit; lib.rs re-exports it.
    • tests/cargo-anneal/tests/ndjson_comparator_e2e.rs and docs/auditing-and-comparator.md.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 (tier2a_core_tcb, Round 8)

  • Identity: multi:98ef27b42cdd4faa428daceff6a0a777d5b0f30d:42f989d4b9dee814e4bd3b84f5f93c289cdb3d74 (base=98ef27b42cdd, head=42f989d4b9de, tree=77b467a35b9e)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 26 inspected, 0 inapplicable, 0 blocked (of 26 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 562s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1839s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 1 762s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R8-01 P1 1 (seat3) probe_confirmed anneal/trusted/cargo-anneal/src/stage.rs:4454 run_ndjson_con_leche omits --jobs=<n>, causing --paranoid-quorum to abort with thread-creation EAGAIN under address-space limits on high-core-count hosts.

G2-R8-01 [P1] (anneal/trusted/cargo-anneal/src/stage.rs:4454, Pass 2 §3 (trusted/cargo-anneal), probe_confirmed): run_ndjson_con_leche omits --jobs=<n>, causing --paranoid-quorum to abort with thread-creation EAGAIN under address-space limits on high-core-count hosts.

  • Invariant: --paranoid-quorum must reliably run con-leche inside ExecSeal across supported host environments, bounding worker virtual-memory reservations consistently with run_ndjson_con_ron and con-leche's documented --jobs=<n> guidance.
  • Evidence: In anneal/trusted/cargo-anneal/src/stage.rs, run_ndjson_con_ron (lines 4424-4431) caps workers via default_compile_workers(2).min(4) and passes vec!["--verified".to_string(), format!("--jobs={jobs}")], whereas run_ndjson_con_leche (lines 4449-4456) passes Vec::new(). con-leche --help documents that --jobs defaults to hardware thread count and each worker reserves ~1 GiB of virtual address space (failed to create thread under ulimit -v). In isolated bwrap probes on a 96-core host: (1) ndjson_kernels_reject_ill_typed_proof_export (live v4.35.0, prlimit --as=68719476736) passed nanoda_bin and con-ron, then failed in run_ndjson_con_leche with exit Some(139): libc++abi: terminating due to uncaught exception of type lean::exception: failed to create thread: Resource temporarily unavailable; (2) a two-sided bwrap probe on a 267-declaration Init.Core NDJSON export under both 16 GiB and 64 GiB RLIMIT_AS failed with [] (rc=-6) and succeeded with ['--verified', '--jobs=4'] (rc=0, con-leche: accepted 267 declarations (--verified)).

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

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

  • G2-R8-A01 [P3] (anneal/ci/test_check_guard_mutation.py:448): The parity test exempts preflightSpecs and inspectHeader without checking that they differ only in the header-syntax call, so a later SpecPreflight edit could drop a check from those entry points without failing CI.
  • G2-R8-A02 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:403): The real-kernel e2e tests (including the ill-typed-export rejection test the commit body cites) return early unless a v4.35 toolchain is installed, and no CI lane sets ANNEAL_REQUIRE_V435=1, so kernel rejection behaviour is never exercised in CI.
  • G2-R8-A03 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:3278): Check is_sysroot_id(arena, cid) alongside expected_cone_set.contains(&cid) when admitting sorryAx references under allow_sorry_in_proof for strict parity with TrustedBoundary.lean.
  • G2-R8-A04 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:3881): On the unpinned comparator route, leanexport and kernel binaries are hashed before and after execution but run by path, so a swap during execution followed by a restore would not be detected.
  • G2-R8-A05 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:4383): run_ndjson_standalone_kernel classifies libc++abi: terminating due to uncaught exception aborts as Failure::policy (code: 1) instead of an operational error (code: 2).

Executed Sandbox Probes

  • seat3 pass1_static_hygiene_and_root_manifest: outcome=passed
  • seat3 workflow_permissions_checklist: outcome=inapplicable
  • seat3 bwrap_python_ci_unit_tests: outcome=passed
  • seat3 bwrap_spec_preflight_v434_v435: outcome=passed
  • seat3 bwrap_rust_ndjson_comparator_unit_and_synthetic_e2e: outcome=passed
  • seat3 bwrap_target_audit_spec_preflight_v434: outcome=partial_timeout
  • seat3 bwrap_live_v435_ndjson_kernels_and_con_leche_two_sided: outcome=failed_confirmed_finding

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 42f989d to aa06e34 Compare November 25, 2026 20:44
@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R8 fix, rebased onto main after #4341

Gate-2 R8 dispositions

ID Sev Disposition
G2-R8-01 P1 Fixed. A private exhaustive StandaloneNdjsonKernel enum now supplies each standalone kernel's label and arguments, and run_ndjson_standalone_kernel derives both from it. con-ron and con-leche get --verified --jobs={default_compile_workers(2)}; that is the same value con-ron used before, and --verified is con-leche's documented default. lean4lean keeps --import. Unit test: arena_ndjson_kernels_run_verified_with_capped_jobs. Reproduced on a 96-core host under prlimit --as=68719476736 [real measurement]: with con-leche given no arguments, ndjson_kernels_reject_ill_typed_proof_export fails (exit 139, "failed to create thread"). With the fix, all six ndjson_comparator_e2e tests pass under the same limit, and every kernel accepts the well-typed export and rejects the ill-typed one.

Verification

All results below are [real measurement].

  • On aa06e3436:
    • clippy -D warnings: 0.
    • cargo-anneal --lib: 225/225.
    • ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e under prlimit --as=64G: 6/6.
  • On 91977d5ba, which differs only by the behavior-preserving enum refactor of the same fix:
    • regenerate_bundle --check: 0.
    • clippy: 0.
    • lib: 225/225.
    • e2e: 6/6.
    • target_audit, boundary_audit, anneal-audit, and anneal/ci are still running; results will follow only on failure. On the previous head 42f989d4b, all of them passed: target_audit 43/43, boundary_audit 60/60, anneal-audit (replay, correspondence 3086, and Miri 39088 all true), and anneal/ci 482 OK.
  • Gate-1: a cross-family read-only reviewer returned PASS with P0=P1=P2=P3=0 on aa06e3436. Its one P3 on 91977d5ba, the catch-all label arm, was fixed by the enum.

Not exercised: real zerocopy items on the NDJSON route (the e2e tests use the scalar and synthetic fixtures), and a full cargo anneal verify CLI run on v4.35.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R8 (42f989d4b9de): trusted/cargo-anneal/src/stage.rs: StandaloneNdjsonKernel and its uses in run_ndjson_{con_ron,con_leche,lean4lean} and run_ndjson_standalone_kernel, plus one commit-message sentence.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 (tier2a_core_tcb, Round 9)

  • Identity: multi:b6eae9a57aaccf9f35b23e629162026ffb405f0f:aa06e34365877e5b95bfdcafcf2156cec4a7b6b9 (base=b6eae9a57aac, head=aa06e3436587, tree=211fb5fb5c8a)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 26 inspected, 0 inapplicable, 0 blocked (of 26 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 1 526s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1271s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 2778s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R9-01 P2 1 (seat1) static_verified anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2570 Open trust question: the NDJSON comparator checks that exports include every constant they depend on, but not that declarations only reference earlier ones, and it drops inductive-record grouping, so soundness against injected cyclic theorems or malformed inductive records rests on unverified external kernel loader behaviour.

G2-R9-01 [P2] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:2570, Pass 2 §3 (trusted/cargo-anneal), static_verified): Open trust question: the NDJSON comparator checks that exports include every constant they depend on, but not that declarations only reference earlier ones, and it drops inductive-record grouping, so soundness against injected cyclic theorems or malformed inductive records rests on unverified external kernel loader behaviour.

  • Invariant: On the comparator route the Rust comparator plus external kernels replace TrustedBoundary's in-order kernel replay. A proof export must be well-founded (each constant references only earlier declarations or its own mutual block), and the inductive blocks the kernels load must be exactly those the comparator vetted.
  • Evidence: check_export_closed (L2570-2593) only tests env.constants.contains_key(dep) and never compares positions in const_order; insert_const appends to const_order (L1413) with no order check elsewhere. The inductive parser (L1824 onward) splits types/ctors/recs into separate Induct/Ctor/Rec constants without checking that the record's types match each type's all list, that every ctor is listed in some type's ctors with a matching induct, or that recursors belong to the record. Trigger: Proof modules are untrusted Lean and may add environment declarations without kernel checking (e.g. in-source set_option debug.skipKernelTC or a metaprogram calling addDeclWithoutChecking), so the sandboxed leanexport can emit theorem T : Expected.claim := A and theorem A : Expected.claim := T. The step-7 type check (L3118-3165) passes because T's declared type is Expected.claim, and the comparator does not unfold values. Whether nanoda_bin (multi-threaded, stage.rs config) and con-ron --verified reject forward or cyclic references and orphan constructors is undocumented and not exercised by the ill-typed-export kernel test. The route is reachable only under --allow-unpinned-lean (tainted receipts). Resolving check: add a const_order precedence check plus an inductive record consistency check in 5c, or cite the pinned kernels' loader semantics and add two-theorem-cycle and orphan-constructor negative tests.

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

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

  • G2-R9-A01 [P3] (anneal/ci/test_check_guard_mutation.py:416): Parity test regex compares only column-0 def blocks; future shared structure/abbrev/instance or one-line @[attr] def guards would drift silently (ParseScope is currently uncompared).
  • G2-R9-A02 [P3] (anneal/tests/audit/tests/target_audit.rs:2195): The ns-root-trusted vector cannot fail if the root stripping in rejectForbiddenSpecDeclNamespace is removed, because isValidSourceIdent rejects root first with a message containing the same substring; the Internal.UV/Dynlib vectors similarly pin the older guard.
  • G2-R9-A03 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:10): Module doc says the comparator is 'default-ON on Lean v4.35.0+', but it is gated on --allow-unpinned-lean.
  • G2-R9-A04 [P3] (anneal/trusted/audit/TrustedBoundary.lean:160): Review Receipt Human review surface says pinned v4.34.1 runs are unaffected, but the stricter spec-namespace guard also applies to pinned runs (a tightening, disclosed in the commit body).
  • G2-R9-A05 [P3] (anneal/trusted/audit/TrustedBoundary.lean:1909): The modified spec admission guard is tested in target_audit.rs rather than boundary_audit.rs as base AGENTS.md literally requires; coverage exists and follows existing spec-preflight test precedent, but only about 6 of about 60 reserved roots are pinned by tests.
  • G2-R9-A06 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1086): parse_ndjson_reader silently skips internal blank lines rather than failing closed on non-JSON empty lines.
  • G2-R9-A07 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1701): Unknown keys inside declaration payload objects are silently ignored, unlike the strictness applied to top-level records; a kernel honouring an extra field could diverge from what the comparator vetted.
  • G2-R9-A08 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:60): In-memory InspectorCacheKey omits the inspector module stem (TrustedBoundary vs SpecPreflight) that OleanCacheKeyInput includes.
  • G2-R9-A09 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:3919): check_pr_hygiene.py emitted 7 non-blocking inline-code-span line-wrap warnings across 5 touched files.
  • G2-R9-A10 [P3] (anneal/trusted/cargo-anneal/src/verify.rs:2415): Receipt v3 lean_assumption lists only (nanoda_bin / con-ron) even when --paranoid-quorum runs con-leche and lean4lean.

Executed Sandbox Probes

  • seat3 root-manifest.sha256 integrity (sha256sum --check --strict trusted/root-manifest.sha256 inside bwrap): outcome=pass
  • seat3 Shell syntax check (bash -n /work/anneal/ci/run_anneal_check.sh inside bwrap): outcome=pass
  • seat3 PR-relevant Python CI unit test suites (8 modules inside bwrap --unshare-all --clearenv): outcome=pass
  • seat3 Base check_pr_hygiene.py (b6eae9a..aa06e34inside bwrap against non-bare/tmp/probe/repobacked by/pr.git + alternates): outcome=pass
  • seat3 Adversarial check_bundle_tree.verify_bundle_tree SpecPreflight enforcement inside bwrap: outcome=pass
  • seat3 Adversarial test_spec_preflight_parity_with_trusted_boundary sensitivity + guard mutation anchor check inside bwrap: outcome=pass
  • seat3 Cross-file Lean/Rust TCB parity and spec_warnings consumer scan inside bwrap: outcome=pass
  • seat3 Minimal rustc compile + run probe inside bwrap (rustc 1.98.0-nightly 2026-05-31): outcome=pass
  • seat3 ``test_ci_workflow.pysubset inside bwrap (excludingtest_root_override_paths_and_symlinks_fail_closed`)`: outcome=`partial_timeout`
  • seat3 Host Lean v4.34.1 runtime check inside bwrap (--versionandlean -j1 --stdin): outcome=blocked_by_host_limits
  • seat3 Workflow Permissions Checklist #1: Top-level and per-job permissions:least-privilege across touched.github/workflows/*.yml``: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #2: No pull_request_target/workflow_run/issue_comment executing untrusted code with secrets/write tokens: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #3: secrets.*/GITHUB_TOKEN exposure and no echo/$GITHUB_ENV/$GITHUB_OUTPUT/artifact leaks: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #4: Release/publish jobs gated by protected environment:``: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #5: actions/checkout persist-credentials: false and full commit-SHA third-party action pinning: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #6: No ${{ github.event.* }}/${{ inputs.* }}shell script injection inrun:``: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #7: Cache key/restore-key trust isolation and artifact verification: outcome=not_applicable
  • seat3 Workflow Permissions Checklist #8: No relaxation of existing workflow/CI guards (permissions, environment, cache, if:): outcome=pass

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from aa06e34 to c32ecde Compare November 25, 2026 23:57
@joshlf

joshlf commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R9 fix, rebased onto main after #4215

Gate-2 R9 dispositions

ID Sev Disposition
G2-R9-01 P2 Fixed. check_export_well_formed requires every export to declare each required dependency strictly earlier. The only exemption is references within the same "inductive" record; self-references are rejected too. A missing, forward, cyclic, or self reference fails closed. check_inductive_block requires each record to be a consistent mutual block:
• each type's all is exactly the record's types, with shared universes and parameter counts;
• the types' constructor lists concatenate to exactly the record's constructors;
• each constructor's induct, cidx, parameters, and universes match its position;
• there is at least one recursor, and each recursor's all is the record's types;
• rule constructors are the record's constructors, or, for a nested block's auxiliary recursors, constructors.
Tests: rejects_forward_and_cyclic_references_in_exports covers forward, cyclic, and self (def and thm) references in proof_full, plus a reordered expected_cone. checks_inductive_record_consistency covers 7 malformed records (orphan constructor, wrong cidx, all mismatch, orphan recursor, foreign rule constructor, nested non-constructor rule, missing recursor). Disabling the order check or the record check makes the corresponding test fail [real measurement]. The live v4.35 end-to-end tests pass real leanexport streams through both checks. The checks follow LeanExport/Basic.lean dumpConstant, which emits dependencies first and each inductive block as a unit.

Additional fix: cargo anneal inspect (#4220) and the comparator's receipts

Gate-1 found that cargo anneal inspect rejected every NDJSON-comparator receipt, for three reasons:

  • It required checkedAlternateProofs.
  • It read kernelsSkipped only as strings.
  • It treated the comparator's digest fields as unrecognized.

When auditMode == "ndjson_comparator", schema.rs now validates the comparator's counts, its SHA-256 digests (the quorum digests are optional), and timingMs. It reads kernelsSkipped entries as either strings or {kernel, reason}, and defaults checkedAlternateProofs to 0. Outside that mode, the fields stay unrecognized and checkedAlternateProofs stays required. diff.rs ranks a drop from the comparator to the default audit as Tier A. Test: accepts_ndjson_comparator_receipts_and_validates_their_fields.

Verification

All of the following are [real measurement].

On the verified tree 0f0d62607ccc:

  • Static and unit checks: clippy -D warnings 0; cargo-anneal --lib 258/258; regenerate_bundle --check 0.
  • End-to-end: ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e under prlimit --as=64G: 6/6.
  • Suites: target_audit 43/43; boundary_audit 61/61.
  • anneal-audit --require-correspondence: replay, correspondence (4116 declarations), and Miri (39088) all true; 22962 replayed declarations; axioms {propext, Classical.choice, Quot.sound}.
  • Repo checks: ci-core verify-repo passed with 191 checks; root-manifest.sha256 4/4; git diff --check clean.

Caveat on target_audit: it was built before the final delta to ndjson_comparator.rs and core/inspect, which neither touches nor exercises. The other suites ran on the final sources.

Gate-1, from a cross-family read-only reviewer:

  • First round: FAIL with P2=2 and P3=2. The two P2s were the self-reference exemption and the inspect conflict.
  • After the fixes: PASS with P0=P1=P2=P3=0. The reviewer independently ran cargo anneal inspect --passive --unknown-fields deny on real comparator receipts and checked the wasm32-unknown-unknown build.

Not exercised: real zerocopy items on the NDJSON route, because the end-to-end tests use the scalar and synthetic fixtures. The anti-vacuity badge for comparator receipts is deferred until a v4.35 toolchain is pinned; today every comparator run is already tainted as unpinned_lean.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R9 (aa06e3436):
    • trusted/cargo-anneal/src/ndjson_comparator.rs: InductiveBlock, ExportedEnv.inductive_blocks, check_export_well_formed (replacing check_export_closed), and check_inductive_block.
    • trusted/cargo-anneal/src/core/inspect/schema.rs: the gated ndjson_comparator audit fields and parse_skipped_kernels.
    • trusted/cargo-anneal/src/core/inspect/diff.rs: mode_rank.
    • docs/auditing-and-comparator.md and the commit message.
    • The resolutions of the rebase conflicts with [cargo-anneal] Add human verdict card, --receipt-out, and TTY UX #4215 in lib.rs and verify.rs.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs and trusted/cargo-anneal/src/core/inspect/{schema,diff}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 (tier2a_core_tcb, Round 10)

  • Identity: one:59c578a6bca721334f4865d3509b807b7648ac56:0f0d62607ccc8e3205dc3b8ddfeb956b22ddeb9f:e1f8f136556c50f4af0f53a8706ebb266444b5070dc65df4fe5967089327e0af (base=c69454f044c7, head=c32ecde0755f, tree=0f0d62607ccc)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 28 inspected, 0 inapplicable, 0 blocked (of 28 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 2 1459s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1579s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 1304s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R10-01 P2 1 (seat1) static_verified anneal/ci/test_check_guard_mutation.py:448 The parity test exempts preflightSpecs and no CI-executed test runs SpecPreflight's spec-preflight mode, so SpecPreflight's specification-admission entry point can stop calling parseAndInspectSpecCommands without any CI failure.
G2-R10-02 P2 1 (seat1) static_verified anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:404 Every test that runs a real or rejecting kernel on the comparator route returns early unless a Lean v4.35.0 toolchain is present, which CI neither provisions nor requires, and the only CI-executed pipeline test stubs nanoda_bin and con-ron as exit 0, so the kernel-rejection guards have no CI-executed negative test.

G2-R10-01 [P2] (anneal/ci/test_check_guard_mutation.py:448, Pass 2 §3 (trusted/audit) / Pass 2 §5 (ci/), static_verified): The parity test exempts preflightSpecs and no CI-executed test runs SpecPreflight's spec-preflight mode, so SpecPreflight's specification-admission entry point can stop calling parseAndInspectSpecCommands without any CI failure.

  • Invariant: Every added or modified admission or syntax guard needs a negative test asserting exit code 1 and the diagnostic that fails if the guard is disabled (AGENTS.md Pass 2 trusted/audit; trust-review section 3).
  • Evidence: The divergent set {inspectHeader, preflightSpecs, run, main} only asserts that each name exists in TrustedBoundary.lean. anneal/trusted/cargo-anneal/src/stage.rs:3381 routes headers, spec-preflight and resolve-imports to SpecPreflight only when ndjson_tools is present, which never holds on the pinned CI toolchain, so the spec-preflight negative vectors in anneal/tests/audit/tests/target_audit.rs (line 1676) exercise TrustedBoundary only. The only SpecPreflight spec-preflight negatives (ndjson_comparator_e2e.rs line 547) are v4.35-gated, and the guard-mutation suite covers only SpecPreflight headers mode. Guard removal: deleting the call at anneal/trusted/audit/SpecPreflight.lean:1317-1318 passes the parity test (exempt), the required-definition list (the def still exists), the mutation suite and target_audit. Independent comparison shows the two preflightSpecs bodies differ only in the header-inspection call, so the exemption is wider than the actual divergence.

G2-R10-02 [P2] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:404, Pass 2 §3 (trusted/cargo-anneal orchestrator) / General (test adequacy), static_verified): Every test that runs a real or rejecting kernel on the comparator route returns early unless a Lean v4.35.0 toolchain is present, which CI neither provisions nor requires, and the only CI-executed pipeline test stubs nanoda_bin and con-ron as exit 0, so the kernel-rejection guards have no CI-executed negative test.

  • Invariant: Negative security tests must fail when their target guard is disabled (trust-review section 3 anti-vacuity; change-review non-vacuous tests); the commit message states that a test requires each kernel to reject an ill-typed export.
  • Evidence: discover_v435_lean (lines 48-66) returns None unless ANNEAL_LEAN_V435 or a home elan v4.35.0 toolchain exists; ANNEAL_REQUIRE_V435 and ANNEAL_LEAN_V435 occur nowhere else in the tree and no file under ci/, .github/, anneal/ci/, flake.nix or the tc Dockerfile references a 4.35 toolchain. Skip sites: 236-239, 404-407, 446-449, 548-551, 626-629. The CI-run synthetic test (line 760) writes both kernels as 'exit 0' shell stubs (956-959) and asserts acceptance only. Guard removal: deleting the non-zero-exit rejection blocks in anneal/trusted/cargo-anneal/src/stage.rs (4352-4363 and 4441-4452), the copy_verified_kernel_input digest check (stage.rs 216-231), or the incomplete-tool fail-closed branch in toolchain.rs discover_ndjson_comparator_tools leaves every CI-executed test green. The con-ron/con-leche invocation with --verified --jobs=N differs from the flagless bundledKernels invocation in upstream Lake/CLI/Check.lean at the cited pinned commit, so its effect is validated only by the skipped tests. The author's receipt reports a manual ANNEAL_REQUIRE_V435=1 run, which is not a merge gate.

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

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

  • G2-R10-A01 [P3] (anneal/docs/auditing-and-comparator.md:73): Documentation spells the safety attribute as crate-level #![forbid(unsafe_code)] while lib.rs applies module-level #[forbid(unsafe_code)] to ndjson_comparator.
  • G2-R10-A02 [P3] (anneal/docs/testing-architecture.md:119): Overview tree comment still says 84 guards for check_guard_mutation.py after adding 4 spec_preflight_* guards.
  • G2-R10-A03 [P3] (anneal/trusted/cargo-anneal/src/core/inspect/schema.rs:1726): parse_ndjson_comparator_audit validates digest formats without cross-checking paranoidQuorum against quorum kernel digests/kernelsPassed or traversing timingMs subkeys.
  • G2-R10-A04 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:109): Two pinned upstream citations in the trusted module docs do not match the cited commit: CollectAxioms does traverse opaque bodies, and Expr equality does compare let nondep and mdata.
  • G2-R10-A05 [P3] (anneal/trusted/cargo-anneal/src/sandbox.rs:2553): Tier 1 bwrap and Tier 2 Landlock reuse PT_INTERP and /nix/store settings probed solely from exec_lean rather than resolving policy.exec_bin.
  • G2-R10-A06 [P3] (anneal/trusted/cargo-anneal/src/stage.rs:4352): A kernel process that dies from a signal or resource limit is reported as a policy rejection (code 1) instead of an operational failure (code 2).

Executed Sandbox Probes

  • seat3 repo_hygiene_and_root_manifest: outcome=passed
  • seat3 ci_python_targeted_suites: outcome=passed
  • seat3 audit_headers_guard_mutation: outcome=passed
  • seat3 spec_preflight_lean_v4_34_1_adversarial_probes: outcome=passed
  • seat3 name_render_round_trip_rustc_and_lean: outcome=passed
  • seat3 check_bundle_tree_and_run_anneal_check_shell_guards: outcome=passed
  • seat3 workflow_checklist_1_permissions: outcome=inapplicable
  • seat3 workflow_checklist_2_triggers: outcome=inapplicable
  • seat3 workflow_checklist_3_secrets: outcome=inapplicable
  • seat3 workflow_checklist_4_release_environments: outcome=inapplicable
  • seat3 workflow_checklist_5_checkout_and_action_pinning: outcome=inapplicable
  • seat3 workflow_checklist_6_script_injection: outcome=inapplicable
  • seat3 workflow_checklist_7_cache_and_artifact_trust: outcome=inapplicable
  • seat3 workflow_checklist_8_guard_relaxation: outcome=inapplicable

Comment thread anneal/ci/test_check_guard_mutation.py Resolved
@joshlf

joshlf commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R10 fixes, rebased onto main after #4234

Gate-2 R10 dispositions

ID Sev Disposition
G2-R10-01 P2 Fixed in two ways. (1) ci/test_check_guard_mutation.py now compares preflightSpecs with TrustedBoundary.lean. One exact substitution is allowed and asserted unique: TrustedBoundary's general header inspectSyntax versus SpecPreflight's inspectHeaderSyntax. preflightSpecs is also required to be among the shared definitions. (2) A #[doc(hidden)] test hook routes only "spec-preflight" to SpecPreflight.lean; production code never sets it. With the hook, spec_preflight_parse_tree_round_trip_and_negative_guards (CI-run, pinned v4.34.1) checks that SpecPreflight admits the base specification during run_target and compiles control/SpecPreflight.olean, and that it rejects all 18 wire samples with TrustedBoundary's reasons. If SpecPreflight's preflightSpecs skips parseAndInspectSpecCommands, both the parity test and the target_audit test fail; the latter accepts a bad sample [real measurement].
G2-R10-02 P2 Fixed. The synthetic pipeline becomes run_synthetic_ndjson_pipeline(nanoda_bin_script, con_ron_script). The new CI-run test synthetic_ndjson_comparator_fails_closed_when_a_stub_kernel_rejects (no v4.35 install needed) requires the comparator route to fail closed in four cases, checking the code, message, and phase each time: nanoda_bin or con-ron exiting 1 (code 1, "<kernel> rejected proof export"), and either kernel exiting 0 with a PANIC at stderr marker (code 2, "Lean runtime panic marker"). With the exit-status checks disabled, the test fails [real measurement].

Verification

Run on tree 2eab4971f7f1 [real measurement]:

  • regenerate_bundle --check: 0
  • clippy -D warnings: 0
  • cargo-anneal --lib: 267/267
  • ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e under prlimit --as=64G: 7/7
  • target_audit: 43/43
  • root-manifest.sha256: 4/4
  • git diff --check: clean
  • check_todo, both copies: OK
  • Still running: boundary_audit, anneal-audit, anneal/ci. The previous head passed all three.

Gate-1: a cross-family read-only reviewer returned PASS with P0=P1=P2=P3=0 on the same patch at 4c45d69c8.

Not exercised: real zerocopy items on the NDJSON route, since the end-to-end tests use the scalar and synthetic fixtures.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R10 (c32ecde07):
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs and trusted/cargo-anneal/src/core/inspect/{schema,diff}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@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 (tier2a_core_tcb, Round 11)

  • Identity: one:4c934b3e9a6a9654e5014f9491469d6d675d6098:2eab4971f7f11dbe7ce6adae9ce708ad8d1275c8:4fe6f26367c4d0f9c972bb9899c2166edd0e174b421ba30da7db4610ee94436c (base=85efba8b01ff, head=3e9f125f1a53, tree=2eab4971f7f1)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 28 inspected, 0 inapplicable, 0 blocked (of 28 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 3054s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 1 1484s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 1257s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R11-01 P2 1 (seat2) static_verified anneal/trusted/cargo-anneal/src/core/inspect/schema.rs:1870 parse_ndjson_comparator_audit bypasses UnknownFieldsPolicy::Deny on audit.timingMs and omits ndjson_comparator quorum, digest, and primitive-count cross-checks.

G2-R11-01 [P2] (anneal/trusted/cargo-anneal/src/core/inspect/schema.rs:1870, Pass 2 §3 (trusted/cargo-anneal/src/core/inspect/schema.rs), static_verified): parse_ndjson_comparator_audit bypasses UnknownFieldsPolicy::Deny on audit.timingMs and omits ndjson_comparator quorum, digest, and primitive-count cross-checks.

  • Invariant: Receipt v3 schema validation (core/inspect/schema.rs) must reject unrecognized keys under UnknownFieldsPolicy::Deny on fixed-schema nested objects (matching /timing_ms at schema.rs:889-896) and enforce internal cross-field invariants matching validate_ndjson_verdict (ndjson_comparator.rs:2224-2296).
  • Evidence: 1) At schema.rs:1898, audit.req_obj("timingMs")?; never creates an ObjectCursor::nested("/audit/timingMs", ...) or calls collect_unrecognized(unknown), so arbitrary unrecognized keys and non-u64 values inside /audit/timingMs pass even under UnknownFieldsPolicy::Deny (and sample_ndjson_success_json at schema.rs:3068 only populates {"total": 1} instead of NdjsonTimingMs's 10 fields). 2) At schema.rs:1108-1131 and 1870-1900, parse_ndjson_comparator_audit accepts auditMode: "ndjson_comparator" receipts with pinnedPrimitivesCount: 0, expectedConeDeclarations: 0, paranoidQuorum: true with omitted conLecheSha256/lean4leanSha256 and only kernelsPassed: ["nanoda_bin"], or a kernel listed in both kernelsPassed and kernelsSkipped, with zero invariant_violations and passing default evaluate_policy. The PR's own test at schema.rs:3091-3100 asserts invariant_violations.is_empty() on a contradictory receipt that has paranoidQuorum: false with quorum digests and con-ron simultaneously in kernelsPassed and kernelsSkipped (citing sorryAx despite no sorryAx in axioms).

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

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

  • G2-R11-A01 [P3] (anneal/README.md:264): The acknowledgments do not credit the external kernels and exporter the new route depends on.
  • G2-R11-A02 [P3] (anneal/ci/test_check_guard_mutation.py:448): The parity test exempts inspectHeader entirely although it differs from the TrustedBoundary version by the same single substitution already modelled for preflightSpecs.
  • G2-R11-A03 [P3] (anneal/docs/trust-model.md:381): The trust model still says the target checker under --allow-unpinned-lean runs two-phase target-audit kernel replay, which is no longer true when the sysroot bundles the comparator binaries.
  • G2-R11-A04 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:236): Five of the seven end-to-end tests return early and report success when no v4.35.0 toolchain is installed, so CI green does not mean they ran.
  • G2-R11-A05 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:86): The MAX_NDJSON_LINES comment says the bound prevents host memory exhaustion, which the quadratic name rendering does not deliver.
  • G2-R11-A06 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:518): intern_name stores a full dotted rendering for every interned name, so memory grows quadratically with name nesting depth in an adversarial proof export.
  • G2-R11-A07 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1101): The comparator silently skips empty lines that the exporter never emits, which is an unverified point of possible divergence from the external kernels' parsers.
  • G2-R11-A08 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:3441): Step 8 sorryAx admission under allow_sorry_in_proof checks expected_cone_set.contains(&cid) but does not also reject is_sysroot_id(arena, cid).
  • G2-R11-A09 [P3] (anneal/trusted/cargo-anneal/src/verify.rs:3430): Receipt assumptions string unconditionally lists (nanoda_bin / con-ron) for NDJSON comparator runs regardless of sorry-induced con-ron skip or --paranoid-quorum.
  • G2-R11-A10 [P3] (ci/checks.toml:1097): The Review Receipt's prose Human review surface list omits the two repository-root CI files, which appear only in its machine-readable footer and the commit body.

Executed Sandbox Probes

  • seat3 repo_hygiene_and_root_manifest: outcome=passed
  • seat3 spec_preflight_parity_and_guard_list: outcome=passed
  • seat3 ci_python_unit_tests_core_and_release: outcome=passed
  • seat3 ci_python_unit_tests_pr_hygiene_and_ci_lib: outcome=passed
  • seat3 ci_python_unit_tests_ci_workflow: outcome=partial
  • seat3 ci_python_unit_tests_host_tool_limited: outcome=inconclusive
  • seat3 shell_syntax_and_env_edge_probes: outcome=passed
  • seat3 rustc_canon_name_and_eq_helper_probes: outcome=passed
  • seat3 lean_v434_spec_preflight_compile_probe: outcome=inconclusive
  • seat3 workflow_checklist_1_permissions_least_privilege: outcome=passed
  • seat3 workflow_checklist_2_triggers: outcome=passed
  • seat3 workflow_checklist_3_secrets_exposure: outcome=passed
  • seat3 workflow_checklist_4_protected_environments: outcome=passed
  • seat3 workflow_checklist_5_checkout_and_sha_pinning: outcome=passed
  • seat3 workflow_checklist_6_script_injection: outcome=passed
  • seat3 workflow_checklist_7_cache_and_artifact_boundaries: outcome=passed
  • seat3 workflow_checklist_8_no_guard_relaxation: outcome=passed
  • seat3 blank-line-kernel-differential: outcome=inconclusive

Verify target theorems on Lean `v4.35.0+` (when `--allow-unpinned-lean`
is enabled and `<sysroot>/bin/` provides `leanexport`, `nanoda_bin`, and
`con-ron`) without any Lean process producing the verdict and without
loading `Proof` `.olean` files outside the sandboxed exporter.
`cargo-anneal` routes those runs through the pure-Rust Universal NDJSON
Comparator (`trusted/cargo-anneal/src/ndjson_comparator.rs`) backed by
dual independent kernels (`nanoda_bin` and `con-ron`), plus optional
4-kernel `--paranoid-quorum` (`con-leche`, `lean4lean --import`). Pinned
admission sets `ndjson_tools: None` until `v4.35.0+` comparator tool
digests are pinned, so the repository's pinned Lean `v4.34.1` toolchain
keeps using `TrustedBoundary.lean` for every mode.

The comparator route runs these actions:

- `5-init`: clean-sysroot export of the 39 kernel-accelerated and
  elaborator `Init` primitives, the 3 standard axioms, and the admitted
  `System.Platform` declarations.
- `target-consts`: `SpecPreflight` validates the compiled `Model`,
  `Capture`, `Specification`, and `Expected` `.olean`s with the same
  pre-import header, companion, and `isModule` checks as the legacy
  `"target-audit"`, imports them with the admitted sysroot (never a
  `Proof` `.olean`; `loadExts := false`), and reports each module's
  exact constant inventory from its `ModuleData`. Compiler-generated
  constants (anonymous and `deriving` instances, constructors and
  projections, `where`/`let rec` auxiliaries) are thus attributed to
  their defining module instead of being reconstructed from source
  syntax. Lean's import keeps the later of two equal-header theorems
  under the earlier module's index, so each target constant must equal
  the stored constant, and a constant another loaded module also
  declares is rejected unless it is a realized equation-style theorem
  equal to the owner's. It also rejects any `unsafe` target constant and
  reports the targets' `@[implemented_by]`, `@[extern]`, and `@[csimp]`
  subjects.
- `5b`: sandboxed export of `proof_full.ndjson`.
- `5a`: export from the trusted modules alone of the expected
  declaration, every `Specification` constant (except the `partial`
  `_unsafe_rec` auxiliaries Lean pairs with well-founded definitions),
  and every target-module constant `proof_full` contains.
  `--ignore-missing` is no longer passed, so an absent root or
  dependency aborts the export.
- `5-pin`: clean-sysroot re-export, with zero target `.olean`s mounted,
  of every sysroot-named constant either export contains.
- `5c`: the pure-Rust checks, then the kernels.

`5c` requires every export to declare each constant's dependencies
before the constant (other than the names-only mutual-block peers
`leanexport` records for definitions, and references within one
inductive record), so a missing, forward, or cyclic reference fails
closed. Each inductive record must be one consistent mutual block whose
types, constructors, and recursors agree on its membership. It requires
each sysroot-named constant to equal its clean `5-init`/`5-pin`
definition, so sysroot status is never granted by name alone; a proof
module that redeclares a sysroot name (or a kernel-accelerated one) with
different content is rejected. Each target-module constant in
`proof_full` must appear identically in the trusted export, and each
trusted-export constant must have a sysroot or target-module origin.
Proof-origin constants may not use the `Trusted` root, a reserved kernel
root, or a kernel-accelerated name (generated equation and splitter
helpers of a pinned parent excepted); this replaces the name-prefix
check that let a registered `Trusted` model module admit any `Trusted.*`
constant. Compiled declaration edges between target modules must satisfy
`TargetRole::allows`, and sysroot constants in either export may not
reference target constants. Canonical inputs must come from their
designated roles, the canonical root must be `CrateTheorem` or
`UnitTheorem` applied to `Crate.mk` or a Profile v2 counterpart applied
to `CrateV2.mk`, the target theorem must be proof-origin, no reached
target declaration may carry a compiler override, and the direct and
transitive specification bans apply to every module-indexed
`Specification` constant. `.opaqueInfo` is admitted only for non-unsafe,
content-pinned sysroot constants such as `System.Platform.getNumBits`.
The comparator also interns names structurally, rejects duplicate NDJSON
keys, and requires export metadata to match the admitted toolchain's
exact version and commit. Kernels re-hash their private copy of
`proof_full.ndjson` against the digest the comparator verified, and
every kernel's stderr is checked for Lean panic markers. `con-ron` and
`con-leche` run in `--verified` mode with a capped `--jobs`; by default
each starts a worker per hardware thread and exhausts address-space
limits on many-core hosts. A test feeds every kernel, in its configured
invocation, an export whose target theorem is ill-typed but structurally
intact, and requires each to reject it while accepting the well-typed
original; that test needs a `v4.35.0` install, so a CI test also runs
the comparator route with stub kernels and requires it to fail closed
when either kernel exits nonzero or panics. The process-wide caches of
the clean sysroot export and the sysroot constant index are keyed by the
pinned manifest digest or, unpinned, by every admitted sysroot module's
artifact digests.

`SpecPreflight.lean` duplicates `TrustedBoundary.lean`'s header and
specification admission guards (including module-mode specifications)
and its pre-import `.olean` validation;
`ci/test_check_guard_mutation.py` requires every shared definition, and
`preflightSpecs` apart from its header check, to stay identical, and
`tests/audit/tests/target_audit.rs` exercises `"sysroot-consts"`,
`"target-consts"`, and (through a test hook that routes it to
`SpecPreflight`) `"spec-preflight"` on the pinned toolchain. In
both files the specification namespace guard keeps the
`isForbiddenPureNamespace` checks (`_root_` stripping and the
`Init.System`/`Internal.UV`/`Dynlib` sub-scopes) and additionally
reserves `Trusted`, `Anneal`, `Proof`, and every `reservedKernelRoots`
root, including `Init` and `Std`.

As in `TrustedBoundary.lean`'s `"target-audit"`, the comparator verdict
carries the admitted module import graph, which `verify` needs to check
bundled-model trust tiers, and its subject, model, and specification
closures list only reached declarations, each with its defining module,
so `candidate:*` features come only from reached `Model` modules.
Receipts record `sysrootPinsSha256` and the comparator and kernel binary
digests. `cargo anneal inspect` validates those digests, the fixed
`timingMs` schema, and the kernel and quorum invariants the comparator
enforces, reads skipped kernels recorded as `{kernel, reason}`, does not
require `checkedAlternateProofs` from the comparator route, and ranks a
change from the comparator to the default audit as a regression. The
comparator route does not run the anti-vacuity specification lint, and
it does not inspect compiler-override attributes on `Proof` declarations
(their `.olean`s never load outside the sandboxed exporter, and the
attributes cannot change kernel reduction). Its receipts therefore omit
`spec_warnings` and list both under `deferred`. `stage.rs`,
`sandbox.rs`, and `verify.rs` reserve `SpecPreflight`, copy NDJSON sinks
read-only into `ExecSeal` inputs, and precompile and cache
`SpecPreflight.olean` (`ci/prebuild_bundled_oleans.py`, `flake.nix`,
`ci/run_anneal_check.sh`, `ci/check_bundle_tree.py`,
`trusted/root-manifest.sha256`). The `anneal-guard-mutation` ci-core
check takes `SpecPreflight.lean` as an input, and the `anneal-tc` image
seeds it for the flake evaluation.

Part of #4016
Part of #4109

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

joshlf commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt: Gate-2 R11 fix, rebased onto main after #4374

Gate-2 R11 dispositions

ID Sev Disposition
G2-R11-01 P2 Fixed. audit.timingMs is now a fixed schema: all ten timings are required non-negative integers, and unknown keys fall under the unknown-fields policy. Comparator receipts must also satisfy the invariants validate_ndjson_verdict enforces:
• pinnedPrimitivesCount is 39 (a unit test ties this to PINNED_INIT_PRIMITIVES) and expectedConeDeclarations is at least 1;
• nanoda_bin passed, and con-ron passed unless the proof uses sorryAx;
• paranoidQuorum is present; when true, lean4lean and (without sorryAx) con-leche passed with their digests; when false, no quorum kernel or digest is recorded;
• only known kernels appear, and none appears twice.
The test now covers all four legitimate modes (default, quorum, sorryAx, quorum + sorryAx), 10 violation cases, and timing schema errors. The contradictory test receipt is gone.
G2-R11-A02 P3 Fixed. The parity test also compares inspectHeader, under the same header-check substitution.
G2-R11-A03 P3 Fixed. The trust-model.md wording now covers the comparator route.
G2-R11-A05 P3 Fixed. The MAX_NDJSON_LINES doc no longer overclaims, and notes the quadratic name rendering.
G2-R11-A07 P3 Fixed. Empty NDJSON lines are rejected, with a test. Gate-1 confirmed on a live leanexport stream that real exports contain none.
G2-R11-A08 P3 Fixed. Step 8 also refuses sorryAx references from sysroot-named constants.
G2-R11-A09 P3 Fixed. The assumption string names the kernels that actually passed.
A01, A04, A06, A10 P3 Not changed. A01 needs accurate attribution. A04 is inherent: those tests need v4.35, and CI-run synthetic tests now cover the guards. A06 is a memory bound, noted in the A05 doc. A10: this receipt's prose surface now lists ci/checks.toml and ci/docker/anneal-tc.Dockerfile.

Verification

On the simulated base (head 6d0fbf101) [real measurement]:

  • clippy, with CI's -A clippy::type_complexity: 0
  • regenerate_bundle --check: 0
  • cargo-anneal --lib: 274/274
  • ANNEAL_REQUIRE_V435=1 ndjson_comparator_e2e under prlimit --as=64G: 7/7
  • target_audit: 43/43
  • boundary_audit: 61/61
  • anneal-audit and anneal/ci: still running

On the final head fe86e6e2e [real measurement]:

  • regenerate_bundle --check: 0
  • root manifest: 4/4
  • check_todo (both): OK
  • git diff --check: clean
  • check_pr_hygiene: ok: true

Gate-1 (cross-family, read-only reviewer):

  • On the fix (eb344a006): PASS P0=P1=P2=P3=0, after one P3 was addressed. Checked live leanexport output and the wasm32 build.
  • On the [anneal] Add --allow-unstable-feature with uniform taint #4374 rebase resolution (6d0fbf101): PASS 0/0/0/0. Checked lossless composition and smoke-tested inspect on a combined NDJSON plus unstable-features receipt.

Not exercised: real zerocopy items on the NDJSON route. The end-to-end tests use the scalar and synthetic fixtures.

Human review surface

  • Policy relaxations. These apply only to Lean v4.35.0+ runs with --allow-unpinned-lean and the bundled comparator binaries, which route through the NDJSON comparator:
    • The anti-vacuity specification lint does not run. Receipts omit spec_warnings and list the lint under deferred.
    • @[implemented_by]/@[extern]/@[csimp] attributes on Proof-module declarations are not inspected; receipts list this under deferred. Proof .oleans never load outside the sandboxed exporter, and the attributes cannot change kernel reduction. Overrides on Model/Capture/Specification/Expected declarations that the proof reaches still fail closed.
    • Pinned Lean v4.34.1 runs are unaffected and keep TrustedBoundary.lean for every mode.
  • Delta since Gate-2 R11 (3e9f125f1):
    • trusted/cargo-anneal/src/core/inspect/schema.rs: the cross-checks in parse_ndjson_comparator_audit and the fixed timingMs schema.
    • trusted/cargo-anneal/src/ndjson_comparator.rs: empty lines rejected, a sysroot sorryAx guard, and an updated MAX_NDJSON_LINES doc.
    • trusted/cargo-anneal/src/verify.rs: the kernel list in the assumption string.
    • ci/test_check_guard_mutation.py: inspectHeader parity.
    • docs/trust-model.md.
    • Conflict resolutions against [anneal] Add --allow-unstable-feature with uniform taint #4374 in schema.rs and verify.rs.
  • Whole PR:
    • trusted/audit/SpecPreflight.lean, trusted/audit/TrustedBoundary.lean.
    • trusted/cargo-anneal/src/{lib,ndjson_comparator,sandbox,stage,target,toolchain,trusted_bundle,verify}.rs and trusted/cargo-anneal/src/core/inspect/{schema,diff}.rs.
    • trusted/root-manifest.sha256, flake.nix.
    • ci/{check_bundle_tree,check_guard_mutation,prebuild_bundled_oleans,test_check_guard_mutation,test_prebuild_bundled_oleans}.py, ci/run_anneal_check.sh.
    • The docs.

@joshlf
joshlf force-pushed the joshlf-anneal-ndjson-comparator branch from 3e9f125 to fe86e6e Compare November 26, 2026 04:54

@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 — CLEAN (tier2a_core_tcb, Round 12)

  • Identity: one:ecbb2d90b35aa47f1e1c1937ac2ccd6904790f1c:7e02bb24a488816a3529a243c4ddc804fa4a1a5e:ed104564356bd0e8437718ae67e66b7d610eca8d130d5b07940c02afa25a9930 (base=24e6e7250c69, head=fe86e6e2e7e0, tree=7e02bb24a488)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 29 inspected, 0 inapplicable, 0 blocked (of 29 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed clean 0 386s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed clean 0 1474s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed clean 0 1043s

No unresolved P0-P2 findings raised across completed seats.

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

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

  • G2-R12-A01 [P3] (anneal/ci/test_check_guard_mutation.py:430): The parity test's boundary_re ends a def body at any column-0 '--' comment, so drift after such a comment inside a shared def would not be compared.
  • G2-R12-A02 [P3] (anneal/tests/audit/tests/target_audit.rs:2152): Negative tests for the modified TrustedBoundary spec namespace guard are in target_audit.rs and the e2e test rather than boundary_audit.rs as the base rule names.
  • G2-R12-A03 [P3] (anneal/tests/cargo-anneal/tests/ndjson_comparator_e2e.rs:237): v4.35 kernel e2e tests silently early-return when no v4.35 toolchain is installed unless ANNEAL_REQUIRE_V435=1 is set.
  • G2-R12-A04 [P3] (anneal/trusted/cargo-anneal/src/ndjson_comparator.rs:1467): Inner NDJSON record sub-objects accept unrecognized extra JSON keys instead of enforcing strict per-variant key counts or allowlists.
  • G2-R12-A05 [P3] (anneal/trusted/cargo-anneal/src/sandbox.rs:1835): drain_to_bounded_file aborts on ErrorKind::Interrupted rather than retrying transient EINTR reads.
  • G2-R12-A06 [P3] (anneal/trusted/cargo-anneal/src/target.rs:1286): --paranoid-quorum only verifies con-leche and lean4lean binary availability at quorum execution after earlier export and dual-kernel phases complete.
  • G2-R12-A07 [P3] (anneal/trusted/cargo-anneal/src/verify.rs:3711): Omitting spec_warnings on ndjson_route causes output.rs classify_success_badge to mark receipts Tainted, which is harmless under --allow-unpinned-lean today but will need updating when v4.35.0+ is pinned.

Executed Sandbox Probes

  • seat3 root_manifest_sha256: outcome=pass (rc=0)
  • seat3 hygiene_static_and_nonascii: outcome=pass (rc=0)
  • seat3 anneal_ci_python_unit_suites: outcome=pass (rc=0)
  • seat3 anneal_ci_long_suites_timeout_and_workflow_checklist: outcome=timeout (rc=124)
  • seat3 repo_ci_skills_and_unit_tests: outcome=pass_with_skips (rc=0)
  • seat3 cross_file_parity_and_cli_fail_closed: outcome=pass (rc=0)
  • seat3 shell_syntax_and_env_edge_cases: outcome=pass (rc=0)
  • seat3 rustc_name_encoding_and_lean_nproc_probe: outcome=partial (rc=1)

@joshlf
joshlf added this pull request to the merge queue Nov 26, 2026
Any commits made after this event will not be merged.

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

anneal Primary scope: Anneal verification stack (`anneal/` and `exocrate/`)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants