Skip to content

Refuse a Malformed Launcher Probe and Check the Wrapper Probe's Exit Status - #4041

Merged
ptr727 merged 2 commits into
developfrom
burndown/4039-agent-safety-launcher-probe-fixes
Nov 10, 2026
Merged

ptr727 merged 2 commits into
developfrom
burndown/4039-agent-safety-launcher-probe-fixes

Conversation

@ptr727

@ptr727 ptr727 commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes two of the three P1 findings raised on promotion PR #4039 against the agent-safety launcher probe that #4032 added. Each fix fails closed, and each comes with a test built on constructed input that fails against the code on develop.

  • host-setup/agent-safety/claude/install.py:498 (launcher_problem): a probe that printed the token followed by a non-numeric version, such as agent-safety-launcher 3a 11, raised ValueError and aborted the install or --report. That output is now a refusal, so hook_launcher() moves on to the next candidate.
  • host-setup/agent-safety/claude/install.sh:16: the wrapper ignored the probe's exit status, so a stub that printed ok and exited 3 was handed install.py. The output is now captured with an && status check before it is compared. The exposure was narrower than the finding states, because install.py's own hook_launcher() already re-probes the hook launcher and checks its return code. What was at stake is only which interpreter runs install.py.

Deferred finding

Tests

New cases in TestLauncher in host-setup/agent-safety/claude/test_install.py:

  • test_a_malformed_version_is_refused_and_the_next_candidate_tried: before the fix it raised ValueError: invalid literal for int() with base 10: '3a'.
  • test_install_sh_passes_over_a_python_that_prints_ok_and_fails: runs install.sh --help with a python3 stub that prints ok and exits 3, placed ahead of a working python. Before the fix the wrapper exits 3.

python3 -m unittest test_install runs 196 tests, all OK. shellcheck install.sh, ruff check, and ruff format --check are clean.

Local review findings, declined

A later local pass found that the new install.sh test's skip condition carried a redundant os.name check. That is fixed in this PR.

Pre-existing findings, not filed

  • host-setup/agent-safety/claude/install.ps1, the Windows twin of install.sh, which this PR does not touch, chooses py -3 or python3 without running a version probe. A python3 app execution alias would be picked and would then fail loudly through exit $LASTEXITCODE rather than fall through to the next candidate. install.py still enforces the 3.11 floor on its own.

Closes on promotion: none

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved installation checks for Python launchers. Invalid version information and checks that fail despite printing a success message are now rejected, allowing the installer to try another candidate and avoid creating an incomplete installation.

…Status

launcher_problem() refuses a probe that prints the token over a
non-numeric version instead of raising, so hook_launcher() moves on to
the next candidate. install.sh checks the probe's exit status as well
as its output, so a stub printing "ok" and exiting non-zero is passed
over.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 10, 2026 19:22
@ptr727

ptr727 commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 302aac954dc972c38337eb9908a6c0257a426122, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The installer now rejects malformed Python launcher version output and checks both the exit status and output of the shell wrapper’s Python probe. Tests cover launcher fallback and a probe that prints ok but exits with a nonzero status.

Changes: Interpreter probe validation

Layer / File(s) Summary
Python launcher rejection and fallback
host-setup/agent-safety/claude/install.py, host-setup/agent-safety/claude/test_install.py
launcher_problem returns a diagnostic for malformed version fields. Tests verify that hook_launcher() selects the next candidate.
Shell wrapper probe validation
host-setup/agent-safety/claude/install.sh, host-setup/agent-safety/claude/test_install.py
The wrapper requires a successful probe command that outputs exactly ok. A test verifies that a candidate that prints ok but exits nonzero is passed over.

Estimated code review effort: 2 (Simple) | ~8 minutes

Possibly related issues

  • ptr727/ProjectTemplate issue 4031 concerns interpreter validation in install.ps1, which this PR does not change.
  • ptr727/ProjectTemplate issue 1172 concerns interpreter selection in install.py and install.sh; this PR changes validation in both paths.
Merge Risk: Minimal · up to da99c

The interpreter probe changes are mergeable after normal checks; no outstanding issue was established.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly names both launcher-probe changes: rejecting malformed version output and checking the wrapper probe’s exit status.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a721aaa and da99c18.

Files selected for processing: 3

  • host-setup/agent-safety/claude/install.py
  • host-setup/agent-safety/claude/install.sh
  • host-setup/agent-safety/claude/test_install.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain, with targeted safeguards and regression tests covering malformed versions and unsuccessful wrapper probes.

No open issues 🎉

What changed in this PR

This PR hardens Claude agent-safety launcher selection by refusing malformed version probes and checking wrapper probe success before selecting Python.

Changes:

  • Refuses malformed launcher version output instead of raising during installation or reporting.
  • Requires the POSIX wrapper's probe command to exit successfully before accepting its output.
  • Adds regression tests for malformed versions and failing wrapper probes.
File Description
host-setup/​agent-safety/​claude/​test_install.py Adds regression tests covering malformed launcher versions and wrapper probes that print valid output but fail.
host-setup/​agent-safety/​claude/​install.sh Requires the Python probe to complete successfully before using its reported interpreter.
host-setup/​agent-safety/​claude/​install.py Refuses malformed launcher probe version output instead of aborting launcher selection.

Review effort: Lite

The encoding gate requires every text-mode subprocess call to name its
encoding rather than leave it to the locale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727

ptr727 commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head da99c18fbe68e14440de7f26c63b4d6bebf04fde, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.03%. Comparing base (a721aaa) to head (da99c18).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4041   +/-   ##
========================================
  Coverage    79.03%   79.03%           
========================================
  Files           37       37           
  Lines        12676    12676           
========================================
  Hits         10019    10019           
  Misses        2657     2657           
Flag Coverage Δ
python-3.13 79.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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