Skip to content

Reconcile the two snippet gates: fix audit cache handling, add RENDERING bucket - #265

Merged
realmarcin merged 1 commit into
mainfrom
reconcile-snippet-validators
Jul 29, 2026
Merged

Reconcile the two snippet gates: fix audit cache handling, add RENDERING bucket#265
realmarcin merged 1 commit into
mainfrom
reconcile-snippet-validators

Conversation

@realmarcin

@realmarcin realmarcin commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #257.

evidence_snippet_audit.py and just validate-references disagreed 1 vs 14 on the same file. The cause was two bugs in the audit, both producing false MISMATCHes, plus one genuine difference in matching strictness that is now surfaced instead of hidden.

Bug 1 — a real full text was discarded as a stub

A .md cache was trusted only with content_type: frontmatter or a ## Content heading. Several were fetched with neither — they begin Full text (re-fetched … via NCBI BioC PMC) — including a 200 KB, a 138 KB and an 88 KB full text. 55 files, 642 KB total. The audit silently fell back to the short abstract .txt and flagged every full-text snippet as absent.

Bug 2 — the curated-snippet stripper ate real text

SNIPPET_SECTION terminated on \nURL:, \nDOI:, \n## or EOF. In a cache laid out notes → snippets → full text, it consumed the full text too. The full-text markers are now terminators.

before after
MISMATCH 166 140
NOCONTENT 794 756
hCom2 mismatches 14 0

New RENDERING bucket — this is the actual reconciliation

The residual disagreement is snippets matching only after punctuation/whitespace/Greek normalization — record 10% CO 2 , 5% H 2 vs cached 10% CO2, 5% H2; beta-5 vs β-5. These are faithful quotes of the paper whose cache carries a PDF/XML extraction artefact, and they are precisely what validate-references reports.

Counting them separately (62 repo-wide, --list-rendering) makes the gates reconcile:

validator errors == RENDERING + MISMATCH

Verified on hCom2: audit reports 1 RENDERING / 0 MISMATCH, validator reports 1 error — the same snippet, now correctly classified as an artefact rather than a fabrication suspect.

What I deliberately did NOT do

I drafted a script to rewrite those 62 snippets to match the cache exactly. Its dry run produced rewrites like cDCE (4 to 5 mg/L)cDCE (4 to 5 mg/ L) and group 5 (prmABCgroup 5 ( prmAB.

That propagates extraction artefacts into the records to satisfy a tool. The script was discarded and the reasoning left in-code so it isn't retried.

Total checks label

Counting issues rather than checks lives in the pip package and can't be patched here. The justfile recipe now says so, and explains how to read a RENDERING hit. Added just audit-snippets.

Verification

266 tests pass; no new ruff findings (5 pre-existing in scripts/, unchanged).

🤖 Generated with Claude Code

…ING bucket (#257)

evidence_snippet_audit.py and `just validate-references` disagreed 1-vs-14 on
hCom2_Complex_Gut_Microbiome.yaml. Root cause was two bugs in the audit, both
making it report false MISMATCHes, plus one genuine difference in matching
strictness that is now surfaced instead of hidden.

Bug 1 - a real full text was discarded as a stub. A .md cache was trusted only
with `content_type:` frontmatter or a `## Content` heading. Several caches were
fetched with neither (they start "Full text (re-fetched ... via NCBI BioC PMC)"),
including a 200 KB, a 138 KB and an 88 KB full text -- 55 files, 642 KB total.
The audit fell back to the short abstract .txt and flagged every full-text
snippet as absent. FULLTEXT_MARKER now counts as a real-content signal.

Bug 2 - the curated-snippet stripper ate real text. SNIPPET_SECTION terminated
on `\nURL:`, `\nDOI:`, `\n## ` or end-of-file, so in a cache laid out as
notes -> snippets -> full text it consumed the full text too. The full-text
markers are now terminators.

Net: MISMATCH 166 -> 140, NOCONTENT 794 -> 756, and hCom2 goes 14 -> 0.

New RENDERING bucket. The residual disagreement is snippets that match only
after punctuation/whitespace/Greek normalisation -- record "10% CO 2 , 5% H 2"
vs cached "10% CO2, 5% H2", "beta-5" vs "β-5". These are faithful quotes of the
PAPER whose CACHE carries a PDF/XML extraction artefact, and they are exactly
what validate-references reports. Counting them separately (62 repo-wide,
`--list-rendering`) makes the two gates reconcile: validator errors ==
RENDERING + MISMATCH. Verified on hCom2: audit 1 RENDERING / 0 MISMATCH,
validator 1 error, same snippet.

Explicitly NOT done: rewriting those snippets to match the cache. A draft that
did so produced "cDCE (4 to 5 mg/ L)" and "group 5 ( prmAB" -- propagating
extraction artefacts into records to satisfy a tool. The script was discarded
and the reasoning recorded in-code so it is not retried.

"Total checks: N" counting issues rather than checks lives in the pip package
and cannot be patched here; the justfile recipe now says so, alongside how to
read a RENDERING hit. Added `just audit-snippets`.

Verification: 266 tests pass; no new ruff findings (5 pre-existing, unchanged).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@realmarcin
realmarcin merged commit 17b62bc into main Jul 29, 2026
2 checks passed
@realmarcin
realmarcin deleted the reconcile-snippet-validators branch July 29, 2026 18:07
realmarcin added a commit that referenced this pull request Jul 29, 2026
- PR #255 Suillus-Bacillus thiamine SynCom: merged after review (id 000312, no
  collision, validates, no snippet mismatches, dangling-check clean). Record
  count 305. Logged an optional causal-edge pass as follow-up since it carries
  no downstream edges.
- #258 dangling edges: DONE — 7 retargeted, 7 dropped as self-referential
  restatements whose claims survive verbatim in the source node descriptions.
  40 -> 26 integrity issues, dangling 14 -> 0. No nodes minted.
- #257 snippet gates: DONE — fixed two audit cache bugs (a real full text
  discarded as a stub; the snippet stripper eating full text past a notes
  section), MISMATCH 166 -> 140, NOCONTENT 794 -> 756, and added the RENDERING
  bucket so validator errors == RENDERING + MISMATCH.
- 000031 rename: DONE (#266), id unchanged, derived artifacts regenerated.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

validate-references: 'Total checks' counts issues, not checks — and its coverage disagrees with evidence_snippet_audit.py

1 participant