Skip to content

Browser and WebArena site adapters for the browser tracks - #350

Merged
lanyue-llk merged 3 commits into
mainfrom
refactor/browser
Nov 24, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
refactor/browser

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Browser and WebArena-site knowledge was spread over shared runners, tools and reports as name checks (engine == "kitesurf", site in {"gitlab", "reddit"}) and as several registries that disagreed. This PR gives each browser engine one adapter, and each WebArena site one adapter, and makes shared code read declared data and capability flags.

flowchart LR
    subgraph B["harness/environments/browser/"]
        R["BROWSERS registry<br/>BrowserAdapter + flags"]
        C[chromium.py] --> R
        M[moli.py] --> R
        L[lightpanda.py] --> R
        O[obscura.py] --> R
        K[kitesurf.py] --> R
    end
    P["environments/participants.py<br/>profile_engines, participant_registry"]
    subgraph W["harness/environments/webarena/"]
        T["topology.json<br/>ports, labels, mutable"] --> S["sites.py<br/>WEBARENA_SITES: login, reset, flags"]
    end
    R --> PT[Playwright tool] & CR[catalog runner] & RE[remote cohort] & PR[public replay] & BU[Browser Use runner] & LX[Lexbench]
    P --> BU & RP[replay reports] & BUR[Browser Use report]
    S --> RT[BrowserTool login / ensure_site] & PE[public replay environment] & RC[remote cohort checks] & RB[Rainbond / manager] & REP[report labels]
Loading

What moved / was removed

#321 browser adapters

  • environments/browser.py became the package environments/browser/; BrowserAdapter declares label, capability flags, container image (+ env override), CDP port, version command, local launch command and hosted-CDP hook. Five adapter modules register themselves.
  • Flags replace name checks: multiple_pages, network_reset_cdp, storage_cdp, context_request_cookie_sharing, native_login_form_submit, playwright_har_capture, hosted_default_context, dom_login_readiness, document_observer, layout_publication, viewport_observer, host_resolver_rules, request_bridge, reference.
  • Removed: BROWSER_ADAPTERS, ENGINE_LABELS, DEFAULT_BROWSER_IMAGES, ENGINE_PORTS, the remote_execution._browser_command if-chain, catalog_runner._kitesurf_cdp_config / _probe_kitesurf_runtime / _chromium_host_resolver_rules (now _hosted_cdp_config / _probe_hosted_runtime / _host_resolver_rules), public_webarena.runner.MOLI_VERSION.
  • Engine choices derive from the registry: catalog --engine = all adapters; remote cohort --engine = adapters with the full CDP surface (chromium, moli, as before); public replay --engines default = adapters with a container image.
  • Public replay reads the pinned browser version from its image recipe (ARG <ENGINE>_VERSION in examples/trajectory_replay/public_webarena/docker/<engine>.Dockerfile) instead of a duplicated constant.
  • Qualification browser = the adapter declaring reference (Chromium).
  • Participant parsing (participant_registry, bind_participant, resolve_participant_id, new profile_engines) moved to shared harness/environments/participants.py; Browser Use Participants.from_profile and the replay reports use it.
  • Browser Use runner takes its browsers from the report profile (--profile) instead of a module constant.
  • Lexbench report finds its measured engine as the one adapter declaring layout_publication.

#325 WebArena site adapters

  • New environments/webarena/sites.py: one SiteAdapter per site with form login (public replay), session login (BrowserTool), auto-login header, URL-initialisation mode, Magento/health-check/PHP/baseline/admin-HTTPS flags. Labels (en/zh) added to topology.json; stateful = topology mutable.
  • Removed: _login_shopping/_shopping_admin/_reddit/_gitlab and the per-site reset chain in public_webarena/webarena_environment.py, its STATEFUL_SITES, manager.STATEFUL_SITES, rainbond.STATEFUL_SITES, config.SITES (now sites.SITE_NAMES), per-site branches in runtime.login_context / ensure_site, catalog_contracts site sets, remote_runtime site checks, remote_execution admin checks, browser_use.selection.ALLOWED_SITES literal, browser_use.report.SITE_LABELS literal and hardcoded site filter options, webarena_report._catalog_site_labels map (and its four catalog.site.* catalog entries).
  • bootstrap_postmill_session / bootstrap_postmill_browser_session moved from runtime.py to sites.py.

