[GH-ISSUE #4748] [Bug] Native UI completion loses cancellation facts and runtime release status #2475

Closed
opened 2026-10-17 21:05:19 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @morluto on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4748

Area

Process capture or runtime observation

Observed behavior

Five controlled production-boundary checks fail at 0f7fd005d: native UI admission loses the exact abort reason; a command-owner cancellation is reported as ProviderAdapterError; malformed helper output becomes cancellation if an unrelated later abort is visible; a completed observation returns success when cancellation occurs during runtime.close; and original/admission/retry cleanup errors remain incomplete after that runtime successfully releases.

Reproduction

Ran npm run test:focused -- tests/boundary/providers/native/nativeUiFinalization.test.ts: 5 failed / 5. Tiny valid snapshot or malformed output through the existing helper seam; mocked runtime factory exposes deterministic close failure/retry and abort-during-close. No Swift compilation, helper subprocess, investigated app, permission changes or GUI actions. The checks exercise observeNativeUi and NativeMacOSProvider client execution/close. Reproduction frequency: each selected case failed once in this baseline run.

Expected behavior

Per docs/tool-design.md#own-the-lifecycle and docs/testing.md#lifecycle-regressions: retain the owner's cancellation fact and exact reason; preserve existing physical/output failures; check cancellation after awaited finalization and retain completed facts; resolve cleanup status only when every reported exact owner confirms release.

Impact and scope

Observed typed outcomes and recovery state are wrong at the controlled module/provider boundary. Real UI/OS occurrence frequency: NOT_ENOUGH_INFO; no real app or public CLI/MCP fault reproduction attempted. Source also shows standalone observeNativeUi finally-close can replace the primary result/failure and provides no retained runtime recovery reference; this additional path is source-derived pending a control.

REA version

Source 0f7fd005db (6.5.0).

Runtime and platform

Node 24.18.0, macOS arm64. Helper/runtime observations simulated as stated above.

Target and artifact context

Inert fixture Mach-O target metadata and tiny UI snapshot; target was not opened/executed.

Interface / Earliest failure stage

Other: production helper/provider boundary / Cleanup, cancellation, or lifecycle.

Relevant output or evidence

  • admission: expected cause object, received undefined;
  • command cancellation: expected AnalysisCancelledError, received ProviderAdapterError;
  • invalid output + later abort: expected ProviderAdapterError retaining ZodError, received AnalysisCancelledError;
  • cleanup cancellation: expected error retaining snapshot and caller reason, received success;
  • cleanup retry: after successful close, expected cleanupIncomplete:false, received true.

Sources at the stated revision: src/native/NativeUiObservation.ts (take catch and standalone finally), src/native/NativeMacOSProvider.ts (#observeNativeUi, #retryNativeUiCleanup, #nativeUiCleanupFailure), src/native/NativeUiHelperRuntime.ts (runtime resource lifetime).

Analysis

Source-derived: take guesses failure class from ambient signal.aborted and drops reason; provider returns success after close without a final signal check; raw runtime sets are disconnected from caller-visible error completion. Fix should give the exact runtime a release capability and keep validated report/cancellation/physical cleanup outcomes distinct. Related umbrella: #4227. Searched open/closed native UI and native-ui-runtime issues and native UI PRs; #3482 only extracts a timeout, #991 covers incomplete AX data, neither supplies these lifecycle semantics.

Originally created by @morluto on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4748 ### Area Process capture or runtime observation ### Observed behavior Five controlled production-boundary checks fail at 0f7fd005d: native UI admission loses the exact abort reason; a command-owner cancellation is reported as ProviderAdapterError; malformed helper output becomes cancellation if an unrelated later abort is visible; a completed observation returns success when cancellation occurs during runtime.close; and original/admission/retry cleanup errors remain incomplete after that runtime successfully releases. ### Reproduction Ran `npm run test:focused -- tests/boundary/providers/native/nativeUiFinalization.test.ts`: 5 failed / 5. Tiny valid snapshot or malformed output through the existing helper seam; mocked runtime factory exposes deterministic close failure/retry and abort-during-close. No Swift compilation, helper subprocess, investigated app, permission changes or GUI actions. The checks exercise observeNativeUi and NativeMacOSProvider client execution/close. Reproduction frequency: each selected case failed once in this baseline run. ### Expected behavior Per docs/tool-design.md#own-the-lifecycle and docs/testing.md#lifecycle-regressions: retain the owner's cancellation fact and exact reason; preserve existing physical/output failures; check cancellation after awaited finalization and retain completed facts; resolve cleanup status only when every reported exact owner confirms release. ### Impact and scope Observed typed outcomes and recovery state are wrong at the controlled module/provider boundary. Real UI/OS occurrence frequency: NOT_ENOUGH_INFO; no real app or public CLI/MCP fault reproduction attempted. Source also shows standalone observeNativeUi finally-close can replace the primary result/failure and provides no retained runtime recovery reference; this additional path is source-derived pending a control. ### REA version Source 0f7fd005dba72fe2c8810fe8b16946d1fd9ee1ac (6.5.0). ### Runtime and platform Node 24.18.0, macOS arm64. Helper/runtime observations simulated as stated above. ### Target and artifact context Inert fixture Mach-O target metadata and tiny UI snapshot; target was not opened/executed. ### Interface / Earliest failure stage Other: production helper/provider boundary / Cleanup, cancellation, or lifecycle. ### Relevant output or evidence - admission: expected cause object, received undefined; - command cancellation: expected AnalysisCancelledError, received ProviderAdapterError; - invalid output + later abort: expected ProviderAdapterError retaining ZodError, received AnalysisCancelledError; - cleanup cancellation: expected error retaining snapshot and caller reason, received success; - cleanup retry: after successful close, expected cleanupIncomplete:false, received true. Sources at the stated revision: src/native/NativeUiObservation.ts (take catch and standalone finally), src/native/NativeMacOSProvider.ts (#observeNativeUi, #retryNativeUiCleanup, #nativeUiCleanupFailure), src/native/NativeUiHelperRuntime.ts (runtime resource lifetime). ### Analysis Source-derived: take guesses failure class from ambient signal.aborted and drops reason; provider returns success after close without a final signal check; raw runtime sets are disconnected from caller-visible error completion. Fix should give the exact runtime a release capability and keep validated report/cancellation/physical cleanup outcomes distinct. Related umbrella: #4227. Searched open/closed native UI and native-ui-runtime issues and native UI PRs; #3482 only extracts a timeout, #991 covers incomplete AX data, neither supplies these lifecycle semantics.
Author
Owner

@kaoru0822-kitauji commented on GitHub (Oct 17, 2026):

This appears fixed on current main (d9099190a, fix(native)!: retain UI outcomes through finalization, plus 04221e5f0 fix(native): bind UI runtime cleanup to exact owners). Both landed just before this issue was filed.

Executed on main d9099190a (macOS arm64, Node 24): npm run test:focused -- tests/boundary/providers/native/nativeUiFinalization.test.ts tests/boundary/providers/native/nativeUiRuntimeOwnership.test.ts src/native/NativeUiObservation.test.ts tests/boundary/mcp/nativeUiFinalizationMcp.test.ts → 4 files, 37/37 passed. That includes the issue's reproduction file nativeUiFinalization.test.ts, reported as 5/5 failing at 0f7fd005d and now 11/11 passing.

No real UI app, Swift helper or public CLI fault run. Leaving closure to a maintainer.

<!-- gh-comment-id:6232635386 --> @kaoru0822-kitauji commented on GitHub (Oct 17, 2026): This appears fixed on current main (d9099190a, `fix(native)!: retain UI outcomes through finalization`, plus 04221e5f0 `fix(native): bind UI runtime cleanup to exact owners`). Both landed just before this issue was filed. Executed on main d9099190a (macOS arm64, Node 24): `npm run test:focused -- tests/boundary/providers/native/nativeUiFinalization.test.ts tests/boundary/providers/native/nativeUiRuntimeOwnership.test.ts src/native/NativeUiObservation.test.ts tests/boundary/mcp/nativeUiFinalizationMcp.test.ts` → 4 files, 37/37 passed. That includes the issue's reproduction file `nativeUiFinalization.test.ts`, reported as 5/5 failing at 0f7fd005d and now 11/11 passing. No real UI app, Swift helper or public CLI fault run. Leaving closure to a maintainer.
Author
Owner

@morluto commented on GitHub (Oct 17, 2026):

Revalidated at main 19329e43b: all 37 focused checks passed across nativeUiFinalization.test.ts, nativeUiRuntimeOwnership.test.ts, NativeUiObservation.test.ts and nativeUiFinalizationMcp.test.ts. Fix commits d9099190a and 04221e5f0 are ancestors of current main.

Closing as fixed. Validation covers deterministic helper/runtime ports and the public MCP adapter boundary. No real UI app, Swift helper, native permission changes or GUI actions were exercised.

<!-- gh-comment-id:6242146423 --> @morluto commented on GitHub (Oct 17, 2026): Revalidated at main 19329e43b: all 37 focused checks passed across nativeUiFinalization.test.ts, nativeUiRuntimeOwnership.test.ts, NativeUiObservation.test.ts and nativeUiFinalizationMcp.test.ts. Fix commits d9099190a and 04221e5f0 are ancestors of current main. Closing as fixed. Validation covers deterministic helper/runtime ports and the public MCP adapter boundary. No real UI app, Swift helper, native permission changes or GUI actions were exercised.
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#2475
No description provided.