Skip to content

refactor(wasm): leave WABT cancellation to the shared owners - #10796

Merged
morluto merged 42 commits into
mainfrom
refactor/wabt-cancellation-owner
Nov 15, 2026
Merged

morluto merged 42 commits into
mainfrom
refactor/wabt-cancellation-owner

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

WABT no longer makes up its own cancellations. The failure dialect matched any Error named AbortError as a cancellation. The provider built two AnalysisCancelledErrors by hand. The dialect branch is removed: no WABT path produces a raw AbortError, and the shared owners already classify the cancellations that do happen. The provider's two caller-signal checks now use cancelledBy. Part of plan W5c. Stacked on #10757 (which now carries #10782).

This branch now also carries #10810 (firmware through the shared classifier: firmware producers throw their own deadline timeout, plus the classifier's interruption and readCleanup hooks). See #10810 for its description and validation.

Problem and expected behavior

wabtFailureDialect's recognise hook reported unknownCause.name === "AbortError" as a cancellation. That is a second, name-based reading of cancellation, separate from the owners:

  • Selected-file reads, tool reads and command-path checks report an abort as ArtifactReaderFailure("cancelled") (assertArtifactReadActive, the reader itself). classifyProviderFailure turns that into a cancellation carrying the reader's recorded reason, in every phase.
  • Owned WABT commands report cancellation as OwnedCommandFailure with a recorded cancellation. classifyProviderOutcome classifies it.

src/process/ProcessInspectionCancellation.ts already records the rule: an error's name does not establish where a cancellation came from. Expected behaviour: WABT supplies no cancellation logic of its own, and its two direct caller-signal checks use the shared constructor.

Change and scope

  • src/wasm/WabtFailures.ts: removed the AbortError branch and the AnalysisCancelledError import.
  • src/wasm/WabtArtifactProvider.ts: the pre-start check and the post-release check use isAborted(signal) and cancelledBy(OPERATION, signal, …). The post-release check still keeps its partialObservation. The precedence with analysisErrorWithCancellation is unchanged.
  • Baseline: the analysis-cancelled-constructor entries for src/wasm/WabtFailures.ts (1) and src/wasm/WabtArtifactProvider.ts (2) are removed, so both are now 0.

Category changes: none for any failure a WABT path produces. A hypothetical raw AbortError reaching the dialect would now go to WABT's unclassified report, like any other unrecognised cause, and no longer become a cancellation. No producer of one exists.

Not included:

  • The provider's closing check (ArtifactReaderFailure("unavailable") without cleanup becomes "Provider is closing") and resourceCleanupFailure. Both are lifecycle reports outside raw-failure classification.
  • The range-error-interpretation baseline entry for the allocation-refusal check.
  • Other providers.