Breaking changes

  • python -m harness.browser_use.runner (and examples/browser_use/run.sh) now requires --profile <report profile>; BROWSER_USE_PROFILE supplies it to the wrapper. The profile's engines select the browsers, and models must include --model.
  • harness.environments.webarena.config.SITES → harness.environments.webarena.sites.SITE_NAMES.
  • Python names removed/renamed as listed above (no CLI command was renamed).
  • run_replay_task(..., backend="playwright") now requires an explicit engine (no implicit Chromium default).

Allowlists

  • Instance literals: 2 modules / 3 entries → 1 module / 1 entry (harness.environments.browser removed; reporting.visual -> chromium remains). The scan now treats child modules of harness.environments.browser as adapters and takes browser names from BROWSERS.
  • Layering: unchanged (9 modules).

Baselines

tests/baselines unchanged. Scorer identity unchanged (lexbench-webfetch version → scoring_source_sha256 0fe89317…169e).

Hash bindings left as they are

  • lexbench/resource_matrix.py and lexbench/resource_profiles.py still name Moli: their own bytes are bound by frozen protocols (orchestrator_sha256), so they were not edited.
  • scripts/run_remote_three_method_cohort.py untouched. remote_execution.py, remote_runtime.py and webarena_replay.py changed; cohort receipts record their hashes at run time, but nothing verifies them against current source (aggregation verifies manifest/dataset/binary/site-map/reset hashes only).
  • Visual checkers (reporting/visual.py, *report_visual.py) untouched, so existing visual receipts keep verifying.

Not converged (follow-up)

  • Two login protocols per site remain (form login for the public replay, header/session login for BrowserTool): unifying them would change measured behaviour. They now live side by side in each site adapter.
  • Two CdpHarRecorder classes remain: they are not equivalent (different API, redaction of auth headers/cookies, creator name webstone-cdp, Playwright transport). Merging would change recorded HAR evidence.
  • Replay runners other than Browser Use still take participants from CLI/registry defaults (--engines, --engine); the curated WebArena replay already reads methods from its plan.
  • trajectory_replay/report.py still embeds Moli-specific timing prose (MOLI_TIMING_*): report content that belongs in bound content.
  • Site names remain inside environments/webarena/ (config deployment contract, Map setup) — the site-adapter package.

Verification

  • uv run --frozen --all-extras python -m pytest -n 8 tests/trajectory_replay tests/browser_use tests/environments tests/baselines tests/test_architecture_*.py tests/test_source_language_policy.py tests/test_documented_paths.py + Lexbench tests → 2854 passed, 5 skipped (base main: all passing).
  • Every other test file importing harness.environments|trajectory_replay|browser_use|lexbench (35 files) → 985 passed, 1 skipped.
  • make lint-check → clean.

Part of #321 (remaining: replay runners still take participants from CLI/registry, Moli timing prose in the replay report)
Part of #325 (remaining: two non-equivalent login protocols and HAR recorders, see above)

@lexmount-ocr lexmount-ocr Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Review complete · 4988507

This review found 3 issue(s), including 3 blocking issue(s).

return str(self.topology["label"][language])


def _base_url(urls: list[Any] | tuple[Any, ...], label: str) -> str:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · low
Non-blocking: _base_url has no callers anywhere in the Python codebase; WebArenaEnvironment._login still performs this normalization and validation inline. Remove the unused helper, or use it in the shared login path, to avoid maintaining two implementations.


def pinned_image_version(engine: str, root: Path | None = None) -> str | None:
"""Return the version the public image recipe pins with ``ARG <ENGINE>_VERSION``."""
recipe = (repository_root() if root is None else root) / IMAGE_RECIPES / f"{engine}.Dockerfile"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
This makes public replay with Moli (including the default engine set) fail from an installed wheel: repository_root() resolves to the installed package parent, but the Dockerfiles under examples/ are not included in tool.webstone.bundled-data or package data. Consequently this returns None, and _verify_pinned_versions() raises even for the correctly pinned image. Bundle the required recipe and resolve it with bundled_data_path() (or package equivalent pin metadata), and cover version discovery from an installed distribution.

Comment thread tests/architecture/scan.py Outdated
Comment on lines +50 to +51
if any(module.startswith(package + ".") for package in ADAPTER_PACKAGES):
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test · medium
This exemption also disables layering checks for browser adapters: layering_violations() uses is_shared(), and these modules have no own_track, so they are now skipped entirely. An adapter importing a track-specific runner would therefore pass the architecture test, despite remaining part of the shared environments package. Apply the adapter exemption only in instance_literals() so the shared-package import boundary remains enforced.

@lexmount-ocr lexmount-ocr Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Review complete · 5c4c688

This review found 3 issue(s), including 3 blocking issue(s).

return str(self.topology["label"][language])


def _base_url(urls: list[Any] | tuple[Any, ...], label: str) -> str:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · low
This new helper has no callers; WebArenaEnvironment._login still performs URL extraction and validation inline. Remove _base_url, or use it in the shared login path, to avoid retaining an unused second implementation. Non-blocking cleanup.


def pinned_image_version(engine: str, root: Path | None = None) -> str | None:
"""Return the version the public image recipe pins with ``ARG <ENGINE>_VERSION``."""
recipe = (repository_root() if root is None else root) / IMAGE_RECIPES / f"{engine}.Dockerfile"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
This lookup breaks installed-package replay runs that include Moli (including the default engine set). Outside a checkout, repository_root() returns the installation's package parent, but the Dockerfiles are neither package data nor listed in tool.webstone.bundled-data. Consequently this returns None and _verify_pinned_versions() aborts even for a correctly versioned container. Bundle the required recipes and resolve them through bundled_data_path() (or ship equivalent generated version metadata), and cover version lookup from an installed wheel.

Comment thread tests/architecture/scan.py Outdated
Comment on lines +50 to +51
if any(module.startswith(package + ".") for package in ADAPTER_PACKAGES):
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test · medium
This exemption also disables dependency-layer checks for every browser adapter: layering_violations() uses is_shared(), and these modules have no own_track, so they are skipped entirely. An adapter could now import a track-specific runner without failing the architecture test. Keep adapters classified as shared for layering and apply the adapter exemption only in instance_literals().

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Re-review complete · e379e03

No findings in this incremental review.

Each engine (chromium, moli, lightpanda, obscura, kitesurf) is one module in
harness/environments/browser/ declaring its launch command, container image and
CDP port, version command, hosted-CDP hook and capability flags. The Playwright
tool, catalog runner, remote cohort, runtime identity and public replay read
flags and adapter data instead of branching on engine names; engine choices
derive from the registry. Profile participant parsing moves to
harness/environments/participants.py, and the Browser Use runner takes its
browsers from the report profile. The public replay reads its pinned browser
version from its image recipe.
…ul flags

harness/environments/webarena/sites.py declares one adapter per WebArena site:
form and session login, auto-login headers, URL initialisation, Magento,
health-check, PHP, baseline and admin-HTTPS behaviour. Labels live in
topology.json beside ports, and the stateful flag is the topology's mutable
flag. The public replay environment, environment manager, Rainbond slices,
BrowserTool login, remote cohort checks, catalog contracts and both reports read
adapters instead of site-name sets and label maps.
…er layering checks, drop unused helper

Installed public replay runs read the recipe through bundled_data_path. Browser
adapter modules are exempt only from the instance-literal scan; the layering scan
still covers them. The unused WebArena _base_url helper is removed.
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Rebased on main after #345, #349, #351, #346, #348 and #358 (head 47a9b71).

  • Conflict: tests/architecture/scan.py registered_names now combines PROVIDERS.names(), ADAPTERS.names(), METHODS.names() and this PR's BROWSERS.names().
  • OCR round 1 fixes (e379e03), all clean in OCR's re-review:
    1. The pinned Moli recipe ships as bundled data (pyproject + MANIFEST.in), and pinned_image_version reads it through bundled_data_path, so installed public replay works.
    2. Browser adapter modules are exempt only from the instance-literal scan. The layering scan still covers them.
    3. The unused _base_url helper is removed.
  • No golden or baseline refreshes, allowlists unchanged, scorer hash unchanged. Local baselines, architecture, packaging, trajectory, environment and browser-use tests pass (2825).

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Review complete · 47a9b71

No findings in this review.

@lanyue-llk
lanyue-llk merged commit b0f975c into main Nov 24, 2026
10 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/browser branch November 24, 2026 11:09
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.

1 participant