Repository navigation
Move published Web Fetch report text out of shared catalogs - #387
Conversation
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.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| """`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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
✅ Re-review complete · 03d80c4
No findings in this incremental review.
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 inreport_i18n.py,messages.jsonandreport_saved_compositionheld 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" .-> SharedWhat moved
data/legacy-report-text.json(new; frozen data, one entry per report):web-fetch-published: 596 exact sentences and 32 phrases fromreport-translations.json; 44 regex rules fromreport_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.jsonin the output) names a release in the frozen Web Fetch history. Other reports localize with the shared catalog only.webmainbench(9 messages),wcxb(1) andpublic-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 ofmessages.jsonand out of the inline English in the renderers. Those page sets read them throughreport_text(language, legacy=...).translate_text(value, catalog)takes an explicitCatalog(exact bound translations, frozen report text, phrases, patterns) instead of atranslationsdict. Callable rules receive the catalog, so nested translation uses the same catalog.localize_htmlandLocalizertakecatalog=.english_passrules on the Moli entry of the method registry. The pricing summaries rendered from the price catalog are now in itsenglish_passsection, 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 fromreport_badges: ["model_fetch"](andreport_label_variants) on the four registry methods._FINAL_ADMISSION, a ContextVar, is replaced by an explicitadmissionargument (_source_admission→generate_saved_matrix(..., admission=)→_render_projection→_saved_renderer_projection).tests/architecture/scan.py::catalog_instance_text()scansreport-translations.json, the values inmessages.jsonand the string constants inreport_i18n.pyfor 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_onlyrequires zero findings; there is no allowlist. A negative-control test pins the detector.Not changed (reported, not done)
native_projection._HISTORICAL_POLICIESstays.native_projection_source()hashesnative_projection.pyitself 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_contractfails). It stays until that binding moves to a stored copy.report_model.py(RenderContext/MethodScope) stays. It is read by about 20 functions inreport.py(write,hero,tablerows, rankings) and bymethods.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, includingweb-fetch,wcxb,webmainbench-sampleandwebmainbench-full.Rebuilds may change two kinds of output bytes:
adoption/pricing.jsonnow carries the price catalog's newenglish_passsection.、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 skippedmake lint-check: passeduv run --frozen lexbench-webfetch version: scoring-source hash unchanged (0fe89317…)test_published_report_text_is_read_only_for_that_reportchecks 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 nowtranslate_text(value, catalog).localize_html(..., translations=)is nowlocalize_html(..., catalog=).report_saved_matrix.generate_saved_matrix(out, model, *, admission=None)gains a keyword argument.Closes #330