Skip to content

Enforce shim mode checks and strip Elab.async overrides - #1

Open
ahrazzle wants to merge 1 commit into
CrocSwap:mainfrom
ahrazzle:fix/shim-mode-and-elab-async-caps
Open

ahrazzle wants to merge 1 commit into
CrocSwap:mainfrom
ahrazzle:fix/shim-mode-and-elab-async-caps

Conversation

@ahrazzle

Copy link
Copy Markdown

Restrict direct os.execv passthrough in lean_buildtools/shim.py to read-only compiler metadata flags and enforce Elab.async=false across CLI, moreLeanArgs, and --setup options.

Root cause

  1. lean_buildtools/shim.py::main previously checked if not any(a.endswith(".lean") for a in args) and called os.execv(real, [real, *args]) before merging extra_args or checking unsupported modes (--run, --server, --worker, --stdin). Because --stdin, --server, --worker, and non-.lean script paths carry no .lean suffix, invoking the shimmed lean binary in those modes executed the real compiler directly without -j/-M caps, --deny-sorry, or children.jsonl supervision.
  2. lean_buildtools/process.py::capped_args prepended -DElab.async=false without stripping caller -DElab.async=true, -Dweak.Elab.async=true, or -D Elab.async=true flags, and BuildMonitor.monitor only set Elab.async=false inside synchronousDispatch rather than on top-level command scopes when lakefile.toml set [leanOptions] Elab.async = true via --setup.

Changes

  • lean_buildtools/shim.py::main: allow direct os.execv only when args is a non-empty subset of read-only metadata flags (METADATA_FLAGS), merge extra_args before mode checks, and exit with an error if no .lean source path is present.
  • lean_buildtools/process.py::capped_args and caps_match: strip Elab.async and weak.Elab.async -D overrides (both attached and separated forms) during normalization and reject non-false overrides during child argv verification.
  • lean_buildtools/lean/BuildMonitor.lean::monitor: apply modifyScope with Elab.async = false before elabCommand so --setup module options cannot re-enable asynchronous command elaboration while preserving namespace/section scopes.
  • tests/test_supervisor.py and tests/test_integration.py: add unit and real-compiler Lake integration coverage for shim mode rejection and Elab.async override stripping.

Validation

Check Before After
shim --stdin with deny_sorry=true on sorry input Exit 0, 0 children.jsonl entries Exit 1 (unsupported compiler mode)
lake build with moreLeanArgs = ["-DElab.async=true"] and [leanOptions] Elab.async = true Elab.async = true, caps_verified = true Elab.async = false, caps_verified = true
python3 -m unittest discover -s tests -v (Lean 4.35.0) 42/42 pass 45/45 pass
NativeProof.Smoke + profile-batch Tests/rules.json --deny-sorry Pass Pass

Automated posting by agentic team with human oversight.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant