Skip to content

feat(pr-pipeline): send etag on the handoff job poll and hold pr-unblock dispatch on a failed read - #12782

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12292-41586958844-1
Nov 3, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12292-41586958844-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Refs: #12292

Summary

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

Takes up two of the ten open criteria in the 2026-11-03 decision on #12292, one in full and one in part. In full: work-resolve-issue and pr-refine element 6. handoff-evidence.sh now reads the job listing a page at a time and sends each repeat of a page that came with an etag as a conditional request; a 304 reuses that page's stored body and next link, and a cut-off or empty 200 is a failed read. In part: pr-unblock element 2. Every dispatcher in pr-unblock-dispatch.yml (dispatch.mjs, fix-ci-dispatch.mjs, fix-docs-dispatch.mjs, dependency-dispatch.mjs) now skips with a warning on any failed read, the open-PR listing and the mergeable re-query included, instead of ending the run red; a failed dispatch still fails. Choice of means: I took the criteria that are script-only and need no workflow change to stay safe. The --find-prior, resolve-pr and apply-verdict holds need a caller or re-trigger change in a workflow, and the rate-guard and reconcile changes alter a shared trust or stop mechanism, so those stay in remaining.

Remaining work

  • shared, element 1: check-trusted-trigger.mjs waits on the rate latch instead of refusing, with a test.
  • shared, elements 1 and 2: rate-guard.mjs waits out a short reset and holds instead of failing the step, with a test.
  • work-resolve-issue, elements 2 and 4: report-outcome.mjs --find-prior holds on a failed read, a failed labeler read no longer holds the PR, and stop-routes.json retry-spent no longer fails the issue when every retry was a fault, with tests.
  • intake-triage, element 2: apply-verdict.mjs holds green with a notice on an admission or read error, with a test.
  • work-unblock, elements 2, 3 and 6: label-unblocked.mjs holds on a failed listing without losing the closes that listing missed (the sweepSince window), drops the stored breaker-trip records, and sends etag on the sweep, with tests.
  • pr-refine, elements 1 to 4: handoff-evidence.sh uses capped backoff with full jitter and a green hold on a failed read, fix-docs-dispatch.mjs no longer counts a red outage run as done, and report-check-run decide.mjs no longer posts failure on no verdict, with tests.
  • pr-review, pr-review-security and pr-verify, elements 3 and 5: maintenance-reconcile-lost-runs reconcile.mjs drops the status-page gate and the one-time re-run record, with a test.
  • pr-verify, elements 2 and 6: resolve-pr.mjs completeness throws hold instead of going red, and check-trusted-trigger.mjs sends etag on the re-run record poll, with tests.
  • pr-unblock, elements 3 and 4: limit-stop.mjs's per-head cap stops acting as a stored breaker, and escalation-routes.json files no fail route on a job fault, with tests (this change did element 2).

Not verified

  • The node test suites for the six changed or new test files (handoff-evidence.test.mjs, callers.test.mjs, dispatch.test.mjs, fix-ci-dispatch.test.mjs, fix-docs-dispatch.test.mjs, dependency-dispatch.test.mjs) were not run: this lane runs check-affected without --tests and allows no node command. I…
  • Tidy skipped: the change is 15 files and about 450 changed lines across several areas, and it touches .github/, a listed shared path, so it is over the tidy cutoffs.
  • Review nit not acted on: gh prints a gh: HTTP 304 line on stderr for each 304 answer, which adds a log line per unchanged page.
  • fix-ci-dispatch.mjs still dispatches under its caps when it cannot read its required run or the head's check runs for a reason other than a 5xx or a rate limit, or when the verifier reader fails. This is a deliberate fail-open from before, so a run that is gone for good cannot strand a PR. I kept…
  • The source-control plugin is not loaded in this lane, so /source-control:pull-request prep ran only as the review and the checks above.
  • The repository root has untracked dotfiles this run did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc), likely sandbox mount points. I left them untouched; they are not part of this change and should stay out of the patch.

Fix

  • .github/scripts/lib/handoff-evidence.sh: read_jobs reads the jobs listing page by page with gh api -i, keeps each page's ETag, body and next link once its body parses, sends If-None-Match on a repeat, reuses the stored page on a 304, and fails a 200 whose gh exit is not 0 or whose body is empty
  • .github/scripts/lib/handoff-evidence.test.mjs (new): five tests on a stub gh: conditional repeat and 304 reuse, per-page ETags through the Link header (a 304 with no Link), no-ETag and 502 pages, a cut-off or empty 200, and the final failure
  • .github/actions/resolve-config/callers.test.mjs: the readPosted gh stub answers gh api -i with a 200 and the listing, and three call-line assertions expect api -i ... instead of --paginate ... --jq
  • .github/scripts/pr-unblock/dispatch.mjs: a failed open-PR listing, mergeable re-query, run listing, holds or check-run read, or shared-copy read logs a warning and holds instead of counting a failure; header comment updated; unused serverFailure import removed
  • .github/scripts/pr-unblock/dispatch.test.mjs: tests updated to the hold, plus new tests for a failed open-PR listing in main and a failed mergeable re-query
  • .github/scripts/pr-unblock/fix-ci-dispatch.mjs: the run listing, hold, fix-ci check-run and annotation reads hold with a warning on any failure
  • .github/scripts/pr-unblock/fix-ci-dispatch.test.mjs: four tests updated to expect warnings and no failure
  • .github/scripts/pr-unblock/fix-docs-dispatch.mjs: the run listing, history or holds, and per-head run reads hold with a warning on any failure; unused serverFailure import removed
  • .github/scripts/pr-unblock/fix-docs-dispatch.test.mjs: three tests updated to expect warnings and no failure
  • .github/scripts/pr-unblock/dependency-dispatch.mjs: a failed check-run read holds with a warning; unused serverFailure import removed
  • .github/scripts/pr-unblock/dependency-dispatch.test.mjs: the rate-limit case and a new 404 case expect a warning and no failure
  • docs/conventions/pr-pipeline/README.md: pr-unblock-dispatch bullet on failed reads holding, with fix-ci's kept fail-open reads and the rate-guard exception
  • docs/conventions/pr-pipeline/pr-run-activity.md: handoff evidence reads send conditional requests for pages that came with an etag
  • docs/outage-posture-audit.md: Remaining records the fourth part 2 change, drops the handoff-evidence element 6 row and narrows the pr-unblock row to elements 3 and 4
  • .changes/pr-pipeline/work-resolve-issue-issue-12292-41586958844-1-e1a801cc.md (new): patch fragment describing both changes

Verification

The runner ran each check from the base copy against 2186752:

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

