Skip to content

Run WebArena catalog loops as backends of the shared replay loop - #383

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/catalog-backends
Nov 25, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/catalog-backends

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Finishes #339. The WebArena-Verified catalog loops now run as execution backends of the shared Trajectory Replay loop. The catalog's two evaluation steps are registered evaluator kinds.

flowchart TD
  L["core/runner.replay_attempts<br/>task / engine / retry order"]
  L --> D["run_replay: Docker engines<br/>(curated, public WebArena)"]
  L --> LB["catalog_runner.LocalBrowserBackend<br/>local process, setup recovery, watchdog, restart"]
  L --> HB["catalog_runner.HostedBrowserBackend<br/>forked watchdog, credential redaction"]
  L --> C["remote_execution cohort<br/>one local browser, no retry"]
  L --> S["webarena_replay suite<br/>Docker sites per method, one logical attempt"]
  LB & HB & C --> T["remote_execution.run_replay_task"]
  T --> R["EvaluatorRegistry"]
  R --> RA["retrieval_acceptance"]
  R --> CA["catalog_acceptance"]
Loading

What moved

  • core/runner.py: new replay_attempts(tasks, engines, run_attempt, max_retries, record) is the one attempt loop. run_replay uses it in place of its inline loop.
  • catalog_runner.py: the local and hosted loops became LocalBrowserBackend (a context manager that starts and stops the browser) and HostedBrowserBackend. Both run through replay_attempts. A restart after a poisoned or dead runtime now happens at the start of the next task. That is the same point in the sequence as before, after the progress record and before the next row binding.
  • remote_execution._execute_cohort and webarena_replay.run_replay_suite run their tasks through replay_attempts (one engine, max_retries=0). The suite's one clean retry is still part of its logical attempt, so both physical executions keep binding to one result. The suite's per-method body is now a local run_method function, with the same indentation and no loop-variable closures.
  • New catalog_evaluators.py registers retrieval_acceptance (answer from current-run observations under the frozen contract) and catalog_acceptance (official WebArena-Verified scoring through a registered correction, plus live-page assertions) in core/evaluators.EVALUATOR_KINDS. run_replay_task scores through EvaluatorRegistry(benchmark=...).
  • core/evaluators.py, all instance-neutral: TaskEvidence gains trace, page_checks, run_id and attempt_id. TaskEvaluation gains record, the persisted evaluator result. EvaluatorRegistry forwards any evaluator options.
  • webarena_replay._run_one keeps its own evaluation. Its state-contract and unsupported-payload handling differs from the remote path, and it has no offline characterization of the retrieval branch.

Nothing was removed. No command was renamed or removed, so there are no breaking changes.

Proof of behaviour preservation

The first commit adds tests/baselines/test_trajectory_replay_execution.py and trajectory-replay-execution.json on unchanged main. They drive each loop with fake browser processes, a hosted CDP transport, BrowserTool and service, a Docker client and an evaluator. They snapshot the ordered calls with their arguments, the progress, receipt and result files, stdout, and the evidence fields:

  • catalog local: pass, setup failure then restart, poisoned runtime, dead browser, failure after evidence, watchdog timeout
  • catalog hosted: forked worker, setup retry, watchdog timeout, endpoint and token redaction
  • remote cohort
  • Docker-site suite: two methods, method-scoped site preparation, a failed attempt with its retry
  • run_replay_task in six cases: pass, retrieve, insufficient retrieval, step failure, evaluator error, correction with failing assertion

The second commit (the refactor) keeps this snapshot byte-identical. Its only test change moves one monkeypatch target, evaluate_corrected_contract, to the new evaluator module. A mutation check confirmed the baseline catches a changed restart condition. Every other baseline is unchanged.

