Repository navigation
fix(web-fetch): repair six scorer defects with paired controls - #239
Conversation
There was a problem hiding this comment.
This review found 3 issue(s), including 3 blocking issue(s).
| # parameter definitions, remain part of the enclosing description. | ||
| local = copy(description) | ||
| for term in local.select('dt'): | ||
| if term.decomposed or not _api_signature(term.get_text()): |
There was a problem hiding this comment.
P2 — Normalize HTML signature whitespace before testing for nested ownership. term.get_text() preserves source newlines, but _api_signature uses .* without DOTALL. Changing the existing definition-nested-signature-body-only control's child term to <dt>child(\n)</dt> therefore leaves the child and its description in the parent's copied dd. The parent still receives sufficient body text and passes despite having no description of its own, leaving #112 unfixed for line-wrapped HTML signatures. Collapse whitespace for this HTML signature check (without broadening recognition to non-signature parameter terms), and add this variant as a rejection control.
| inline = visible_html_text(''.join('<br>' if id(child) in ancestry else str(child) | ||
| for child in children)) |
There was a problem hiding this comment.
P2 — Escape text nodes before reparsing this fragment. str(child) serializes a Tag safely, but returns decoded text for a NavigableString. With declared HTML <article><a href="/item/1">Widget</a><span>$10.00</span></article> and price pattern \$\d+\.\d{2}, the existing field correctly fails to match the literal <span>$10.00</span>, whereas this new candidate reparses it as markup and accepts $10.00. This introduces a false-positive product record. Preserve DOM text as text (and exclude comments), either by escaping non-Tag children or by projecting the existing nodes without a serialize/reparse round trip. Add an escaped-markup negative control paired with genuine inline elements.
| end = next((section.start() for section in sections | ||
| if bullet.end() <= section.start() < end and len(section[1]) <= indent), end) |
There was a problem hiding this comment.
P2 — Compare the heading indentation against the list item's content column, not the bullet marker's indentation. For - Widget\n\n ## Related\nUnrelated section prose., the one-space-indented heading is outside the item (whose content starts at column 2), but 1 <= 0 is false, so the unrelated section still supplies Widget's missing description. This leaves the ownership defect in #111 unresolved for valid indented headings. Derive the content column from the marker plus following whitespace and stop at headings below that column; add this case and an ordered-marker case alongside the existing in-item heading control.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
src/lexbench_webfetch/article_comments.py(token_budget_reached): skipped round 2 of group "src/lexbench_webfetch/article_comments.py,src/lexbench_webfetch/article_posts.py,src/lexbench_webfetch/article_text.py,src/lexbench_webfetch/document_structure.py,src/lexbench_webfetch/dynamic_lists.py,src/lexbench_webfetch/metrics.py,src/lexbench_webfetch/stable_tasks.py,tests/golden/web-fetch.json": used 504161 tokens exceeds budget 500000
| prices = [_visible_product_field(value, representation) | ||
| for node in owner.select(scope['price_selector']) | ||
| for value in (node.get_text(' ', strip=True), visible_html_text(str(node)))] |
There was a problem hiding this comment.
P2 — Preserve existing price-candidate priority across all selected nodes. This comprehension interleaves each new inline-preserving candidate with the old candidates, rather than appending them afterward. With two matching price elements, <span class="price">$<b>10</b>.00</span><span class="price">$20.00</span> and pattern \$\d+\.\d{2}, the old path selects $20.00, but this change selects $10.00 via prices[0]. This contradicts the stated compatibility guarantee that already-selected prices remain unchanged and can change fixed-membership outcomes when price participates in the record hash. Collect all original get_text candidates first, then append all inline-preserving candidates; add a two-price-element regression control.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
src/lexbench_webfetch/article_comments.py(token_budget_reached): skipped round 2 of group "src/lexbench_webfetch/article_comments.py,src/lexbench_webfetch/article_posts.py,src/lexbench_webfetch/article_text.py,src/lexbench_webfetch/document_structure.py,src/lexbench_webfetch/dynamic_lists.py,src/lexbench_webfetch/metrics.py,src/lexbench_webfetch/stable_tasks.py,tests/golden/web-fetch.json": used 512046 tokens exceeds budget 500000
| return records | ||
| bullets = [] if literal else list(re.finditer(r"(?m)^\s*(?:[-*+]|\d+[.)])[ \t]+\S.*$", text)) | ||
| if bullets: | ||
| sections = list(re.finditer(r'(?m)^( {0,3})#{1,6}[ \t]+\S', text)) |
There was a problem hiding this comment.
P2: This boundary scan also matches escaped literal hashes after _visible() has decoded Markdown escapes. For example, the Markdown answer - Widget\n\# This is the widget description. has a valid lazy paragraph continuation, not a section heading. _visible() restores \# to # before _descriptions() runs, so the new scan truncates the record before its only description and turns a previously complete record into a failure. Preserve whether the heading marker was escaped through boundary detection (or identify boundaries before escape restoration), and add a public-scorer control pairing an escaped hash continuation with a real outside heading.
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
| opaque = not body_view and value in {'`', '\\'} or ( | ||
| schema == 'name_description' and value == '#' | ||
| and not text[text.rfind('\n', 0, match.start()) + 1:match.start()].strip()) |
There was a problem hiding this comment.
P2: Preserve escaped hashes within a leading hash run, not only at its first position. For example, - Widget\n#\# This is the widget description. is a bullet with a lazy paragraph continuation, not an ATX heading: the escaped second hash prevents the raw heading prefix from matching. Here the prefix before that escape is #, so _visible restores it as an unescaped ##; the new section scan then truncates the record and rejects its otherwise valid description. ## ... has the same problem. Keep such decoded hashes opaque until scalar rendering and add a paired regression control so literal hash runs cannot become section boundaries.
| return records | ||
| bullets = [] if literal else list(re.finditer(r"(?m)^\s*(?:[-*+]|\d+[.)])[ \t]+\S.*$", text)) | ||
| if bullets: | ||
| sections = list(re.finditer(r'(?m)^( {0,3})#{1,6}[ \t]+\S', text)) |
There was a problem hiding this comment.
P2: Empty ATX headings still allow a bullet to borrow the following section's prose. For example, - Widget\n\n##\nUnrelated section prose. contains a valid Markdown heading outside the list, but this pattern requires whitespace and a non-whitespace title after the hashes, so it finds no boundary. _descriptions consequently assigns the unrelated prose to Widget and a name_description contract with minimum_records: 1 still passes. This leaves a boundary case of #111 unfixed. Recognize empty ATX headings as well (including optional trailing whitespace), preserving the indentation ownership check, and add a public-scorer regression for this case.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Head reviewed: 96ab646a. Each finding was reproduced through the public score_attempt and task_passed, on this head and on base 8f2232b7. All inputs are declared markdown unless stated.
Findings
P1. src/lexbench_webfetch/stable_tasks.py:289: an escaped hash inside a hash run still becomes a section boundary (regression)
The opaque rule only covers a hash with nothing before it on the line. In #\# and ## the second hash decodes to ##, and the new scan at line 731 truncates the record.
| Input | Base | Head | Expected |
|---|---|---|---|
- Widget\n#\# This is the widget description. |
pass | fail | pass |
- Widget\n## This is the widget description. |
pass | fail | pass |
This confirms the bot comment. Fix: drop the line-prefix test and keep every decoded hash opaque for this schema: opaque = not body_view and value in {'', '\'} or (schema == 'name_description' and value == '#')`. I applied this locally: both inputs pass, and all current and historical controls still pass. Add the pair as controls.
P1. src/lexbench_webfetch/stable_tasks.py:731: a # line inside a fenced code block ends the description (regression)
_visible restores code payloads before _descriptions runs, so the scan treats a code comment as a heading. The neighbouring document-structure code states the opposite rule: "Markdown code contributes body content, but cannot declare section titles".
| Input | Base | Head |
|---|---|---|
- Widget\n```\n# code comment text here\n``` |
pass | fail |
- Widget\n```\nprint(1) and more\n``` |
pass | pass |
The verdict now depends on whether the code has a # comment, which is not an ownership signal. Fix: consume fences in the same scan, so one regex rule decides boundaries, and keep only matches of the heading group:
sections = [match for match in re.finditer(
r'(?ms)^ {0,3}(`{3,}|~{3,}).*?(?:^ {0,3}\1[ \t]*$|\Z)'
r'|^( {0,3})(?:#{1,6}(?:[ \t]+\S|[ \t]*$)|[^\s\n][^\n]*\n {0,3}(?:=+|-+)[ \t]*$)', text)
if match[2] is not None]Then compare len(section[2]) < column. I applied this locally. It also fixes the next two findings, and the only test failure was the expected after_sha256 binding. Add the pair above as controls.
P2. src/lexbench_webfetch/stable_tasks.py:731: empty ATX headings do not end a bullet
- Widget\n\n##\nUnrelated section prose. and the same input with ## both pass on head. The pattern requires a title after the hashes. This confirms the bot comment, and #111 is not fully closed. The regex above fixes it. Add a control.
P2. src/lexbench_webfetch/stable_tasks.py:731: setext headings do not end a bullet
- Widget\n\nRelated\n-------\nUnrelated section prose. and the ======= form both pass on head. This is the defect #111 describes, with a heading syntax that _text_events already recognizes. The regex above fixes it. - Widget\n Real desc.\n---\n- Other\n Other desc. still passes with that change. Add a control.
P2. src/lexbench_webfetch/article_text.py:156: a literal HTML link in a text node still creates a permalink (#85)
With the #85 issue contract, declared html:
<h2><a href="/post/1">Alice</a></h2><p>First post.</p><h2><a href="/post/2">Bob</a></h2><p>Second post.</p>
This passes on base and on head, although the DOM contains no links. str(node) decodes the entities, _literal_markdown_text does not escape <, and the record parser then reads a real anchor. #85 says fallback must not credit structure that is absent from the DOM, so Closes #85 is not yet accurate. Fix: add < to the escaped set, r'([\\*[]<])'`. I applied this locally: the input fails, the genuine-anchor control still passes, and all controls pass. Add a rejection control.
P2. PR body: stale values and undisclosed verdict classes
- Stale hash.
SCORING_SOURCE_SHA256at this head is825e584b1d28…, but the body gives11a32c43…in "Values that moved" and "What #114 needs". Update it after the fixes above move it again. - Stale counts. The file adds 44 controls, not 43. 18 of them fail on verdict alone against the base scorer. Recount the "21 of 43" figure at the final head, including
expected_metrics. - Inaccurate #111 row. It says other records keep their verdict. These do not:
\# Widget\n\nDesc of widget here.goes from pass to fail, because the no-bullet heading branch no longer sees the now-opaque hash. Failing is defensible, since a literal hash is not a heading, but it is a verdict class that #114'schange_notemust disclose.- The fenced-code case above also moves, unless it is fixed first.
Add the first class to the table, and re-derive the table after the fixes.
P3. src/lexbench_webfetch/stable_tasks.py:2025: matched can exceed observed on duplicates
For #83's contract, an answer repeating one quote gives stable_source_observed_record_count: 2 and stable_source_matched_record_count: 3. The verdict correctly fails. #83 asks for consistent counts, so consider counting unique matched records.
Verified with no defect
- #83: the swapped-author reproduction gives observed 2, matched 0, mismatched 2, and the rejected records carry their hashes. The matching answer gives 2, 2, 0 and passes.
- #85: literal
[Alice](/post/1)now fails and genuine anchors pass. Literal## <a…>in a paragraph also fails. - #86: indented and fenced plain text pass, and the same bytes declared as Markdown still fail.
- #110:
- Inline prices pass in the unscoped, in-anchor and comment-split forms.
- Escaped
<b>$10.00</b>fails,$<br>10.00and block-split prices fail, and a neighbour's price does not fill a record. - The extra
visible_html_textparsing added 0.3 to 0.5 s on 1,500 to 3,000 element pages, which is acceptable.
- #112: the reproduction, the line-wrapped form and an empty child all fail, and the parameter-list control passes.
[source],→andclassmethodprefixed nested terms stay parent text, as the PR describes for non-name(...)terms. The four frozen definition contracts I found on disk contain only plainname(...)headings. - Hash
\#in_render_inline_scalar: a fixed-membership hash for a name containing literalC\#still matches in HTML, plain text and Markdown (C\\\#). - Bindings:
code-migration.jsonregression IDs match the 44 added controls exactly, anddata-lock.json, frozen profiles and receipts are untouched. - Over-design: nothing to remove.
_api_signature,_local_definition_textand theliteralflag are proportional, and there is no new test machinery. - Local tests:
tests/test_golden_reports.py,tests/benchmarks,tests/test_scoring_regressions.pyandtests/test_scoring.pygave 11426 passed. The ruff gate passes. - Golden routes: the snapshots pass. I did not independently repeat the PR's check that the route changes come only from the scorer hash.
CI
"Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass on 96ab646a. ocr-review is red, and two of the findings above are its two blocking findings.
|
Review round 1 is addressed on Fixed
One change from the suggested regex A setext title now needs an empty line before it. As suggested, The scan also accepts a longer closing fence and does not treat an inline Disputed: nothing. Not rebased: the branch stays on Known limits, both still open:
|
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
| def article_markdown(content): | ||
| def _literal_markdown_text(text): | ||
| """Escape Markdown syntax in a DOM text node; only elements create structure.""" | ||
| text = re.sub(r'([\\`*\[\]<])', r'\\\1', text) |
There was a problem hiding this comment.
P2: Backslash-escaping < does not preserve literal tags through the fallback's subsequent HTML parse. Both _coverage_text_records and _text_records pass this projection through article_html/_post_html again, and BeautifulSoup still recognizes \<script> as a script element. For example, a genuine fallback comment whose body is <p><script>This is visible comment prose.</script></p> loses that prose during the second visibility pass, even though it is displayed text in the declared HTML. This leaves the literal-tag requirement of #85 incomplete and can reject valid records. Protect text-node tag syntax with opaque placeholders (restored only when reading owned fields), or otherwise prevent it from reaching another HTML parser as markup; add a positive literal-tag body control.
| sections = [match for match in re.finditer( | ||
| r'(?ms)^ {0,3}(`{3,}(?=[^`\n]*$)|~{3,}).*?(?:^ {0,3}\1[`~]*[ \t]*$|\Z)' | ||
| r'|^(?:(?= {0,3}#{1,6}(?:[ \t]+\S|[ \t]*$))' | ||
| r'|(?<![^\n]\n)(?= {0,3}\S[^\n]*\n {0,3}(?:=+|-+)[ \t]*$))( {0,3})', text) |
There was a problem hiding this comment.
P2: The setext boundary requires a literally empty preceding line, rather than a Markdown blank line. (?<![^\n]\n) rejects a line containing spaces or tabs. For example, - Widget\n \nOther section\n-------------\nUnrelated prose still assigns the section title and prose to Widget, whereas the same input with an empty separator stops ownership. _visible preserves this whitespace, so this misses a valid heading boundary and can still accept a bullet with no description. Recognize whitespace-only blank lines too, and add a paired control with a space/tab-only separator.
|
The two new
The scorer hash is now Still open: a multi-line setext title is not treated as a boundary. The branch is still based on |
There was a problem hiding this comment.
This review found 4 issue(s), including 4 blocking issue(s).
| def _literal_markdown_text(text): | ||
| """Escape Markdown syntax in a DOM text node; only elements create structure.""" | ||
| # The projection is reparsed as HTML, where a backslash would not protect a tag. | ||
| text = re.sub(r'([\\`*\[\]])', r'\\\1', text).replace('<', '<') |
There was a problem hiding this comment.
P2: Literal entity spellings still become Markdown structure during the fallback reparse. For example, declared HTML <p>&#35; Comments</p><p>&#35;&#35; Alice</p><p>Actual body.</p> produces DOM text # Comments / ## Alice. This helper leaves those ampersands untouched; _coverage_text_records then reparses the projection through article_html/visible_html_text, yielding real # Comments and ## Alice lines and accepting a heading-authored comment despite neither heading existing in the HTML. This leaves the #85 literal-text guarantee bypassable. Protect literal ampersands as well as < across the reparse (before inserting your own entities), and add a declared-HTML negative control with entity-spelled hashes, paired with genuine headings.
| # Fences are consumed so their code lines cannot declare a section. A | ||
| # setext title needs a blank line before it; otherwise it is a lazy | ||
| # continuation of the item and the underline is not a heading. | ||
| sections = [match for match in re.finditer( |
There was a problem hiding this comment.
P2: Detect headings before inline formatting is flattened. This new scan runs on _visible() output, which has already removed **/__. For example, Markdown - Widget\n**# Genuine description** contains a bold lazy continuation, not an ATX heading, but _visible() turns its second line into # Genuine description. The new boundary truncates the record to - Widget, changing a valid one-record answer into too_few_complete_records. Preserve source heading ownership through normalization (or protect hashes emitted by inline-format removal), and add a paired public-scorer control for this case alongside a genuine heading. This is a localized false-negative regression.
| # setext title needs a blank line before it; otherwise it is a lazy | ||
| # continuation of the item and the underline is not a heading. | ||
| sections = [match for match in re.finditer( | ||
| r'(?ms)^ {0,3}(`{3,}(?=[^`\n]*$)|~{3,}).*?(?:^ {0,3}\1[`~]*[ \t]*$|\Z)' |
There was a problem hiding this comment.
P2: Fence masking must respect the enclosing list boundary. For - Widget\n ```\n Genuine code description\n# Unrelated section\nUnrelated prose, the unclosed fenced block ends when its list container ends: the unindented # Unrelated section is a real heading outside the item. This regex instead consumes through \Z, hiding that heading from sections, so the new ownership check still appends the unrelated section to Widget's description (and can reject an otherwise matching fixed-membership record). Use container-aware fence ranges, as markdown_fenced_code_blocks already computes, rather than treating every fence as document-wide until a closing delimiter.
| end = bullets[index + 1].start() if index + 1 < len(bullets) else len(text) | ||
| # A section heading left of the item's content column ends its | ||
| # ownership; a heading indented into the item remains a continuation. | ||
| column = re.match(r'\s*(?:[-*+]|\d+[.)])[ \t]+', bullet[0].rsplit('\n', 1)[-1]).end() |
There was a problem hiding this comment.
P2: Measure indentation in Markdown columns, not character offsets. For -\tWidget\n ## Unrelated section\n Unrelated descriptive text., the tab puts the item's content at column 4, so the two-space heading is outside the item and must end its ownership. Here column is 2 and len(section[2]) is also 2, so the new boundary check retains the unrelated section as Widget's description. This leaves the #111 false-pass case reachable for supported tab-separated bullets. Expand tabs to four-column stops when calculating the content column and add a paired tab-indentation control.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Head reviewed: 7bcd5126. Every verdict below comes from score_attempt and task_passed, run on this head and on base 8f2232b7.
Findings
P1, regression: src/lexbench_webfetch/stable_tasks.py:734 (a hash behind inline markup becomes a section boundary)
The boundary scan runs on _visible() output, where emphasis and link wrappers are already gone. A wrapped hash therefore looks like a real ATX heading. The lexmount-ocr comment on this line is correct.
Answer (name_description, declared Markdown) |
Base | Head |
|---|---|---|
- Widget\n**# Genuine description here** |
pass | fail |
- Widget\n__# Genuine description here__ |
pass | fail |
- Widget\n*# Genuine description here* |
pass | fail |
- Widget\n_# Genuine description here_ |
pass | fail |
- Widget\n[# Genuine description here](/x) |
pass | fail |
Suggested fix: apply the same opaque-hash rule to these lines. Add this immediately before the rendered_literal substitution in _visible:
if schema == 'name_description':
# A hash behind inline markup is prose, never a heading.
text = re.sub(r'(?m)^([ \t]*(?:[*_]+|\[)[ \t]*)#', r'\1\\#', text)Applied locally, all five inputs pass, and a real ## section still ends the bullet. The stored description becomes # Genuine description here, whereas base stored it without the hash. Add paired controls, and add the description change to the historical verdict table.
P1, regression: src/lexbench_webfetch/stable_tasks.py:346 (the opaque hash leaks a backslash in pipe tables)
_visible now keeps \# opaque for name_description, but _render_inline_scalar(pipe_cell=True) only unescapes a backtick. For a cell written Issue \#12 desc here. or Issue #12 desc here.:
- Head stores
Issue \#12 desc here.. Base storesIssue #12 desc here.. - Under fixed membership on
descriptionandname, base passes. Head fails withstable_source_mismatched_record_count: 1.
Suggested fix: use r'\\([#])' if pipe_cell, and add a paired control. Applied locally, the record is Issue #12 desc here.` and the task passes.
P2, incomplete Closes #85: src/lexbench_webfetch/article_text.py:157 (entity spellings in a text node still create structure)
The projection is reparsed as HTML, so an & left unescaped decodes a second time. This declared-HTML answer has no DOM links, yet it passes on base and head because the text nodes become [Alice](/post/1):
<h2>&#91;Alice&#93;(/post/1)</h2><p>First post.</p><h2>&#91;Bob&#93;(/post/2)</h2><p>Second post.</p>
The comment form <p>&#35;&#35;&#35; Alice</p><p>Body prose.</p> also passes on both. lexmount-ocr raised the same defect on this line.
Suggested fix: use .replace('&', '&').replace('<', '<'), and add paired controls. Applied locally, both inputs fail, and genuine anchors plus text such as AT&T and &amp; still pass.
P2, PR body: ## Historical verdict classes that could change omits a fail-to-pass class
The escaped-hash row lists only pass-to-fail. These answers go from fail on base to pass on head, and the #114 change_note needs to disclose them:
## Widget\n\# Desc of widget here.Widget\n\# Desc of widget here.Widget\n# Desc of widget here.
Suggested fix: add this class to the table, along with whatever the two P1 fixes change.
P3: src/lexbench_webfetch/stable_tasks.py:743 (a tab after the bullet marker gives the wrong content column)
-\tWidget\n ## Unrelated section\n Unrelated descriptive text. still passes, because column is measured as 2 instead of 4. The false pass is the #111 defect in a rare form; base also passes this input.
Suggested fix: match against bullet[0].rsplit('\n', 1)[-1].expandtabs(4), and add a rejection control. Applied locally, the input fails and -\tWidget\n ## In item\n Item text. still passes.
All the suggested code changes applied together: tests/benchmarks/test_current_scoring_controls.py, tests/test_scoring_regressions.py and tests/test_scoring.py had one failure, the expected after_sha256 binding. Those changes were not committed. New controls, migration hashes and goldens still need updating.
Considered and not raised
The lexmount-ocr comment at stable_tasks.py:735 is accurate: an unclosed fence inside an item hides a later unindented heading. It needs malformed Markdown, base behaves the same, and handling it would add container tracking to the scan, which is disproportionate. I would leave it and note it in the PR.
Verified
- Round 1 fixes: escaped hashes in a run, fenced
#lines, empty ATX, setext including whitespace-only separators,<in text nodes, literal script text and unique matched counts all behave as described. - Controls: all 59 new controls match on head. On base, 32 are wrong, 27 on verdict and 5 on metrics only, matching the PR body.
- Scorer hash: head computes
3547c1b4c4be…. The old hash no longer appears insrc,tests,evaluationordocs. - Goldens: with the base scorer hash patched in and the base
web-fetch.jsonsnapshot, the Web Fetch golden test passes on this head. The six golden route changes are hash-only, including afterf21e01a2and7bcd5126. - #83, #86, #110, #112: probes of plain-text headings, nested and wrapped signatures, parameter lists, and inline, hidden, block-split and neighbor prices found no defect.
- Over-design: I found no unnecessary abstraction or layer. The diff is proportional to six defects.
- Local runs: the ruff gate passes.
tests/test_golden_reports.py,tests/benchmarks/test_current_scoring_controls.py,tests/test_scoring_regressions.py,tests/test_scoring.pyandtests/test_scoring_revision.pygave 104 passed. - CI on this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass.
ocr-reviewshows as failed; it has no duration and links back to this PR's review comments, so I read it as the review bot's status rather than a test failure and did not rerun it.
|
Review round 2 fixes, on head
One change from the suggested fix: the pipe-table fix does not use Controls: 18 new paired controls, 12 of which give the wrong verdict on Not changed:
|
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| # setext title needs a blank line before it; otherwise it is a lazy | ||
| # continuation of the item and the underline is not a heading. | ||
| sections = [match for match in re.finditer( | ||
| r'(?ms)^ {0,3}(`{3,}(?=[^`\n]*$)|~{3,}).*?(?:^ {0,3}\1[`~]*[ \t]*$|\Z)' |
There was a problem hiding this comment.
P2: The fence terminator accepts mixed backticks and tildes because of [~]*. For example, in - Widget\n \n ~~~\n# Literal code heading\nThis is still code belonging to Widget.\n ````, the ```~~~ line does not close the Markdown backtick fence, but this regex closes it and treats the following `#` as an external section boundary. The new truncation therefore drops owned description text (and can invalidate an otherwise complete record). Require all closing-fence characters to match the opening fence character, and add a control with an invalid mixed-character closer followed by a hash line.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 3
Head reviewed: 681a61ab. Every verdict below comes from score_attempt and task_passed, run on this head and on base 8f2232b7, with a one-record name_description contract and a Markdown answer.
Findings
P2, regression: src/lexbench_webfetch/stable_tasks.py:741 (a mixed-character line closes a fence)
The closer pattern \1[~]*accepts tildes after a backtick fence, and backticks after a tilde fence. CommonMark does not treat such a line as a closer, so the next#line is still code. The scan reads it as a section boundary and cuts the description. The lexmount-ocr comment on this line is correct, and it is whyocr-review` is red.
| Answer | Base | Head |
|---|---|---|
- Widget\n ```\n ```~~~\n# Literal code heading\nThis is still code belonging to Widget.\n ``` |
pass | fail |
- Widget\n ~~~\n ~~~```\n# Literal code heading\nThis is still code belonging to Widget.\n ~~~ |
pass | fail |
Suggested fix: replace \1[~]* with ``\1(?:(?<=)*|(?<=~)~*)``, and add paired controls: a mixed closer followed by a #` line (pass), and a longer same-character closer followed by a real section (fail). Tried locally: both inputs pass, and - Widget\n ```\n ````\n# Real section\nprose still fails.
P2, regression: src/lexbench_webfetch/stable_tasks.py:274 (nested wrappers still turn a hash into a boundary)
The round 2 fix accepts one wrapper kind per line, either [*_]+ or [. A wrapped hash with both kinds, or with two separate runs, still reaches the boundary scan as a heading.
| Answer | Base | Head |
|---|---|---|
- Widget\n**[# Genuine description here](/x)** |
pass | fail |
- Widget\n[**# Genuine description here**](/x) |
pass | fail |
- Widget\n** **# Genuine description here |
pass | fail |
Suggested fix: one pattern for any mix of wrapper characters, ^([ \t]*(?:[*_\[][ \t]*)+)#, with paired controls. Tried locally: all three inputs pass.
With both trial changes applied, tests/benchmarks/test_current_scoring_controls.py, tests/test_scoring_regressions.py, tests/test_scoring.py and tests/benchmarks/webfetch/test_stable_tasks.py had one failure, the expected after_sha256 binding. The changes were not committed. New controls, the migration hashes, the goldens and the PR body's scorer hash and control counts still need updating.
P2, PR body: ## Behavior worth checking omits a remaining pass-to-fail class
A hash that follows an inline element removed during normalization still ends a description. The first three inputs below pass on base and fail on head, and the suggested fix does not change them. Each would need its own special case, which I do not think is justified for inputs this rare. The class should be disclosed instead, because the #114 change_note is built from this list.
- Widget\n<br># Genuine description here- Widget\n# Genuine description here- Widget\n[](/x)# Genuine description here
Suggested fix: add this class to the historical verdict table.
Considered and not raised
- Unclosed fence in an item:
- Widget\n ```\n# Section\nprosekeeps its base result, and the PR body discloses it. Handling it would add container tracking. - Thematic break read as a title:
- Widget\n\n---\n---\nDesc after rulegoes from pass to fail. I do not expect this form in real answers, and it does not justify another rule. - Blockquoted bullets:
> - Widget\n> ## Related\n> Unrelated prose text.passes on base and head. It does not enter the bullet branch, and #111 does not cover it. _table_recordshash rendering for every schema: in Markdown, other schemas have already decoded\#by this point, so only literal\#in undeclared projected HTML could change. I did not find a verdict change.
Verified
- #85: literal and encoded link, heading and bold forms fail under declared HTML. Genuine anchors, headings and bold authors pass, including text with
&,<,>, brackets, asterisks and backslashes. - #111 paths: CRLF answers, declared
plain_textand DOM-derived text behave as intended. A#line from HTML text does not end a description in the probes I ran, and declaredplain_textkeeps literal#lines. - #83: no code outside
stable_tasks.pyreads the changedstable_source_*diagnostics, so they cannot change a verdict. - Controls: all 77 new controls match on head. On base, 42 are wrong, 33 on verdict and 9 on metrics only, matching the PR body.
- Scorer hash: head computes
eb31cd27c2e9…, matching the PR body. - Migration bindings and bounds: the binding test passes.
data-lock.jsonand.github/workflows/are unchanged. - Goldens: with the base scorer hash patched in and the base
web-fetch.jsonsnapshot, the Web Fetch golden test passes on this head, so the six route changes are hash-only. - Over-design: I found no unnecessary abstraction or layer.
- Local runs: the ruff gate passes.
tests/test_golden_reports.py,tests/benchmarks/test_current_scoring_controls.py,tests/test_scoring_regressions.py,tests/test_scoring.py,tests/test_scoring_revision.pyandtests/benchmarks/webfetch/test_stable_tasks.pygave 167 passed. - CI on this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass.
ocr-reviewis red because of the fence finding above, so I did not rerun it.
681a61a to
b875978
Compare
…ue hashes A heading left of a bullet's content column ended the description even when it was the card's own title. It now ends the description only when nothing follows it before the next bullet, or after the last bullet unless it repeats the bullet's title. Remove the opaque-hash handling and the rare-form controls that only guarded it, restoring base code in _visible, _render_inline_scalar and _table_records.
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
| section = next((section.start() for section in sections | ||
| if bullet.end() <= section.start() < end and len(section[2]) < column), None) | ||
| if section is not None: | ||
| heading, _, body = text[section:end].partition('\n') |
There was a problem hiding this comment.
P2: The new empty-body check counts a setext heading's underline as body text. For example, - Widget\n\nRelated products\n-------\n\n- Gadget\n A genuine gadget description. leaves body starting with -------, so the non-final Widget bullet keeps the unrelated heading as its description and becomes a valid record. This violates the stated boundary rule for a heading with nothing after it before the next bullet (and differs from the equivalent ATX heading). Consume the entire heading, including its setext underline, before checking whether any body remains, and add a public-scorer control with minimum_records: 2 for this case.
| if bullet.end() <= section.start() < end and len(section[2]) < column), None) | ||
| if section is not None: | ||
| heading, _, body = text[section:end].partition('\n') | ||
| title = _line(heading) |
There was a problem hiding this comment.
P2: The card-title exception rejects valid ATX headings with closing hashes. For - [Alpha](/a)\n\n### Alpha ###\n\nAlpha is a great item., _line(heading) returns Alpha ###, which is not in the normalized bullet - Alpha. The last bullet therefore loses its entire genuine description and fails a one-record name_description contract, despite the requirement to preserve repeated card titles. Normalize optional ATX closing hashes before comparing the heading title, and add this variant to the card-title control.
Issues
Closes #83
Closes #85
Closes #86
Closes #110
Closes #111
Closes #112
Summary
All six public-scorer reproductions failed on the unfixed scorer, so each one gets a code fix. No stored verdict, frozen profile or receipt changes, no provider ran, and there are no provider-specific branches.
record_sha256. Observed, matched and mismatched counts are consistent, including for matching answersarticle_markdownescapes text-node syntax, including literal HTML tags, when the answer is declaredhtml. Real anchors and headings still create structureplain_textrepresentation_text_eventsgets a literal mode: fences, indentation, hashes and link syntax stay literal, and declared titles still match#line inside fenced code never ends itddtextBehavior worth checking
html. Undeclared answers keep the existing tolerance for Markdown inside an HTML wrapper, because the current controlsarticle-visible-postandarticle-visible-commentrequire it. The same bytes with no declared format therefore keep their old verdict._descriptionsunchanged. There the first line of a block can be a heading that is the card's own title, and no reproduction covers that branch.- [Alpha](/a)\n\n### Alpha\n\nAlpha is a great item.keeps its description on every bullet, including the last, because the heading repeats the bullet's title. A later section after the last bullet does not, so- Widget\n\n## Related\nUnrelated section prose.fails.- Widget\nGenuine text.\n-------keeps its description. A multi-line setext title is not recognized as a boundary.- Widget\n ```\n# Section\nprose, the fence still runs to the end of the input, so the bullet keeps the section as its description. This is the same result as8f2232b7, not a regression.name(...)signatures, using the same pattern as the text path. A nested term likeclass Inner(x)is still treated as parent text, as it is today.Controls
There are 69 new controls in
src/harness/benchmarks/scoring-regressions.json, covering both error directions where both are plausible.test_current_corrections_run_through_the_public_scorer_and_task_predicateruns them throughscore_attemptandtask_passed.Run against the
43b149a8scorer, 37 of the 69 give a wrong result: 33 on the verdict and 4 onexpected_metricsonly. The other 32 are guards that already held, such as the same bytes declared as Markdown, neighboring-record prices and card titles after a bullet.The task named
evaluation/scoring-regressions.json. That file is the frozen registry resolved from the pinned dataset, so new current controls go in the in-repo file thatload_scoring_regressionsalready appends to it.Values that moved
SCORING_SOURCE_SHA256(computed at import)5c8bfec2…6744c189…(6744c189b278462692aaa20f88353c4a32873d09e3b2335cd127a00314b19d41)code-migration.jsonafter_sha256article_comments.py,article_posts.py,article_text.py,dynamic_lists.py,metrics.pyandstable_tasks.pycode-migration.jsonchangesdocument_structure.pyadded, because it now differs from the pinned sourcecode-migration.jsoncorrectionstests/golden/web-fetch.jsonNo other file in the repository contains the old hash.
Golden routes.
attempts/fixture__ok__r001.html,attempts/fixture__fail__r001.html, their twoen/versions,results.jsonlandreport-manifest.jsonchanged only because the scorer hash moved. With the hash set back to5c8bfec2…in-process, the Web Fetch golden test on this code passes against the base snapshot.Historical verdict classes that could change
This is derived from the code; nothing was rescored and no provider ran.
stable_source_*diagnostics change for fixed-membership taskshtml, with no native record containers, using the post or comment fallback&#35;. Fail to pass when literal brackets, a literal script or style tag, or similar in genuine text broke parsingplain_texton tasks withdocument_structure#-prefixed literal text. Pass to fail when a heading matched only through literal[Title](url)syntaxlinked_productanswers whose price is split by inline elementsname_descriptionrecords, including composite groups, where a heading outside the item follows the last bullet and does not repeat its title, including empty ATX and setext headingsname_descriptionbullets where a heading outside the item has nothing after it before the next bulletname_descriptionlast bullets followed by a line that reads as a heading once markup is removed, such as\# Text,#\# Text,**# Text**or[# Text](/x)43b149a8-\tWidget\n ## Section\n Textdocument_body_charsalso falls, which can fail the body floorKnown limits, left on purpose
Each of these is left as it is on purpose, because the owner asked to focus on the main behavior and leave minor edge cases:
- Widget\n\n## Related\nUnrelated section prose.\n\n- Gadget\n Gadget description text here.still passes, because a heading before another bullet cannot be told apart from a card title with text. This is the accepted cost of keeping card-title answers correct. The same applies after the last bullet when the section heading happens to repeat the bullet's title.- Widget\n\nGenuine description of widget.\n---\nFooter text.goes from pass to fail.- Widget\n\# Text,- Widget\n**# Text**,- Widget\n[# Text](/x),- Widget\n<br># Textand- Widget\n# Textgo from pass to fail. A scan of the 3,755 stored files underwebfetch-430-refresh-20261014found no#or emphasis-wrapped form at a line start. Nearly all\#lines there are hashtags or numbers with no space after the hash, so they are not headings; five are a bare\#. The sampled[#lines are links wrapping real headings.- Widget\n\nRelated products\n-------\n\n- Gadget\n A genuine gadget description.still passes, while the ATX form fails. The review found this form in none of the 2,945 stored answers.- [Alpha](/a)\n\n### Alpha ###\n\nAlpha is a great item., and a truncated title such as### 1,000 Places to See ..., lose the last card's description. One stored answer,obscura/live-034-travel, loses one card this way.- Widget\n```\n```~~~\n# Text, the```~~~line closes the fence, so# Textis a heading and the verdict goes from pass to fail.No dataset release is needed: tasks do not depend on the scorer, and #114 is closed with the reason.
Test plan
43b149a8tests/test_golden_reports.py: goldens regenerated throughUPDATE_GOLDEN=1, hash-only as described abovetests/benchmarks,tests/test_scoring_regressions.py,tests/test_golden_reports.pylocally: 11398 passed, 4317 subtests passedecommerce-list/run-001.txtandlive-038-mystery/run-001.txtwithminimum_records20: both pass, as on43b149a8, with 21 and 22 complete records#lines, empty ATX and setext headings, literal HTML tags in text nodes, unique matched counts under fixed membership, literal tags surviving the fallback reparse, whitespace-only blank lines before a setext title, doubly encoded references in the fallback, a tab after the bullet marker, and card titles after a bulletBase: the branch sits on
43b149a8.CI on the first revision had one failure:
tests/test_local_task_replacement.py::test_current_replacement_validates_live_qualification_without_before_matrices[call],DID NOT RAISE ValueError. The test sets a record'selapsed_msto 1 and expects a mismatch, and this PR changes nothing it touches. It passed locally and on the next CI run, so it looks intermittent. My unconfirmed reading is that it flakes when the fixture call really took 1 ms.