The run reports:

  • check-changelog-fragments: all 33 fragments valid (run before and after the review fixes)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: first run failed shellcheck SC2310 on if read_jobs; fixed with a reasoned disable directive; the last three runs show 11 passed, 4 skipped over 15 changed files (shellcheck, markdownlint, shell-portability, comment-hygiene among the passes)
  • cant-fail-scan --check --file on handoff-evidence.test.mjs, dispatch.test.mjs, fix-ci-dispatch.test.mjs, fix-docs-dispatch.test.mjs, dependency-dispatch.test.mjs and callers.test.mjs: PASS, no gating findings
  • fresh-context review subagent over the whole diff: no blocker; fixed the unguarded getPulls re-query, made handoff-evidence fail a cut-off or empty 200 and keep only parsed pages, and corrected the docs (rate-guard exception, fix-ci's kept fail-open reads, 'each page that came with an etag')
  • read https: //docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api: under 'Use conditional requests', most endpoints return an etag; send it in if-none-match; an unchanged response is 304 Not Modified, which does not count against the primary rate limit when the request…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41586958844

Left out: the items under Not verified.

Related

#12292

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

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 21867523f4f4ff8f9149ce5f6ae0ac0b6a783990: read 15 of 15 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #12782

No security issues found in this change.

critical-findings: 0

Scope. I read every hunk of all 15 changed files in .claude-lane/pr.diff. None of them match a listed trusted-path glob. I also checked whether the changed dispatchers are part of a merge-hold control: merge-holds.mjs, enable-auto-merge.mjs, superseded.mjs and clear-escalations.mjs import none of dispatch.mjs, fix-ci-dispatch.mjs, fix-docs-dispatch.mjs or dependency-dispatch.mjs. These files only decide whether a dispatch is sent. They do not decide merges.

What I checked

  • handoff-evidence.sh page-by-page reads with ETag (L111-L142).
    • The URL for the next page comes from GitHub's own Link response header. The job-listing data feeding the posted, allowed, handed-off and stale answers is the same as before, so no new untrusted text gets in.
    • A 304 reuses a stored body only when the request was conditional, and only a body that parsed is stored.
    • A cut-off or empty 200 still counts as a failed read, through jq input and gh's exit status.
    • The 20-page limit means a Link header that never ends cannot loop forever.
    • The ETag value goes into -H as one array element, so it cannot inject arguments.
  • Dispatcher reads that fail now skip with a warning instead of ending the run red. In every changed path a failed read leads to continue, return, or pending = [], so it never leads to a dispatch.
    • A failed read of a hold (where the human-gated label came from, prHold) now skips the PR. That fails closed: an unreadable hold cannot let a dispatch through.
    • A failed open-PR listing returns before the dispatch record is read or written, so no record state gets corrupted.
  • Existing behaviour that is unchanged. fix-ci still dispatches under its caps on some failed reads. That fail-open predates this PR, and this diff does not widen it.

Trust controls. Nothing in the diff touches the trusted-trigger check, the lane token's scope, the kill switch, the token broker, or the merge holds. No plugin manifests changed. No standing instructions were deleted or softened.

Spend. The change spends only GitHub API rate-limit budget, and it lowers that use, because unchanged pages come back as 304 answers. It adds no billed resource.

Embedded text. The PR context contains no instructions aimed at this lane.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 21867523f4f4ff8f9149ce5f6ae0ac0b6a783990: read 15 of 15 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read the whole diff for all 15 files. Nothing in it meets the bar for a blocking or advisory finding.

What I checked

.github/scripts/lib/handoff-evidence.sh (read_jobs)

  • Status parsing. It reads the status from the first line of gh api -i output and strips \r from both the header block and the body separator. That works for the HTTP/2.0 and HTTP/1.1 status lines gh prints.

  • Failed reads.

    • A 200 counts as a read only when gh also exits 0. A body cut off after its headers is a failure.
    • An empty body is a failure, because jq -n input fails on it.
    • A body without .jobs is a failure, because .jobs[] on null fails.
    • A 304 is accepted only when the request was conditional.
  • Stored pages. A page's stored body, ETag and next link are updated only after its body parses, so a 304 never brings back a bad page. A 304 that carries no Link header follows the stored next link.

  • Shell settings. Under set -euo pipefail, the || page_next[$url]="" fallback covers a Link header with no rel="next". max_pages=20 stops a Link chain that never ends.

  • Budget wrapper. api_budget_wrap_gh handles -i itself: the guard reads the headers and passes the output on unchanged. The listing read is now counted in the job's API budget; under --paginate the wrapper passed the call through and left it out.

  • Tests. The new handoff-evidence.test.mjs cases match how the script behaves:

    • a conditional repeat and a 304 reusing the stored page;
    • each page keeping its own ETag through the Link header;
    • a page with no ETag, and a 502;
    • a cut-off or empty 200;
    • the final failure.

    The callers.test.mjs stub's HTTP/2.0 200 OK\r\n\r\n plus the listing still gives the .jobs shape the old --jq filter read.

pr-unblock dispatchers (dispatch.mjs, fix-ci-dispatch.mjs, fix-docs-dispatch.mjs, dependency-dispatch.mjs)

  • Failed reads now hold. Every failed read changed from counting a failure to logging a warning and skipping (continue), or to returning without dispatching for a listing.
  • Mergeable re-query. A failed re-query clears pending and leaves the loop, so the "still UNKNOWN" log does not fire.
  • Open-PR listing. A failed listing in dispatchAll returns 0 before the record is pruned or written. The new test checks that no outputs file is written.
  • Imports. serverFailure is still imported only in fix-ci-dispatch.mjs, where lines 594 and 610 still use it for the reads fix-ci deliberately dispatches past.
  • Docs. The claim that a rate limit still ends the run red holds: rate-guard.mjs sets process.exitCode = 1 through the latch.

Docs and changelog fragment. README.md, pr-run-activity.md and outage-posture-audit.md match the code. That includes the exception kept for fix-ci and the rate-guard exception. A bump: patch fragment fits a change to failure handling that adds no new interface.

Notes

  • I did not run any tests. The PR says its node suites were not run in its own lane either; that claim is the author's and is unverified. The new and changed assertions look consistent with the code paths they exercise.
  • A lasting fault such as a revoked token (401) or a 404 now leaves pr-unblock-dispatch.yml green, with warnings, on every tick. That is the intended behaviour for element 2 of feat\(pr-pipeline\): audit each lane against the outage pause-and-resume posture \(#​9205 slice 3\) - part 2 of 2 #12292, and the docs record it. Operators will need to watch for the warnings, because a red run will no longer flag the fault.
  • API spend: sending conditional requests on the handoff job poll lowers primary rate-limit use. The change adds no billed resource or spend.
  • No closing issue: the PR says Refs: #12292, and the context file has no closing-issue section, so there are no acceptance criteria to check. There are no prior findings and no settled threads. No embedded instructions appear in the PR context.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 3, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 21867523f4f4ff8f9149ce5f6ae0ac0b6a783990.

Merged via the queue into main with commit da7763c Nov 3, 2026
47 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-12292-41586958844-1 branch November 3, 2026 08:28
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