Repository navigation
refactor(cli): project procedure-references and inspect-native-api with named selector options - #10738
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
[Medium impact] The reviewed changes appear safe to merge; no blocking issue was found. SummaryThe PR adds shared support for positional selectors with named alternatives and moves seven commands onto contract-based registration.
This assessment is source-based; tests and real providers were not run. Live supersession status could not be checked because GitHub authentication was unavailable. The supplied stack lists no higher dependent PR. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Parse arguments and options] --> B[Keep selector spellings separate]
B --> C{Selectors agree and required value exists?}
C -->|No| D[Return input error]
C -->|Yes| E[Check delivery and opening options]
E --> F[Run direct analysis]
F --> G[Await provider cleanup]
G --> H[Return Evidence or publish bundle]
Reviews (4) · Last reviewed commit: "refactor(cli): project inspect, xrefs, t..." · Reviewed by Greptile |
2394666 to
0b50b74
Compare
3bebed9 to
5dead85
Compare
…th named selector options A contract projection may let the caller give a positional selector with a named option instead, for values that begin with a dash. The positional becomes optional; equal values agree (native addresses by identity), and different values, or neither for a required field, are refused before the target is opened. selectCliAnalysisSelector owns that rule and returns a Result; resolveCliAnalysisSelector remains for the hand-written core binary commands. procedure-references and inspect-native-api are now derived from their contracts on the native session target, which completes the core native family.
…ns from their contracts (#10747) The five core binary commands are derived from their contracts on the native session target with the snapshot option, using named selector options for the procedure, address and query. A selector projection may require a selector the contract lets the MCP caller omit: xrefs' address defaults to Hopper's cursor, which a one-shot CLI command does not have. A selector names one object, so neither spelling may be empty, as before, even where the contract's text admits it. open_binary's pairing rules now refuse an unpaired --target-format, --architecture or --entry-point for inspect before the target is opened, naming the CLI key.
0b50b74 to
6b05a90
Compare
5dead85 to
bb60c95
Compare
…ptions (#10736) * refactor(cli): project core native commands with open_binary target options A session target's opening fields may now be caller paths, admitted resolved and passed on as the caller spelled them, and a union of text forms such as the provider selector renders as one argv token. nativeTarget declares a native executable opened with open_binary's format, architecture, entry point and provider fields, plus the snapshot where a command loads one. runDirectOnTarget runs an operation on that target through runDirectAnalysis, with Evidence delivery when declared. Eleven core native commands are now derived from their contracts. Their inputs are admitted by the service's contract parse, which replaces the CLI's copies of the byte-pattern and data-type selector checks. inspect-native-dispatch-metadata now exposes the contract's Objective-C class import address fields. * fix(cli): read core native contracts from their contract groups so startup stays lazy * refactor(cli): project procedure-references and inspect-native-api with named selector options (#10738) * refactor(cli): project procedure-references and inspect-native-api with named selector options A contract projection may let the caller give a positional selector with a named option instead, for values that begin with a dash. The positional becomes optional; equal values agree (native addresses by identity), and different values, or neither for a required field, are refused before the target is opened. selectCliAnalysisSelector owns that rule and returns a Result; resolveCliAnalysisSelector remains for the hand-written core binary commands. procedure-references and inspect-native-api are now derived from their contracts on the native session target, which completes the core native family. * fix(cli): refuse empty named and positional selectors before opening the target * refactor(cli): project inspect, xrefs, trace, function and instructions from their contracts (#10747) The five core binary commands are derived from their contracts on the native session target with the snapshot option, using named selector options for the procedure, address and query. A selector projection may require a selector the contract lets the MCP caller omit: xrefs' address defaults to Hopper's cursor, which a one-shot CLI command does not have. A selector names one object, so neither spelling may be empty, as before, even where the contract's text admits it. open_binary's pairing rules now refuse an unpaired --target-format, --architecture or --entry-point for inspect before the target is opened, naming the CLI key. * fix(cli): read core binary contracts from their contract groups so startup stays lazy
Summary
Next slice of plan W1, stacked on #10736 (base
refactor/cli-contract-native-open; retarget as the lower PRs merge). Refs #10583.A contract projection can now take a positional selector that the caller may instead give with a named option, the form the remaining core binary commands use.
procedure-referencesandinspect-native-apiare derived from their contracts with it, which completes the core native family.Problem and expected behavior
procedure-referencesandinspect-native-apiwere hand-written because they take the procedure either positionally or as--procedure(for symbols that begin with a dash). Equal values agree, native addresses by identity (0x1aand0x1A), and conflicts fail. The contract projection had no such form, so each command re-declared its inputs and calledresolveCliAnalysisSelectoritself. The same form blocksdecompile,xrefs,trace,function,instructionsandsearch.Expected behavior: same arguments, options and help. Missing or conflicting selectors are refused before the target is opened, with the same issue paths and messages.
Change and scope
analysisSelector.ts:selectCliAnalysisSelectorowns the agreement rule and returns aResult.resolveCliAnalysisSelectornow wraps it (throws) for the core binary commands that are still hand-written.contractCliDescription.ts:selectorOptionsnames, per positional field, the option key, help and agreement kind (textornative). The positional becomes optional. Registration refuses a selector on a non-positional or non-text field.valueKey. CLI-key collisions are checked separately for positionals and for options.toContractInputkeeps the named spelling when both are given.admitrunsselectCliAnalysisSelectorbefore the contract input is admitted.contractCommand.ts: renders selector options and keeps the positional and named values apart.coreNativeCommands.ts: the two commands are registered fromprocedure_referencesandinspect_native_apionnativeTarget(..., true)(with--snapshot).procedure-referenceskeeps Evidence delivery. The Hopperdocumentfield is omitted.decompile-directory, utility and managed families.Contribution scope: not applicable. Target selection and authority are unchanged.
contractNamed(OFFICIAL_TOOL_CONTRACTS, …),ENHANCED_TOOL_CONTRACTS,NATIVE_TOOL_CONTRACTS,ELECTRON_TOOL_CONTRACTS,OPEN_BINARY_TOOL_CONTRACT) instead oftoolContractfromtoolContracts.ts, which loaded the complete catalog at CLI startup (tests/boundary/cli/cliStartupImports.test.ts). The lint rule added in refactor(cli): project inspect-artifact and extract-artifact with open_binary target options #10722 keeps it out.Contract and boundary impact
selectCliAnalysisSelectorowns positional/named selector agreement. The contract projection owns the two commands' inputs. Removed: the two hand-written commands.procedureand the same messages.inspect-native-apinow runs under the command's cancellation signal. Otherwise unchanged.Expected effects (unchanged from the existing commands; left for the human owner to check):
Evidence and regression coverage
cliContractCommandParity.test.ts):invalid_value.missing_argument.0x1a/0x1Aagree and keep the named spelling.analysisSelectorCli.test.ts(missing, conflicting and dash-leadinginspect-native-apiselectors through the real CLI),procedureReferencesDelivery.test.ts,cliInputSchemaRequired.test.ts,emptyLocalTargetAdmission.test.ts,src/analysisSelector.test.ts.coreNativeCommands.tswas rendered with incur from refactor(cli): project inspect-artifact and extract-artifact with open_binary target options #10722's tree and this branch and diffed. For these two commands only option order differs; the other differences are the ones refactor(cli): project core native commands with open_binary target options #10736 describes.For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts: 429 passed.npm run test:focused --procedureReferencesDelivery,analysisSelectorCli,cliInputSchemaRequired,emptyLocalTargetAdmission,filesystem/productCatalog,mcp/nativeProcedureReferenceViews,src/analysisSelector.test.ts: 117 passed.npm run check:fast: passed.npx oxfmt --check src/cli tests/boundary/cli: clean.Review follow-up (3f6291e):
npm run test:focused -- tests/boundary/cli/analysisSelectorCli.test.ts— 36 passed; the newprocedure-referencesempty-selector case failed before the selector projection refused"".cliContractCommandParity.test.ts+cliInputSchemaRequired.test.ts— 454 passed.npm run check:fast— passed.This branch now also carries refactor(cli): project inspect, xrefs, trace, function and instructions from their contracts #10747 (collapsed into it); see that PR for its validation.
After rebasing onto
mainwith the startup-import fix:npm run check:fastpassed (pre-push) at this branch; at the top of the stacknpm run test:focused -- tests/boundary/cli/cliStartupImports.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/nativePlistCli.test.ts tests/boundary/cli/nativePlistSelectionFailureCli.test.ts tests/boundary/cli/contractCommandInputFields.test.ts tests/boundary/cli/nativeMachoEvidenceDeliveryCli.test.ts: 660 passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.