Skip to content

refactor(cli): register every command in an REA-owned command table - #11680

Merged
morluto merged 2 commits into
mainfrom
refactor/cli-command-registry
Nov 16, 2026
Merged

morluto merged 2 commits into
mainfrom
refactor/cli-command-registry

Conversation

@morluto

@morluto morluto commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds REA's own command table, the registry the incur removal (#11654) builds on, and makes shell completion its first reader instead of incur's Cli.toCommands. Each entry also records the contract operations the command runs and the flag of each contract field, the per-command table #11476 needs. No CLI output changes. Refs #11654, refs #11476.

Problem and expected behavior

Command identity lived only in incur's private command map (read through Cli.toCommands) plus three per-CLI description WeakMaps in contractCommand.ts. Replacing incur's parser, help and dispatch needs one REA-owned table holding what incur's map holds, and #11476's error projection needs each command's operations and field-to-flag mapping (registry design note: #11654 (comment)).

Change and scope

  • src/cli/commandRegistry.ts: registerCliCommand(cli, name, definition, { operations, source }) records the entry in registration order and hands the same definition object to incur, so the in-place rewrites by the shell owners (omittable defaults, result output, argument policy) stay visible to readers. cliCommands(cli) lists entries. A duplicate name is refused. CliCommandDefinition is REA's own definition type (description, positionals, options, aliases, output policy, handler with args, options, formatExplicit); every registrar compiles against it unchanged.
  • Operation columns: each contract command records its contract, the alternatives its operationBy option chooses, the contract that opens its session target (for example open_binary with format: --target-format, entry_point: --entry-point, provider_id: --provider, snapshot_path: --snapshot), and the source of its Evidence targets. Routed commands (analyze) record every route. rea function, search, decompile and analyze are contract or routed commands, so they need no separate map. ContractCliSessionTarget now names its opening contract.
  • All 22 hand-built cli.command(...) sites and the 3 contract registration sites go through registerCliCommand; host commands record no operations.
  • The three description WeakMaps in contractCommand.ts are removed; contractCommandDescriptions, routedCommandDescriptions and contractDocumentCommandDescriptions now read the table.
  • completions.ts reads the table; the cast in cliShell.ts is gone.
  • Fix at the flag owner (inputBinding.flags in contractCliDescription.ts, from review): each field of a field group now maps to the group's option (inspect-android-jni-bindings: class_name, method_names, descriptors, abis, library_paths -> --query; the non-field query entry is gone), and a positional selector maps to its named option (procedure -> --procedure on function, instructions, decompile; pattern -> --pattern on search). That map also feeds cli_flag and related_cli_flags in errors. Before/after: no current producer names a selector or group field in details.limit.parameter or details.related_parameters (I searched the producers; the related-parameter producers name path and columns/table/schema_scope), so no error output changes today. A future error naming procedure on rea function would now carry cli_flag: --procedure instead of no flag, and one naming class_name on inspect-android-jni-bindings would carry --query instead of no flag. Goldens unchanged.
  • Deleted the dead nativeOpenOptionFields export in src/cli/options.ts and the four option schemas only it used, plus the unused snapshotSelectionOption.
  • New guard cli-command-outside-registry (baseline 0): cli.command( outside src/cli/commandRegistry.ts.

Not included: the other visitRegisteredCommands readers (argument errors, strict positionals, sensitive values, result output, omittable defaults) move in the errors/middleware PR; parser, help, formatting and dispatch follow. #11476's producer migrations are separate.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/cli/commandRegistry.ts owns command registration; readers are completion and the description accessors.
  • Contribution scope fit and linked maintainer decision: refactor under Remove incur: run the CLI on an REA-owned, contract-generated layer with parity tests #11654.
  • CLI and MCP/tool-catalog contract: none changed (parity goldens unchanged).
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: tests/boundary/cli/cliCommandRegistry.test.ts (table matches incur's dispatched commands in order and by identity; operation and flag columns for function, search, decompile, analyze, inspect-byte-entropy; host commands have none); tests/boundary/cli/completions.test.ts registers through the table.
  • Base reproduction or other evidence: not a fix. The CLI parity goldens (refactor(cli): own shell completion behind new CLI parity goldens #11662) pass unchanged, including every completion case.
  • User-visible CLI/MCP output (if applicable): none changed.
  • Remaining proof gaps: none known for this step.

Validation performed

  • npm run test:focused -- tests/boundary/cli/cliCommandRegistry.test.ts tests/boundary/cli/completions.test.ts tests/boundary/cli/cliParityGoldens.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/routedCommand.test.ts tests/boundary/cli/cliLazyRegistration.test.ts — passed except a registry expectation I then corrected (search also records search_procedures); cliCommandRegistry.test.ts rerun — 4 passed
  • npm run test:focused -- the 20 test files importing a changed registrar or contractCommand.ts — 1260 passed, 8 skipped
  • After the review fix: the new registry test (grouped fields and named selectors) fails on 37d7d2e and passes on 28a21ee; npm run test:focused -- the 13 test files that read input bindings or cli_flag plus cliCommandRegistry, cliParityGoldens, cliContractCommandParity — 15 files, 1233 passed, 1 skipped
  • npm run check:fast — passed (before and after the review fix)
  • node scripts/verify/architecture-guards.mjs — passed
  • npx oxfmt --check src/cli tests/boundary/cli scripts/verify — clean
  • pre-push hook — passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • 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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T03:04:40.404977Z
We couldn’t complete this review. Comment @codex review to try again.
37d7d2e 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No blocking issues found at the reviewed head; the available main-branch history already includes this change.

Summary

REA now owns the CLI command table, and shell completion reads it instead of Incur’s private map.

  • REA’s CLI commands are recorded in one table before they reach Incur.
  • Completion and command descriptions now come from REA’s command table.
  • Contract operation details now show the real CLI flags for each field.
  • The unused native-open option schemas are removed from the CLI options module.

No new actionable issues found. Tests were not rerun.

Status check: the available origin/main history already includes this PR and its review fix in commit f14e9a1d2.

Reviews (5) · Last reviewed commit: "fix(cli): flag grouped fields and named ..." · Reviewed by Greptile

Comment thread src/cli/commandRegistry.ts Resolved
@morluto

morluto commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

@morluto
morluto merged commit f14e9a1 into main Nov 16, 2026
40 of 44 checks passed
@morluto
morluto deleted the refactor/cli-command-registry branch November 16, 2026 03:39
morluto added a commit that referenced this pull request Nov 16, 2026
#11686)

#11680 moved every CLI command onto registerCliCommand(cli, CLI_COMMANDS.x,
...), so the Stryker command-handler selector, which matched
cli.command(CLI_COMMANDS.x, ...), found no target for debugWithGdb and
debugWithRizin and the reverse-tools quality job failed to load its config.
The selector now matches the registry call.

Refs #11654
Afloat16 added a commit to Afloat16/rea that referenced this pull request Nov 16, 2026
Reuse the core registrar for decompile-all instead of registering it twice
after upstream morluto#11680. Assert the outer MCP start/completion notifications
separately from provider cleanup progress introduced by morluto#11637, retaining
cleanup, rate, timeout, cancellation, and evidence assertions.
morluto added a commit that referenced this pull request Nov 16, 2026
…gistry (#11689)

registerCoreBinaryCommands already registers decompile-all; the test registered it a second time. incur overwrote the duplicate silently; REA's command table (#11680) rejects it, so every case in the file failed on main.
N0zoM1z0 pushed a commit that referenced this pull request Nov 22, 2026
* feat(evidence): paginate retained evidence discovery summaries

Let callers page summary metadata in canonical Evidence ID order without loading record payloads into the response. Keep filter and link totals global to all matches and preserve the unpaged response for existing clients.

* test(evidence): use the supported compact schema profile

* docs(evidence): explain the summary pagination request default

* test: align verification fixtures with current public contracts

Keep the production changes from upstream and update the verification consumers that still asserted their retired contracts:

- assert unknown workflow identity structurally and retain the bounded provider caveats;
- observe the process capture's partial-error delivery while preserving live cleanup ownership assertions;
- use the package's declared imports in the isolated release controller;
- refresh the replay card digest after the Evidence subject identity migration;
- use the supported compact Kimi profile while testing case-insensitive environment keys;
- assert each public interface's own capture issue path.

These are shared test and verifier compatibility repairs. The evidence summary pagination and config-printer feature changes remain separate.

* test: observe the session close result in Kuna retry coverage

* test: follow the persisted DOL snapshot target identity

* test: align CLI and progress fixtures with shared owners

Reuse the core registrar for decompile-all instead of registering it twice
after upstream #11680. Assert the outer MCP start/completion notifications
separately from provider cleanup progress introduced by #11637, retaining
cleanup, rate, timeout, cancellation, and evidence assertions.

* docs: link CLI paging guidance to its canonical contract
@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