Skip to content

Remove remaining Web Fetch and Web Extract instance knowledge and the native-policy context variable - #390

Merged
lanyue-llk merged 4 commits into
mainfrom
refactor/final-residuals
Nov 25, 2026
Merged

lanyue-llk merged 4 commits into
mainfrom
refactor/final-residuals

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Part of #389: remove the remaining instance knowledge from shared Web Fetch and Web Extract code, and remove the native-projection context variable (spec rules 1, 4 and 8). The render-scope context variable in web_fetch/report_model.py comes in a separate PR, so that wide mechanical change can be reviewed on its own.

New structure

flowchart LR
    subgraph Policy["Native answer policy identity"]
      L["native_projection.py (live)"] -->|current digest, v7| P["native_projection_policy_version(policy, type, approved)"]
      S["data/native-answer-policies/&lt;sha&gt;.py.txt<br/>stored earlier v7 module bytes"] -->|digest recomputed from the copy| P
      R["bound registry in the saved-matrix spec"] -->|approved_policy_versions()| A["approved"]
      A -->|explicit argument| B["_load_saved_matrix → verify_record_artifacts<br/>→ verify_saved_native_answer"]
      A --> P
    end
    subgraph Data["Instance content as data"]
      LR["legacy-report-text.json<br/>ranking_basis"] --> RP["report.py ranking intro"]
      RM["report-methods.json<br/>pricing_duration_example"] --> PR["report_pricing.py"]
      TC["report-track-context.json<br/>examples, reference_status"] --> RC["report_components.py"]
      SS["bound score-summaries.json"] --> WC["webmainbench_report_check"]
      BA["benchmark_adapter.record_value_key<br/>product_fields.DECLARED/SCORED"] --> EX["web_extract analysis/report"]
    end
Loading

What moved or was removed

Native projection context variable (Web Fetch). native_projection_source() hashes the live native_projection.py, which is part of the version-7 policy identity, so any edit changed every policy digest. I applied the #385 pattern:

  • data/native-answer-policies/85cf5852….py.txt is a stored copy of the module bytes the current v7 evidence was frozen with (main at ed00452). index.json binds the copy to its hash and its version.
  • native_projection_policy_version accepts a v7 digest when it equals the digest recomputed from a stored copy (native_projection_source(type, policy_module=copy)). The policy version does not change, and no version bump was needed.
  • _HISTORICAL_POLICIES (a ContextVar) and the approved_native_policies context manager are removed. approved_policy_versions(registry) parses the bound registry. The result is passed explicitly: build_saved_matrix/check_saved_matrix → _load_saved_matrix(spec, approved) (stored on inputs, and used for nested matrices) → verify_record_artifacts(..., approved_policies=) → verify_saved_native_answer and _native_retry_scoring_record.
  • tests/fixtures/native-route-baseline.json changes only in its policy digests. Computing the fixture with the stored module copy reproduces the previous fixture exactly (38/38 entries). With the live module only the digest differs.

Web Fetch instance content.

  • report.py: the check case_count==150 and track_count==6 is gone. The published report declares ranking_basis beside its frozen text, and published_ranking_basis() replaces legacy_t.
  • report_pricing.py: the cloudflare-markdown branch is gone. Its numbers and text now live in pricing_duration_example on that method's registry entry. browser_monthly takes the plan's figures as arguments instead of one provider's defaults.
  • report_components.py: the Books to Scrape, GraphQL, Attention, JustWatch and Zhihu/Dianping example text, the example task links and the reference example case ids now live in report-track-context.json. Six entries were removed from messages.json.
  • webmainbench_report_check.py: SAMPLE_PROVIDERS is removed. The method set comes from the bound score-summaries.json, whose bytes the repository content binding pins. The latency-diagnostic run ids come from webmainbench_latency_diagnostic.RUNS. The fixed attempt and dataset hrefs are replaced by a generic rule: the bound interpretation must link at least one task and one result, and every such link must open a generated page.

