Skip to content

refactor(cli): project native Mach-O, Swift and native UI commands from their contracts - #10784

Merged
morluto merged 1 commit into
refactor/cli-contract-decompile-directoryfrom
refactor/cli-contract-utility-native
Nov 15, 2026
Merged

morluto merged 1 commit into
refactor/cli-contract-decompile-directoryfrom
refactor/cli-contract-utility-native

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Part of plan W1 (CLI commands derived from their contracts). Six utility commands (inspect-macho, inspect-signature, list-architectures, demangle-swift, observe-native-ui, capture-native-ui-scenario) re-declared their contract fields by hand. They now register through registerContractCommand on a session target with the shared runOnSessionTarget handler, so options, help and --schema come from the contracts.

Refs #10583

Problem and expected behavior

Each command repeated its contract's fields (decimal wrappers, renames, a per-command mapper), and capture-native-ui-scenario had its own JSON decoding and error wrapper for --steps. Expected: one definition (the contract) drives both MCP and CLI admission, with shared JSON decoding.

Change and scope

  • src/cli/utilityCommands.ts: the six commands are contract projections; the native UI scope mapper, the scenario's JSON decoding and invalidNativeUiScenarioInput are removed. --steps is a runtime-JSON field.
  • src/cli/contractCliDescription.ts: a runtime-JSON field the contract requires is now a required option (it previously refused to register). The parity test checks that the option is required exactly when the contract field is.
  • src/cli/cliJsonOption.ts: the shared JSON-option refusal now carries expected: "JSON", as the other JSON-format producers (cliJsonInput, JsonInputFile, browser commands, the removed scenario copy) do. This adds a field to existing refusals from runtime-JSON options; messages are unchanged.
  • inspect-macho omits the contract's detail (the CLI returns complete Evidence, as before).

Intentionally not included:

  • inspect-plist keeps its hand-written option. Its contract's path field is the CLI's --relative-path, but NativePlistSource.unreadablePlist reports a plist that the target itself selects (no path given) under the same ["path"] issue path. With the rename, that case would name relativePath, which the caller never supplied. The producer needs to report the target separately first (proposed follow-up).
  • capabilities/providers (no contract input) and import-reference-source (W1 item 4, raw .meta()).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the six native contracts now own CLI admission; copied option shapes and mappers are removed.
  • Contribution scope fit and linked maintainer decision: not applicable (refactor within existing boundaries).
  • CLI and MCP/tool-catalog contract: same flags, defaults and required options. Help comes from contract descriptions, with CLI wording kept where it differed (--pid, --window-id, --max-nodes, --steps, demangle-swift symbols). Malformed --steps JSON is still invalid_request at ["steps"], reason: invalid_format, expected: "JSON", and now has the shared message steps must be valid JSON. MCP unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): commands now run under the shared command cancellation via registerContractCommand.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: 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/cliContractCommandParity.test.ts: the six commands are in the migrated list, so every parity case covers them. The runtime-JSON case now checks required-ness against the contract, and the argv-mapping case decodes runtime JSON as admission does.
  • Base reproduction or other evidence: existing native CLI suites (Mach-O, signature, demangle, native UI scenario input, decimal options, aliases, empty target admission) pass unchanged through the new path.
  • User-visible CLI/MCP output (if applicable): rea capture-native-ui-scenario --help lists --pid, --window-id, --screenshot, --accessibility, --max-nodes, --native-ui-deadline-ms and --steps, as before.
  • Remaining proof gaps: native UI capture itself was not run (no window). No real-provider runs beyond the macOS native tools the suites invoke.

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 -- 33 files (cliContractCommandParity, the native Mach-O/plist/signature/demangle/UI-scenario CLI suites, cliInputSchemaRequired, emptyLocalTargetAdmission, cliOptionAliases, utilityIntegerOptions, the app-bundle and Mach-O acceptance suites, nativeDeadlineFlags, androidPackageViewCli, apktoolCli, projectCliAnalysisResult, cliDomainFieldSchema): 734 passed, 1 skipped. An earlier run, with inspect-plist migrated, failed 12 tests: the plist selection-failure cases described above, two parity cases since fixed, and the scenario expected: "JSON" case.
  • npm run check:fast: passed.
  • node scripts/rea.mjs capture-native-ui-scenario --help: output as described above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Runtime-JSON refusals gain an expected: "JSON" issue field (additive).
  • Real Hopper/Ghidra, browser, or OS coverage: macOS native tools through the existing suites; no native UI capture.
  • 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:56:43.521887Z c037bdf 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 reviewed changes appear safe to merge.

Summary

Six native utility commands now derive their CLI fields from contracts and use the shared session-target handler.

  • Native UI commands take their input fields from tool contracts.
  • Native inspection and Swift commands take their fields from contracts.
  • Runtime JSON options follow the required fields in their contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Native tool contracts] --> B[CLI arguments and options]
  B --> C[Decode scenario steps]
  C --> D[Check decoded request]
  D --> E[Shared command cancellation]
  E --> F[Run on selected target]
  F --> G[Await cleanup and return Evidence]
Loading

Reviews (2) · Last reviewed commit: "refactor(cli): project native Mach-O, Sw..." · Reviewed by Greptile

@morluto
morluto merged commit df32573 into refactor/cli-contract-decompile-directory Nov 15, 2026
1 check passed
@morluto
morluto deleted the refactor/cli-contract-utility-native branch November 15, 2026 05:56
@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