Skip to content

fix(tests): treat zombies as stopped in process liveness checks (#11819) - #12034

Merged
morluto merged 2 commits into
morluto:mainfrom
phon-t:fix-11819-zombie-process-liveness
Nov 18, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
phon-t:fix-11819-zombie-process-liveness

Conversation

@phon-t

@phon-t phon-t commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #11819.

Killed descendants that are waiting to be reaped read as alive to
process.kill(pid, 0), so three boundary tests fail in containers
whose PID 1 does not reap orphans. The liveness checks now treat a
zombie as stopped, using the repo's existing observePosixProcess
helper (ps -o stat=, comm-safe) with two small wrappers,
processHasStopped / processGroupHasStopped, swapped in at the
three call sites: desktopTaskReaderRunner (reader liveness),
mcpDoctor waitForExit, and ownedGroupCleanup (process-group
liveness). Test-only change; production code untouched.

Tests: kunaVersionProbeOwnership 7/7, desktopTaskReaderRunner
22 passed + 1 skipped, mcpDoctor 33 passed — the 8 tests from
#11819, run in a non-reaping container where they failed at baseline.
npm run check:fast exit 0. Full typecheck could not run locally
(OOM on this machine); CI is the gate.

Caveats, please read before merging:

  • The fix was first produced by Nona (Phon's Telegram assistant,
    via the OpenCode ACP adapter) and reworked by Lotus onto the repo
    helper for review quality; the diff below is the reworked version,
    not her verbatim diff. Her original approach read /proc directly
    and had a comm-with-spaces parsing caveat; this version removes it.
  • The bug does not reproduce on a reaping host, so the passing
    result on a normal machine proves no regression only — the
    non-reaping-container run above is the real evidence.

Maintainer update

The prior CI run failed formatting in the process observation helper. The review also identified missing process-group coverage. While adding that coverage, I reproduced a second issue. With ps unavailable, the old signal-zero fallback treated EPERM as proof that a group had stopped.

The fallback now treats only ESRCH as absence and keeps the Windows single-process check on signal zero. The controlled ps cases exercise empty, zombie-only, mixed live/zombie, unrelated groups and checker failures. The change remains test-only.

On macOS and Node 24.22.1, all 65 focused tests passed across process observation, reader cleanup, MCP doctor and Kuna probe ownership. npm run check:fast and targeted formatting also passed. The original non-reaping-container observations above were reported by the author and were not repeated for this revision.

Author readiness

Human owner: @phon-t

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Fixes morluto#11819.

Killed descendants waiting to be reaped read as alive to
process.kill(pid, 0), so three boundary tests fail in containers
whose PID 1 does not reap orphans. The liveness checks now treat a
zombie as stopped, using the existing observePosixProcess helper
(ps -o stat=, comm-safe) with two small wrappers,
processHasStopped / processGroupHasStopped, swapped in at the three
call sites. Test-only change; production code untouched.
@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-18T14:24:48.287912Z 6c3c50f New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no blocking issue was found.

Summary

The PR makes test liveness checks count zombies as stopped without changing production code.

  • Process checks now count zombie children as stopped.
  • Kuna cleanup checks whether any live process remains in its group.

Reviews (3) · Last reviewed commit: "Merge main and verify process-group stop..." · Reviewed by Greptile

@morluto
morluto merged commit 6c3e9e0 into morluto:main Nov 18, 2026
41 checks passed
morluto pushed a commit that referenced this pull request Nov 18, 2026
…12091)

Where PID 1 does not reap orphans promptly, a killed descendant stays a zombie for a while. Signal 0 still reaches a zombie, and a raw process table still lists it, so four boundary tests decided a stopped process was alive although cleanup had worked.

The stop assertions in artifactVerifierCleanupOwner and desktopBuildOwnedCommand now use processHasStopped. The run-token sweep in ownedCommand reads the product's liveProcesses view, which drops zombie rows. The testing guide says to assert a stop this way and not with signal 0.

Ported onto current main from #11837. The helper and the first eight cases landed in #12034, so this keeps the four that remained.

Co-authored-by: Dayan Kijege <[email protected]>
@morluto morluto added area: tests Test suite and verification bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Process-cleanup tests count a killed descendant as alive while it waits to be reaped

2 participants