Repository navigation
refactor(errors): give caller aborts a typed reason at the adapters - #10633
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The reviewed changes appear safe to merge; no new actionable issues were found. SummaryAdds typed caller and owner abort reasons across the adapters and internal work owners.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Caller["Caller cancels or disconnects"] --> Adapter["CLI, MCP or HTTP adapter"]
Adapter --> CallerReason["CallerAbort"]
Owner["REA stops owned work"] --> OwnerReason["OwnerCancellation"]
CallerReason --> Signal["AbortSignal.reason"]
OwnerReason --> Signal
Signal --> Wait["waitForAbortable"]
Wait --> Carried["AbortedWait carries the observed reason"]
Carried --> Cancelled["cancelledBy preserves the cause"]
Reviews (10) · Last reviewed commit: "Merge origin/main into refactor/caller-a..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62ce5d008d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d596435 to
a9cc145
Compare
…the browser adapters (#10692) * refactor(errors): give owner-initiated aborts a typed reason outside the browser adapters * refactor(verify): keep the abort-reason scan receiver-independent Playwright's route.abort takes a network error code; the one call site now names its default code instead of the guard exempting a variable name. * refactor(browser): give owner-initiated CDP aborts typed reasons (#10706) * refactor(browser): give owner-initiated CDP aborts typed reasons * fix(browser): give the page-side request fetch page-native abort reasons The request callback runs in the page through page.evaluate and cannot reach REA's modules. Define its deadline and cleanup reasons as DOMExceptions inside the callback, and make the test fake evaluate the callback from its source so module imports are unavailable, as in a page.
Closing the Darwin run-token reader aborts its compilation with OwnerCancellation.ownerClosed since the owner-abort change in this PR; the boundary test still expected the default DOMException.
a9cc145 to
fa54a49
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa54a493e5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
The CLI, direct-analysis, MCP and HTTP adapters aborted their controllers with no reason, so a caller cancellation's
causewas an anonymous platformAbortError(or, for MCP, the client's bare string). This adds a typedCallerAbortthat each adapter creates when its caller ends work, gives REA's own aborts at those boundaries anOwnerCancellation, folds the startup-owner symbol intoOwnerCancellation, makeswaitForAbortablereturn the reason it observed, and adds a counted-baseline guard against new bare.abort()calls.Stacked on #10566 (base branch
refactor/cancellation-owner). Refs #8223Problem and expected behavior
withCommandCancellation(CLI),withProcessCancellation(direct analysis), the MCP request/completion bookkeeping and the node HTTP bridge calledcontroller.abort(). The resulting cause could not say whether SIGINT, SIGTERM, an MCPnotifications/cancelled, a client disconnect or REA itself ended the work.STARTUP_OWNER_CLOSEDwas a bareSymbol, which also became thecauseof a Ghidra NativeAOT and doctor cancellation.waitForAbortablereturned anABORTEDsentinel, so every consumer readsignal?.reasonagain (and IDA/Kuna wrapped it incarriedReason).OwnerCancellation; the abortable wait hands its reason straight tocancelledBy.Change and scope
src/domain/analysisErrorCore.ts:CallerAbort extends DOMExceptionwithname === "AbortError",kind(interrupt,terminate,request-cancelled,client-disconnected) and optionalclientReason;CallerAbort.forProcessSignal(signal). It keeps the platform abort shape on purpose. Existing classifiers that matchname === "AbortError", and Node'sfs/fetchwrapping ofsignal.reason, see the same shape as before (checked:fswraps it ascause;fetchrejects with it directly). The doc comment states it is opaque like any caller reason: its kind never establishes failure origin or cleanup authority.OwnerCancellation.startupOwnerClosed(new kindstartup-owner-closed) replacesSTARTUP_OWNER_CLOSED. It is kept distinct fromOwnerCancellation.ownerClosedon purpose. Hopper and Ghidra compare a startup signal's reason by identity to report "session closed during startup". If it were merged with the generalownerClosed, an outer owner's close reaching the caller's signal would be misreported as a startup closure.commandCancellation.ts: SIGINT and SIGTERM abort withCallerAbort.forProcessSignal.DirectAnalysis.withProcessCancellation: the same, split into two listeners.EvidenceMcpServerCore/McpToolRequest:notifications/cancelledaborts withCallerAbort("request-cancelled", params.reason). Transportoncloseaborts withclient-disconnected. REA'sclose()and the post-reply release useOwnerCancellation.ownerClosed.McpToolRequest.cancelandforgetPendingMcpRequestnow require the reason.nodeHttpBridge: client leaving aborts withclient-disconnected;serveStreamableHttpbody-forwarding release and shutdown useownerClosed.eagerRuntimeshutdown aborts startup withownerClosed.src/process/AbortablePromise.ts:ABORTEDis replaced byAbortedWait, aCarriedCancellationReasonholding the reason observed when the abort won. All 14 consumers were migrated. gdb, IDA and the two Kuna sites now callcancelledBy(operation, waited); desktop rethrowswaited.carried;SharedStartupAttemptreturns and forwards it.scripts/verify/architecture-guards.mjsaddsabort-without-reason(pattern.abort()with no argument, non-testsrc/), using the existing counted baseline. Baseline: 32 sites in 25 files (43 before this PR). gdb'snew AnalysisCancelledError(baseline drops 13 → 12..abort()sites. Several are internal controllers whose consumers rely on the platformAbortError(for exampleZipArtifactReader), so each needs checking in its own slice;Finalized<T>/runOwned(W4b);hopperCancelledBySignal,#startupWaitCancellation,rizinCancellation), which still read the signal for the post-completion check.Contract and boundary impact
CallerAbort/OwnerCancellationinsrc/domain/analysisErrorCore.ts. The CLI, MCP and HTTP adapters create them, andcancelledByconsumes them.causeis not projected; exit codes 130/143 are unchanged.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
None checked: this changes abort reasons only.
The MCP request boundary now passes the owned cancellation signal to both schema-bearing and schema-free handlers. Owner shutdown records close intent before transport closure, preserving the owner reason when
onclosefires synchronously.Evidence and regression coverage
src/server/EvidenceMcpServer.test.ts:callToolaborted with"user stopped"gives the running tool's request signal aCallerAbortof kindrequest-cancelledwith thatclientReason;src/server/http/nodeHttpBridge.test.ts: a client leaving aborts the webRequestwithCallerAbortclient-disconnected.tests/boundary/cli/androidCliCancellation.test.ts: SIGINT/SIGTERM giveinterrupt/terminatereasons withname: "AbortError".src/domain/analysisErrorCore.cancellation.test.ts: theCallerAbortshape;startupOwnerClosedis distinct fromownerClosed.src/process/AbortablePromise.test.ts(new): the wait carries the reason intocancelledBy, including a signal aborted before the wait.SharedStartupAttempt, Kuna doctor and Ghidra profile-ownership tests now assertOwnerCancellation.startupOwnerClosed.EvidenceMcpServerCore.tsandnodeHttpBridge.tsreverted to the base branch, the three MCP/HTTP tests fail (reasons are the client string or a plainDOMException); they pass with this change..abort()failsnode scripts/verify/architecture-guards.mjs(same mechanism as refactor(errors): require a reason for every analysis cancellation #10566).Additional validation: MCP server and cancellation lifecycle tests passed (20 tests), including real in-memory transport shutdown and joined handler cleanup.
npm run check:fastpassed.Validation performed
origin/main(conflict inscripts/verify/architecture-guards.mjs: kept both theabort-without-reasonand the newgdb-mi-record-regexchecks):npm run check:fast— passed;node scripts/verify/architecture-guards.mjs— passed;npx oxfmt --check scripts/verify/architecture-guards.mjs— passed.npm run check:fast: passed (typecheck, lint).node scripts/verify/architecture-guards.mjs: passed across 2783 source files.npm run docs:check: passed.npx oxfmt --checkon changed files: passed.npm run test:local -- src/server/EvidenceMcpServer.test.ts src/server/http/nodeHttpBridge.test.ts src/process/SharedStartupAttempt.test.ts src/doctorRuntime.test.ts: 61 passed, 1 skipped.npm run test:local -- src/application/desktop/DesktopBuildTurns.test.ts src/application/desktop/DesktopRemoteTaskReaders.test.ts: 13 passed.npm run test:local -- src/ida/IdaSessionClient.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/process/OwnedCommand.test.ts: 396 passed.npm run test:local -- src/domain/analysisErrorCore.cancellation.test.ts src/process/AbortablePromise.test.ts: 8 passed.npm run test:focused -- tests/boundary/cli/androidCliCancellation.test.ts tests/boundary/providers/hopper/hopperClient.startupWaiters.test.ts tests/boundary/providers/hopper/hopperClient.restart.test.ts tests/boundary/providers/ghidra/ghidraClient.test.ts tests/boundary/providers/kuna/kunaDoctor.test.ts tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts tests/boundary/providers/GdbCommandQueue.test.ts tests/boundary/providers/RizinDebugSessionAdmission.test.ts tests/boundary/providers/kuna/kunaCommandCancellation.test.ts tests/boundary/providers/ida/retainedConnectionRetry.test.ts tests/process-global/commandFinalizationCancellation.test.ts: 11 files, 191 passed.darwinProcessRunTokenReader.test.tsstill expecting the defaultDOMExceptionfor a reader close, which this PR's owner-abort change now reports asOwnerCancellation.ownerClosed; the expectation was updated.npm run test:focused -- tests/boundary/process/darwinProcessRunTokenReader.test.ts: 37 passed. Related abort-reason tests (nativeCommandResolver,cdpConnection,EvidenceMcpServer,HopperDownload,KunaCopy,analysisErrorCore.cancellation,ExecFileOutput,androidTargetSnapshot): 137 passed. Architecture guards and pre-pushcheck:fastpassed.scripts/verify/architecture-guards.mjswith main's new tshark guard; both guards kept):node scripts/verify/architecture-guards.mjspassed;npm run check:fastpassed.npm run test:focused -- src/server/http/serveStreamableHttp.test.ts: 77 passed; with theonclosechange reverted the new replacement and shutdown cases fail.npm run test:focused -- src/server/EvidenceMcpServer.test.ts tests/boundary/cli/cliStartupImports.test.ts: 16 passed.npm run check:fastpassed.Compatibility, safety, and release
STARTUP_OWNER_CLOSEDandABORTEDwere internal).DirectAnalysis.ts,Doctor.ts, desktop imports), refactor(process): build infrastructure cancellations with a required reason #10595 (McpToolRequest.tsimport) and refactor(native): build debugger and native cancellations with a required reason #10599/fix(gdb): keep a retained cancelled startup a cancellation on cleanup retry #10551 (gdb/rizinwaitFor*Turn). Keep both sides, then rerunnode scripts/verify/architecture-guards.mjs --shrink-baselines.CallerAbort.clientReasonretains the MCP client's own cancellation text in memory only; it is not projected.Author readiness
Human owner:
Before merge
type(scope): outcome.