Skip to content

refactor(cli): project observe-native-calls onto a session target and its contract document - #10700

Merged
morluto merged 3 commits into
mainfrom
refactor/cli-contract-native-call-document
Nov 15, 2026
Merged

morluto merged 3 commits into
mainfrom
refactor/cli-contract-native-call-document

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Next slice of plan W1, stacked on #10697 (base refactor/cli-contract-reconstruction-documents; retarget as the lower PRs merge). Refs #10583.

The contract-document projection gains a session target: the path positional before the JSON document. observe-native-calls is derived from its contract with it.

Problem and expected behavior

observe-native-calls <path> <input-json> was hand-written:

  • It decoded the document without a cancellation signal.
  • It parsed the document with a schema imported separately from the contract.
  • It re-validated the output through z.record(...).parse.
  • It called runProviderAnalysis without the command's signal.

The JSON-document projection (#10668) could not express a target the CLI opens, so this command stayed outside it.

The expected behavior is unchanged: the same positionals, the same refusals before the target is opened, and the same provider call.

Change and scope

  • contractCliDescription.ts: CliDocumentProjection.sessionTarget adds the path positional ahead of the document key. A CLI-only option cannot take either key.
  • contractCommand.ts: ContractDocumentContext.sessionTarget carries the target as the caller spelled it, as the flag projection does.
  • nativeCallCommands.ts: registered through registerContractDocumentCommand with NATIVE_TOOL_CONTRACTS' observe_native_calls. The handler admits the document with the contract's input schema before opening the target. It then runs the operation on the spelled target with the command's cancellation signal.
  • Not included: the other remaining JSON-document commands (compare-static-and-observed-endpoints, capture-browser-scenario, validate-browser-scenario). They take contract fields as CLI flags beside the document.
  • Contribution scope: not applicable. Target execution authority is unchanged; this only moves the CLI projection.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI document projection. The hand-written argument list, decoding and output re-validation are removed.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract:
    • MCP: unchanged.
    • CLI arguments: unchanged (path, inputJson). --schema advertises the contract input, which is the same schema object as before.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details:
    • Cancellation: observe-native-calls now runs under withCommandCancellation, and the provider receives the command's signal. This matches the other session-target commands.
    • Target selection: unchanged.

Expected effects (unchanged from the existing command):

  • 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:
    • jsonInputStatus.test.ts: observe-native-calls refuses an invalid document (breakpoints: "main") with operation: observe_native_calls, before opening a missing target.
    • cliContractCommandParity.test.ts: document commands may declare a session target positional before the document; observe-native-calls is listed.
    • localPathAdmissionCli.test.ts (unchanged) still covers the empty path refusal.
  • Remaining proof gaps: no real LLDB run in this change. The provider call and its arguments are unchanged, apart from the added signal.

Validation performed

  • npm run typecheck: passed.
  • npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/jsonInputSchema.test.ts tests/acceptance/localPathAdmissionCli.test.ts tests/boundary/cli/jsonInputStatus.test.ts: 324 passed, before the new status case.
  • npm run test:focused -- tests/boundary/cli/jsonInputStatus.test.ts: 36 passed, with the new case.
  • Pushed with --no-verify. Typecheck was run manually; lint-staged ran oxlint and oxfmt on commit.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: no real LLDB run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new authority. Cancellation now reaches the provider.

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: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T12:19:08.627362Z
We couldn’t complete this review. Comment @codex review to try again.
d270416 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 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

Moves more CLI commands onto their named contracts and shared command builders.

  • CLI commands take more of their input shape from shared contracts.
  • Native-call commands check their JSON input before running the target analysis.
  • Artifact commands use the opening contract for target-format options.
  • Source-to-bundle comparisons use a shared request shape and keep the caller's path spelling.
  • Static and observed endpoint comparisons use the application contract projection.
  • Browser scenario commands take their JSON inputs from shared contracts.
  • Reconstruction workflows take their JSON documents from application contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["observe-native-calls path inputJson"] --> B["Decode JSON with the command signal"]
  B --> C{"Contract accepts the document?"}
  C -->|No|D["Return an input error"]
  C -->|Yes|E["Run the provider on the caller's path"]
  E --> F["Await provider cleanup"]
  F --> G["Return the result"]
Loading

Reviews (4) · Last reviewed commit: "refactor(cli): project inspect-artifact ..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from 769ba82 to 44c8628 Compare November 15, 2026 00:48
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from 44c8628 to b81ed2a Compare November 15, 2026 01:45
@morluto
morluto force-pushed the refactor/cli-contract-reconstruction-documents branch 2 times, most recently from afb76d7 to 63990e9 Compare November 15, 2026 05:58
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from b81ed2a to e8b0a9e Compare November 15, 2026 05:58
@morluto
morluto force-pushed the refactor/cli-contract-reconstruction-documents branch from 63990e9 to fb146a1 Compare November 15, 2026 07:34
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from e6f1711 to 0e105c7 Compare November 15, 2026 07:35
@morluto
morluto force-pushed the refactor/cli-contract-reconstruction-documents branch from fb146a1 to cdb44f0 Compare November 15, 2026 09:37
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from 0e105c7 to bd32c3d Compare November 15, 2026 09:37
@morluto
morluto force-pushed the refactor/cli-contract-reconstruction-documents branch from cdb44f0 to dfd85dd Compare November 15, 2026 10:08
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch 2 times, most recently from 00fc8a2 to eefe85d Compare November 15, 2026 11:18
@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.

@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from eefe85d to 58a3b8b Compare November 15, 2026 11:26
@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.

@morluto
morluto changed the base branch from refactor/cli-contract-reconstruction-documents to main November 15, 2026 11:40
@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.

…ents with delivery options (#10711)

* refactor(cli): carry document command delivery as options and project endpoint and browser scenario commands

A JSON-document projection can now take the contract's detail and view
fields as --detail, --evidence_output and --view beside the document.
The document refuses those fields with the option to use, and the
delivery is admitted by the contract's own view schema before the
document is read.

compare-static-and-observed-endpoints, capture-browser-scenario and
validate-browser-scenario now register from their contracts; validation
projects the capture contract without detail.

* fix(cli): admit the endpoint comparison document before reading its Evidence bundle

The document command context carries the document's transport frame, so
a handler that reads an Evidence bundle first can refuse a malformed
document beforehand, as the hand-written command did.

* refactor(cli): pass only object documents to the document field refusal
…n_binary target options (#10722)

* refactor(cli): project inspect-artifact and extract-artifact with open_binary target options

A declared session target can now take fields of the contract an MCP
client opens the target with as options. They are admitted by that
contract, with the target as its path, before the target is opened, and
the projection can narrow an enum to the values the command supports.

inspect-artifact and extract-artifact are derived from their contracts
with open_binary's format and ESP flash fields. MCP open_binary and the
CLI share one mapping from those fields to the target selection.
extract-artifact now runs under the command's cancellation signal.

* fix(cli): read open_binary from its session contract so startup stays lazy

* build(lint): refuse value imports of the complete tool catalog in CLI startup modules
@morluto
morluto force-pushed the refactor/cli-contract-native-call-document branch from 6047cc5 to d270416 Compare November 15, 2026 12:19
@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.

@morluto
morluto merged commit 781f89e into main Nov 15, 2026
6 checks passed
@morluto
morluto deleted the refactor/cli-contract-native-call-document branch November 15, 2026 12:37
@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