Repository navigation
refactor(web-extract): method, engine, benchmark and report-shape adapters - #348
Conversation
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| PRODUCT = fixed_field_benchmark() | ||
| PROFILE = Path(__file__).resolve().parents[1] / "benchmarks/cards" / PRODUCT.profile | ||
| PRODUCT_FIELDS = PRODUCT.fields | ||
| FIELDS = (*PRODUCT_FIELDS, *PRODUCT.derived_fields) | ||
| SCHEMA = PRODUCT.schema |
There was a problem hiding this comment.
Moving these declarations and the default request instructions into dataset.py leaves product executions outside the frozen implementation boundary. task_bindings() returns {} for the product benchmark, and both probe collection and certification only add the dataset registry hash for record datasets. Consequently, changing PRODUCT_SCHEMA or PRODUCT.instructions without changing pipeline.py can pass resume/preflight implementation checks while sending different requests within the same product run (the probe resume comparison also does not compare schema). Bind and verify the benchmark registry for product runs too, and include the dependency in the execution snapshot so the frozen pipeline retains its original declarations.
a714a7c to
3dd6ba2
Compare
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| PRODUCT = fixed_field_benchmark() | ||
| PROFILE = Path(__file__).resolve().parents[1] / "benchmarks/cards" / PRODUCT.profile | ||
| PRODUCT_FIELDS = PRODUCT.fields | ||
| FIELDS = (*PRODUCT_FIELDS, *PRODUCT.derived_fields) | ||
| SCHEMA = PRODUCT.schema |
There was a problem hiding this comment.
The product request semantics now depend on dataset.py, but product runs do not bind that file: task_bindings() returns {} for this benchmark, and _probe_unlocked() only adds those bindings for task adapters. Consequently, changing PRODUCT.schema or PRODUCT.instructions without changing pipeline.py passes the existing resume/preflight implementation checks and can mix different requests into the same frozen cohort. Although the schema is recorded in the contract, it is not compared during resume, and the product instructions are not bound there. Include the benchmark declaration source (or a complete resolved semantic identity) in product execution contracts and enforce it in resume/preflight validation.
Each Web Extract method is an ExtractMethod in a harness.adapters.Registry carrying its request builder, envelope projection and post-call usage hook. provider_call and normalize dispatch through the adapter; request builders no longer branch on method names. Self-hosted engines register version, extract, identity, attestation, failure and availability functions.
… on adapters BENCHMARKS becomes a registry of ExtractBenchmark objects. The product benchmark declares its fields, schema, default instructions, value rules, reference controls and review prompts; record benchmarks declare theirs. Name branches on the default benchmark give way to declared capabilities (exported evaluator, implicit record instructions) and to the single-schema benchmark owning manifests without a benchmark name.
…e hooks build and _check_rendered_report dispatch through REPORT_SHAPES keyed by the content or manifest mode; product, record cohort and suite renderers become hooks. A shared rendered_files inventory replaces two copies.
Product request declarations moved to dataset.py, so every run contract and certified plan now records dataset_registry_sha256; resume and certified collection reject a changed registry. Plans recorded before this field still verify.
There was a problem hiding this comment.
✅ Re-review complete · d8343e6
No findings in this incremental review.
d8343e6 to
d83f41d
Compare
|
Rebased on main after #345, #349, #351 and #346 (head d83f41d).
|
…ng definitions default_patterns() is cached per process. When this test was a worker's first caller, the stubbed definition_path cached the test dataset as the patterns, and later factual-acceptance tests failed with KeyError: 'identity_patterns'.
|
The secondary shard failed three times in a row (
Fix (81c19f4): the test resolves the real patterns before stubbing. Run in that order, the pair fails 5 tests without the fix and passes with it. No scorer source changed (hash 0fe89317…). |
There was a problem hiding this comment.
ℹ️ Review skipped · 81c19f4
No reviewable content was selected for this run.
|
All required checks pass on 81c19f4. The one primary-shard failure on the first run was |
Purpose
Move Web Extract instance knowledge out of shared branches and into registered adapters (docs/spec.md, "Extension points"): methods and self-hosted engines become adapter objects, benchmarks declare their fields, schema, review prompts and analysis controls, and the report has one build and one check entry with task-shape hooks.
flowchart LR subgraph Methods["pipeline.METHODS (Registry[ExtractMethod])"] M["ExtractMethod<br/>request · project · usage<br/>options · input · capabilities()"] end subgraph Engines["self_hosted.ENGINES (Registry[Engine])"] E["Engine<br/>version · extract · identity<br/>attest · failure · unavailable"] end subgraph Benchmarks["dataset.BENCHMARKS (Registry[ExtractBenchmark])"] B["ExtractBenchmark<br/>profile · module · fields · schema<br/>valid_value · reference_controls<br/>review_prompts · capabilities"] end subgraph Report["report.REPORT_SHAPES (Registry[ReportShape])"] R["product · record cohort · suite<br/>build + check hooks"] end PC["provider_call / normalize"] --> M M -- "self-hosted route" --> E W["worker / health / native_failure"] --> E P["prepare / validate / certify / review / analysis"] --> B BLD["report.build"] --> R CHK["report.check"] --> RWhat moved or was removed
METHODSdict of dicts →Registry[ExtractMethod](conforms toharness.adapters.MethodAdapter). Each adapter carries its request builder, envelope projection (project), post-callusagehook andrequest_settings. Theelif method ==chain innormalize, the method branches inprovider_calland the method checks inside request builders are gone (shared builders were split per method around small shared helpers).available_methods()removed; callers useMETHODS.ENGINES→Registry[Engine]with version, extract, identity, attestation, failure and availability functions.validate_input,local_runtime_identity,runtime_identity,native_failure,workerand/healthcontain no engine names.BENCHMARKS→Registry[ExtractBenchmark]. The product benchmark declaresfields,derived_fields,schema, defaultinstructions,valid_value,reference_controlsand its two review prompts; record benchmarks declare the record review prompts.PRODUCT_FIELDS/SCHEMA/PROFILEinpipeline.py,FIELDSinreview.pyand the reference controls inanalysis.pynow come from the adapter. Name branches replaced:preparedefault benchmark,validate_datasetrecords evaluator (exported_evaluatorcapability),benchmark_configdefault and records profile (profile is None), certification SWDE instruction default (implicit_record_instructionscapability), model-comparison SWDE scoring (record reference shape), CLI--benchmarkdefault.report.py:buildand_check_rendered_reportdispatch throughREPORT_SHAPES, keyed by the content/manifest mode; the product shape remains the default for content without a registered mode, as before. The record cohort self-check goes through the single check path.rendered_filesreplaces two copies of the file inventory.tests/web_extract/test_registry_contract.pyiterates all three registries.Kept in place on purpose: method registrations stay in
pipeline.pyand engine registrations inself_hosted.py, becausepipeline.pyis the frozen execution snapshot (execution/pipeline.py,pipeline_sha256) andself_hosted.pyis hashed into the runtimeimplementation_sha256; moving them would leave request and engine code outside those bindings.Remaining (not in this PR)
report.pyandanalysis.pystill spell product field names (OutOfStock, table columns).ExtractBenchmarkdoes not yet expose thecases/inputs/score/populationshooks ofBenchmarkAdapter; the Extract pipeline still calls the task module'sprepare/probe_cases/scoredirectly.pipeline.check_projection_controls/check_record_projection_controlsstill name the method whose projection they exercise.Breaking changes
No command is renamed or removed.
webstone web-extract prepare --benchmarkkeeps its choices; its default is no longer spelled out as a name but still selects the single-schema product benchmark, so the behaviour is unchanged.Python API changes inside
harness.web_extract(all callers migrated in this PR):pipeline.available_methods()removed; usepipeline.METHODS(aRegistry[ExtractMethod], attribute access instead of dict keys).pipeline.valid_product_valuemoved todataset.valid_product_value(alsoPRODUCT.valid_value);pipeline.SCHEMAis now the product adapter'sschema.analysis.REFERENCE_CONTROLSmoved todataset.PRODUCT_REFERENCE_CONTROLS(PRODUCT.reference_controls).dataset.BENCHMARKSis aRegistry[ExtractBenchmark];benchmark_config()also returns the adapter under"benchmark".self_hosted.ENGINESis aRegistry[Engine].report.build_record_cohorttakes the shared hook signature (addsrun).Scorer identity unchanged:
uv run --frozen lexbench-webfetch versionprintsscoring_source_sha2560fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169e. No HF dataset content or card config is touched.Allowlists
METHODS.names()).Baselines
tests/baselines/unchanged for all four Web Extract modes (and the other tracks). Behaviour notes: unknown method/benchmark names now raise the registry'sValueErrorinstead ofKeyError;/healthlists engines in registry (sorted) order.Verification
Closes #320
Part of #324
Part of #318
Part of #338