Skip to content

refactor(webarena): pass Map ports through the contract and move the host alias to its owner - #168

Merged
lanyue-llk merged 3 commits into
mainfrom
refactor/webarena-host-port-literals
Nov 3, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
refactor/webarena-host-port-literals

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #154

Part of #87. Follow-up found during this work: #167.

Summary

Every issue item was checked against the current code and still applied.

Map container ports

  • topology.json now holds the ports used inside the Map container: Rails 3000, Nominatim 8085 and the detail service 8091.
  • map_setup.py cannot read the registry in the upstream image, so it reads these ports from the Map component of the mounted delivery contract. It also takes the 8080 browser-asset check from the contract's existing service_port.
  • map_setup.py passes the Nominatim and detail ports to map_detail.py as required --port and --nominatim-port arguments. map-bootstrap.sh needs no change.
  • verify_deployment_contract rejects a contract whose local_services differ from the registry.

Docker host alias

  • environments/browser.py extra_hosts now uses CONTAINER_HOST_ALIAS from the topology module.
  • Both fixture servers build their origin with a new topology.container_host_origin.
  • The public replay only gains that one import from the topology module, which it already uses elsewhere. It shares no report target or denominator with the curated suite.

Generated values do not change. New tests pin the Apache configuration, the detail-service command, extra_hosts and both fixture origins to the previous literal values.

Deployment note: the contract and both Map scripts must be mounted from the same revision. A contract without local_services now stops map_setup.py with a KeyError before any download starts.

Hash-bound files

None of the changed files needed to be left alone:

  • Their pre-change SHA-256 values do not appear in any file tracked at the base commit.
  • In the local data home (~/.browser-eval), I searched the plain-text files in evidence, datasets, reference-inputs, implementations, builds, reviews, runtime, build-cache and report-builds. I did not search private-originals, vm or toolchains, and I did not open archives. evidence/current does not exist on this machine and WEB_FETCH_EVIDENCE_DIR is not set, so the search covered evidence/research and no current evidence.
  • One old hash has a match there: the pre-change map_detail.py hash is in the harness_files snapshot of three historical pre-call contracts from one Web Fetch research cohort. No other changed file's old hash appears.
  • That snapshot is not verified, so this PR does not invalidate it. It lists 246 files from an older commit. At the base commit, 197 of them already differ and 24 no longer exist. Nothing in the repository or in lexbench_webfetch reads harness_files. The contracts are not changed.
  • None of them is in the HASH_BOUND list in tests/test_explicit_utf8_io.py or in collection_implementation.

Not changed

  • Recorded host.docker.internal URLs in frozen trajectories and profiles stay as recorded.
  • 127.0.0.1 and localhost stay in the two Map scripts, because only the ports move to the contract.
  • The top-level harness import in map_setup.py is unchanged. With only the standard library (python -I -S) the script stops with ModuleNotFoundError, and fix(webarena): mounted map_setup.py imports the harness package #167 tracks that because this PR must not change behaviour.

Test plan

Local, Python 3.11 from the shared locked environment:

  • Lint gate: both ruff check commands pass.
  • pytest tests/environments tests/test_golden_reports.py tests/trajectory_replay tests/test_webarena_state.py tests/test_explicit_utf8_io.py -n 2: 2357 passed, 5 skipped.
  • Golden report snapshots are unchanged, with no regeneration.
  • New test runs the mounted map_detail.py with -I -S against a stub Nominatim on the ports it was given. Adding a harness import to the script makes it fail.
  • New tests run map_setup.main with the repository contract and check the values each step receives, in order. Misspelling local_services or service_port, or dropping the detail command, makes them fail.
  • New test runs map_setup.py as a script with a contract that lacks local_services: it exits 1 with the KeyError and creates nothing under --root.
  • New negative controls cover contract port drift, a Rails port that does not match the Apache configuration, and the browser-asset check following service_port.
  • Not run: the changed scripts against the real upstream Map image.
  • CI is the full-suite gate.

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

