Skip to content

Move published Web Fetch report text out of shared catalogs - #387

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/fetch-prose
Nov 25, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/fetch-prose

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Shared Web Fetch catalogs should hold interface text only (spec rules 1 and 8, #330). Before this change, report-translations.json, the regex rules in report_i18n.py, messages.json and report_saved_composition held text written for already-published reports: measured values, engine names in sentences, dated notes and one-report narrative. That content lives outside Git and is not available locally, so this PR keeps it in the repository but moves it into frozen per-report data. A report reads that data only when the build identifies itself as that report. Rendered bytes do not change, and every Web Fetch baseline is byte-identical.

This PR also removes the saved-matrix final-admission context variable.

New structure

flowchart LR
    subgraph Shared["Shared catalogs (interface text only)"]
      T["report-translations.json"]
      M["messages.json"]
      R["report_i18n.py REGEX"]
    end
    L["data/legacy-report-text.json<br/>keyed by report"]
    RM["data/report-methods.json<br/>method english_pass, report_badges"]
    PP["research/provider-pricing.json<br/>english_pass"]
    H["out/report-changes.json<br/>bound release history"]
    H -- "names a frozen-history release?" --> C["published_report_catalog(out)"]
    L -- "only when yes" --> C
    PP --> C
    Shared --> TT["translate_text(value, Catalog)"]
    C --> TT
    RM --> TT
    L -- "page set names its report:<br/>report_text(lang, legacy=...)" --> PS["webmainbench / wcxb / research page sets"]
    A["tests/architecture/scan.py<br/>catalog_instance_text()"] -. "empty allowlist" .-> Shared
Loading

What moved

  • data/legacy-report-text.json (new; frozen data, one entry per report):
    • web-fetch-published: 596 exact sentences and 32 phrases from report-translations.json; 44 regex rules from report_i18n.py (the CowAgent/Moli/Cloudflare article sentences, the Kitesurf resource notes, "twelve-method", "six family rankings", Codex review and others), stored as JSON patterns; the comparison kinds whose releases have no English records; and the 150-task ranking message. These load only when the report's bound release history (report-changes.json in the output) names a release in the frozen Web Fetch history. Other reports localize with the shared catalog only.
    • webmainbench (9 messages), wcxb (1) and public-benchmark-research (2): the Kitesurf/Cloudflare/Moli prose, the "5 vs 570" TEDS defect text, the pinned commit and the WebMainBench-545 wording. Both language editions moved out of messages.json and out of the inline English in the renderers. Those page sets read them through report_text(language, legacy=...).
  • Translation engine: translate_text(value, catalog) takes an explicit Catalog (exact bound translations, frozen report text, phrases, patterns) instead of a translations dict. Callable rules receive the catalog, so nested translation uses the same catalog. localize_html and Localizer take catalog=.
  • Owned English: the Moli timeout descriptions are now english_pass rules on the Moli entry of the method registry. The pricing summaries rendered from the price catalog are now in its english_pass section, read from the copy the report ships. Generic interface rules replace the Moli-only and price-specific ones: $X/月, annual price, N 页/月总支出, 官方 X 文档 ↗, X N · 官方发布 ↗, and a Latin-name list joined by 、.
  • _model_fetch_badges: the hardcoded labels and slug regex are gone. The badge now comes from report_badges: ["model_fetch"] (and report_label_variants) on the four registry methods.
  • Saved-matrix admission: _FINAL_ADMISSION, a ContextVar, is replaced by an explicit admission argument (_source_admission → generate_saved_matrix(..., admission=) → _render_projection → _saved_renderer_projection).
  • Check: tests/architecture/scan.py::catalog_instance_text() scans report-translations.json, the values in messages.json and the string constants in report_i18n.py for measured values (decimal measurements, grouped counts, counts of three or more digits, dates, versions) and registered method names inside sentences. test_shared_web_fetch_catalogs_hold_interface_text_only requires zero findings; there is no allowlist. A negative-control test pins the detector.

Not changed (reported, not done)

  • native_projection._HISTORICAL_POLICIES stays. native_projection_source() hashes native_projection.py itself as the current answer-selection policy identity. Editing the file changes the version-7 policy hash that saved evidence and the route-contract baseline verify (test_native_route_contract fails). It stays until that binding moves to a stored copy.
  • The render-scope ContextVar in report_model.py (RenderContext/MethodScope) stays. It is read by about 20 functions in report.py (write, hero, table rows, rankings) and by methods.py. Making it explicit means threading a context through most of the Web Fetch renderer and the method-label helpers, more than 500 call sites across about 10 modules. That belongs in its own change rather than in this text move.

Allowlists

Instance-literal 1 → 1; layering 0 → 0; new catalog check: 0 findings, no allowlist.

Baselines

All baselines in tests/baselines/ are unchanged, including web-fetch, wcxb, webmainbench-sample and webmainbench-full.

Rebuilds may change two kinds of output bytes:

  • adoption/pricing.json now carries the price catalog's new english_pass section.
  • In the English pass, a Latin-only list joined by 、 that matches no other rule is now rendered with , ; before, it stayed untranslated.

Verification

  • uv run --frozen --all-extras python -m pytest tests -n 8 --dist worksteal: 21647 passed, 78 skipped
  • make lint-check: passed
  • uv run --frozen lexbench-webfetch version: scoring-source hash unchanged (0fe89317…)
  • New tests: test_published_report_text_is_read_only_for_that_report checks that frozen text translates only for a report identified as published. The catalog check has positive and negative controls.

Breaking changes

None to commands. Python API changes:

  • report_i18n.translate_text(value, translations=) is now translate_text(value, catalog).
  • localize_html(..., translations=) is now localize_html(..., catalog=).
  • report_saved_matrix.generate_saved_matrix(out, model, *, admission=None) gains a keyword argument.

Closes #330

Measured-value sentences, method-named rules and one-report messages leave
report-translations.json, report_i18n.py and messages.json for
data/legacy-report-text.json, read only when the build is that report.
Method registry and price catalog own the English of the text they render;
an architecture check keeps shared catalogs to interface text.
The source-validated build hands its admission to the render instead of
installing it in a context variable.

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

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

Comment thread src/harness/web_fetch/report_i18n.py Outdated
"""`t` for one already-published report's frozen message."""
message = legacy_report_text(report)['messages'][key]
chinese = message['zh'].format_map(values)
TEXT.setdefault(chinese.strip(), message['en'].format_map(values))

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
This adds frozen report text to the shared TEXT dictionary permanently. overall_ranking() calls this helper, after which translate_text(chinese, Catalog()) (or a catalog for an unrelated report) returns this published report's English narrative without any legacy identity. This defeats the new catalog isolation and makes localization depend on rendering order. Keep this translation in the published report's catalog instead of mutating TEXT, and add a regression test that calls legacy_t() before checking an unrelated catalog; the current isolation test only checks a legacy['text'] entry.

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.

Fixed in fddfe0b: legacy_t no longer writes to the shared TEXT. The English for this message now comes only from the published report's catalog, where the frozen phrase already maps it to the same English. Added test_rendering_a_published_message_does_not_leak_into_other_reports, which renders the message and then checks the shared catalog and an unrelated report's catalog before checking the published one.

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

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

Comment thread src/harness/web_fetch/report_i18n.py Outdated
Comment on lines +511 to +512
path = repository_root() / 'research/report-changes.json'
return {row['id'] for row in json.loads(path.read_text(encoding='utf-8')).get('releases', [])} if path.is_file() else set()

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
Published-report detection silently fails in an installed distribution: repository_root() resolves to the installed package parent, and research/report-changes.json is neither package data nor listed in tool.webstone.bundled-data. Consequently this returns an empty set even when the output contains a valid published release history, so published_report_catalog() disables the frozen translations and leaves published narrative untranslated. Store the frozen release IDs in packaged data (or bundle the history and resolve it through bundled_data_path) and add coverage without checkout assets.

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.

Fixed in 03d80c4: the frozen Web Fetch release IDs now live in release_ids of data/legacy-report-text.json, which is package data. Identification no longer reads research/. test_published_release_identity_is_packaged_with_the_frozen_text checks that the packaged IDs match the research history, so any drift is caught.

@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 · 03d80c4

No findings in this incremental review.

@lanyue-llk
lanyue-llk merged commit a673bc2 into main Nov 25, 2026
10 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/fetch-prose branch November 25, 2026 07:20
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.

Move report-instance prose and numbers out of renderers, checks and translation maps

1 participant