[PR #1907] [MERGED] fix(process): retain owned command cleanup diagnostics #4899

Closed
opened 2026-10-31 00:56:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/1856-owned-command-cleanup-ledger


📝 Commits (1)

  • 33cf4c3 fix(process): retain owned command cleanup diagnostics

📊 Changes

8 files changed (+209 additions, -29 deletions)

View changed files

📝 src/process/OwnedCommand.ts (+20 -4)
📝 src/process/ProcessOwnership.part2.test.ts (+1 -1)
📝 src/process/ProcessOwnership.test.ts (+2 -2)
📝 src/process/ProcessOwnership.ts (+18 -14)
📝 src/process/ProcessOwnership.validation.test.ts (+4 -4)
📝 src/process/ProviderProcess.ts (+16 -3)
📝 tests/boundary/process/ownedCommand.test.ts (+97 -1)
📝 tests/boundary/process/providerProcess.test.ts (+51 -0)

📄 Description

Summary

An interrupted owned command can retain cleanup ownership while losing the diagnostics explaining which member could not be verified. Preserve that verification ledger through the supervisor and command failure, and identify the observed token mismatch in its summary. Fixes #1856.

Problem and expected behavior

A source-owned parent starts a child with a different ownership token in the same process group. On cancellation or timeout, cleanup correctly refuses to signal the mixed-ownership group. Its lower result identifies the child's PID and run-token-mismatch, but the supervisor previously discarded those fields and the command returned only process tree contains an unowned or PID-reused process.

Callers should receive the actual verification failures and retained owner, without treating an ordinary token mismatch as proof of PID reuse or acquiring additional authority.

Change and scope

  • Name the existing failed-cleanup representation and preserve it as optional cleanupResult on incomplete supervisor results and owned-command failures, including cleanup revalidation after launcher grace. Member failures, diagnostic reasons and sweep uncertainty remain intact.
  • Describe token mismatches with deterministic, deduplicated PID coordinates. Existing callers retaining the summary receive useful coordinates too.
  • Keep the existing fail-closed signal decisions, command failure reason/output, resource identities and retryable retained supervisor. Once the fixture cooperatively exits, a subsequent verified stop settles normally.

Contract and boundary impact

  • Semantic owner and earliest changed stage: process ownership verification produces the summary; the supervisor retains its complete failure result rather than reducing it to text.
  • CLI and MCP/tool-catalog contract: no advertised schema or operation changes. Failed-cleanup summaries become more specific; the shared process helper gains additive diagnostic fields.
  • Provider, bridge, target-format, or platform compatibility: no protocol or target-format change. Cleanup records retain their existing semantics.
  • Evidence, artifact, provenance, or reconstruction contract: no Evidence format change; captured command output and original interruption reason are preserved.
  • Process execution, authorization, cleanup, or containment impact: no new signaling authority. Unverified members remain unsignaled and ownership remains retained until a verified stop succeeds.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: actual parent/child cancellation and timeout cases; a controlled adapter case for a failed cleanup recheck retaining both member failures and sweep uncertainty. Existing ownership assertions now expect the factual token-mismatch summary.

  • Base reproduction: both new real process cases fail on the base because OwnedCommandFailure.cleanupResult is absent, while the lower cleanup result contains the exact child failure. Their cooperative cleanup still completes, so the tests leave no fixture processes behind.

  • User-visible output: the summary identifies the failed PID coordinates; process callers can inspect cleanupResult.failures for run-token-mismatch, environment-unreadable or process-identity-unavailable, and cleanupResult.unverified for sweep uncertainty.

  • Remaining proof gaps: no provider-specific leak, PID reuse or successful full client-family cleanup is inferred from this fixture. The recheck's unavailable-identity observation is deliberately injected; the parent/child token mismatch is observed through the real operating-system boundary.

  • 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 -- tests/boundary/process/ownedCommand.test.ts tests/boundary/process/providerProcess.test.ts src/process/ProcessOwnership.test.ts src/process/ProcessOwnership.part2.test.ts src/process/ProcessOwnership.part3.test.ts src/process/ProcessOwnership.validation.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.observation.test.ts — 107 tests passed, one platform-conditional test skipped, eight files passed.
  • Final affected boundary reruns — passed after test-only type narrowing and ready-fixture PID validation.
  • Actual built-runtime helper on a source-owned nested-token process fixture — retained per-member diagnostics, unsignaled unresolved group and later verified settlement passed.
  • npm run check — passed.
  • npm run verify:test-discovery and git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; cleanupResult is additive and absent when no structured failure was produced. Consumers should use typed verification reasons instead of parsing historical summary text.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux process ownership and supervision exercised. Other operating systems and real analysis engines were not locally exercised for this change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: preserve the existing token/identity checks, authority refusal and retained ownership. No ambient environment or token values are persisted. Verification ran serially under one CPU and 3 GiB; no binaries or generated outputs are committed.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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 (none changed).
  • User-visible CLI/MCP changes include representative output (shared failure summary described above).
  • 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/1907 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/1856-owned-command-cleanup-ledger` --- ### 📝 Commits (1) - [`33cf4c3`](https://github.com/morluto/rea/commit/33cf4c34ec6a0291c2ea0168a1c47e084a91eb78) fix(process): retain owned command cleanup diagnostics ### 📊 Changes **8 files changed** (+209 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `src/process/OwnedCommand.ts` (+20 -4) 📝 `src/process/ProcessOwnership.part2.test.ts` (+1 -1) 📝 `src/process/ProcessOwnership.test.ts` (+2 -2) 📝 `src/process/ProcessOwnership.ts` (+18 -14) 📝 `src/process/ProcessOwnership.validation.test.ts` (+4 -4) 📝 `src/process/ProviderProcess.ts` (+16 -3) 📝 `tests/boundary/process/ownedCommand.test.ts` (+97 -1) 📝 `tests/boundary/process/providerProcess.test.ts` (+51 -0) </details> ### 📄 Description ## Summary An interrupted owned command can retain cleanup ownership while losing the diagnostics explaining which member could not be verified. Preserve that verification ledger through the supervisor and command failure, and identify the observed token mismatch in its summary. Fixes #1856. ## Problem and expected behavior A source-owned parent starts a child with a different ownership token in the same process group. On cancellation or timeout, cleanup correctly refuses to signal the mixed-ownership group. Its lower result identifies the child's PID and `run-token-mismatch`, but the supervisor previously discarded those fields and the command returned only `process tree contains an unowned or PID-reused process`. Callers should receive the actual verification failures and retained owner, without treating an ordinary token mismatch as proof of PID reuse or acquiring additional authority. ## Change and scope - Name the existing failed-cleanup representation and preserve it as optional `cleanupResult` on incomplete supervisor results and owned-command failures, including cleanup revalidation after launcher grace. Member failures, diagnostic reasons and sweep uncertainty remain intact. - Describe token mismatches with deterministic, deduplicated PID coordinates. Existing callers retaining the summary receive useful coordinates too. - Keep the existing fail-closed signal decisions, command failure reason/output, resource identities and retryable retained supervisor. Once the fixture cooperatively exits, a subsequent verified stop settles normally. ## Contract and boundary impact - Semantic owner and earliest changed stage: process ownership verification produces the summary; the supervisor retains its complete failure result rather than reducing it to text. - CLI and MCP/tool-catalog contract: no advertised schema or operation changes. Failed-cleanup summaries become more specific; the shared process helper gains additive diagnostic fields. - Provider, bridge, target-format, or platform compatibility: no protocol or target-format change. Cleanup records retain their existing semantics. - Evidence, artifact, provenance, or reconstruction contract: no Evidence format change; captured command output and original interruption reason are preserved. - Process execution, authorization, cleanup, or containment impact: no new signaling authority. Unverified members remain unsignaled and ownership remains retained until a verified stop succeeds. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: actual parent/child cancellation and timeout cases; a controlled adapter case for a failed cleanup recheck retaining both member failures and sweep uncertainty. Existing ownership assertions now expect the factual token-mismatch summary. - Base reproduction: both new real process cases fail on the base because `OwnedCommandFailure.cleanupResult` is absent, while the lower cleanup result contains the exact child failure. Their cooperative cleanup still completes, so the tests leave no fixture processes behind. - User-visible output: the summary identifies the failed PID coordinates; process callers can inspect `cleanupResult.failures` for `run-token-mismatch`, `environment-unreadable` or `process-identity-unavailable`, and `cleanupResult.unverified` for sweep uncertainty. - Remaining proof gaps: no provider-specific leak, PID reuse or successful full client-family cleanup is inferred from this fixture. The recheck's unavailable-identity observation is deliberately injected; the parent/child token mismatch is observed through the real operating-system boundary. - [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 -- tests/boundary/process/ownedCommand.test.ts tests/boundary/process/providerProcess.test.ts src/process/ProcessOwnership.test.ts src/process/ProcessOwnership.part2.test.ts src/process/ProcessOwnership.part3.test.ts src/process/ProcessOwnership.validation.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.observation.test.ts` — 107 tests passed, one platform-conditional test skipped, eight files passed. - Final affected boundary reruns — passed after test-only type narrowing and ready-fixture PID validation. - Actual built-runtime helper on a source-owned nested-token process fixture — retained per-member diagnostics, unsignaled unresolved group and later verified settlement passed. - `npm run check` — passed. - `npm run verify:test-discovery` and `git diff --check` — passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none; `cleanupResult` is additive and absent when no structured failure was produced. Consumers should use typed verification reasons instead of parsing historical summary text. - Real Hopper/Ghidra, browser, or OS coverage: Linux process ownership and supervision exercised. Other operating systems and real analysis engines were not locally exercised for this change. - Package or release metadata impact: none. - Security, privacy, process, or containment review: preserve the existing token/identity checks, authority refusal and retained ownership. No ambient environment or token values are persisted. Verification ran serially under one CPU and 3 GiB; no binaries or generated outputs are committed. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed (none changed). - [x] User-visible CLI/MCP changes include representative output (shared failure summary described above). - [x] 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-10-31 00:56:33 +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#4899
No description provided.