Repository navigation
refactor(process): build infrastructure cancellations with a required reason - #10595
Merged
Merged
Conversation
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.
…equired 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.
… 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.
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. |
Contributor
[Medium impact] No blocking issue was found in the reviewed changes. SummaryReplaces direct cancellation construction with
Reviews (8) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
11 tasks
…o HEAD # Conflicts: # scripts/verify/architecture-guard-baselines.json
19 tasks
# Conflicts: # scripts/verify/architecture-guard-baselines.json # scripts/verify/architecture-guards.mjs
11 tasks
…o HEAD # Conflicts: # scripts/verify/architecture-guard-baselines.json
# Conflicts: # scripts/verify/architecture-guard-baselines.json # src/sqlite/SqliteDatabaseProvider.ts
# Conflicts: # scripts/verify/architecture-guard-baselines.json # src/gpu/GpuCodeObjectsProvider.ts # src/model/ModelArtifactProvider.ts # src/rust/RustBinaryProvider.ts
…-reason-infrastructure # Conflicts: # scripts/verify/architecture-guard-baselines.json # src/cli/finishAnalysisCommand.ts # src/evm/EvmoleFailures.ts # src/pcap/PcapCommand.ts # src/process/ArtifactAnalysisResources.ts # src/wasm/WabtFailures.ts
22 tasks
…-reason-infrastructure # Conflicts: # scripts/verify/architecture-guard-baselines.json # src/evm/EvmoleFailures.ts # src/evm/EvmoleInterfaceProvider.ts # src/pcap/PcapOutput.ts # src/wasm/WabtFailures.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates every
AnalysisCancelledErrorconstruction in the shared infrastructure and the smaller providers tocancelledBy, the reason-requiring owner from #10566. That is 105 sites undersrc/process/,src/providers/,src/artifacts/,src/domain/,src/server/,src/cli/,src/sqlite/,src/pcap/,src/evm/,src/wasm/,src/firmware/,src/desktop/,src/signals/,src/gpu/,src/model/,src/rust/,src/cliJsonInput.tsandsrc/doctorRuntime.ts. The guard baseline drops from 671 to 566. Stacked on #10566 (its base branch); retarget tomainafter #10566 merges. Independent of the other slice PRs.Refs #8223
Problem and expected behavior
Each site threaded the cancellation reason into
causeby hand, often by spreading a shared option bag and then overriding itscause. After this change each site names the reason's source, andCancelledOptions(cause?: never) rejects an option bag that still carries a cause. A spread can no longer silently supply or replace the reason.AnalysisClientCreationrereadsignal?.reasonafter a shared startup wait reportedcancelled. It now uses the departing caller's reason that the wait returns (#10566).Change and scope
new AnalysisCancelledError(op, { cause: s.reason, ...rest })becamecancelledBy(op, s, rest)whereversis a narrowedAbortSignal. Every other cause becamecarriedReason(x), which keeps the existing value.cause(PcapCommanddetails,ArtifactAnalysisResourcesdetail, SQLite and WABToptions) are now split into…WithoutCauseplus the original bag. The cancellation branch uses the bag withoutcause; every other error branch keeps the bag withcause, in the same property order.AnalysisClientFailureandexplicitSensitiveFailurerebuild a cancellation from an earlierAnalysisCancelledErrorby passing that error as the reason.cancelledBycarries its cause unchanged.RegexMatcher's abort listener keeps its value throughcarriedReason(input.signal?.reason), because it runs only after that signal aborts.abort()calls with no reason (commandCancellation,EvidenceMcpServerCore, HTTP bridges). Giving them a typed caller reason is the separateCallerAbortdesign step. Also excluded: internal teardown controllers (OwnedCommandsink abandonment, Darwin token reader, worker frames, capture lifecycle), whose reasons are not surfaced as cancellation causes; debugger, native and Hopper directories (separate slices); and W4b finalization.Contract and boundary impact
cancelledBy,isAbortedandSharedStartupAttempt.wait(refactor(errors): require a reason for every analysis cancellation #10566); the infrastructure and provider adapters here are consumers.causeis not projected, and the redacted projection inexplicitSensitiveFailureis unchanged.Expected effects: none checked. This changes error construction only.
Evidence and regression coverage
Validation performed
npm run check:fast— passed (typecheck, lint).node scripts/verify/architecture-guards.mjs— passed; baseline 566 sites in 194 files, none in the migrated paths.npm run test:focused --the test files beside the changed modules plus thetests/files that import a changed module and assert on cancellation orcause(53 files) — 52 passed, 1 skipped (platform); 1687 tests passed, 103 skipped.npx oxfmton changed files — formatted.main(b0e3257), 2026-11-15: main'srunOwned(fix(apktool): report the decoder JVM's heap exhaustion as memory, not a target refusal #10634) and shared provider classifier (classifyProviderOutcome) now ownfinishAnalysisCommand, Evmole, WABT, pcap andArtifactAnalysisResourcescommand-failure classification and already build cancellations throughcancelledBy, so this PR's edits to those regions were dropped in favour of main; the remaining direct sites there (Evmole and WABT artifact-read cancellation, pcap's early abort) were converted.npm run check:fastpassed;node scripts/verify/architecture-guards.mjs --shrink-baselines, then the guard passed (it also lowered the staleMcpRegistrationGit.tsbindCleanupDependenciesentry, already 0 on main);npm run test:focused --11 pcap/WABT/Evmole/artifact-resources/finishAnalysisCommand/providerOutcome files: 197 tests passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.