Skip to content

fix(work-resolve-issue): stop a run before its push when a listed human opens a PR for the issue - #17080

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/16748-stop-run-on-human-pr
Nov 18, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/16748-stop-run-on-human-pr

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Closes #16748

Summary

A dispatched work-resolve-issue run now stops before it opens a pull request when a listed human's open pull request, draft or ready, names the issue (Closes #N or Refs: #N). That covers both ways the lane opens one: a run that wrote a patch pushes no branch, and a run that reuses an earlier lane branch opens no PR from it. Either way the run takes the existing blocked-by-pr route: the issue keeps agent-ready, the stop comment names the human's pull request, and work-unblock starts the run again once that pull request merges or closes.

Fix

  • .github/scripts/intake-triage/admit.mjs: new exported humanPullsFor, built on openPullsFor, keeps the open pull requests whose author id is in the trusted-actor list's humans. This is the filter work-unblock's humanPull applied; humanPull in .github/scripts/work-unblock/label-unblocked.mjs now calls it, so only one copy of the reader remains.
  • .github/scripts/work-resolve-issue/check-human-pull.mjs (new): runs humanPullsFor for the issue with the default branch's trusted-actors.json, the same trusted-actor source admission and check-blockers use, and writes pull=<n> or pull=. The listed-human test reads the pull request's author id from the API. It never reads a pull request's title, body or login text.
  • .github/workflows/work-resolve-issue.yml: a new check-human-pull job runs after the model job, from the default branch tip with contents, issues and pull-requests: read only. It runs under the same written-patch condition as apply-issue-patch, and also when the run reuses a lane branch (scan-reuse-branch set), since such a run writes no patch and report-outcome opens the PR from the resumed branch. apply-issue-patch, the job that pushes the branch, now runs only when that job succeeded and named no pull request. report-outcome passes the job's output through as the new human-pull input.
  • .github/workflows/pr-run-activity-write.yml: the new human-pull input reaches the script only through env: (HUMAN_PULL). The first step checks it as a pull request number, in issue mode only.
  • .github/scripts/work-resolve-issue/report-outcome.mjs: on a done run with HUMAN_PULL set, decide routes blocked-by-pr, naming the pull request, before its resumed-branch PR open, so a reuse run is stopped by the same branch. Stops the run itself reported (hold, pushback, host-only and the rest) keep their own route, so a person's hold is never replaced by a wait.
  • scripts/read-lane-broker-check.test.sh: its caller context names check-human-pull's result, which apply-issue-patch's and report-outcome's conditions now read.

When the pull-request read fails: the script throws and check-human-pull fails. apply-issue-patch then does not run, so nothing is pushed and no pull request opens. This follows the same rule as the existing checks: admission awaits openPullsFor without a catch, so a failed read admits nothing (admit.mjs:2551), and report-outcome's own closer re-read before a PR open says "A failed read throws, like this script's other reads, and opens no PR" (report-outcome.mjs:2787-2788). report-outcome then receives escalation-reason: patch-apply-failed, the existing fault retry for a job that failed before it committed. On a reuse run the same escalation keeps the resumed branch's PR closed. The issue keeps agent-ready, work-unblock starts it again, and the failed job is named in the run's log.

The route follows the owner-approved acceptance on the issue (decision): the existing blocked-by-pr wait. Admission parks the same case at Work status deferred with a wait comment (admit.mjs:1586-1588, admit.mjs:2736). Inside a run, blocked-by-pr is the stop with the same effect: it waits on that pull request and restarts once it closes.

Verification

Run locally in the worktree with node --test --test-concurrency=4:

  • check-human-pull.test.mjs (new, 5 tests): a listed human's draft Refs: pull request is named; a listed human's closing pull request is named; with none, nothing is named; with only a non-listed author's pull request, nothing is named; a failed read rejects and writes no output. All five failed first, with the module missing (commit ba1a925), then passed.
  • report-outcome.test.mjs: a done run with humanPull routes wait/blocked-by-pr with pr=31 and opens no PR, the same run without it opens the PR, and a run's own intent-change stop keeps its hand-back. A reuse run with checks passed opens the PR from the resumed branch, waits on the human's pull request instead when humanPull is set (naming the branch), and opens none when the check failed (patch-apply-failed).
  • callers.test.mjs: apply-issue-patch needs check-human-pull and skips on a named pull request or a failed check; the check job's needs, permissions, script, trusted-actor path and output; the check runs for a written patch and for a reuse run, and not for an empty patch or no run (the reuse case failed before the workflow change, then passed); report-outcome passes human-pull and maps a failed check to patch-apply-failed; check-human-pull takes each resolve-issue value from the call that ran.
  • scripts/read-lane-broker-check.test.sh: 37/37. It failed in CI on the first ready run (Test Bash (3)), since its evaluator throws on the new needs.check-human-pull reference; fixed in 7039947.
  • Touched and neighbouring suites (check-human-pull, report-outcome, check-blockers, stop-routes, callers, admit, label-unblocked): 1942 pass, 0 fail. Further workflow-reading suites (apply-patch, lane-run-report, monitor-signals, publish-lane-level, refire-refused, pr-unblock workflow-gates and gate-source, handoff-evidence): 1850 pass, 0 fail. Action suites (log-api-budget, check-kill-switch, check-upstream-status, check-trusted-trigger, check-wip-cap, check-signed-commits): pass.
  • scripts/write-runner-never-rules.test.sh 75/75, write-runner-hold-labels.test.sh 12/12, write-runner-revoke-step.test.sh 7/7, check-read-caller-keys.test.sh 73/73, check-app-key-references.test.sh 9/9. check-read-caller-keys.sh --check, runner-policy.mjs, actionlint and zizmor --offline on both workflows, and check-line-citations.py: clean.
  • scripts/check-affected.sh after merging main: 14 passed, 5 skipped. check-changelog-fragments.sh --check-required origin/main: no plugin changed, so no fragment is needed.

Not verified: a live lane run on a real issue. The workflow wiring is covered only by the callers tests and the linters above.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 18, 2026 00:09
…'s open pull request

The issue lane must stop before its push when a listed human's open
pull request names the issue. These cases fail until the check exists:
a listed human's draft Refs pull request and closing pull request are
named, none and a stranger's pull request name nothing, and a failed
read fails the check.

Refs: #16748

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…an opens a PR for the issue

A dispatched run checked for a listed human's open pull request only at
admission and at a work-unblock re-fire, so a human's draft opened while
the run worked still got a duplicate lane branch and PR.

A new check-human-pull job runs after the model job and before
apply-issue-patch. It calls admit.mjs humanPullsFor, built on
openPullsFor with the listed-human filter work-unblock's humanPull used
(which now calls it too), with the trusted-actor list from the default
branch tip. When it names a pull request, apply-issue-patch pushes
nothing and report-outcome routes the done run as blocked-by-pr, which
keeps agent-ready and waits on that pull request. A failed read fails
the job, so nothing is pushed, and report-outcome routes it as the
patch-apply-failed fault retry.

Closes #16748

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 18, 2026 08:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T08:27:12.483863Z 047492e 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 Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 2b65a237d52a692c8ff9d3a7f0905e8a155eda39: read 10 of 10 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

This review was blocking only: the lane already reviewed an earlier head (047492e2), so it reports only CRITICAL and IMPORTANT findings. I read the whole diff for all 10 changed files. Five of them match trusted-path globs: resolve-config/callers.test.mjs, intake-triage/admit.mjs, work-resolve-issue/report-outcome.mjs, pr-run-activity-write.yml and work-resolve-issue.yml. A trusted-path match alone is not a finding.

Changes since the last review

  • The check now also runs on reuse runs. check-human-pull (work-resolve-issue.yml) now also runs when a run reuses an existing branch (scan-reuse-branch is set), not only when it wrote a patch. This widens when a read-only job runs. It widens no control:
    • Its permissions are still only contents, issues and pull-requests: read, with github.token. It gets no lane App token and no Claude credential.
    • It runs only code from the default branch tip, checked out into .base with persist-credentials: false.
  • Reuse-run stop (report-outcome.mjs). When HUMAN_PULL is set on a done run, decide now takes blocked-by-pr with branch || resumed. So on a reuse run, a listed human's pull request stops the lane before it opens a pull request from the resumed branch.
    • If the check fails on a reuse run, escalation-reason becomes patch-apply-failed, through needs.check-human-pull.result == 'failure'. That keeps the pull request closed, so the check fails closed on this path too.
  • scripts/read-lane-broker-check.test.sh. This only adds the new needs.check-human-pull.* context keys to a test fixture.

Rechecked from the earlier review

  • The push gate only adds a stop. apply-issue-patch still requires needs.check-human-pull.result == 'success' && needs.check-human-pull.outputs.pull == ''.
  • Trust filter. humanPullsFor (admit.mjs) still tests the pull request author's numeric user.id from the API against humans. Those come from the default branch's trusted-actors.json. Logins, titles and bodies are never used, so an outsider's cross-referencing pull request cannot stop a run.
  • HUMAN_PULL handling. The value reaches run: only through env:. It is checked as ^[1-9][0-9]{0,9}$ in the write runner's first step (issue mode only) and again in report-outcome.mjs.

