Skip to content

fix(pr-pipeline): hold an apply-patch push on a body Hold: line - #10300

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/8998-apply-patch-body-hold
Oct 26, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/8998-apply-patch-body-hold

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #8998

Summary

For the pr target, held() in apply-patch.mjs rechecked draft state and hold labels at push time, but not a body hold. A Hold: line added to an owner's PR while a lane worked did not stop that run's push. The recorded decision on #8998 asks for three things:

  • Reuse the existing body-hold pattern.
  • Read the lanes App login from one shared module.
  • Hold every pr-target push on a PR the lanes App did not open.

The issue lane could not build this. apply-patch.mjs runs from $RUNNER_TEMP/base-script, so a ../pr-merge/ import needs a copy step in pr-run-activity-write.yml, and the issue lane's patch rules refuse github-workflows.

Broker note: .github/workflows/pr-run-activity-write.yml is a broker workflow-modified file in this PR.

Fix

  • held() (pr target) returns held when the PR body matches BODY_HOLD from merge-holds.mjs, unless the lanes App opened the PR (pull.user.type == "Bot" and the login matches). BODY_HOLD is the existing export; this PR adds no new regex.
    • BODY_HOLD matches a line opening with Hold: in any case, after any whitespace including NBSP, with a bare CR also ending a line.
    • It also matches "do not merge" anywhere in the body, so that text now holds an owner PR's lane push too.
    • On the lanes App's own PR, the line holds the merge, not a fix.
    • The check covers every pr-target push, merge rows included.
  • The lanes App login is a new export of merge-holds.mjs, LANES_APP_LOGIN. The module stays import-free, because ci-status runs it alone.
    • clear-escalations.mjs and refire-refused.mjs now import it in place of their own DEFAULT_BOT literals, so the change adds no net copy.
    • The PR adds no environment variable.
  • pr-run-activity-write.yml's "Copy the apply-patch base files" step copies merge-holds.mjs to $RUNNER_TEMP/pr-merge/, so the ../pr-merge/merge-holds.mjs import resolves from the base-script copy.
  • scripts/write-runner-never-rules.test.sh now checks that every sibling-directory import of apply-patch.mjs and predicates.mjs is copied, and that its directory is created. Before, it checked only the pr-unblock imports of predicates.mjs.
  • Changelog fragment: .changes/pr-pipeline/fix-8998-apply-patch-body-hold-8f6de948.md (patch).

Verification

  • New tests in apply-patch.test.mjs:
    • An owner PR is held for each of these body forms: Hold: on its own line, a lowercase hold: first line, an NBSP-led Hold:, a bare-CR \rHold:, and \r\n HOLD:. With the base apply-patch.mjs restored, this test fails (✖ a Hold: line in an owner PR's body drops the patch uncommitted).
    • A lanes App PR with Hold: is not held and its branch moves.
    • An owner PR with Hold: mid-line pushes.
    • The last two pass before and after the change. They guard against a fix that holds too much.
  • write-runner-never-rules.test.sh fails without the new copy line (FAIL: the apply-patch base copy holds every sibling-directory module ...) and passes with it (PASS=76 FAIL=0).
  • Runtime layout replay: apply-patch.mjs was copied into a scratch base-script/ with the step's pr-unblock copies. import() failed ERR_MODULE_NOT_FOUND until pr-merge/merge-holds.mjs was copied, then loaded.
  • node --test on apply-patch.test.mjs, every .github/scripts/pr-merge/*.test.mjs, callers.test.mjs, models.test.mjs, check-signed-commits.test.mjs, label-unblocked.test.mjs and rate-guard.test.mjs: 1050 pass, 0 fail.
  • Shell suites, all FAIL=0:
    • act-turns-denied
    • check-app-key-references
    • check-read-caller-keys
    • pr-unblock-trusted-base
    • write-runner-over-cap-success
    • write-runner-promote-holds
    • write-runner-revoke-step
    • ci-lanes-pr-hold (runs merge-holds.mjs alone)
    • ci-hold-merge-group
  • actionlint .github/workflows/pr-run-activity-write.yml: clean.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits October 25, 2026 15:53
held() for the pr target now treats a pull request the lanes App did not
open as held when its body matches merge-holds.mjs BODY_HOLD (a Hold: line
in any case after any whitespace, NBSP included, a bare CR ending a line, or
"do not merge"). On the lanes App's own PR that line holds the merge, not a
fix, so it does not stop the push. Every pr-target push reads it.

The lanes App login is one export of merge-holds.mjs, which stays
import-free; clear-escalations.mjs and refire-refused.mjs read it in place
of their own literals. The write runner's "Copy the apply-patch base files"
step copies merge-holds.mjs to $RUNNER_TEMP/pr-merge so apply-patch's
../pr-merge import resolves from its base-script copy, and
write-runner-never-rules.test.sh checks every sibling-directory import of
apply-patch.mjs and predicates.mjs is copied.

Closes #8998

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

# Conflicts:
#	.github/scripts/pr-merge/clear-escalations.mjs
#	.github/scripts/pr-merge/merge-holds.mjs
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T15:47:17.790847Z 92c8a1f PR opened
ℹ️ 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

Copy link
Copy Markdown
Contributor

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

No security findings.

critical-findings: 0

I read the whole diff and the PR context. Both treat the PR context as data. I also checked merge-holds.mjs for side effects on import.

  • apply-patch.mjs held(): The change only adds a hold condition to the existing draft and label checks, so it narrows what a lane push can do. BODY_HOLD is reused unchanged, and the lanes-App exemption can't be forged. It requires pull.user.type === "Bot" and an exact login match, and an owner can't claim a [bot] login. The exemption only skips the new body check. Draft state and hold labels are still enforced on the App's own PRs. Before this PR no body check ran on any PR, so the exemption widens nothing.
  • merge-holds.mjs (trusted path): The only change is a new LANES_APP_LOGIN export. BODY_HOLD, HUMAN_VETO and LANE_HOLD are unchanged. The module's main() is guarded by an import.meta.url check, so importing it from apply-patch.mjs runs nothing. It still imports only node: built-ins.
  • clear-escalations.mjs and refire-refused.mjs (trusted path and caller): The local DEFAULT_BOT literal is replaced by the imported constant. The value is identical, so the trusted-actor and bot checks they perform are unchanged.
  • pr-run-activity-write.yml: The new cp reads merge-holds.mjs from .base, the base checkout, not from the PR head. A PR can't substitute its own hold logic, and no token scope or permission changes. The mkdir only adds a directory under $RUNNER_TEMP.
  • write-runner-never-rules.test.sh and the changelog fragment: These are tests and a changelog fragment, with no runtime effect.

Spend: none. The change adds no lane runs, turns, models or billed resources.

@github-actions

Copy link
Copy Markdown
Contributor

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

No findings. I read the full diff and the PR context, and checked the import layout and the callers myself. I did not run any tests, so the test results in the PR description are the author's claims and I have not verified them.

Acceptance criteria from #8998

  • Owner PR with a Hold: line is held. held() in .github/scripts/apply-patch/apply-patch.mjs now returns held when !lanesApp && BODY_HOLD.test(body). The new test covers five body forms: a standalone Hold: line, lowercase, an NBSP-led line, a bare CR, and \r\n with leading spaces. The NBSP and bare-CR forms are in that test.
  • Lanes App PR is not held by held(). lanesApp requires both user.type === "Bot" and the login match, and a test covers it.
  • One shared login, no new env var. LANES_APP_LOGIN is a new export of merge-holds.mjs. clear-escalations.mjs and refire-refused.mjs now import it. The PR names the other literal copies it leaves for a follow-up, and that is acceptable.
  • No new regex. The change reuses the BODY_HOLD export.
  • Tests that fail first. The author reports the owner-PR test fails against the base apply-patch.mjs. I have not run that.

Import layout and callers

  • Runtime layout. apply-patch.mjs runs from $RUNNER_TEMP/base-script, and its ../pr-merge/merge-holds.mjs import resolves to $RUNNER_TEMP/pr-merge/. The new mkdir and cp in .github/workflows/pr-run-activity-write.yml create exactly that path.
  • Other importers. The only other importers of apply-patch.mjs are tests, which run in-tree where the sibling exists.
  • merge-holds.mjs is import-safe. It has only node: imports, and its CLI entry point is behind an import.meta.url guard at .github/scripts/pr-merge/merge-holds.mjs:949. Importing it has no side effects, and it stays usable by ci-status alone.
  • refire-refused.mjs. It runs in-tree from .base/.github/scripts/pr-merge/ in pr-merge.yml, so its new sibling import resolves.
  • Guard test. The change to scripts/write-runner-never-rules.test.sh generalises the copy check to every sibling-directory import of apply-patch.mjs and predicates.mjs. It also checks that the destination directory is created.

Noted, not a finding. BODY_HOLD also matches "do not merge" anywhere in the body. So that phrase now blocks every pr-target push on a PR the lanes App did not open, merge rows included. The PR description and changelog both state this, and it follows the owner's decision to reuse the existing pattern. The tests cover only the Hold: forms, not the "do not merge" form.

Cost. None. There is no paid plan, billing or billed-resource change.

The PR touches trusted paths, including merge-holds.mjs. The change only narrows what a lane may push, with no widening of any gate.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 77804a9 Oct 26, 2026
39 checks passed
@kyle-sexton
kyle-sexton deleted the fix/8998-apply-patch-body-hold branch October 26, 2026 16:46
kyle-sexton added a commit that referenced this pull request Oct 26, 2026
Brings in #10300, #10116 and the #10305 release; merged cleanly.

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.

pr-pipeline: apply-patch held() honours a Hold: line added to an adopted owner PR mid-run

1 participant