[PR #5161] [CLOSED] fix(process): clear cleanup_incomplete after owner-confirmed cleanup retry #6790

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5161
Author: @Varshith-Kali
Created: 10/19/2026
Status: ❌ Closed

Base: main ← Head: fix/cleanup-incomplete-cleared-on-owner-retry-5144-fork


📝 Commits (1)

  • 437c239 fix(process): clear cleanup_incomplete after owner-confirmed cleanup retry

📊 Changes

2 files changed (+272 additions, -30 deletions)

View changed files

📝 src/process/capture/ProcessCaptureLifecycle.ts (+103 -30)
📝 src/process/capture/ProcessHarness.test.ts (+169 -0)

📄 Description

Summary

Fixes #5144. ProcessCaptureResourceScope retained failed-cleanup owners in a private set and dropped them after a successful retryCleanup, but the ProcessCaptureError produced by resolveProcessResult was never bound to those owners. The scope knew recovery happened; the published errors did not, so cleanupIncomplete stayed true and projectAnalysisError() kept returning cleanup_incomplete after the exact owner confirmed release.

Problem and expected behavior

Repro (from the issue, mirrored in a new regression test): real temp dir, removal host rejects, error via resolveProcessResult(undefined, typedPrimaryFailure, report), restore fs.rm, retryCleanup + close, stat reports ENOENT, project the same error. Before the fix, cleanupIncomplete stayed true and the projection kept returning cleanup_incomplete. Expected: after the exact owner confirms release, clear the marker on originating and composed errors while preserving the original failure facts and the historical cleanup report. An unrelated or still-pending owner must remain incomplete.

Change and scope

  • Each failed owner retained by ProcessCaptureResourceScope.release() is now wrapped in an AnalysisCleanupLease whose live attribution follows the owner's latest failed resources across retries.
  • resolveProcessResult binds the cleanup error produced from a scope report to that report's exact leases via AnalysisCleanupLeaseGroup, the same exact-owner lease pattern used by the sibling fixes for #4467, #4869 and #4734. Retry goes through the lease, so a confirmed release resolves the originating and composed (withFinalization) errors.
  • The retry aggregate thrown by retryCleanup is now a typed ProcessCaptureError (cleanup_incomplete, original AggregateError kept as cause) bound to the still-pending leases: it stays incomplete until every owner it reports is released, and releasing one child cannot clear another child's status.
  • An empty unrelated scope is not treated as recovery proof: binding is keyed to the exact report returned by release().
  • Out of scope: the historical cleanup report and the error's original failure facts are untouched; no behavior change for the scope-less releaseProcessResources path.

Contribution scope fit: ordinary fix within existing boundaries; maintainer scope decision not applicable (no new providers, target execution, injection, or mutation).

Contract and boundary impact

  • Semantic owner and earliest changed stage: ProcessCaptureResourceScope.release / retryCleanup and resolveProcessResult in src/process/capture/ProcessCaptureLifecycle.ts.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: none; projections only move from cleanup_incomplete to the underlying code after genuine owner-confirmed recovery.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: historical cleanup report and original failure facts preserved; only the live cleanup marker and live resource attribution change.
  • Target selection, authority, upstream behavior, and cleanup details: cleanup now resolves only on exact-owner confirmation, per docs/tool-design.md own-the-lifecycle.
  • Generated metadata, package, or installation impact: none.

Expected effects: none of the listed target-interaction effects apply (local temp-dir cleanup in tests only).

Evidence and regression coverage

  • Tests added or updated: 3 regression tests in src/process/capture/ProcessHarness.test.ts: (a) retry-confirmed path clears the marker and projection while preserving original facts and the historical report; (b) a still-pending peer owner keeps its error incomplete while the recovered owner's error clears, and the retry aggregate resolves only after its own owners release; (c) an empty unrelated scope is not treated as recovery proof.

  • Base reproduction or other evidence: 2 of the 3 new tests fail on the pre-fix base (stale cleanupIncomplete; retry threw an untyped AggregateError). The third passes pre- and post-fix as a guard.

  • User-visible CLI/MCP output: not applicable; verified at the error/projection boundary.

  • Remaining proof gaps: no real-OS close-failure or Windows qualification; natural filesystem denial frequency is NOT_ENOUGH_INFO per the issue.

  • 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

  • npm run test:focused -- src/process/capture/ProcessHarness.test.ts: 34 passed (31 existing + 3 new)
  • focused runs across all 13 src/process/capture suites: all pass
  • npm run test:focused -- src/domain/analysisErrorProjection.test.ts: 57 passed
  • npm run test:focused -- src/artifacts/AnalysisCleanupLease.test.ts: 11 passed
  • npm run test:focused -- src/artifacts/ArtifactResourceScope.test.ts: 16 passed
  • node node_modules/typescript/bin/tsc --noEmit: clean
  • oxlint on touched files: 0 errors (10 warnings, all pre-existing on the base)
  • node scripts/verify-module-boundaries.mjs: clean (2113 files)
  • Note: npm run check:fast could not run end-to-end here (symlinked node_modules has no .bin entries, so turbo is not on PATH); the underlying typecheck, lint, and boundary steps were run directly as listed above.

Compatibility, safety, and release

  • Breaking changes or migration steps: on persistent failure, retryCleanup/close now reject with a typed ProcessCaptureError (cleanup_incomplete) instead of a bare AggregateError; the original AggregateError is preserved as cause. Callers catch broadly and the MCP adapter already wraps it, so no migration is needed.
  • Real Hopper/Ghidra, browser, or OS coverage: synthetic temp-dir lifecycle only; no real Chromium/native qualification.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; local-only cleanup bookkeeping.

Author readiness

Human owner:

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

🔄 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/5161 **Author:** [@Varshith-Kali](https://github.com/Varshith-Kali) **Created:** 10/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/cleanup-incomplete-cleared-on-owner-retry-5144-fork` --- ### 📝 Commits (1) - [`437c239`](https://github.com/morluto/rea/commit/437c2390fd279bad24ae81242f0fc1dba689d1c8) fix(process): clear cleanup_incomplete after owner-confirmed cleanup retry ### 📊 Changes **2 files changed** (+272 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `src/process/capture/ProcessCaptureLifecycle.ts` (+103 -30) 📝 `src/process/capture/ProcessHarness.test.ts` (+169 -0) </details> ### 📄 Description ## Summary Fixes #5144. `ProcessCaptureResourceScope` retained failed-cleanup owners in a private set and dropped them after a successful `retryCleanup`, but the `ProcessCaptureError` produced by `resolveProcessResult` was never bound to those owners. The scope knew recovery happened; the published errors did not, so `cleanupIncomplete` stayed true and `projectAnalysisError()` kept returning `cleanup_incomplete` after the exact owner confirmed release. ## Problem and expected behavior Repro (from the issue, mirrored in a new regression test): real temp dir, removal host rejects, error via `resolveProcessResult(undefined, typedPrimaryFailure, report)`, restore `fs.rm`, `retryCleanup` + `close`, `stat` reports ENOENT, project the same error. Before the fix, `cleanupIncomplete` stayed true and the projection kept returning `cleanup_incomplete`. Expected: after the exact owner confirms release, clear the marker on originating and composed errors while preserving the original failure facts and the historical cleanup report. An unrelated or still-pending owner must remain incomplete. ## Change and scope - Each failed owner retained by `ProcessCaptureResourceScope.release()` is now wrapped in an `AnalysisCleanupLease` whose live attribution follows the owner's latest failed resources across retries. - `resolveProcessResult` binds the cleanup error produced from a scope report to that report's exact leases via `AnalysisCleanupLeaseGroup`, the same exact-owner lease pattern used by the sibling fixes for #4467, #4869 and #4734. Retry goes through the lease, so a confirmed release resolves the originating and composed (`withFinalization`) errors. - The retry aggregate thrown by `retryCleanup` is now a typed `ProcessCaptureError` (`cleanup_incomplete`, original `AggregateError` kept as cause) bound to the still-pending leases: it stays incomplete until every owner it reports is released, and releasing one child cannot clear another child's status. - An empty unrelated scope is not treated as recovery proof: binding is keyed to the exact report returned by `release()`. - Out of scope: the historical cleanup report and the error's original failure facts are untouched; no behavior change for the scope-less `releaseProcessResources` path. Contribution scope fit: ordinary fix within existing boundaries; maintainer scope decision not applicable (no new providers, target execution, injection, or mutation). ## Contract and boundary impact - Semantic owner and earliest changed stage: `ProcessCaptureResourceScope.release` / `retryCleanup` and `resolveProcessResult` in `src/process/capture/ProcessCaptureLifecycle.ts`. - Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: none; projections only move from `cleanup_incomplete` to the underlying code after genuine owner-confirmed recovery. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: historical cleanup report and original failure facts preserved; only the live cleanup marker and live resource attribution change. - Target selection, authority, upstream behavior, and cleanup details: cleanup now resolves only on exact-owner confirmation, per `docs/tool-design.md` own-the-lifecycle. - Generated metadata, package, or installation impact: none. Expected effects: none of the listed target-interaction effects apply (local temp-dir cleanup in tests only). ## Evidence and regression coverage - Tests added or updated: 3 regression tests in `src/process/capture/ProcessHarness.test.ts`: (a) retry-confirmed path clears the marker and projection while preserving original facts and the historical report; (b) a still-pending peer owner keeps its error incomplete while the recovered owner's error clears, and the retry aggregate resolves only after its own owners release; (c) an empty unrelated scope is not treated as recovery proof. - Base reproduction or other evidence: 2 of the 3 new tests fail on the pre-fix base (stale `cleanupIncomplete`; retry threw an untyped `AggregateError`). The third passes pre- and post-fix as a guard. - User-visible CLI/MCP output: not applicable; verified at the error/projection boundary. - Remaining proof gaps: no real-OS close-failure or Windows qualification; natural filesystem denial frequency is NOT_ENOUGH_INFO per the issue. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- src/process/capture/ProcessHarness.test.ts`: 34 passed (31 existing + 3 new) - focused runs across all 13 `src/process/capture` suites: all pass - `npm run test:focused -- src/domain/analysisErrorProjection.test.ts`: 57 passed - `npm run test:focused -- src/artifacts/AnalysisCleanupLease.test.ts`: 11 passed - `npm run test:focused -- src/artifacts/ArtifactResourceScope.test.ts`: 16 passed - `node node_modules/typescript/bin/tsc --noEmit`: clean - oxlint on touched files: 0 errors (10 warnings, all pre-existing on the base) - `node scripts/verify-module-boundaries.mjs`: clean (2113 files) - Note: `npm run check:fast` could not run end-to-end here (symlinked `node_modules` has no `.bin` entries, so `turbo` is not on PATH); the underlying typecheck, lint, and boundary steps were run directly as listed above. ## Compatibility, safety, and release - Breaking changes or migration steps: on persistent failure, `retryCleanup`/`close` now reject with a typed `ProcessCaptureError` (`cleanup_incomplete`) instead of a bare `AggregateError`; the original `AggregateError` is preserved as `cause`. Callers catch broadly and the MCP adapter already wraps it, so no migration is needed. - Real Hopper/Ghidra, browser, or OS coverage: synthetic temp-dir lifecycle only; no real Chromium/native qualification. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; local-only cleanup bookkeeping. ## Author readiness Human owner: <!-- @Varshith-Kali --> - [ ] 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. --- <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:04 +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#6790
No description provided.