Skip to content

refactor(captures): classify TShark, sigrok and pcap failures through the shared provider classifier - #10820

Merged
morluto merged 46 commits into
mainfrom
refactor/capture-classifier-dialect
Nov 15, 2026
Merged

morluto merged 46 commits into
mainfrom
refactor/capture-classifier-dialect

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Moves TShark (inspect_packet_fields), sigrok (inspect_signal_decoders) and the pcap provider onto the shared classifyProviderFailure owner. Each provider now supplies a dialect instead of a per-site classifier, and the existing cleanup report shapes are kept through the readCleanup hook added by the firmware slice (#10810, now folded into #10796). The rea/provider-failure-classifier baseline drops four entries: PcapProvider.ts 2 → 0, TsharkCaptureProvider.ts 1 → 0, SigrokRecordingProvider.ts 1 → 0.

Stacked on #10796 (which now carries #10810). Refs #10482 (W5c of the structural cleanup).

Problem and expected behavior

TsharkCaptureProvider#failure and SigrokRecordingProvider#failure were near-identical copies, and PcapProvider.analysisFailure and readToolIdentity were two more. Each one re-derived the same facts from unknown: is the cause typed, an owned command outcome, a cancelled read, or a read whose cleanup failed. Expected: the shared owner decides these facts once, and each provider supplies only its own meaning (budget refusals, phase-specific reports, configuration refusals).

Change and scope

  • ArtifactAnalysisResources (src/process): adds commandContext(...), the ProviderOutcomeContext that commandFailure already built (commandFailure now delegates to it), and readCleanupFailure(read, primary, capturedOutput, operation), which composes a given primary with the provider's lease-bound ProviderCleanupError. cleanupFailure computes its primary as before and delegates to it.
  • CleanupFailedRead moves to src/artifacts/ArtifactReader.ts so that src/process can name it without importing src/providers.
  • The classifier's cleanup-failed read primary now carries the dialect's observedOutput on a cancellation, as the resources' own primary did.
  • TShark/sigrok dialects: the discovery-budget refusal is in recognise; commands use the resources' command context; the phase-specific reports (workspace, integrity, configuration, changed read, output) are in unclassified, which the classifier reaches only after typed errors, commands, cleanup-failed reads and cancelled reads. Neither provider composed a command's own cleanup before, because the retained workspace reports it when the run finishes. commandCleanup keeps that and reports only the command's outcome.
  • pcap dialect: PcapConfigurationFailure becomes pcapToolUnavailable, and unrecognised causes become AnalysisProtocolError. readToolIdentity swaps in a tool-unavailable unclassified report and still rethrows a cancelled read for the request to report.

Not included: other providers (Ghidra, Hopper, IDA, Kuna, JEB, gdb, rizin, ADB, SQLite) follow as one PR each. The three remaining classifier copies inside ArtifactAnalysisResources are left for the SQLite/capture slice.

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 raw-failure classification. ArtifactAnalysisResources still owns its command context and cleanup composite.

  • CLI and MCP/tool-catalog contract: unchanged. One addition: a cancelled read without failed cleanup now keeps the reader's partial observation, as with every other shared-classifier provider. A raw launcher errno that reaches these catch sites outside OwnedCommandFailure now goes through the shared command classifier (launch-refused), not the phase report. The capture paths launch through runOwnedCommand, which reports OwnedCommandFailure, so this is source-derived and not observed.

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

  • Evidence, artifact, provenance, or reconstruction contract: unchanged.

  • Target selection, authority, upstream behavior, and cleanup details: cleanup ownership and lease binding are unchanged.

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

  • Read existing files or captured data.

  • Launch or attach to a process.

Evidence and regression coverage

  • No new test: this is a behavior-preserving move, and the existing boundary tests pin the reports.
  • Remaining proof gaps: tests/boundary/captures/captureDescriptorCleanup.test.ts, tests/boundary/captures/resourceLimits.test.ts and tests/boundary/pcap/pcapRetainedView.test.ts are Linux-only. They are skipped on the macOS host used here and run in CI. They are the cleanup-shape proof for the TShark/sigrok readCleanup path. No real TShark or sigrok run.

Validation performed

  • npm run check:fast: pass.
  • npm run test:focused -- tests/boundary/pcap/pcapCredentialErrors.test.ts tests/boundary/pcap/pcapProviderCrossPlatform.test.ts tests/boundary/captures/captureProvider.test.ts tests/boundary/pcap/pcapProviderCancellation.test.ts tests/boundary/captures/resourceLimits.test.ts tests/boundary/pcap/pcapRetainedView.test.ts tests/boundary/pcap/pcapProvider.test.ts tests/boundary/pcap/pcapCommand.test.ts tests/boundary/captures/captureDescriptorCleanup.test.ts tests/boundary/signals/recordingProvider.test.ts (macOS): 7 files passed, 3 skipped; 182 passed, 54 skipped.
  • npm run test:focused -- src/pcap/PcapNativeBound.test.ts src/process/ArtifactAnalysisResources.test.ts tests/boundary/process/artifactSelectedCommand.test.ts tests/process-global/stableArtifactConsumers.test.ts src/firmware/FirmwareDeadline.test.ts tests/process-global/firmwareFileLifetime.test.ts tests/boundary/firmware/firmwareReportFiles.test.ts src/evm/EvmoleFailures.test.ts src/wasm/WabtFailures.test.ts src/native/pwntools/PwntoolsFailures.test.ts tests/evaluation/providerFailureClassifierRule.test.ts: 11 files, 397 passed, 1 skipped.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none; Linux-only capture tests run in CI.
  • 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
…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.
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.
@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-15T10:31:17.957182Z 72f0ed9 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, with no actionable failure found.

Summary

Routes TShark, sigrok and pcap failures through classifyProviderFailure while keeping provider-specific reports and cleanup ownership.

  • TShark, sigrok, and pcap failures now use one shared classifier.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[TShark, sigrok or pcap failure] --> B[Shared failure classifier]
  B --> C{Failure kind}
  C -->|Already typed| D[Keep existing error]
  C -->|Owned command| E[Shared command report]
  C -->|Read cleanup failed| F[Classify read outcome]
  F --> G[Provider cleanup report with exact leases]
  C -->|Read cancelled| H[Cancellation with retained observations]
  C -->|Other| I[Provider-specific report]
Loading

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

…' into w5/ccd

# Conflicts:
#	src/pcap/PcapProvider.ts
#	src/process/ArtifactAnalysisResources.ts
#	src/signals/SigrokRecordingProvider.ts
@morluto
morluto changed the base branch from refactor/wabt-cancellation-owner to main November 15, 2026 09:42
# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
#	src/captures/TsharkCaptureProvider.ts
#	src/providers/classifyProviderFailure.ts
@morluto
morluto merged commit d61de7b into main Nov 15, 2026
7 checks passed
@morluto
morluto deleted the refactor/capture-classifier-dialect branch November 15, 2026 10:37
@morluto morluto added area: runtime Process capture and runtime observation provider: pcap Analysis provider / engine: pcap provider: tshark Analysis provider / engine: tshark labels 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 provider: pcap Analysis provider / engine: pcap provider: tshark Analysis provider / engine: tshark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant