Repository navigation
fix(python): choose the pytest verify interpreter and confidence at the producer (#13801) - #14853
Conversation
…he producer (#13801) The Python producer now decides once, from static facts at the selected root, which interpreter the generated pytest verify command names and how confident the route is. A project `.venv/bin/python` or `venv/bin/python` (POSIX) replaces PATH `python` in `suggested_verify_command` and every `test_verify_command`; confidence drops to `low` when that venv statically lacks pytest and `medium` when its layout cannot be read, with the fact in `suggested_verify_venv_pytest`. No venv keeps `python` at its existing confidence (no runtime probe; doctor checks PATH pytest). JSON, SARIF, GitHub, human, pilot and MCP read the same evidence. The native pytest route and the editor command allowlist accept only `python`, `.venv/bin/python` or `venv/bin/python` as the program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLT6mGYgTpTRWiCZcAU
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 29 minutes. View limit details
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
The producer now emits .venv/bin/python -m pytest and venv/bin/python -m pytest; the extension's shared test-runner prefix list rejected them as unsafeCommand in first-PR packets and actionable-gap queues. Add both exact prefixes and positive/negative regression cases (pip, runner options, parent/absolute paths). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLT6mGYgTpTRWiCZcAU
…n fallback (#13801) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLT6mGYgTpTRWiCZcAU
EffortlessSteven
left a comment
There was a problem hiding this comment.
SOURCE_REVIEW_READY
Source review of head 13a4af1. An independent reviewer read the whole diff, and I verified the load-bearing points myself.
- Producer pass (
verify_interpreter.rs):- It rewrites only the exact
suggested_verify_command: python -m pytestandtest_verify_command: python -m pytestprefixes. - It is idempotent, and it can only lower confidence: the classifier always emits
highfor pytest placement. - On Windows,
project_venv_pythonreturnsNone, so no POSIXbin/pythonpath is ever emitted there.
- It rewrites only the exact
- Execution allowlists:
- The repair card (
python_repair_card.rs) takes its program from one of three fixed strings and requires an exact display match. - The LSP (
gap_artifacts.rs) accepts only the exact.venv/bin/pythonandvenv/bin/pythontokens before-m pytest. Arguments still have to stay package-local. - VS Code (
packetJson.ts, 119ccd0, fixes Devin's finding) has the same two exact prefixes, andtestRunnerCommandLeavesScopestill checks the arguments. - Negatives cover
-m pip,-p,../, absolute interpreters andpython3. I confirmed them against the compiledfirstPrCommandIsSafe, andtsc --noEmitexits 0.
- The repair card (
- Consumers: grepping
crates/andeditors/turned up no remaining hard-codedpython -m pytestprefix gate outside the sharedis_pytest_verify_command/pytest_verify_interpreterhelpers, doctor's intentional PATH probe, and unittest. - Oracle: the per-surface app test runs the real check pipeline on 4 roots and asserts JSON, SARIF, GitHub, human, pilot and MCP for each.
- Docs: 13a4af1 updates the
PYTEST_VERIFY_PROGRAMdoc and the RIPR-SPEC-0028 text so they no longer imply PATHpythonis always used. - Focused proof at this head:
cargo test -p ripr --lib venvpasses 14/14. - Missing, left to hosted proof: Windows branches, the VS Code extension test run, and Clippy.
full-ciis requested because the LSP and editor surface changed.
Non-blocking: if .venv lacks pytest while venv/ has it, .venv is still chosen, at low confidence. That is conservative and labelled as such.
Generated by Claude Code
Requested by Steven Zimmerman · project thread
Summary
Closes the verify-command half of #13617 (#13799 did the doctor half).
analysis/language/python/verify_interpreter.rs) runs before findings leave the adapter, in both diff and repo mode. Renderers do not read the filesystem..venv/bin/pythonorvenv/bin/python(POSIX only; Windows keepspython) replaces PATHpython, root-relative, insuggested_verify_commandand in everytest_verify_command.high) when the venv statically lists pytest,lowwhen it statically lacks pytest, andmediumwhen its layout cannot be read statically (system site-packages, ambiguouslib/python3.X). The fact is recorded assuggested_verify_venv_pytest: present|missing|unknown. This uses the existing high/medium/low/unknown vocabulary.pythonat its existing confidence. A static producer cannot know whether system Python has pytest, and a runtime probe in the producer would make reports and goldens depend on the host.ripr doctorcovers PATH pytest (RIPR-SPEC-0007). This is documented in RIPR-SPEC-0028.output/python_env.rstoanalysis/python_env.rs, its semantic owner now (check-architectureforbidscrate::outputin analysis). Doctor imports it from there, and its behaviour is unchanged.python -m pytestnow share one contract helper:ripr_contract::domain::pytest_verify_interpreterwithPYTEST_VERIFY_INTERPRETERS = [python, .venv/bin/python, venv/bin/python].is_pytest_verify_commandandpython_pytest_verify_display_foruse it too. The native pytest route (python_repair_card.rs) takes its program from the producer's command and refuses any other interpreter. The editor command allowlist (lsp/gap_artifacts.rs) accepts the two venv programs for-m pytestonly.Surfaces carrying the producer's command and confidence: JSON (
findings[].evidence,repair_placement,python_repair_card.verify), SARIF, GitHub annotations, human (Verify command (Bash): (cd -P -- <root> && .venv/bin/python -m pytest …) (high)), pilot (python_first_use.top_repair_card), and MCP (ripr_get_gapevidence document).Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal:
Spec: RIPR-SPEC-0028 (verify route interpreter/confidence), RIPR-SPEC-0007 (doctor note)
ADR:
Plan item:
Governing issue or accepted claim: #13801
Acceptance delta (one sentence): The Python producer selects the project venv interpreter (statically) and a confidence below
highwhen that venv lacks or cannot show pytest, and JSON, SARIF, GitHub, human, pilot and MCP all carry that one decision, proven by a per-surface contract test.Candidate Relationships
Candidate branch (GitHub PR head is authoritative after publication): claude/project-thread-ebaya9-13801
Stack parent or prerequisite PR (if any): none (#13799 already merged)
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): n/a
Accepted winner and losing candidate disposition (when decided): n/a
Scope
Scope Classification
Production delta:
Evidence/support delta:
.venvwith pytest (command.venv/bin/python, confidence kept),venv/without pytest (low), unreadable venv (medium), no venv (byte-for-byte unchanged), unittest and no-route evidence untouched, idempotence, and a real temp-root static read. Windows-gated test: the venv layout keepspython.app/tests/python_project_venv_verify_route.rs): runs the realcheck_workspace_with_configon a temp workspace for no venv,.venv+pytest,venvwithout pytest, and system-site-packages. It asserts evidence, repair card, JSON placement and card, SARIF (with no leftover PATHpython -m pytest), GitHub, human, pilot JSON and MCPGapItemevidence. POSIX assertions are gated withcfg!(windows).python3, absolute paths and../.venv. The LSP payload accepts the venv-m pytestand refuses venv-m pipand absolute venv paths.Single acceptance criterion:
Non-goals:
pythonand never executes a checkout interpreter. When a venv exists, doctor and the printed command can still name different interpreters. Doctor's existing venv hint covers that case, and running the venv interpreter would need a separate decision..venvfixture would need a Windows golden projection, because Windows keepspython. The per-surface contract test covers all six surfaces instead. Existing goldens do not change, because no fixture input has a venv.Support-tier Impact
Policy Impact
Proof
Result, failures, or skipped proof:
check-architecture: the new analysis file importedcrate::output::python_env. An earlier standalone run had passed only because the file was untracked then. Fixed by moving the venv reader toanalysis/python_env.rs.check-architecture, the focused tests and precommit were re-run on the final head.python output::human lsp::actionstest run and fixtures/goldens/verdict-corpus ran before the venv-reader move, which is a pure file relocation plus test-helper refactor. They were not repeated on the final head.Claim Boundary
Static venv detection reads directory listings and
pyvenv.cfgonly. It does not prove the venv runs or that pytest imports. The confidence label is a static availability signal, not a runtime result.Rollback
Revert the commit. There are no schema-version or config changes; the new evidence line
suggested_verify_venv_pytestis additive.Spec-Test-Code Traceability
.ripr/traceability.d/13801-python-verify-interpreter-at-producer.tomlanalysis/language/python/verify_interpreter.rs,analysis/python_env.rs,output/python_repair_card.rs,ripr-contractlanguage.rs/command_spec.rs,lsp/gap_artifacts.rsStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Generated by Claude Code