Contribution scope: refactor within existing boundaries; maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: classifyProviderFailure (file and reader cancellations) and classifyProviderOutcome (command cancellations) own cancellation. cancelledBy builds the provider's two signal-check cancellations. No superseded path remains in WABT.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: none.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none. The partial observation on a late cancellation is preserved.

  • Target selection, authority, upstream behavior, and cleanup details: none.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/wasm/WabtFailures.test.ts gains a case for each phase (configuration, artifact, producer). A cancelled read classifies as AnalysisCancelledError, its cause is the caller's reason, and it carries the earlier command output. This shows the shared owner covers every phase without the removed branch.

  • Base reproduction or other evidence: this is a refactor, not a fix. The new case also passes on the base, because the shared owner already handled reader cancellation. The existing late-cancellation CLI and MCP tests cover the provider's signal checks.

  • Remaining proof gaps: no real WABT installation was exercised.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check:fast (Node 24.22.1): pass
  • node scripts/verify/architecture-guards.mjs --shrink-baselines: passed and removed the two WABT entries
  • npm run test:focused -- src/wasm/WabtFailures.test.ts src/wasm/WabtArtifactProvider.test.ts tests/boundary/cli/wasmLateCancellationCli.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts src/application/wasm/WasmArtifactService.test.ts tests/evaluation/providerFailureClassifierRule.test.ts: 170 passed
  • Pushed with the pre-push hook (check:fast) on Node 24.22.1.
  • Review follow-up (73d31fd): the private snapshot write now turns Node's abort envelope that carries its own signal's reason into cancelledBy. The new test "reports a snapshot write the caller cancelled as that caller's cancellation" failed on the previous commit (AnalysisOutputError). npm run test:focused -- src/wasm/WabtArtifactProvider.test.ts src/wasm/WabtFailures.test.ts src/wasm/WabtRuntime.test.ts: 87 passed; npm run check:fast: pass.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none (macOS host only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no process, authority or cleanup change.

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.

When a capture read's tool launch was refused with EPERM, pcap reported it
as unreadable tool output (AnalysisProtocolError) instead of an unavailable
tool. Pcap also never told "not executable" apart from "missing".

Add classifyLaunchFailure in src/process as the one owner of which spawn
errnos mean missing (ENOENT, ENOTDIR) and which mean present but not
executable (EACCES, EPERM, ENOEXEC, EISDIR). Pcap, apktool and gdb used three
different errno lists; all three now use it.
Add ProviderOutcome, read once from the supervisor's facts, and classifyProviderOutcome, the one mapping from an outcome to a typed error. Migrate pcap and the shared artifact producer command failure (TShark, sigrok). Add the rea/provider-failure-classifier lint rule with a shrink-only baseline of per-site (cause: unknown) => AnalysisError functions.
…red owner (#10598)

The Ghidra and JADX Java probes and adb's version probe now take
missing-versus-not-executable from classifyLaunchFailure instead of their
own errno checks. ELOOP and ENAMETOOLONG join the owner's missing set, so
adb keeps its existing classification and both Java probes now treat a
non-directory path component as a missing runtime.
Add ProviderOutcome, read once from the supervisor's facts, and classifyProviderOutcome, the one mapping from an outcome to a typed error. Migrate pcap and the shared artifact producer command failure (TShark, sigrok). Add the rea/provider-failure-classifier lint rule with a shrink-only baseline of per-site (cause: unknown) => AnalysisError functions.
…nto HEAD

# Conflicts:
#	src/pcap/PcapCommand.ts
… a target refusal

The supervisor now watches for a managed runtime's out-of-memory report while output streams (JVM java.lang.OutOfMemoryError, V8 'JavaScript heap out of memory'), so a retention budget cannot hide it. ProviderOutcome gains a runtime-exhausted kind and classifyProviderOutcome maps it once. Apktool decode opts in and moves to the shared classifier; Ghidra's single-purpose output token becomes the JVM runtime option and its area matching reuses the shared table.
…HEAD

# Conflicts:
#	src/pcap/PcapCommand.ts
#	tests/evaluation/providerFailureClassifierRule.test.ts
…nto refactor/provider-outcome

# Conflicts:
#	src/pcap/PcapCommand.ts
Name the executable on errnos Node throws synchronously from spawn
(ENOEXEC, ENOTDIR, ...) and read the Windows native launcher's
executable-launch constraint, so pcap attributes those refusals to the
selected tool or limiter instead of an unknown stage.
…nto w5/provider-outcome

# Conflicts:
#	src/pcap/PcapCommand.ts
…t retained stderr (#10724)

The SQLite worker and the Node capture decoders now declare runtime: "v8", so the supervisor observes V8's heap report as output streams. Both classifiers read the runtime-exhausted outcome instead of matching retained stderr, so a report beyond the retention budget, or one whose process then overflowed its output budget, is still reported as memory exhaustion.
# Conflicts:
#	.oxlintrc.json
#	scripts/lint/index.mjs
#	src/pcap/PcapCommand.ts
…vider classifier (#10716)

* refactor(evm): classify EVMole worker outcomes through the shared provider classifier

The EVMole worker's cancellation, deadline, output budget and CPU/file-size signals now go through classifyProviderOutcome; only the prlimit launch refusal and the reserved EFBIG exit remain in its dialect. The worker is opted into V8 exhaustion scanning so a heap report names its fixed 256 MiB heap. providerOutcomeOf now reads a launch refusal only from a spawn errno, so a private-storage or carrier read errno is no longer reported as a limiter launch failure.

* fix(evm): keep a stream failure's exit status and update Linux worker expectations

* refactor(process): read launch refusals through the launcher identity owner

* refactor(wasm): classify WABT command outcomes through the shared provider classifier (#10727)

* refactor(wasm): classify WABT command outcomes through the shared provider classifier

WABT's cancellation, command deadline, output budget, and inherited-limit signals now go through classifyProviderOutcome; its dialect keeps only the configuration-probe and launch-refusal unavailability and the unclassified-exit output error. A tool ended by SIGXCPU/SIGXFSZ or the memory limit is now a resource constraint instead of an output error, and a refused launch in the producer phase is reported as unavailable. The shared timeout context gains the analysis setting that selected the deadline, and the output-limit context may name its exceeded budget.

* fix(wasm): keep setup guidance when a WABT version probe's output cannot be collected
…w5-10634

# Conflicts:
#	src/apktool/ApktoolProvider.ts
#	src/ghidra/GhidraDiagnostics.ts
…-classifier; build the shared read cancellation with cancelledBy
…tion report

The shared classifier replaced the provider-supplied recovery with generic capacity advice whenever the JVM reported it could not create a native thread, dropping Apktool's launcher guidance and flipping retryable to true. The provider's recovery now wins; the capacity advice remains the fallback for providers that supply none.
…vider classifier (#10782)

* refactor(pwntools): classify pwntools failures through the shared provider classifier

pwntools' per-site classifier is replaced by pwntoolsFailureDialect for classifyProviderFailure. Command outcomes go through classifyProviderOutcome, launch refusals through launcherRefusalOf instead of a 'spawn ' syscall prefix check, the input limit through the file dialect's fileSize, and the cleanup report through commandCleanup. The shared read cancellation now carries the reader's partial observation, and resource-signal reports accept provider detail.

* fix(pwntools): report a failed command's output once and expect resource_constraint for overflow

The shared outcome owner already attaches the command's output as capturedOutput, so the pwntools adapter fallback no longer copies the same text into diagnostics.stdout, diagnostics.stderr and diagnostics.captured_output; diagnostics keep the exit facts. Update the overflow expectations the dialect migration missed (layout provider cleanup and over-budget rows, pwntools cleanup) to resource_constraint.
WabtFailures matched any Error named AbortError as a cancellation. No WABT path produces one: reads, path checks and owned commands report cancellation as ArtifactReaderFailure or OwnedCommandFailure, which classifyProviderFailure and classifyProviderOutcome already classify with the caller's reason. The provider's two signal checks now build the cancellation with cancelledBy. Lowers the AnalysisCancelledError constructor baseline for both WABT files to zero.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T09:27:24.275593Z 1aa6fba 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 15, 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 blocking issue was found.

Summary

WABT now leaves cancellation classification to shared owners. Firmware also uses the shared classifier, with phase-owned timeouts and its existing cleanup reports.

  • Firmware phases report failures through the shared classifier.
  • WABT cancellation reports come from signals and command owners.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Provider failure] --> B{Already an AnalysisError?}
  B -->|Yes| C[Keep typed error]
  B -->|No| D{Owned command outcome?}
  D -->|Yes| E[classifyProviderOutcome]
  D -->|No| F{Read cleanup failed?}
  F -->|Yes, firmware| G[Keep primary and bind cleanup owners]
  F -->|No| H{Read cancelled?}
  H -->|Phase deadline| I[Phase timeout]
  H -->|Caller abort| J[Caller cancellation]
  H -->|No| K[Provider dialect or unclassified report]
Loading

Reviews (3) · Last reviewed commit: "Merge origin/main into refactor/wabt-can..." · Reviewed by Greptile

Comment thread src/wasm/WabtFailures.ts Resolved
…tion

The private snapshot write passed the caller's signal to Node's writeFile, whose abort envelope reached the dialect's unclassified output failure once the name-based AbortError guess was removed. The write now turns the envelope carrying its own signal's reason into cancelledBy at the producer.
…vider classifier (#10810)

Firmware producers now report their own deadline expiry: the start check, the output inventory and launcher admission throw the phase timeout where they observe the abort, and a read the phase signal cancelled reports it through the dialect's interruption. The classifier no longer rereads a cancellation's reason as a timeout. A new readCleanup hook keeps firmware's cleanup report shape.
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Merged origin/main (at 9a3a703) after #10757 landed, as a merge commit so the stacked children keep their bases. The merge tree is the branch's three commits rebased onto main, without #10757's pre-squash commits. Conflicts resolved: WABT imports (main's cancelledBy list plus isAborted), the WABT dialect's AbortError branch (removed, per this PR), and firmware's firmwareSignalInterruption (this branch's signal-based form). Counted baselines were lowered with --shrink-baselines. Ran: npm run check:fast (pass), node scripts/verify/architecture-guards.mjs (pass), and focused tests for src/wasm/src/firmware units, WasmArtifactService, firmware boundary suites and wasmArtifactMcp (13 files run, 242 passed, 54 skipped on macOS).

@morluto
morluto merged commit b87b318 into main Nov 15, 2026
8 checks passed
@morluto
morluto deleted the refactor/wabt-cancellation-owner branch November 15, 2026 09:42
@morluto morluto added provider: wabt Analysis provider / engine: wabt area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior provider: wabt Analysis provider / engine: wabt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant