Skip to content

refactor(cli): project GPU, signal and capture inspectors from their contracts - #10643

Merged
morluto merged 1 commit into
refactor/cli-contract-option-effectsfrom
refactor/cli-contract-runtime-json-null-limits
Nov 14, 2026
Merged

morluto merged 1 commit into
refactor/cli-contract-option-effectsfrom
refactor/cli-contract-runtime-json-null-limits

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Eighth slice of plan W1, stacked on #10635 (base refactor/cli-contract-option-effects; retarget as the lower PRs merge). Refs #10583.

The contract command description gains two features, and five commands are derived from their contracts with them:

  • JSON options decoded when the command runs, with their own refusal message: inspect-gpu-code-objects (--object_ids, --targets, and --view).
  • Bare flags that spell a nullable limit's null: inspect-signal-decoders --all, decode-signal-recording --all_lines, inspect-packet-fields --all and inspect-packet-capture --all_matches.

Problem and expected behavior

These commands re-declared their contract fields by hand:

  • GPU decoded three JSON options itself, re-parsed the whole input against the contract, and added the view kind.
  • Signal and capture copied the domain shape, replaced each nullable limit with a non-null option plus a boolean flag, and hand-wrote a superRefine, a not constraint and the null mapping. Two domain schemas (signalRecordingOptionsSchema, packetCaptureOptionsSchema) existed only for these CLI copies.

The derived commands must keep their flags (including snake_case spellings such as --line_limit and --display_filter), help, --schema, refusal messages (object_ids must be valid JSON, all and limit are mutually exclusive), the selector-budget refusal at argv parsing, and the service input.

Change and scope

  • contractCliDescription.ts:
    • runtimeJson: fields taken as JSON text, each with its refusal for text that is not JSON. The CLI admits any text; when the command runs, the text is decoded, and the decoded input, delivery and view are admitted together by the contract input before any target is opened. viewDelivery now uses the same mechanism, so a view is one run-time JSON field.
    • nullFlags: a nullable contract field whose null is spelled by a bare flag. The option takes only a value (the contract field without null or its default). The flag is a CLI-only boolean, the pair is refused at argv parsing with the previous message, and --schema advertises the same not constraint.
    • admit(values) replaces delivery(values) and returns the contract input with the delivery. Registration refuses run-time JSON combined with argv cross-field rules, which could not see the decoded values.
  • contractCommand.ts: the adapter runs admit. analyzeWithService runs a command with no target path through finishAnalysisCommand, as the two discovery commands did.
  • Migrations: GPU, both signal commands, both capture commands. The injected services used by the cleanup tests are kept.
  • Deleted: signalRecordingOptionsSchema and packetCaptureOptionsSchema, which only these CLI copies used.
  • Parity guard:
    • Run-time JSON: text that is not JSON is refused with the declared message, and decoded values are admitted exactly as the contract admits them. This replaces the view-only check.
    • Null flags: the flag maps to null, the pair is refused, and the not constraint is advertised.
    • Required options are filled when building argv values, and nullable numeric fields count as numeric.
  • Not included (next PR): WASM caller-path lists and its JSON-input compare command, firmware's flattened range.
  • Contribution scope: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI argv projection (contractCliDescription.ts). Per-command decoding, null mapping and mutual-exclusion code is removed.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract:
    • MCP: unchanged.
    • CLI --schema: semantically identical for all five commands.
    • Help: only line order changes.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. Same services, provider ids and caller-path recording.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged.
  • Generated metadata, package, or installation impact: none.

Expected effects:

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

(No effect changes: the migrated commands keep their existing behavior.)

