Skip to content

feat(cli): validate a browser scenario without launching a browser - #7149

Closed
z2Ace0107 wants to merge 1 commit into
morluto:mainfrom
z2Ace0107:feat/5488-browser-scenario-validation
Closed

z2Ace0107 wants to merge 1 commit into
morluto:mainfrom
z2Ace0107:feat/5488-browser-scenario-validation

Conversation

@z2Ace0107

Copy link
Copy Markdown
Contributor

feat(cli): validate a browser scenario without launching a browser

Summary

Fixes #5488.

validate-browser-scenario INPUT_JSON
  parseCliJsonInput                      # inline JSON, file path, or '-'
  resolveCliJsonPaths                    # same operator-relative resolution as capture
  browserScenarioSchema.safeParse        # the exact schema capture admits
    ├── reject → projected input error with field paths
    └── accept → { valid: true, actions, secrets }   # no provider, no browser

Problem and expected behavior

A browser scenario carries actions, selectors, storage seeds and secret
references. Today the only way to learn that a scenario is invalid is to run
capture-browser-scenario, which has already resolved a provider by the time
the schema is checked. Issue #5488 asks for a validation-only workflow that
reuses the same canonical schema and semantic validation but stops before
browser discovery, launch, attachment, or navigation.

Change and scope

validate-browser-scenario shares the capture command's input path exactly: the
same parseCliJsonInput, the same resolveCliJsonPaths for
browser.executable_path, and the same browserScenarioSchema refinement.
Duplicate or reserved step IDs, duplicate secret identities and
environment-variable names, undeclared secret references, request-step
violations, and unknown fields are therefore rejected here with the same field
paths capture reports, so a correction made here is the correction capture
needs. Failures reuse analysisInputErrorFromIssues, so the reported operation
stays capture_browser_scenario.

Deliberately not included: no new MCP operation (CLI-only command); no read of
secret environment variables, so a scenario whose declared variables are unset
still validates, because the missing-value failure belongs to capture; no check
that the browser executable or CDP target exists on the host. The scenario
contract itself (src/domain/browserScenario.ts) is unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI adapter boundary
    (src/cliBrowserScenarioCommands.ts); the scenario contract owner is untouched.
  • Contribution scope fit and linked maintainer decision: not applicable — this
    stays inside the existing CLI adapter and the existing scenario contract, and
    involves no target execution, injection, mutation, or protection recovery.
  • CLI and MCP/tool-catalog contract: adds validate-browser-scenario to
    CLI_COMMANDS. No MCP tool, no catalog operation, no input/output schema change.
  • Provider, bridge, target-format, or platform compatibility: none. No provider
    is constructed and Playwright is not imported.
  • Evidence, artifact, provenance, or reconstruction contract: none; no Evidence
    is produced.
  • Generated metadata (docs/public/product-catalog.json): generated and
    validated by CI; not committed here.

Expected effects (checked): documentation or usability only; no target
interaction.

Evidence and regression coverage

  • Tests added: tests/boundary/cli/browserScenarioValidation.test.ts, 7 cases —
    valid scenario, declared secrets counted without resolution, duplicate step
    identity, reserved initial step identity, undeclared secret reference,
    unknown field, unreadable input file.
  • Base reproduction: before this change there was no validation-only entry
    point; the schema was only reached after provider resolution.
  • Mutation evidence (each new case against one deliberate production change):
    constructing a provider — killed; counting only resolved secrets — killed;
    dropping the step-ID uniqueness assertion — killed; dropping the
    undeclared-secret check — killed; relaxing the strict request object — killed;
    disabling the reserved-step check — killed. 6/6 killed.
  • User-visible output: {"valid":true,"actions":1,"secrets":0} on success; the
    projected input error with field paths on failure.
  • Remaining proof gaps: the acceptance lane and the dist/-dependent
    catalog/identity suites were not run for this change; --project cli-boundary
    has 110 pre-existing failing files on this Windows host, verified identical on
    unmodified main, and this change adds one passing file and no new failure.

Validation performed

  • vitest run tests/boundary/cli/browserScenarioValidation.test.ts — 7 passed
  • mutation check (6 mutations) — 6/6 killed
  • npm run verify:test-discovery — 2484 files discovered exactly once
  • npm run verify:module-boundaries — 3059 source files checked
  • oxfmt --check . — all matched files correctly formatted
  • oxlint on the four changed files — no new findings
  • vitest run --project cli-boundary — 110 failed / 34 passed / 35 skipped,
    against 110 failed / 33 passed / 35 skipped on unmodified main