No findings in this 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

Reviewed head d2e73d1a against base a239d1cc. Two P2 findings, both test coverage. I found no defect in the production code.

Findings

P2: the mounted-script test does not check that the script runs alone

tests/environments/test_webarena_map_detail.py:99 (docstring at line 78)

Problem: The docstring says the container has "neither this package nor the topology registry", and the PR test plan cites this test. But -I only ignores PYTHONPATH, user site and the current directory. It keeps the venv's site-packages, where the project is installed, so harness still imports.

I added from harness.web_fetch.safety import unlinked_path, write_new_file to map_detail.py, which is the same import #167 reports for map_setup.py. The test still passed (1 passed). python -I map_setup.py --help also succeeds in this environment, so the same check would not catch #167 either.

Fix: Run the script with -I -S. map_detail.py --help works that way, because it only needs the standard library, and map_setup.py --help then fails with ModuleNotFoundError: No module named 'harness'. Please also correct #167's suggested test, which recommends the same -I approach.

P2: no test covers the __main__ wiring from contract to scripts

src/harness/environments/webarena/map_setup.py:602-603, :613, :615, :626

Problem: This block is the only production route from the contract into the scripts, and nothing runs it. The helpers are tested only with a literal LOCAL_SERVICES dict or an explicit port. I changed the keys to component["local_servicez"] and component["service_portz"], and test_webarena_map_setup.py, test_webarena_topology.py, test_webarena_environment_config.py and test_webarena_env_contract.py all still passed (91 passed). In production, that typo would stop the Map container at boot. The PR also records that the scripts were not run against the real image, so nothing else would catch it before deployment.

Fix: Move the block into main(argv=None), as map_detail.py now does. Add a test that patches setup, configure_*, version_browser_assets and serve, passes the repository's site-delivery-contract.json, and asserts the port, Apache and detail-command values each call receives.

Verified with no defect

  • Generated values: The old and new code produce the same values for the asset check bytes, the Apache ProxyPass and ProxyPassMatch lines, the Nominatim lookup URL, the detail bind address, extra_hosts and both fixture origins. The new tests pin these to the previous literals.
  • Scope of Closes #154: Both issue items are done.
    • No literal service port remains in map_setup.py or map_detail.py.
    • host.docker.internal no longer appears in code outside the WebArena owner. It remains only in comments in webarena/runtime.py, which is inside the owner.
    • map-bootstrap.sh does pass no ports, so it needs no change, and no other caller starts map_detail.py.
  • Hash bindings:
    • The pre-change SHA-256 of each production file in the diff has no match in evaluation, research, configs, deploy, src, tests or examples, or in the JSON under the local evidence directory.
    • The canonical JSON hashes of the contract and topology.json also have no match in the repository paths; I did not search the evidence directory for those.
    • None of these files is in HASH_BOUND or collection_implementation.
  • Public replay isolation: The public runner gains one import from the topology module, which other modules in that package already use. It shares no report target or denominator with the curated suite.
  • Import of the topology module from browser.py: This adds no import cycle in tests. topology.py only pulls in env_file, and python-dotenv is a core dependency. topology.json is in the package data.
  • Deployment check: verify_deployment_contract rejects drift in local_services, and the negative control exercises that.

Tests and CI

  • Lint: both gate commands pass.
  • Local tests: tests/environments, tests/test_golden_reports.py, tests/trajectory_replay, tests/test_webarena_state.py, tests/test_explicit_utf8_io.py and tests/test_remaining_public_boundaries.py gave 2358 passed, 6 skipped.
  • Golden snapshots: unchanged, with no regeneration.
  • CI on this head: all checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".
  • Not run: the scripts against the real upstream Map image, as the PR also states.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1: both findings are fixed and none is disputed.

