Repository navigation
Stop macOS EPERM marking a finished QA capture as incomplete - #4170
Merged
Merged
Conversation
On macOS the cleanup kill of an exited command's process group can get EPERM while the group is being torn down, and the capture then recorded a successful command as incomplete with exit code 2. On EPERM, check the group directly (kill with signal 0, then a ps listing that ignores zombie and exiting entries) and treat it as gone only when no live member remains. A live member or a failed check keeps the fail-closed result. Co-authored-by: vilano93 <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
On macOS, ps shows a process that is exiting with a trailing E flag (for example RE or UE), so a check on the leading letter alone read a mid-exit member as live and kept the capture incomplete. Count a member as gone when its state starts with Z or carries E; X means traced on macOS, so it stays live. Linux is unchanged and still fails closed. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS,
gstack-qa-evidence captureno longer records a command that exited 0 as an incomplete capture, so /ship's exploratory QA stops stalling on commands that worked. This serves gstack's goal of a QA loop you can trust unattended: a capture still fails closed whenever the command's process group has a live member.What changed
Before, any group-kill error except ESRCH failed the capture; after, a macOS EPERM fails it only if the group still has a live member.
Before/after as text: Before, any group-kill error except ESRCH failed the capture; after, a macOS EPERM fails it only if the group still has a live member
Before: an
EPERMfrom the cleanup kill of an exited command's process group meantincomplete, exit 2, on every platform.After, on macOS only: an
EPERMmakes the capture check the group itself. The group counts as gone whenkill(-pgid, 0)returnsESRCH, or whenps -A -o pgid=,stat=lists no member of that group except zombies (state starting withZ) or members that are exiting (theEflag). A live member, a failedps, or any other error still fails closed. On Linux and every other platform,EPERMfails closed exactly as on main.The macOS teardown state is inferred from XNU and
ps, not measured: this PR was never run on a Mac. If captures on macOS still come backincompleteafter a command exits 0, @vilano93, please reopen #4166 or comment here with the capture receipt.Why
"
gstack-qa-evidence capturesometimes records a successful command asstatus: incomplete,exitCode: 2. The QA chain then refuses--afteron that capture, so /ship's exploratory QA stalls on a command that worked" (#4166, which measured 3 of 12 captures failing on main and 0 of 16 with a fix). Finished commands now record as complete on macOS, and a group that still has a live member is still reported.Blast radius
runQaDeadlineCommand's group-kill error path is shared bylib/qa-evidence.ts:232(QA captures) andlib/dx-error-capture.ts:405. Only theEPERM-on-macOS branch changed, and it can only turn a failure into a pass afterpsshows no live member, so Linux and Windows behave as on main (read at lib/qa-deadline.ts:160-168; the off-macOS test fails without the platform check). The check spawnsps(found through PATH) synchronously with a 5 s timeout, only on that path. No network, secrets, permissions, workflows, install scripts or dependencies change.Summary
The QA capture recorded finished macOS commands as incomplete because it treated a teardown
EPERMlike a containment failure. The fix checks the group directly on macOS. Review then narrowed it twice. The check runs only on macOS, so a Linux member hidden frompscan't turn a failure into a pass, and thepsstate parsing now matches macOS, whereE(exiting) is a trailing flag andXmeans traced. The QA deadline reference now documents the exception.Test Coverage
All new code paths have test coverage. Coverage: deterministic (the one changed runtime file has a changed test naming it).
Tests: 11 new cases in
test/qa-evidence.test.ts. Three stubprocess.killto throwEPERM: an empty group as macOS records complete, a live member as macOS fails closed, and an empty group as Linux fails closed. Six put a fakepsfirst on PATH:REandUEmembers count as gone;R,S,XandRXstay live.Regression proof: the empty-group case is red on main 15a35ff; the Linux case is red against f89e2c3's lib;
RE,UEandXare red against bd0f126's lib; all pass at 7b0717c.Tests ran: qa-evidence 43
Pre-Landing Review
Pre-Landing Review: 10 issues — 0 auto-fixed, 2 fixed in granted fix rounds, 8 noted, 0 deferred.
psfallback ran on Linux too, where a member hidden fromps(hidepid/proc, another user's process) read as gone. Now macOS-only.EandXare trailingpsflags, so only a leadingZcounted as gone. NowZfirst orEanywhere counts as gone;X(traced) stays live.Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: unavailable as Codex (not installed); the outside-voice brief ran on a Claude subagent and completed.
Review notes
psresolves through PATH rather than/bin/ps(low; anyone who controls the parent's PATH already controls the run).pscan block the event loop up to 5 s, at most twice, on the macOSEPERMpath only (low).outcome ??= 2would fix it) (low).EPERMor real macOSpsoutput; both are stubbed (low).lib/claude-code.ts:100has the sameESRCH-only group kill; left alone, no reproduction there.Exploratory QA
Functional smoke, 4 probes at 7b0717c on Linux with a preload stub for macOS behavior, verdict pass: a finished command records complete; as macOS, a refused group kill with a live member fails closed (incomplete, exit 2); as macOS, a refused group kill after the group emptied records complete; as Linux, the same refused kill fails closed. Not run: real macOS. Earlier runs at f89e2c3 and bd0f126 are superseded.
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
Review bot comments
No review bot comments.
Scope Drift
Scope Check: CLEAN
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix, exempt from plan review.
Issues
Refs p1/red-team#1
Verification Results
No plan verification items (bug fix, plan exempt). Exploratory QA: 4 PASS, 0 FAIL, 0 BLOCKED, 0 NOT RUN.
TODOS
No TODO items completed in this PR.
Documentation
Status: updated.
Scope: the branch diff from 15a35ff (lib/qa-deadline.ts, test/qa-evidence.test.ts, changelog.d fragment) plus the docs that cover QA capture cleanup (docs/reference-qa-deadlines.md, docs/troubleshooting.md). Result: docs/reference-qa-deadlines.md now documents that a failed cleanup kill is a guard error (exit 2) except a macOS EPERM where every remaining group member is a zombie or exiting; the changelog fragment already matched the code. Debt: none.
Test plan
bun test test/qa-evidence.test.ts: 43 pass, 1 skip, 0 fail at 7b0717cRewritten on main from #4166 by @vilano93, credited as co-author.
Agent notes
Refs GST-1917
Approvals
Approved: yes (record r-3a10cb75530b). The full approval record stays private: this repository is public or its visibility is unknown.
Plan: exempt: bug fix
Plan check: exempt bug fix
Bug fix lane GST-1917 under GStack Minder. Failing-first test written before the fix; red on main 15a35ff with exit 2, green after.
Review loop: pass 1 full (4 readers), fix-check 1 on f89e2c3..bd0f126, then fix-check 2 on bd0f126..402f230 under the owner's grant a-665a5edc68e7 (review_loop_grant at bd0f126); both clean.
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=2 scope=frozen unbound=2 ledgers_read=4 fix_checks=2 dispatches=4
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)