Skip to content

refactor(jeb): classify JEB failures through the shared provider classifier - #10831

Merged
morluto merged 51 commits into
mainfrom
refactor/jeb-provider-classifier
Nov 15, 2026
Merged

morluto merged 51 commits into
mainfrom
refactor/jeb-provider-classifier

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Moves JEB onto the shared classifyProviderFailure owner and folds JebMcpDeadline's reason comparison onto the producer-reports-its-own-interruption pattern accepted for firmware (#10810). A JEB refusal that carries the JVM's own java.lang.OutOfMemoryError report now becomes a resource constraint instead of execution_failure. The rea/provider-failure-classifier baseline drops src/jeb/JebProvider.ts (1 → 0).

Stacked on #10820. Refs #10482 (W5c of the structural cleanup).

Problem and expected behavior

  • JebProvider#providerFailure(operation, cause: unknown) re-derived every raw failure kind itself (ZodError, physical MCP failure, cleanup composite, cancellation, timeout).
  • JebMcpDeadline.failure() re-read the startup deadline's state after the fact. requestFailure decided whether a cancellation was the caller's by comparing failure.cause === signal.reason.
  • JEB is JVM-hosted, but a heap exhaustion it reported came back as execution_failure with no memory recovery (audit finding 4: "Apktool and JEB have no JVM matcher").

Expected: raw classification goes through the shared owner. Each MCP phase deadline reports its own timeout or cancellation when it aborts, and decides whose cancellation it was from the caller's own signal. JVM exhaustion is read with the shared JVM marker.

Change and scope

  • JebMcpDeadline takes the selected timeout, phase, phase operation and the { caller, owner } signals. When it aborts, it records its report: a timeout (with the existing jeb.mcp_timeout_ms guidance) when the budget elapsed, otherwise a cancellation. It records cancelledBy: "caller" | "owner" from whether the caller's own signal aborted. interruption(rejection: SdkError) maps its own abort token, or the SDK's request timeout, back to that report. SDK 2.3.1 only keeps an SdkError abort reason by identity, so the token stays.
  • JebMcpConnection.requestFailure no longer compares abort reasons: a cancellation by the caller, or by closing, leaves the connection alone; anything else invalidates it, as before.
  • JebProvider: a #dialect(operation) gives the shared classifier JEB's ZodError → AnalysisProtocolError and the unreachable-endpoint report. A typed #attributed(operation, failure: AnalysisError) step reports a shared phase's failure (catalog discovery, tools/call) under the REA operation and endpoint, and keeps the phase's cleanup ownership and the JebMcpCleanupFailure composite.
  • parseJebEnvelope: a refusal whose error.message or message contains RUNTIME_EXHAUSTION_TOKENS.jvm becomes AnalysisResourceConstraintError. It is memory, or capacity for native-thread exhaustion, and the area comes from the shared jvmExhaustionArea. Recovery follows the reported area: -Xmx for heap and GC overhead, -XX:MaxMetaspaceSize for metaspace, a smaller input for an oversized array, and thread limits for native-thread exhaustion. The envelope stays in diagnostics.upstream_response, and diagnostics.jvm_exhaustion_area is added.
  • Docs: docs/providers/jeb-analysis.md records the exhaustion case beside the existing refusal semantics.

Not included:

  • No JEB remote-code table. The repository documents no real JEB refusal codes; the fixture codes (ENGINE_NOT_READY, PROJECT_BUSY, INVALID_ITEM) are invented. The provider doc says REA does not infer meaning from refusals, so a table would be speculative.
  • Transport-level JSON-RPC errors that might carry an OOM are not inspected.
  • Other providers follow as one PR each.

Contribution scope: ordinary refactor within existing boundaries plus one classification addition the plan names (W5c/finding 4). No new authority.

Contract and boundary impact

  • Semantic owner and earliest changed stage: classifyProviderFailure owns raw-failure classification. JebMcpDeadline owns its phase's interruption report.
  • CLI and MCP/tool-catalog contract: one visible change. A JEB refusal carrying java.lang.OutOfMemoryError returns the resource-constraint error code with details.resource: "memory" (or "capacity"), details.diagnostics.jvm_exhaustion_area ("heap", "native-thread", …, or null) and the area's recovery, instead of execution_failure. All other JEB reports are unchanged; the existing JEB boundary tests pass unmodified.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged; the envelope and inputs are retained as before.
  • Target selection, authority, upstream behavior, and cleanup details: connection invalidation rules and cleanup ownership are unchanged.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • tests/boundary/providers/jeb/failureEnvelopes.test.ts: new public MCP workflow cases, run against a real HTTP producer with both envelope encodings. They cover heap, metaspace, array-size, an unnamed area and native-thread exhaustion. Each asserts resource_constraint and its area's recovery. Verified failing without the provider change: 6 failed, 8 passed. The existing refusal cases now share one harness helper.
  • Remaining proof gaps: source-derived only. No real JEB engine was run, and whether JEB's MCP server reports an OutOfMemoryError in a refusal envelope has not been observed.

