Repository navigation
feat(web-extract): benchmark self-hosted engines and local models - #258
Conversation
There was a problem hiding this comment.
This review found 5 issue(s), including 5 blocking issue(s).
src/harness/web_extract/certification.py(token_budget_reached): skipped round 3 of group "src/harness/web_extract/certification.py,src/harness/web_extract/cli.py,src/harness/web_extract/pipeline.py,src/harness/web_extract/self_hosted.py": used 500533 tokens exceeds budget 500000
There was a problem hiding this comment.
This review found 3 issue(s), including 3 blocking issue(s).
There was a problem hiding this comment.
This review found 7 issue(s), including 7 blocking issue(s).
src/harness/web_extract/self_hosted.py(token_budget_reached): stopped group "src/harness/web_extract/self_hosted.py" mid-review: used 540788 tokens exceeds budget 500000
There was a problem hiding this comment.
This review found 4 issue(s), including 4 blocking issue(s).
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
There was a problem hiding this comment.
✅ Re-review complete · 1ec4b58
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 0d3376b
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · d48847c
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 953295c
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 42ef96c
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 00de044
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
Reviewed against origin/main at fe47b246. The PR merges cleanly, also with #257, and CI is green.
The approach is sound. The service validates input well: allowed snapshot origins, JSON Schema checks, a body-size limit and constant-time token comparison. Process cleanup has a real design (a subreaper on Linux, suspend then kill). The Crawl4AI and ScrapeGraphAI protocol fixes are tested against the real pinned SDKs. The cost disclosure is tied to the source plan's hash and the population size. The browser test drives the new panel navigation from start to finish.
Inline findings, in priority order:
- Must fix before leaving draft: the engine list is copied in several places (
pipeline.py). - Must fix before leaving draft:
package-checknow depends on the extraction service's SDKs (Makefile). - Must fix before leaving draft: the post-extraction runtime check does nothing for three engines (
self_hosted.py). - Cheap hardening: the container build isn't reproducible (
Dockerfile). - Cheap hardening: ScrapeGraphAI's input decoding may garble non-UTF-8 snapshots.
- Cheap hardening:
/healthexposes internal addresses without authentication. - Nit: the ScrapeGraphAI model timeout disagrees with the worker deadline.
General notes:
- Old links break. The
result-{method}-{case}.htmlroutes are removed. That's fine for new builds, since published reports stay as they are, but republishing to an existing site breaks outside links to those pages. Worth a line in the release notes. - No picture in the PR body. Please add one picture of the main content, for example the topology of the facade, the engines and the private Firecrawl backend, or the new per-case result page.
There was a problem hiding this comment.
This review found 8 issue(s), including 8 blocking issue(s).
There was a problem hiding this comment.
This review found 4 issue(s), including 4 blocking issue(s).
lanyue-llk
left a comment
There was a problem hiding this comment.
Follow-up review of 040e50a0 against origin/main.
Addressed since the last review: thanks.
package-checkno longer depends ontest-extraction-sdk.worker()now clearslocal_runtime_identity's cache before the post-extraction check.
Still open from the last review:
- The engine names are still copied in
pipeline.py(method list, method→engine dict,normalizetuple). - The base image comes from an unpinned mirror (
docker.1ms.run), andapt-get install chromiumis unpinned. - ScrapeGraphAI still gets
decode("utf-8", errors="replace")input. /healthis still unauthenticated and returns internal addresses.- The ScrapeGraphAI model timeout is still
timeout=150.
New concern: the PR has grown from +4,884 to about +7,600 lines. Commits 315038a9, d36d594b, e0162b58 and 040e50a0 add harness/benchmark_execution.py, a scheduler shared by all tracks. It brings a policy object with purposes and named resource capacities, a dispatcher using threads or forked processes, and a required trial run and wall-time budget before collection. It also:
- moves the Web Search, Web Fetch, Browser Use and Trajectory Replay runners onto the scheduler;
- changes
configs/report-templates.jsonand the golden files for Web Fetch and Web Search; - adds a 144-line
docs/benchmark-execution.mdand a new AGENTS.md rule binding every track.
This is a separate architecture change inside a Web Extract feature PR, and much of it is over-design. Details are inline.
The new opt-in keepalive streaming mode adds a second response protocol: HTTP 200 is sent first, and failures go into the JSON body. It works around gateway timeouts that the README already handles by raising the proxy read timeout. Unless a proxy you can't configure requires it, prefer the configuration fix and keep one response shape.
The $(MAKE) -j2 test test-extraction-sdk line also conflicts with #257 once both merge (see the inline comment).
Recommendation:
- Take the shared scheduler out of this PR and leave the other tracks' runners and golden files unchanged.
- If the self-hosted engines need concurrency, use a bounded
ThreadPoolExecutorinside Web Extract's own collector, with one concurrency setting per method. - Propose a shared scheduler separately, with an issue, if more than one track needs it.
- Then fix the open items above. The engine-name duplication still blocks leaving draft.
There was a problem hiding this comment.
This review found 3 issue(s), including 3 blocking issue(s).
There was a problem hiding this comment.
This review found 5 issue(s), including 5 blocking issue(s).
There was a problem hiding this comment.
✅ Re-review complete · 71979a0
No findings in this incremental review.
There was a problem hiding this comment.
ℹ️ Review skipped · 1f03d16
No reviewable content was selected for this run.
lanyue-llk
left a comment
There was a problem hiding this comment.
Review of head 1f03d16b against main (d4fb973d), including a re-check of what I found at 71b42711. Scoped tests: 729 passed and 4 skipped. The 6 test_deployment_recipe.py failures only reflect a host without docker compose. Both lockfiles pass uv lock --check.
Several earlier issues are fixed:
- An interrupted Web Fetch run now writes its manifest.
- Web Search keeps a partial retry as a checkpoint instead of committing it.
- The service has a container-wide admission lease.
- The Firecrawl identity now covers the browser service.
verify_completion_auditnow runs once per publish.release_checkin the template registry has--home/--profile.
Blocking: design and scope
model_comparison.pyis a second collection pipeline (inline). It has its own plan,.pendingreservations, call-hash index, resume reconciliation, preflight budget and transport-repair chain, all parallel topipeline.collect_calls(dispatch, journal, in-flight reconciliation,physical_attempt, retry accounting,failure_repair). AGENTS.md: a new provider or cohort "must select behavior through data, a registry or parameters in the existing pipeline. It must not create a … runner". It also bypasses certified collection, and every future durability or retry fix would have to land twice.- Scope. About 1.6k lines of model comparison (collector, scoring, about 880 test lines, README) were added to an already roughly 16k-line PR, and no report, check or publication path reads their output. Please split it into its own PR after the owner question in #1 is settled. If it is kept, add a streaming model method to the existing registry and
collect_calls, with page-text input as an adapter option. - Model scores are not comparable to the report's scores (inline,
analysis.py:16).score_model_comparisonreuses only per-field diagnostics, then computes its own pooled precision/recall/F1, page-exact and P95. The official scores come fromscore_rows(upstream per-field evaluation for Zyte, the adapter's page-hit macro for SWDE), so "F1" means different things. It also hasdataset == "swde"branches, dropsOutOfStockby name, and borrowsnormalize("crawl4ai-json", …). References and page text come from a hand-writtencase-contract.json, checked only against itself, and never derived from the frozen ground truth ordataset/html.
Correctness
- The service 429 becomes a scored engine failure (inline).
create_plangives each self-hosted method its own resource at the default--concurrency 4(certification.py:128-143), but the service admitsEXTRACTION_MAX_WORKERS(default 1) and returns429 "Extraction worker capacity reached"to the rest.access_blocker(pipeline.py:1273-1319) matches 403/429 only by account/quota wording, so that 429 is recorded as an ordinary failed call. Withquality_retries: 0, roughly 3 of every 4 calls fail. Reject a self-hostedmax_in_flightabove the frozenservice_worker_capacityat plan time, and treat the service 429 as an infrastructure stop. - Web Search Ctrl-C still records killed calls as real failures (inline). curl still runs through
subprocess.runin the terminal's process group (web_search/runner.py:253), so the deferred SIGINT kills it (returncode -2) and the attempt is saved as a transport failure. With the new partial checkpoint, that killed attempt now uses up the declared retry on resume. If it was the last attempt, it is committed as a final result that resume keeps. Start curl withstart_new_session=True, or discard negative return codes whilestoppedis set. - An interrupt while draining hides the error that stopped the run (inline,
benchmark_execution.py:209-214). Reproduced: a job raisesValueError, SIGINT arrives during the drain, andrun_jobsraises a bareKeyboardInterruptwith no__context__. Budget, evidence or commit errors are lost. A second Ctrl-C is still only deferred, so there is no escalation past a hung call. Raise the stored failure chained from the interrupt, and let a second SIGINT restore the previous handler. - The default concurrency is still 4 and still feeds latency comparisons. That is
web_fetch/certification.py:193-194andweb_extract/cli.pyplan --concurrency(where 1 needs--serial-reason). The home latency table (report.pyoperating_metrics) still marks Mean/P50/P95 winners across cohorts collected at different in-flight loads, and only the protocol page discloses the load. Default to 1, or make latency highlights neutral when loads differ. - Medium: the "returned objects" wording regressed. d236b5a reverted the labels to "Structured responses / Fields were returned" (
messages.json:132-150, 222, 250, 700, 728).structured_outputis also set for an all-empty{}, and the same table's header now says "Returned objects".
Still open from the previous review, lower priority
packageandpublishinconfigs/report-templates.json(lines 95, 98) still omit--profile/--home, whichcli.pynow requires, so the documented commands fail at argument parsing.table()setsdata-highlight-ties="all"on every Web Extract table, so the new completion, worker and latency columns highlight ties. Commit a118cdf reverted the neutral-tie fix.- The worker CPU/RSS "lowest" leader is still named although out-of-process backends are excluded. Firecrawl wins by construction, so make it neutral.
- The cost-unavailable disclosure is still checked only against its own numbers, not recomputed from row charge receipts (
check_cost_disclosures). - Published
result-{method}-{cid}.htmllinks now 404, and the release notes don't say so. - SDK-specific usage parsing (
self_hosted_usage), the duplicated effective-capacity calculation (Web Extract vs Web Search), product field names hard-coded inreport.py/report.js, and method-table detection by header text. inline_limit_bytes: an inline 413 still leaves the journal stuck on inline.- Web Fetch still commits a single failed attempt after a stop (
web_fetch/runner.py:921-923). This is low, because the run is then uncertifiable. - Browser Use / Trajectory Replay are registered as
execution_ownerbut only stamp a policy into metadata. Process-tree cleanup is duplicated withweb_fetch/providers/base.py.make ci-testssyncs a separate Python 3.12 SDK environment every run. The rootDockerfilestill uses an unpinned aptchromiumanduv sync --frozen.
Minor
- Stagehand hashes the whole Chromium binary in each request child, twice per request (inline), and only Stagehand pays this inside measured latency. Hash once at startup and pass it down.
- With case-unit resume, a re-run case reuses its old partial attempt, mixing two execution windows in one case (
web_search/runner.py:476-494). - An interrupted provider-parallel Web Fetch run lists the same attempts twice in
manifest.unexecuted. - ConnectTimeout in model comparison is a dead end: resume refuses to continue, and
model-repair-planrejects it. self_hosted.pygrew about 390 lines of attestation machinery (per-file site-packages hashing, the compileall lock, prctl/itimer supervision, boot-ID and cgroup capture) for a local example service. Simple is best: a package list, the image digest and the worker capacity would cover it.
Merge order: merge-tree gives 4 conflicting files with #259 and 10 with #260. Merging #259 first, then rebasing this PR, then #260 keeps each resolution small.
There was a problem hiding this comment.
Duplicate submission caused by a network retry; see #258 (review)
There was a problem hiding this comment.
✅ Re-review complete · baf388a
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · ea8614c
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 0279f89
No findings in this incremental review.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
lanyue-llk
left a comment
There was a problem hiding this comment.
Re-review at bdd6083b, P0/P1 only.
Fixed since 1f03d16b, verified in code:
- The service's own 429 no longer becomes a scored failure. Self-hosted participants now share an endpoint-keyed resource capped at
service_worker_capacity, andaccess_blockermaps the 429 toservice_capacity, which pauses the run instead of scoring the call. - Web Search's curl now runs in its own session, so terminal SIGINT no longer kills in-flight calls.
- An interrupt while draining now chains to the original failure instead of hiding it. A second Ctrl-C escalates.
- Certified Web Fetch defaults to 1 worker.
No P0 found. Three P1s remain; details are in the inline comments.
- Model comparison is still a parallel stack, and its published numbers are not bound by the renderer. (
model_comparison.py, unchanged in substance) - One latency ranking now mixes loads. Hosted APIs default to 4 in-flight calls; self-hosted engines are capped at 1. (
certification.py:147) - Silent conflict with #259 over what comes first on the home page. This will not appear as a textual merge conflict. (
report.py:207)
Textual conflicts are unchanged: 8 files with #259 and 13 with #260. Suggested merge order is still #259, then this PR, then #260.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
There was a problem hiding this comment.
✅ Re-review complete · 39ce703
No findings in this incremental review.
There was a problem hiding this comment.
✅ Re-review complete · 25cd118
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
Re-review at 25cd1185, P0/P1 only. No P0 or P1 remaining.
All three P1s from bdd6083b are fixed; I checked each in the code:
- Model tables:
model_comparison_tablesnow rebuilds each table from the hash-bound scored JSON inside the published evidence archive. It also recomputes the aggregates from the per-case rows, andcheck_reader_contractcompares the rendered tables. Latency columns are neutral. - Mixed loads:
--concurrencydefaults to 1.latency_comparablesuppresses latency winners whenever effective in-flight limits differ or are undeclared, and the note says so. This is applied in both the cohort and record renderers and in their checks. - Home-page order: an
indexintro is rejected, and the core comparison must be the first element ofmain. The model-comparison stack is still separate, but its published numbers are now bound to evidence, so I'm not blocking on that.
Merge note, not P1: #259 (ac153f8d) now carries its own copy of authored_intro, page_intro_hash and page(intro=...), and handles a home intro differently. #259 places it after the core comparison; this PR rejects it. report.py will conflict textually, so pick one rule while resolving and keep a single implementation. Whichever PR merges second should drop its copy.
The new 429 retry for read-only verification in reporting/publish.py is confined to GET/HEAD reads, which is safe.
Add native self-hosted Crawl4AI, ScrapeGraphAI, Stagehand and Firecrawl to the existing Zyte and SWDE reports. Their 3,760 new results join 9,680 fully reviewed SDK/API results. The existing scores and reviews are reused. Extruct is removed from active code, dependencies and reports.
All seven candidates have qualification evidence. Scrapy and Scrapling need site rules or another extractor for generic schema extraction; Crawlee qualifies through its Stagehand integration. The reports cover these interface differences, deployment locations, Firecrawl commercial-use requirements and software/model costs.
The six-service stack runs in Rainbond Efficiency / office. Worker admission is service-wide; subprocess deadlines cover extraction and Firecrawl identity validation. Startup attestations bind code, native services and host generations. Browser hashing now happens at startup and is reused in request children while file signatures match; all four deployed identities match
ea8614c92. The shared execution contract covers resource-aware concurrency, measured preflight, pacing, durable checkpoints and account-denial stops. Completed calls survive interruption; cancellation during model loading leaves an unsent generation eligible for resume. Recovery preserves predecessor evidence and never retries quality failures.The interpretation pages now open with one diagram of the four native extraction paths and the separate fixed-text model study. Crawl4AI uses HTTP/Markdown and XML-block extraction; ScrapeGraphAI parses local HTML and can parallelize chunks before an LLM merge; Stagehand extracts from a Chromium page; Firecrawl uses its native scrape/JSON pipeline. The reports distinguish available acceleration from the caching, browser lifecycle and concurrency settings actually used. All four full SDK/API configurations use DeepSeek; the dual-5090 model study is a separate comparison.
Model comparison
Add Qwen 3.8 27B, Gemma 4 12B, Nemotron 3.5 Lightning 30B-A3B and Nemotron 3.5 Bolt E4B, each with predeclared thinking and direct modes. The 576 new model-page results reuse the same held-out 24 Zyte and 48 SWDE pages, frozen Cloudflare text, prompts and references. Eight preflights are separate. DeepSeek and every old model received zero additional generation calls.
The combined study retains 1,656 authoritative comparisons and 1,762 physical generation attempts, including historical controls and repairs. Model scores are automatic, with 0/1,656 independently reviewed; this study does not replace the fully reviewed SDK/API cohort. All four new packages remain under
/data/linkaiand run in a separate Ollama 0.40.15 instance on the existing GPU host.Representative configurations are below; both reports retain all 17 held-out configurations. Timings begin after model loading and include request/response transfer. Reused and new rows come from different collection windows, so these records do not establish a contemporaneous speed ratio. Mean/P50/P95 and all-call timing, including failures, are available in the reports.
Gemma 4 31B thinking has the highest Zyte field F1 across all tested configurations, 93.43%. The new Qwen thinking configuration slightly exceeds DeepSeek on Zyte, while the highest new SWDE score is Bolt direct at 69.98%, below DeepSeek's 74.35%. Retained Gemma 4 31B direct still has the highest field F1 among tested local direct configurations on both subsets. Lightning thinking exhausts the 8,192-token output budget on ten pages before producing any field answer; raw
lengthtermination events and schema errors are inspectable. Successful model loading took up to 25.5 minutes on the rotational data volume and is reported separately. All model/draft layers were placed on GPU; no native input truncation was observed.The reports display model F1 to two decimal places, including Qwen's 91.18% and DeepSeek's 90.51% on the Zyte 24-page subset. The Gemma 31B runtime diagnosis uses its retained 144 calls: direct output has a median of 38 generated tokens and 1.671 seconds, versus 511.5 tokens and 5.034 seconds in thinking mode. Native prompt/decode timers, mean/P50/P95, and per-receipt hashes are inspectable. Thinking improves Zyte F1 and reduces SWDE F1 in these samples.
The measured Gemma package uses Q4_K_M weights, draft-MTP with at most three proposed tokens, context 20,000, output limit 8,192, Flash Attention, Q8 KV cache, one active generation and one loaded model. Logs place all 61 main-model layers and all five draft layers on GPU, with buffers on both RTX 5090 cards. The cards share a PCIe host bridge; no NVLink was reported. Clearing unrelated idle Ollama models releases capacity for future loading; it does not establish a faster historical result.
Deployment and reproduction · Model collection, additive cohorts and offline scoring · Zyte report · SWDE report. Both reports retain their existing private access settings and provide the original and supplemental model evidence archives, exact tags/digests, raw streams, sampling parameters and offline scoring instructions.
Evidence and validation
model-score. Controls reject wrong F1/timers, missing rows/bindings, aggregate errors in both directions, and incomplete or duplicate cases. Authored content supplies placeholders and labels.