Skip to content

fix(python): choose the pytest verify interpreter and confidence at the producer (#13801) - #14853

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-ebaya9-13801
Nov 16, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-ebaya9-13801

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Summary

Closes the verify-command half of #13617 (#13799 did the doctor half).

  • 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 new pass (analysis/language/python/verify_interpreter.rs) runs before findings leave the adapter, in both diff and repo mode. Renderers do not read the filesystem.
  • A project .venv/bin/python or venv/bin/python (POSIX only; Windows keeps python) replaces PATH python, root-relative, in suggested_verify_command and in every test_verify_command.
  • Confidence: unchanged (high) when the venv statically lists pytest, low when it statically lacks pytest, and medium when its layout cannot be read statically (system site-packages, ambiguous lib/python3.X). The fact is recorded as suggested_verify_venv_pytest: present|missing|unknown. This uses the existing high/medium/low/unknown vocabulary.
  • Design decision (case b of ux(python): doctor and verify command use the PATH python/pytest, ignore the project .venv, and doctor is silent when pytest is missing #13617): with no project venv, the command keeps PATH python at 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 doctor covers PATH pytest (RIPR-SPEC-0007). This is documented in RIPR-SPEC-0028.
  • The static venv reader moved from output/python_env.rs to analysis/python_env.rs, its semantic owner now (check-architecture forbids crate::output in analysis). Doctor imports it from there, and its behaviour is unchanged.
  • Consumers that pattern-matched python -m pytest now share one contract helper: ripr_contract::domain::pytest_verify_interpreter with PYTEST_VERIFY_INTERPRETERS = [python, .venv/bin/python, venv/bin/python]. is_pytest_verify_command and python_pytest_verify_display_for use 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 pytest only.

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_gap evidence document).

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm
  • repair or follow-up for a same-repo swarm PR
  • swarm-only CI, runner, routing, source-of-truth, or agent-operating surface
  • other swarm-scoped work:

Source-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 high when 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

  • Producer pass, contract helpers, native route, editor allowlist, venv reader move, spec/schema docs, traceability, changelog.

Scope Classification

  • One production behavior

Production delta:

  • The pytest verify command uses the project venv interpreter when one exists, and its confidence reflects static pytest availability in that venv.

Evidence/support delta:

  • Producer unit tests: .venv with 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 keeps python.
  • End-to-end contract test (app/tests/python_project_venv_verify_route.rs): runs the real check_workspace_with_config on a temp workspace for no venv, .venv+pytest, venv without pytest, and system-site-packages. It asserts evidence, repair card, JSON placement and card, SARIF (with no leftover PATH python -m pytest), GitHub, human, pilot JSON and MCP GapItem evidence. POSIX assertions are gated with cfg!(windows).
  • Contract and route tests: the interpreter allowlist rejects python3, absolute paths and ../.venv. The LSP payload accepts the venv -m pytest and refuses venv -m pip and absolute venv paths.

Single acceptance criterion:

  • Every surface shows the same producer-selected interpreter and confidence.

Non-goals:

  • Doctor still probes only PATH python and 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.
  • The unittest route is unchanged.
  • No new golden fixture: a committed .venv fixture would need a Windows golden projection, because Windows keeps python. 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

  • none

Policy Impact

  • none

Proof

cargo test -p ripr --lib -- verify_interpreter native_route command_payload_accepts_python python_project_venv python_env pytest_probe   # exit 0, 20 passed (final head)
cargo test -p ripr-contract --lib -- pytest_verify          # exit 0
cargo test -p ripr --lib -- python_repair_card output::human python lsp::actions   # exit 0, 2828 passed (before the venv-reader move)
cargo xtask check-architecture      # exit 0 (final head; failed before the move, see below)
cargo xtask check-traceability      # exit 0 (final head)
cargo xtask check-spec-format       # exit 0
cargo xtask check-output-contracts  # exit 0
cargo xtask check-changelog-fragments  # exit 0
cargo xtask check-user-text         # exit 0
cargo xtask check-public-api        # exit 0
cargo xtask fixtures                # exit 0
cargo xtask goldens check           # exit 0
cargo xtask verdict-corpus          # exit 0
cargo fmt --check                   # exit 0
cargo xtask precommit               # exit 0 (final head)

Result, failures, or skipped proof:

  • The first precommit failed check-architecture: the new analysis file imported crate::output::python_env. An earlier standalone run had passed only because the file was untracked then. Fixed by moving the venv reader to analysis/python_env.rs. check-architecture, the focused tests and precommit were re-run on the final head.
  • The broad python output::human lsp::actions test 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.
  • Not established: whether precommit's selected Rust lint ran Clippy over the changed packages (its log shows no clippy line).
  • Windows-only branches were not executed locally (Linux host). Hosted CI will cover them.

Claim Boundary

Static venv detection reads directory listings and pyvenv.cfg only. 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_pytest is additive.

Spec-Test-Code Traceability

  • Tests: .ripr/traceability.d/13801-python-verify-interpreter-at-producer.toml
  • Code: analysis/language/python/verify_interpreter.rs, analysis/python_env.rs, output/python_repair_card.rs, ripr-contract language.rs/command_spec.rs, lsp/gap_artifacts.rs
  • Golden outputs: unchanged

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • Errors are reported with actionable context.

Generated by Claude Code

…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
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 146 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: c440b9a4-6099-41c6-91cc-2c646d716877
Commits

Reviewing files that changed from the base of the PR and between 9d46066 and 13a4af1.

Files selected for processing: 22

  • .ripr/traceability.d/13617-doctor-python-pytest-probe.toml
  • .ripr/traceability.d/13801-python-verify-interpreter-at-producer.toml
  • changelog.d/13801-python-verify-uses-project-venv.md
  • crates/ripr-contract/src/domain/command_spec.rs
  • crates/ripr-contract/src/domain/language.rs
  • crates/ripr-contract/src/domain/mod.rs
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/verify_interpreter.rs
  • crates/ripr/src/analysis/mod.rs
  • crates/ripr/src/analysis/python_env.rs
  • crates/ripr/src/app/tests/mod.rs
  • crates/ripr/src/app/tests/python_project_venv_verify_route.rs
  • crates/ripr/src/cli/commands/doctor.rs
  • crates/ripr/src/domain.rs
  • crates/ripr/src/lsp/gap_artifacts.rs
  • crates/ripr/src/output/mod.rs
  • crates/ripr/src/output/python_repair_card.rs
  • docs/OUTPUT_SCHEMA.md
  • docs/specs/RIPR-SPEC-0007-repository-configuration.md
  • docs/specs/RIPR-SPEC-0028-python-preview-static-facts.md
  • editors/vscode/src/packetJson.ts
  • editors/vscode/test/suite/extension.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 15, 2026 17:10
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread crates/ripr/src/lsp/gap_artifacts.rs Resolved
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 EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pytest and test_verify_command: python -m pytest prefixes.
    • It is idempotent, and it can only lower confidence: the classifier always emits high for pytest placement.
    • On Windows, project_venv_python returns None, so no POSIX bin/python path is ever emitted there.
  • 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/python and venv/bin/python tokens 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, and testRunnerCommandLeavesScope still checks the arguments.
    • Negatives cover -m pip, -p, ../, absolute interpreters and python3. I confirmed them against the compiled firstPrCommandIsSafe, and tsc --noEmit exits 0.
  • Consumers: grepping crates/ and editors/ turned up no remaining hard-coded python -m pytest prefix gate outside the shared is_pytest_verify_command / pytest_verify_interpreter helpers, 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_PROGRAM doc and the RIPR-SPEC-0028 text so they no longer imply PATH python is always used.
  • Focused proof at this head: cargo test -p ripr --lib venv passes 14/14.
  • Missing, left to hosted proof: Windows branches, the VS Code extension test run, and Clippy. full-ci is 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

@EffortlessSteven EffortlessSteven added full-ci Run required, advisory, and release-like CI lanes. merge-ready labels Nov 15, 2026 — with Claude
@EffortlessSteven
EffortlessSteven added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit ee9c2d1 Nov 16, 2026
34 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-ebaya9-13801 branch November 16, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run required, advisory, and release-like CI lanes. merge-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants