Repository navigation
Conversation
[Low impact] The PR appears safe to merge; no actionable issue remains in the reviewed changes. Summary
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["CLI request"] --> B["Check local path"]
B -->|Invalid| C["Return path error"]
B -->|Valid| D["Check exactly one nonempty selector"]
D -->|Invalid| E["Return input error without target access"]
D -->|Valid| F["Open target and run analysis"]
Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile |
inspect-native-data-type still declared its positional target as a plain string after morluto#7956 moved its sibling local-file commands to localPathStringSchema, so an empty target passed validation and resolved to the working directory. Use the shared schema and cover the command in the empty-target admission table.
Codex Review Summary: ❌ FailedThis 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. |
|
TL;DR: I ran the PR's 3 changed test files on Node 22.23.4, 24.22.1 and 26.12.1, and 79 tests passed each time. With the 2 changed source files swapped back to the merge base, 3 tests failed on every Node version. I did not run the command on a real binary.
The red run puts In the Node 24.22.1 log, one test fails in each file:
So the new checks fail without the fix and pass with it. CI on 220c14a: all 19 check runs that ran passed, including The head is 25 commits behind main b81da90. Not run
Test setup
Commandsnpm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/boundary/cli/analysisSelectorCli.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/boundary/cli/emptyLocalTargetAdmission.test.ts🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
…a-type-selector-admission # Conflicts: # src/cli/coreNativeCommands.ts
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Summary
Fixes #7276.
rea inspect-native-data-typeforwarded its optional--typeand--addressselectors straight torunDirectAnalysis, which prepares the target before the provider validates the operation input. A request with no selector, both selectors, or an empty selector therefore reportedtarget_unavailablefor a missing or unsupported target, and for a valid target it opened the target before rejecting the request. The command now admits the canonical selector choice before opening the target, and its help names that choice like the other CLI commands with selector alternatives. It also declares its positional target withlocalPathStringSchema, which #7956 applied to its sibling local-file commands but not to this one, so an empty target is rejected at validation instead of resolving to the working directory.Current
main(db0b9ac20) is merged into the branch.Problem and expected behavior
Smallest trigger:
rea inspect-native-data-type does-not-exist --format json, or the same command with--type /MyStruct --address 0x1000,--type "", or--address "".Base behavior:
code: "target_unavailable". #7276 reproduces the six malformed cases through the production CLI builder and dispatcher. By source,runAnalysisinsrc/application/DirectAnalysis.tscallsprepareSnapshotbeforesession.execute, and the selector rule is enforced after that, for Ghidra by its input schema insrc/ghidra/GhidraFunctionValues.ts.Violated invariant:
nativeDataTypeInputSchemainsrc/domain/native/nativeDataType.tsrequires exactly one nonemptytypeoraddress. The CLI translations section ofdocs/tool-design.mdrequires the help to state a required choice that the CLI schema cannot express, and admission of that choice before target access.Expected: an input error before target access, whether or not the target exists or is supported.
Change and scope
src/cli/analysisSelector.ts: exportdataTypeSelectorGuidancealongside the existing shared CLI selector guidance constants so theinspect-native-data-typehelp text and its discovery test share one owner.src/cli/coreNativeCommands.ts: parse the selectors withnativeDataTypeInputSchemabefore callingrunDirectAnalysis, and return failures throughanalysisInputErrorFromIssues(retaining{ cause: selected.error }) andprojectAnalysisError, the admission shape thatsearch-bytes,inspect-gpu-code-objects, andinspect-model-artifactalready use. Valid requests pass the same input object torunDirectAnalysisas before.dataTypeSelectorGuidance, following theinstrument-with-fridascript source guidance.pathuseslocalPathStringSchema, the shared nonempty, NUL-free schema that fix(cli): reject empty native and managed targets before resolution #7956 adopted for the other local-file commands in this group.docs/cli.mdalready states that local inspection commands reject empty paths before resolution.runDirectAnalysisordering for other commands. Pre-existing selector test constants for unrelated commands incliInputSchemaRequired.test.tsare left untouched to keep this PR scoped to [Bug] inspect-native-data-type reports target_unavailable for an invalid selector #7276.Contract and boundary impact
nativeDataTypeInputSchema, and the CLI selector guidance text is owned bydataTypeSelectorGuidanceinsrc/cli/analysisSelector.ts; the CLI adapter applies the schema at admission, beforerunDirectAnalysis.invalid_requestfor operationinspect_native_data_typebefore target access, and the command help, schema, and full manifest name the exactly-one choice. Valid requests and MCP are unchanged.docs/public/product-catalog.json), package, or installation impact: no generated file is committed; the advertised change is the command and option description text.Expected effects:
Evidence and regression coverage
Tests added or updated:
tests/boundary/cli/analysisSelectorCli.test.ts: runs the compiled CLI againstdoes-not-existwith no selector, both selectors,--type "", and--address "", and expectsinvalid_requestfor operationinspect_native_data_typewith the root issue message read from the owningnativeDataTypeInputSchemaalongside independent checks on parameter names (type,address), paths, reasons, andminimum: 1bounds. A single--typeor--addressstill reaches the target and reportstarget_unavailable. On the base revision the four invalid cases reporttarget_unavailable, so the test fails there.tests/boundary/cli/cliInputSchemaRequired.test.ts: addsinspect-native-data-typeto the required selector discovery table, comparing the advertised schema, help, and full manifest against the owningdataTypeSelectorGuidancealongside independent checks for"exactly one", absence of"at least one", preserved--typeand--addressoption names, optional schema fields, and Ajv validation of representable and rejected shapes. On the base revision the descriptions lack the guidance, so the entry fails there.tests/boundary/cli/emptyLocalTargetAdmission.test.ts: addsinspect-native-data-type --type /MyStructto the empty-target table, which expectsVALIDATION_ERRORonpathwithtoo_smallbeforerunDirectAnalysisis called, rejects NUL bytes, and admits an explicit.. Onmainthe command still accepts the empty target, so the row fails there.Base reproduction or other evidence: the [Bug] inspect-native-data-type reports target_unavailable for an invalid selector #7276 reproduction, and the source path above (
coreNativeCommands.ts,DirectAnalysis.tsrunAnalysis,GhidraFunctionValues.ts).User-visible CLI/MCP output (if applicable): the
detailsasserted by the new test, which the compiled CLI produced in the earlier local run:{"operation":"inspect_native_data_type","issues":[{"path":[],"reason":"invalid_value","message":"Supply exactly one of type or address"}]}An empty selector reports
{"path":["type"],"reason":"out_of_range","minimum":1}(oraddress).Remaining proof gaps: no real provider run; none is needed for the rejected cases because they no longer reach a provider, and valid requests take the unchanged path. The latest commits (
810c94da1,a735387be,220c14a25) were verified by source reading and run through CI rather than re-executed locally.Covered boundary regressions: missing, empty, and unknown values (omitted, empty, and conflicting selectors against a single valid selector) and public success and error delivery (the compiled CLI path and its named
invalid_requestcontract). Lifecycle regressions: not applicable; no resource ownership or finalization changes, and invalid requests no longer acquire a target.Validation performed
On the earlier branch revision merged with
mainatd48e472fa(Node 24.22.1, macOS arm64):npm run test:focused -- tests/boundary/cli/analysisSelectorCli.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/boundary/cli/emptyLocalTargetAdmission.test.ts: 3 files, 73 tests passed, including the compiled-CLI selector cases and the new empty-target row.npm run check:fast: typecheck and lint passed.mainatdb0b9ac20and binding the selector guidance tests to their owning contracts (a735387be,220c14a25); those updates were verified by source reading and rely on CI execution. Fullcheck:prand real provider workflows were not run locally.Compatibility, safety, and release
Author readiness
Human owner: @viniciusdsandrade
Before merge
type(scope): outcome.