Repository navigation
refactor(replay): move identical report and diagnostics definitions into core - #235
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head b05ab7fb. One P2 finding; no P0 or P1.
Findings
P2: src/harness/trajectory_replay/diagnostics.py:1 and src/harness/trajectory_replay/public_webarena/diagnostics.py:1: stale module docstrings.
Both modules still open with "Rule-based and optional LLM-assisted failure diagnosis." This PR moved all of that code to core/diagnostics.py, so neither module holds rule-based or LLM failure diagnosis now. The curated module holds input and readiness audits, saved-correction audits and the saved-retrieval rescore. The public module holds the Codex repair packet and repair jobs, recorded-outcome audits and the runtime smoke entry point. A reader looking for classify_failure or diagnose_summary is sent to the wrong file.
Fix: change the first line of each docstring to what the module now holds, for example "Read-only audits of curated replay inputs and saved evidence." and "Public WebArena repair-packet, recorded-outcome and runtime-smoke diagnostics." Check the second docstring sentence at the same time, because it describes the code that moved.
What I verified
- AST comparison, base
35bed218against head. At base there were 18 identical definitions inreport.pyand 6 indiagnostics.py. At head only_navand_detail_filenameremain identical, and they read each track's ownPAGESandREPORT_STEM. The other replay modules (runner, metrics, executor, suite, cli) have no identical definitions apart from the__all__in__init__.py. - Byte-level moves. The source of all 6 diagnostics functions and the 13 report functions and classes I compared is unchanged from base.
SUITE_FILTER_JSandEVIDENCE_DIALOG_JSload the same asset files, becausecore/report.pyresolvesASSETStotrajectory_replay/assets. - Stale references. No attribute access,
getattror import reaches the old location of a moved diagnostics name. Report names still imported through the track modules (_annotate_source_marksin tests,SUITE_FILTER_JSintests/package_smoke.py) resolve because those modules really use them. - Deleted test.
tests/trajectory_replay/public_webarena/test_diagnostics.pydiffered from the curated file only in its imports and in lacking the credentials test, so no coverage is lost. - Dead code.
_ratehas no caller.pairedandcohort_commitsare gone from_article_body, and_cohort_commitsis removed.paired_by_modelandbundlesstill have other users.resource_resulthas both callers updated.load_macos_resourceskeeps the macOS-first order and theNoneresults.
- Hash bindings. No hash binding names the changed files. The repository references are ruff per-file ignores, a
configs/report-templates.jsonrenderer path, a README and a test constant. ThePath(__file__)hash sites intrajectory_replay,browser_use,lexbenchandreportingdo not cover the changed modules. - Scope. The curated track stays, as the owner default says.
catalog_runner.pyno longer imports private public-track helpers. I found no missing part of the assigned scope forCloses #103. - Over-design. No new abstraction beyond the two
coremodules the item asks for. - Golden snapshots. No snapshot file is changed.
Local runs and CI
- Both ruff gates pass.
tests/test_golden_reports.py,tests/trajectory_replayandtests/test_resource_accounting.py: 2296 passed, 5 skipped.- CI at this head: Tests and static checks, Installation and packaging, Rendered reference and report checks, and Python 3.11 all pass.
|
Review round 1: Fixed: the module docstrings of Disputed: nothing. |
There was a problem hiding this comment.
✅ Re-review complete · b309953
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Reviewed head b3099535. No P0, P1 or P2 defects. One P3 nit, which does not block merge.
Finding
P3: tests/trajectory_replay/public_webarena/test_report.py:115. test_source_permalink_character_is_annotated_not_removed is byte-identical to the test at tests/trajectory_replay/test_report.py:38. Since _annotate_source_marks moved to core/report.py, both copies test one function, and both reach it through a track module's import. The PR deleted public_webarena/test_diagnostics.py for this same reason.
Suggested fix: delete the public copy and its import, and import _annotate_source_marks from harness.trajectory_replay.core.report in the curated test.
What I verified
- Moved code: my own AST and source-segment comparison against
35bed218covered report, diagnostics, runner, metrics, executor, suite and cli. The 15 moved report definitions and 6 diagnostics definitions match the old curated and public text exactly, andASSETSin core matches the public line. - Remaining copies: only
_navand_detail_filenameare still identical. Leaving them is sound becausePAGESandREPORT_STEMdiffer per track at runtime._ratehad no caller. - Rest of the track modules: no other definition changed, apart from the
resource_result(...)call in each_run_task. - Test deletion:
public_webarena/test_diagnostics.pydiffered from the curated file only in its imports, and the curated file is a superset. The credential test that ran against both modules now runs against core once. - Patch targets:
monkeypatchtargets moved tocore.diagnostics, so they still intercept the real calls. - Dead parameters:
paired,cohort_commits,_cohort_commitsand thesourceparameter ofresource_resultare gone along with all their plumbing.paired_by_modelis still used by its other consumer.load_macos_resourceskeeps macOS first, and each call still runs only when its path is set. - Hash bindings: no file under
evaluation/orresearch/names the changed modules. The non-source references are ruff per-file ignores andconfigs/report-templates.json, and neither carries a hash. Neitherevaluation/norresearch/changed, and neither didconfigs/or any golden snapshot. - Rule compliance: there are no compatibility aliases. Track modules import the moved names only because they use them.
- Docstrings: the round 1 fix is correct, and both module docstrings now describe what the modules hold.
- Issue scope:
Closes #103fits the scope given for this PR. The curated track stays under the owner default.
Results
- Lint: the F,TID252 gate and default
ruff checkboth pass. - Local tests:
tests/test_golden_reports.py,tests/trajectory_replay,tests/browser_useandtests/test_resource_accounting.pygave 2631 passed, 5 skipped. A second run oftests/test_shared_hash_json_helpers.pywith the Lexbench-named test files gave 214 passed. No snapshot was regenerated. - CI on
b3099535: all checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks". The packaging job includes the installed-package smoke test.
|
Review round 2: fixed the one finding, nothing disputed.
Local runs: ruff gates pass; |
There was a problem hiding this comment.
ℹ️ Review skipped · fdbce89
No reviewable content was selected for this run.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 3
Head reviewed: fdbce89, based on current main 35bed21.
No defects were found: no P0, P1, P2 or P3 findings.
What I verified
- Duplicate inventory. My own AST comparison of the base commit found 24 definitions identical between the curated and public report and diagnostics modules: 18 in report, 6 in diagnostics. At head, only
_navand_detail_filenameremain. They read each track's ownPAGESandREPORT_STEM, so keeping them is correct. A scan of every top-level function and class undertrajectory_replay/found no other curated/public duplicate. - Moved code. All 15 moved report definitions and all 6 diagnostics definitions have the same AST as both base copies. No definition kept in a track module changed.
_ratehad no caller.core/report.pyresolvesASSETSto the sametrajectory_replay/assetsdirectory, which holds both shared JS files. - No re-exports. Callers import moved names from core. Track modules import only the names they use, and no test or script reaches a moved name through a track module.
- Deleted test.
public_webarena/test_diagnostics.pyat base held only tests also present in the curated file, with no public-specific case. - Dead code.
paired,cohort_commitsand_cohort_commitsare gone.paired_by_modelandbundlesremain live through other readers._cohort_commitsdid no validation, and_load_evidence_bundlesalways sets the keys it read.- Every
resource_resultcaller is updated, and both runners still useresourcesfor counters and the sampler. load_macos_resourceskeeps the same arguments and the macOS-first order.
- Hash bindings. No committed path or hash binding names the changed modules.
pyproject.tomlandconfigs/report-templates.jsonhold paths only, and thePath(__file__)hash sites do not cover these files. - Import boundary. Importing
core.diagnosticsand the curated audit module loads neitherplaywrightnorwebarena_verified. - Scope. The items in #103 as scoped for this PR are done, and the curated track is kept per the owner default. The
resource_summarydead parameter is left alone and disclosed in the PR body.Closes #103is accurate for that scope. - Earlier rounds. The round 1 docstring fix and the round 2 duplicate-test fix are both in place.
Local runs
- Both ruff gates passed.
tests/test_golden_reports.py,tests/trajectory_replayandtests/test_resource_accounting.py: 2295 passed, 5 skipped, with no snapshot changed.tests/browser_use/test_report_check.py, the Lexbench report runtime and verification tests, andtests/test_shared_hash_json_helpers.py: 175 passed.
CI on fdbce89
All checks pass, including "Tests and static checks", "Installation and packaging", and "Rendered reference and report checks". The PR is mergeable on current main.
…nto core
Move the definitions that are byte-identical between the curated and public
replay modules into trajectory_replay/core/{report,diagnostics}.py and delete
the copies, along with the unused _rate helper and the public diagnostics tests
that duplicated the curated ones.
Remove dead parameters: _article_body's paired and cohort_commits with
_cohort_commits, and resource_result's source. Simplify load_macos_resources to
two conditional calls.
fdbce89 to
41d8de2
Compare
Issues
Closes #103
Summary
An AST and source-text comparison of the curated and public replay modules found 24 definitions with identical code. 22 of them behave the same in both tracks and now live in one place. The curated track stays, per the owner default.
trajectory_replay/core/report.pyholds 16 report definitions (_e,_trace_text,_show,_stat,ComparedValue,_source_referencesand others)._ratehad no caller in either track, so it was deleted instead of moved.trajectory_replay/core/diagnostics.pyholds 6 diagnostics definitions (classify_failure,build_failure_groups,add_llm_diagnoses,diagnose_summaryand their helpers). Callers import from core directly; there are no re-exports._navand_detail_filenamestay in each track. Their code is identical, but they read that track's ownPAGESandREPORT_STEM, so they are not real duplicates.tests/trajectory_replay/public_webarena/test_diagnostics.pyis deleted. It was a copy of the curated test file, and both now test one implementation.Dead code removed in the same change:
_article_body'spairedandcohort_commitsinbrowser_use/report.py, with_cohort_commitsand its plumbing.sourceparameter ofresource_resultincore/docker_runner.py.load_macos_resourcesinlexbench/report.pyis now two conditional calls, macOS first.No hash binding names the changed files. A repository search for their paths finds only ruff per-file ignores,
configs/report-templates.jsonrenderer paths, a README and a test constant, and none of those carries a hash. Thefile_sha256(Path(__file__))bindings do not cover these modules.Remaining definitions shared by the two tracks differ in code, so this PR does not change them.
resource_summaryinenvironments/webarena/runtime.pyhas the same kind of dead first parameter; it was outside this item and is unchanged.Test plan
ruff checkwith the F,TID252 gate and the default config: both pass.tests/test_golden_reports.py: 17 passed with no snapshot regenerated, so rendered curated, public and Browser Use routes are unchanged.tests/trajectory_replay,tests/browser_use,tests/test_resource_accounting.py, the Lexbench report, CLI and verification tests, andtests/test_shared_hash_json_helpers.py, run with the golden tests: 2790 passed, 5 skipped._navand_detail_filenameremain identical.