Skip to content

refactor(cli): project view-delivery inspectors from their contracts - #10600

Merged
morluto merged 2 commits into
mainfrom
refactor/cli-contract-view-delivery
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
refactor/cli-contract-view-delivery

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fourth slice of plan W1, stacked on #10589 (base refactor/cli-contract-json-options; retarget after #10571, #10576 and #10589 merge). Refs #10583 (the description stays framework-neutral).

It adds a view-delivery declaration to the contract command description and migrates the four --view inspectors: inspect-rust-binary, inspect-python-pyc, inspect-erlang-beam and inspect-model-artifact. Their hand-written options, view decoding and input spreads are deleted.

Problem and expected behavior

These four commands took --view as JSON text and each decoded and checked it by hand, in two different ways:

  • Python and Erlang checked {detail, view} against a delivery schema that duplicated their contract's detail-discriminated union (pythonPycDeliverySchema, erlangBeamDeliverySchema).
  • Rust and model checked the whole input against the contract, added the view kind themselves, and Rust chose summary when a view was given without --detail.

The derived commands must keep:

  • the flags, help text and --schema of each command;
  • the refusal messages: view must be valid JSON (Python, Erlang), view must be a JSON package or edge selection (Rust), view must be a JSON model page selection (model), and the contract's own messages for a view with complete detail;
  • the refusal of summary delivery without --evidence_output before any target is opened.

Change and scope

  • contractCliDescription.ts:
    • New projection viewDelivery: { invalidJson, kind?, viewSelectsSummary? }, which requires evidenceDelivery. --view stays a string option. When the command runs, its JSON is decoded, then the contract input schema admits it together with detail and the other inputs. Issues are projected with analysisInputErrorFromIssues, as before.
    • delivery(values) now returns a Result, and is undefined without evidenceDelivery. It also refuses summary delivery without --evidence_output for every delivering command, before the service is created. This was already the order for Python and Erlang. For Go, V8, the delivery inspectors, Rust and model, the refusal moves from inside deliverCliAnalysisEvidence to before service creation, and the output is byte-identical (captured below).
    • A contract input may be a discriminated union. Each field the CLI takes as an argument must be the same schema in every branch. Only delivery-owned fields (detail, view) may differ, and anything else is refused at registration. A x-rea-root-discriminator naming a delivery field is accepted. The description exposes fields (each field's schema) so the parity guard no longer reads inputSchema.shape.
  • contractCommand.ts: the Incur adapter projects a refused delivery as the analysis error, and deliverWithService forwards the admitted view.
  • Migrated: the four commands. For model, the handler passes detail: "complete" to the service, as before, because the CLI delivers the summary itself.
  • Removed:
    • pythonPycDeliverySchema and erlangBeamDeliverySchema, which are now unused (the contracts keep the shared branch shapes);
    • the local copy of the producer-limits help text in binaryDiagnosticsCommands.ts. PRODUCER_LIMITS_HELP is exported once from producerLimitsOption.ts.
  • Not included:
    • parseCliAnalysisEvidenceDelivery stays for the hand-written browser, Electron and static-endpoint commands until they migrate.
    • The remaining hand-written families.
  • Contribution scope: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI argv projection (describeContractCommand) and its run-time delivery admission.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract:
    • MCP: unchanged.
    • CLI --schema: semantically identical for all four commands; only key order differs.
    • Help: the same lines for all four commands. Options now follow contract order, with --evidence_output last.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. The same services, provider ids, caller-path recording and deliverCliAnalysisEvidence are used.
  • 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 in tests/boundary/cli/cliContractCommandParity.test.ts. It now covers 24 projected commands.
    • Every delivering command refuses --detail summary without --evidence_output at evidence_output, and admits it with one.
    • Every view command reports malformed --view JSON at view with invalid_format, and admits exactly the {}, [], null and unknown-key views its contract admits under complete and summary detail.
    • A union input whose branches differ outside the delivery is refused at registration.
  • Base reproduction: with the four 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 23 argv runs before and after, through createCli().serve. The argv runs cover malformed view JSON, a view with complete detail, summary without --evidence_output, invalid view kinds and collections, malformed --producer-limits, a non-decimal integer and plain runs.
    • --schema: semantically equal for all four commands.
    • --help: the same lines, in a different order.
    • All 23 argv outputs: byte-identical.
  • Remaining proof gaps: none beyond the listed tests. Success paths run against the generated fixtures in the acceptance tests below.

Validation performed

  • npm run check:fast: passed (typecheck and lint).
  • npm run knip: no findings.
  • npx oxfmt --check on the changed files: clean.
  • npm run test:focused -- 15 files: 15 passed; 322 tests passed.
    • Parity guard.
    • CLI acceptance: pythonPycCli, erlangBeamCli, rustBinaryCli, modelArtifactCli, rustDependencyViews, rustUnnamedSections, modelSafetensorsZipCollision, applications/erlangBeamViews and applications/pythonPycViews.
    • Caller paths: localPathAdmissionCli and formatSpecificCallerPathCli.
    • CLI boundary: cliIntegerArguments, evidenceOutputPublicationCli and artifactInputLimits.

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.

@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-15T05:56:39.519215Z 84e1691 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 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no blocking issue was found.

Summary

Moves seven inspectors onto contract-derived CLI descriptions, including the four view inspectors plus APK signature, desktop application, and EVM inspection.

  • Four view inspectors check selections through their contracts.
  • APK, desktop, and EVM commands use contract-based CLI fields.
  • Producer-limit options now share one help message.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Parsed CLI arguments] --> B[Decode optional view JSON]
  B --> C[Check view and detail against contract]
  C --> D[Require bundle path for summary]
  B -->|Invalid JSON| E[Return input error]
  C -->|Invalid input| E
  D -->|Missing path| E
  D --> F[Create service and inspect]
  F --> G[Finish cleanup]
  G --> H[Deliver complete Evidence or selected view]
  H --> I[Publish complete Evidence when requested]
Loading

Reviews (3) · Last reviewed commit: "refactor(cli): project APK signature, de..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/cli-contract-json-options branch from 07d25a2 to 793dfbb Compare November 14, 2026 20:33
@morluto
morluto force-pushed the refactor/cli-contract-view-delivery branch from 4897cb8 to 3c850d0 Compare November 14, 2026 20:33
@morluto
morluto force-pushed the refactor/cli-contract-json-options branch from 793dfbb to 1a19726 Compare November 15, 2026 01:15
@morluto
morluto force-pushed the refactor/cli-contract-view-delivery branch from 3c850d0 to e809764 Compare November 15, 2026 01:45
@morluto
morluto changed the base branch from refactor/cli-contract-json-options to main November 15, 2026 04:34
@morluto
morluto force-pushed the refactor/cli-contract-view-delivery branch from 272142e to 84e1691 Compare November 15, 2026 05:54
@morluto
morluto merged commit fa53f70 into main Nov 15, 2026
52 checks passed
@morluto
morluto deleted the refactor/cli-contract-view-delivery branch November 15, 2026 07:00
@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