P2, mounted-script test (21b083e4). test_mounted_script_runs_alone_on_the_ports_it_is_given now runs map_detail.py with -I -S, so only the standard library is available. Adding a harness import to the script now fails the test. map_setup.py --help fails with ModuleNotFoundError under the same flags, which #167 tracks. I corrected the test suggestion in #167 to use -I -S.

P2, untested entry point (c41f6b35). The __main__ block is now main(argv=None), and exit behaviour is meant to stay the same. New tests:

  • A serving run with the repository contract checks the call order and the port, Apache and detail-command values each step receives. It also checks that serve's status is returned.
  • A run without --serve stops after setup.
  • A script run with a contract that lacks local_services exits 1 with the KeyError and creates nothing under --root.

Misspelling local_services or service_port, or dropping the detail command, each fails these tests.

Still not covered:

  • Nothing test-covers the raise SystemExit(main()) line passing serve's status to the process. Replacing it with a bare main() left the tests passing, because they check main's return value and not the process exit code.
  • The scripts have still not been run against the real Map image.

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

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

Reviewed head c41f6b35 against base a239d1cc.

Findings

P3, PR body, "Hash-bound files" section: the evidence check is not supported as written.

  • Problem: the PR says the pre-change hashes do not appear in the JSON files under the local current evidence directory. On the review machine ~/.browser-eval/evidence/current does not exist and WEB_FETCH_EVIDENCE_DIR is not set, so that search covers nothing. A wider search of the JSON and JSONL files under 50 MB in the data home's evidence, datasets, builds, reviews and runtime directories finds the pre-change map_detail.py hash in three historical pre-call contracts. They are from one Web Fetch research cohort and the hash sits in a harness_files snapshot.
  • Impact: none on the code. The snapshot lists 246 files from an older commit, and at the base commit 197 of them already differ and 24 are gone, including map_setup.py. Nothing in the repository reads harness_files, so this change invalidates no check.
  • Fix: correct the section to say the old hash appears only in that unverified historical snapshot, and state which directories were searched. No code change is needed.

Verified

  • Round 1 fixes: the mounted-script test runs with -I -S, and map_setup.main tests check the values passed to each step. #167 now suggests -I -S.
  • Issue scope: no literal service ports remain in map_setup.py or map_detail.py. Outside recorded data, host.docker.internal remains only in comments in webarena/runtime.py. Nothing still calls map_detail.py without its new arguments.
  • Generated values: configure_tiles output from base and head was byte-identical for the same input. The browser-asset check builds the same byte strings for port 8080.
  • Contract: setup only reads archive fields and receipts, so the new local_services key does not affect existing volumes. verify_deployment_contract rejects port drift.
  • Imports: importing topology from browser.py reads no file at import time, adds no cycle, and topology.json is package data.
  • Local runs: both ruff commands pass. tests/environments, tests/test_golden_reports.py, tests/test_webarena_state.py, tests/test_explicit_utf8_io.py and tests/trajectory_replay/public_webarena gave 954 passed, 3 skipped. tests/trajectory_replay and tests/browser_use gave 2426 passed, 5 skipped. Golden snapshots are unchanged.

Not verified

  • The scripts were not run against the real upstream Map image.
  • The hash search skipped files over 50 MB and the data home's implementations, private-originals and reference-inputs directories.
  • CI at time of writing, Tests and static checks / Installation and packaging: pass pass .

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2: the one finding is fixed in the PR body. There are no new commits, so the head stays at c41f6b3 and the code is unchanged.

Fixed: Hash-bound files section (P3). The section claimed a search of the local current evidence directory, but that directory does not exist on this machine and WEB_FETCH_EVIDENCE_DIR is not set. It now says which directories were searched and which were not.

I repeated the wider search and got the same result as the review:

  • The pre-change map_detail.py hash appears in the harness_files snapshot of three historical pre-call contracts from one Web Fetch research cohort. No other changed file's old hash appears.
  • The snapshot lists 246 files. At the base commit, 197 differ, 24 no longer exist and 25 still match.
  • git grep harness_files finds nothing at the base commit or at the PR head, and the lexbench_webfetch package does not read it either.