Evidence and regression coverage

  • Tests added or updated: the parity guard covers 34 projected commands, with the run-time JSON and null-flag checks above.
  • Base reproduction: with the three hand-written command files restored on this branch, the guard fails (registers the migrated commands).
  • User-visible CLI output: captured --schema --format json, --help and 39 argv runs before and after through createCli().serve, recording the CLI exit and process.exitCode.
    • The runs cover:
      • GPU: malformed --object_ids, --targets and --view; --object_ids without --expected_sha256; a non-string object id; a non-array --targets; a view with complete detail; summary without --evidence_output; an unknown view key; an invalid --analysis and digest; a missing file; and a complete run on a small fixture.
      • Signal and capture: the flag with a limit, zero and non-decimal limits, the flag alone, paging options, an invalid decoder id, malformed and unknown-key --producer-limits, a missing --decoders, a negative offset, and near-limit selectors.
    • --schema: semantically equal for all five commands.
    • Help: order-only differences.
    • All 39 argv outputs and exit statuses: byte-identical.
  • Service input: on this macOS host the signal and capture providers stop at capability_unavailable. A script registered both families with recording fake services and compared the input reaching the service for 15 argv lines, including --all, --all_lines, --all_matches, limits, --producer-limits and relative paths. The values were identical before and after; only object key order differs.
  • Remaining proof gaps: no real sigrok or TShark run (Linux-only providers); the existing signalCleanup and captureCleanup tests pass with injected services.

Validation performed

  • npm run check:fast: passed.
  • npm run knip: no findings after deleting the two superseded schemas.
  • npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts: 208 passed.
  • npm run test:focused -- signalCleanup, captureCleanup, gpuCodeObjectsCli, cliDomainFieldSchema, localPathAdmissionCli, rejectedSymlinkCliMcp, apkSignatureViewsCliMcp, modelArtifactCli, rustDependencyViews, evidenceOutputPublicationCli, formatSpecificCallerPathCli: 11 files, 80 tests 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: no change in authority or side effects.

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.

…contracts

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 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-14T19:50:01.712678Z c1d9a38 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 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

Moves five GPU, signal and capture commands onto their named contracts.

  • GPU inspection checks its JSON options against the tool contract before running.
  • Signal and capture paging keep their bare flags for returning all remaining results.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Parse CLI arguments] --> B[Check fields and flag conflicts]
  B --> C[Map flags and decode run-time JSON]
  C --> D[Check decoded input and delivery]
  D -->|Refused| E[Return input error]
  D -->|Accepted| F[Run service]
  F --> G[Await cleanup and preserve results]
  G --> H[Return or publish Evidence]
Loading

Reviews (1) · Last reviewed commit: "refactor(cli): project GPU, signal and c..." · Reviewed by Greptile

@morluto
morluto merged commit d9f8120 into refactor/cli-contract-option-effects Nov 14, 2026
1 check passed
@morluto
morluto deleted the refactor/cli-contract-runtime-json-null-limits branch November 14, 2026 20:02
morluto added a commit that referenced this pull request Nov 14, 2026
…contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
morluto added a commit that referenced this pull request Nov 15, 2026
…contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
morluto added a commit that referenced this pull request Nov 15, 2026
…contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
morluto added a commit that referenced this pull request Nov 15, 2026
…PP from contracts (#10635)

* refactor(cli): project CLI-only options for release exposure and IL2CPP from contracts

The contract command description gains CLI-only options whose effect the handler owns, plus their dependentRequired entries. audit-release-exposure keeps --fail_on (exit status 3) and inspect-il2cpp-metadata keeps --ghidra-seeds/--seed-base; their hand-written options and input spreads are deleted.

* refactor(cli): project GPU, signal and capture inspectors from their contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
morluto added a commit that referenced this pull request Nov 15, 2026
…nce (#10606)

* fix(cli): record the caller's --join-path spelling in Apple IPS Evidence

* refactor(cli): project CLI-only options for release exposure and IL2CPP from contracts (#10635)

* refactor(cli): project CLI-only options for release exposure and IL2CPP from contracts

The contract command description gains CLI-only options whose effect the handler owns, plus their dependentRequired entries. audit-release-exposure keeps --fail_on (exit status 3) and inspect-il2cpp-metadata keeps --ghidra-seeds/--seed-base; their hand-written options and input spreads are deleted.

* refactor(cli): project GPU, signal and capture inspectors from their contracts (#10643)

The contract command description gains JSON options decoded when the command runs, admitted with the delivery by the contract input, and bare flags that spell a nullable limit's null. inspect-gpu-code-objects, inspect-signal-decoders, decode-signal-recording, inspect-packet-fields and inspect-packet-capture are derived from their contracts; their hand-written options, superRefine blocks and CLI-only option schemas are deleted.
@morluto morluto added area: cli CLI adapter and one-shot commands provider: gpu Analysis provider / engine: gpu labels 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 provider: gpu Analysis provider / engine: gpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant