Repository navigation
refactor(webarena): derive hosts, ports and site credentials from one topology registry - #130
Conversation
… 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]>
There was a problem hiding this comment.
This review found 7 issue(s), including 7 blocking issue(s).
| "admin1234", | ||
| "test1234", | ||
| "hello1234", | ||
| from harness.environments.webarena.topology import ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
[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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
✅ Re-review complete · b86600c
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
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,TID252andruff 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_callsfrom agit archiveof main8b8aa30fon the test'sRECORDED_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_textmatches main'ssanitize_textexactly, including the length-sorted origin replacement, the order of the host replacements,_BEARERand_LOCAL_PATH.public_origin_replacements()produces the same ten keys as the removed table._HOST_REPLACEMENTSkeeps the old order: alias first, then gateway. - Ordering and types:
SITE_PORTSandSITE_CREDENTIALSkeep their old order (shopping, shopping_admin, reddit, gitlab), so the Browser Use manifest"sites"list is unchanged. The_LEGACY_ORIGIN_REalternation is byte-identical.str(WebArenaSite.X)returns its value becauseWebArenaSiteis aStrEnum, sosite_url(WebArenaSite.SHOPPING_ADMIN, h)giveshttp://h:7780/admin. The newREAD_ONLY_PORTSorder (3000 before 8888) does not affect any consumer: it only feedsby_port.updateand a frozenset. - The Rainbond changes only replace constants.
_wait_siteis 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_portandcontrol_portfor each component) andsrc/harness/environments/webarena/config.py:197-235. - Problem: the contract repeats
service_port80/80/80/8023 andcontrol_port8877. Those values are now owned bySITE_CONTAINER_PORTSandENV_CTRL_CONTAINER_PORTin the registry. The contract also has Map's internal8080, which the registry does not model.verify_deployment_contractnow cross-checksruntime.example.jsonagainst 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, requirecomponent["service_port"] == SITE_CONTAINER_PORTS[site]for mutable sites andcomponent["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:1877and: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.jsonalready records192.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-42and:73-75. - Problem:
_loadchecks onlyportandcontrol_portfor uniqueness. If a later edit lists the same recorded port under two sites, theRECORDED_PORT_SITESdict comprehension keeps whichever site comes last, with no error. That would silently change URL-to-site attribution insuite.py,qualification.pyandwebarena_environment.py, and thebound_calls_sha256guarantees depend on that attribution. - Fix: reject duplicate ports across
recorded_portsand acrossofficial_trace_portsin_load, and extendtest_registry_rejects_shared_portsto cover both.
No P0 or P1 defects found.
…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]>
|
Review round 1 follow-up. All three findings are fixed; none are disputed.
Local checks:
🤖 Generated with Claude Code |
There was a problem hiding this comment.
✅ Re-review complete · 1660ce0
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
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_contractnow requires three things: the registry's container-port keys equal the delivery components, eachservice_portequalsSITE_CONTAINER_PORTS[site], and eachcontrol_portequalsENV_CTRL_CONTAINER_PORT. The registry now carries Map's8080. The parametrized negative controls cover gitlab and mapservice_portand redditcontrol_port, and each asserts the unmodified value first. -
Round-1 P3, report gateway (1660ce0). The gateway now comes from
execution.trusted_source_site_hostsintersected with the registered gateways. The committed profileresearch/browser-use-bridge-inputs/trajectory-run-profile.jsonbinds["192.168.5.2", "host.docker.internal"], so the published local page still names192.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).
_loadnow rejects a duplicate port within one site and a port shared across sites, for bothrecorded_portsandofficial_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;
/adminbefore the bare origin) - the host-replacement order
- the
_LEGACY_ORIGIN_REalternation, which is the same port set UNREBOUND_SOURCE_HOST, which matches the same hostsREAD_ONLY_PORTS- the diagnostics
OFFICIAL_TRACE_PORTS, still separate fromRECORDED_PORT_SITES
The
bound_calls_sha256golden digest and the redaction-equivalence tests both pass. - origin-replacement order (alias first, then gateway;
-
Scope. The PR says "Part of #96" and lists what remains: Map container internals,
host.docker.internalinenvironments/browser.pyand in the fixture-server origins in the two runner modules, and browser images/CDP ports. A grep ofsrc/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".
Issues
Closes #96. Remaining:
map_detail.py(Nominatim127.0.0.1:8085, detail service8091) andmap_setup.py(bakedlocalhost:8080service URLs, Railslocalhost:3000proxy,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.environments/browser.pyextra_hostsand the ephemeral fixture-server origins intrajectory_replay/runner.pyandpublic_webarena/runner.pystill spellhost.docker.internaldirectly.environments/browser.py) are already one browser registry and are left there. The:latesttags inconfig.official_image_references()are only the source tags thatlock_webarena_imagesresolves into digests. Runtime sites always use the digest-pinned lock.Also covers the "plaintext passwords in redaction tables" bullet of #95.
browser_use/publication.pynow builds its secret list from the registry credentials. Artifact Site token logic is unchanged.Summary
src/harness/environments/webarena/topology.jsonandtopology.py. Together they are the single registry for site ports and control ports, container-internal ports (site, env-ctrl8877, initializer readiness8080, Magento Elasticsearch9200), default site credentials, the/adminsuffix, recorded-URL port aliases (reddit4399), official-trace ports (wikipedia8080), and the hosts that recorded frozen inputs. The Colima gateway192.168.5.2now lives in that data file as arecording_gatewaysentry with a provenance note. No Python source mentions it any more.runtime.py:SITE_PORTS,SITE_CREDENTIALS,SITE_URL_SUFFIX,site_url, container host alias, loopback health URLs, Elasticsearch portrainbond.py: containerSITE_PORTS,8877,8080, and the gitlab8023noteremote_runtime.py:READ_ONLY_PORTS,LEGACY_LOCAL_SOURCE_HOSTS, which becomesLOCAL_RECORDED_HOSTS, the inline copy inrevise_method_inputs, andUNREBOUND_SOURCE_HOSTremote_execution.py: the inline nine-host set, nowTRUSTED_RECORDED_HOSTScatalog_contracts.pyTRUSTED_RECORDED_HOSTS, which moves to the registry, and its four importerspublic_webarenasuite.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.pySITE_PORTS, nowOFFICIAL_TRACE_PORTSbrowser_use/publication.py: origin, host and password redaction tablesbrowser_use/runner.pyhostname allowlistwebarena_report.py: gateway proserecorded_portsandofficial_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 makewebarena_environmentrewrite map-internal:8080URLs as Wikipedia origins.verify_deployment_contractnow fails ifruntime.example.jsonports differ from the registry.deploy/webarena/README.mdnames the registry.webarena_verified, so the deployment check, the Rainbond pool, publication and the public suite modules still work in the base install.runtime.pyconverts names toWebArenaSite(SITE_PORTS,SITE_CREDENTIALS), andremote_runtime.pydoes the same forREAD_ONLY_PORTS.topology.jsonis declared as package data.Behavior preservation
tests/environments/test_webarena_topology.pychecks 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.6a2e9d55…), computed by runningrebind_remote_callsfrom agit archiveof main8b8aa30fon 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.sanitize_textoutput 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.load_catalog_inputson the frozen HF catalogwebarena-replay/fc32333d…/definitions/catalog/full-812-v1.jsonwithsuites/full-portable-v1.jsonandsite-map.jsonverifies all 812 rows'bound_calls_sha256with the new registry.tests/test_golden_reports.pyroute hashes are unchanged.Test plan
ruff check --config 'include=["*.py"]' --select F,TID252 .andruff check: passpytest 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 withwebarena_verifiedblocked.build_metaand confirmed that it containsharness/environments/webarena/topology.json. The first CI run failedmake package-checkbecause the JSON was missing from the wheel andwebarena_verifiedwas imported eagerly. Both are fixed in the second commit.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.🤖 Generated with Claude Code