Skip to content

refactor(cli): project Go, V8 and delivery inspectors from their contracts - #10576

Merged
morluto merged 1 commit into
mainfrom
refactor/cli-contract-artifact-inspectors
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/cli-contract-artifact-inspectors

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Second slice of plan W1, stacked on #10571 (base branch refactor/cli-contract-command; retarget to main after #10571 merges). It moves four more contract-backed CLI commands onto registerContractCommand and deletes their hand-written option schemas and input mapping:

  • inspect-go-binary
  • inspect-v8-code-cache
  • inspect-devicetree
  • inspect-native-exports

Problem and expected behavior

These commands restated their contract fields by hand. inspect-go-binary had 11 conditional spreads and per-field renames. The derived projection must keep the CLI surface: command names, flags, positionals and help wording, plus where each refusal happens.

Change and scope

  • Projection addition (in the framework-neutral src/cli/contractCliDescription.ts from refactor(cli): derive contract-backed command options from the tool contract #10571; Refs [Design] Replace incur with a contract-generated CLI layer now that REA owns its MCP server #10583): evidenceDelivery: true declares the shared --detail / --evidence_output options (analysisEvidenceDeliveryOptions) as CLI-only options in the description. The Incur adapter renders them, the run context carries the selected delivery, and deliverWithService calls deliverCliAnalysisEvidence. A contract detail field selects that delivery and is not passed to the analysis, matching the hand-written commands.
  • Go's cross-field budget rule stays with the service's contract parse; the projection does not set crossFieldRules: "argv". inspect-go-binary --max-string-literals 2 without --include-string-literals still returns the invalid_request with path max_string_literals that tests/acceptance/goBinaryCli.test.ts asserts.
  • Exact-optional fields such as Go's include_string_literals and architecture are projected as optional (added in refactor(cli): derive contract-backed command options from the tool contract #10571), so help still shows --include-string-literals as a flag and --architecture <x86|...> with its choices.
  • Parity guard: the declared CLI-only delivery options are the only options without a contract field.
  • Not included:
    • Commands with JSON --view / --producer-limits options (rust, pyc, beam, model, binary layout, recorded crash); these need a JSON-option projection.
    • Other families.
    • The registry-derived lists (later PRs).

Contribution scope: not applicable (refactor within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI argv projection (registerContractCommand). The contract remains the single definition. Per-command option blocks and spreads for the four commands are removed.
  • 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.
    • Help: byte-identical for devicetree, native-exports and v8. Go lists the same option lines in contract order, so --detail/--evidence_output move from first to last.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. Delivery still goes through deliverCliAnalysisEvidence with the verbatim caller path.
  • 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 read the same files as before.)

Evidence and regression coverage

  • Tests added or updated: parity guard extended as above; it now covers 18 projected commands.
  • Base reproduction or other evidence:
    • Captured --schema --format json and --help for each command from the base build and after the change. The exact-optional help regression above was caught this way during development and is now guarded.
    • Default service-level cross-field refusal is covered by the existing go acceptance test; argv-level refusal by the existing sqlite tests in overnightBatch1CliSchemas.test.ts.
  • User-visible CLI/MCP output: none intended, apart from the go help option order.
  • Remaining proof gaps: no real-provider runs (in-process readers only).

Validation performed

  • npm run typecheck: passed.
  • npm run check:fast: passed.
  • npm run knip: no findings.
  • npm run test:focused -- 25 files (rerun after rebasing on the framework-neutral split): 25 passed; 415 tests passed, 1 skipped.
    • Acceptance: go (3), v8, devicetree, native-exports (4), builtin document tokens, local-path admission, native ELF architecture, rust, stable-artifact parser failure, sqlite CLI.
    • CLI boundary: artifact input limits, caller-path symlink parent, parity guard, help default annotations, integer arguments, lazy registration, JSON output, overnight batch-1 schemas, startup imports, command evidence delivery.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (macOS host only).
  • 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-14T20:35:26.832411Z 8c0e8ab 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 634ada185b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/goCommands.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The PR appears safe to merge; no actionable new defects were found.

Summary

Moves four inspectors onto registerContractCommand and adds shared Evidence delivery support.

  • Four inspectors now take their CLI fields from their contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Named tool contract + CLI projection"] --> B["describeContractCommand"]
  B --> C["registerContractCommand"]
  C --> D["Analysis input"]
  C --> E["Delivery choices"]
  D --> F["Service inspection"]
  F --> G["Existing cleanup helpers"]
  E --> H["Existing Evidence delivery"]
  G --> H
  H --> I["Complete Evidence or summary + bundle"]
Loading

Reviews (5) · Last reviewed commit: "refactor(cli): project Go, V8 and delive..." · Reviewed by Greptile

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

morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

The Greptile summary's Issue 1 ("Contract selection depends on order") was reviewed at 634ada1 and is fixed in the current head (377a0baa48):

  • src/cli/goCommands.ts:15 uses contractNamed(GO_TOOL_CONTRACTS, "inspect_go_binary").
  • src/cli/v8CodeCacheCommands.ts:18 uses contractNamed(V8_CODE_CACHE_TOOL_CONTRACTS, "inspect_v8_code_cache").
  • contractNamed throws at registration when the name is missing.
  • Sweep: git grep -nE "_CONTRACTS\[[0-9]\]|const \[[a-zA-Z]+\] = [A-Z_]+_CONTRACTS|_CONTRACTS\.at\(" over src on the stack tip (refactor(cli): project Apple bundle commands onto a declared session target #10656) finds no positional contract selection.
  • On the stack tip, npm run check:fast passed and npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts passed (254 tests).

@greptileai please re-review.

Base automatically changed from refactor/cli-contract-command to main November 14, 2026 20:30
@morluto morluto closed this Nov 14, 2026
…racts

Migrate inspect-go-binary, inspect-v8-code-cache, inspect-devicetree and
inspect-native-exports onto the contract command description and delete
their hand-written options and input spreads.

The description gains evidenceDelivery. It adds the shared --detail and
--evidence_output options, and the run context carries the selected
delivery. A contract detail field selects that delivery and is not passed
to the analysis, as the hand-written commands did. Go's cross-field
budget rules stay with the service's contract parse, so standalone
--max-string-literals still returns invalid_request.

The parity guard accepts the declared CLI-only delivery options as the
only options without a contract field.
@morluto morluto reopened this Nov 14, 2026
@morluto
morluto force-pushed the refactor/cli-contract-artifact-inspectors branch from 377a0ba to 8c0e8ab Compare November 14, 2026 20:33
@morluto
morluto merged commit da53dce into main Nov 15, 2026
53 checks passed
@morluto
morluto deleted the refactor/cli-contract-artifact-inspectors branch November 15, 2026 01:15
@morluto
morluto restored the refactor/cli-contract-artifact-inspectors branch November 15, 2026 01:15
@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