Disputed: nothing.

@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 3

Reviewed head c41f6b35 against base a239d1cc, which is still the tip of main. No defects found.

What I verified

Issue #154

  • Both items are done. A search of src, scripts and deploy finds host.docker.internal only in comments in webarena/runtime.py, apart from JSON data files, which the search excluded.
  • The two Map scripts no longer hold literal local service ports. localhost and 127.0.0.1 remain, as the PR body says.

Old and new behaviour

  • I ran the base and head versions of configure_tiles on four Apache inputs: plain, already configured, wrong Rails port, and a duplicate catch-all line. The results were identical, including the error cases.
  • I ran both versions of configure_browser_assets on five asset bodies. The results were identical, including the rejected nominatim and osrm URLs.
  • The map_detail.py handler changes only in how it receives the Nominatim origin.
  • main() makes the same calls in the same order. The one intended difference is the earlier KeyError for a contract without local_services, which the PR body discloses.
  • map-bootstrap.sh is the only caller of map_setup.py, and map_setup.py is the only starter of map_detail.py, so the new required arguments reach every route.

Contract and imports

  • verify_deployment_contract compares local_services with the registry. The contract's service_port was already checked against the registry.
  • No import cycle: importing harness.environments.browser loads only the webarena package and topology. python-dotenv, which topology pulls in through env_file, is a core dependency, and topology.json is declared package data.
  • The public replay gains only one import from the topology module, and it already imports that module elsewhere. harness/browser_use/ is not changed.

Hash-bound files

  • The pre-change SHA-256 of each changed file under src and deploy has no match in any tracked file at the base commit.
  • None of those files is in HASH_BOUND or collection_implementation.
  • I did not repeat the data-home search; round 2 reproduced the snapshot figures it relies on.

Test strength
Each of these six mutations made at least one test fail:

  • map_detail.py ignores --port.
  • map_detail.py ignores --nominatim-port.
  • detail_service_command passes the wrong port.
  • The asset check uses a hard-coded port.
  • The Apache detail route uses the wrong port.
  • The asset check drops osrm.

Local runs

  • Both ruff commands pass.
  • tests/environments, tests/test_golden_reports.py, tests/trajectory_replay, tests/test_webarena_state.py, tests/test_explicit_utf8_io.py and tests/test_cowagent_isolation.py: 2362 passed, 5 skipped, 1 failed. The failure is test_worker_runs_from_source_without_an_installed_harness, which is on the known local macOS failure list.
  • Golden snapshots are unchanged, with no regeneration.

CI on this head
All checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".

Standing rules

  • The PR body says Closes #154.
  • The diff adds no internal hostnames, local paths or credentials, and the PR text has no attribution lines.
  • #167 is open and now recommends -I -S.

Not verified

The changed scripts have not been run against the real upstream Map image, as the PR's test plan says. #167 tracks the existing harness import in the mounted map_setup.py. If the pinned image has no harness package, that import stops the script at startup with or without this PR.

lanyue-llk added a commit that referenced this pull request Nov 3, 2026
…host alias to its owner

map_setup.py and map_detail.py run in the upstream Map image without the topology
registry. Their container-local ports now live in the registry, reach the scripts
through the mounted delivery contract and a detail-service command, and
verify_deployment_contract rejects drift between the two.

The Docker host alias in browser extra_hosts and both fixture-server origins now
comes from the topology module. Generated values are unchanged.
@lanyue-llk
lanyue-llk force-pushed the refactor/webarena-host-port-literals branch from c41f6b3 to a482d94 Compare November 3, 2026 16:01

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

No findings in this review.

@lanyue-llk
lanyue-llk merged commit e6d3eaa into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/webarena-host-port-literals branch November 3, 2026 16: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.

Follow-up to #96: remaining WebArena host and port literals

1 participant