Compatibility, safety, and release

  • Breaking changes or migration steps: none; the command is additive.
  • Real Hopper/Ghidra, browser, or OS coverage: none required — no browser is
    launched and no provider is constructed.
  • Package or release metadata impact: CLI_COMMANDS grows by one entry; the
    generated product catalog picks it up in CI.
  • Security, privacy, process, or containment review: no secret values are read
    or printed; validation reports counts and field paths only.

Author readiness

Human owner: @z2Ace0107

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

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change reaches the browser-scenario CLI workflow.

The PR appears safe to merge; the unused test provider is a non-blocking cleanup.

Findings

  1. P2 Unused provider checks nothing ▶
Fix with agent prompt
### Issue 1
tests/boundary/cli/browserScenarioValidation.test.ts:36-47
The `provider` in `registerValidatingCli` is never passed to the command, so its methods cannot catch a regression. The extra setup makes the test look like it checks more than it does. Remove this object, `void provider`, and the now-unused imports and `providerIdentity`. Keep the throwing `createProvider`, which actually guards against browser startup.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds validate-browser-scenario to check scenario JSON without starting a browser.

  • The CLI checks browser scenarios without starting browser work.

z2Ace0107 explicitly states that validation errors retain capture_browser_scenario as their operation; this was treated as intentional.

Tests were not run during this review. Supersession and existing GitHub review threads could not be checked because GitHub authentication was unavailable.

Reviews (1) · Last reviewed commit: "feat(cli): validate a browser scenario w..." · Reviewed by Greptile

Comment on lines +36 to +47
const provider: BrowserScenarioCapturePort = {
identity: () => providerIdentity,
captureScenario: async () =>
err(
new AnalysisCapabilityUnavailableError(
providerIdentity.id,
"capture_browser_scenario",
"validation must not reach a provider",
),
),
close: async () => undefined,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Unused provider checks nothing

The provider in registerValidatingCli is never passed to the command, so its methods cannot catch a regression. The extra setup makes the test look like it checks more than it does. Remove this object, void provider, and the now-unused imports and providerIdentity. Keep the throwing createProvider, which actually guards against browser startup.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/cli/browserScenarioValidation.test.ts
Line: 36-47

Comment:
**Unused provider checks nothing**

The `provider` in `registerValidatingCli` is never passed to the command, so its methods cannot catch a regression. The extra setup makes the test look like it checks more than it does. Remove this object, `void provider`, and the now-unused imports and `providerIdentity`. Keep the throwing `createProvider`, which actually guards against browser startup.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for the validation-only workflow. #7116 also addresses #5488, but proposes a --dry-run on capture and checks secret availability, whereas this adds a separate command and leaves that check to capture. Could you coordinate with the other contributor on the intended interface and validation scope before the implementations diverge further? Both proposals remain open.

gensokyo-dev added a commit that referenced this pull request Oct 27, 2026
Add validate-browser-scenario for offline schema and semantic checks of inline JSON, local files and stdin. Return compact validity/action/secret counts without reading secret values or discovering, launching, attaching to or navigating a browser.

Execution and validation share CLI input admission and the canonical domain schema. Preserve existing capture lifecycle, diagnostics, cancellation and caller-relative executable paths.

Integrates #7149 with attribution. Fixes #5488. Validation includes 24 focused tests, static/build/docs checks, and the preserved real PocketBase scenario with its backend stopped and secret variables unset. Verification and resource/token measurements are recorded in docs/verification/browser-scenario-validation-2026-10-27.md.

Co-authored-by: Ace <[email protected]>
@z2Ace0107

Copy link
Copy Markdown
Contributor Author

Closing as superseded by an upstream implementation of the same command.

d109a3910 ("feat(cli): validate browser scenarios offline", #7343) landed on
main on 2026-10-27 and adds validate-browser-scenario with the same contract
this PR targets: the same browserScenarioSchema refinement shared with
capture-browser-scenario, the same {valid, actions, secrets} reply, and no
provider construction or secret resolution. That version also accepts stdin and
factors the shared input parsing into one helper, so there is nothing here worth
rebasing onto it.

Note the linkage: this PR addressed #5488, while the merged work references a
different issue, #7343. Both describe the same validation-only workflow, so
#5488 may still be worth closing against d109a3910 for whoever tracks it.

Verification recorded for this branch before closing: 7 boundary tests passing,
6/6 deliberate production mutations killed, verify:test-discovery,
verify:module-boundaries, format and changed-file lint clean, and a
control run showing no new failures against unmodified main. Nothing from this
branch is needed upstream.

@z2Ace0107 z2Ace0107 closed this Oct 28, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands enhancement New feature or request labels Nov 23, 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add a validation-only command for browser scenario files

2 participants