Repository navigation
fix(pcap): report workspace allocation failures by their system cause - #6229
Conversation
Pcap workspace allocation and snapshot writes mapped every filesystem error, including ENOTDIR and EACCES from mkdtemp, to a file-size resource constraint with null limits and worker file-size advice. Flutter's owned snapshot storage had the same errno-blind mapping, while TShark and sigrok carried duplicate copies of the correct split. Move the private-workspace failure projection into one shared owner: ENOSPC/EDQUOT/EFBIG stay file-size resource constraints with their system code and path; descriptor exhaustion and every other failure become provider workspace failures carrying stage, workspace path, failing path, system code and cause-specific recovery. Fixes #6123 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge, with a non-blocking Windows test matcher issue. Findings
Fix with agent prompt### Issue 1
tests/boundary/filesystem/flutterBuildProvider.test.ts:327
The new matcher requires `/` before `rea-flutter-`, but Windows workspace paths use `\`. Running this suite on Windows now fails all seven cases after workspace allocation, even when the provider returns the correct location. Accept either separator, or compare the final directory name with `basename`.
```suggestion
: (expect.stringMatching(/[\\/]rea-flutter-[^\\/]+$/u) as unknown);
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR puts workspace failure reporting in one shared helper.
No new security issue was established. GitHub status and possible replacement PRs could not be checked because GitHub authentication was unavailable. Tests were not run during this review. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Workspace allocation or file error] --> B[privateWorkspaceFailure]
B --> C{System code}
C -->|ENOSPC or EDQUOT| D[File-size constraint with storage advice]
C -->|EFBIG| E[File-size constraint with file-size advice]
C -->|Other| F[Provider failure with workspace details]
G[Flutter package error] --> H[execute catch with snapshot root]
H --> B
Reviews (2) · Last reviewed commit: "fix(flutter): locate owned storage failu..." · Reviewed by Greptile |
mapOwnedIoFailure always passed a null workspace path, so a descriptor write or read failure without its own errno path lost every location. Thread the owned root through: allocation keeps null (no workspace yet), snapshot failures use the allocated root, and package-reader system errors propagate to the request owner, which maps them against the snapshot root instead of mapping early without it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| const workspace = | ||
| stage === "root" | ||
| ? null | ||
| : (expect.stringMatching(/\/rea-flutter-[^/]+$/u) as unknown); |
There was a problem hiding this comment.
Windows tests reject correct paths
The new matcher requires / before rea-flutter-, but Windows workspace paths use \. Running this suite on Windows now fails all seven cases after workspace allocation, even when the provider returns the correct location. Accept either separator, or compare the final directory name with basename.
| : (expect.stringMatching(/\/rea-flutter-[^/]+$/u) as unknown); | |
| : (expect.stringMatching(/[\\/]rea-flutter-[^\\/]+$/u) as unknown); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/filesystem/flutterBuildProvider.test.ts
Line: 327
Comment:
**Windows tests reject correct paths**
The new matcher requires `/` before `rea-flutter-`, but Windows workspace paths use `\`. Running this suite on Windows now fails all seven cases after workspace allocation, even when the provider returns the correct location. Accept either separator, or compare the final directory name with `basename`.
```suggestion
: (expect.stringMatching(/[\\/]rea-flutter-[^\\/]+$/u) as unknown);
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Resolve import conflicts with main's retained-result validation helper (b8c1b45) and workspace-failure mapping (morluto#6229): pcapCaptureView keeps the historical-Evidence compatibility schema (pcapEvidenceSchemas) and parses it through main's parseAnalysisViewResult; TsharkCaptureProvider keeps both the shared Wireshark identity imports and privateWorkspaceFailure.
What broke:
inspect_pcap_capturereported any failure to allocate or write its private workspace, including realENOTDIR/EACCESfrommkdtemp, asresource_constraint/resource: "file-size"withreported_limits: nulland worker file-size advice. The errno and failing path were lost. Flutter's owned snapshot storage had the same errno-blind mapping.Fix: One shared owner,
src/process/privateWorkspaceFailure.ts, classifies private-workspace filesystem failures.ENOSPC/EDQUOT/EFBIGstay file-size resource constraints, now with their system code and path. All other failures become a provider workspace failure (execution_failure) with stage, workspace path, failing path, system code and recovery that fits the cause. Pcap, Flutter, TShark and sigrok all use it, and the duplicate TShark/sigrok copies are removed.Risk: Low. No schema change. Pcap and Flutter workspace failures that are not about storage move from
resource_constrainttoexecution_failurewith diagnostics. TShark/sigrok keep their classification and gainpathplus cause-specific remediation.Summary
Fixes #6123.
Before this change,
PcapSnapshot.createturned every allocation failure except the privacy-capability one into afile-sizeresource constraint.PcapSnapshot.capturedid the same for writes inside the workspace (Owned capture snapshot I/O failed). A denied or non-directory temporary parent was therefore reported as an exceeded size allowance, with no errno and no path. Now a workspace failure keeps its system cause, its failing path and cause-specific recovery. Real size refusals are still reported as size limits.Problem and expected behavior
Smallest trigger: run
inspect_pcap_capturewith the pcap workspace parent set to a regular file (ENOTDIR) or to a mode-0500 directory (EACCES). This violates theAnalysisResourceConstraintErrorcontract, which means a measured resource limit or a bounded admission refusal. A permission denial or a bad path does not establish either. Expected: a workspace-preparation failure that preservessystem_codeand the path and points recovery at the temporary parent. Genuine storage exhaustion keeps its cause and gets storage-specific recovery.Change and scope
src/process/privateWorkspaceFailure.ts(new) is the single owner of private-workspace filesystem failure projection:ENOSPC/EDQUOTproduceAnalysisResourceConstraintError("file-size").reported_limitscarries{workspace_path, path, system_code}and the remediation says to free disk space or quota.EFBIGproduces the same constraint and keeps the default worker file-size recovery.EMFILE/ENFILEproduceProviderAdapterErrorwhose remediation says to close files or raise the open-file limit.ProviderAdapterError. Itsdiagnosticshold{stage: "workspace", workspace_path, path, system_code, reason}and its remediation covers TMPDIR existence, permission and writability.pathis the errno's own coordinate when one exists (for example themkdtemptemplate) and otherwise the workspace path.src/pcap/PcapSnapshot.ts: allocation failures and snapshot workspace writes (mkdirof the configuration directory, thewxopen, write,chmod) use the shared owner. The privacy-capability path (PrivateRuntimeRootUnavailableError) and source-read handling are unchanged.src/flutter/FlutterBuildProvider.ts: the errno branch ofmapOwnedIoFailureuses the shared owner. It previously mapped every errno,EACCESincluded, tofile-size.mapOwnedIoFailurenow receives the owned root (nullonly beforemkdtempsucceeds). Package-reader system errors propagate to the request owner, which maps them againstsnapshot.root, so failures with no errno path still name their workspace.src/captures/TsharkCaptureProvider.tsandsrc/signals/SigrokRecordingProvider.ts: their identical inline workspace classification is replaced by the shared owner."file-size"producer. They are real size guards or SIGXFSZ projections. OtherPrivateRuntimeRoot.createcallers (firmware, apktool, lldb, kuna, ida, and others) do not project allocation errors as size limits.PrivateRuntimeRootallocates.Contribution scope: not applicable. This is an ordinary fix within existing boundaries.
Contract and boundary impact
Semantic owner and earliest changed stage:
privateWorkspaceFailure(src/process), at workspace allocation and owned-snapshot writes.Contribution scope fit and linked maintainer decision: not applicable (ordinary fix).
CLI and MCP/tool-catalog contract: no schema change. Error projections for non-storage workspace failures change from
resource_constrainttoexecution_failureand now includedetails.diagnostics.Provider, bridge, target-format, or platform compatibility: pcap, Flutter, TShark and sigrok. No platform behavior change.
Evidence, artifact, provenance, or reconstruction contract: none. The failure happens before any capture bytes are read.
Target selection, authority, upstream behavior, and cleanup details: unchanged. A partially prepared pcap workspace is still removed; the new test covers this.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
(This is what the existing tools already do. This PR adds no new effects.)
Evidence and regression coverage
Tests added or updated:
tests/boundary/mcp/pcapWorkspaceAllocation.test.ts(new) runs through the production MCP server,PcapProviderand the POSIX tool stubs. Native admission is simulated so macOS reaches allocation, as in the issue. It covers:ENOTDIRand realEACCESfrommkdtemp;invalid_request;ENOSPC/EDQUOT(resource constraint plus storage recovery);EMFILE/ENFILE(descriptor recovery);EROFS;EACCESon the configuration directory inside an allocated workspace, checkingworkspace_path, the failing path and that the partial workspace is removed;resource_constraint/file-sizewithmax_capture_bytes.src/process/privateWorkspaceFailure.test.ts(new):EFBIGkeeps the file-size recovery, and errno without a path, an error without errno, and a non-Error value all fall back to the workspace coordinate.tests/boundary/filesystem/flutterBuildProvider.test.ts: owned-storageENOSPCstaysresource_constraint, andEACCES/EPERM/EIObecome workspaceexecution_failurewithsystem_code. Each case also assertsworkspace_pathandpath:nullfor the root stage and therea-flutter-*root otherwise. 7 of the 8 cases fail without the root threading.Base reproduction: on base
34fd7bdf7, the issue's focused test reproduced the bug verbatim.ENOTDIRandEACCESboth projected asresource_constraint/file-size/reported_limits: nullwith no errno, and the normal-parent control returnedinvalid_request. With onlysrc/pcap/PcapSnapshot.tsreverted, 8 of the 10 new MCP tests fail. The 2 that still pass are the control and the size-limit counterexample.User-visible MCP output (fixed, real
EACCESfrommkdtemp):{"code":"execution_failure","category":"execution_failure","message":"Cannot prepare the private analysis workspace (EACCES): EACCES: permission denied, mkdtemp '<fixture-root>/parent/rea-pcap-Gq5FCR'","retryable":false,"remediation":{"action":"Review details.diagnostics.system_code and details.diagnostics.path. Make the host temporary directory (TMPDIR) an existing directory this user can create files in on a writable filesystem, then retry."},"details":{"provider_id":"pcap","operation":"inspect_pcap_capture","diagnostics":{"stage":"workspace","workspace_path":null,"path":"<fixture-root>/parent/rea-pcap-Gq5FCR","system_code":"EACCES","reason":"EACCES: permission denied, mkdtemp '<fixture-root>/parent/rea-pcap-Gq5FCR'"}}}Remaining proof gaps:
ENOSPC,EDQUOT,EMFILE,ENFILEandEROFSwere simulated as thrown errno errors, not produced by a full disk or exhausted descriptors.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
All runs were on macOS arm64 as a non-root user.
file-size.vitest run tests/boundary/mcp/pcapWorkspaceAllocation.test.ts: 10 passed. With the pcap fix reverted: 8 failed, 2 passed.vitest runacross the Flutter provider,tests/boundary/{captures,signals,pcap}, the pcap and packet-capture MCP tests, the artifact process boundary tests and the new unit test: 262 passed and 44 skipped, the skips being Linux-only suites.npm run check:fast: passed.npm run format:check: passed.Compatibility, safety, and release
resource_constraintfor a non-storage pcap or Flutter workspace failure now getsexecution_failurewithdetails.diagnostics.system_code.ENOTDIR/EACCESonly. No real Wireshark.Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code