No trust control is widened. No token scope grows, the trusted-actor check is not loosened, no new untrusted text reaches a credentialed lane, and no merge hold or kill switch is weakened. The pull request touches no plugin manifest. I found no embedded instructions in the PR context.

Spend (not a finding): each run that writes a patch, and now each reuse run, starts one more short job on a standard ubuntu-24.04 runner (timeout-minutes: 5). That job makes a few REST/GraphQL reads with github.token.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 2b65a237d52a692c8ff9d3a7f0905e8a155eda39: read 10 of 10 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #17080, stop a run before its push when a listed human opens a PR for the issue

Blocking only: this lane already reviewed an earlier head (047492e2), so this pass reports blocking findings only. I read all 10 changed files in full in .claude-lane/pr.diff. I also read the unchanged code they call:

  • decide in report-outcome.mjs, from the patchRefused branch through the resumed-branch paths
  • the if conditions of run-checks, report-outcome and report-statuses in work-resolve-issue.yml

The earlier advisory finding is fixed. It was that a reuse-branch run opened its PR without the check.

  • check-human-pull now also runs when scan-reuse-branch is set (work-resolve-issue.yml#L418-L420). In the expression, && binds tighter than ||, so this reads as !cancelled() && (started && written || reuse).
  • On a reuse run, a named pull request reaches the humanPull && outcome.exit === "done" branch. That branch comes before the resumed-branch open-pr path (report-outcome.mjs#L1501-L1511).
  • A failed check on a reuse run becomes patch-apply-failed with no branch. decide then retries instead of opening the PR (report-outcome.mjs#L1528-L1530).
  • The new tests in report-outcome.test.mjs and callers.test.mjs cover both cases.

Closing issue #16748 acceptance criteria:

  • Shared helper, exported once, built on openPullsFor: met. humanPullsFor is in admit.mjs, and humanPull in label-unblocked.mjs calls it.
  • Stops without pushing or opening a pull request: met on both paths:
    • Written-patch path: apply-issue-patch now runs only when check-human-pull succeeded with an empty pull.
    • Reuse path: decide routes the run to a wait before the PR opens.
  • Takes the blocked-by-pr route and names the PR: met. The tests assert pr: "31" and the comment text.
  • Tests with a listed human's PR present, absent, and only a non-listed author's PR: met in check-human-pull.test.mjs.

The test results in the PR description are the author's claims, not checked by me: this lane has no shell.

Loosened-check verdict: fail (no loosened_check_verdict: line in the prompt, so the default applies, with no consumer entries). No changed file loosens a check: the PR tightens the push gate and adds tests.

Spend (not a finding): each run that writes a patch or resumes a branch adds one short ubuntu-24.04 job (5-minute cap) and a few GitHub API reads. These use the existing Actions minutes and API budget.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 3 commits November 18, 2026 03:33
…eck-human-pull job's result

read-lane-broker-check.test.sh evaluates apply-issue-patch's and
report-outcome's if expressions, and its evaluator throws on any context
reference it lacks. Both now read needs.check-human-pull, so the caller
context names the job's success with no pull request.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…use run opens its PR

A reuse run writes no patch, so check-human-pull skipped and report-outcome
opened the lane PR from the resumed branch while a listed human's pull
request for the issue was open. The check now also runs when the run reuses
a branch; decide's existing blocked-by-pr branch stops that PR, and a failed
read still opens none.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 18, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held for the owner's sign-off on four choices the issue does not settle:

(a) A failed pull-request read fails closed: nothing is pushed, and the run is routed as the existing patch-apply-failed escalation.
(b) The stop routes to the existing blocked-by-pr wait, which keeps agent-ready and re-fires when the human's pull request closes, not to admission-deferred.
(c) The check is a separate job before the push, so a human pull request opened between the check and the push is not caught.
(d) The reuse-branch path now runs the same check before report-outcome opens a pull request from the resumed branch.

CI Status is green and both review lanes report 0 findings on 2b65a23. The label comes off when the owner decides.

@kyle-sexton

Copy link
Copy Markdown
Member Author

Owner decision, 2026-11-18, typed in the owning session: "go w/ recommendations" on Q69, option A: merge as built, with the four agent-made choices (fail closed on a failed PR read, the blocked-by-pr wait, a separate check job before the push, the same check on the reuse-branch path). The hold is lifted.

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 18, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit f1a8189 Nov 18, 2026
106 of 107 checks passed
@kyle-sexton
kyle-sexton deleted the fix/16748-stop-run-on-human-pr branch November 18, 2026 16:26
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(work-resolve-issue): stop a run when a listed human opens a PR for the issue mid-run

1 participant