Repository navigation
Move Web Fetch provider projection and routing into registered adapters - #349
Merged
Merged
Conversation
This was referenced Nov 24, 2026
…red adapters Replace PROVIDER_TYPES with a harness.adapters Registry, declare the MethodAdapter hooks on Provider, move native answer selection into each adapter, read evidence capabilities instead of provider types, and split the hosted fetch adapter into vendor subclasses.
…cy sources Every registered fixed-native type is now covered; route cells are unchanged apart from the answer selection policy digest.
lanyue-llk
force-pushed
the
refactor/fetch-methods
branch
from
November 24, 2026 08:05
e0b428c to
d7aa45e
Compare
Contributor
Author
|
Rebased on main after #345. Conflicts were import-only ( |
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Adding a Web Fetch provider no longer edits shared modules. Each adapter declares its answer selection policy, evidence capabilities and optional hooks; shared code resolves adapters through one registry and reads declared capabilities instead of provider types.
What moved or was removed
PROVIDER_TYPESdict →harness.adapters.RegistryPROVIDERSinproviders/base.py(type → module/class, still loaded on demand), plusprovider_class()andprovider_capabilities(). The route-baseline test, the registry test and the architecture scan derive their type lists from it.Providerconforms toMethodAdapter:capabilities()(fromcapability_flags),implementation_identity()with a neutral default,recorded_implementation_identity(),preflight_capacity()/capacity_credits_for_cases()no-op defaults, a declaredcall_diagnosticsattribute and anative_answer_selectionhook.runner.py,call_boundary.pyandrisk_control.pycall these instead ofgetattrprobing;risk_control.implementation_identityis removed.native_projection.py: the 240-line if-chain over 19 provider types becomes onenative_answer_selection(selection)hook per adapter (Lexmount, Claude, Tavily, Exa, Firecrawl, Cloudflare, JSONL worker/CowAgent, Moli, fixture, hosted vendors), dispatched through the registry. Shared helpers stay.native_routes.py: the provider-type set and three special cases become capability flags:malformed_envelope_is_evidence,raw_answer_bytes,raw_stdout_evidence,raw_http_evidence,legacy_markdown_output_label.providers/hosted_fetch.py: 35self.typebranches →HostedFetchProvider(shared call, evidence and failure flow) plus seven small vendor subclasses declaring endpoint, request body, answer fields and envelope rules. Its answer selection is derived from the same description.ENDPOINTSis removed (tests readprovider_class(kind).endpoint).native_projection.pyandnative_routes.pynow name no provider (19 and 11 names before → 0).Breaking changes
No command is renamed or removed. Python API changes, with every in-repository caller migrated:
providers.base.PROVIDER_TYPES→PROVIDERS(Registry),provider_class(),provider_capabilities().providers.hosted_fetch.ENDPOINTSremoved; each vendor class declaresendpoint.HostedFetchProvideris now the shared base, and each hosted type maps to its vendor subclass.risk_control.implementation_identity(provider)removed; useprovider.implementation_identity().provider._call_diagnostics→ declaredprovider.call_diagnostics.native_projection.native_projection_source()→native_projection_source(provider_type).The scorer identity is unchanged (
lexbench-webfetch version:scoring_source_sha2560fe89317…169e);src/lexbench_webfetch/and dataset content are untouched.Policy identity (hash-frozen source)
Before, a policy's
source_sha256was the hash ofnative_projection.pyalone, written beside evidence asnative-answer-policies/<sha256>.py. Historical versions (1–7) are accepted only through an externally approved registry (digest → version) and replayed by the current code withpolicy_version=N; saved bytes are hash-checked and never executed.Now the policy source of a provider type is
native_projection.pyfollowed by the module that defines that type'snative_answer_selection(each part prefixed by a# native answer policy source: <path>line). The frozen file format, path, version numbers and approval mechanism are unchanged, and everypolicy_versionbranch is kept in the adapter hooks, so historical approvals keep verifying. As with every earlier edit ofnative_projection.py, evidence frozen under main's digest (0fc54974…for all types) verifies through an approved-registry entry{source_sha256, version: 7}; no repository profile binds that digest. The bundle also closes a gap: Moli's selection depended onmoli._route_for_case, which was outside the hashed bytes.Allowlists
I did not extend the instance-literal scan to Web Fetch shared modules: it would add 56 entries across 23 modules, mostly in runner, certification, WebMainBench, WCXB and report code owned by other lanes.
Baselines
tests/baselinesandtests/goldenunchanged.tests/fixtures/native-route-baseline.jsonis regenerated: every cell binds the policy digest, which changes with any edit of the policy source, and it now covers every registered type with a fixed-native route (19 types, was 13), derived from the registry. Before regenerating, I compared all route cells, endpoints and normalized parameters for all 22 registered types × defaults/configured × 192 synthetic cases between main and this branch with the digest masked: identical.Behaviour-equivalence checks (scratch, not committed)
native_answer_projection: main vs branch over 24 types (22 registered, unknown,None) × 60 payloads × 51 cases × 4 interfaces × 4 statuses × 8 policy versions: 7.5M comparisons, 0 differences (including error messages).HostedFetchProvidervs the vendor subclasses over 7 vendors × 5 configs × 20 cases × 23 response bodies × 6 HTTP statuses (fetchresults with metadata order, request arguments, routes, validation): 93,870 comparisons; the only difference is the order ofvalidate()messages when a Browserbase or Crawl4AI config has both an invalid option and an invaliddns_mode(same set)._expected_native_declaration: main vs branch over every type × raw bodies × output-contract/interface variants: 0 differences.Remaining provider/engine names (not cheap; left)
task_outputs.py: headless engine contract checks (moli,chromium,lightpanda,obscura,kitesurf) — would move into the headlessENGINESdefinitions.network_preflight.py/local_execution_contract.py:GUARDED_NATIVE_TYPESincludes retired types (openclaw_builtin,langchain_webbase, …) that historical local-runner contracts still verify; not representable as capabilities of registered adapters.assembly.py:634,refresh_assembly.py:77: keyed by the configured provider name in historical evidence; a type capability would change which records qualify.comparison_audit.py: a Moli-only audit.failure_diagnosis.py: matches vendor error-message text, not an adapter identity.native_routes.normalized_http_parameters: recognizes three vendor request shapes (Claude messages, Lexmountextract, Browser Use session header) structurally; a per-adapter normalizer hook would remove it.Verification
uv run --frozen --all-extras python -m pytest -q -n 8 tests— 12 failures, the same set that fails on main a0b5b56 in this environment (missing node_modules/benchmark data); no new failures. AMockprovider exposed a regression in the first run (recorded identity must be a dict); fixed.make lint-check: pass.Closes #319
Part of #318