Skip to content

fix(webfetch): ignore malformed and metadata fields in Lexmount answers - #261

Merged
lanyue-llk merged 2 commits into
mainfrom
fix/lexmount-malformed-fields
Nov 10, 2026
Merged

lanyue-llk merged 2 commits into
mainfrom
fix/lexmount-malformed-fields

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

Follow-up to #252.

Lexmount answer fields before and after: malformed fields become absent; description and site_name stay document metadata

Problem

#252 introduced two P1 regressions in Lexmount /v1/extract scoring:

  1. Malformed optional fields abort the run. The projection copied result.author, result.publish_time and result.extra.* into page_information, page_structure and records without type checks. The shared scorer validates those fields strictly and raises ValueError; runner.py calls score_attempt unguarded, so one successful response such as publish_time: 1730000000, author: [{"name": "A"}], extra.subtitle: {...}, extra.dom_summary.headings: [{"level": 1, "text": "H"}] (title contract) or extra.reviews: {} (quote schema) stopped the run. These scored normally at 914ed1e.
  2. Document metadata counted as page text. result.description and extra.site_name were projected as page_information, so a navigation-only body (Home | Products | About us | Contact | Sign in | Cookie settings) passed stable anchors, required facts and page patterns found only in the meta description. This contradicts fix(webfetch): score returned structured page fields #252's own rule that the title and generic document metadata stay separate.

Fix

  • native_projection.py (policy 7, fixed in place because no evidence uses it yet): scalar page fields use text_or_none; list fields keep text_items. page_structure keeps only headings as a text list and is dropped unless dom_summary is an object; records is dropped unless the selected rows are a list. Malformed fields are now absent, not exceptions. description and site_name are no longer projected, and result.description leaves the Lexmount route. Policies 4-6 keep their original behavior.
  • response_input.py: page_information_texts ignores description and site_name, as it already ignores section_headings, so no adapter can reintroduce the false pass. The report's anchor evidence uses the same field set.
  • README: removed the stale sentence that returned named-link labels can satisfy unscoped page-text anchors; documented both rules.

Evidence

  • tests/test_lexmount_native.py: every repro runs through the real adapter, native projection verification, score_attempt and the task predicate. Malformed fields score as absent (positive and negative cases); description/site_name fail anchors and page patterns while the same value in extra.subtitle passes. Before the fix the malformed cases raised ValueError.
  • scoring-regressions.json: paired controls description-field-not-page-text (false positive; fails against the previous response_input.py) and extracted-subtitle-field-page-text (false negative).
  • code-migration.json: refreshed response_input.py hash and a correction record binding the root cause and both controls.
  • tests/fixtures/native-route-baseline.json regenerated for the new projection source hash.
  • make lint-check passes; targeted pytest (Lexmount native, native projection, route contract, extracted page information, current scoring controls, saved report/matrix tests): 363 passed.

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

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.

✅ Re-review complete · 628af46

No findings in this incremental review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Independent review at 628af465: no P0/P1. Two non-blocking P2s go to a follow-up:

  • native_projection.py: text_or_none on author/subtitle/publish_time drops valid text lists (e.g. several authors).
  • providers/lexmount.py:179-180: a non-string title/final_url still raises in require_native_answer_projection (pre-existing on main).

@lanyue-llk
lanyue-llk force-pushed the fix/lexmount-malformed-fields branch from 628af46 to c73cbee Compare November 10, 2026 12:55

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

No findings in this review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Rebased onto main (5d3d67be); the only conflict was the generated tests/golden/web-fetch.json, regenerated with UPDATE_GOLDEN=1. Code is unchanged from the independently reviewed 628af465 (no P0/P1). Non-blocking P2s go to a follow-up: text_or_none drops valid text lists for author/subtitle; a non-string title/final_url still raises (pre-existing).

@lanyue-llk
lanyue-llk merged commit ea2a5ab into main Nov 10, 2026
8 checks passed
@lanyue-llk
lanyue-llk deleted the fix/lexmount-malformed-fields branch November 10, 2026 13:05
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