[PR #1011] [MERGED] fix(process): preserve partial evidence and verify detached cleanup #2578

Closed
opened 2026-10-17 21:07:48 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1011
Author: @morluto
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: codex/process-partial-cleanup


📝 Commits (10+)

  • 0f88b28 test(ci): allow transport delivery in source identity regression
  • d3d3e25 fix(process): preserve partial evidence and verify detached cleanup
  • 1d8769c fix(process): scope Linux token sweeps by stable process identity
  • 1808ed4 fix(process): retain environment permission failure codes
  • 0d1f201 fix(process): wait for signaled processes before verifying cleanup
  • 3138a5d fix(process): verify sampled detached groups during cleanup
  • bd19b43 fix(electron): preserve prelaunch identities through cleanup
  • 8e53b28 fix(process): retry growing Darwin process table snapshots
  • 03cc3ca fix(process): retain compatibility with saved v3 capture evidence
  • c81453c fix(process): migrate saved v3 captures during reconstruction verification

📊 Changes

55 files changed (+5563 additions, -346 deletions)

View changed files

➕ bridge/process/ProcessRunTokenReader.swift (+263 -0)
➕ bridge/process/ProcessRunTokenReaderMain.swift (+35 -0)
📝 docs/process-capture.md (+8 -0)
📝 docs/product-catalog.json (+2 -2)
📝 docs/verification/managed-conformance-manifest.json (+2 -2)
📝 package.json (+2 -0)
📝 skills/reverse-engineer-anything/SKILL.md (+1 -1)
📝 src/android/JadxProvider.ts (+1 -0)
📝 src/application/ReconstructionObligationCandidates.test.ts (+46 -0)
📝 src/application/ReconstructionObligationCandidates.ts (+6 -0)
📝 src/browser/PlaywrightElectronActiveProvider.ts (+23 -3)
📝 src/domain/analysisErrorBase.ts (+8 -0)
📝 src/domain/analysisErrorProjection.ts (+19 -1)
📝 src/domain/javascript/javascriptExportShapeComparison.ts (+38 -11)
📝 src/domain/javascript/javascriptExportShapeVariants.ts (+0 -19)
📝 src/domain/process/processCapture.ts (+367 -106)
📝 src/domain/process/processCapture.validation.test.ts (+87 -1)
📝 src/domain/process/processCaptureExample.ts (+5 -0)
📝 src/domain/process/processCaptureParsing.ts (+40 -1)
📝 src/domain/process/processCaptureValidation.ts (+17 -2)

...and 35 more files

📄 Description

When process capture stops early or cleanup cannot be verified, REA returns the observations collected so far with the execution failure and per-resource cleanup reasons. Incomplete observations remain distinct from a verified capture; CLI and MCP honor the caller's PID normalization setting.

Cleanup verifies run tokens and stable process identities before signaling, including detached children. Prelaunch baselines on Linux and Darwin exclude only unchanged preexisting processes. Sampled groups remain cleanup candidates even after the root exits or a child drops its token; unowned groups stay unsignaled and make cleanup incomplete. Verification waits briefly for signaled children to exit without repeating signals. Darwin process-table reads retry transient ENOMEM with a fresh size query and preserve other errno diagnostics. Electron carries its baseline through both cleanup and final verification.

Launch observations distinguish the selected executable digest from an unknown running-image identity. Original v3 saved captures remain loadable, comparable, exportable, and available in prompt completion: migration preserves their old digest separately and reports the newer identity observations as unknown. Malformed old digests and incomplete modern manifests remain rejected. Generated contracts and catalog metadata are updated.

Sanitized MCP error excerpt (other fields omitted):

{
  "code": "cleanup_incomplete",
  "details": {
    "execution_failure": "fixture final snapshot failure",
    "partial_observation": {
      "observations": {
        "target_pid": { "state": "available", "value": 1 },
        "filesystem_snapshots": {
          "after": {
            "state": "unavailable",
            "reason": "Final filesystem snapshot failed: fixture final snapshot failure"
          }
        }
      }
    }
  }
}

Validation:

  • npm run build:cached, npm run check:ci, and npm run docs:check passed.
  • Single-worker ownership, harness, lifecycle, Electron action/hook lane: 74 passed, one Linux-only skip on macOS.
  • Final legacy parsing/comparison, prompt completion, and advertised output-schema lane: 21 passed.
  • Native Darwin lane: all five tests passed, including compiled Swift retry and real run-token inspection.
  • Real macOS detached-child cleanup and protection of an unowned neighbor passed. Linux process regressions also passed on the earlier CI head.
  • A real Electron 43.3 workflow was attempted. Tracing confirmed preexisting identities were excluded, but full verification remains unproven on this busy host: unrelated protected processes started during the capture and exposed unreadable tokens, so cleanup correctly failed closed.
  • Independent source review found no remaining blocking findings after the follow-up fixes. Real Hopper/Ghidra verification was not performed.

Related to #893.

Follow-up review fixes: behavioral reconstruction verification now uses the canonical saved-v3 parser while preserving original Evidence. Cancellation during Darwin helper compilation remains cancellation through cleanup and both process/Electron boundaries; genuine compiler errors retain their diagnostics. Added real fake-compiler regressions for cancellation, temporary-root removal, retry, and preventing Electron launch. Follow-up single-worker runs passed 80 reconstruction/parser tests and 17 native/cancellation tests; build, check:ci, and docs:check passed.

The final cancellation follow-up threads the caller signal through prelaunch baseline capture, process listing, identity reads, and retries for both process and Electron workflows. Cleanup deliberately completes without the aborted startup signal. Focused native/baseline/lifecycle tests passed 29 cases with one Linux-only skip; build, check:ci, and docs:check passed.

Synced with current main. The unrelated Linux large-export-inventory timeout is addressed by the separately reviewable optimization in #1028, included here so this PR's merge CI can exercise it. Export comparison/MCP tests passed 21 cases, and profiling verified byte-for-byte identical full results with lower comparison time.

Final review follow-up: owned provider startup forwards existing cancellation signals through native preparation and checks before spawning. Native compilation uses an internal controller and independent waiter cancellation, retains a surviving caller, aborts when the last waiter leaves, and waits for generation cleanup before retry. Closing during compilation stops it; directory-removal failures remain tracked and close reports them so cleanup can be retried. Final combined native/provider/display lane passed 43 tests with two host-specific skips; Ghidra/Hopper/JADX adapter lane passed, and build, check:ci, and docs:check passed. Independent review is clean after the cleanup-failure correction. The earlier 01a95075 merge CI passed all four Linux test shards.


🔄 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/1011 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/process-partial-cleanup` --- ### 📝 Commits (10+) - [`0f88b28`](https://github.com/morluto/rea/commit/0f88b28766a4ebf75b47e5db94ca419c5fa404ac) test(ci): allow transport delivery in source identity regression - [`d3d3e25`](https://github.com/morluto/rea/commit/d3d3e250110c1510462c704a9c35d89b4e63b75a) fix(process): preserve partial evidence and verify detached cleanup - [`1d8769c`](https://github.com/morluto/rea/commit/1d8769c8d39557cfa96a38236d0d92d1fd7e308a) fix(process): scope Linux token sweeps by stable process identity - [`1808ed4`](https://github.com/morluto/rea/commit/1808ed4a0c93035043e8e2c0848c637bb705bcdc) fix(process): retain environment permission failure codes - [`0d1f201`](https://github.com/morluto/rea/commit/0d1f201f08eed0f7a78e604a485218af128c117b) fix(process): wait for signaled processes before verifying cleanup - [`3138a5d`](https://github.com/morluto/rea/commit/3138a5d0adc68a9d28c44f90c84a857c28a66131) fix(process): verify sampled detached groups during cleanup - [`bd19b43`](https://github.com/morluto/rea/commit/bd19b43476852f75be58147f62f083a46fdf87d1) fix(electron): preserve prelaunch identities through cleanup - [`8e53b28`](https://github.com/morluto/rea/commit/8e53b2889933d53bbdbd31bad3e6379b48a06ed9) fix(process): retry growing Darwin process table snapshots - [`03cc3ca`](https://github.com/morluto/rea/commit/03cc3cae730bd51c6ce998af830d6bbc321c355c) fix(process): retain compatibility with saved v3 capture evidence - [`c81453c`](https://github.com/morluto/rea/commit/c81453ceafb1391dd602dd93cb75d60201b8128a) fix(process): migrate saved v3 captures during reconstruction verification ### 📊 Changes **55 files changed** (+5563 additions, -346 deletions) <details> <summary>View changed files</summary> ➕ `bridge/process/ProcessRunTokenReader.swift` (+263 -0) ➕ `bridge/process/ProcessRunTokenReaderMain.swift` (+35 -0) 📝 `docs/process-capture.md` (+8 -0) 📝 `docs/product-catalog.json` (+2 -2) 📝 `docs/verification/managed-conformance-manifest.json` (+2 -2) 📝 `package.json` (+2 -0) 📝 `skills/reverse-engineer-anything/SKILL.md` (+1 -1) 📝 `src/android/JadxProvider.ts` (+1 -0) 📝 `src/application/ReconstructionObligationCandidates.test.ts` (+46 -0) 📝 `src/application/ReconstructionObligationCandidates.ts` (+6 -0) 📝 `src/browser/PlaywrightElectronActiveProvider.ts` (+23 -3) 📝 `src/domain/analysisErrorBase.ts` (+8 -0) 📝 `src/domain/analysisErrorProjection.ts` (+19 -1) 📝 `src/domain/javascript/javascriptExportShapeComparison.ts` (+38 -11) 📝 `src/domain/javascript/javascriptExportShapeVariants.ts` (+0 -19) 📝 `src/domain/process/processCapture.ts` (+367 -106) 📝 `src/domain/process/processCapture.validation.test.ts` (+87 -1) 📝 `src/domain/process/processCaptureExample.ts` (+5 -0) 📝 `src/domain/process/processCaptureParsing.ts` (+40 -1) 📝 `src/domain/process/processCaptureValidation.ts` (+17 -2) _...and 35 more files_ </details> ### 📄 Description When process capture stops early or cleanup cannot be verified, REA returns the observations collected so far with the execution failure and per-resource cleanup reasons. Incomplete observations remain distinct from a verified capture; CLI and MCP honor the caller's PID normalization setting. Cleanup verifies run tokens and stable process identities before signaling, including detached children. Prelaunch baselines on Linux and Darwin exclude only unchanged preexisting processes. Sampled groups remain cleanup candidates even after the root exits or a child drops its token; unowned groups stay unsignaled and make cleanup incomplete. Verification waits briefly for signaled children to exit without repeating signals. Darwin process-table reads retry transient `ENOMEM` with a fresh size query and preserve other errno diagnostics. Electron carries its baseline through both cleanup and final verification. Launch observations distinguish the selected executable digest from an unknown running-image identity. Original v3 saved captures remain loadable, comparable, exportable, and available in prompt completion: migration preserves their old digest separately and reports the newer identity observations as unknown. Malformed old digests and incomplete modern manifests remain rejected. Generated contracts and catalog metadata are updated. Sanitized MCP error excerpt (other fields omitted): ```json { "code": "cleanup_incomplete", "details": { "execution_failure": "fixture final snapshot failure", "partial_observation": { "observations": { "target_pid": { "state": "available", "value": 1 }, "filesystem_snapshots": { "after": { "state": "unavailable", "reason": "Final filesystem snapshot failed: fixture final snapshot failure" } } } } } } ``` Validation: - `npm run build:cached`, `npm run check:ci`, and `npm run docs:check` passed. - Single-worker ownership, harness, lifecycle, Electron action/hook lane: 74 passed, one Linux-only skip on macOS. - Final legacy parsing/comparison, prompt completion, and advertised output-schema lane: 21 passed. - Native Darwin lane: all five tests passed, including compiled Swift retry and real run-token inspection. - Real macOS detached-child cleanup and protection of an unowned neighbor passed. Linux process regressions also passed on the earlier CI head. - A real Electron 43.3 workflow was attempted. Tracing confirmed preexisting identities were excluded, but full verification remains unproven on this busy host: unrelated protected processes started during the capture and exposed unreadable tokens, so cleanup correctly failed closed. - Independent source review found no remaining blocking findings after the follow-up fixes. Real Hopper/Ghidra verification was not performed. Related to #893. Follow-up review fixes: behavioral reconstruction verification now uses the canonical saved-v3 parser while preserving original Evidence. Cancellation during Darwin helper compilation remains cancellation through cleanup and both process/Electron boundaries; genuine compiler errors retain their diagnostics. Added real fake-compiler regressions for cancellation, temporary-root removal, retry, and preventing Electron launch. Follow-up single-worker runs passed 80 reconstruction/parser tests and 17 native/cancellation tests; build, check:ci, and docs:check passed. The final cancellation follow-up threads the caller signal through prelaunch baseline capture, process listing, identity reads, and retries for both process and Electron workflows. Cleanup deliberately completes without the aborted startup signal. Focused native/baseline/lifecycle tests passed 29 cases with one Linux-only skip; build, check:ci, and docs:check passed. Synced with current main. The unrelated Linux large-export-inventory timeout is addressed by the separately reviewable optimization in #1028, included here so this PR's merge CI can exercise it. Export comparison/MCP tests passed 21 cases, and profiling verified byte-for-byte identical full results with lower comparison time. Final review follow-up: owned provider startup forwards existing cancellation signals through native preparation and checks before spawning. Native compilation uses an internal controller and independent waiter cancellation, retains a surviving caller, aborts when the last waiter leaves, and waits for generation cleanup before retry. Closing during compilation stops it; directory-removal failures remain tracked and close reports them so cleanup can be retried. Final combined native/provider/display lane passed 43 tests with two host-specific skips; Ghidra/Hopper/JADX adapter lane passed, and build, check:ci, and docs:check passed. Independent review is clean after the cleanup-failure correction. The earlier 01a95075 merge CI passed all four Linux test shards. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:07:48 +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#2578
No description provided.