Skip to content

refactor(providers): build decompiler-provider cancellations with a required reason - #10587

Merged
morluto merged 1 commit into
refactor/cancellation-ownerfrom
refactor/cancellation-reason-decompilers
Nov 14, 2026
Merged

morluto merged 1 commit into
refactor/cancellation-ownerfrom
refactor/cancellation-reason-decompilers

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Migrates every AnalysisCancelledError construction under src/ghidra/, src/ida/, src/cutter/, src/jeb/ and src/kuna/ (99 sites) to cancelledBy, the reason-requiring owner from #10566. The guard baseline drops from 671 to 572. Stacked on #10566 (its base branch); retarget to main after #10566 merges. Independent of the other slice PRs.

Refs #8223

Problem and expected behavior

  • KunaTargetCommands.run, prepare and inputHead refused work while closing with cause: undefined unless the signal had aborted. They now report OwnerCancellation.ownerClosed in that case and keep the caller's reason when the caller aborted.
  • KunaSessionClient.close and the JEB MCP connection's close aborted their lifetime controllers with no reason. Work cancelled by that close (for example Kuna target commands reading lifetime.signal.reason) then reported a generic AbortError. Both now abort with OwnerCancellation.ownerClosed.
  • Ghidra (GhidraProvider, GhidraNativeAotSnapshotOwner) and Kuna reread callerSignal?.reason after a shared startup wait reported cancelled. They now use the departing caller's reason that the wait returns (refactor(errors): require a reason for every analysis cancellation #10566).

Change and scope

  • Mechanical: new AnalysisCancelledError(op, { cause: s.reason, ...rest }) became cancelledBy(op, s, rest) wherever s is a narrowed AbortSignal. Every other cause became carriedReason(x), which keeps the existing value.
  • Replaced local abort predicates with the shared isAborted: GhidraLauncher's isAborted, IDA's wasCancelled, KunaSessionClient's cancelled and KunaStringQueries' #cancelled.
  • Abort listeners, plus waits that return ABORTED (IDA call wait, Kuna waitFor, project reader, query work, project cache, single-function waiters, Cutter session listing, JEB catalog wait), keep their value through carriedReason(signal?.reason). They run only after the signal aborts.
  • JebProvider, GhidraProviderClient and KunaCommand built shared options that included cause. The cancellation branch now passes those options without cause, and cause?: never enforces that; the timeout and provider branches are unchanged.
  • Not included: other directories (separate slices), Kuna's internal abort() calls with no reason (KunaProjectCache waiter-less export, KunaJsonStream rejection, yielded reader), whose reasons are not surfaced as cancellation causes, and W4b finalization.

Contract and boundary impact

  • Semantic owner and earliest changed stage: cancelledBy and isAborted in src/domain/analysisErrorCore.ts, and SharedStartupAttempt.wait (refactor(errors): require a reason for every analysis cancellation #10566); the provider adapters are consumers.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: none; cause is not projected.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: none; cleanup ownership and retained resources are unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects: none checked. This changes error construction only.

Evidence and regression coverage

  • Tests updated: tests/boundary/providers/kuna/kunaCommandFailures.test.ts. A closed KunaTargetCommands without a caller abort now reports OwnerCancellation.ownerClosed, not an invented caller cause. The test previously pinned cause to undefined, so it fails against the unmigrated code.
  • Remaining proof gaps: the Kuna session and JEB close reasons are source-derived; no test observes them. No real Ghidra, IDA, JEB, Cutter or Kuna run was made.

Validation performed

  • npm run check:fast — passed (typecheck, lint).
  • node scripts/verify/architecture-guards.mjs — passed; baseline 572 sites in 203 files, none under the migrated directories.
  • npm run test:focused -- the test files beside the changed modules plus the tests/ files that import a changed module and assert on cancellation or cause (43 files) — 42 passed, 1 failed: kunaCommandFailures.test.ts pinned the old absent cause. After the update, npm run test:focused -- tests/boundary/providers/kuna/kunaCommandFailures.test.ts — 9 passed.
  • npx oxfmt on changed files — formatted.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner:

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

…equired reason

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T15:47:15.558422Z 587af7f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Migrates 99 provider cancellation errors to cancelledBy, using the shared owner introduced in #10566.

  • Provider cancellations now keep their caller’s reason through one shared constructor.
  • Closed Kuna and JEB owners now give cancelled work an owner-close reason.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Aborted caller signal"] --> D["cancelledBy"]
  B["Captured reason or earlier cancellation"] --> D
  C["OwnerCancellation.ownerClosed"] --> D
  D --> E["AnalysisCancelledError"]
  E --> F["Existing error reporting and cleanup"]
Loading

Reviews (2) · Last reviewed commit: "refactor(providers): build decompiler-pr..." · Reviewed by Greptile

@morluto
morluto merged commit dc0baa9 into refactor/cancellation-owner Nov 14, 2026
1 check passed
@morluto
morluto deleted the refactor/cancellation-reason-decompilers branch November 14, 2026 15:56
morluto added a commit that referenced this pull request Nov 14, 2026
…10566)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* fix(errors): read the reason of any signal-shaped cancellation source

* test(ci): cover the counted-baseline comparison behind the architecture guard
morluto added a commit that referenced this pull request Nov 14, 2026
…d reason (#10590)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(android): build mobile-provider cancellations with a required reason

Migrate every remaining AnalysisCancelledError construction under
src/adb, src/android, src/apktool, src/apkSignature, src/flutter,
src/il2cpp, src/dotnet and src/frida to cancelledBy and lower the guard
baseline from 671 to 608. A closed adb provider reports
OwnerCancellation.ownerClosed for later probes, and JADX and apktool
shutdown abort with that typed reason.

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* fix(errors): read the reason of any signal-shaped cancellation source

* test(ci): cover the counted-baseline comparison behind the architecture guard
morluto added a commit that referenced this pull request Nov 15, 2026
…10601)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* fix(errors): read the reason of any signal-shaped cancellation source

* test(ci): cover the counted-baseline comparison behind the architecture guard

* refactor(hopper): build Hopper cancellations with a required reason

Migrate the remaining AnalysisCancelledError constructions under
src/hopper to cancelledBy. Regex-search close aborts its workers with
OwnerCancellation.ownerClosed. HopperCleanup and HopperClient are not
touched.

* test(hopper): cover cancellation during search shutdown
morluto added a commit that referenced this pull request Nov 15, 2026
… reason (#10595)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* refactor(process): build infrastructure cancellations with a required reason

Migrate every AnalysisCancelledError construction in shared process,
provider, artifact, domain, server and CLI code and in the smaller
providers to cancelledBy, lowering the guard baseline from 671 to 566.
Option bags that carried a cause are split so the cancellation branch
cannot receive one.

* fix(errors): read the reason of any signal-shaped cancellation source

* test(ci): cover the counted-baseline comparison behind the architecture guard
morluto added a commit that referenced this pull request Nov 15, 2026
…#10581)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(browser): build browser cancellations with a required reason

Migrate every AnalysisCancelledError construction under src/browser,
src/javascript, src/electron, src/inspector and src/captures to
cancelledBy and lower the guard baseline from 671 to 572. Service-worker
setup aborts with OwnerCancellation.ownerClosed on close.

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* fix(errors): read the reason of any signal-shaped cancellation source

* test(ci): cover the counted-baseline comparison behind the architecture guard

* refactor(electron): drop an unused error import from the fuse failure mapper
morluto added a commit that referenced this pull request Nov 15, 2026
…ired reason (#10599)

* refactor(errors): require a reason for every analysis cancellation

Add cancelledBy, the one constructor for AnalysisCancelledError. Its
reason argument is required: an aborted signal, an earlier cancellation,
a reason carried from an inner failure, or an OwnerCancellation when REA
closed the work's owner itself.

Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and
binary-session record owners now report OwnerCancellation.ownerClosed
instead of an absent reason. Firmware's predecessor wait returns its
cancellation as a Result, removing an unreachable reason-less fallback.

An architecture guard rejects new direct constructions, with a counted
per-file baseline that can only shrink.

* refactor(errors): share one aborted-signal predicate with cancelledBy

* refactor(process): return a departing caller's reason from a shared startup wait

* refactor(providers): build decompiler-provider cancellations with a required reason (#10587)

Migrate every AnalysisCancelledError construction under src/ghidra,
src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the
guard baseline from 671 to 572. Closed Kuna target commands report
OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and
JEB close abort their lifetimes with that typed reason.

* fix(errors): read the reason of any signal-shaped cancellation source

* refactor(native): build debugger and native cancellations with a required reason

Migrate every AnalysisCancelledError construction under src/native,
src/gdb and src/rizin to cancelledBy and delete Rizin's local
rizinCancellation constructor; its reason choice becomes a
CancellationReason. GDB close aborts active startups with
OwnerCancellation.ownerClosed.

* test(ci): cover the counted-baseline comparison behind the architecture guard

* refactor(native): drop an unused cancellation import from native UI observation
@morluto morluto added the area: providers Provider and capability discovery, including provider proposal triage label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant