Repository navigation
fix(process): retain withheld-process observations on cleanup failures - #2931
CodeAlex52 wants to merge 2 commits into
Conversation
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. |
|
3fac873 to
b5dede1
Compare
| ); | ||
| if ("cleaned" in revalidation) return revalidation; | ||
| if ("cleaned" in revalidation) | ||
| return withUnverifiedObservations(revalidation, plan.unverified); |
There was a problem hiding this comment.
revalidation has a return type that allows cleaned: true. Checking "cleaned" in revalidation removes the empty-group case but still allows success. The new call passes that value to withUnverifiedObservations, which accepts only ProcessCleanupFailure, so TypeScript rejects it and blocks static checks.
Give the failure-only helpers a failure-only return type, or check revalidation.cleaned before this call.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/process/ProcessOwnership.ts
Line: 270
Comment:
**TypeScript checks fail**
`revalidation` has a return type that allows `cleaned: true`. Checking `"cleaned" in revalidation` removes the empty-group case but still allows success. The new call passes that value to `withUnverifiedObservations`, which accepts only `ProcessCleanupFailure`, so TypeScript rejects it and blocks static checks.
Give the failure-only helpers a failure-only return type, or check `revalidation.cleaned` before this call.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5dede162c
ℹ️ 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".
| if ("cleaned" in revalidation) | ||
| return withUnverifiedObservations(revalidation, plan.unverified); |
There was a problem hiding this comment.
Carry scan observations through planning failures
When a token sweep sees an unrelated withheld PID and a launcher descendant has moved into a group whose leader is absent or not rooted and no member carries the run token, createOwnedCleanupPlan takes its direct cleaned: false return after the scan has already collected the withheld observation. cleanupOwnedProcessGroup then returns that planning failure before this revalidation wrapper runs, and the planning result does not carry tokenOwned.unverified, so this cleanup-failure branch still drops the same PID and diagnostic; carry the scan observations on that planning failure (or on every post-scan result).
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
b5dede1 to
e62ec0b
Compare
The revalidation-failure and signal-error returns omitted the plan's withheld observations, while the success and unresolved-failure returns kept them, so the documented uncertainty evidence depended on which cleanup branch finished the attempt. Thread the plan's observations through both returns; a result that already carries its own observations is unchanged.
e62ec0b to
efe9928
Compare
| if (mode === "signal-error") | ||
| expect(result.reason).toBe( | ||
| "owned process group signal failed: signal denied", | ||
| ); |
There was a problem hiding this comment.
New assertion fails TypeScript checks
The signal-error assertion reads result.reason, but result is still ProcessCleanupResult, whose success case has no reason. Checking mode does not narrow result, so this blocks static checks. Check result.cleaned === false before reading reason, or use toMatchObject as the revalidation assertion does.
| if (mode === "signal-error") | |
| expect(result.reason).toBe( | |
| "owned process group signal failed: signal denied", | |
| ); | |
| if (mode === "signal-error") | |
| expect(result).toMatchObject({ | |
| reason: "owned process group signal failed: signal denied", | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/process/cleanup-withheld.regression.test.ts
Line: 92-95
Comment:
**New assertion fails TypeScript checks**
The signal-error assertion reads `result.reason`, but `result` is still `ProcessCleanupResult`, whose success case has no `reason`. Checking `mode` does not narrow `result`, so this blocks static checks. Check `result.cleaned === false` before reading `reason`, or use `toMatchObject` as the revalidation assertion does.
```suggestion
if (mode === "signal-error")
expect(result).toMatchObject({
reason: "owned process group signal failed: signal denied",
});
```
---
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: the same |
|
@CodeAlex52, thanks for finding that cleanup failures could discard the sweep’s withheld-process observations depending on which branch returned. The cleanup owner now preserves those observations across its failure outcomes (main). |
Summary
Fixes #2543.
Cleanup failures now retain the sweep's withheld-process observations: the revalidation-failure and signal-error returns no longer drop the PID and diagnostic that successful cleanup preserves.
Problem and expected behavior
cleanupOwnedProcessGroupreturned a revalidation failure (ProcessOwnership.ts:255) and a signal error (:263-269) without the plan's observations, while the success return (:273-277) and the unresolved-failure return kept them. An unrelated process whose environment the OS withholds therefore lost its uncertainty evidence depending on which branch finished the attempt.Expected (per the issue's restoration check): all three fixture cases retain PID 900 with
platform_binary_environment_withheld, each keeping its own cleanup status, mismatch or signal-error reason, and signal-call count. A control with no withheld candidate must not invent an observation.Change and scope
src/process/ProcessOwnership.ts: addedwithUnverifiedObservations, which attaches the plan's observations to a failure result that does not already carry its own, and used it on both returns. Ownership authority, reasons and signaling behaviour are unchanged.Verification
Added
src/process/cleanup-withheld.regression.test.tswith the issue'sit.eachfixture (revalidation / signal-error / success) plus the documented control expectations.I traced all three fixtures through the plan, the revalidation and the signal paths 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-withheld.regression.test.tsand the static checks.