Repository navigation
Fix #1003: reject Python below the supported floor instead of reporting it healthy - #1005
Merged
Merged
Conversation
…ng it healthy detect-tools.sh accepted the first interpreter on PATH that merely answered `-V` with no version check, so a Python below 3.9 (pipeline/_tz.py imports zoneinfo, stdlib only since 3.9) could be selected -- and doctor.sh then reported "OK python ... 3.8.10" and "capture is working" while consolidation crashed on every attempt, silently, for months (reported by @amitpatelx). _remember_python now rejects any candidate below the floor and tries versioned fallbacks (python3.9 through python3.13) before giving up, with a FATAL message distinct from "no working Python found" when every interpreter present is simply too old. The floor is pinned against tests/pep604_floor.py's own CI-matrix derivation rather than hardcoded a second time. The tool-verdict cache (#668) now carries the floor it was written against, so a cache from before this fix -- or an interpreter swapped out in place at the same PATH -- is distrusted and re-probed rather than trusted forever. _remember_run_python gained the matching literal arms for the new versioned candidates, without which a fallback pick would FATAL on every real use after being "successfully" detected. doctor.sh gained two independent WARNs, left out of the VERDICT ladder like the existing log-rotation and case-divergence checks: the selected Python is below the floor (a backstop for a path that bypasses detect-tools.sh's own enforcement), and consolidation's last recorded log entry is an ERROR with no later done -- the exact silent state this issue reports. Co-Authored-By: Claude Sonnet 5 <[email protected]>
The Explore reviewer caught it: the changelog said the tool-verdict cache's new PYFLOOR line distrusts "an interpreter swapped out in place at the same PATH", but the cache only compares the PATH string and the floor CONSTANT -- it never re-runs `-V` on the cached interpreter, so a python3 downgraded in place (pyenv switch, reinstalled venv) under an unchanged PATH and an unchanged floor constant is still served from cache with no re-probe. doctor.sh's independent, uncached `-V` call is what actually surfaces that case (for diagnosis, not prevention) -- tests/test_doctor_consolidation_1003.py's own docstring already said this correctly; the changelog now matches it. The oss:auditor caught a second, smaller one: `_real_path_without_other_pythons`'s docstring claimed it reliably preserves coreutils (mktemp/sort/grep) while filtering out python3*-holding directories, which is false on a Linux image where /usr/bin holds both in the same directory. No current test assertion depends on the dropped coreutils, so this is a corrected docstring, not a behavior change. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Neither blocked the actual fix -- both were worked around by splitting edits smaller and avoiding inline env-var-prefixed bash invocations -- but both cost retries and are worth a curator's look. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ds, Windows triage doc, and the CI-only below-floor leak Review of PR #1005 found the versioned-fallback probe loop running `$_candidate -V` directly, which left a bare variable in command position -- the plugin directory's tree-shaker refused to shake any of the four compiled hooks because of it, and the untreated session-start-hook.sh blew past the 120 KiB hook-script budget (#900) as a direct consequence. Route the probe through the same literal if/elif dispatch `_remember_run_python` already uses (moved earlier in the file so the probe loop can call it), restoring tree-shaking, and trim the new floor-detection code (a single `_py_ok` floor check, kept standalone since doctor.sh also calls it as an independent backstop; the versioned fallback scoped to python3.11 only, since the hook budget has no room for the full 3.9-3.13 ladder inlined into every hook) until session-start-hook.sh's compiled size is back at exactly 122880 bytes. scripts/doctor.sh's own consolidation-health section used a `case` on a quoted-literal pattern -- a shape the directory's scanner holds on sight; rewrite as if/elif. Add the missing windows-skip-triage.md row for tests/test_doctor_consolidation_1003.py's blanket win32 skip. The CI-only "below-floor interpreter accepted" failures traced to tests/test_detect_tools_floor_1003.py's own `_real_path_without_other_pythons()` helper: it filtered the real PATH for directories holding a `python3*` binary, which misses a directory that carries a bare `python` with no `python3*` sibling at all -- exactly the shape a CI image has, confirmed by reproducing the leak locally. Replace it with `base_path=""` (exclude the real PATH outright; none of the three call sites needing no OTHER python on PATH need real coreutils either). Preserved along the way: tests/test_detect_tools_fatal_diagnostics_650.py (the FATAL must still show the PATH searched and each candidate's own probe result) and tests/test_detect_tools_cache_668.py (the exit-49 diagnostic) both needed their diagnostic detail restored after an over-aggressive first trimming pass; doctor.sh's own backstop floor check needed updating to call the renamed `_py_ok` instead of the no-longer- existing `_remember_py_meets_floor`. Compiled sizes: session-start-hook.sh 122880 B (budget 122880 B, exactly at the line), session-end-hook.sh 46863 B, user-prompt-hook.sh 58407 B, post-tool-hook.sh 71214 B. All four hooks report shaken=True. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…not just 3.11 The maintainer's own reproduction: Ubuntu 20.04 with python3=3.8.10 and python3.10 installed, no python3.11. Round 2's fallback had one literal if/elif arm per version (the plugin directory's scanner refuses a variable-driven dispatch), scoped to python3.11 alone for the #900 hook- script byte budget -- so on this exact machine detect-tools.sh would reject 3.8, find no 3.11, and FATAL on every hook, breaking capture for the very reporter #1003 was filed by (capture worked on 3.8 for three months; only consolidation was broken). _remember_run_python gets one new generic arm instead of a fourth per-version one: any PYTHON matching the glob `python3.[0-9]*` dispatches through `command "$PYTHON" "$@"` -- a literal word in command position (what the scanner's UNPINNED_NPX check can read) that then runs the variable as a program name. `env "$PYTHON" "$@"` was the other candidate; rejected because check_release_tree.py's BARE_ENV_WORD check (#898 round 4/5) FAILs a bare `env` word at command position, and `env` is also a separate process spawn on Windows where `command` is a shell builtin. With one generic arm instead of one per name, the candidate loop can now list the whole ladder (python3.13 down to python3.9, the file's own floor) instead of a single pinned version. Kept FATAL for "nothing on PATH meets the floor at all" rather than degrading capture to run on a below-floor interpreter: this repo's own pipeline code happens not to use any 3.9-only runtime feature today, but that is incidental, not a guarantee, and a silent "ran anyway, maybe wrong" is a worse failure than a loud FATAL doctor.sh already explains. The reporter's own machine no longer hits this branch at all now that 3.10 is in the ladder. Red: added test_the_reporters_ubuntu_2004_shape_falls_through_to_python310 (python3=3.8, python3.10 present, no 3.11) -- failed with the round-2 code (FATAL: below the floor this plugin supports:python3 Python 3.8.10). Green after the fix: PYTHON=python3.10. Co-Authored-By: Claude Sonnet 5 <[email protected]>
3 of 4 tasks
fdaviddpt
added a commit
that referenced
this pull request
Oct 31, 2026
…or (#1062) * Fix #1007: doctor.sh's below-floor FAIL Python line now names the floor detect-tools.sh's FATAL text for every-candidate-below-floor named each rejected candidate's version but never the floor those versions were measured against. doctor.sh relayed that text unchanged in its "FAIL Python:" line, so neither surface told a user which version to install. detect-tools.sh cannot grow the message itself -- it is inlined into every compiled hook and #1005 left only 37 bytes of budget under the compiled session-start-hook.sh size cap (#1006). doctor.sh is not inlined, so the fix lives there instead: it re-sources detect-tools.sh in lazy mode (skips the candidate probe and its `exit 1`, needing only the floor constants that file sets as plain variables) to recover the floor and append "need Python X.Y+ -- install a newer Python." to the FAIL line, the same convention as doctor's existing below-floor WARN for the cache-hit backstop (#1003). Co-Authored-By: Claude Sonnet 5 <[email protected]> * #1007 self-review: fix stale lazy-mode-caller prose in detect-tools.sh The self-review of f11dddd flagged two comment blocks in detect-tools.sh (the USAGE header and the "Lazy mode (#662)" block) that enumerated which sourcers set _REMEMBER_LAZY_PYTHON=1 and said only session-start-hook.sh does -- no longer true, since doctor.sh's new FAIL-path floor lookup also sets it, inside its own throwaway `$(...)` subshell. Note both spots that doctor.sh's main execution still uses the real, eager probe, and that the new use is a second, unrelated purpose scoped to that subshell alone. Co-Authored-By: Claude Sonnet 5 <[email protected]> * #1007 self-review: triage the new test's blanket win32 skip tests/test_doctor_fatal_floor_1007.py (added in f11dddd) carries a module-level pytest.mark.skipif(sys.platform == "win32", ...), the pattern docs/windows-skip-triage.md requires a row for in the same commit as the convention it violated. Caught by the audit's platform-band check plus tests/test_windows_skip_triage_497.py itself, which already fails without this row. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scripts/detect-tools.sh accepted the first Python interpreter on PATH that merely answered -V with exit 0, with no version check at all, so an interpreter below 3.9 (pipeline/_tz.py imports zoneinfo, stdlib only since 3.9) could be selected -- and scripts/doctor.sh then reported OK python ... 3.8.10 and capture is working while consolidation crashed on every attempt, silently, for months. Reported by @amitpatelx.
_remember_python's candidate loop now rejects any below-floor candidate and, only once the four generic candidates have each failed or come in below the floor, tries versioned fallbacks python3.13 down to python3.9. The floor (3.9) is pinned against tests/pep604_floor.py's own CI-matrix derivation rather than hardcoded a second time. A distinct FATAL message fires when every candidate present is simply too old, instead of reusing the no-working-Python-found message. The tool-verdict cache (#668) now also carries the floor it was written against, so a cache from before this fix, or one with a stale floor, is distrusted and re-probed -- this does not re-validate an interpreter swapped out in place under an unchanged PATH and unchanged floor, which doctor.sh's own independent, uncached check still catches, as a WARN rather than a prevention (noted explicitly so the scope is not overstated). scripts/doctor.sh gained two WARN-only checks, left out of the VERDICT ladder like its existing log-rotation and case-divergence checks: the selected Python is below the floor, and consolidation's last recorded log entry is an ERROR with no later done.
Full TDD evidence (red-before-green on both changed scripts, positive controls, and a combined test run across ten files) and the full review exchange (two findings, both fixed) are recorded in this run's own note file rather than restated here.
Below-bar note: the two new 1003 test files intentionally differ on how they skip under the Windows runner, matching two different existing conventions already used elsewhere in this suite; left for the maintainer's judgment on whether to align them.
Closes #1003
[AI-generated]