[PR #4387] [MERGED] fix(electron): cancel windowless waits and state reads #6210

Closed
opened 2026-10-31 01:12:42 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/electron-wait-cancellation


📝 Commits (10+)

  • b1e7bbd fix(electron): cancel windowless waits and state reads
  • d47aa1f fix(electron): observe operations abandoned by prior cancellation
  • 39ec10e Merge upstream/main into fix/electron-wait-cancellation
  • 0f40cef fix(electron): check cancellation after capture finalization
  • 344c774 fix(electron): carry the caller abort reason through cancellation
  • af732dd fix(electron): report final state grace expiry as the caller's cancellation
  • 781d575 fix(pwntools): preserve worker ownership across launcher exec
  • b25d351 fix(browser): report cancellation after cleanup and source-map abort (#2893)
  • c884864 fix(filesystem): observe cancellation after file finalization
  • fe2a398 fix(managed): retain descriptor ownership through hash cancellation

📊 Changes

26 files changed (+5435 additions, -258 deletions)

View changed files

📝 docs/electron-observation.md (+7 -2)
➕ docs/verification/electron-cancellation-2026-10-16.json (+2895 -0)
➕ docs/verification/electron-cancellation-2026-10-16.md (+158 -0)
➕ experiments/analysis-efficiency/electron-cancellation-oracles.py (+154 -0)
➕ experiments/analysis-efficiency/electron-cancellation.mjs (+273 -0)
➕ experiments/analysis-efficiency/joplin-cli-cancellation.py (+123 -0)
📝 src/adb/AdbProvider.ts (+31 -20)
📝 src/application/RegularFileRead.ts (+16 -7)
📝 src/browser/PlaywrightElectronActiveActions.test.ts (+188 -2)
📝 src/browser/PlaywrightElectronActiveActions.ts (+68 -6)
📝 src/browser/PlaywrightElectronActiveProvider.test.ts (+456 -5)
📝 src/browser/PlaywrightElectronActiveProvider.ts (+49 -14)
📝 src/dotnet/ManagedSnapshot.ts (+33 -23)
📝 src/filesystem/OwnedRegularFile.ts (+35 -0)
📝 src/native/pwntools/PwntoolsDecoder.ts (+7 -4)
📝 tests/boundary/binaryDiagnostics/recordedCrashProvider.test.ts (+94 -19)
📝 tests/boundary/browser/cdpBrowserProvider.lifecycle_failures.test.ts (+195 -0)
➕ tests/boundary/filesystem/regularFileCancellation.test.ts (+233 -0)
📝 tests/boundary/filesystem/stableFileHashOwnership.test.ts (+49 -1)
📝 tests/boundary/mcp/fridaLifecycleMcp.test.ts (+5 -4)

...and 6 more files

📄 Description

Summary

Fixes #4388. Electron scenario capture now observes cancellation while waiting for the first window and while reading initial/final state. Cancellation already observed before cleanup retains its caller reason when cleanup subsequently fails.

Problem and expected behavior

An unbounded firstWindow or state read could prevent cancellation from reaching finalization. The earlier PR also replaced cancellation with success after a settled final snapshot, so a later cleanup failure changed the public category to execution_failure. Capture must preserve cancellation, partial observations and cleanup uncertainty independently.

Change and scope

The shared Electron provider bounds the initial snapshot by the startup deadline, observes cancellation during window waits and final reads, and grants the final snapshot the existing five-second post-cancellation grace. It records cancellation before finalization and checks cancellation first observed during cleanup afterward. One constructor owns early/late partial-capture cancellation errors; cleanup failures retain precedence and their diagnostics.

Scope decision: not applicable; ordinary fix within the existing capture boundary. No new execution authority, provider, tool, cache or normal-case result field.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Electron active action/state execution and provider outcome construction.
  • Contribution scope fit and linked maintainer decision: existing authorized capture boundary; no new capability.
  • CLI and MCP/tool-catalog contract: same shared implementation and input/result schemas; interrupted calls return typed errors rather than waiting indefinitely. Recorded catalog metadata is byte-identical to main.
  • Provider, bridge, target-format, or platform compatibility: deterministic regressions and Linux Joplin probes; packaged-runtime compatibility remains unverified.
  • Evidence, artifact, provenance, or reconstruction contract: retain caller cancellation cause, cancelled actions, partial snapshots and grace-expiry diagnostics; never convert unverified cleanup into success.
  • Target selection, authority, upstream behavior, and cleanup details: existing explicit target/lifecycle; process ownership policy unchanged. Linux cleanup/first-signal CLI exit remains an observed gap (#4282).
  • Generated metadata, package, or installation impact: none.

Expected effects retain the existing Electron capture authority:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Base reproduction: original main remains pending 20.001 s after cancellation with a controlled first-window stall. Two new cleanup-cause cases fail on the previously reviewed PR (20 pass, 2 fail), then pass after the producing-outcome fix.
  • Real app: unchanged Joplin 3.7.21 ASAR plus complete unpacked assets, generic Electron 44.7.0, fresh profiles/Xvfb. Controlled REA-side window/initial/final reply stalls return cancellation in 5.658/5.335/10.262 s respectively. These do not establish naturally occurring Joplin stalls or a completed GUI workflow.
  • Public CLI: main/fixed replies preserve code: cleanup_incomplete, category: cancelled and cancelled actions. The reviewed PR lost that category. All real CLI trials still fail the first-signal exit deadline; recorded recovery is not provider cleanup.
  • Remaining proof gaps: every real probe has incomplete/unverified Linux cleanup and a nonzero verifier exit. The official packaged runtime failed initial Inspector evaluation before reaching cancellation. No Windows/macOS, complete-task speedup or live-agent token savings claimed.

Reproduction scripts, exact source/input identities, all failures and resource observations.

  • 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

Review follow-up: both verifier success paths now require complete provider cleanup, including when the main process/CLI has exited. Six controlled oracle cases pass; both previous scripts fail the negative controls. Frozen real Joplin reruns retain cancellation and explicitly fail on unverified cleanup/first-signal CLI exit. These controlled replies are not real-provider evidence; production source and original historical records are unchanged.

  • npm run test:focused -- src/browser/PlaywrightElectronActiveActions.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts tests/boundary/mcp/serverIdentity.test.ts — 49 passed across three files.
  • npm run check:fast — six tasks and architecture guards passed.
  • npm run docs:check — six tasks (two cached) plus five README consistency cases passed.
  • Preserved real Joplin shared-provider/public-CLI probes — cancellation phases verified; complete workflows partial/failed as explained above.
  • Serial one-CPU/8 GiB scopes; full static gate 153.534 s wall, 152.274161 family CPU s, 6,442,016,768 peak cgroup bytes including cache. No OOM. Payload-exit counters are not final whole-scope counters.

Earlier-head CI (39 successful checks) and clear Codex review preceded the verifier follow-up; they do not establish current-head validation. Fresh CI and review results are being tracked on this head.

Compatibility, safety, and release

No breaking call, dependency or installation change. Existing instrumentation/lifecycle authority and strict process ownership remain unchanged. External owned-scope recovery is recorded separately from provider cleanup. Application binaries, profiles and regenerable large outputs are excluded from Git.

Author readiness

Human owner: @Adolanium

  • 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/4387 **Author:** [@Adolanium](https://github.com/Adolanium) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/electron-wait-cancellation` --- ### 📝 Commits (10+) - [`b1e7bbd`](https://github.com/morluto/rea/commit/b1e7bbddf97140692bbf656cd969a204c2d58305) fix(electron): cancel windowless waits and state reads - [`d47aa1f`](https://github.com/morluto/rea/commit/d47aa1fbca8d1f9d9de03c13d043ffe9245085b1) fix(electron): observe operations abandoned by prior cancellation - [`39ec10e`](https://github.com/morluto/rea/commit/39ec10e18dcbea68f98b06dff7b1b0c425336560) Merge upstream/main into fix/electron-wait-cancellation - [`0f40cef`](https://github.com/morluto/rea/commit/0f40cef32c1c5cb70d291d731ad3029cf0b179c5) fix(electron): check cancellation after capture finalization - [`344c774`](https://github.com/morluto/rea/commit/344c7744686e6c1c14a0e2950b11cc2f5eac8d61) fix(electron): carry the caller abort reason through cancellation - [`af732dd`](https://github.com/morluto/rea/commit/af732dd805cc4c881757ba6d02916841e7706863) fix(electron): report final state grace expiry as the caller's cancellation - [`781d575`](https://github.com/morluto/rea/commit/781d5751ad18b25a1fe1ffa8c6035388be8c3283) fix(pwntools): preserve worker ownership across launcher exec - [`b25d351`](https://github.com/morluto/rea/commit/b25d3517b68ad4352fa44e435f23c26de4bce54a) fix(browser): report cancellation after cleanup and source-map abort (#2893) - [`c884864`](https://github.com/morluto/rea/commit/c884864876c2568d8567235737b32e3f5893751d) fix(filesystem): observe cancellation after file finalization - [`fe2a398`](https://github.com/morluto/rea/commit/fe2a398dd9ab290ba6cb3411403d319cec8d07a2) fix(managed): retain descriptor ownership through hash cancellation ### 📊 Changes **26 files changed** (+5435 additions, -258 deletions) <details> <summary>View changed files</summary> 📝 `docs/electron-observation.md` (+7 -2) ➕ `docs/verification/electron-cancellation-2026-10-16.json` (+2895 -0) ➕ `docs/verification/electron-cancellation-2026-10-16.md` (+158 -0) ➕ `experiments/analysis-efficiency/electron-cancellation-oracles.py` (+154 -0) ➕ `experiments/analysis-efficiency/electron-cancellation.mjs` (+273 -0) ➕ `experiments/analysis-efficiency/joplin-cli-cancellation.py` (+123 -0) 📝 `src/adb/AdbProvider.ts` (+31 -20) 📝 `src/application/RegularFileRead.ts` (+16 -7) 📝 `src/browser/PlaywrightElectronActiveActions.test.ts` (+188 -2) 📝 `src/browser/PlaywrightElectronActiveActions.ts` (+68 -6) 📝 `src/browser/PlaywrightElectronActiveProvider.test.ts` (+456 -5) 📝 `src/browser/PlaywrightElectronActiveProvider.ts` (+49 -14) 📝 `src/dotnet/ManagedSnapshot.ts` (+33 -23) 📝 `src/filesystem/OwnedRegularFile.ts` (+35 -0) 📝 `src/native/pwntools/PwntoolsDecoder.ts` (+7 -4) 📝 `tests/boundary/binaryDiagnostics/recordedCrashProvider.test.ts` (+94 -19) 📝 `tests/boundary/browser/cdpBrowserProvider.lifecycle_failures.test.ts` (+195 -0) ➕ `tests/boundary/filesystem/regularFileCancellation.test.ts` (+233 -0) 📝 `tests/boundary/filesystem/stableFileHashOwnership.test.ts` (+49 -1) 📝 `tests/boundary/mcp/fridaLifecycleMcp.test.ts` (+5 -4) _...and 6 more files_ </details> ### 📄 Description ## Summary Fixes #4388. Electron scenario capture now observes cancellation while waiting for the first window and while reading initial/final state. Cancellation already observed before cleanup retains its caller reason when cleanup subsequently fails. ## Problem and expected behavior An unbounded `firstWindow` or state read could prevent cancellation from reaching finalization. The earlier PR also replaced cancellation with success after a settled final snapshot, so a later cleanup failure changed the public category to `execution_failure`. Capture must preserve cancellation, partial observations and cleanup uncertainty independently. ## Change and scope The shared Electron provider bounds the initial snapshot by the startup deadline, observes cancellation during window waits and final reads, and grants the final snapshot the existing five-second post-cancellation grace. It records cancellation before finalization and checks cancellation first observed during cleanup afterward. One constructor owns early/late partial-capture cancellation errors; cleanup failures retain precedence and their diagnostics. Scope decision: not applicable; ordinary fix within the existing capture boundary. No new execution authority, provider, tool, cache or normal-case result field. ## Contract and boundary impact - Semantic owner and earliest changed stage: Electron active action/state execution and provider outcome construction. - Contribution scope fit and linked maintainer decision: existing authorized capture boundary; no new capability. - CLI and MCP/tool-catalog contract: same shared implementation and input/result schemas; interrupted calls return typed errors rather than waiting indefinitely. Recorded catalog metadata is byte-identical to main. - Provider, bridge, target-format, or platform compatibility: deterministic regressions and Linux Joplin probes; packaged-runtime compatibility remains unverified. - Evidence, artifact, provenance, or reconstruction contract: retain caller cancellation cause, cancelled actions, partial snapshots and grace-expiry diagnostics; never convert unverified cleanup into success. - Target selection, authority, upstream behavior, and cleanup details: existing explicit target/lifecycle; process ownership policy unchanged. Linux cleanup/first-signal CLI exit remains an observed gap (#4282). - Generated metadata, package, or installation impact: none. Expected effects retain the existing Electron capture authority: - [x] Read existing files or captured data. - [x] Launch or attach to a process. - [x] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Base reproduction: original main remains pending 20.001 s after cancellation with a controlled first-window stall. Two new cleanup-cause cases fail on the previously reviewed PR (20 pass, 2 fail), then pass after the producing-outcome fix. - Real app: unchanged Joplin 3.7.21 ASAR plus complete unpacked assets, generic Electron 44.7.0, fresh profiles/Xvfb. Controlled REA-side window/initial/final reply stalls return cancellation in 5.658/5.335/10.262 s respectively. These do not establish naturally occurring Joplin stalls or a completed GUI workflow. - Public CLI: main/fixed replies preserve `code: cleanup_incomplete`, `category: cancelled` and cancelled actions. The reviewed PR lost that category. All real CLI trials still fail the first-signal exit deadline; recorded recovery is not provider cleanup. - Remaining proof gaps: every real probe has incomplete/unverified Linux cleanup and a nonzero verifier exit. The official packaged runtime failed initial Inspector evaluation before reaching cancellation. No Windows/macOS, complete-task speedup or live-agent token savings claimed. [Reproduction scripts, exact source/input identities, all failures and resource observations](https://github.com/Adolanium/rea/blob/de3733147496f1231db614b996b5c143003c622b/docs/verification/electron-cancellation-2026-10-16.md). - [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 Review follow-up: both verifier success paths now require complete provider cleanup, including when the main process/CLI has exited. Six controlled oracle cases pass; both previous scripts fail the negative controls. Frozen real Joplin reruns retain cancellation and explicitly fail on unverified cleanup/first-signal CLI exit. These controlled replies are not real-provider evidence; production source and original historical records are unchanged. - `npm run test:focused -- src/browser/PlaywrightElectronActiveActions.test.ts src/browser/PlaywrightElectronActiveProvider.test.ts tests/boundary/mcp/serverIdentity.test.ts` — 49 passed across three files. - `npm run check:fast` — six tasks and architecture guards passed. - `npm run docs:check` — six tasks (two cached) plus five README consistency cases passed. - Preserved real Joplin shared-provider/public-CLI probes — cancellation phases verified; complete workflows partial/failed as explained above. - Serial one-CPU/8 GiB scopes; full static gate 153.534 s wall, 152.274161 family CPU s, 6,442,016,768 peak cgroup bytes including cache. No OOM. Payload-exit counters are not final whole-scope counters. Earlier-head CI (39 successful checks) and clear Codex review preceded the verifier follow-up; they do not establish current-head validation. Fresh CI and review results are being tracked on this head. ## Compatibility, safety, and release No breaking call, dependency or installation change. Existing instrumentation/lifecycle authority and strict process ownership remain unchanged. External owned-scope recovery is recorded separately from provider cleanup. Application binaries, profiles and regenerable large outputs are excluded from Git. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @Adolanium - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [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. - [x] User-visible CLI/MCP changes include representative output. - [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 01:12:42 +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#6210
No description provided.