Skip to content

refactor(web-search): make English the source language of the report - #192

Merged
lanyue-llk merged 3 commits into
mainfrom
refactor/web-search-english-source
Nov 3, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
refactor/web-search-english-source

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 #185

Part of #99 and #120 (each stays open for the other tracks).

Summary

English is now the source language of the Web Search report, and Chinese is only a catalog translation.

  • One lookup. messages.py exposes report_text(source, zh, *, context=None, **values) and zh_text(source, ...). The local t(en, cn) helpers are now partial(report_text, zh=zh), so a call site reads t("Known page@{cutoff}", cutoff=cutoff).
  • English catalog keys. messages.json no longer uses text_<sha256(zh)> IDs. It maps the English source text to Chinese. Chinese sentences that were split into fragments around values are now single templates with named placeholders.
  • context| keys. 18 English labels had more than one existing Chinese wording, such as Method as 方法 or 接口. A context| key keeps each wording, so the bytes do not change. Page navigation labels use navigation|.
  • No inline Chinese left. comparison.py and delivery.py moved to the catalog and joined CATALOG_RENDERERS, so the source-language policy now rejects inline Chinese in them.
  • Dead entries removed. Catalog entries nothing referenced at base are gone, such as text_94ad856f2c0d1003 (非空成功响应耗时). review_failures and review_unreviewed were not dead: review.py used both, and they moved to English keys with the same Chinese values.
  • Zh-only text now has English keys. Examples are the source notes, the relevance annotation page and the source-rule reason. I wrote these keys as new translations of the Chinese. They never render in English.
  • New lint. tests/web_search/test_messages.py fails on a missing or unused key, a non-English key, a placeholder that is not supplied, a placeholder named ids or with a numeric suffix, or inline Chinese in the renderers. Navigation keys come from reader_pages, not a copied list.

Rendered output

Only one golden route changed for web-search: manifest.json. Its renderer_sha256 field hashes report.py, so any edit to that file changes it. Every other route hash is unchanged.

The golden snapshot only builds the synthetic example, so I also compared wider output. I ran tests/web_search against both base 2c8a6947 and this branch, with temp directories kept, and compared every generated file.

  • All 1,187 HTML, JS and CSS files were byte-identical after normalizing the temp root.
  • Other files did differ, such as manifests, run records and review contracts. The samples I inspected differ through timestamps, the build revision, or hashes that depend on them. I did not check all of these file by file.
  • This shows the bytes match only for branches those tests exercise. No real Web Search evidence exists on this machine, so a measured report was not rebuilt.

Left unchanged

  • Bound files. collection_implementation binds runner.py, core.py, adapters.py, profiles.py and shared modules, and scoring_source_sha256 binds src/lexbench_websearch/. None were edited. Of these, only harness/web_fetch/config.py contains Chinese characters. It stays as it is because the binding prevents the edit, and it belongs to the Web Fetch track anyway.
  • Stored reason text. The source-rule reason in relevance.py is written into judge results. Only its key changed; its Chinese value is the same.
  • Chinese punctuation shared by both editions. : in review.py, and 、 and ; in report.py, render in English pages too. Fixing that would change rendered bytes, so it is left for follow-up Stop rendering Chinese punctuation on English Web Search pages #191.

Test plan

All run locally on the final commit:

  • tests/web_search, tests/test_source_language_policy.py, tests/test_golden_reports.py, tests/test_report_locales.py, tests/test_report_software_versions.py and tests/package_smoke.py: 571 passed, 45 subtests passed.
  • Ruff, both the F,TID252 gate and the default config: passed.
  • Base and branch comparison over tests/web_search, as described above: 0 of 1,187 HTML, JS and CSS files differ. This ran before the placeholder rename in 36dd1cb3. For that rename I formatted each of the 5 renamed keys and translations with the old and new names and got the same strings, and the golden snapshots show only manifest.json changed.
  • Full suite: left to CI.

Renderers pass English source text to one catalog lookup. messages.json maps that text to its Chinese translation instead of hash-derived IDs, and comparison.py and delivery.py no longer hold inline Chinese. Rendered pages keep the same bytes.

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

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: d071ceee. I found no correctness defects, no bound-file edits and no rendered-output changes. There are three P3 findings, none of which changes rendered bytes.

Findings

P3: src/harness/web_search/report.py:3248-3250 (also :1926, :804): placeholder names do not describe their values.
The catalog key is what a translator or maintainer reads, and these names mislead:

  • {ids} is the defective-reference count (len(ids) - len(quality_ids)), and {ids_2} is the total.
  • {value} in "from {value} physical requests" is a call count.
  • {overview_case_ids} is a count, not IDs.

Suggested fix: rename them, for example to {defective}, {total}, {physical_calls} and {overview_cases}, in the key and the call. Rendered bytes stay the same.

P3: tests/web_search/test_messages.py:41-44: the lint is tied to unrelated details of pages.py.
assert dynamic == [("pages.py", 28)] fails if a line is added above that call. The 14 navigation labels are also copied by hand from the pages.py registry.

Suggested fix: compare only the file name for the dynamic lookup, and derive the navigation keys from pages._STANDARD, pages._COMPARISON and the review row.

P3: PR body, "Dead entries removed": the two named examples were not dead.
review_failures and review_unreviewed were both referenced by review.py at base. They were migrated with the same Chinese values, to "Review covers failed outputs; passing outputs are outside this review." and "Accepted passing outputs without review: ".

About 29 other entries had no reference in the six renderer modules at base, such as 非空成功响应耗时 and 排除镜像后.

Suggested fix: correct the sentence so the merge record does not suggest that review text was dropped.

What I verified

Output comparison

  • I ran tests/web_search serially against base 2c8a6947 and this head, then compared every generated file. All 1,187 HTML, JS and CSS files were byte-identical after normalizing the temp root, which reproduces the PR's figure.
  • The PR left the other differing files unchecked, so I parsed them. The JSON differences are in timestamps, durations, PIDs, hashes, the revision and path-valued fields, plus a few fields I did not inspect individually (for example .model[] and .environment.HOME). Differing JSONL and zip files were counted but not parsed. Nothing I inspected changed report wording.
  • A rebuilt example manifest differs only in renderer_sha256, browser_eval and bundle, and that rebuild was not run under the golden test's pinned identity. tests/test_golden_reports.py passes with only the manifest.json hash changed in the snapshot.

Branches the tests do not reach
These checks are static, because no measured Web Search evidence was available to rebuild.

  • I compared old and new call sites by AST, inlining the old fragment lookups. Each English/Chinese pair matches base, including format specs such as {value:.1f}. The exceptions are the zh-only entries the PR says got new English keys, which I checked by value instead.
  • Per-label Chinese wording counts match base. The small count differences trace to old table-header lists my pairing could not read.
  • A site-by-site Chinese sequence comparison found only extraction artifacts: moved literal fragments and punctuation.
  • All 18 non-navigation context| keys and the navigation| labels keep the base wording.
  • Every Chinese fragment in the new catalog exists in the base catalog or base source, so no Chinese was reworded. New English appears only in keys for zh-only text.

Helper semantics

  • No template contains literal {{ or }}, and none uses the reserved names zh, context or source.
  • Every t call sits in the scope that binds its zh. The page() helper is the only apparent exception, and it receives t through t=t, as the old code did.
  • No t call passes a second positional argument, and no report_text call omits zh.
  • Values are now evaluated for both editions. The new eager expressions I checked, such as the partial-charge sum and the len values, are harmless on these inputs.

Bindings and scope

  • collection_implementation() lists no file that this PR edits, and nothing under src/lexbench_websearch/ changed. evaluation/ does not reference the edited renderers.
  • visual.py hashes pages.py for capture producers, and renderer_sha256 hashes report.py. Both are expected to change with the code and are not frozen inputs.
  • Han characters remain only in messages.json across src/harness/web_search/, src/lexbench_websearch/ and examples/web_search/, so the #185 scope is met.
  • The three Chinese punctuation marks still rendered in both editions are tracked in open issue #191, which is a fair deferral because fixing them changes bytes.
  • No old text_<hash> IDs remain, and messages.json is still package data.

New lint
Mutations made tests/web_search/test_messages.py fail for a missing key, an unused key, a missing value and a wrong placeholder name.

Runs on this head

  • tests/web_search, tests/test_source_language_policy.py, tests/test_golden_reports.py and tests/test_report_locales.py: 542 passed, 45 subtests passed.
  • tests/test_report_software_versions.py, tests/package_smoke.py and tests/test_golden_reports.py: 38 passed.
  • Ruff, both the F,TID252 gate and the default config: passed.
  • CI on d071ceee: all checks pass, including "Tests and static checks" and "Installation and packaging". The PR is mergeable and based on current main.

