Repository navigation
fix(targets): project invalid raw-binary loads as caller input - #2004
Conversation
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. |
|
I filed #2002 and had a local fix in progress when this opened, so I'll leave this one to you. Two things my branch hit that this diff doesn't touch yet:
Verified locally through the real CLI on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21cc7c5b11
ℹ️ 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".
| error instanceof BinaryTargetError && | ||
| error.constraint === "raw_binary_load_rejected" | ||
| ) | ||
| return "Correct the reported raw-binary load argument (target_format, architecture, entry_point) and retry."; |
There was a problem hiding this comment.
Use public raw-binary option names in remediation
When this new branch handles any raw_binary_load_rejected, the remediation tells both adapters to correct target_format, but that is not a caller input on either surface. I checked the CLI contract and guide (src/cli/options.ts:39-43, docs/raw-binary.md:9-23), which expose --target-format/--entry-point, and the MCP contract (src/contracts/sessionLifecycleInputs.ts:33-50), which exposes format/entry_point. A user following this action can therefore submit an unknown flag or field; name both surface spellings (or avoid parameter identifiers) in this shared message.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6deebe0: the remediation now names the real option spellings on both surfaces — --target-format, --architecture, or --entry-point on the CLI and format, architecture, or entry_point through MCP — following the cross-adapter naming the WASM remediation already uses.
|
Thank you — both points addressed in 6deebe0:
|
Summary
Fixes #2002. Invalid caller-supplied raw-binary load choices (
--target-format/--architecture/--entry-point) were projected as problems with the target file:target_unavailable/unsupported_target(orunavailable) with remediation that told the caller to review the file. They now project as caller input —invalid_request/invalid_input, retryable, with remediation naming the load options by their real spellings on both surfaces. An empty file remains a target refusal, and the DOS COM target-kind pairing is reclassified with the same caller-input treatment.Problem and expected behavior
rea analyze f.bin --target-format raw-binary --architecture arm --entry-point 0x1on any readable non-empty file reportedunsupported_targetwith "Review the reported file-format reason and select a supported, well-formed target." — the file was fine; only the entry alignment was wrong.BinaryTargetResolverlabeled everyadmitRawBinaryrejectionfile_format_rejected, although only the empty-file extent is a property of the target; the format-pairing rejection carried no constraint at all and fell to the generic "Check that the path exists…" advice.load_selection_rejectedconstraint and project asinvalid_request/invalid_inputwith "Correct the reported load argument (--target-format, --architecture, or --entry-point on the CLI; format, architecture, or entry_point through MCP) and retry."; the empty-file extent keepsfile_format_rejected→target_unavailable/unsupported_target.Change and scope
src/domain/rawBinary.ts:admitRawBinaryrejections are now structured (reason+ owning classification:load_selection_rejectedfor caller input,file_format_rejectedfor the empty-file target refusal), so the classification is derived at the owner instead of being re-inferred downstream.src/application/BinaryTargetResolver.ts: raw-binary rejections carry the admission's constraint; both target-kind pairings (raw-binary and DOS COM) use it too, so the analogous DOS COM conflict no longer advises selecting a different file; the architecture/entry pairing now reusesrawBinarySelectionError(its existing message owner, already used by the MCP contract layer) instead of a duplicated inline string.src/domain/analysisErrorPresentation.ts+analysisErrorProjection.ts:load_selection_rejectedmaps to categoryinvalid_input, codeinvalid_request, its own remediation (option names verified againstsrc/cli/options.tsandsrc/contracts/sessionLifecycleInputs.ts, following the cross-adapter naming the WASM remediation uses), and drops the path-checking advice from the user message.load_selection_rejectedrather than raw-binary-specific so one value covers both headerless formats' caller-input rejections honestly.file_format_rejected(it is a property of the file); Doctor'sinspectTargetpasses no load arguments and cannot observe these rejections, so it is unchanged.Contract and boundary impact
src/domain/rawBinary.ts, consumed by target resolution before any provider selection.invalid_request/invalid_inputare existing projection values; the newload_selection_rejectedstring appears indetails.constraint(a free-form detail field).docs:checkgreen; no code enumeration changed).Evidence and regression coverage
Tests added or updated:
src/domain/rawBinary.test.tsasserts the owning classification for the unaligned, width-overflow, malformed/missing-argument, and empty-file rejections;tests/boundary/filesystem/targetDiagnostics.test.tsprojects the misaligned arm entry, the x86 width overflow, the pairing-without-format, the raw-binary and DOS COM target-kind pairings, and the empty file through the publicparseBinaryTarget→projectAnalysisErrorboundary, including message text, remediation, and absence of path advice;tests/boundary/cli/rawBinaryCli.test.tsnow pinsinvalid_requestfor the missing-architecture and unaligned-arm64 cases through the real CLI.Base reproduction: with the source changes stashed, the new filesystem-boundary tests fail on
e19879328(they receivetarget_unavailable/unsupported_target/unavailable); the empty-file test passes on base by design, pinning the behavior that must not change. The CLI boundary expectations fail on base with the new code and pass with it.Real public CLI before/after on a 64-byte fixture (macOS 27 arm64, Node 24.18.0), matching the issue's table:
--target-format raw-binary --architecture arm --entry-point 0x1target_unavailable/unsupported_target, "Review the reported file-format reason…"invalid_request/invalid_input, retryable, remediation naming the CLI/MCP option spellings--target-format raw-binary --architecture x86 --entry-point 0xffffffffffinvalid_request/invalid_input--architecture arm --entry-point 0x0(no format)target_unavailable/unavailable+ "Check that the path exists…"invalid_request/invalid_input, no path advicetarget_unavailable/unsupported_targetRemaining proof gaps: MCP-path behavior is covered through the shared projection, not a separate stdio MCP session run; non-macOS hosts were not exercised (path is platform-neutral).
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 test:focused -- src/domain/rawBinary.test.ts tests/boundary/filesystem/targetDiagnostics.test.ts tests/boundary/cli/rawBinaryCli.test.ts— 41 passed (including real-CLI boundary runs)npm run check:fast— greennpm run check— green (typecheck, lint, format, knip, metadata, architecture guards)npm run docs:check— greenrea analyzeruns before/after as tabled abovegit stashof the source changesCompatibility, safety, and release
details.constraint === "file_format_rejected"for raw-binary argument errors (introduced in [Bug] NE, LE and LX refusals give misleading "check the path" advice #1979, four days old) see the newload_selection_rejectedvalue instead.Review checklist
type(scope): outcome.