[PR #5252] [CLOSED] fix(process): settle native zombies during ownership sweeps #6841

Closed
opened 2026-11-01 21:43:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5252
Author: @kwakhyun
Created: 10/19/2026
Status: ❌ Closed

Base: main ← Head: codex/fix-native-zombie-cleanup


📝 Commits (1)

  • 604f3ef fix(process): settle native zombies during ownership sweeps

📊 Changes

5 files changed (+250 additions, -17 deletions)

View changed files

📝 src/process/ProcessOwnership.nativeExit.test.ts (+106 -0)
📝 src/process/ProcessOwnership.ts (+6 -6)
📝 src/process/ProcessOwnershipEvidence.ts (+13 -11)
➕ tests/boundary/process/processZombieSettlement.test.ts (+90 -0)
➕ tests/fixtures/processZombie.c (+35 -0)

📄 Description

Summary

A process can exit after the process-table snapshot and remain as a zombie. On macOS the native identity reader still confirms its generation and zombie lifecycle, while the token reader returns sysctl_failed_22. The ownership ledger already retires that generation, but the final token sweep incorrectly reports environment-unreadable for a live process and refuses cleanup.

Use one native-exit predicate for ledger reconciliation and sweep validation. Only confirmed absence or a same-generation, native-confirmed zombie settles the candidate. Live processes, missing lifecycle facts, unavailable identities, and a replaced generation that is now a zombie still fail closed. No signal is needed for the exited candidate.

Found while investigating main CI at 3ea0d9489. Related to #4322. This is a separately reproduced macOS defect; the baseline-absence repair in #5249 and the recorded-crash trace-verifier failure remain outside this PR. No separate issue was opened because the deterministic reproducer and regression are included here.

Scope and contract impact

  • Existing process-ownership semantics only; advance maintainer scope decision is not applicable.
  • CLI/MCP schemas, Evidence formats, provider selection, generated metadata, installation and package contents are unchanged.
  • A shared predicate replaces duplicate lifecycle interpretation in the ledger and sweep. The existing native readers remain the source of identity and lifecycle facts.
  • The regression launches a source-owned fixture, retains a real live process-table row, then uses waitid(WNOWAIT) to hold the exited child. Native identity and token reads are unmodified. The holder reaps its child in cleanup; the observer is closed and its temporary directory is removed.

Evidence and validation

Executed on macOS arm64 with Node 24.18.0 and npm 11.16.0, based on 3ea0d9489:

  • Before: the new native boundary test copied into a clean baseline worktree fails with cleaned: false, environment-unreadable, and sysctl_failed_22. Two focused source regressions also fail before the fix.
  • After: the same native test passes. Fresh and retained/table-omitted zombie candidates settle without signaling. Negative controls preserve live, unavailable, unknown-lifecycle, and replaced-zombie failures.
  • Final review rerun on 604f3ef: all eight ownership source files plus the native macOS regression — 121 passed, one Linux-only test skipped across 9 files (7.08 s). An independent agent diff review found no blockers.
  • npm run test:focused -- tests/boundary/process/processZombieSettlement.test.ts tests/boundary/process/ownedCommand.test.ts tests/boundary/process/processCleanupRetryOwnership.test.ts tests/boundary/mcp/processCleanupRetryMcp.test.ts tests/acceptance/process/processFinalization.test.ts — 47 passed across 5 files, including actual compiled CLI/MCP finalization, cancellation and cleanup retry; 88.27 s.
  • npm run check — passed again on the final commit (deterministic tasks reused valid caches): typecheck, lint, format, unused-code, metadata, module boundaries and architecture guards. Lint reported zero errors and existing repository warnings.
  • npm run verify:test-discovery — all 1,653 test files discovered exactly once.
  • git diff --check — passed.

Limits

The native regression is macOS-only. Linux and Windows native behavior and real Hopper/Ghidra/IDA engines were not run. This PR does not claim to repair every failure in main CI or demonstrate a performance improvement. No retries, timeouts or required checks were weakened. Remote CI currently reports action_required and has no executed jobs; maintainer workflow approval is still needed, so no remote CI pass is claimed.

Author readiness

Human owner: @kwakhyun

At @kwakhyun's explicit request, Codex performed the final diff and evidence review. The owner authorized removing Draft and requesting maintainer review if that review found no blockers. The declarations below record this delegated review and the owner's readiness authorization; no separate manual human diff review is claimed.

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5252 **Author:** [@kwakhyun](https://github.com/kwakhyun) **Created:** 10/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/fix-native-zombie-cleanup` --- ### 📝 Commits (1) - [`604f3ef`](https://github.com/morluto/rea/commit/604f3efbe00fd9dcdd0d131120e788dd89a6c924) fix(process): settle native zombies during ownership sweeps ### 📊 Changes **5 files changed** (+250 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/process/ProcessOwnership.nativeExit.test.ts` (+106 -0) 📝 `src/process/ProcessOwnership.ts` (+6 -6) 📝 `src/process/ProcessOwnershipEvidence.ts` (+13 -11) ➕ `tests/boundary/process/processZombieSettlement.test.ts` (+90 -0) ➕ `tests/fixtures/processZombie.c` (+35 -0) </details> ### 📄 Description ## Summary A process can exit after the process-table snapshot and remain as a zombie. On macOS the native identity reader still confirms its generation and zombie lifecycle, while the token reader returns `sysctl_failed_22`. The ownership ledger already retires that generation, but the final token sweep incorrectly reports `environment-unreadable` for a live process and refuses cleanup. Use one native-exit predicate for ledger reconciliation and sweep validation. Only confirmed absence or a same-generation, native-confirmed zombie settles the candidate. Live processes, missing lifecycle facts, unavailable identities, and a replaced generation that is now a zombie still fail closed. No signal is needed for the exited candidate. Found while investigating [main CI at 3ea0d9489](https://github.com/morluto/rea/actions/runs/39250630911). Related to #4322. This is a separately reproduced macOS defect; the baseline-absence repair in #5249 and the recorded-crash trace-verifier failure remain outside this PR. No separate issue was opened because the deterministic reproducer and regression are included here. ## Scope and contract impact - Existing process-ownership semantics only; advance maintainer scope decision is not applicable. - CLI/MCP schemas, Evidence formats, provider selection, generated metadata, installation and package contents are unchanged. - A shared predicate replaces duplicate lifecycle interpretation in the ledger and sweep. The existing native readers remain the source of identity and lifecycle facts. - The regression launches a source-owned fixture, retains a real live process-table row, then uses `waitid(WNOWAIT)` to hold the exited child. Native identity and token reads are unmodified. The holder reaps its child in cleanup; the observer is closed and its temporary directory is removed. ## Evidence and validation Executed on macOS arm64 with Node 24.18.0 and npm 11.16.0, based on `3ea0d9489`: - **Before:** the new native boundary test copied into a clean baseline worktree fails with `cleaned: false`, `environment-unreadable`, and `sysctl_failed_22`. Two focused source regressions also fail before the fix. - **After:** the same native test passes. Fresh and retained/table-omitted zombie candidates settle without signaling. Negative controls preserve live, unavailable, unknown-lifecycle, and replaced-zombie failures. - Final review rerun on `604f3ef`: all eight ownership source files plus the native macOS regression — **121 passed, one Linux-only test skipped across 9 files** (7.08 s). An independent agent diff review found no blockers. - `npm run test:focused -- tests/boundary/process/processZombieSettlement.test.ts tests/boundary/process/ownedCommand.test.ts tests/boundary/process/processCleanupRetryOwnership.test.ts tests/boundary/mcp/processCleanupRetryMcp.test.ts tests/acceptance/process/processFinalization.test.ts` — **47 passed across 5 files**, including actual compiled CLI/MCP finalization, cancellation and cleanup retry; 88.27 s. - `npm run check` — **passed again on the final commit** (deterministic tasks reused valid caches): typecheck, lint, format, unused-code, metadata, module boundaries and architecture guards. Lint reported zero errors and existing repository warnings. - `npm run verify:test-discovery` — **all 1,653 test files discovered exactly once**. - `git diff --check` — **passed**. ## Limits The native regression is macOS-only. Linux and Windows native behavior and real Hopper/Ghidra/IDA engines were not run. This PR does not claim to repair every failure in main CI or demonstrate a performance improvement. No retries, timeouts or required checks were weakened. Remote CI currently reports `action_required` and has no executed jobs; maintainer workflow approval is still needed, so no remote CI pass is claimed. ## Author readiness Human owner: @kwakhyun At @kwakhyun's explicit request, Codex performed the final diff and evidence review. The owner authorized removing Draft and requesting maintainer review if that review found no blockers. The declarations below record this delegated review and the owner's readiness authorization; no separate manual human diff review is claimed. - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:43:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6841
No description provided.