Skip to content

refactor(application): build application cancellations with a required reason - #10574

Merged
morluto merged 11 commits into
mainfrom
refactor/cancellation-reason-application
Nov 15, 2026
Merged

morluto merged 11 commits into
mainfrom
refactor/cancellation-reason-application

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Migrates every AnalysisCancelledError construction under src/application/ (229 sites) to cancelledBy, the reason-requiring owner added in #10566, and lowers the guard baseline from 671 to 442. Stacked on #10566 (its base branch); retarget to main after #10566 merges.

Refs #8223

Problem and expected behavior

Several application paths built a cancellation whose reason could be absent:

  • BinarySession refused work after beginShutdown() with cause: signal?.reason, which is undefined whenever the caller had not aborted. These now report the caller's reason when the caller aborted, and OwnerCancellation.ownerClosed otherwise.
  • ReverseEngineeringService closed its active operations with controller.abort(). Each operation then reported a generic AbortError as its cancellation reason. Close now aborts with OwnerCancellation.ownerClosed.
  • DesktopBuildOwnedWork used an ad hoc new Error("REA is closing its build computers") as its close reason; it now uses the typed OwnerCancellation.ownerClosed.
  • AnalysisProviderRegistry rebuilt a departing caller's reason from options.signal?.reason after SharedStartupAttempt.wait reported cancelled. The wait result now carries reason, the departing caller's own reason, and the registry uses it.

Change and scope

  • Mechanical: new AnalysisCancelledError(op, { cause: s.reason, ...rest }) became cancelledBy(op, s, rest) wherever s is typed as an aborted or non-optional AbortSignal. Every other cause became carriedReason(x), which preserves the existing value exactly. A TypeScript-checker codemod did the rewrite; cause?: never in CancelledOptions made each options spread that still carried a cause fail to compile until it was fixed (DesktopBuildComputers.startFailure).
  • The shared isAborted(signal): signal is AbortedSignal from refactor(errors): require a reason for every analysis cancellation #10566 replaces 11 local isAborted/signalIsAborted copies in application files, and its narrowing lets a checked signal go straight to cancelledBy.
  • Deleted local cancellation helpers that cancelledBy supersedes: decompileAll's cancelled, SourceToBundleReference's cancelled, ProcessScenarioPreparation's cancelled/aborted, the reset closure in BinarySession, and Frida's rejectBeforeStart closure.
  • Abort-listener closures that only run after the caller's signal aborted, plus two branches reachable only after an abort, keep carriedReason(signal?.reason) with a comment. TypeScript cannot narrow a captured signal inside a listener.
  • AnalysisProviderRegistry uses the departing caller's reason that SharedStartupAttempt.wait now returns (refactor(errors): require a reason for every analysis cancellation #10566).
  • Not included: other directories (separate slices), the CLI SIGINT/SIGTERM controllers and BinarySession's prompt-completion abort() calls (no reason reaches a cancellation from them today), and W4b finalization.

Contract and boundary impact

  • Semantic owner and earliest changed stage: cancelledBy and isAborted in src/domain/analysisErrorCore.ts (from refactor(errors): require a reason for every analysis cancellation #10566); SharedStartupAttempt.wait now owns the departing caller's reason.
  • 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.
  • Generated metadata, package, or installation impact: none.

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

Evidence and regression coverage

  • Tests added or updated:
    • src/application/binary/BinarySessionInvestigation.test.ts: shutdown refusals without a caller abort now expect OwnerCancellation.ownerClosed. The test previously pinned cause to undefined, so it fails against the unmigrated code.
  • Remaining proof gaps: no new workflow test covers ReverseEngineeringService close or DesktopBuildOwnedWork close reasons; both are source-derived.

Validation performed

  • npm run check:fast — passed (typecheck, lint).
  • node scripts/verify/architecture-guards.mjs — passed; baseline 442 sites in 156 files, none under src/application/.
  • npm run test:focused -- the 90 test files beside the changed modules (src/application/**, matched by module name) plus src/process/SharedStartupAttempt.test.ts — 90 files passed; 1766 tests passed, 17 skipped.
  • npm run test:focused -- the 57 tests/ files that import a changed application module and assert on cancellation or cause — 57 passed; 1256 tests passed, 1 skipped.
  • npx oxfmt on changed files — formatted.
  • Merge with main (b0e3257), 2026-11-15: main (perf(mcp): run Kilo's read-only Git probes through execFileOutput's process group #10800) rewrote Kilo project-root discovery in McpRegistrationGit.ts onto execFileOutput, which supersedes this PR's edits to the old owned-command cleanup path there; resolved onto main's version and converted its two remaining direct cancellations to cancelledBy. npm run check:fast passed; node scripts/verify/architecture-guards.mjs --shrink-baselines, then the guard passed (stale McpRegistrationGit.ts bindCleanupDependencies entry lowered to 0); npm run test:focused -- src/application/McpRegistrationGit.test.ts src/application/binary/BinarySessionInvestigation.test.ts: 32 tests passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not exercised.
  • 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.

@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-15T10:30:21.137152Z d133ea7 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.

@morluto
morluto force-pushed the refactor/cancellation-reason-application branch from 478ca66 to 2e21450 Compare November 14, 2026 15:30
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable defects or rule violations were found.

Summary

Migrates application cancellation construction to cancelledBy, reuses isAborted, and removes the corresponding guard allowances.

  • Application operations now build cancellations through one reason-required path.
  • Shutdown refusals and stopped work now carry a typed owner-closed reason.
  • Provider selection reports the reason of the caller whose wait ended.

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

@morluto
morluto force-pushed the refactor/cancellation-reason-application branch from 2e21450 to e811803 Compare November 14, 2026 15:39
@morluto
morluto force-pushed the refactor/cancellation-reason-application branch from e811803 to 5f6bba1 Compare November 14, 2026 16:13
Base automatically changed from refactor/cancellation-owner to main November 14, 2026 20:20
…d reason

Migrate every AnalysisCancelledError construction under src/application
to cancelledBy and lower the guard baseline from 671 to 442.

Shutdown refusals in BinarySession report OwnerCancellation.ownerClosed
when the caller did not abort, instead of an undefined reason.
ReverseEngineeringService and DesktopBuildOwnedWork close their work
with the typed owner reason. SharedStartupAttempt returns the departing
caller's reason with a cancelled wait. One shared isAborted predicate
replaces eleven local copies and narrows a checked signal for
cancelledBy.
@morluto
morluto force-pushed the refactor/cancellation-reason-application branch from ba875a1 to 487ec71 Compare November 14, 2026 20:34
# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
…-reason-application

# Conflicts:
#	src/application/McpRegistrationGit.ts
…-reason-application

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
…-reason-application

# Conflicts:
#	src/application/EnhancedTools.ts
#	src/application/XrefsAddressResolution.ts
…-reason-application

# Conflicts:
#	src/application/DirectAnalysis.ts
#	src/application/Doctor.ts
#	src/application/binary/BinarySession.ts
#	src/application/reverse/ReverseEngineeringService.ts
…-reason-application

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
#	src/application/EvidenceBundleCommands.ts
…-reason-application

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
#	src/application/binary/AnalysisProviderEvaluation.ts
…-reason-application

# Conflicts:
#	src/application/process/ProcessCli.ts
@morluto
morluto merged commit 2826592 into main Nov 15, 2026
7 checks passed
@morluto
morluto deleted the refactor/cancellation-reason-application branch November 15, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant