Skip to content

fix(web-fetch): score declared image links and heading-price catalog cards - #250

Merged
lanyue-llk merged 4 commits into
mainfrom
fix/scorer-image-links-and-price-cards
Nov 5, 2026
Merged

lanyue-llk merged 4 commits into
mainfrom
fix/scorer-image-links-and-price-cards

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Question

Why do tasks that passed on stored answers fail when those same answers are rescored by the current scorer, and do the closed fixes for #85 and #86 reach real runs?

Cause

Item Shared cause
Image tasks (candidate_scope: image_answer_fields, 9 tasks) The headless route returns {"links":[...]} and declares output_contract: structured_resource_urls. The image branch reads only image-typed JSON keys, so it finds no candidates.
Catalog cards (dynamic-catalog, dynamic-020-webscraper-io-test) In _product_start, the title-then-price layout claims any line above a price. For #### $price then #### [title], the title becomes 117 items or the previous card's 1 reviews, and the real title ends the card. Result: 0 complete records.

Fix

  • metrics.py: under image_answer_fields, read the top-level links strings only when the route declares structured_resource_urls. Only the headless route sets that value, and its image selector is img,picture source, so that list holds image URLs.
  • Why the scorer and not the projection: emitting images would change the projection expression and its hash, and stored answers would stay at 0 until a rerun. This fix leaves the projection and its hash unchanged.
  • stable_tasks.py: in catalog_product only, when a heading price is followed by a heading no deeper than it, the plain line above is no longer taken as the title, so the price starts its own card. product parsing matches main, and catalog Alpha then #### $10 with no heading after it, or with a deeper heading as its description, stays title-first.
  • Bindings: 9 controls added to scoring-regressions.json, 2 correction entries and new hashes in code-migration.json. SCORING_SOURCE_SHA256 is now 0cc6d7df…, which moves six routes in tests/golden/web-fetch.json (the same six as fix(web-fetch): repair six scorer defects with paired controls #239). I did not separately prove those golden changes are hash-only.

Evidence

Stored answers in webfetch-430-refresh-20261014/evidence, rescored read-only with cases from its dataset.json. No provider ran and no stored file changed.

Image tasks, passes out of 9:

Provider Stored verdict Rescored on main Rescored with this PR
chromium 7 0 6
lightpanda 7 0 6
obscura 7 0 6
kitesurf 5 0 3
moli-fixed 9 6 6
moli-pr919 9 4 4

Catalog tasks: all 6 providers go from stored 2/2 to 0/2 on main to 2/2 with this PR. The other 2 tasks using a product schema give identical verdicts on both trees.

This does not restore every stored image verdict. The remaining gaps have other causes:

  • The stored metrics were scored against older expected URLs than the current dataset.json. For example, image-04 now expects Wikimedia thumbnail URLs with utm_* query strings. Chromium's answer has no such URL. Kitesurf's has the thumbnail path, but the task still fails.
  • Kitesurf image-pexels-detail passed only because the old scorer's bare-URL reader dropped the query string. Its answer has pexels-photo-12377231.jpeg?auto=compress..., while the task expects no query.
  • Moli's route is not affected by this fix, so its counts do not move. I did not fully root-cause each Moli failure.

Controls

Control Expected main scorer This PR
structured-resource-route-image-links-answer pass fail pass
structured-resource-route-undeclared-links-rejected fail fail fail
structured-resource-route-diagnostic-json-rejected fail fail fail
catalog-heading-price-title-cards-complete pass fail pass
catalog-heading-price-without-title-incomplete fail fail fail
catalog-plain-title-above-heading-price-complete pass pass pass
product-plain-title-above-heading-price-complete pass pass pass
product-plain-title-above-heading-price-and-heading-complete pass pass pass
catalog-plain-title-above-heading-price-deeper-description-complete pass pass pass

Two controls flip; the other seven are guards that already held. The last four pin the title-first layout, which earlier revisions of this PR broke.

answer_format (#85, #86): not reachable in real runs, left unchanged

  • Nothing under src/harness, scripts, configs or evaluation declares answer_format; only regression fixtures do.
  • A scan of the 121 results.jsonl files found under ~/.browser-eval/evidence, skipping any of 1 KiB or less, found none containing answer_format. score_attempt records the field when it is declared.
  • The HTML article fallback interprets literal Markdown as links and comment headings #85 fix applies only to declared html and the Plain-text document structure is still parsed with Markdown syntax #86 fix only to declared plain_text, so neither runs for these answers. Their tests pass because the fixtures declare the format.
  • I made no change because no single declaration fits: routes return different formats, and existing controls show declared and inferred Markdown giving different verdicts on the same bytes. Declaring it would need a per-route decision and a verdict impact check.

Tests

Rebased on 506b2743.

  • Final commit: tests/benchmarks, tests/test_scoring_regressions.py and tests/test_golden_reports.py gave 11407 passed, 4326 subtests passed. Ruff passes. The 22 distinct stored catalog answers each still give 6 complete records.
  • Full suite, previous commit 04ca0916: 14 failed, 20053 passed, 61 skipped. The baseline on d053e239 was also 14 failed, with the same 13 tests (Node converter, CI gate, local data) plus the same Moli subtest failure, test_answer_capacity_does_not_limit_native_resource_downloads, which passes alone. Parser changes since then are the catalog_product gate and the heading-level check; the rebases also brought in other changes from main.
  • tests/trajectory_replay/test_playwright_tool.py failed in one earlier full run on this branch and passes alone and in the 04ca0916 run.

Known limit

A rescore of all 2,580 stored records was stopped unfinished, so verdict changes outside the 13 tasks above are unchecked.

What I did not do

  • Rewrite stored verdicts, frozen profiles or published reports, or call any provider.
  • Change image references, query-string matching or the Moli results.
  • Declare answer_format.
  • Add a control for prose in a declared route. Non-JSON content does not reach the new links reader, but no control pins that.

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

This review found 2 issue(s), including 2 blocking issue(s).

"expected_task_pass": false
},
{
"id": "catalog-heading-price-title-cards-complete",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test · medium
P2 — Add a compatibility control for the shared product parser, not only price-first catalog cards. With schema: product, minimum_records: 1, and artifact Alpha\n#### $10, the previous _product_start recognized name + price; the new heading-level guard skips Alpha, then creates a price-only record (the price-first branch supplies a title only for catalog_product). This loses a previously complete record, but both new catalog controls miss it. Add an expected-pass control for this layout and preserve that behavior in the parser before updating the correction binding. This is a localized scoring compatibility/coverage regression.

Comment thread src/lexbench_webfetch/stable_tasks.py Outdated
next_price = index + 1 < len(lines) and re.fullmatch(_MONEY, _field(lines[index + 1], "price"), re.I)
# A heading price starts its own card; a plain line above it is not its title.
next_price = (index + 1 < len(lines)
and not (levels and levels[index] is None and levels[index + 1] is not None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
P2 — Preserve the supported title-before-price layout for product cards. With schema product, Alpha\n#### $10 previously produced a valid {name: "Alpha", price: "$10"} record. This new condition skips Alpha; the price-first branch then returns only price because it consumes a following title only for catalog_product, so _record reports invalid_field:name. The same regression applies to native HTML with a plain name followed by a heading price. This is a localized scoring regression, not just missing coverage. Restrict the catalog boundary fix so it preserves the existing product layout, and add a public-scoring regression control for it alongside the new catalog controls.

@lanyue-llk
lanyue-llk force-pushed the fix/scorer-image-links-and-price-cards branch from a51d6f4 to 04ca091 Compare November 5, 2026 06:29

@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 · 04ca091

This review found 1 issue(s), including 1 blocking issue(s).

Comment thread src/lexbench_webfetch/stable_tasks.py Outdated
Comment on lines +513 to +515
next_price = (index + 1 < len(lines)
and not (levels[index] is None and levels[index + 1] is not None
and index + 2 < len(lines) and levels[index + 2] is not None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
P2: Restrict this heading-price disambiguation to catalog cards. For the supported product schema, Alpha\n#### $10\n#### Free shipping\n previously yields a valid name/price record with shipping. The new condition skips Alpha because the following two lines are headings; parsing then starts at $10, and the product price-first branch never consumes a name, producing invalid_field:name. This also affects a heading price followed by a new section heading. The added product regression only covers end-of-input, so it misses this remaining false negative. Gate the exception on schema == "catalog_product" and add a product control with a following heading.

@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 · 2649d5b

No findings in this review.

lanyue-llk added a commit that referenced this pull request Nov 5, 2026
lanyue-llk added a commit that referenced this pull request Nov 5, 2026
…cards

The rendered-DOM image route returns {"links": [...]} under the declared
structured_resource_urls contract, but image-answer scoring read only
image-typed JSON keys, so every headless image task scored zero. Read that
declared list as image candidates; undeclared JSON and diagnostic keys stay
excluded.

A plain line above a heading price was taken as the card title, so
'#### $price' + '#### [title]' catalog cards lost their titles and parsed
to zero complete records. A heading price now starts its own card.

Adds five paired controls and the matching code-migration bindings.
A heading price only starts its own card when a heading title follows it.
Plain 'Alpha' then '#### $10' stays title-first, as it was before this
branch. Adds controls for both product schemas and updates the scorer
bindings.
The price-first branch reads a title only for catalog_product, so applying
the rule to product cards lost the name in 'Alpha', '#### $10', '#### Free
shipping'. Product parsing now matches main. Adds a control and updates the
scorer bindings.
@lanyue-llk
lanyue-llk force-pushed the fix/scorer-image-links-and-price-cards branch from 2649d5b to 2126b47 Compare November 5, 2026 07:23

@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 · 2126b47

This review found 1 issue(s), including 1 blocking issue(s).

Comment thread src/lexbench_webfetch/stable_tasks.py Outdated
Comment on lines +515 to +516
and levels[index] is None and levels[index + 1] is not None
and index + 2 < len(lines) and levels[index + 2] is not None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
P2: This also suppresses a valid title-first catalog card when the heading after the price is a deeper description heading. For example, Alpha\n#### $10\n##### Blue machine\n2 reviews previously produces a complete catalog record: the level-5 heading belongs to the level-4 card's description. Now Alpha is skipped, Blue machine becomes the title, and the empty description makes the record invalid. Restrict the price-first override to a heading that actually establishes the next card title (accounting for heading levels), and add a catalog title-first regression with a deeper heading after the price; the new heading-after-price control only covers product.

Only a heading no deeper than the price is the next card's title. In
'Alpha', '#### $10', '##### Blue machine', '2 reviews' the deeper heading
is the description, so the card stays title-first as on main. Adds a
control and updates the scorer bindings.

@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.

✅ Re-review complete · b6995c2

No findings in this incremental review.

lanyue-llk added a commit that referenced this pull request Nov 5, 2026
@lanyue-llk
lanyue-llk merged commit 9b0172f into main Nov 5, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the fix/scorer-image-links-and-price-cards branch November 5, 2026 08:05
lanyue-llk added a commit that referenced this pull request Nov 9, 2026
Port of #252 (16 commits, head cebd6aa) onto #224 rebased on current #131,
resolved once. Same behavior as cebd6aa except:

- Keep main's CJK rule (#253): plain text folds letter-spaced single
  characters only, so separate CJK words or paragraphs never join
  (cjk-separate-paragraphs-fact-rejected passes again). The
  plain-text-typography control no longer relies on joining 中文 文本.
- Catalog price-heading cards keep #252's broader condition, which covers
  main's #250 case.
- Keep both stable-anchor fallbacks (escaped prose from #131, link labels
  and extracted fields from #252).
- Bind loop variables for B023 and recompute scorer source hashes; add
  #252's two correction records to the migration receipt.

Co-authored-by: Maisiqi <[email protected]>
lanyue-llk added a commit that referenced this pull request Nov 9, 2026
Port of #252 (16 commits, head cebd6aa) onto #224 rebased on current #131,
resolved once. Same behavior as cebd6aa except:

- Keep main's CJK rule (#253): plain text folds letter-spaced single
  characters only, so separate CJK words or paragraphs never join
  (cjk-separate-paragraphs-fact-rejected passes again). The
  plain-text-typography control no longer relies on joining 中文 文本.
- Catalog price-heading cards keep #252's broader condition, which covers
  main's #250 case.
- Keep both stable-anchor fallbacks (escaped prose from #131, link labels
  and extracted fields from #252).
- Bind loop variables for B023 and recompute scorer source hashes; add
  #252's two correction records to the migration receipt.

Co-authored-by: Maisiqi <[email protected]>
lanyue-llk added a commit that referenced this pull request Nov 9, 2026
Port of #252 (16 commits, head cebd6aa) onto #224 rebased on current #131,
resolved once. Same behavior as cebd6aa except:

- Keep main's CJK rule (#253): plain text folds letter-spaced single
  characters only, so separate CJK words or paragraphs never join
  (cjk-separate-paragraphs-fact-rejected passes again). The
  plain-text-typography control no longer relies on joining 中文 文本.
- Catalog price-heading cards keep #252's broader condition, which covers
  main's #250 case.
- Keep both stable-anchor fallbacks (escaped prose from #131, link labels
  and extracted fields from #252).
- Bind loop variables for B023 and recompute scorer source hashes; add
  #252's two correction records to the migration receipt.

Co-authored-by: Maisiqi <[email protected]>
lanyue-llk added a commit that referenced this pull request Nov 9, 2026
Port of #252 (16 commits, head cebd6aa) onto #224 rebased on current #131,
resolved once. Same behavior as cebd6aa except:

- Keep main's CJK rule (#253): plain text folds letter-spaced single
  characters only, so separate CJK words or paragraphs never join
  (cjk-separate-paragraphs-fact-rejected passes again). The
  plain-text-typography control no longer relies on joining 中文 文本.
- Catalog price-heading cards keep #252's broader condition, which covers
  main's #250 case.
- Keep both stable-anchor fallbacks (escaped prose from #131, link labels
  and extracted fields from #252).
- Bind loop variables for B023 and recompute scorer source hashes; add
  #252's two correction records to the migration receipt.

Co-authored-by: Maisiqi <[email protected]>
lanyue-llk added a commit that referenced this pull request Nov 10, 2026
* fix(webfetch): score returned structured page fields

Port of #252 (16 commits, head cebd6aa) onto #224 rebased on current #131,
resolved once. Same behavior as cebd6aa except:

- Keep main's CJK rule (#253): plain text folds letter-spaced single
  characters only, so separate CJK words or paragraphs never join
  (cjk-separate-paragraphs-fact-rejected passes again). The
  plain-text-typography control no longer relies on joining 中文 文本.
- Catalog price-heading cards keep #252's broader condition, which covers
  main's #250 case.
- Keep both stable-anchor fallbacks (escaped prose from #131, link labels
  and extracted fields from #252).
- Bind loop variables for B023 and recompute scorer source hashes; add
  #252's two correction records to the migration receipt.

Co-authored-by: Maisiqi <[email protected]>

* fix(webfetch): stop link labels and document titles from passing content checks

Independent review of #252 found two false passes in the shared scorer:

- Labels of returned links (Firecrawl, Exa and Lexmount return page-wide
  link lists) satisfied required body facts and stable anchors, so a
  truncated body plus a table-of-contents link passed. Link labels no
  longer feed facts or anchors, and tasks without an acceptance contract
  keep body-only facts.
- The Lexmount projection copied the document title (result.title) into
  page_information.title, letting it pass title contracts that reject
  document titles. It is already scored as the title field.

returned-link-label becomes a negative control; returned-link-fact-cross-page
is new. Both are bound in a new correction record.

* fix(webfetch): keep malformed Lexmount envelopes free of answer fields

After rebasing onto main (#224), a non-JSON body still merged projected
page fields into metadata without a declaration, so its evidence failed
verification. Merge answer fields only for a parsed envelope. Refresh the
route baseline for the projection source hash.

* fix(webfetch): keep returned-field scoring within declared scope

Returned headings no longer satisfy title checks that exclude page regions,
since a flat field cannot prove it came from outside them. Remove the
dev.to-specific comment-card parser and revert the unbound named-link,
catalog-boundary, Han-spacing and section-heading scoring changes to main;
they need their own bound corrections.

* fix(webfetch): keep returned duplicates and paragraph breaks visible to checks

Repeated returned records now reach the duplicate-record check, and plain-text
paragraphs ending in CJK punctuation no longer join. A trailing reply-form
heading no longer hides earlier comments. Report evidence shows only fields
the scorer accepts for an anchor, and the method-comparison caption is
localized. Bind two new controls.

* fix(webfetch): merge returned records only with valid, case-exact text rows

A complete returned record replaces the same fields parsed as invalid text, and
API paths that differ only in case stay separate records. Revert the comment
discussion-heading start rule to main: a populated reply-form heading could
hide earlier comments.

* fix(webfetch): let each text record absorb only one returned copy

Further identical returned rows reach the duplicate-record check even when the
body also contains the record. Bind a paired control.

* fix(webfetch): consume each text record once across quote and exact matches

A body quote could absorb one returned copy by exact fields and another by
equivalent tags. Track consumed text rows by index. Bind a quote control.

---------

Co-authored-by: lanyue-llk <[email protected]>
Co-authored-by: Maisiqi <[email protected]>
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