Skip to content

test(process): count zombie descendants as stopped in cleanup checks - #12091

Merged
morluto merged 1 commit into
morluto:mainfrom
Davmunrey:fix/process-stop-checks-zombie
Nov 18, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Davmunrey:fix/process-stop-checks-zombie

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

After #12034, three boundary tests still fail where PID 1 does not reap orphans promptly (a container started without an init process). They decide that a killed descendant is alive with signal 0, which still reaches a zombie.

This is the part of #11837 by @djrk935 that #12034 did not land, ported onto current main, where #11837 now conflicts. The commit keeps the original author. If #11837 is updated instead, close this one.

Refs #11819, which #12034 closed. That issue listed eight tests; these are the further cases #11837 found.

Problem and expected behavior

Smallest trigger: run these tests on Linux where PID 1 leaves an orphaned, killed process as a zombie for a few seconds.

  • artifactVerifierCleanupOwner › joins an owned protocol process and its descendant before closing
  • desktopBuildOwnedCommand › stops the packing process family before removing its partial archive on timeout
  • desktopBuildOwnedCommand › cancels a running setup process family before removing its partial output

Each asserts process.kill(pid, 0) throws after cleanup. Reading /proc/<pid>/stat around transport.close() in the first test shows what happens: the direct child is gone (ESRCH), the descendant is in state Z with PPID 1 and still answers signal 0, and it disappears within about 3 seconds. Cleanup worked; the assertion read a dead process as alive.

Expected: a process that has exited and only waits to be reaped counts as stopped, as tests/support/process/observePosixProcess.ts already defines it.

Change and scope

  • artifactVerifierCleanupOwner and desktopBuildOwnedCommand: the three stop assertions use processHasStopped, the helper fix(tests): treat zombies as stopped in process liveness checks (#11819) #12034 added.
  • ownedCommand: the run-token sweep reads the product's liveProcesses view of the process table, which drops zombie rows, instead of the raw table.
  • docs/development/testing.md: one paragraph says to assert a stop with processHasStopped or processGroupHasStopped, not signal 0.

Test-only. No production code changes.

Differences from #11837: everything #12034 already landed is dropped (the helper, mcpDoctor, desktopTaskReaderRunner, the Kuna probe launcher and their tests). The three assertions use processHasStopped instead of observePosixProcess(...).kind, and the guide names the two helpers that exist on main, because observePosixProcessGroup did not land.

Not included: the other signal-0 assertions in the suite. They pass in this environment, mostly because they check a direct child that its parent reaps.

Contract and boundary impact

  • Semantic owner and earliest changed stage: tests/boundary/process/ assertions; tests/support/process/observePosixProcess.ts is used unchanged.
  • Contribution scope fit and linked maintainer decision: not applicable; test-only follow-up to fix(tests): treat zombies as stopped in process liveness checks (#11819) #12034.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: POSIX test hosts. Two of the tests are already skipped on Windows; processHasStopped keeps signal 0 there.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none; npm run docs:check passed.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: the three assertions and the ownedCommand sweep listed above. No new test.
  • Base reproduction or other evidence (executed, Firecracker microVM, PID 1 is process_api, running as root, Linux x64, Node 24):
    • On main (b236bcfe3) the three test files give 3 failed, 32 passed. The same three tests failed in the full built group on 23adfc610 and when run alone on an idle machine.
    • With this change, rebased onto b236bcfe3: 35 passed, in three consecutive runs.
    • /proc observation described above: state Z, PPID 1, gone within about 3 seconds.
  • User-visible CLI/MCP output (if applicable): not applicable.
  • Remaining proof gaps: the ownedCommand case passed on main here too, because this PID 1 reaps inside that test's 2 second poll, so I could not reproduce that one; the change is kept as test(process): count zombie descendants as stopped in cleanup checks #11837 wrote it. Not run on a host with a reaping init; CI covers that.

Lifecycle regressions: these are the owned-process cleanup scenarios (protocol transport close, setup timeout, setup cancellation). The assertions still fail if a member of the process family keeps running.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

On b236bcfe3 plus this change, in the environment above.

  • npx vitest run tests/boundary/process/artifactVerifierCleanupOwner.test.ts tests/boundary/process/desktopBuildOwnedCommand.test.ts tests/boundary/process/ownedCommand.test.ts — 35 passed, three runs; 3 failed with main's versions of the files
  • node scripts/run-typescript.mjs --noEmit — no errors
  • npm run check:fast — passed
  • node scripts/verify/architecture-guards.mjs — passed across 2873 source files
  • npm run docs:check — passed
  • npx oxfmt --check docs/development/testing.md tests/boundary/process — all formatted

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux only, in a container whose PID 1 does not reap promptly.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: test-only. The assertions observe processes with ps and send no signal.

Author readiness

Human owner: @Davmunrey

  • 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.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

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 morluto#11837. The helper and the first eight cases landed in morluto#12034, so this keeps the four that remained.
@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-18T19:27:39.812937Z 40f1240 PR opened
ℹ️ 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] This PR appears safe to merge; no actionable issues were found.

Summary

This test-only change counts exited zombie descendants as stopped, avoiding false cleanup failures in containers that do not promptly reap orphaned processes.

  • Process cleanup tests now recognize zombie children as stopped.
  • The descendant sweep ignores zombie rows when checking what is still live.

No actionable issues found. Running children still fail the checks, and inspection errors are not swallowed. No new security issue was identified. Tests were not run during this review.

Davmunrey explicitly left other signal-0 assertions unchanged because they mostly check direct children that their parents reap. The checked origin/main versions still contain the old assertions; the current status of the overlapping #11837 was not available.

Reviews (1) · Last reviewed commit: "test(process): count zombie descendants ..." · Reviewed by Greptile

@morluto
morluto merged commit 5397780 into morluto:main Nov 18, 2026
39 checks passed
Davmunrey added a commit to Davmunrey/Davmunrey that referenced this pull request Nov 18, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants