Skip to content

refactor(source-control): share guarded worker CLI scaffolding through guarded_mutation.py - #15615

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-15607-43256903695-1
Nov 12, 2026
Merged

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

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #15607

Summary

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

guarded_mutation.py gains run_under_state_lock(args, run_locked), add_head_pin_arguments(parser) and add_worker_arguments(parser, apply_help), and now imports resolve_state_dir, state_path_for and MIN_HEAD_SHA_PREFIX_LENGTH. manage_feedback_ledger.py, refresh_pr_branch.py and request_review.py drop their copies of the lock wrapper and of the --pr/--expected-head-sha and --state-dir/--lease-token/--apply blocks. Each main calls the helpers where the old blocks were, so argument order and help text stay the same. Each main now calls run_under_state_lock(args, run_locked) inside the same try block, and run_locked and main keep their names. The issue says no test touches run, but test_request_review_policy.py:116 patched request_review.run, so that one line now patches request_review.run_under_state_lock.

Not verified

  • The pytest suites test_guarded_mutation.py, test_manage_feedback_ledger.py, test_request_review_policy.py, test_review_trigger_race.py, test_babysit_merge.py, test_guards.py, test_floor_paths.py and test_merge_holds_sync.py did not run: this lane cannot start an interpreter. They are left to the…
  • The byte-for-byte comparison of python3 <script> --help before and after did not run, for the same reason. Reading the code shows the same arguments, order and help strings. test_guards.py in CI runs --help on each entry point.
  • scripts/run-ruff.sh check on the changed files did not run separately: the lane only runs its named wrappers, and check-affected does not list which 13 checks it ran. The review found no new unused imports, and ruff.toml selects only E4, E7, E9 and F. Left to the PR's CI.
  • Tidy pass 5 (ai-slop): the detector detect.sh is not a wrapper this lane may run, so only the rubric read ran on the fragment, and it found no tells. Passes 1 to 4 made no edits. One proposal not applied: the mock variable at test_request_review_policy.py:113 is still named run, outside the listed…
  • The issue's done-when items 'ci-status is green' and 'the PR stays within 400 changed lines' are checked on the PR by CI. The diff here is about 202 lines over 6 files.
  • The change is left uncommitted, as the lane's system prompt asks. The runner turns it into a patch, so ci-mode's commit step does not apply.

Fix

  • plugins/source-control/skills/babysit-prs/scripts/guarded_mutation.py: added run_under_state_lock, add_head_pin_arguments, add_worker_arguments and the imports they need
  • plugins/source-control/skills/babysit-prs/scripts/manage_feedback_ledger.py: removed run and the duplicated argument blocks, kept argument order (action, head pin, own four flags, worker trio, --fix-round-cap), removed unused imports
  • plugins/source-control/skills/babysit-prs/scripts/refresh_pr_branch.py: removed run and the duplicated argument blocks, removed unused imports
  • plugins/source-control/skills/babysit-prs/scripts/request_review.py: removed run and the duplicated argument blocks, removed unused imports
  • plugins/source-control/skills/babysit-prs/scripts/tests/test_request_review_policy.py: line 116 patches run_under_state_lock in place of the removed run (the assertion that the CLI never reaches the run step is unchanged)
  • .changes/source-control/work-resolve-issue-issue-15607-43256903695-1-b171c9b6.md: new patch fragment, ### Changed, Internal restructuring, no behavior change.

Verification

The runner ran each check from the base copy against 1becba6:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 10 fragments valid (run before and after tidy)
  • check-changed-skills: babysit-prs PASS, 0 errors, 4 warnings that were already there (description and body size)
  • check-affected: 13 passed, 6 skipped over 6 changed files (run before and after tidy)
  • Grep for line citations of the four changed files (file.py:<n>) across the repo: none, so no citation drifts
  • Grep of the tests for .run, state_lock, resolve_state_dir, state_path_for and MIN_HEAD_SHA_PREFIX_LENGTH on the three modules: only test_request_review_policy.py:116, which was updated
  • Fresh-context review subagent over the full diff: no findings. It confirmed argument order and help strings match the originals, exit codes and error text are unchanged, no unused or missing imports, no import cycle (babysit_util imports only the standard library), the guard_contract source-text…
  • Floor check: none of the four files is in babysit_risk.py, so FLOOR_CLASSES is unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43256903695

Left out: the items under Not verified.

Related

#15607

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

Copy link
Copy Markdown
Contributor

claude-review reviewed 1becba608d0ea3c90ecb0558a1032c5cbb8e4f72: read 6 of 6 changed file(s); 1 finding(s), 0 as inline comments.

Code review: PR #15615, sharing the guarded worker CLI scaffolding through guarded_mutation.py

