Repository navigation
refactor(cli): project decompile from its contract with --file-offset as an alternative selector - #10756
Conversation
… as an alternative selector
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 PR appears safe to merge; no blocking issues were found. Summary
Review was source-only. Tests were not rerun because dependencies were absent. The supplied stack has no higher PR; live supersession status could not be checked because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
Contract["procedure_pseudo_code contract"] --> CLI["decompile arguments and options"]
CLI --> Select{"Selector spellings agree?"}
Select -->|No| Refuse["Return input error"]
Select -->|Yes| Open["Check opening options"]
Open --> Run["Run direct analysis"]
Run --> Cleanup["Await provider cleanup"]
Cleanup --> Result["Return Evidence or failure"]
Reviews (2) · Last reviewed commit: "refactor(cli): project decompile from it..." · Reviewed by Greptile |
… as an alternative selector (#10756)
… as an alternative selector (#10756)
…ontracts (#10753) * fix(contracts): refuse empty address and procedure selectors in the contracts * refactor(cli): project decompile from its contract with --file-offset as an alternative selector (#10756) * refactor(cli): project search from its contracts with --kind choosing the operation (#10761) * refactor(cli): project search from its contracts with --kind choosing the operation * fix(cli): check operation choices' option rules and bind errors to the selected contract * test(cli): group operation-choice checks in their own block * refactor(cli): project decompile-all from its contract onto a native session target (#10778) * refactor(cli): project decompile-all from its contract onto a native session target * refactor(cli): project native Mach-O, Swift and native UI commands from their contracts * fix(cli): read search, decompile-all and native utility contracts from their groups so startup stays lazy * test(cli): drop the empty-selector admission mismatches the contracts now refuse
Summary
Next slice of plan W1, stacked on #10753. Refs #10583.
decompileis now derived from theprocedure_pseudo_codecontract. Its third selector spelling,--file-offset, is declared as an alternative option of the procedure selector, so the shared selector owner handles all three spellings instead of a hand-written resolver chain.Problem and expected behavior
decompilere-declaredprocedure,analysisand the native open flags by hand and resolved the positional,--procedureand--file-offsetspellings with two nestedresolveCliAnalysisSelectorcalls. The contract-derived selector path (#10738) could not express a third spelling, so the command stayed hand-written.Expected: the same arguments, options, defaults, refusals and help, with the input taken from the contract.
Change and scope
contractCliDescription.ts: a selector option may declare analternativeoption with its own argv grammar and a mapping to the selector's text (selects).selectSpelledSelectorowns the agreement rules: the named option and the alternative agree only as text; the positional then agrees with either as the selector's kind; a conflict names the option the caller used (file-offsetwhen it was given). This is the same rule the hand-written command applied.contractCommand.ts: the alternative is registered as an option and its parsed value kept apart like the named option.coreBinaryCommands.ts:decompileis registered fromprocedure_pseudo_codeon the native target with--snapshot.--file-offset 0x…selectsfile-offset:0x…. The Hopperdocumentfield anddetailare omitted (the CLI keeps returning complete pseudocode Evidence, as before).search, where--kindselects betweensearch_stringsandsearch_procedures.analyze, which routes JavaScript targets to another lane.decompile-directory, the utility family and the managed family.--detail/--evidence_outputdelivery fordecompile(a CLI addition, left for a separate change).Contribution scope: not applicable. Target selection and authority are unchanged.
Contract and boundary impact
procedure_pseudo_codeowns the inputs; the shared selector description owns spelling agreement. Removed: the hand-writtendecompileschemas and resolver chain.decompileis unchanged except option order (--procedureand--file-offsetnow follow the native open flags). Refusals keep their codes and paths (invalid_requestwithissues[].path["file-offset"]for mixed coordinates;VALIDATION_ERRORfor an empty or malformed value).decompilenow runs under the command's cancellation signal, like the other contract commands. Otherwise unchanged.Expected effects (unchanged from the existing command; left for the human owner to check):
Evidence and regression coverage
cliContractCommandParity.test.ts):decompilejoins the parity checks (every contract field exposed or omitted; option keys include the alternative).--procedure, and a conflict with the positional or the named option is refused naming the alternative.""throws (the guard from fix(contracts): refuse empty address and procedure selectors in the contracts #10753).analysisSelectorCli.test.ts(file-offset admission and mixed-coordinate refusal through the real CLI, missing/conflicting/empty/dash selectors),cliInputSchemaRequired.test.ts, Kuna and IDA CLI decompile tests listed below.rea decompile --helprendered from this branch lists the same arguments and options as before.--file-offsetin this PR.For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/boundary/cli/analysisSelectorCli.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts— 553 passed.npm run test:focused -- tests/boundary/providers/kuna/kunaSingleFunctionRuns.test.ts tests/boundary/providers/kuna/kunaProvider.test.ts tests/boundary/providers/kuna/kunaCommandCancellation.test.ts tests/boundary/providers/kuna/kunaReferences.test.ts tests/boundary/filesystem/productCatalog.test.ts tests/boundary/cli/emptyLocalTargetAdmission.test.ts tests/boundary/cli/providerSelectionRemediationCli.test.ts tests/boundary/cli/idaRetainedCleanupCli.test.ts tests/boundary/cli/idaStartupAttributionCli.test.ts tests/boundary/providers/ida/calleeRelationships.test.ts— 146 passed.npm run check:fast— passed.node scripts/rea.mjs decompile --help— inspected.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.