Skip to content

refactor(process): build infrastructure cancellations with a required reason - #10595

Merged
morluto merged 14 commits into
mainfrom
refactor/cancellation-reason-infrastructure
Nov 15, 2026
Merged

morluto merged 14 commits into
mainfrom
refactor/cancellation-reason-infrastructure

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Migrates every AnalysisCancelledError construction in the shared infrastructure and the smaller providers to cancelledBy, the reason-requiring owner from #10566. That is 105 sites under src/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.ts and src/doctorRuntime.ts. The guard baseline drops from 671 to 566. Stacked on #10566 (its base branch); retarget to main after #10566 merges. Independent of the other slice PRs.

Refs #8223

Problem and expected behavior

Each site threaded the cancellation reason into cause by hand, often by spreading a shared option bag and then overriding its cause. After this change each site names the reason's source, and CancelledOptions (cause?: never) rejects an option bag that still carries a cause. A spread can no longer silently supply or replace the reason.

AnalysisClientCreation reread signal?.reason after a shared startup wait reported cancelled. It now uses the departing caller's reason that the wait returns (#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.
  • Shared option bags that began with cause (PcapCommand details, ArtifactAnalysisResources detail, SQLite and WABT options) are now split into …WithoutCause plus the original bag. The cancellation branch uses the bag without cause; every other error branch keeps the bag with cause, in the same property order.
  • AnalysisClientFailure and explicitSensitiveFailure rebuild a cancellation from an earlier AnalysisCancelledError by passing that error as the reason. cancelledBy carries its cause unchanged.
  • RegexMatcher's abort listener keeps its value through carriedReason(input.signal?.reason), because it runs only after that signal aborts.
  • Not included: the CLI and MCP adapters' own abort() calls with no reason (commandCancellation, EvidenceMcpServerCore, HTTP bridges). Giving them a typed caller reason is the separate CallerAbort design step. Also excluded: internal teardown controllers (OwnedCommand sink 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

  • Semantic owner and earliest changed stage: cancelledBy, isAborted and SharedStartupAttempt.wait (refactor(errors): require a reason for every analysis cancellation #10566); the infrastructure and provider adapters here are consumers.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: none; cause is not projected, and the redacted projection in explicitSensitiveFailure is unchanged.
  • 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 objects and retained resources are passed unchanged.
  • Generated metadata, package, or installation impact: none.

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

Evidence and regression coverage

  • Tests added or updated: none. Every site keeps its previous cause value, and existing tests assert exact caller reasons through these paths.
  • Remaining proof gaps: no real-provider run; the change is source-derived plus existing tests.

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 the tests/ files that import a changed module and assert on cancellation or cause (53 files) — 52 passed, 1 skipped (platform); 1687 tests passed, 103 skipped.
  • npx oxfmt on changed files — formatted.
  • Merge with main (b0e3257), 2026-11-15: main's runOwned (fix(apktool): report the decoder JVM's heap exhaustion as memory, not a target refusal #10634) and shared provider classifier (classifyProviderOutcome) now own finishAnalysisCommand, Evmole, WABT, pcap and ArtifactAnalysisResources command-failure classification and already build cancellations through cancelledBy, 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:fast passed; node scripts/verify/architecture-guards.mjs --shrink-baselines, then the guard passed (it also lowered the stale McpRegistrationGit.ts bindCleanupDependencies entry, already 0 on main); npm run test:focused -- 11 pcap/WABT/Evmole/artifact-resources/finishAnalysisCommand/providerOutcome files: 197 tests passed.

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: the redaction path for explicitly sensitive failures keeps the same cause and redacted fields.

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.

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.
@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-15T08:53:22.944578Z 0cee6f2 New commits
ℹ️ 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: plus

[Medium impact] No blocking issue was found in the reviewed changes.

Summary

Replaces direct cancellation construction with cancelledBy across shared infrastructure and providers.

  • Cancellation errors now name where their reason comes from.

Reviews (8) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

…o HEAD

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
#	scripts/verify/architecture-guards.mjs
…o HEAD

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
Base automatically changed from refactor/cancellation-owner to main November 14, 2026 20:20
# 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
…-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
@morluto
morluto merged commit d5e0747 into main Nov 15, 2026
14 checks passed
@morluto
morluto deleted the refactor/cancellation-reason-infrastructure branch November 15, 2026 09:05
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant