Skip to content

refactor(cli): project endpoint comparison and browser scenario documents with delivery options - #10711

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

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

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Next slice of plan W1, stacked on #10700 (base refactor/cli-contract-native-call-document; retarget as the lower PRs merge). Refs #10583.

A JSON-document projection can now take the contract's detail and view fields as --detail, --evidence_output and --view beside the document. compare-static-and-observed-endpoints, capture-browser-scenario and validate-browser-scenario are derived from their contracts with it.

Problem and expected behavior

These three commands were the last JSON-document commands outside the contract-document projection, because they take contract fields as flags beside the document:

  • compare-static-and-observed-endpoints imported the facts schema separately from its contract. It parsed --view with a private delivery schema and a hand-written superRefine.
  • capture-browser-scenario and validate-browser-scenario advertised browserScenarioSchema directly and resolved browser.executable_path through their own helper.
  • A detail or view key inside the document was refused only as an unrecognized key, without naming the option to use.

Expected behavior is unchanged apart from these refusal messages: the same arguments and options, the same delivery defaults (--detail complete), and the same services.

Change and scope

  • contractCliDescription.ts:
    • CliDocumentProjection gains evidenceDelivery and viewDelivery, with the same meaning as on the flag projection.
    • The described command removes those fields from the advertised document, adds them to deliveryOptions, and lists them in flagged.
    • documentRefusals gives each omitted or flagged field its refusal, for example detail is not accepted in the document: pass --detail beside it.
    • admitDelivery decodes --view and admits it with the contract's own view schema. A page needs --detail summary, and summary needs --evidence_output.
    • A projection that omits and flags the same field, or that gives two parameters one CLI key, throws when it is described.
  • contractCommand.ts: renders the delivery options and admits the delivery before the document is read. ContractDocumentContext.delivery carries the admitted choice.
  • staticObservedEndpointsCommand.ts: registered from compare_static_and_observed_endpoints. The service still owns document admission.
  • cliBrowserScenarioCommands.ts:
    • Both commands are registered from capture_browser_scenario, with browser.executable_path as a declared caller path.
    • Validation omits detail and gives the reason.
    • browserScenarioSchema still owns semantic diagnostics, which cite the document as the caller spelled it.
  • Not included:
    • match-native-functions keeps detail inside its document (default summary). Moving it to a flag would change its CLI contract.
    • Recording browser.executable_path's spelling in Evidence (W1 step 7).
    • The open-options and runner work for the remaining flag commands.
  • Contribution scope: not applicable. Execution authority and target selection are unchanged; this only moves the CLI projection.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI document projection now owns delivery options beside a document. Removed: the endpoints command's private delivery schema and refinement, the browser commands' private document parse and path resolution.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract:
    • MCP: unchanged.
    • CLI arguments and options: the names, defaults and --schema documents are unchanged; the browser scenario --schema now also advertises that browser.executable_path accepts a caller-relative path, which the command already resolved.
    • Help text: the endpoints --view description now reads JSON page selection; requires --detail summary and --evidence_output.
    • Refusals: a document detail or view key names its option. A capture-browser-scenario delivery refusal no longer carries the Browser scenario capture failed headline; its code and issues are unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged. Delivery is still refused before Playwright loads or any Evidence bundle is read.

Expected effects (unchanged from the existing commands):

  • 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: the three commands refuse detail (and endpoints view) inside the document, naming the option to use, through the compiled CLI.
    • cliContractCommandParity.test.ts:
      • Each document command's contract fields reach the document, are omitted, or are flagged options.
      • Rendered options equal delivery plus CLI-only options.
      • The three commands are listed.
      • A new block checks delivery admission (complete default, summary with a page, a page with complete, malformed and invalid views, summary without a sink) and the projection invariants.
    • jsonInputStatus.test.ts: compare-static-and-observed-endpoints '{}' --evidence-bundle <missing> is refused for the document's missing fields before the bundle is read. The handler admits the document with ContractDocumentContext.frame, the advertised transport frame, as the hand-written command did. This test fails with that check removed.
    • jsonInputSchema.test.ts: the browser scenario documents declare browser.executable_path as a caller path.
    • Unchanged and passing: staticObservedEndpoints.test.ts (CLI --view, summary, missing sink and invalid view), browserScenarioValidation.test.ts, browserScenarioSummaryCli.test.ts, scenarioCliInputDiagnostics.test.ts, cliJsonCallerPath.test.ts, cliJsonStdinCli.test.ts.
  • Base reproduction: on the base, a document detail key is refused only as an unrecognized key. This is source-derived; the new message assertions cannot pass there.
  • Remaining proof gaps: no real browser run in this change; the browser tests use the injected provider. The capture service call is unchanged.

Validation performed

  • npm run test:focused -- tests/acceptance/applications/staticObservedEndpoints.test.ts tests/boundary/cli/browserScenarioValidation.test.ts tests/boundary/cli/browserScenarioSummaryCli.test.ts tests/boundary/cli/scenarioCliInputDiagnostics.test.ts tests/boundary/cli/jsonInputStatus.test.ts tests/boundary/cli/cliJsonCallerPath.test.ts tests/boundary/cli/cliJsonStdinCli.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/jsonInputSchema.test.ts: 9 files, 376 tests passed.
  • After the frame fix: npm run test:focused -- tests/boundary/cli/jsonInputStatus.test.ts tests/acceptance/applications/staticObservedEndpoints.test.ts: 43 passed; with the frame check removed, the new case failed (1 failed, 41 passed).
  • npm run check:fast: passed.
  • npm run docs:check: passed.
  • npx oxfmt --check on the changed files: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Refusal messages change for document keys the commands never accepted.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change to the processes the commands launch or the files they read.

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-15T06:00:09.349877Z 05ed54d 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 PR appears safe to merge; the previous document-check ordering issue is fixed.

Summary

Moves endpoint comparison and browser scenario commands onto shared contract-derived document registration.

  • Endpoint comparison gets its delivery options from the shared document projection.
  • Browser scenario capture and validation use the shared document projection.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI arguments and options] --> B[Check delivery options]
  B --> C[Read JSON document]
  C --> D[Refuse omitted or flagged fields]
  D --> E{Command}
  E --> F[Check endpoint document fields]
  F --> G[Read selected Evidence bundle]
  G --> H[Service checks sources and compares]
  E --> I[Check browser scenario]
  I --> J[Validate only or capture]
  H --> K[Deliver requested output]
  J --> K
Loading

Reviews (3) · Last reviewed commit: "fix(cli): admit the endpoint comparison ..." · Reviewed by Greptile

@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-document-delivery branch from ce4fa7c to abd18b3 Compare November 15, 2026 01:45
… 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.
…vidence 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.
@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-document-delivery branch from abd18b3 to 05ed54d Compare November 15, 2026 05:58
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto the rebased #10600 (after #10589 merged to main). Main's new rea/provider-failure-classifier lint rule flagged refusedDocumentFieldError(operation, refusals, document: unknown): AnalysisError | undefined as a per-site failure classifier. It isn't one: it reads a caller's decoded JSON document. It now takes document: object, and the call site skips the check when the document is not an object, so the contract still refuses it. Validation: npm run check:fast passed on this branch and at the top of the stack; npm run test:focused -- tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/jsonInputStatus.test.ts tests/boundary/cli/bundleComparisonCli.test.ts tests/boundary/cli/browserCompareJsonFiles.test.ts at the stack top: 606 passed.

@morluto
morluto merged commit e6f1711 into refactor/cli-contract-native-call-document Nov 15, 2026
@morluto
morluto deleted the refactor/cli-contract-document-delivery branch November 15, 2026 07:11
morluto added a commit that referenced this pull request Nov 15, 2026
…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
morluto added a commit that referenced this pull request Nov 15, 2026
… its contract document (#10700)

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

* refactor(cli): project endpoint comparison and browser scenario documents 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

* refactor(cli): project inspect-artifact and extract-artifact with open_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 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