Skip to content

refactor(providers): classify raw provider failures through one owner - #10757

Merged
morluto merged 39 commits into
mainfrom
refactor/provider-failure-classifier
Nov 15, 2026
Merged

morluto merged 39 commits into
mainfrom
refactor/provider-failure-classifier

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds one owner for turning a raw provider failure into a typed AnalysisError: classifyProviderFailure(cause, dialect) in src/providers/classifyProviderFailure.ts. A provider now supplies a dialect (its own typed refusals, command settings, the file it read and what it reports for an unrecognised cause) instead of writing a (cause: unknown) => AnalysisError classifier. EVMole and WABT are converted to show the shape; their per-site classifiers are deleted and the rea/provider-failure-classifier baseline drops from 107 to 104.

Stacked on #10634 (which now carries #10716, #10727 and #10724). Refs #10482 (W5c of the structural cleanup).

Problem and expected behavior

Every provider re-derived the same facts from unknown: is this already typed, an owned command outcome, a cancelled or changed file read, an errno that names the selected path, or something else. Each copy made slightly different choices. For example, EVMole treated EISDIR, ENOTFILE and ESTALE on the selected carrier as a provider adapter failure, while the shared selected-file projection treats them as invalid input. Expected: one classifier decides these shared facts, and the provider decides only its own meaning.

Change and scope

classifyProviderFailure works through the cause in this order:

  1. Typed AnalysisError values pass through unchanged.
  2. Owned command outcomes (providerOutcomeOf) go to classifyProviderOutcome with the provider's command context. If command cleanup failed, commandCleanup builds the report. When a provider gives no commandCleanup, the primary failure is composed with a ProviderCleanupError.
  3. The provider's recognise hook checks provider-owned typed failures.
  4. Failures reading the selected file use the shared projections. Cancellation becomes AnalysisCancelledError, integrity becomes AnalysisArtifactChangedError, the file-size limit goes to the provider's fileSize, path and format rejections use stableArtifactInputFailure, and errno values use projectSelectedArtifactFileFailure.
  5. Anything else reaches the provider's unclassified report. W5d will replace this with UnclassifiedProviderFailure carrying the examined outcome.

Every result keeps the read's unresolved cleanup (passed to each constructor as details) and its bound cleanup leases. When the provider asks for it, the result also keeps the completed read's byte identity (retainCompletedIdentity).

Supporting changes:

  • projectSelectedArtifactFileFailure and stableArtifactInputFailure accept a request-path field (for example ["candidate_paths", 2]) and extra error options.
  • The lint baseline JSON now has owners (exempt from the rule) and counts (a list that can only shrink). The rule message points to classifyProviderFailure.
  • docs/development/tool-design.md describes the owner.
  • EVMole: evmInterfaceFailure is replaced by evmFailureDialect. The provider's duplicate lease binding and snapshot-identity code after classification is removed, because the owner now does both.
  • WABT: wabtFailure and classifyWabtFailure are replaced by wabtFailureDialect.

Not included: the other providers. They follow as one PR each, in this order: pwntools, firmware, TShark/sigrok, Ghidra, Hopper, IDA, Kuna, JEB, gdb, rizin, ADB, SQLite/capture. Also not included: replacing the spawn prefix checks with launcherRefusalOf, which lands with pwntools and EVMole's remaining sites, and W5d.

Error categories that changed, all for selected-file reads:

  • EVMole carrier read with EISDIR, ENOTFILE or ESTALE: was ProviderAdapterError, now AnalysisInputError (invalid_value, "Selected bytecode carrier could not be read (EISDIR): ."), matching the shared selected-file set.
  • WABT artifact read with reader path or format rejection: the issue reason was invalid_value, now invalid_format, the same as every other stableArtifactInputFailure caller.
  • WABT artifact read with ENOENT, ENOTDIR, ELOOP and similar errno values: the issue message is now the shared "Selected WebAssembly input could not be read (): ." instead of the raw errno text.

Contribution scope: ordinary refactor within existing boundaries; no maintainer scope decision is needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: classifyProviderFailure owns the mapping from raw failure to typed error; classifyProviderOutcome still owns command outcomes, and StableArtifactFailure still owns the file projections. The per-site EVMole and WABT classifiers are removed.

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

  • CLI and MCP/tool-catalog contract: schemas are unchanged. Error categories change only as listed above.

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

  • Evidence, artifact, provenance, or reconstruction contract: unchanged. Cleanup observations, leases, captured output and completed snapshot identity stay on the reported error.

  • Target selection, authority, upstream behavior, and cleanup details: cleanup ownership is unchanged; binding moved into the owner.

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

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: src/evm/EvmoleFailures.test.ts adds a test that a carrier read failing with EISDIR is reported as invalid input. EVMole and WABT tests now call the provider dialect through classifyProviderFailure. tests/evaluation/providerFailureClassifierRule.test.ts covers the owner exemption and checks that owner files exist.
  • Base reproduction or other evidence: source-derived. On the base, artifactSelectedPathErrno does not include EISDIR, so the new EVMole test would fall through to ProviderAdapterError. The test was not run against the base, because the base has no evmFailureDialect export.
  • Remaining proof gaps: no real-provider run. WABT and EVMole coverage uses the existing simulated tools and boundary workflows.

