Skip to content

Keep native-query replay assertions active in child processes - #4964

Merged
Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
aliromman:codex/publish-native-query-limits
Oct 23, 2026
Merged

Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
aliromman:codex/publish-native-query-limits

Conversation

@aliromman

Copy link
Copy Markdown
Contributor

This fixes a verifier failure mode in PR #4952. An isolated Python parent ignores PYTHONOPTIMIZE=1, but its child processes can still inherit that variable and disable their mathematical assertions. The wrapper now removes the variable from each child environment, which also protects descendant processes. Its rejection of an optimized parent remains in place.

The five-line wrapper change, independent environment review, and fresh mathematical replay receipt bind the correction. The mathematical sources and the scoped lower-bound claims are unchanged. There is no supplier or kappa improvement.

From the repository root, with Python 3 and the standard library, use a new output directory:

env PYTHONOPTIMIZE=1 python3 -I -B research/legacy-native-query-obstructions/verify.py --work /tmp/native-query-environment-replay

Expected final line:

PASS_LEGACY_NATIVE_QUERY_OBSTRUCTIONS checks=5

All five actual checks passed with that triggering environment. The independent review separately tested real children and grandchildren at all five dispatch sites: all ten probes had optimization level zero and active assertions. Those probes test the environment contract; they do not replace the mathematical replay. The prior independent mathematical review remains applicable because its proof and checker inputs are unchanged. Original review records are retained alongside the new file manifest.

The correction follows the merged head 159dda696ee2004065d250da76d7d2b94a3e4f21. The original package and predecessor credit remain as published in PR #4952. The additional evidence records only this verifier correction; no full supplier replay, Lean run, or hosted CI result is claimed. OpenAI Codex assisted this change and its separate agent review. No human review is claimed.

@jwr404

jwr404 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Independent review at head 9c8c1308b0458b8edd9382b0d62ad28f8478f26e

The fix is correct for the reported mechanism. A probe child started the old way (sys.executable -B, with the inherited environment containing PYTHONOPTIMIZE=1) reports sys.flags.optimize == 1. With the variable popped it reports 0. On Linux with CPython 3.12.14, env PYTHONOPTIMIZE=1 python3.12 -I -B …/verify.py --work <new dir> gives PASS_LEGACY_NATIVE_QUERY_OBSTRUCTIONS checks=5, and all five children exit 0 with their normal output.

A remaining gap of the same kind (suggested follow-up). The children still inherit every other PYTHON* variable. On a child's sys.path, PYTHONPATH comes before the standard library, and the wrapper accepts any child that exits 0. For example, a stray PYTHONPATH directory containing a fractions.py that just calls sys.exit(0) (four of the five checks import fractions) produces:

$ env PYTHONPATH=/tmp/shadow python3.12 -I -B research/legacy-native-query-obstructions/verify.py --work /tmp/w2
PASS_LEGACY_NATIVE_QUERY_OBSTRUCTIONS checks=5

That PASS appears even though checks 0, 1, 2 and 4 ran nothing: stdout is 0 bytes and stderr shows the shadow message. This is not an adversarial scenario. It is the same "inherited environment silently weakens the replay" failure that this PR fixes for PYTHONOPTIMIZE.

Two small changes would close it:

  1. Start children with -E. They then ignore all PYTHON* variables, including PYTHONOPTIMIZE and PYTHONPATH, while keeping the script directory on sys.path, unlike -I. Also scrub the environment passed on to grandchildren, for example child_env = {k: v for k, v in os.environ.items() if not k.startswith("PYTHON")}. I checked -E on the five children: with both PYTHONPATH=<shadow> and PYTHONOPTIMIZE=1 set, all five ran and passed normally (check-0 stdout 739 bytes, check-3 672 bytes).
  2. Require a success marker from each child, such as its expected final stdout line, rather than exit code 0 alone. Then any early sys.exit(0) fails the wrapper.

I would not hold the PR on this. It strictly improves the wrapper, and the mathematical sources are unchanged. But the README's claim that the wrapper "protects descendant processes" is currently true only for the optimization flag.

This is an author-independent check. It is not maintainer acceptance, and κ is unchanged.

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

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

3 participants