Web Extract. analysis.py no longer imports swde. It uses benchmark_adapter.record_value_key, which resolves the record value equivalence from the registered task adapter modules. analysis.py and report.py take field names from product_fields (DECLARED, SCORED, REPORTED). The historical F1 headers come from per-field history_labels_<field> catalog keys instead of positional slices. report_ui.py builds its field label keys from REPORTED.

Check. tests/architecture/scan.py::benchmark_module_imports(), with a test in test_architecture_layering.py, fails when Web Extract analysis, report, report_ui, report_suite or model_comparison import a registered benchmark module.

Allowlists

Instance-literal 0 → 0; layering 0 → 0; the new benchmark-module import check has 0 findings and no allowlist.

Baselines

tests/baselines/ is unchanged and passes without a refresh. Rendered pricing output is byte-identical before and after (checked directly). Scorer hash unchanged: 0fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169e.

Verification

  • uv run --frozen --all-extras python -m pytest -q -n 8 --dist worksteal tests: 21653 passed, 78 skipped, 2 xfailed
  • make lint-check: passed
  • uv run --frozen lexbench-webfetch version: same scoring-source hash

Not done here

  • Render-scope ContextVar in report_model.py: separate PR.
  • Web Extract assets/report.js still lists the product field names. Changing it changes report route digests and would need a baseline refresh.
  • webmainbench_report.py still links one fixed attempt (obscura__949e…) in its TEDS section, and the sample check still asserts the 200-case cohort size and the dataset id. Both describe that one published report.
  • I could not find the "Moli before/after deltas" from the issue (report.py:266-273) in the current report.py. It appears to have been removed already.

Breaking changes

None to commands. Python API:

  • native_projection.approved_native_policies(registry) (context manager) is replaced by approved_policy_versions(registry) -> dict. native_projection_policy_version(policy, type, approved=None) takes it explicitly. verify_saved_native_answer and verify_record_artifacts gain approved_policies=.
  • report_i18n.legacy_t is replaced by published_ranking_basis(case_count, track_count).
  • report_pricing.browser_monthly(pages, seconds, *, base_usd, included_hours, usd_per_hour) has no provider defaults.
  • webmainbench_report_check.SAMPLE_PROVIDERS is removed.

Part of #389

…rk declarations

Shared analysis no longer imports the swde task adapter: record value
equivalence resolves through benchmark_adapter.record_value_key from the
registered task adapter that declares it. Report and analysis read
declared, scored and reported field names from product_fields, and the
historical F1 headers come from per-field catalog keys instead of
positional navigation labels. An architecture scan keeps shared Web
Extract report and analysis modules off registered task-adapter modules.

Part of #389
…ion-7 policy digests verifying from a stored module copy

native_projection.py is part of the version-7 answer-selection policy identity,
so editing it changed every policy digest. Earlier digests now resolve through a
stored copy of the module bytes they were frozen with
(data/native-answer-policies/), verified against its hash; the policy version
is unchanged. The approved historical registry is parsed by
approved_policy_versions and passed explicitly through the saved-matrix build
and check instead of a context variable.

The native route fixture changes only in its policy digests: computing it with
the stored module copy reproduces the previous fixture exactly.

Part of #389
…shed-report data

- The published 150-task ranking basis is declared beside its frozen text
  (legacy-report-text.json ranking_basis) instead of a size check in report.py.
- The browser-time duration example of a price entry is declared on its method
  (report-methods.json pricing_duration_example); browser_monthly takes the
  plan's numbers instead of defaulting to one provider's.
- Benchmark-specific example sentences, example task links and the popular-site
  snapshot scope live in report-track-context.json instead of the shared
  message catalog and renderer.
- The WebMainBench sample check takes its method set from the bound score
  summary, the latency-diagnostic run ids from the diagnostic module that owns
  them, and checks that the bound interpretation's own evidence links open
  generated pages instead of naming three fixed ones.

Rendered output is unchanged.

Part of #389

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

No findings in this review.

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

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 0246471 into main Nov 25, 2026
10 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/final-residuals branch November 25, 2026 08:40
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.

1 participant