Hash bindings

  • scripts/run_remote_three_method_cohort.py is untouched, and cohort_reference_hashes keeps the same keys and files.
  • The bound files remote_execution.py (runner, remote_execution) and webarena_replay.py (replay_logic) did change. These hashes are recorded in each cohort receipt at run time and compared only within that run, before against after. No current authority (webarena_results, profiles, tests) compares them with checkout bytes. Existing receipts and published reports still verify. New cohort runs will record new source hashes, as they would for any code change.
  • core/runner.py and catalog_evaluators.py are not added to the cohort's bound sources, because that would change the receipt format.
  • The scorer identity (lexbench-webfetch version) is unchanged: no scoring sources were touched.

Allowlists

Layering and instance-literal allowlists are unchanged. No entry was added and none applied.

Verification

  • make lint-check: pass
  • uv run --frozen --all-extras python -m pytest tests/baselines tests/trajectory_replay tests/test_architecture_layering.py tests/test_architecture_instance_literals.py tests/test_env_file.py tests/test_webarena_state.py -n 8 --dist worksteal: 1893 passed, 4 skipped

Live validation still recommended

This is live execution code. The offline proof covers the loop and evaluator wiring with fakes, not real WebArena sites or browsers. Before the next formal cohort, an operator should run a small diagnostic catalog replay on the deployed sites, for example:

uv run --frozen webstone trajectory-replay catalog-run --site-map <sites.json> --site-reset-receipt <receipt.json> --environment-profile <environment.json> --engine chromium --binary <chromium> --cowagent <CowAgent checkout> --output <new dir> --task-id <id> --task-id <id>

Check the resulting progress.jsonl and task-*/ evidence against a run of the same tasks from the previous release.

Closes #339

@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 · 589331c

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

Comment on lines +42 to +44
from harness.trajectory_replay.catalog_evaluators import catalog_task
from harness.trajectory_replay.core.evaluators import EvaluatorRegistry, TaskEvidence
from harness.trajectory_replay.core.runner import replay_attempts

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
The extracted execution and scoring code is no longer covered by the cohort's source-integrity check. cohort_reference_hashes() still hashes remote_execution.py and the previous supporting modules, but not catalog_evaluators.py, core/evaluators.py, or core/runner.py; certify_cohort() relies on equality of those before/after hashes. Consequently, changing the newly extracted scoring or loop implementation during a cohort leaves this check unchanged and can still produce a certified receipt. Include these modules in the source bindings (with receipt-version handling if necessary), and add an integrity test that changes an extracted source and verifies certification fails.

@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 · 5ef2a2b

No findings in this incremental review.

…loops

Drive the catalog runner (local and hosted browsers), the remote cohort, the
Docker-site suite and one remote task with fake browsers, transports and
evaluators, and snapshot the ordered calls, attempt files and evidence fields.
…f the shared replay loop

- core/runner.replay_attempts is the one task/engine/retry loop; run_replay uses it.
- catalog_runner: LocalBrowserBackend and HostedBrowserBackend.
- remote cohort and the Docker-site suite run their tasks through the same loop.
- Register retrieval_acceptance and catalog_acceptance evaluator kinds; the remote
  task scores through EvaluatorRegistry. TaskEvidence/TaskEvaluation gain
  instance-neutral trace, page_checks, identity and record fields.
@lanyue-llk
lanyue-llk force-pushed the refactor/catalog-backends branch from 5ef2a2b to b08ac13 Compare November 25, 2026 07: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 · b08ac13

No findings in this review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Owner approved the additive fix for the OCR integrity finding: cohort_reference_hashes now also binds core/runner.py (replay_loop), core/evaluators.py (evaluator_registry) and catalog_evaluators.py, so editing the shared loop or evaluators during a cohort run blocks certification (before/after must match). Old receipts verify unchanged because webarena_results checks named keys only; new receipts gain three entries (execution baseline refreshed accordingly). Test: test_cohort_reference_hashes_cover_the_shared_replay_loop_and_evaluators.

@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 · 5570b36

No findings in this incremental review.

@lanyue-llk
lanyue-llk merged commit 082216b into main Nov 25, 2026
10 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/catalog-backends branch November 25, 2026 07:10
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.

Trajectory Replay: one pipeline for the curated, catalog and public WebArena benchmarks

1 participant