Validation performed

  • npm run check:fast: pass.
  • npm run test:local -- src/jeb/JebMcpConnection.test.ts src/jeb/JebMcpEndpoint.test.ts src/jeb/JebProvider.test.ts: 3 files, 66 passed.
  • npm run test:focused -- tests/boundary/providers/jebMcpCleanup.test.ts tests/boundary/providers/jebMcpReplies.test.ts tests/boundary/providers/jebFixtureCompletion.test.ts tests/boundary/providers/jebMcpTimeout.test.ts tests/boundary/providers/jebMcpCatalog.test.ts tests/boundary/providers/jebMcpConnection.test.ts tests/boundary/providers/jeb/failureEnvelopes.test.ts tests/boundary/mcp/jebMcp.test.ts tests/boundary/cli/jebCli.test.ts tests/boundary/providers/mcpHttpUtf8.test.ts: 10 files, 86 passed (before the new cases); failureEnvelopes.test.ts with the new cases: 18 passed.
  • npm run test:focused -- tests/evaluation/providerFailureClassifierRule.test.ts: 12 passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none; no real JEB.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process, network 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
…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.
…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.
… the shared provider classifier

TsharkCaptureProvider and SigrokRecordingProvider replace #failure with a dialect, and PcapProvider replaces analysisFailure and the tool-identity classifier. ArtifactAnalysisResources exposes its command context and a readCleanupFailure composer so the readCleanup hook keeps each provider's cleanup report shape.
…sifier

JEB's raw MCP failures go through classifyProviderFailure with a JEB dialect;
a typed attribution step reports a shared phase's failure under the REA
operation. Each MCP phase deadline now reports its own interruption when it
aborts, deciding a cancellation's owner from the caller's own signal instead
of comparing abort reasons. A refusal carrying the JVM's OutOfMemoryError
report becomes a resource constraint naming JEB's Java heap.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T11:21:16.987404Z
We couldn’t complete this review. Comment @codex review to try again.
488d9a3 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8326873292

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/jeb/JebProvider.ts Resolved
@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, with no actionable defect established.

Summary

Routes JEB failures through classifyProviderFailure, records each MCP phase’s interruption when it happens, and reports JVM exhaustion refusals as resource constraints.

  • JEB refusals with JVM exhaustion return resource errors.
  • JEB MCP failures keep their phase’s timeout or cancellation.
  • Ghidra startup reports its own deadline outcome.
  • Ghidra extension reads use shared failure rules.
  • Hopper source checks keep their existing failure details.
  • Kuna project exports use shared failure rules.
  • Kuna session calls use shared failure rules.
  • Kuna workspace copies use shared failure rules.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI or MCP request] --> B[JEB MCP phase]
  B --> C[Raw failure or recorded interruption]
  C --> D[classifyProviderFailure]
  D --> E[Attribute operation and endpoint]
  E --> F[Typed failure with cleanup ownership]
  B --> G[Decoded refusal]
  G --> H{JVM exhaustion report?}
  H -->|Yes| I[Resource constraint and recovery advice]
  H -->|No| J[Execution failure]
Loading

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

…r classifier (#10836)

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

PSP extension inspection reports through classifyProviderFailure with a
Ghidra dialect. The startup deadline decides at abort time whether the shared
startup owner closed it, so Ghidra and Hopper no longer compare the abort
reason with the owner's sentinel, and Ghidra's startup no longer compares a
producer cancellation's reason with the deadline's. Three helpers that only
construct one error kind now name that kind instead of AnalysisError.

* refactor(hopper): classify original-source read failures through the shared provider classifier (#10838)

* test(ghidra): pin the aborted startup deadline over a producer cancellation

* refactor(kuna): classify Kuna failures through the shared provider classifier (#10843)

Session operations, the workspace copy and the project export report raw
failures through classifyProviderFailure with Kuna dialects; the copy and
export keep their cleanup report shapes through the readCleanup hook.
…' into w5/ccd

# Conflicts:
#	src/pcap/PcapProvider.ts
#	src/process/ArtifactAnalysisResources.ts
#	src/signals/SigrokRecordingProvider.ts
# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
#	src/captures/TsharkCaptureProvider.ts
#	src/providers/classifyProviderFailure.ts
@morluto
morluto changed the base branch from refactor/capture-classifier-dialect to main November 15, 2026 10:37
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Merged the final #10820 head (72f0ed9) and then current main into this branch. Conflicts: GhidraClient and HopperClient took main's OwnerCancellation.startupOwnerClosed / AbortedWait; this branch's ProviderStartupDeadline.ownerClosed / STARTUP_OWNER_CLOSED is superseded by main's owner-cancellation reason (equivalent: a timeout aborts the signal first, so a later owner close cannot replace its reason), and the Ghidra regression for owner close vs timeout now aborts with OwnerCancellation.startupOwnerClosed. Validation: check:fast passes and the architecture guards pass with main's duplicate advertisedOutputJsonSchema declaration (from #11005, being fixed separately) removed locally; ProviderDeadline, EVMole, WABT and ArtifactAnalysisResources tests (91) and tests/boundary/providers/ghidra/ghidraClient.test.ts (109) pass. Pushed with --no-verify only because main itself does not typecheck at 08420be.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto merged commit 607a787 into main Nov 15, 2026
8 checks passed
@morluto
morluto deleted the refactor/jeb-provider-classifier branch November 15, 2026 11:37
@morluto morluto added area: providers Provider and capability discovery, including provider proposal triage provider: jeb Analysis provider / engine: jeb labels 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 provider: jeb Analysis provider / engine: jeb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant