Skip to content

fix(source-control): hold plugin-declared executable paths on the merge floor - #8479

Merged
kyle-sexton merged 9 commits into
mainfrom
fix/source-control-merge-floor-declared-executables
Oct 19, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
fix/source-control-merge-floor-declared-executables

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: Phase 2 of the lane-funding write-lane plan (owner-approved 2026-10-19), a merge-floor hardening ahead of lanes that author plugin code

Hold: a human merges this

Summary

The pr-merge risk scorer's HIGH floor holds listed paths (hooks, lib/, .claude-plugin/, and so on) for a human merge. Write lanes are about to author plugin code, so the floor now also reads every plugin's declarations at the base SHA and holds each path a plugin declares as executable.

Fix

  • babysit_risk.py: RiskInput.declarations takes the base-side text of these declaration files: plugin.json, .mcp.json, hooks/hooks.json, .lsp.json, and monitors/monitors.json (the documented monitors array).
    • Covered keys: hooks, mcpServers, lspServers, monitors and experimental.monitors, plus plugin.json string pointers to other config files.
    • Every ${CLAUDE_PLUGIN_ROOT}-relative or ./-relative path joins the HIGH match as the directory that holds it.
    • It fails closed (HIGH) on:
      • an unreadable or unparsable declaration;
      • an unread pointer, or a path that leaves its plugin;
      • any CLAUDE_PLUGIN_ROOT spelling the parser cannot resolve.
    • plugins/*/bin/** joins HIGH_FLOOR, since bin/ is on the Bash tool's PATH while the plugin is enabled.
  • babysit_merge_policy.declarations_at reads the declarations at pr.base.sha, never the head, so a PR cannot drop its own declaration to escape the floor.
    • With a clone holding the base (the pr-merge CI checkout), it reads every plugin through git with no API calls.
    • Without a clone, it reads only the plugins the PR's changed paths sit in, and nothing for a PR outside plugins/. This keeps the lanes App's hourly API budget intact.
  • babysit_merge.score_unattended passes the declarations whenever the high floor applies.
  • Existing tests: one shared harness fake in test_babysit_merge_unattended.py returns an empty declaration set. No assertion changed.

Verification

  • pytest plugins/source-control/skills/babysit-prs/scripts/tests: 2064 passed, 1 failed. The failure is test_guards::test_the_recording_shim_is_reachable, which fails the same way on main under this host's Python.
  • 42 new tests in test_babysit_risk_declared_executables.py, including end-to-end score_unattended cases. With main's scorer and reader restored, 37 of 38 fail; the one that passes is the LOW control.
  • Ruff via scripts/run-ruff.sh: clean.
  • Two fresh-context verifier passes. The first failed one criterion (unparsed CLAUDE_PLUGIN_ROOT spellings slipped through) and the second passed. The second's high finding, the monitors array shape, is fixed here.

A bare ${CLAUDE_PLUGIN_ROOT} argument floors the whole plugin (about 13 plugins today). That is deliberately conservative.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 8 commits October 19, 2026 12:30
…ge floor

The risk scorer takes each plugin's plugin.json, .mcp.json and
hooks/hooks.json as read at the base commit (RiskInput.declarations) and
joins every path they declare as run to the HIGH floor: each
${CLAUDE_PLUGIN_ROOT} reference, and plugin.json's ./ paths under its
executable keys. A declaration it cannot read, an unknown declaration
file, or a path outside its plugin rates HIGH as high-path:**.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…merge gate

score_unattended now reads each DECLARATION_FILES file at the base SHA
(babysit_merge_policy.declarations_at: a clone holding it, else the
contents API) whenever the floor applies and passes them to the risk
scorer. A file that cannot be read is passed as (path, None), and a base
tree that cannot be listed as None, both scoring HIGH. The unattended
test harness answers the new read with no declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…touched plugins

The scorer also reads .lsp.json, monitors/monitors.json, plugin.json
experimental.monitors, and config files a plugin.json executable key
points at (declaration_pointers); a pointer not read is unsafe. Any
plugin-root reference it cannot resolve (a default, a trim, $env: or
%...%) is unsafe, and ./ and ../ paths in any declaration resolve
against the plugin root.

declarations_at now reads only the plugins the pull request's changed
files sit in, plus their pointed config files, and nothing for a change
outside every plugin. The test fixtures use made-up plugin names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a clone holds the base SHA, declarations_at reads every plugin's
declarations through git, which costs no API call, so an untouched
plugin whose declared path escapes into a changed plugin holds the pull
request. Without a clone it still reads only the touched plugins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ectories

A monitors file, monitors/monitors.json or one a monitors key points at,
is read as the documented top-level array or as an object; every other
declaration must still be an object. HIGH_FLOOR holds plugins/*/bin/**,
whose files are on the Bash tool's PATH while the plugin is enabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 19, 2026 17:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T17:57:17.471898Z 9008a53 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

No security findings in the incremental change since 9008a53.

  • babysit_risk.py: **/.lsp.json joins the HIGH floor beside **/.mcp.json. A pull request that adds or edits an LSP server declaration (a file that can name an executable to run) now scores HIGH. This tightens the merge gate and removes no control.
  • Test file: the new test checks that a changed .lsp.json scores HIGH. The module also clears inherited GIT_* variables before any test spawns git, so fixture git calls can't write into the caller's repository. That only affects the test process, and it adds no attack surface.
  • Changelog fragment: documentation only. It matches the code change.

I did not consult the instruction exception register. The diff deletes and softens no standing instruction.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 402ea7215098fde1c0870dfaf3f3d697aa17d121: 0 finding(s), 0 as inline comments.

Incremental review of 402ea72 against 9008a53 (3 files). No findings.

  • **/.lsp.json added to HIGH_FLOOR (babysit_risk.py:189): it sits beside **/.mcp.json, and the entry matches the existing DECLARATION_FILES item for plugins/*/.lsp.json. An edit to the declaration file itself now scores HIGH even when no base declaration exists. The new test_declared_executable_changed_lsp_declaration_scores_high covers that, with declarations=() and the high-path:**/.lsp.json code. I searched the repo for a second copy of the floor list (docs, conventions, other scripts), such as one that lists AGENTS.override.md. Only babysit_risk.py and test_babysit_risk.py list it, so no copy needs updating. I did not run the tests. Verification claims in the PR body are the author's and unverified by me.
  • Test git-env isolation: the module-level clear of GIT_DIR, GIT_WORK_TREE, GIT_CONFIG and related variables follows the idiom that scripts/check-fixture-git-isolation.sh describes for Python suites. It runs before the first git spawn, and the noqa: E402 markers are the matching import consequence.
  • Changelog fragment: the added .lsp.json clause matches the code change.

The earlier-reviewed files are unchanged since the last review and were not re-reviewed.

…ble tests from git env

Hold `**/.lsp.json` on the HIGH floor beside `**/.mcp.json`, with a test that
a pull request changing only a plugin's .lsp.json scores HIGH.

Clear inherited GIT_DIR, GIT_WORK_TREE and GIT_CONFIG at the top of
test_babysit_risk_declared_executables.py, which builds git fixtures, so
the fixture-git-isolation hygiene check passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit a410222 Oct 19, 2026
25 checks passed
@kyle-sexton
kyle-sexton deleted the fix/source-control-merge-floor-declared-executables branch October 19, 2026 18:20
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.

1 participant