Repository navigation
fix(process): count one unreadable child once during cleanup - #2928
CodeAlex52 wants to merge 5 commits into
Conversation
The cleanup plan seeded its unresolved list with the sweep failures and then appended the same member's validation failure, so one live process that could not expose its run token was reported twice: the reason counted two live processes and listed the same PID twice. Keep one failure per PID when merging the per-group validation failures into the sweep's unresolved list. Distinct unreadable children still report once each, and cleanup remains unsuccessful without signaling.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70a18934e6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // diagnostic. Keep one observation per PID. | ||
| unresolved.push( | ||
| ...failures.filter( | ||
| ({ pid }) => !unresolved.some((entry) => entry.pid === pid), |
There was a problem hiding this comment.
Retain later failure evidence when deduplicating by PID
When a sweep records a PID as environment-unreadable but the subsequent per-group read returns a foreign run token, processOwnershipFailures emits run-token-mismatch; because unresolved was seeded from sweep failures, this PID-only predicate discards that newer result. The group is still not signaled, but cleanupValidationFailure now falsely reports the older unreadable-token diagnosis and callers lose the definitive mismatch, so one-entry-per-PID needs to merge or replace changed observations rather than always retaining the first.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
The cleanup plan seeded its unresolved list with the sweep failures and then appended the same member's validation failure, so one live process that could not expose its run token was reported twice: the reason counted two live processes and listed the same PID twice. Keep one failure per PID when merging the per-group validation failures into the sweep's unresolved list. Distinct unreadable children still report once each, and cleanup remains unsuccessful without signaling.
70a1893 to
89d36df
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89d36dfbb0
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...failures.filter( | ||
| ({ pid }) => !unresolved.some((entry) => entry.pid === pid), |
There was a problem hiding this comment.
Deduplicate failures returned in the same validation batch
Even with no sweep failure already in unresolved, if an owned member's identity becomes unavailable during revalidation and its token read is also unavailable, processOwnershipFailures returns both process-identity-unavailable and environment-unreadable for that PID. This filter evaluates both entries before unresolved.push changes the array, so both pass and the cleanup result still reports one PID twice; normalize these failures at their producing boundary or update a seen-PID map while merging.
AGENTS.md reference: AGENTS.md:L23-L25
Useful? React with 👍 / 👎.
…codex/maintenance-pr-2928 # Conflicts: # src/process/ProcessOwnership.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 014ce9fd1b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const failure of failures) | ||
| mergeProcessOwnershipFailure(unresolved, failure); |
There was a problem hiding this comment.
Normalize failures before every cleanup consumer
When an owned member's identity becomes unavailable and its token read is also unavailable during the final pre-signal check, processOwnershipFailures returns both process-identity-unavailable and environment-unreadable for the same PID. The remaining revalidateOwnedProcessGroup path passes that array directly to cleanupValidationFailure at lines 591–597, so this new merge loop is never applied and cleanup still reports one PID twice; normalize at the producing boundary rather than only in createOwnedCleanupPlan.
AGENTS.md reference: AGENTS.md:L23-L25
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e46862dc3a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| failures: ProcessOwnershipValidationFailure[], | ||
| next: ProcessOwnershipValidationFailure, | ||
| ): void => { | ||
| const index = failures.findIndex(({ pid }) => pid === next.pid); |
There was a problem hiding this comment.
Normalize failures emitted by the sweep
When a sweep first reads a stable identity, keeps getting an unreadable token, and then sees the identity change or become unavailable in its post-read check, scanTokenOwnedProcesses emits both environment-unreadable and process-identity-unavailable for the same PID. Both entries seed unresolved, and this findIndex updates only the first one, so the final cleanup result still reports that PID twice. This is a separate producer from the already-reported final-revalidation path; normalize the sweep output (or seed the plan through a PID-keyed merge) as well.
AGENTS.md reference: AGENTS.md:L23-L25
Useful? React with 👍 / 👎.
| for (const failure of failures) | ||
| mergeProcessOwnershipFailure(unresolved, failure); |
There was a problem hiding this comment.
The sweep can record both an unreadable token and a changed or unreadable identity for one live PID. unresolved starts with both entries, and mergeProcessOwnershipFailure only replaces the first match. Cleanup callers therefore still get duplicate failures, leaving the one-entry-per-PID fix incomplete.
Build the initial list through the same merge helper, and add a test with both failures for one PID.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/process/ProcessOwnership.ts
Line: 510-511
Comment:
**One child still appears twice**
The sweep can record both an unreadable token and a changed or unreadable identity for one live PID. `unresolved` starts with both entries, and `mergeProcessOwnershipFailure` only replaces the first match. Cleanup callers therefore still get duplicate failures, leaving the one-entry-per-PID fix incomplete.
Build the initial list through the same merge helper, and add a test with both failures for one PID.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Retain unresolved process identity and launch evidence through retryable cleanup. Share capture path normalization and preserve failed filesystem observations. Bound child output and drain Windows pipes without one-chunk throttling. Reviewed fixes include #1628, #2632, #2644, #2784, #2928, #2931, #2965, #2992, and #3011. Validation: 92 focused source tests passed; four platform-specific skips. Real Windows and Hopper lifecycle coverage was not rerun.
|
Heads up: main covers this in its own way in 599a8ee. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Verified against 599a8ee: |
|
@CodeAlex52, thanks for noticing that one unreadable child could be counted more than once in cleanup reporting. The current ownership path counts unreadable live members once and keeps the later identity-validation case distinct (main). |
Summary
Fixes #2540.
Cleanup now reports one unreadable live child once: the reason names one live process and the failure list keeps one entry per PID.
Problem and expected behavior
The cleanup plan seeded its unresolved list with the sweep failures (
ProcessOwnership.ts:459) and then appended the per-group validation failures, which describe the same member again (:492-510), socleanupValidationFailurecounted the same PID twice:Expected (per the issue's restoration check): one failure for PID 101, a count of one, cleanup still unsuccessful, and no signal to the unverified group. A control with two distinct unreadable live children must still report each PID once and count two.
Change and scope
src/process/ProcessOwnership.ts: when merging the per-group validation failures into the unresolved list, skip PIDs that the sweep already recorded. One observation per PID is kept; distinct PIDs are unaffected, and the signalability decision (failures.length === 0 && scanFailures.length === 0) is unchanged.Verification
Added
src/process/cleanup-count.regression.test.tswith the issue's reproduction and its control:failureshas length 1, reason contains1 live process(es), zero signal calls;2 live process(es), zero signal calls.I traced both fixtures through the cleanup plan and the failure merge by hand; I could not run Vitest in this environment (no local checkout), so please let CI run
npm run test:focused -- src/process/cleanup-count.regression.test.tsand the static checks.