Repository navigation
feat(browser): validate browser scenarios with --dry-run before launching - #7116
Closed
kaoru0822-kitauji wants to merge 2 commits into
Closed
kaoru0822-kitauji wants to merge 2 commits into
kaoru0822-kitauji wants to merge 2 commits into
Conversation
…hing Checking a scenario file meant running it, which discovers, launches or attaches to a browser and can change page state before a typo surfaces. `rea capture-browser-scenario <json> --dry-run` reuses the same JSON and path resolution, the canonical scenario schema and its semantic rules, and the secret-availability rule capture applies before acquiring a browser, now shared from one domain owner. It returns the same projected input errors, or a compact plan of steps, secret availability and the stages it did not check, and never creates a provider or reads secret values. Fixes #5488 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Low impact] The reviewed changes appear safe to merge; no blocking issues were found. SummaryAdds
Reviews (2) · Last reviewed commit: "docs(browser): fence the dry-run plan ex..." · Reviewed by Greptile |
Every JSON block in the scenario contract guide is admitted as a scenario by the product catalog test; the plan is output, not input. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 25, 2026
11 tasks
13 tasks
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke: The only way to check a browser scenario file was to run it. A run discovers, launches or attaches to a browser and may change page state before a typo, a duplicate step ID or a missing secret variable is reported.
Fix:
rea capture-browser-scenario <json> --dry-runapplies the same JSON and path resolution, the same canonical schema and semantic rules, and the same secret-availability rule as a capture, all through shared owners. It then stops before any provider is created and returns either the same projected input error or a compact plan.Risk: Low. The flag is opt-in. Without it the command is unchanged. The secret-availability rule moved verbatim from
BrowserScenarioSecrets.resolveinto the domain, and capture still uses it.Summary
Fixes #5488
A dry run reports schema and semantic errors with field paths, using the exact projection a capture returns. On success it returns the browser mode, the start origin, every step in capture order, each declared secret with only
environment_value: "present", and an explicitnot_checkedlist. It creates no browser provider, profile, file or connection, and it never reads a secret value into its output.Problem and expected behavior
Change and scope
src/domain/browserScenario.ts: newbrowserScenarioSecretAvailability. This is the presence rule capture applied at session open: the variable must be an own property with a string value, and an empty string counts as set. It is moved fromBrowserScenarioSecrets.resolve, which now calls it and then reads the values, so the rule has one owner and both paths return the same error.src/application/BrowserScenarioCaptureService.ts:planBrowserScenario(scenario, environment)builds the plan from an already parsed scenario.src/cliBrowserScenarioCommands.ts: adds the--dry-runoption. Argument parsing,resolveCliJsonPathsandbrowserScenarioSchemaare the same code path as a capture. The branch returns before the Playwright composition is imported orcreateProvideris called. Failures are labelledBrowser scenario validation failed, with the same projected body.docs/browser-scenario-contract.md, with an example plan.capture_browser_scenarioalready rejects schema-invalid input and missing secrets before acquiring a browser. Executable, endpoint and locator checks are also excluded, because they need discovery or a page; they are listed innot_checkedinstead.Contribution scope: not applicable. This is an opt-in, read-only mode of an existing command that adds no target interaction.
Contract and boundary impact
Semantic owner and earliest changed stage: the scenario schema (unchanged) and the secret-availability rule, now owned by the domain.
BrowserScenarioSecretsis its consumer.Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: the CLI gains
--dry-run. MCP is unchanged.Provider, bridge, target-format, or platform compatibility: none. The dry run never loads Playwright.
Evidence, artifact, provenance, or reconstruction contract: a dry run produces no Evidence. Its plan is not Evidence and claims nothing about the target.
Target selection, authority, upstream behavior, and cleanup details: no browser, profile, process or network access, and nothing to clean up.
Generated metadata, package, or installation impact: none.
metadata:checkpasses.Documentation or usability only; no target interaction.
Evidence and regression coverage
tests/boundary/cli/browserScenarioDryRun.test.ts):createProviderspy that throws: a valid dry run returns the exact plan, the stdout never contains the secret value, and the spy is never called.projectAnalysisError(BrowserScenarioSecrets.resolve(...).error), which is the capture rule's error, at["secrets", 0, "environment_variable"]. An inherited (prototype) variable also counts as missing.errorlabel differs. No provider is created in either mode.BrowserScenarioSecretsproducer tests.BrowserScenarioSecrets.resolverefactor, because no browser is installed on this host. The refactor is covered by the existing producer tests and by the equality assertion above.Boundary regressions: input parsing and projection parity between modes, secret-environment admission (missing, inherited, present) and provider non-creation. There is no lifecycle stage, because no resource is acquired.
Validation performed
npm run test:focused -- tests/boundary/cli/browserScenarioDryRun.test.ts tests/boundary/cli/scenarioCliInputDiagnostics.test.ts tests/boundary/cli/cliJsonCallerPath.test.ts tests/process-global/browserScenarioCleanup.test.ts tests/boundary/mcp/browserScenarioInputDiagnosticsMcp.test.ts: 23 passed.npm run test:local -- src/browser/BrowserScenario.test.ts src/browser/PlaywrightScenarioRequest.test.ts: 51 passed.npm run check:fast: passed.npm run format:check: passed.npm run docs:check: passed.npm run metadata:check: passed.Compatibility, safety, and release
Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code