Skip to content

refactor(trajectory-replay): read replay report text from the catalog - #214

Merged
lanyue-llk merged 1 commit into
mainfrom
refactor/replay-report-catalog
Nov 4, 2026
Merged

lanyue-llk merged 1 commit into
mainfrom
refactor/replay-report-catalog

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #210

Follow-up found during this work: #213 (English shows absent timing samples as 0.0 s).

Summary

The replay report now reads its text from the catalog instead of inline language ternaries. Rendered output is unchanged in both languages.

  • Lookup: catalog_text(path, language) in reporting/locales.py binds t(id, english, **values). English stays inline as source text; other languages read the catalog through the existing translate.
  • Track wiring: a new trajectory_replay/messages.py owns the catalog path and report_text(lang). interpretation.py imports the path from there instead of defining its own.
  • Catalog: messages.json gains 329 semantic IDs such as result.diagnosis.heading and comparison.relation.all_pass, under zh. The interpretation renderer's existing keys are unchanged.
  • Cleanup:
    • Unconditional .replace() rewrites on the dataset, results and environment bodies are gone; those pages render the final text directly.
    • The time formatters are now one _format_ms(value, lang).
    • The duplicate failure-stage and task-type label tables are merged.
  • Policy: failure_matrix.py joins CATALOG_RENDERERS, so inline Chinese there now fails the source-language check.

What stays as it was

  • Chinese left in webarena_report.py: the Chinese-only catalog acceptance renderer and the English-not-generated notice have no language ternaries, so they are out of scope. This is also why webarena_report.py can't join CATALOG_RENDERERS yet.
  • zh conditionals left in place: these only pick paths or evidence fields such as reason_zh, not display text.
  • Two English quirks kept for byte identity:
  • Frozen bindings: none record these files. The base-commit hashes of webarena_report.py, failure_matrix.py and messages.json don't appear under evaluation/, configs/, research/, src/ or tests/. configs/report-templates.json only names the renderer path.

Test plan

  • tests/test_golden_reports.py: 16 passed with no snapshot regenerated, so the replay route hashes did not move.
  • tests/test_golden_reports.py, tests/trajectory_replay, tests/test_report_locales.py, tests/test_source_language_policy.py, tests/test_report_software_versions.py, tests/test_report_browser_interactions.py and tests/test_release_check_base.py: 2388 passed, 5 skipped. After a final line-length fix in the new test file, I reran only that file and the golden snapshots: 23 passed.
  • New tests/trajectory_replay/test_report_messages.py checks that:
    • every lookup has a semantic ID and literal English;
    • each ID has one English source;
    • catalog entries are exactly the used IDs;
    • placeholders are supplied in both languages;
    • no language ternary contains Chinese, with a negative control.
  • One-off differential run, not committed: the base-commit helpers and the migrated helpers gave identical output in 198 calls across both languages. It covers branches the golden fixtures miss, including the legacy notice, supplemental diagnostics, unverifiable and corrected tasks, absent samples and unknown stages. The build function's Rainbond and has_resource_samples branches weren't called directly; a static comparison covers their text.
  • One-off static comparison, not committed: every old zh/en pair maps to a new catalog pair. The only exceptions are the folded .replace() sources and missing , which is now the missing {count} template.
  • ruff check passes in both lint gate modes.
  • The full suite runs in CI; I only ran the targets above locally.

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

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

Head reviewed: b51724a4. No defects found.

Byte identity (base 0565b4ab against head, both run locally)

  • Full build_webarena_replay_report builds in both languages for 12 fixture variants: pass and fail crossed with the default fixture, a non-Rainbond site stack, resource samples present, a declared Playwright backend, unverifiable references and a recorded browser host. Each build has 37 files. Every HTML, CSS, JS and data file matched by SHA-256. Only browser-eval-version.json and report-manifest.json differ, as the checkout's build identity would. Those two were not inspected line by line.
  • Direct helper calls matched in both languages for branches those builds miss: singular and plural failure headings, the failure matrix with unreviewed rows, verdict labels for pass, fail and error, the supplemental diagnostic, the task page with a corrected acceptance, and the legacy notice.
  • A fixture that drops duration_ms raises the same KeyError before rendering on both commits, so it adds no output comparison.
  • _detail_page was covered through the builds, plus reading the diff for its rarer branches. The interpretation-article path was covered only by the curated golden snapshots.

Catalog mapping (my own AST pass over the base source)

  • 236 old zh/en string ternaries map to a new source and catalog pair. The 5 exceptions are expected: the 4 folded .replace() sources and missing , which is now the missing {count} template.
  • Tuple and index-selected label tables also match, apart from four unpaired adjacent strings that are not translations (for example display / visibility, which stays literal). I read the remaining non-string forms, such as dict label tables and nested ternaries, in the diff.
  • messages.json has no duplicate keys. Placeholder names and format specs agree between English and Chinese, apart from verdict.not_passed, whose Chinese text intentionally has no placeholder. 329 dotted IDs are used, as the PR states.

Scope (Closes #210)

  • Neither file has a language ternary containing Chinese left. The remaining zh conditionals pick paths or evidence fields, or preserve the 0.0 s quirk, which the PR discloses and #213 tracks.
  • The Chinese still in webarena_report.py is the Chinese-only catalog renderer and the not-generated notice, which have no ternaries.

Rules

  • No file under tests/golden, evaluation/, research/ or configs/ changed.
  • The base-commit SHA-256 and Git blob hashes of the changed renderer, catalog and locale files appear nowhere in the repository at base.
  • configs/report-templates.json records only the renderer path.
  • No callers of the changed _format_ms signature or FAMILIES shape exist outside these files. No compatibility aliases were added.

Tests

  • ruff check passes in both lint modes.
  • tests/test_golden_reports.py, tests/test_report_locales.py, tests/test_source_language_policy.py and tests/trajectory_replay/test_report_messages.py: 41 passed.
  • tests/trajectory_replay, tests/test_report_software_versions.py, tests/test_report_browser_interactions.py and tests/test_release_check_base.py: 2354 passed, 5 skipped.

CI at b51724a4: all checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
Replace the inline language ternaries in webarena_report.py and failure_matrix.py with t(id, english) lookups. English stays inline as source; Chinese lives in messages.json under stable semantic IDs. Rendered output is unchanged in both languages.
@lanyue-llk
lanyue-llk force-pushed the refactor/replay-report-catalog branch from b51724a to f0aa94b Compare November 4, 2026 03:03

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

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 332084e into main Nov 4, 2026
10 of 12 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/replay-report-catalog branch November 4, 2026 03:22
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.

Replace language ternaries in the replay report with catalog text

1 participant