Skip to content

refactor(cli): project search from its contracts with --kind choosing the operation - #10761

Merged
morluto merged 2 commits into
fix/selector-contracts-refuse-emptyfrom
refactor/cli-contract-search
Nov 15, 2026
Merged

morluto merged 2 commits into
fix/selector-contracts-refuse-emptyfrom
refactor/cli-contract-search

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Next slice of plan W1, stacked on #10753 (which now carries #10756). Refs #10583.

search is now derived from its contracts. --kind is a CLI-only option that selects search_procedures in place of the registered search_strings; both contracts must project to the same arguments and options, which is checked when the command is described.

Problem and expected behavior

search re-declared pattern, mode, case_sensitive and the native open flags by hand, and chose the operation inline. The contract-derived registration could describe only one contract per command.

Expected: the same arguments, options, defaults, refusals and help, with each invocation admitted by the contract --kind selects (errors keep naming search_strings or search_procedures).

Change and scope

  • contractCliDescription.ts: a projection may declare operationBy: { option, contracts }. describeOperationChoices describes each alternative contract with the same projection and throws if its arguments/options differ from the registered contract's, so help and --schema hold for every choice.
  • contractCommand.ts: the handler admits, opens and runs with the selected contract's description, and passes that contract's name as the operation.
  • coreBinaryCommands.ts: search is registered from search_strings with --kind (strings default, procedures) selecting search_procedures. document and detail are omitted as before.
  • Not included: analyze (JavaScript lane routing), decompile-directory, the utility and managed families, and the item-4 families.

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

Contract and boundary impact

  • Semantic owner and earliest changed stage: search_strings / search_procedures own the inputs; the shared registration owns contract selection. Removed: the hand-written search schemas and inline operation choice.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: MCP unchanged. CLI help for search is unchanged except option order. Refusals keep their codes, paths and operation names.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: search now runs under the command's cancellation signal. 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: search joins the parity checks; new case that an operation choice projecting other options is refused when described.
    • analysisSelectorCli.test.ts: new real-CLI case that a conflicting selector is refused naming search_strings by default and with --kind strings, and search_procedures with --kind procedures, before the target is opened.
  • Unchanged and passing: the selector suite (missing, conflicting, empty, dash, positional/named/identical) for search, cliInputSchemaRequired.test.ts, and the search CLI tests listed below.
  • Base reproduction or other evidence: rea search --help from this branch lists the same arguments and options as before.
  • Remaining proof gaps: no real provider run.

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 — 565 passed.
  • npm run test:focused -- tests/boundary/go/goBinaryProvider.test.ts tests/boundary/cli/emptyLocalTargetAdmission.test.ts tests/boundary/cli/argumentGuidance.test.ts tests/boundary/filesystem/productCatalog.test.ts tests/acceptance/applications/applicationWorkflowCli.test.ts tests/boundary/cli/markdownArgumentErrors.test.ts tests/boundary/cli/cliOutput.test.ts — 182 passed, 1 failed: applicationWorkflowCli "keeps Electron identity unresolved for conditional initializers ([Bug] Electron APIs are not recovered through aliasing variables (e.g. const ipc = ipcMain) #1656)" ran 900 s and failed. That case runs the JavaScript application lane, not search; it is reported to the coordinator as a slow-test defect in the JavaScript analyzer, not investigated here.
  • npm run check:fast — passed.
  • node scripts/rea.mjs search --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-15T05:35:00.818943Z da67988 New commits
ℹ️ 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

[Low impact] The PR appears safe to merge; both previous findings are fixed and no new actionable issues were found.

Summary

search now derives its arguments and options from its contracts. --kind selects the contract used to check inputs and run the search.

  • Search uses its contracts and lets --kind choose the inventory.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Parse search arguments and options"] --> B{"kind"}
  B -->|strings or default| C["search_strings"]
  B -->|procedures| D["search_procedures"]
  C --> E["Check selectors and opening options"]
  D --> E
  E -->|refused| F["Return error naming selected contract"]
  E -->|accepted| G["Open target and run selected operation"]
Loading

Reviews (2) · Last reviewed commit: "fix(cli): check operation choices' optio..." · Reviewed by Greptile

Comment thread src/cli/contractCliDescription.ts Resolved
Comment thread src/cli/contractCommand.ts Resolved
@morluto
morluto merged commit 19d57e9 into fix/selector-contracts-refuse-empty Nov 15, 2026
1 check passed
@morluto
morluto deleted the refactor/cli-contract-search branch November 15, 2026 05:41
morluto added a commit that referenced this pull request Nov 15, 2026
… 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
morluto added a commit that referenced this pull request Nov 15, 2026
… 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
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