[PR #5296] fix(process): preserve observed command failures before cancellation #6864

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5296
Author: @nimraweb3
Created: 10/19/2026
Status: 🔄 Open

Base: main ← Head: fix/owned-command-exit-before-cancellation


📝 Commits (1)

  • 2d2c771 fix(process): preserve observed command failures before cancellation

📊 Changes

2 files changed (+163 additions, -12 deletions)

View changed files

📝 src/process/OwnedCommand.ts (+51 -11)
📝 tests/boundary/process/ownedCommand.test.ts (+112 -1)

📄 Description

Summary

Fixes #5292. Preserve command failures observed before cancellation instead of replacing them when the owner resumes classification.

Problem and expected behavior

A child can exit 7 and finish writing stderr while its stdout sink is still finalizing. If the caller aborts before the owner resumes, the previous code reports cancellation despite having already observed the failed exit. The earlier failure should remain primary, with the exact later cancellation reason retained separately.

Change and scope

Record failed exits, output-limit violations, and collection failures at their observation boundary. Preserve the first failure through classification and cleanup; reuse the same exit predicate so accepted nonzero exits remain eligible for cancellation.

This is an ordinary fix within the existing owned-command boundary; a separate maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: OwnedCommand, during supervisor diagnostics and output collection.
  • CLI and MCP/tool-catalog contract: no schema or catalog changes; shared command failure classification changes as described above.
  • Provider/platform compatibility: existing process ownership and cleanup paths remain in use.
  • Evidence and cleanup: retain final exit/output snapshots, opaque caller cancellation, and retryable refused cleanup. Abort-induced sink errors do not replace the earlier failure.
  • Target selection and authority: unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.

The regression tests launch local Node children with controlled scripts.

Evidence and regression coverage

  • Added real-child cases for failed exit, accepted nonzero exit, successful exit, and output-limit failure followed by cancellation.
  • The test delays owner classification after real output closure; it does not fake exit diagnostics.
  • Against base 10f1994, the failed-exit and output-limit regressions both returned cancellation incorrectly. Both cancellation controls passed.
  • The cases also verify exact caller reason identity, retained diagnostics, sink destruction, absence of spurious collection errors, and cleanup retry.
  • Public CLI/MCP and external providers were not exercised. macOS/Linux behavior was not run locally.

Validation performed

  • npm run test:focused -- tests/boundary/process/ownedCommand.test.ts tests/boundary/process/ownedCommandCancellation.test.ts tests/boundary/providers/ownedCommandCleanup.test.ts src/process/OwnedCommandPreparation.test.ts — 40 passed, 4 POSIX-only tests skipped on Windows; required runtime artifacts built successfully.
  • npm run check — passed (type checking, lint with 0 errors, formatting, unused-code analysis, metadata, module boundaries, and architecture guards).
  • npm run verify:test-discovery — passed; all 1,683 test files discovered exactly once.

Node 24.18.0, npm 11.16.0, Windows.

Compatibility, safety, and release

No API, dependency, migration, or release metadata changes. Process cleanup remains independently verified and retryable. Real OS coverage is limited to Windows with the native process owner.

Author readiness

Human owner: @nimraweb3

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR.
  • 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/5296 **Author:** [@nimraweb3](https://github.com/nimraweb3) **Created:** 10/19/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/owned-command-exit-before-cancellation` --- ### 📝 Commits (1) - [`2d2c771`](https://github.com/morluto/rea/commit/2d2c77101b32e241e0891d64798dfea97a872640) fix(process): preserve observed command failures before cancellation ### 📊 Changes **2 files changed** (+163 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/process/OwnedCommand.ts` (+51 -11) 📝 `tests/boundary/process/ownedCommand.test.ts` (+112 -1) </details> ### 📄 Description ## Summary Fixes #5292. Preserve command failures observed before cancellation instead of replacing them when the owner resumes classification. ## Problem and expected behavior A child can exit 7 and finish writing stderr while its stdout sink is still finalizing. If the caller aborts before the owner resumes, the previous code reports cancellation despite having already observed the failed exit. The earlier failure should remain primary, with the exact later cancellation reason retained separately. ## Change and scope Record failed exits, output-limit violations, and collection failures at their observation boundary. Preserve the first failure through classification and cleanup; reuse the same exit predicate so accepted nonzero exits remain eligible for cancellation. This is an ordinary fix within the existing owned-command boundary; a separate maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `OwnedCommand`, during supervisor diagnostics and output collection. - CLI and MCP/tool-catalog contract: no schema or catalog changes; shared command failure classification changes as described above. - Provider/platform compatibility: existing process ownership and cleanup paths remain in use. - Evidence and cleanup: retain final exit/output snapshots, opaque caller cancellation, and retryable refused cleanup. Abort-induced sink errors do not replace the earlier failure. - Target selection and authority: unchanged. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Launch or attach to a process. - [x] Inject instrumentation or run scripts/code. The regression tests launch local Node children with controlled scripts. ## Evidence and regression coverage - Added real-child cases for failed exit, accepted nonzero exit, successful exit, and output-limit failure followed by cancellation. - The test delays owner classification after real output closure; it does not fake exit diagnostics. - Against base `10f1994`, the failed-exit and output-limit regressions both returned cancellation incorrectly. Both cancellation controls passed. - The cases also verify exact caller reason identity, retained diagnostics, sink destruction, absence of spurious collection errors, and cleanup retry. - Public CLI/MCP and external providers were not exercised. macOS/Linux behavior was not run locally. ## Validation performed - `npm run test:focused -- tests/boundary/process/ownedCommand.test.ts tests/boundary/process/ownedCommandCancellation.test.ts tests/boundary/providers/ownedCommandCleanup.test.ts src/process/OwnedCommandPreparation.test.ts` — 40 passed, 4 POSIX-only tests skipped on Windows; required runtime artifacts built successfully. - `npm run check` — passed (type checking, lint with 0 errors, formatting, unused-code analysis, metadata, module boundaries, and architecture guards). - `npm run verify:test-discovery` — passed; all 1,683 test files discovered exactly once. Node 24.18.0, npm 11.16.0, Windows. ## Compatibility, safety, and release No API, dependency, migration, or release metadata changes. Process cleanup remains independently verified and retryable. Real OS coverage is limited to Windows with the native process owner. ## Author readiness Human owner: @nimraweb3 - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR. - [ ] 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>
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#6864
No description provided.