[PR #6959] [MERGED] fix(process): preserve the caller abort reason in regex worker cancellations #7474

Closed
opened 2026-11-01 21:48:06 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/6957-regex-worker-abort-reason


📝 Commits (2)

  • 830444b fix(process): preserve the caller abort reason in regex worker cancellations
  • 7c369c7 test(process): assert the caller abort reason for cancelled regex matches

📊 Changes

2 files changed (+44 additions, -2 deletions)

View changed files

📝 src/process/RegexMatcher.ts (+12 -2)
📝 tests/boundary/process/regexMatcher.test.ts (+32 -0)

📄 Description

Summary

matchRegexValues built its cancellation errors without the caller's abort reason at both producing sites, so a regex search_procedures or search_strings cancelled through Hopper reported cancelled with cause === undefined, although the exact object passed to AbortController.abort(reason) was still on the signal. Both sites now pass the caller's signal.reason as the error cause, following the convention #6144 established and that HopperRegexSearch already applies to the cancellation it observes itself.

Fixes #6957

Problem and expected behavior

Smallest trigger: call matchRegexValues with an AbortSignal aborted with a non-undefined reason, either already aborted or aborted while the worker runs.

Expected: the cancellation error's cause is that exact reason. Observed before this change: cause === undefined. Violated invariant: a caller-supplied abort reason survives into the typed cancellation error. Hopper returns the matcher result unchanged (src/hopper/HopperRegexSearch.ts line 147), so the loss reached its provider result; the IDA client repairs a missing cause at its failure boundary (src/ida/IdaSessionClient.ts lines 453 to 456).

Change and scope

  • src/process/RegexMatcher.ts: the pre-admission refusal passes cause: input.signal.reason; the abort listener armed while the worker runs passes cause: input.signal?.reason.

The matcher is the producer shared by the Hopper, IDA, and Kuna regex searches, so the fix lands once at its owner. Intentionally not included: consumer-side rewrapping, the deadline and heap failures (unchanged), and any schema change. No complexity was added for a speculative race.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/process/RegexMatcher.ts, the construction of the cancellation error inside matchRegexValues.
  • Contribution scope fit and linked maintainer decision: not applicable (ordinary fix within an existing boundary).
  • CLI and MCP/tool-catalog contract: no schema change. The typed error's cause is now populated; whether cause reaches wire output was not examined.
  • Provider, bridge, target-format, or platform compatibility: none. Hopper, IDA, and Kuna share the matcher and receive the populated cause.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; worker termination in finally is untouched.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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.

No target interaction: the change affects only the construction of a typed error.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/process/regexMatcher.test.ts, "preserves the caller abort reason for pre-cancelled and interrupted matches". It covers a pre-aborted signal and an abort raised after the call starts, asserting with toBe that error.cause is the identical reason object. On the base revision both assertions fail because cause is undefined.
  • Base reproduction or other evidence: source-derived; the issue lists the file and line references at 1d896e03b.
  • User-visible CLI/MCP output (if applicable): none intended.
  • Remaining proof gaps: the Hopper boundary is established by reading (HopperRegexSearch.ts line 147 returns the matcher result unchanged), not by a new provider-level test. Wire projection of cause was not examined.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Not an evidence-bearing change.

Validation performed

  • No commands were run locally. The repository CI on this PR (source tests, built-dependent shards, PR readiness) is the executed validation; its results are the checks on this PR.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not exercised; the matcher runs in a worker thread without provider processes.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; the cause is the caller's own reason object.

Author readiness

Human owner: @viniciusdsandrade

  • 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/6959 **Author:** [@viniciusdsandrade](https://github.com/viniciusdsandrade) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/6957-regex-worker-abort-reason` --- ### 📝 Commits (2) - [`830444b`](https://github.com/morluto/rea/commit/830444b63bb5ba84c84cd72e441ebc4842483f54) fix(process): preserve the caller abort reason in regex worker cancellations - [`7c369c7`](https://github.com/morluto/rea/commit/7c369c7a5bb10f8a5028699732c21fc9d45cef17) test(process): assert the caller abort reason for cancelled regex matches ### 📊 Changes **2 files changed** (+44 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/process/RegexMatcher.ts` (+12 -2) 📝 `tests/boundary/process/regexMatcher.test.ts` (+32 -0) </details> ### 📄 Description ## Summary `matchRegexValues` built its cancellation errors without the caller's abort reason at both producing sites, so a regex `search_procedures` or `search_strings` cancelled through Hopper reported `cancelled` with `cause === undefined`, although the exact object passed to `AbortController.abort(reason)` was still on the signal. Both sites now pass the caller's `signal.reason` as the error `cause`, following the convention #6144 established and that `HopperRegexSearch` already applies to the cancellation it observes itself. Fixes #6957 ## Problem and expected behavior Smallest trigger: call `matchRegexValues` with an `AbortSignal` aborted with a non-undefined reason, either already aborted or aborted while the worker runs. Expected: the cancellation error's `cause` is that exact reason. Observed before this change: `cause === undefined`. Violated invariant: a caller-supplied abort reason survives into the typed cancellation error. Hopper returns the matcher result unchanged (`src/hopper/HopperRegexSearch.ts` line 147), so the loss reached its provider result; the IDA client repairs a missing cause at its failure boundary (`src/ida/IdaSessionClient.ts` lines 453 to 456). ## Change and scope - `src/process/RegexMatcher.ts`: the pre-admission refusal passes `cause: input.signal.reason`; the abort listener armed while the worker runs passes `cause: input.signal?.reason`. The matcher is the producer shared by the Hopper, IDA, and Kuna regex searches, so the fix lands once at its owner. Intentionally not included: consumer-side rewrapping, the deadline and heap failures (unchanged), and any schema change. No complexity was added for a speculative race. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/process/RegexMatcher.ts`, the construction of the cancellation error inside `matchRegexValues`. - Contribution scope fit and linked maintainer decision: not applicable (ordinary fix within an existing boundary). - CLI and MCP/tool-catalog contract: no schema change. The typed error's `cause` is now populated; whether `cause` reaches wire output was not examined. - Provider, bridge, target-format, or platform compatibility: none. Hopper, IDA, and Kuna share the matcher and receive the populated cause. - Evidence, artifact, provenance, or reconstruction contract: unchanged. - Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; worker termination in `finally` is untouched. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [ ] 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. No target interaction: the change affects only the construction of a typed error. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/process/regexMatcher.test.ts`, "preserves the caller abort reason for pre-cancelled and interrupted matches". It covers a pre-aborted signal and an abort raised after the call starts, asserting with `toBe` that `error.cause` is the identical reason object. On the base revision both assertions fail because `cause` is `undefined`. - Base reproduction or other evidence: source-derived; the issue lists the file and line references at `1d896e03b`. - User-visible CLI/MCP output (if applicable): none intended. - Remaining proof gaps: the Hopper boundary is established by reading (`HopperRegexSearch.ts` line 147 returns the matcher result unchanged), not by a new provider-level test. Wire projection of `cause` was not examined. For evidence-bearing changes: - [ ] Observed, derived, and inferred claims remain distinguishable. - [ ] Artifact identity, source provenance, and failed attempts remain preserved. - [ ] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. Not an evidence-bearing change. ## Validation performed - No commands were run locally. The repository CI on this PR (source tests, built-dependent shards, PR readiness) is the executed validation; its results are the checks on this PR. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not exercised; the matcher runs in a worker thread without provider processes. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; the cause is the caller's own reason object. ## Author readiness Human owner: @viniciusdsandrade - [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-11-01 21:48:06 +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#7474
No description provided.