Skip to content

refactor(cli): project decompile from its contract with --file-offset as an alternative selector - #10756

Merged
morluto merged 1 commit into
fix/selector-contracts-refuse-emptyfrom
refactor/cli-contract-decompile
Nov 15, 2026
Merged

morluto merged 1 commit into
fix/selector-contracts-refuse-emptyfrom
refactor/cli-contract-decompile

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Next slice of plan W1, stacked on #10753. Refs #10583.

decompile is now derived from the procedure_pseudo_code contract. 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

decompile re-declared procedure, analysis and the native open flags by hand and resolved the positional, --procedure and --file-offset spellings with two nested resolveCliAnalysisSelector calls. 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 an alternative option with its own argv grammar and a mapping to the selector's text (selects). selectSpelledSelector owns 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-offset when 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: decompile is registered from procedure_pseudo_code on the native target with --snapshot. --file-offset 0x… selects file-offset:0x…. The Hopper document field and detail are omitted (the CLI keeps returning complete pseudocode Evidence, as before).
  • Not included (each needs its own mechanism; next slices):
    • search, where --kind selects between search_strings and search_procedures.
    • analyze, which routes JavaScript targets to another lane.
    • decompile-directory, the utility family and the managed family.
    • --detail/--evidence_output delivery for decompile (a CLI addition, left for a separate change).

Contribution scope: not applicable. Target selection and authority are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: procedure_pseudo_code owns the inputs; the shared selector description owns spelling agreement. Removed: the hand-written decompile schemas and resolver chain.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: MCP unchanged. CLI help for decompile is unchanged except option order (--procedure and --file-offset now follow the native open flags). Refusals keep their codes and paths (invalid_request with issues[].path ["file-offset"] for mixed coordinates; VALIDATION_ERROR for an empty or malformed value).
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: decompile now runs under the command's cancellation signal, like the other contract commands. Otherwise unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects (unchanged from the existing command; left for the human owner to check):

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated (cliContractCommandParity.test.ts):
    • decompile joins the parity checks (every contract field exposed or omitted; option keys include the alternative).
    • New: each alternative selector maps onto the same field, agrees with an equal --procedure, and a conflict with the positional or the named option is refused naming the alternative.
    • New: describing a selector whose contract admits "" throws (the guard from fix(contracts): refuse empty address and procedure selectors in the contracts #10753).
  • Unchanged and passing: 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.
  • Base reproduction or other evidence: rea decompile --help rendered from this branch lists the same arguments and options as before.
  • Remaining proof gaps: no real Ghidra run of --file-offset in this PR.

For evidence-bearing changes:

  • 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 -- 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

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T02:29:44.992696Z dbe2dc0 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

decompile now takes its inputs from the procedure_pseudo_code contract. Shared selector code replaces the command’s nested resolver calls.

  • Decompile now gets its procedure options from the shared contract.

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"]
Loading

Reviews (2) · Last reviewed commit: "refactor(cli): project decompile from it..." · Reviewed by Greptile

@morluto
morluto merged commit 88811ef into fix/selector-contracts-refuse-empty Nov 15, 2026
1 check passed
@morluto
morluto deleted the refactor/cli-contract-decompile branch November 15, 2026 03:23
morluto added a commit that referenced this pull request Nov 15, 2026
morluto added a commit that referenced this pull request Nov 15, 2026
morluto added a commit that referenced this pull request Nov 15, 2026
…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
@morluto morluto added the area: cli CLI adapter and one-shot commands label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant