Skip to content

Keep an inherited PYTHONPATH from hollowing out registered and selected replays - #4973

Merged
Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
jwr404:verifier/harness-scrub-pythonpath
Oct 23, 2026
Merged

Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
jwr404:verifier/harness-scrub-pythonpath

Conversation

@jwr404

@jwr404 jwr404 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

scripts/research_package.py's run_command already drops PYTHONOPTIMIZE, so that a caller's environment cannot disable verifier assertions (test_inherited_optimization_cannot_disable_child_checks). PYTHONPATH has the same failure mode and is still inherited.

On a child's sys.path, PYTHONPATH comes before the standard library. A stray directory holding a module named like a stdlib import can therefore end a verifier with exit code 0 before any check runs. The harness accepts exit code 0. For example, with a fractions.py that only calls sys.exit(0), at current main:

$ env PYTHONPATH=/tmp/shadow python3.12 -B scripts/research_package.py --package research/swap-row-order-cut
CHECK Regular-representation row-order cut counts ...
SHADOW fractions imported; exiting 0 before any check
PASS_REGISTERED_RESEARCH_PACKAGE research/swap-row-order-cut outcome=completed

This is not an adversarial scenario. It is an accidental local-environment hazard for the local replays that donors cite as evidence. A clean CI environment is presumably unaffected.

I found it while reviewing #4964, which fixes the same PYTHONOPTIMIZE inheritance in one package's own wrapper. The review comment has the package-level reproduction.

The selected record's reproduction command has the same gap

certificates/selected-result.json names make frontier4470-verify as its reproduction. That target passes the caller's environment through scripts/verify_frontier4470.py and the pinned run_bounded.py to all eight jobs. Acceptance is exit code 0.

At current main, with a PYTHONPATH directory holding a gzip.py and a copy.py that just exit 0 (neither module is imported by the parent), the replay printed

PASS_FRONTIER4470_WITH_SOURCE_BOUND_FOUNDATION_REUSE kappa=60403/20000000

in 44 s. Six of the eight jobs ran nothing: each took 0.51 s, and each log holds only the shadow message. Only pr4470-arithmetic-check and stage-zero-forced-translation really ran.

scripts/verify_frontier4470.py and run_bounded.py are pinned in certificates/frontier4470-source.json, so they are left unchanged. The second commit instead runs both selected-record-check and frontier4470-verify under env -u PYTHONPATH in the Makefile, which is not pinned. That removes the variable from the whole process tree.

With the same shadow PYTHONPATH, the fixed target runs all eight jobs genuinely (4.6, 37.3, 14.3, 19.4, 3.6, 38.9, 0.5 and 1.0 s). No log contains the shadow message, and the replay passes. No record, manifest or pinned file changes.

Other scripts/verify_frontier*.py targets and runners such as run_parallel.py and run_isolated_tests.py likely share the pattern. They are not changed here.

Change

  • run_command now also drops PYTHONPATH from the child environment, with a comment explaining why. It still leaves non-PYTHON* variables and explicit manifest options intact, such as deliberate -O controls.
  • New regression test test_inherited_pythonpath_cannot_shadow_child_imports. A shadow fractions.py that exits 0 must not mask a child that exits 5. The test also checks that the parent's PYTHONPATH is left unchanged.

PYTHONHOME is deliberately left alone: dropping it could break unusual but legitimate installs, and a wrong home fails loudly rather than silently. Requiring a success marker from each verifier, instead of exit code 0, would be a stronger follow-up. It needs a manifest field, so it is not attempted here.

Test plan

python3.12 -W error -B -m unittest tests.test_research_onboarding        # 27 tests OK
python3.12 -W error -B -m unittest tests.test_research_bytecode_isolation tests.test_research_commit_bytes \
  tests.test_research_git_compatibility tests.test_research_descendant_source_roles   # OK
python3.12 -W error -B -m unittest tests.test_research_windows_job tests.test_research_windows_process_tree  # OK (Windows-only cases skipped on Linux)
  • With the fix reverted, the new test fails. With it applied, the end-to-end shadow run above executes the verifier, prints PASS_SWAP_ROW_ORDER_CUT … and then PASS_REGISTERED….
  • No workflow or VERIFY.json relies on passing PYTHONPATH to verifiers.
  • The old harness hash appears only in two frozen historical evidence records, which describe past runs.
  • Linux, CPython 3.12.14. Not run: the Windows replay path, other than its skipped unit tests, and hosted CI.

No research result, κ, selected-record or pinned-file change. Not run: make verify as a whole.

Prepared by James Reed with substantial Anthropic Claude (Claude Code) assistance.

🤖 Generated with Claude Code

jwr404 and others added 2 commits October 22, 2026 21:57
run_command already drops PYTHONOPTIMIZE so a caller's environment cannot
disable verifier assertions. PYTHONPATH has the same failure mode: it
precedes the standard library on the child's sys.path, so a stray module
named like a stdlib import can end a verifier with exit code 0 before any
check, and the harness then prints PASS_REGISTERED_RESEARCH_PACKAGE.
Drop it from the child environment too, with a regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`make frontier4470-verify` (the selected record's reproduce command)
passes the caller's environment through verify_frontier4470.py and the
pinned run_bounded.py to every job. With a stray PYTHONPATH holding
gzip.py/copy.py that exit 0, it printed PASS_FRONTIER4470 while six of
eight jobs ran nothing. Unsetting PYTHONPATH at the make target fixes
the whole process tree without touching any pinned replay file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jwr404 jwr404 changed the title Keep an inherited PYTHONPATH from hollowing out registered replays Keep an inherited PYTHONPATH from hollowing out registered and selected replays Oct 23, 2026
@jwr404

jwr404 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

The three failing "Selected family 626/741/799 finite composition" replays fail in scripts/verify_pr_reconciliation.py with ValueError: #4110: starting head changed. That check compares live PR state. It fails identically on unmodified main (b91956876), locally and in main's own runs of this workflow on 2026-10-21 and 2026-10-22. These workflows ran here only because this PR touches scripts/ and the Makefile. The failure is unrelated to this change.

@jwr404

jwr404 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Because this PR changes scripts/research_package.py, CI replays every registered package. Two replays have already failed: research/a5-conjugate-any-registers (ValueError: sha256 drift certificates/selected-result.json) and research/a5-conjugate-5cycle-seedd316f8 (working source drift: certificates/selected-result.json). Both fail identically under main's unmodified harness at b91956876. Each package pins an earlier version of the selected record, so the failure is pre-existing source drift. It does not come from dropping PYTHONPATH. Main's push CI replays only changed packages, so these failures don't surface there. I'll classify any further failures once the full run completes.

@Mister-Meeseeks
Mister-Meeseeks merged commit 9f789e8 into CrocSwap:main Oct 23, 2026
208 of 260 checks passed
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.

2 participants