Validation performed

  • npm run check:fast: typecheck and lint pass, including module-layer boundaries. A first attempt that placed the owner in src/process failed the process -> artifacts upward-import baseline; the owner was moved to src/providers.
  • npm run test:local -- src/evm/EvmoleFailures.test.ts src/evm/EvmoleInterfaceProvider.test.ts src/wasm/WabtFailures.test.ts src/wasm/WabtRuntime.test.ts src/wasm/WabtArtifactProvider.test.ts tests/evaluation/providerFailureClassifierRule.test.ts: 6 files, 118 tests passed.
  • npm run test:focused -- tests/boundary/filesystem/wabtEnvironment.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts tests/boundary/mcp/evmLimiterAvailability.test.ts tests/boundary/mcp/evmInterfaceMcp.test.ts tests/boundary/cli/wasmAcquiredInputsCli.test.ts tests/boundary/cli/wasmLateCancellationCli.test.ts: 30 passed, 1 skipped.
  • Shepherd follow-up (cancelledBy for the shared read cancellation, parent merged): architecture guards pass; npm run check:fast pass; npm run test:focused on EvmoleFailures, evmoleInterfaceProvider, wabtEnvironment, providerFailureClassifierRule and cancellationCauseLint tests 55 passed, 36 skipped. Pushed with --no-verify (hooks resolve the rejected default Node 25); check:fast was run by hand.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Only the error categories listed above change.
  • Real Hopper/Ghidra, browser, or OS coverage: none needed; no real-provider run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process or file authority.

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
@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-15T07:17:02.193907Z 7d347dc 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 PR appears safe to merge, with WABT’s deferred cancellation cleanup covered by dependent PR #10796.

Summary

Adds classifyProviderFailure as the shared owner for raw provider failures and moves EVMole, WABT, and pwntools onto provider dialects.

  • Provider failures now pass through one shared classifier.
  • EVMole reports selected carrier read failures through shared rules.
  • WABT reports selected artifact read failures through shared rules.
  • Pwntools decoder and debugger failures use a shared path with custom reports.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Raw["Raw provider failure"] --> Typed{"Already AnalysisError?"}
  Typed -->|Yes| Pass["Return unchanged"]
  Typed -->|No| Command{"Command outcome?"}
  Command -->|Yes| Outcome["classifyProviderOutcome"]
  Outcome --> Cleanup["Provider cleanup report when needed"]
  Command -->|No| Recognise["Provider recognise hook"]
  Recognise --> File["Shared selected-file projections"]
  File --> Fallback["Provider unclassified report"]
  Recognise --> Retain["Retain file identity and cleanup leases"]
  File --> Retain
  Fallback --> Retain
Loading

Reviews (7) · Last reviewed commit: "Merge origin/main into refactor/provider..." · Reviewed by Greptile

…rror that claims it

SQLite and historical-capture memory errors recognised a streamed V8 heap report but dropped it, so a report outside retained output reached callers without its source line or omission flags. One projection, runtimeExhaustionReport, now owns that shape for the shared classifier and both consumers. Also lowers the EVMole and WABT cancellation-constructor baselines.
…-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.
@morluto
morluto changed the base branch from fix/streaming-runtime-exhaustion to main November 15, 2026 07:11
@morluto
morluto merged commit 6a4caa0 into main Nov 15, 2026
54 checks passed
@morluto
morluto deleted the refactor/provider-failure-classifier branch November 15, 2026 08:28
morluto added a commit that referenced this pull request Nov 15, 2026
Plastic-time added a commit to Plastic-time/rea that referenced this pull request Nov 15, 2026
…ailure

Main now rejects new per-site failure classifiers (morluto#10757) and verifier
temp roots outside VerifierFixture.

- The provider passes a dialect to classifyProviderFailure: the parser's
  budget and format refusals, the file-size recovery, and the read
  cleanup. A nested read keeps its physical primary under one cleanup
  envelope, as the shared PE projection did.
- scripts/verify-pe-rich-header.mjs allocates its scratch root with
  VerifierFixture.
@morluto morluto added the area: providers Provider and capability discovery, including provider proposal triage label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant