Skip to content

fix(pr-pipeline): land issue-lane scripts executable through apply-patch - #9100

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/patch-mode-chmod
Oct 22, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/patch-mode-chmod

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Closes #9096

Summary

In the issue lane, a patch run committed new scripts as 100644, so check-affected's exec-bit
check failed and run 39729937593
stopped on #8324. Two things caused this. The chmod grant exists only for runs that commit
(collect-base-activity/action.yml, the elif CAN_COMMIT branch). And granting it in patch mode
would not help, because new-executable refuses any executable bit a patch carries
(apply-patch.mjs REFUSALS). With this change, apply-patch sets the bit itself, and the model
still sets no file mode.

Fix

  • apply-patch: under a new script-exec-bit row key, each new or changed file that ends in .sh
    or starts with #! is set to 100755 in the applied index once every refusal has passed. The
    tree is then rebuilt.
  • new-executable is unchanged for the patch's own entries. A bit the model set is still refused,
    on a script or on any other file. On a resumed run, refusals also cover what the start commit
    added, so a script's bit that only the start commit carries is admitted. That is the bit an
    earlier apply set.
  • patch-rules.json: the issue row sets script-exec-bit and now refuses instruction-path,
    so the issue lane pushes no plugin hooks, monitors, bin, or agent instruction files. checkRow
    fails any row that sets script-exec-bit without refusing instruction-path. The schema and
    the pr-pipeline README describe both.
  • In-run check: only in an issue lane's patch run, the checks wrapper exports
    CHECK_AFFECTED_SCRIPT_EXEC_BIT=1. check-affected.sh --uncommitted then gives its snapshot
    the same bits, so exec-bit passes inside the run. A run that commits gets no flag and still has
    to chmod its own scripts.
  • No broker-fetched file changed: UNIVERSAL_REFUSE and resolve.mjs are untouched, and none
    of the BROKER_PATHS files in pr-require-checks.yml is in the diff. No azure-iac pin is
    needed.

Verification

Each new test was run red before its fix and green after:

  • apply-patch.test.mjs, 93/93 pass. Red then green:
    • "a resumed run whose patch adds a gitlink to a commit not in the repository escalates
      patch-invalid". Red: Command failed: git ... cat-file blob abab..., because isScript read
      a gitlink's sha before any refusal ran. Fixed in bba6511: isScript checks the mode
      first, and start-commit entries get their refusal list lazily.
    • "a new or changed file that ends in .sh or starts with #! lands 100755; any other file keeps
      100644"
    • "a resumed run keeps the executable script its earlier lane commit landed; a non-script made
      executable there is still refused"
    • "a script under an instruction path is refused before any API call"
    • "a row that sets script exec bits must refuse instruction paths"
    • the updated issue-row refuse pin
  • The guard "an executable bit the patch itself sets is refused, on a script or not" passed
    before and after the change, as a guard test should.
  • collect-base-activity.test.mjs, 112/112 pass. "only an issue lane's patch run gets a wrapper
    that sets the script exec bit" was red, then green.
  • check-affected.test.sh exits 0. "--uncommitted with CHECK_AFFECTED_SCRIPT_EXEC_BIT judges a
    new #! file as executable" was red with FAIL exec-bit, then green.
  • The resolve-config suites pass, 802 in total across the node suites.
  • check-affected.sh --uncommitted --base origin/main: 8 passed, 5 skipped.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 22, 2026 11:40
The issue lane's patch committed new scripts as 100644, so check-affected's
exec-bit check failed and run 39729937593 stopped. apply-patch now sets
100755 itself, after every refusal passes, on each new or changed file that
ends in .sh or starts with #!, under a new script-exec-bit row key the issue
row sets. new-executable still refuses any bit the patch itself carries; on
a resumed run, a script bit only the start commit carries is admitted.

The issue row now refuses instruction-path, and a row that sets
script-exec-bit must. The issue lane's checks wrapper sets
CHECK_AFFECTED_SCRIPT_EXEC_BIT=1, so check-affected --uncommitted gives its
snapshot the same bits and exec-bit passes inside the run.

Closes #9096

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

chatgpt-codex-connector Bot commented Oct 22, 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-22T15:58:29.687554Z 948f7c5 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 22, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review (incremental, since 948f7c5)

I found no security issues in apply-patch.mjs or apply-patch.test.mjs. Nothing outside those two files was re-read, and I did not run the tests.

isScript (.github/scripts/apply-patch/apply-patch.mjs):

  • It now checks that the new mode is regular or executable before reading any blob. Before, a gitlink's commit SHA or a symlink could reach git cat-file blob. For a resumed run's gitlink to a commit not in the repo, that read threw instead of refusing cleanly.
  • The change only tightens the check. A symlink or gitlink at a .sh path used to count as a script and so skipped the new-executable refusal. It now takes the full refuse list.
  • Deletions have mode 000000 and are not scripts. This matches the old zero-SHA exclusion.
  • Every row must name symlink and gitlink in refuse. The validator at line 258 enforces this, and only backslash is exempt through ALWAYS. So gitlink and symlink entries that reach the checks are refused.

Lazy checks (lines 540–552): The checks run in the same order as before, and each list is computed only when its turn comes. The patch's own entries are refused before isScript reads any blob from the resumed range. A refused entry still returns before any blob write or API call. The new test asserts api.calls is empty.

Line 578 (the script-exec-bit promotion): It uses the same stricter isScript, so it cannot promote a non-regular entry to 100755.

The change touches no manifest, so there are no manifest <field> lines. It is not an instruction-surface change.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

No findings. I reviewed the incremental change since 948f7c5 in apply-patch.mjs and apply-patch.test.mjs.

  • isScript mode check: It now requires newMode to be 100644 or 100755 before reading a blob. A gitlink, symlink or deleted entry (000000) is never read as a blob, and the deleted case is still covered because the old ZERO.test(newSha) guard is now implied by the mode check. The other caller, the exec-bit step at line 578, only sees written entries, and gitlinks and symlinks are already refused by then.
  • Lazy refusal lists: Each check is now a thunk, so isScript runs only when that entry's turn comes. The patch's own entries are checked first. A gitlink to a missing commit now escalates patch-invalid through the gitlink refusal instead of crashing on cat-file blob. The ordering is unchanged otherwise.
  • New test: It covers the crash case and asserts no API calls. I only read it. I did not run the suite, and the 93/93 result in the PR description is author-claimed.

On a resumed issue-lane run, isScript ran while the refusal list was being
built. That was before any refusal, so for a gitlink it read the entry's
commit sha as a blob, and the uncaught git error came before the gitlink
refusal could escalate patch-invalid. isScript now admits only 100644 and
100755 entries before it calls git. The start commit's entries also get
their refusal list only when their turn comes, after the patch's own
entries have passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 6a69302 Oct 22, 2026
52 of 53 checks passed
@kyle-sexton
kyle-sexton deleted the fix/patch-mode-chmod branch October 22, 2026 16:10
kyle-sexton added a commit that referenced this pull request Oct 22, 2026
Compose both new --uncommitted test cases in scripts/check-affected.test.sh:
the branch's CHECK_DATA_ROOT case and main's CHECK_AFFECTED_SCRIPT_EXEC_BIT
case (#9100).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-merge-queue Bot pushed a commit that referenced this pull request Oct 22, 2026
…mode and report the patch escalation (#9182)

Closes #9180

## Summary

Fixes two issue-lane defects found in [run
39836229787](https://github.com/melodic-software/claude-code-plugins/actions/runs/39836229787)
(#9161):

1. The lane bumped `plugins/corrections/.claude-plugin/plugin.json`, and
since #9100 the `issue` row's `instruction-path` refusal blocks that
path. The bump was the real defect. `corrections` (#8822) and
`app-control` (#8820) were never added to
`scripts/fragment-plugins.txt`, so the lane followed an unlisted
plugin's per-PR rules and bumped the version. Every other plugin is
listed, and only the release PR moves a version
(`scripts/check-changelog-parity.sh:101-110`, `pr-require-checks.yml`
changelog-parity comment).
2. report-outcome never received apply-issue-patch's escalation reason,
so it told the issue "The run reported done but committed nothing" when
the patch had in fact been refused.

## Fix

- **Fragment list:** `scripts/fragment-plugins.txt` now lists
`corrections` and `app-control`. Every directory under `plugins/` is
listed (checked with `comm`). The lane's per-PR rule is now a fragment,
and `instruction-path` still refuses every `plugin.json` change, as
#9100 intended. An earlier commit on this branch added a version-only
`plugin.json` admission; the security review (S&C) questioned it and it
is removed.
- **report-outcome**:
- `work-resolve-issue.yml` passes
`needs.apply-issue-patch.outputs.escalation-reason` to report-outcome.
- `report-outcome.mjs` validates `ESCALATION_REASON` against
`PATCH_REASONS` and throws on an unknown value.
- When a `done` run's patch was refused (`patch-protected-path`,
`patch-invalid` or `patch-not-applied`), report-outcome hands the issue
back naming the reason and opens no PR, from a resumed branch either. On
a resumed run the hand-back names the resumed branch.
  - `patch-empty`, and every non-done exit, keep their current plan.
- **Write runner input check** (`pr-run-activity-write.yml`): accepts
the four `patch-*` reasons in issue mode only. pr-unblock's
report-escalation still takes none, as `callers.test.mjs` documents.
- **Refused path not passed through.** report-outcome does not receive
it. Passing it would need a new apply-patch output, a reusable-workflow
output and input, and sanitizing of a path the model chose before it
goes into an issue comment. The hand-back links the run, whose log has
the `refused (<refusal>): <path>` line.
- Docs: the `report-outcome` paragraph in `pr-run-activity.md`, plus a
`pr-pipeline` changelog fragment (patch).

## Verification

- **Both plugins are now listed.** `comm` of `plugins/` against
`scripts/fragment-plugins.txt` shows no plugin missing.
`check-changelog-fragments.sh --check` and `check-changelog-parity.sh
--check` both pass. The `changelog-fragments` and
`check-changelog-parity` test scripts pass: 14 and 111.
- **The #9161 patch, committed at base `ba598f08d3` in a scratch
worktree, against `check-changelog-parity.sh --check-bump ba598f0`:**
- With the old list it exits 0, and the gate lets the lane's bump
through.
- With this branch's list it exits 1: `FRAGMENT-MODE RELEASE:
corrections is in fragment mode ... moves its version 0.5.0 -> 0.6.0`,
and again for the added `0.6.0` heading.
- **report-outcome:** six new tests failed before the fix and pass after
it: the refused-patch hand-back, the resumed case, `main` naming the
reason, and an unknown reason refused. Guard tests show `patch-empty`
and pushback plans unchanged.
- **callers:** two new tests, for the `escalation-reason` wiring and the
issue-mode-only input check, failed on the old workflows and pass now.
- **Suites:** `node --test` over `work-resolve-issue` and `apply-patch`
passes, 344 of 344. `.github/actions/resolve-config` passes, 600 of 600.
`report-escalation.test.sh`: ok. The pre-push `check-affected` hook
passed.

## Related

- #9161, the run diagnosis.
- #8639.
- #9100, which added `instruction-path` to the issue row.
- #9211, version_sort_key hardening, found in the same review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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(pr-pipeline): make new scripts executable in issue lane patch mode

1 participant