Skip to content

refactor(webarena): derive hosts, ports and site credentials from one topology registry - #130

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/webarena-topology-registry
Nov 2, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/webarena-topology-registry

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Issues

Closes #96. Remaining:

  • Map image internals: map_detail.py (Nominatim 127.0.0.1:8085, detail service 8091) and map_setup.py (baked localhost:8080 service URLs, Rails localhost:3000 proxy, 127.0.0.1:8091). Both files are mounted standalone into the upstream Map container (/opt/map_detail.py, /opt/map_setup.py) and cannot read the registry there, so the ports need to be passed in through the bootstrap command or contract first.
  • Docker host alias outside the WebArena owner: environments/browser.py extra_hosts and the ephemeral fixture-server origins in trajectory_replay/runner.py and public_webarena/runner.py still spell host.docker.internal directly.
  • Browser images and CDP ports (environments/browser.py) are already one browser registry and are left there. The :latest tags in config.official_image_references() are only the source tags that lock_webarena_images resolves into digests. Runtime sites always use the digest-pinned lock.

Also covers the "plaintext passwords in redaction tables" bullet of #95. browser_use/publication.py now builds its secret list from the registry credentials. Artifact Site token logic is unchanged.

Summary

  • New src/harness/environments/webarena/topology.json and topology.py. Together they are the single registry for site ports and control ports, container-internal ports (site, env-ctrl 8877, initializer readiness 8080, Magento Elasticsearch 9200), default site credentials, the /admin suffix, recorded-URL port aliases (reddit 4399), official-trace ports (wikipedia 8080), and the hosts that recorded frozen inputs. The Colima gateway 192.168.5.2 now lives in that data file as a recording_gateways entry with a provenance note. No Python source mentions it any more.
  • Derived from the registry (each old table was removed in this PR, with no aliases left behind):
    • runtime.py: SITE_PORTS, SITE_CREDENTIALS, SITE_URL_SUFFIX, site_url, container host alias, loopback health URLs, Elasticsearch port
    • rainbond.py: container SITE_PORTS, 8877, 8080, and the gitlab 8023 note
    • remote_runtime.py: READ_ONLY_PORTS, LEGACY_LOCAL_SOURCE_HOSTS, which becomes LOCAL_RECORDED_HOSTS, the inline copy in revise_method_inputs, and UNREBOUND_SOURCE_HOST
    • remote_execution.py: the inline nine-host set, now TRUSTED_RECORDED_HOSTS
    • catalog_contracts.py TRUSTED_RECORDED_HOSTS, which moves to the registry, and its four importers
    • public_webarena suite.py / qualification.py / webarena_environment.py: three copies of the port-to-site map plus the origin regex. Also the docker hostname default and the gitlab internal port.
    • public_webarena/diagnostics.py SITE_PORTS, now OFFICIAL_TRACE_PORTS
    • browser_use/publication.py: origin, host and password redaction tables
    • browser_use/runner.py hostname allowlist
    • webarena_report.py: gateway prose
  • The two port maps that disagreed now each have their own field: recorded_ports and official_trace_ports. Each consumer gets exactly the map it used before. The diagnostics map was not merged with the recorded-URL map. A merge would make webarena_environment rewrite map-internal :8080 URLs as Wikipedia origins.
  • verify_deployment_contract now fails if runtime.example.json ports differ from the registry. deploy/webarena/README.md names the registry.
  • The registry is keyed by site name and does not import webarena_verified, so the deployment check, the Rainbond pool, publication and the public suite modules still work in the base install. runtime.py converts names to WebArenaSite (SITE_PORTS, SITE_CREDENTIALS), and remote_runtime.py does the same for READ_ONLY_PORTS. topology.json is declared as package data.

