Skip to content

test(source-control): fail when a babysit-prs script shadows a standard-library module - #10798

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-10788-40790055623-1
Oct 29, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-10788-40790055623-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #10788

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Adds a babysit-prs unittest that lists the merge gate's scripts directory and fails, naming the entry, when a module file (any import suffix, compiled ones included) or subdirectory there has a name in sys.stdlib_module_names. A second test confirms every sibling module still resolves from the scripts directory, and a temp-directory test confirms json.py, socket.pyc and a logging/ package get caught. Nothing changes how the gate runs: no -I or -P flag is added, so the sibling imports stay as they were.

Not verified

  • The babysit-prs unittest suite (engine.test.sh, which runs python -m unittest discover -s tests) and its ruff pass were not run here: this lane allows no Python interpreter. The new tests and the existing suite are left to the PR's CI
  • tidy recorded as skipped: the simplify, comment and write-for-humans passes ran (one edit: the changelog fragment's long first sentence was split). The ai-slop fix pass ran only as a manual read with no finding, because this lane's Bash cannot run the ai-slop detect.sh or sha256sum. The PR's CI purg
  • review-venue.txt was absent from the scratchpad, so the review ran locally in one fresh-context subagent instead of being left to the CI code-review lane
  • new-changelog-fragment refused on the detached HEAD (it names the fragment after the branch), so the fragment was written by hand in the same .changes/<plugin>/<slug>-<8 hex>.md shape; check-changelog-fragments accepts it
  • git status shows untracked root entries (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) that this run did not create; they look like sandbox mount stubs and are not part of this change
  • Changes are left uncommitted in the working tree per the runner's instruction; no commit tool was provided

Fix

  • plugins/source-control/skills/babysit-prs/scripts/tests/test_stdlib_shadowing.py: new test module with stdlib_shadows() and three tests (the real scripts directory has no stdlib-named entry, every sibling *.py resolves from the scripts directory, a temp directory holding json.py, socket.pyc and logg
  • .changes/source-control/test-babysit-stdlib-shadowing-1078804a.md: bump none changelog fragment for the test-only change

Verification

The runner ran each check from the base copy against 6a60812:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: All 8 changelog fragment(s) under .changes/ are valid (before tidy, after tidy, and after the review fix)
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: 12 passed, 6 skipped over 2 changed files (before tidy, after tidy, and after the review fix)
  • Fresh-context review subagent (read-only) over both new files: no confirmed correctness bugs. It listed the scripts directory and found no stdlib-named entry, confirmed the expected temp-dir list and its order on POSIX and Windows, and found no flakiness risk from sys.modules or sys.path in the sibl
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40790055623

Left out: the items under Not verified.

Related

#10788

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6a60812192ad807f940e9e33eb9277065e31266d: 0 finding(s), 0 as inline comments.

No security issues found.

The pull request adds a unittest, plugins/source-control/skills/babysit-prs/scripts/tests/test_stdlib_shadowing.py, and a bump: none changelog fragment. It touches no workflow, action, token or kill-switch path, merge hold, trusted-actor list, or plugin manifest. The new test file is not one of the listed trusted paths.

  • Test code: It only reads the scripts directory. It briefly adds that directory to sys.path for importlib.util.find_spec, then removes it in a finally. It uses a temp directory with empty touched files, and runs no subprocesses and no network or secret access. The sys.path insertion only makes the directory's own *.py modules importable, and the first test fails the suite if one of them has a stdlib name.
  • Gate behavior: The gate's invocation is unchanged, with no -I or -P added, so its sibling imports resolve as before. The test only adds a guard against stdlib-named files in that directory.
  • PR context: The PR description contains no embedded instructions aimed at the reviewer.
  • Manifests: The diff hits no manifest field, so there are no manifest <field> lines.
  • Skip gate: Item 2 applies. The change has no security-relevant surface and touches no trust control, instruction surface or manifest.
  • Cost: None. The change adds no billed resource.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 6a60812192ad807f940e9e33eb9277065e31266d: 0 finding(s), 0 as inline comments.

No findings. The change is a test-only module plus a bump: none changelog fragment.

Closing issue #10788

  • Criterion "No file in the gate scripts' directory can shadow a standard-library module… and the gate's sibling imports still resolve" is met. test_the_scripts_directory_has_no_stdlib_name and test_every_sibling_module_resolves_from_the_scripts_directory cover it, and the PR adds no -I or -P flag.
  • Criterion "A test fails if such a file is added" is met. test_a_stdlib_named_module_or_package_is_caught shows the helper flags a stdlib-named module, a compiled module and a package, and test_the_scripts_directory_has_no_stdlib_name applies it to the real directory.

What I checked

  • I listed the scripts directory. It has no stdlib-named entry, so the first test should pass. The names are babysit_*, pr_*, manage_*, guarded_mutation, refresh_pr_branch, request_review, prune_* and tests/.
  • sys.stdlib_module_names needs Python 3.10 or later. The suite's runners (engine.test.sh and babysit-python.sh) require 3.11 or later.
  • Suffix matching follows the order of importlib.machinery.all_suffixes(), which lists extension suffixes first. A name like x.cpython-312-*.so therefore strips to x, not x.cpython-312-….
  • The one test that puts a stub babysit_gh into sys.modules (test_babysit_gh_rate_guard.py:378) does it in a subprocess. It can't make find_spec see a spec-less module in this test.
  • I did not run the tests: this lane has no Python. The PR's claim that the suite and ruff pass is author-claimed and unverified.

Spend: none beyond normal CI test runs.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 6a60812192ad807f940e9e33eb9277065e31266d.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit caa6a71 Oct 29, 2026
44 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-10788-40790055623-1 branch October 29, 2026 00:51
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.

fix(source-control): keep a sibling file from shadowing a standard-library module in the merge gate's Python

0 participants