Repository navigation
fix(wait-for-pr-review): [#2712] bound the reader wait by the deadline and signals - #2750
Conversation
…sign decision Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…deadline and signals The success path waited for the stdout and stderr readers without limit, so a descendant of gh holding the pipes defeated --timeout-seconds and SIGINT/SIGTERM. One bounded collect routine now serves both paths; the two integration tests ran red on the unfixed code (see manual-verification-evidence.md). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The documentation conflates budget expiry with interruption, incorrectly implying that cancellation is reported as a timeout rather than a failure.
1 open issue
What changed in this PR
This PR addresses #2712 under EPIC #2003 by bounding output collection in the wait-for-pr-review poller when gh exits but a descendant keeps its pipes open.
Changes:
- Shares a bounded collection routine that checks deadlines and signals while preserving the error path’s 200 ms grace period.
- Adds deadline and SIGTERM regression tests, plus unit coverage for output collection.
- Documents the failure behavior, design decision, and before/after verification evidence.
| File | Description |
|---|---|
docs/issues/open/2712-2003-wait-for-pr-review-pipe-wait-after-exit/manual-verification-evidence.md |
Records fixed-build timing and red/green regression results. |
docs/issues/open/2712-2003-wait-for-pr-review-pipe-wait-after-exit/ISSUE.md |
Records the selected behavior and completed implementation tasks. |
.github/skills/dev/pr-reviews/wait-for-pr-review/tool/tests/cli.rs |
Adds descendant-held-pipe deadline and SIGTERM scenarios. |
.github/skills/dev/pr-reviews/wait-for-pr-review/tool/src/gh.rs |
Bounds reader collection and adds focused unit tests. |
.github/skills/dev/pr-reviews/wait-for-pr-review/SKILL.md |
Documents deadline and signal handling after gh exits. |
Review effort: Balanced
…budget expiry in the skill Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…nd 1 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
ACK 36cc80c |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
This relies on a backgroundsleepcontinuing to run after theghshell process exits, which can… · New The “Severity” allowed values list does not includeLow, but the findings table usesLow. To… · New Passing&AtomicBool::new(false)takes a reference to a temporary, which is easy to misread and is… · New
1 resolved since last review
Review effort: Lite
|
Approving a follow-up PR for Copilot review 5802998503 (submitted 16:00:51 UTC, before the 16:01:58 UTC merge): fix its three findings and record them in the audit. |
…w submitted before the merge of #2750 3b59214 docs(pr-reviews): [#2712] fix the round 2 audit references and log times (josecelano-bot) 973816c docs(pr-reviews): [#2712] record round 2 of the PR 2750 audit (josecelano-bot) 31dcfca docs(pr-reviews): [#2712] use a declared severity value in the PR 2750 audit (josecelano-bot) eb43a8f refactor(wait-for-pr-review): [#2712] bind the never-set interrupt flag to a local (josecelano-bot) c5596b9 test(wait-for-pr-review): [#2712] make the fake gh descendant ignore SIGHUP (josecelano-bot) Pull request description: Follow-up to #2750 (merged), approved by the maintainer: #2750 (comment) Copilot review 5802998503 was submitted at 16:00:51 UTC, 67 s before #2750 merged at 16:01:58 UTC, so it went unprocessed. Its three findings were valid on the merged tree: 1. `tests/cli.rs`: the fake `gh` descendant now ignores SIGHUP (`trap '' HUP`), so the held-pipe condition does not depend on the shell. 2. `gh.rs`: the never-set interrupt flag of the reclaim path is bound to a local instead of a temporary reference. 3. `docs/pr-reviews/pr-2750-review/PR-REVIEW.md`: severity `Low` replaced by the declared `Minor (inferred)`. One signed commit per fix; the audit gets round 2 in a separate commit. Refs #2712 (already closed by #2750). 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: da2ce7: ACK 3b59214 — the diff, the audit's rows, cited commit times and subjects, the fixture's SIGHUP behaviour and the merge against develop recompute at this head josecelano: ACK 3b59214 Tree-SHA512: 5e24b7944d9fe5e65c17879c8e52329bc037a08711e2cd0ebea90ee5f99f6fcf753431fd593dbe835e8d481199ee3efcd96568fd89e50dcb7afcbcca5b458ef1
…ipe-wait issue 4860e51 docs(pr-reviews): [#2712] cite commits by subject and keep AUDIT-002 in the PR 2756 audit (josecelano-bot) efb9627 docs(pr-reviews): [#2712] record the refreshed thread count and correct the EPIC log stamp (josecelano-bot) b2ac031 docs(pr-reviews): [#2712] scope the PR 2756 audit verifications and correct its stamps (josecelano-bot) 43986a8 docs(issues): [#2712] record the completion review and point final-build evidence at V3 (josecelano-bot) 1dce70e docs(pr-reviews): [#2712] close the PR 2750 audit after the follow-up merged (josecelano-bot) c3025f0 docs(pr-reviews): [#2712] add the audit record for PR 2756 (josecelano-bot) 971f8d8 docs(issues): [#2712] move the spec to closed and update the EPIC 2003 table (josecelano-bot) Pull request description: Close-out for #2712 (EPIC #2003), after #2750 (fix) and #2756 (follow-up for Copilot's late review) merged. - Moves the spec to `docs/issues/closed/` with status `done`, all acceptance criteria and checkpoints ticked, and the progress log updated. - Records V3, the like-for-like recheck on the final build (`develop` at `92665ae17`): 3 s budget ends at 3.0 s with `deadline_exceeded`, `SIGTERM` at 3.0 s is honored at 3.0 s; 62 unit and 24 integration tests pass. - EPIC #2003: row 17 is `DONE`, with a log entry. - Audits: closes the PR 2750 audit (F2 to F4 `FIXED`/`RESOLVED`; the three threads on #2750 are resolved) and adds the PR 2756 audit. Both pass `validate-audit-record.py`. Docs only; no code change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 4860e51 da2ce7: ACK 4860e51 — the one new commit's statements and F1 to F9 recomputed at this head, with the record findings F7 to F12 non-blocking Tree-SHA512: 0f0474ec26e995bf577b972a0e02f87790faedde902ebb2a47df400984e45510787f71b64992fcbe8a594021138db0e8ce314e80d2730e81ca7037cb2e1c602d
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #2750 as it stands at e170b9620 on the default branch.
What still runs: collect at .claude/skills/wait-for-pr-review/tool/src/gh.rs:257-278 is the merged version unchanged, and GhCli::run still uses it on both paths (gh.rs:123-141). After a normal exit each reader is awaited in slices of at most 25 ms against the handle's absolute deadline and the interrupt flag, and a reader that has not finished by then is a DeadlineExceeded or Interrupted failure with no data. After a kill the two readers share one 200 ms bound and their result is discarded. Since the merge, e3c24d6 moved the tool from .github/skills/dev/pr-reviews/ to .claude/skills/, eb43a8f bound the never-set flag to a local, c5596b9 made the fake descendant ignore SIGHUP (tests/cli.rs:27), and 95a5d05 added a second GhCli handle for the identity lookup (main.rs:215) whose shorter deadline also bounds its own reader wait. The two command-line scenarios are at tests/cli.rs:593-629.
[Minor] .claude/skills/wait-for-pr-review/tool/src/error.rs:43-45: DeadlineExceeded is now also returned when gh has exited and a process it started still holds its output pipes (gh.rs:138-139), but its doc comment and message still say the budget ended while a gh call was still running, so the call was killed. Concrete sequence: --gh-command ./wrapper, where the wrapper runs gh and leaves a background helper attached to stdout; the first look at the pull request exits 0 at once, the reader wait runs to the end of the budget, and the run exits 1 with deadline_exceeded and that message. SKILL.md:134 tells the caller to read the message, which points at a hung or slow request, when in fact the request finished, nothing was killed and the helper is still running. Smallest fix: reword the doc comment and the message to cover both cases, for example the wait budget ended before a gh call finished: it was still running and was killed, or it had exited but a process it started still held its output open; the kind stays the same.
[Nit] .claude/skills/wait-for-pr-review/tool/src/gh.rs:123-133, with RECLAIM_GRACE at gh.rs:18-21: the wait after a kill does not reclaim anything. Both collect results are dropped, and a reader thread ends on its own when its pipe closes whether or not anything waits for it, so the only observable effect is a delay. When a process the killed gh started still holds a pipe, the failure is returned up to 200 ms later, and the interrupt flag is not checked during that time. The repository's own auth-hangs scenario hits this: the fake's foreground sleep 30 survives the kill of the script and holds both pipes, so every deadline kill there waits the full 200 ms for nothing. Smallest fix: replace the match with let status = outcome?; and delete RECLAIM_GRACE and the never_interrupted local; the doc comment of collect already states that readers are left to finish on their own.
[Nit] .claude/skills/wait-for-pr-review/tool/tests/cli.rs:615-616: the SIGTERM scenario for a descendant that holds the pipes sends the signal after a fixed 500 ms sleep and assumes gh auth status has exited by then. If the fake has not exited yet, for example on a loaded runner, wait_for sees the signal and kills the child, and the run still ends promptly with interrupted. The test then passes without ever reaching the reader wait it is named for. The deadline scenario at tests/cli.rs:593-608 does not have this gap. Smallest fix: have the fake write a marker right after it starts the descendant at tests/cli.rs:27, for example : > "$dir/descendant-started", and have the test wait for that file, with a bound, plus a short margin before it sends SIGTERM.
Checked and found sound:
- The reader wait after a normal exit is bounded by the absolute deadline and the interrupt flag, in slices of at most 25 ms, and both readers share that one deadline.
- Output that was already sent is returned even at or after the deadline, because a zero-length
recv_timeoutstill receives. - A
ghthat closes its pipes normally keeps its full output. - After the first look,
pollturns a reader-waitDeadlineExceededinto atimeoutresult, asSKILL.md:137-145states. - The identity lookup's shorter deadline bounds its own reader wait.
- No
collectpath panics. - The descendant in both scenarios holds only the poller's pipes to
gh, never the test's. - Read against the pre-change code, the deadline scenario fails on its elapsed-time assertion.
- The pull request description's claims are borne out by its diff.


Closes #2712. Part of EPIC #2003.
Problem
When
ghexits successfully but a descendant still holds its stdout/stderr pipes, the success path ofGhCli::runwaited for the readers without limit, so--timeout-secondsand SIGINT/SIGTERM were ignored until the descendant exited (25 s for a 3 s budget in the repro).Fix
One bounded
collectroutine serves both paths: it waits in slices of at most 25 ms and checks the interrupt flag and the call's absolute deadline. Unfinished output at that point is adeadline_exceeded/interruptedfailure with no data (option 1 in the spec; alternatives and trade-offs recorded there). The error path keeps its 200 ms grace.SKILL.mddocuments the bound.Evidence
tests/cli.rs(deadline, SIGTERM) failed red on the unfixed code (20 s) and pass now; unit tests covercollect.manual-verification-evidence.mdV2).linter alland the pre-commit gate pass.The close-out PR (spec move, EPIC row 17) follows after merge.
🤖 Generated with Claude Code