@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 · 9f4f975

No findings in this incremental review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 fixes, all three findings addressed and none disputed.

  • Placeholder names: fixed in 36dd1cb3. The defective-reference key now uses {qualified}, {defective} and {total}; the physical-call key uses {physical_calls}; the overview key uses {overview_cases}. I also renamed the same misnaming in two nearby keys: {quality_ids}/{ids} in the other quality sentence, and {ids} to {queries} in the reference-page heading. A new lint rejects placeholders named ids or with a numeric suffix. Every renamed key and translation formats to the same string as before. Only the manifest.json golden changed, because its renderer_sha256 hashes report.py.
  • Brittle lint: fixed in 9f4f9759. The dynamic lookup check now compares only the file name. Navigation keys now come from pages.reader_pages(presentation, reviewed=True) for both presentations, which also covers the review row.
  • PR body: corrected. review_failures and review_unreviewed are now described as migrated. The dead-entry example is text_94ad856f2c0d1003 (非空成功响应耗时), which only messages.json contained at base.

Local run: 571 passed and 45 subtests passed across the Web Search, source-language policy, golden, locale, software-version and package-smoke targets. Ruff passed. CI on the new head is pending.

@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

Head reviewed: 9f4f9759. No defects found.

Round 1 findings

All three are fixed. Catalog placeholders are named after their values, the catalog lint derives navigation keys from reader_pages and compares only the file name for the dynamic lookup, and the PR body's dead-entries bullet is corrected.

What I verified

  • Old and new text, by parsing. I parsed report.py, comparison.py and review.py at base 2c8a6947 and at this head, and resolved every old text_<hash> ID. For each function I expanded the new templates with their keyword expressions and compared the (English, Chinese) pairs, including format specs such as :.1f. I checked the differences and leftover non-pair expressions by hand. The differences are the helper bodies, the old .replace fragments in factual_panel that are now single templates, and the .get lookups for the language name and the dataset label, which keep the same strings. None changes a rendered string.
  • Labels with several Chinese wordings. There are 20 such labels. I compared their order within each function, so a wrong context| at a call site would show up. Only factual_panel differs, because its .replace chain now uses the catalog. Those Chinese strings match the old ones.
  • Late binding. The old local t read zh when called and partial binds it when created. zh is only assigned in the build language loop, before t is created there, so behaviour is the same. No call passes a zh= override.
  • Direct byte comparison at base and head. reader_pages for both presentations, relevance.ANNOTATION_HTML and delivery.BRIDGE hash identically.
  • Bound files. None of the changed files is in collection_implementation or under src/lexbench_websearch/. visual.py hashes pages.py into capture receipts, but no versioned file under evaluation/ or configs/ references that capture schema or renderer_sha256.
  • Catalog. There are no duplicate JSON keys, and every lookup uses a literal key with a literal context. No lookup passes a value that neither template uses. Five entries have different placeholders in English and Chinese; each comes from an old call where only one language showed the value, so they are not bugs.
  • Scope of #185. src/harness/web_search/ has no Han characters outside messages.json, and no reference to text_<hash> IDs remains in the repository. The body's Closes #185 holds. I did not rebuild a measured report, because no real evidence exists on this machine; the parsed comparison above covers branches the synthetic build does not reach.
  • Lint. Adding an unused catalog key makes test_messages.py fail. I restored the file afterwards.

Tests

  • tests/web_search, tests/test_source_language_policy.py, tests/test_golden_reports.py, tests/test_report_locales.py, tests/test_report_software_versions.py and tests/package_smoke.py: 571 passed, 45 subtests passed.
  • Both ruff gates passed.
  • In tests/golden/web-search.json only manifest.json changed, because its renderer_sha256 hashes report.py.

CI on 9f4f9759

"Tests and static checks", "Installation and packaging", "Rendered reference and report checks", "Python 3.11" and "Select check scope" all pass.

lanyue-llk added a commit that referenced this pull request Nov 3, 2026
@lanyue-llk
lanyue-llk merged commit ecbb790 into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/web-search-english-source branch November 3, 2026 21:32
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.

Make English the source language of the Web Search report

1 participant