Behavior preservation

  • tests/environments/test_webarena_topology.py checks every derived table against the literal values removed in this PR: ports, read-only ports, local and trusted host sets, the port-to-site maps, the official-trace map, container ports, the origin regex and the unrebound-host regex.
  • bound_calls_sha256: a golden digest (6a2e9d55…), computed by running rebind_remote_calls from a git archive of main 8b8aa30f on recorded calls that cover every recorded host. The test requires the registry-derived host set to reproduce that digest. A negative control drops the gateway and requires the digest to change.
  • Public redaction: the test compares sanitize_text output with the previous implementation, copied into the test, over gateway, alias, loopback, credential, bearer and local-path inputs. It also checks that all four site passwords are still redacted.
  • Frozen catalog: run locally only, not in CI. load_catalog_inputs on the frozen HF catalog webarena-replay/fc32333d…/definitions/catalog/full-812-v1.json with suites/full-portable-v1.json and site-map.json verifies all 812 rows' bound_calls_sha256 with the new registry.
  • tests/test_golden_reports.py route hashes are unchanged.

Test plan

  • ruff check --config 'include=["*.py"]' --select F,TID252 . and ruff check: pass
  • pytest tests/environments tests/browser_use tests/trajectory_replay tests/test_golden_reports.py -n 2: 2392 passed, 5 skipped. This includes a subprocess test that imports the registry's consumers with webarena_verified blocked.
  • Built a wheel with setuptools build_meta and confirmed that it contains harness/environments/webarena/topology.json. The first CI run failed make package-check because the JSON was missing from the wheel and webarena_verified was imported eagerly. Both are fixed in the second commit.
  • Local frozen-catalog verification (812/812 rows), described above
  • Full suite locally: 66 failures, all in Web Fetch / headless / CI-gate modules that this change does not import. That is 52 more than the 14 failures expected on main in this macOS setup. I checked a sample of the extra failures (test_runner_concurrency.py, test_public_call_logs.py, test_selected_native_policy.py) against main's sources in this same checkout and they fail the same way (Historical benchmark source is not recorded in the dataset lock). The other extra failures were not checked against main one by one. Linux CI is the full-suite gate.
  • CI "Tests and static checks"

🤖 Generated with Claude Code

… topology registry

Add src/harness/environments/webarena/topology.json and topology.py as the
single source of WebArena site ports, container ports, default site
credentials and the hosts that recorded frozen inputs. The Colima gateway
(192.168.5.2) moves from code into that data file.

Runtime, Rainbond, remote replay, catalog binding, public WebArena suite,
qualification, diagnostics, Browser Use publication redaction and the replay
report now derive their port maps, origins, recorded-host sets and redaction
tables from the registry. The deployment check rejects runtime templates whose
ports leave the registry.

Tests pin every derived table to the previously hard-coded values, keep a
golden bound_calls_sha256 computed on main, compare public redaction output
with the previous implementation, and add negative controls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 · 2479853

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

"admin1234",
"test1234",
"hello1234",
from harness.environments.webarena.topology import (

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 · high
P1: The new import eagerly loads topology.json, but that file is not included in the package resources: pyproject.toml only includes runtime/*.ini for harness.environments.webarena, and there is no MANIFEST.in. A clean wheel installation with the Browser Use extra therefore raises FileNotFoundError when importing publication (and consequently the report builder); the runner also loads this registry. Add topology.json to the package-data declaration and check these imports from an installed wheel outside the checkout. Source-tree tests do not cover this installation failure.

from typing import Any
from urllib.parse import urlparse

from harness.environments.webarena.topology import TOPOLOGY

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 · high
[P1] Include the new registry in the built package. This import now loads topology.json at module initialization, but pyproject.toml still declares only runtime/*.ini as package data for harness.environments.webarena, and there is no MANIFEST.in or VCS file-discovery build plugin to include the JSON. A clean wheel/sdist installation therefore raises FileNotFoundError when importing this module (also affecting runtime and Rainbond), preventing WebArena startup even with its optional dependencies installed. Add topology.json to that package-data entry and exercise the import from an installed wheel outside the checkout.

from pathlib import Path
from typing import Any

from webarena_verified.types.task import WebArenaSite

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
P2: This eager import makes the formerly dependency-light config, Rainbond, publication and suite modules require webarena_verified, which is only installed by the optional browser-use-eval extra. For example, after the documented base make setup, uv run --frozen python scripts/verify_webarena_env_contract.py now fails with ModuleNotFoundError before checking the contract. Keep the raw registry and string-based tables usable without the optional evaluator, and defer WebArenaSite-dependent conversions to the runtime boundary. Add a base-environment import/contract check; the all-extras tests cannot catch this regression.

return payload


TOPOLOGY = _load(TOPOLOGY_PATH)

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 · high
P1: The registry is loaded unconditionally at import time, but pyproject.toml only includes runtime/*.ini as package data for harness.environments.webarena, and there is no MANIFEST.in or VCS packaging plugin to include this JSON. Consequently, a clean wheel/sdist installation lacks topology.json, so importing runtime/config/Rainbond (even with the browser-use extra installed) raises FileNotFoundError. Add topology.json to the package-data declaration and exercise registry import from the installed wheel outside the checkout.

from typing import Any
from urllib.parse import urlparse

from harness.environments.webarena.topology import RECORDED_PORT_SITES

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 · high
P1: This import now loads topology.json immediately via Path(__file__).with_name(...).read_text(), but the setuptools package-data entry for harness.environments.webarena still includes only runtime/*.ini, and there is no MANIFEST.in including the new JSON. Consequently, a clean built distribution omits the registry and importing this module (and the other migrated consumers) raises FileNotFoundError even with the WebArena extra installed. Add topology.json to that package's package-data and verify an import from an installed wheel outside the checkout.


from harness.distribution import repository_root
from harness.environments.webarena.runtime import (
from harness.environments.webarena.topology import (

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 · high
P1: This import now requires topology.json at module initialization, but the setuptools package-data entry for harness.environments.webarena includes only runtime/*.ini, and there is no MANIFEST.in or VCS file-discovery build plugin to include the new JSON. A clean wheel installation therefore raises FileNotFoundError in topology._load() when importing remote replay (and other topology consumers), although checkout-based tests pass. Add topology.json to package data and verify an import from a wheel installed outside the checkout.

from typing import Any
from urllib.parse import urlencode, urlsplit

from harness.environments.webarena.topology import RECORDING_GATEWAYS

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 · high
P1: Include topology.json in the installed package before importing this registry. topology.py reads that sibling file at import time, but pyproject.toml only includes runtime/*.ini as package data for harness.environments.webarena, and there is no MANIFEST.in supplying the JSON. Consequently, a clean wheel installation raises FileNotFoundError when importing this report module (and the migrated planning/replay modules), even with the WebArena dependencies installed. Add topology.json to the package-data declaration and verify these imports from an installed wheel outside the checkout.

…ional evaluator

Declare topology.json as package data so installed wheels can load the
registry. Key the registry by site name so the deployment check, Rainbond
pool, publication and public suite modules still import without
webarena_verified; runtime converts names to WebArenaSite at its boundary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 · b86600c

No findings in this incremental review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 1

Head reviewed: b86600c9. I checked out the head in a separate worktree and read the full diff against 8b8aa30f.

What I verified

  • Lint gates pass: ruff check --select F,TID252 and ruff check.
  • pytest tests/environments tests/browser_use tests/trajectory_replay tests/test_golden_reports.py -n 2: 2392 passed, 5 skipped. Golden route hashes are unchanged.
  • bound_calls_sha256: I ran rebind_remote_calls from a git archive of main 8b8aa30f on the test's RECORDED_CALLS, using the old trusted host set. It reproduces the test's golden digest, 6a2e9d55…3ed8, so the digest anchor really does come from main. The negative control that drops the gateway changes the digest as expected.
  • Redaction: _frozen_sanitize_text matches main's sanitize_text exactly, including the length-sorted origin replacement, the order of the host replacements, _BEARER and _LOCAL_PATH. public_origin_replacements() produces the same ten keys as the removed table. _HOST_REPLACEMENTS keeps the old order: alias first, then gateway.
  • Ordering and types: SITE_PORTS and SITE_CREDENTIALS keep their old order (shopping, shopping_admin, reddit, gitlab), so the Browser Use manifest "sites" list is unchanged. The _LEGACY_ORIGIN_RE alternation is byte-identical. str(WebArenaSite.X) returns its value because WebArenaSite is a StrEnum, so site_url(WebArenaSite.SHOPPING_ADMIN, h) gives http://h:7780/admin. The new READ_ONLY_PORTS order (3000 before 8888) does not affect any consumer: it only feeds by_port.update and a frozenset.
  • The Rainbond changes only replace constants. _wait_site is untouched (#94), and no Artifact token logic changed (#95).
  • CI on b86600c9: every check passes, including "Tests and static checks" and "Installation and packaging".
  • The "## Issues" section correctly says "Part of #96", not "Closes".

Findings

P2: deploy/webarena/site-delivery-contract.json is a second, unchecked copy of the container port table, and the Remaining list does not mention it

  • Location: deploy/webarena/site-delivery-contract.json:8-70 (service_port and control_port for each component) and src/harness/environments/webarena/config.py:197-235.
  • Problem: the contract repeats service_port 80/80/80/8023 and control_port 8877. Those values are now owned by SITE_CONTAINER_PORTS and ENV_CTRL_CONTAINER_PORT in the registry. The contract also has Map's internal 8080, which the registry does not model. verify_deployment_contract now cross-checks runtime.example.json against the registry but not these fields. The registry and the delivery contract can therefore drift without any error. This conflicts with #96's "single source of truth", and the PR's Remaining list does not disclose it.
  • Fix: in verify_deployment_contract, require component["service_port"] == SITE_CONTAINER_PORTS[site] for mutable sites and component["control_port"] == ENV_CTRL_CONTAINER_PORT. Add a negative-control test. Optionally add Map's container port to the registry so the Map row can be checked too. If you defer this, at least add it to the "Remaining" list.

P3: the report's environment prose reads RECORDING_GATEWAYS[0]

  • Location: src/harness/trajectory_replay/webarena_report.py:1877 and :1884.
  • Problem: the registry entry exists to recognise hosts in historical recordings. Here it also drives the published execution-topology narrative, and by position. If the gateway map is ever empty, the report build fails with IndexError. If a second gateway is added, the page silently describes whichever entry comes first, which may not be the host the reported run actually used.
  • Fix: take the gateway from the report's bound run profile or evidence. For example, research/browser-use-bridge-inputs/trajectory-run-profile.json already records 192.168.5.2. Alternatively, select it by an explicit key instead of index 0.

P3: the registry loader does not reject recorded or official-trace ports shared between sites

  • Location: src/harness/environments/webarena/topology.py:28-42 and :73-75.
  • Problem: _load checks only port and control_port for uniqueness. If a later edit lists the same recorded port under two sites, the RECORDED_PORT_SITES dict comprehension keeps whichever site comes last, with no error. That would silently change URL-to-site attribution in suite.py, qualification.py and webarena_environment.py, and the bound_calls_sha256 guarantees depend on that attribution.
  • Fix: reject duplicate ports across recorded_ports and across official_trace_ports in _load, and extend test_registry_rejects_shared_ports to cover both.

No P0 or P1 defects found.

lanyue-llk and others added 3 commits October 30, 2026 21:32
…gy registry

The site delivery contract repeated each component's container service port
and the env-ctrl control port without any check, so it could drift from the
registry silently. The registry now also owns Map's container port, and
verify_deployment_contract rejects a delivery component whose service or
control port differs from SITE_CONTAINER_PORTS or ENV_CTRL_CONTAINER_PORT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RECORDED_PORT_SITES kept the last site silently when a recorded or official
trace port appeared under two sites, which would change URL attribution and
the bound call digests. The registry loader now rejects a port listed twice
in either field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The local environment page read the first registered recording gateway by
position, which raised IndexError on an empty map and could name a host the
run never used. The page now names a gateway only when the profile's
trusted_source_site_hosts bind exactly one registered recording gateway and
otherwise describes the gateway without an address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 follow-up. All three findings are fixed; none are disputed.

  • P2: the site delivery contract repeated container ports without a check (30d08de). The registry now also owns Map's container port (map.container_port: 8080), so SITE_CONTAINER_PORTS covers every delivered site. verify_deployment_contract now requires the following:

    • The SITE_CONTAINER_PORTS keys equal the delivery components.
    • Each component's service_port equals SITE_CONTAINER_PORTS[site].
    • Each component's control_port equals ENV_CTRL_CONTAINER_PORT.

    Negative controls: test_deployment_contract_rejects_delivery_ports_that_leave_the_registry covers gitlab service_port, map service_port and reddit control_port. Mutability now governs only credentials; a mutable site still needs a container port.

  • P3: the gateway was read by position (1660ce0). The local environment page now takes the gateway from the run profile's execution.trusted_source_site_hosts, which already binds the hosts a run used. It names an address only when exactly one registered recording gateway is in that list. Otherwise it describes the gateway without an address, so an empty or multi-entry map no longer raises an error or names the wrong host. Test: test_local_environment_page_names_the_profile_bound_site_gateway covers a bound gateway, no hosts, and only unregistered hosts. The Rainbond path and the golden route hashes are unchanged.

  • P3: a recorded port could be attributed to two sites (a80a03a). _load now rejects a port that is listed twice or under two sites, in both recorded_ports and official_trace_ports. Test: test_registry_rejects_ports_attributed_to_two_sites, parametrized over both fields.

Local checks:

  • The ruff gates pass.
  • tests/test_golden_reports.py tests/environments tests/trajectory_replay tests/browser_use gave 2397 passed and 5 skipped. One test failed under -n 2: test_playwright_tool.py::test_playwright_backend_executes_portable_and_snapshot_ref_calls. It passes when run alone and is not in the code this change touches.

🤖 Generated with Claude Code

@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 · 1660ce0

No findings in this incremental review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 2

Head reviewed: 1660ce0f. No defects found.

What I checked:

  • Round-1 P2, delivery contract ports (30d08de). The fix is in place. verify_deployment_contract now requires three things: the registry's container-port keys equal the delivery components, each service_port equals SITE_CONTAINER_PORTS[site], and each control_port equals ENV_CTRL_CONTAINER_PORT. The registry now carries Map's 8080. The parametrized negative controls cover gitlab and map service_port and reddit control_port, and each asserts the unmodified value first.

  • Round-1 P3, report gateway (1660ce0). The gateway now comes from execution.trusted_source_site_hosts intersected with the registered gateways. The committed profile research/browser-use-bridge-inputs/trajectory-run-profile.json binds ["192.168.5.2", "host.docker.internal"], so the published local page still names 192.168.5.2, and the golden route hashes are unchanged. An empty list or a list without a registered gateway falls back to unnamed prose without raising. The new test covers all three cases.

  • Round-1 P3, shared recorded ports (a80a03a). _load now rejects a duplicate port within one site and a port shared across sites, for both recorded_ports and official_trace_ports. The site port must appear in both lists. Tests are parametrized over both fields.

  • Behavior preservation, by reading the code. Each derived table matches the removed literals:

    • origin-replacement order (alias first, then gateway; /admin before the bare origin)
    • the host-replacement order
    • the _LEGACY_ORIGIN_RE alternation, which is the same port set
    • UNREBOUND_SOURCE_HOST, which matches the same hosts
    • READ_ONLY_PORTS
    • the diagnostics OFFICIAL_TRACE_PORTS, still separate from RECORDED_PORT_SITES

    The bound_calls_sha256 golden digest and the redaction-equivalence tests both pass.

  • Scope. The PR says "Part of #96" and lists what remains: Map container internals, host.docker.internal in environments/browser.py and in the fixture-server origins in the two runner modules, and browser images/CDP ports. A grep of src/ for the gateway, the alias and the WebArena port literals found nothing beyond that list and comments. That is consistent with "Part of", not "Closes".

  • Local runs. Ruff gates pass. pytest tests/environments tests/browser_use tests/trajectory_replay tests/test_golden_reports.py -n 2: 2398 passed, 5 skipped.

  • CI on 1660ce0f. All checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".

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.

Use a single registry for WebArena hosts, ports and site credentials

1 participant