I read all 6 changed files in full. I also read the current guarded_mutation.py and the tests that cover these CLIs (test_request_review_policy.py, the --help and enforced_at checks in test_guards.py, and guard_contract.py).

Correctness: no blocking findings.

  • Lock wrapper. run_under_state_lock at guarded_mutation.py#L113 does the same three steps as the removed run copies: it calls resolve_state_dir, then state_path_for, then calls run_locked inside state_lock. Each main calls it from inside the same try block, so exceptions, exit codes and the ledger's FlakeCapReached branch at exit EXIT_FLAKE_CAP work as before.
  • Arguments. add_head_pin_arguments and add_worker_arguments copy the old help strings exactly. Each --apply help string is passed through unchanged. Argument order is kept in all three CLIs, including the ledger's order: action, the head pin, its own four flags, the worker trio, then --fix-round-cap.
  • Names and imports. run_locked and main keep their names, so the anchors in tests/test_babysit_merge.py, test_request_review_policy.py and guard_contract.py (manage_feedback_ledger.py::main) still resolve. The imports that are no longer used were removed. No import cycle is added, because babysit_util is the only new dependency.
  • Test change. In test_request_review_policy.py:116 the patch now targets request_review.run_under_state_lock. main looks that name up as a module global, so the test still proves that a rejected --trigger-phrase never reaches the locked run.

Closing issue #15607:

  • The three helpers exist and the three CLIs use them: met.
  • FLOOR_CLASSES and hold paths: untouched by the diff.
  • Scope: only the listed files changed, plus the one test line that patched the removed run.
  • Size: about 200 changed lines over 6 files, within the 400-line and 15-file limits.
  • Pytest, ruff and ci-status: the PR's CI checks these. I ran nothing myself, and the author lists them as not run.
  • Advisory (1 finding): the criterion "python3 <script> --help prints the same bytes before and after the change" is met, but no test checks it. Reading the code, the help text matches byte for byte. The only test that runs --help on these entry points (test_guards.py#L418-L438 and #L611-L643) checks the exit code and the set of long flags only. A change to help text or argument order in the shared helpers would pass every test. The author says the byte-for-byte comparison was not run; it is still unverified.

Changelog fragment. bump: patch with "Internal restructuring, no behavior change." matches a refactor that changes no behavior. No plugin manifest changed.

No embedded instructions were found in the PR context.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 1becba608d0ea3c90ecb0558a1032c5cbb8e4f72: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15615 (head 1becba6)

No security issues found.

What changed: This is a refactor of the babysit-prs worker CLIs. The state-lock wrapper (run) and the --pr/--expected-head-sha and --state-dir/--lease-token/--apply argument blocks were copied in manage_feedback_ledger.py, refresh_pr_branch.py and request_review.py. They now live in guarded_mutation.py as run_under_state_lock, add_head_pin_arguments and add_worker_arguments.

Checked, all six files read in full:

  • Lock wrapper. run_under_state_lock has the same body as the three removed run functions: resolve_state_dir(args.state_dir), then state_path_for, then with state_lock(state_path): return run_locked(...). Each main still calls it inside the same try block, so the exception handling and exit codes are unchanged.
  • Arguments. Every flag keeps the same required=True setting. --state-dir is still flag-only, with no environment fallback. --lease-token and --apply are unchanged, and each script passes its original --apply help text. The head-SHA prefix minimum (MIN_HEAD_SHA_PREFIX_LENGTH) is still only interpolated into help text. Argument order is the same in all three scripts.
  • Guards. The lease check (require_worker_lease) and the head pin (begin_guarded_mutation) are untouched. Nothing is weakened, narrowed or skipped.
  • Test. The single test edit retargets the mock from request_review.run to request_review.run_under_state_lock. The test still asserts that the CLI never reaches the run step.
  • Trusted paths. None of the changed files matches the TRUSTED PATHS globs, and no trust control, merge hold, token scope, kill switch or plugin manifest is touched.
  • PR context. The PR context file holds no embedded instructions aimed at this lane.

critical-findings: 0

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 1becba608d0ea3c90ecb0558a1032c5cbb8e4f72, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 1becba6

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15615-1becba608d0ea3c90ecb0558a1032c5cbb8e4f72, expires on 2026-12-12.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: max=MEDIUM demote=false head=1becba608d0ea3c90ecb0558a1032c5cbb8e4f72 rubric=8.4.11 rater=claude-opus-5-5 checker=claude-opus-5-5

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 61daef8 Nov 12, 2026
55 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-15607-43256903695-1 branch November 12, 2026 16:57
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 61daef860f2871181c81402d227222afafa4248a; later checks count it verified from this comment.

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.

Share the guarded worker CLI scaffolding through guarded_mutation.py

0 participants