Skip to content

fix: preserve browser environments across action journeys#2099

Merged
chubes4 merged 5 commits into
mainfrom
fix-2091-browser-action-environments
Jul 26, 2026
Merged

fix: preserve browser environments across action journeys#2099
chubes4 merged 5 commits into
mainfrom
fix-2091-browser-action-environments

Conversation

@chubes4

@chubes4 chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • carry canonical browser environments through standalone probes, authored actions, adaptive exploration, and scenarios via the shared Playwright environment adapter
  • give probe-plus-action scenarios one owned context/page so init scripts, storage, auth cookies, permissions, and page state survive phase collection
  • resolve once and create an independently configured context for every multi-actor participant, with actor-level observed evidence and isolation
  • bind adaptive state, oracle findings, minimized replay, and replay identity to the canonical requested environment digest
  • validate inline and @path environments without bypassing existing steps/scenario validation, preserve scenario-over-argument precedence, and reject unknown profiles

Root cause and ownership boundary

wordpress.browser-probe, wordpress.browser-actions, scenarios, and multi-actor scenarios previously owned separate context construction paths. Scenario probe and action phases launched independent browsers, action viewport changes happened after context creation, and multi-actor scenarios always used plain contexts. This lost geolocation/device state and also lost scripts, cookies, storage, permissions, and page state between scenario phases.

The Playwright environment adapter now owns context creation for probes, actions, shared scenarios, matrices, and actors. A scenario that needs both probe collection and actions creates one session and lends the same page to both runners without transferring ownership. Multi-actor runs reuse one resolved environment definition but create and close an isolated context per actor.

Evidence

Action/scenario artifacts now separate:

  • requested: canonical caller declaration
  • resolved: provider-resolved configuration
  • observed: browser-observed viewport, touch, user agent, locale/timezone, online state, permission, and granted coordinates
  • unsupported and inconclusive: dimensions that cannot be applied or independently observed

Adaptive contracts, state digests, finding fingerprints, result replay, and per-finding replay include the canonical environment and digest.

Tests

  • npm run build
  • npm run test:browser-actions-environment
  • npm run test:browser-environment-matrix
  • npm run test:browser-scenarios
  • npx tsx tests/recipe-validation-descriptors.test.ts
  • npm run test:fixture-auth-storage-state
  • npm run test:browser-preview-routing
  • npm run test:public-api-contract
  • npm run test:wordpress-runtime-actions
  • targeted adaptive replay/finding tests via --test-name-pattern

Coverage includes probe/action state continuity under performance collection and pre-page scripts, routed granted/denied/prompt geolocation, auth and storage state, scenario precedence and unknown profiles, malformed JSON validation, valid/invalid/missing @path environments, run isolation, per-actor environment/isolation, unsupported evidence, and environment-bound adaptive identity.

npm run check still reaches the unrelated main-branch registry failure tracked in #1745. The full adaptive umbrella has a pre-existing fixed-delay cancellation race now tracked in #2104; all adaptive replay/finding tests affected by this PR pass.

Compatibility

Existing recipes remain valid. Legacy viewport, profile/device, auth, storage state, and routed preview controls continue to work. Scenario declarations retain precedence over command arguments. Unsupported multi-actor shared pre-page/auth/storage controls now fail before actor launch instead of being ignored. No changelog or version strings were modified.

Fixes #2091

Latest re-review fixes

  • load and validate file-backed steps-json and scenario-json relative to the recipe directory, including evaluate-capability policy derivation
  • execute scenario steps-json=@path instead of silently dropping it
  • treat nested adaptive environment as authoritative and reject conflicting outer declarations
  • verify cookie, localStorage, and imported storage-state isolation across consecutive scenario contexts
  • rebase onto current origin/main, including Fix canonical routed preview origins #2098 preview routing/readiness changes

Final path-consistency fix

  • canonicalize recipe-local file-backed browser payload arguments to absolute paths in recipeExecutionSpec
  • prove validation, evaluate-policy derivation, dry-run planning, and runtime execution use the same files from a different process CWD
  • cover valid and malformed action steps-json, scenario objects, and scenario steps-json

@chubes4

chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all requested review items in c0ae9de and rebased onto current main. Shared scenario context/page continuity, per-actor configured isolation, validation flow, adaptive environment identity, resolved-vs-observed evidence, precedence/profile handling, and expanded compatibility/routing/path tests are ready for re-review. No merge, release, or deploy performed.

@chubes4
chubes4 force-pushed the fix-2091-browser-action-environments branch from c0ae9de to f22389e Compare July 26, 2026 17:50
@chubes4

chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the three remaining re-review blockers in f22389e and rebased onto current origin/main (including #2098). File-backed action/scenario payloads now receive recipe-relative semantic validation and evaluate-policy detection; scenario steps-json=@path executes; nested adaptive environments own context creation and conflict with outer environment args; and consecutive storage/auth/storage scenarios prove cookie and localStorage isolation in both directions. Build, browser actions environment (8/8), recipe validation, browser scenarios, preview routing (6/6), environment matrix (13/13), and fixture auth/storage tests pass. Ready for re-review; no merge, release, or deploy performed.

@chubes4

chubes4 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Final high blocker addressed at ef8e7f5; rebased head is f3e0485 on current main. recipeExecutionSpec now canonicalizes recipe-local file-backed browser action/scenario payload arguments to absolute paths before runtime execution, so validation, policy derivation, dry-run planning, and runtime consume the same files regardless of process CWD. Added a true built-CLI recipe-run integration launched from a separate temporary CWD covering valid action steps, scenario objects, scenario steps, automatic wordpress.browser-actions.evaluate policy, full runtime execution, and malformed validation failures. Passing: build, cross-CWD recipe integration, recipe validation descriptors, browser actions environment (8/8), preview routing (6/6), browser scenarios, and targeted rebased adaptive oracle tests. The unrelated fixed-delay cancellation race remains tracked in #2104. Ready for re-review; no merge, release, or deploy performed.

@chubes4
chubes4 force-pushed the fix-2091-browser-action-environments branch from f22389e to f3e0485 Compare July 26, 2026 18:02
@chubes4
chubes4 merged commit 3f9ca38 into main Jul 26, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser scenarios lose geolocation and device context before actions

1 participant