Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ The reference validator already catches the *mechanical* citation failures autom
verifies each cited reference's `title` matches the fetched record (a transposed/wrong PMID whose
title no longer matches fails) and that every `supporting_text` is a **verbatim substring** of the
cached publication (a quote from the wrong paper, or a paraphrased/invented quote, fails).
A `supporting_text` value must contain actual verbatim source text. Editorial square
brackets may clarify part of a real quotation; an empty string or a value consisting
only of editorial commentary is not a quotation. Omit this optional field when no
quotation is being asserted, and keep method commentary in the finding statement,
review reason, or notes. Scientific notation copied from the source (such as `[4Fe-4S]`)
is literal text, not editorial commentary.
Quotes citing `file:` or `Reactome:` sources are checked the same way, against
the local file (resolved under `genes/`, then the repository root) or the cached
`reactome/R-*.md` entry; a UniProt flat-file quote may run across the file's line
Expand Down
4 changes: 2 additions & 2 deletions assets/jsonschema/gene_review.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@
]
},
"supporting_text": {
"description": "Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. If editorialization is necessary, put this in square brackets (this is not checked). For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'",
"description": "Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. The value must contain verbatim source text, not an empty string or editorial commentary alone. Square brackets may interpolate editorial clarification inside a real quote; bracketed scientific notation from the source remains literal. Omit this optional field when no source quotation is being asserted. For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'",
"type": [
"string",
"null"
Expand Down Expand Up @@ -4610,7 +4610,7 @@
"description": "Type of section in the reference (e.g., 'ABSTRACT', 'METHODS', 'RESULTS', 'DISCUSSION')"
},
"supporting_text": {
"description": "Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. If editorialization is necessary, put this in square brackets (this is not checked). For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'",
"description": "Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. The value must contain verbatim source text, not an empty string or editorial commentary alone. Square brackets may interpolate editorial clarification inside a real quote; bracketed scientific notation from the source remains literal. Omit this optional field when no source quotation is being asserted. For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'",
"type": [
"string",
"null"
Expand Down
5 changes: 5 additions & 0 deletions conf/reference_validator_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ unknown_prefix_severity: WARNING
# cache_dir: directory containing cached publication text files (PMID_12345.md)
cache_dir: publications

# These files are committed, reviewed evidence. Validate their current text;
# upgrades must not refresh it implicitly and invalidate reviewed quotations.
# Missing references can still be fetched. Explicit cache-warming opts out.
trust_cached_entries: true

# reference_base_dir: base directory for resolving file: references
reference_base_dir: genes

Expand Down
24 changes: 23 additions & 1 deletion docs/publication_fulltext_warming.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`just warm-publications [limit]` upgrades abstract-only records in the
`publications/` cache to full text by driving the
**linkml-reference-validator (LRV ≥ 0.2.1) full-text provider chain**:
**linkml-reference-validator (LRV ≥ 0.3.0) full-text provider chain**:

1. **pmc** — PMC XML, then PMC HTML (resolves a PMC id from the PMID when the
cache has none)
Expand All @@ -17,6 +17,28 @@ never retried at all — their DOI lets Unpaywall/OpenAlex locate open text.
Note the sweep targets `PMID_*.md` records only; the small number of
`DOI_*.md`-keyed records in the cache are not candidates.

## Validation uses the committed evidence

Repository validation enables LRV's `trust_cached_entries`: an existing cache
entry is checked as committed, without a staleness refresh or a full-text retry.
Missing references can still be fetched. Validation does not promote an
abstract-only record to full text just because a quote needs it.

If a full-text quote fails against an abstract-only record, first inspect the
cached text. Run an explicit warming command (`just warm-publications [limit]`,
or `just warm-references` for the references used by gene reviews) when new
source text is needed. `warm-references` explicitly disables cache trust while
it runs. Inspect and review the resulting source changes, re-quote if needed,
and rerun validation. Warming does not guarantee that full text is available;
never replace a missing quotation with an invented or paraphrased one.

LRV 0.3.1rc1 also changes newly fetched `url:` HTML caches from markup to
readable text. Cache trust deliberately preserves older committed markup;
`just warm-references` opts out of trust and allows stale URL cache entries
to refresh. Review those source changes and validate their quotations in a
separate cache-refresh change. The upstream cache contract preserves consumer
metadata such as `full_text_available` across refreshes.

## Tagging convention (adopted from monarch-initiative/dismech)

The sweep follows the `warm-reference-cache` workflow from the
Expand Down
26 changes: 26 additions & 0 deletions history/schema/gene_review/2026-10-12T174549Z-codex-cb27a5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
history_version: 1
target:
kind: schema
slug: gene_review
path: src/ai_gene_review/schema/gene_review.yaml
session:
id: 2026-10-12T174549Z-codex-cb27a5
timestamp: '2026-10-12T17:45:49Z'
actors:
- type: ai_agent
name: codex
agent_tool: codex
links:
issues:
- https://github.com/ai4curation/ai-gene-review/issues/4954
prs:
- https://github.com/ai4curation/ai-gene-review/pull/4947
urls: []
events:
- type: EDIT
outcome: changed
sections:
- supporting_text
summary: Clarify that supporting text must include source quotations
details: |
Address the LRV 0.3.0 upgrade review: supporting_text is optional but, when supplied, must include verbatim source text. Clarify editorial interpolation versus literal scientific brackets and omission when no quotation is asserted. Regenerate Pydantic descriptions and synchronize the corresponding JSON Schema descriptions without unrelated generated-schema changes. The broader curation audit remains tracked in issue 4954.
2 changes: 1 addition & 1 deletion project.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ validate-all:
echo ""
echo "Reference validation (batch; errors block, advisory warnings allowed)..."
# One linkml-reference-validator process over all files (schema parsed once),
# rather than one process per file. Requires linkml-reference-validator >= 0.2.1.
# rather than one process per file. Requires linkml-reference-validator >= 0.3.0.
{{ref_validator}} validate data genes/*/*/*-ai-review.yaml --schema {{schema_path}} --target-class GeneReview --config {{ref_validator_config}} || exit_code=1
echo ""
echo "Best practices validation..."
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ dependencies = [
"rapidfuzz>=3.14.3",
"scipy>=1.16.1",
"linkml-data-qc>=0.1.0",
# <0.3: publication_warm.py calls LRV's private ReferenceFetcher._materialize;
# lift the bound once a public API lands (tracked in issue #2789).
"linkml-reference-validator>=0.2.1,<0.3",
# publication_warm.py still uses ReferenceFetcher._materialize (issue #2789).
# Its contract is covered by the warming tests; recheck on the next minor release.
"linkml-reference-validator>=0.3.1rc1,<0.4",
"linkml-term-validator>=0.4.5",
"gocam>=0.11.0",
"pyhmmer>=0.12.1",
Expand Down
25 changes: 5 additions & 20 deletions scripts/extract_supporting_text_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,11 @@
import yaml
from pathlib import Path

from linkml_reference_validator.validation.supporting_text_validator import SupportingTextValidator
from linkml_reference_validator.models import ReferenceValidationConfig
from ai_gene_review.validation.reference_cache_compat import (
install_reference_cache_compatibility,
)


config = ReferenceValidationConfig(
cache_dir="publications",
literal_bracket_patterns=[r"[^a-zA-Z\s]"],
)
install_reference_cache_compatibility()
validator = SupportingTextValidator(config)

SKIP_PREFIXES = {
"GO_REF", "GO", "Reactome", "UniProt", "UniProtKB",
"PDB", "EC", "TEMP", "ISBN", "RHEA", "file",
"curator_inference", "ComplexPortal", "HPA",
"PROSITE", "CHEBI", "PMC", "CONTACT_INFO",
}
from ai_gene_review.validation.supporting_text import build_supporting_text_validator


validator, _ = build_supporting_text_validator(Path("publications"))
SKIP_PREFIXES = set(validator.config.skip_prefixes)


def check_file(filepath: Path):
Expand Down
15 changes: 2 additions & 13 deletions scripts/mark_full_text_unavailable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
import yaml as pyyaml
from ruamel.yaml import YAML

from linkml_reference_validator.validation.supporting_text_validator import (
SupportingTextValidator,
)
from linkml_reference_validator.models import ReferenceValidationConfig
from ai_gene_review.validation.reference_cache_compat import (
install_reference_cache_compatibility,
)
from ai_gene_review.validation.supporting_text import build_supporting_text_validator

yaml_rt = YAML()
yaml_rt.preserve_quotes = True
Expand Down Expand Up @@ -95,12 +89,7 @@ def check_full_text(ref_id: str) -> bool | None:
return has_ft

# Set up LRV to check if supporting_text passes strict validation
config = ReferenceValidationConfig(
cache_dir="publications",
literal_bracket_patterns=[r"[^a-zA-Z\s]", r"^[A-Z]{2,5}$"],
)
install_reference_cache_compatibility()
lrv = SupportingTextValidator(config)
lrv, _ = build_supporting_text_validator(cache_dir)

total_marked = 0
files_changed = 0
Expand Down
7 changes: 4 additions & 3 deletions scripts/run_reference_validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# so we pre-process the YAML to remove supporting_text from those entries.
#
# Accepts one OR many data files. With many files it strips them in a single
# pass and makes a single `validate data F1 F2 ...` call through the version-gated
# ai_gene_review.validation.reference_cli compatibility entry point (the validator builds/parses the schema once), which is dramatically
# faster than one process per file. Requires linkml-reference-validator >= 0.2.1
# pass and makes a single `validate data F1 F2 ...` call through the project
# ai_gene_review.validation.reference_cli entry point. The validator builds/parses
# the schema once, which is dramatically faster than one process per file.
# Requires linkml-reference-validator >= 0.3.0
# (multi-file `validate data`).
#
# Usage: scripts/run_reference_validator.sh validate data F1 [F2 ...] --schema S --target-class C --config CFG
Expand Down
50 changes: 31 additions & 19 deletions scripts/warm_reference_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
yet, the validator re-fetches it every run, which made the full validate-all
reference phase network-bound (~59 min). Running the validator once over the whole
corpus with full-text fetching on (the validator's default) populates the cache so
subsequent runs are cache-bound.
subsequent runs are cache-bound. Normal validation trusts committed entries;
this explicit warming command opts into retrying and refreshing existing entries.

This processes the corpus in chunks for progress/resumability and ignores
validation pass/fail — the goal here is only to populate the cache. References are
Expand All @@ -23,6 +24,9 @@
import subprocess
import sys
import time
from tempfile import NamedTemporaryFile

import yaml

SCHEMA = "src/ai_gene_review/schema/gene_review.yaml"
CONFIG = "conf/reference_validator_config.yaml"
Expand All @@ -37,24 +41,32 @@ def main() -> int:

print(f"warming reference cache for {len(files)} gene files (chunks of {CHUNK})", flush=True)
t0 = time.time()
for i in range(0, len(files), CHUNK):
batch = files[i : i + CHUNK]
# check=False: validation failures (snippet mismatches, flaky fetches) are
# expected and irrelevant here; we only want the references fetched into the cache.
subprocess.run(
[
"uv", "run", "python", "-m",
"ai_gene_review.validation.reference_cli", "validate", "data", *batch,
"--schema", SCHEMA, "--target-class", "GeneReview", "--config", CONFIG,
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=False,
)
done = i + len(batch)
elapsed = time.time() - t0
eta = elapsed / done * (len(files) - done)
print(f" warmed {done}/{len(files)} elapsed={elapsed / 60:.1f}m eta={eta / 60:.1f}m", flush=True)
# Validation trusts reviewed cache entries; this explicit warming command
# must still retry cached abstracts and refresh legacy extraction formats.
with open(CONFIG) as source:
config = yaml.safe_load(source)
config["trust_cached_entries"] = False
with NamedTemporaryFile(mode="w", suffix=".yaml") as config_file:
yaml.safe_dump(config, config_file)
config_file.flush()
for i in range(0, len(files), CHUNK):
batch = files[i : i + CHUNK]
# check=False: validation failures (snippet mismatches, flaky fetches) are
# expected and irrelevant here; we only want the references fetched into the cache.
subprocess.run(
[
"uv", "run", "python", "-m",
"ai_gene_review.validation.reference_cli", "validate", "data", *batch,
"--schema", SCHEMA, "--target-class", "GeneReview", "--config", config_file.name,
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=False,
)
done = i + len(batch)
elapsed = time.time() - t0
eta = elapsed / done * (len(files) - done)
print(f" warmed {done}/{len(files)} elapsed={elapsed / 60:.1f}m eta={eta / 60:.1f}m", flush=True)

print(f"reference cache warm complete in {(time.time() - t0) / 60:.1f}m", flush=True)
return 0
Expand Down
4 changes: 2 additions & 2 deletions src/ai_gene_review/datamodel/gene_review_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ class Finding(ConfiguredBaseModel):
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://ai4curation.io/ai-gene-review'})

statement: Optional[str] = Field(default=None, description="""Concise statement describing an aspect of the gene""", json_schema_extra = { "linkml_meta": {'domain_of': ['Finding', 'EvidenceItem'], 'recommended': True} })
supporting_text: Optional[str] = Field(default=None, description="""Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. If editorialization is necessary, put this in square brackets (this is not checked). For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'""", json_schema_extra = { "linkml_meta": {'domain_of': ['Finding',
supporting_text: Optional[str] = Field(default=None, description="""Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. The value must contain verbatim source text, not an empty string or editorial commentary alone. Square brackets may interpolate editorial clarification inside a real quote; bracketed scientific notation from the source remains literal. Omit this optional field when no source quotation is being asserted. For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'""", json_schema_extra = { "linkml_meta": {'domain_of': ['Finding',
'SupportingTextInReference',
'EvidenceItem',
'GoCamActivityReview'],
Expand Down Expand Up @@ -2080,7 +2080,7 @@ class SupportingTextInReference(ConfiguredBaseModel):

reference_id: str = Field(default=..., json_schema_extra = { "linkml_meta": {'domain_of': ['ReferenceReplacement', 'SupportingTextInReference'],
'implements': ['dcterms:references']} })
supporting_text: Optional[str] = Field(default=None, description="""Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. If editorialization is necessary, put this in square brackets (this is not checked). For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'""", json_schema_extra = { "linkml_meta": {'domain_of': ['Finding',
supporting_text: Optional[str] = Field(default=None, description="""Supporting text from the publication. This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual text of the paper. The value must contain verbatim source text, not an empty string or editorial commentary alone. Square brackets may interpolate editorial clarification inside a real quote; bracketed scientific notation from the source remains literal. Omit this optional field when no source quotation is being asserted. For example, you can say '...[CFAP300 shows] transport within cilia is IFT dependent...'""", json_schema_extra = { "linkml_meta": {'domain_of': ['Finding',
'SupportingTextInReference',
'EvidenceItem',
'GoCamActivityReview'],
Expand Down
6 changes: 3 additions & 3 deletions src/ai_gene_review/etl/publication_warm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Warm the publications cache with full text via linkml-reference-validator.

This module drives the linkml-reference-validator (>= 0.2.1) full-text provider
This module drives the linkml-reference-validator (>= 0.3.0) full-text provider
chain — PMC, Europe PMC preprints, Unpaywall, OpenAlex by default — over the
repo's own ``publications/PMID_*.md`` cache to upgrade abstract-only records to
full text. It is modeled on the monarch-initiative/dismech
Expand Down Expand Up @@ -394,8 +394,8 @@ def warm_publication(
# routine `ReferenceFetcher.fetch` uses internally; it is not yet public
# API — public-API request tracked in
# https://github.com/ai4curation/ai-gene-review/issues/2789 (to be
# transferred to linkml-reference-validator); pyproject bounds LRV <0.3
# until it lands.
# transferred to linkml-reference-validator). The contract is tested with
# LRV 0.3; recheck it before lifting the next minor-version bound.
try: # external system boundary: symmetric with the locate guard above,
# so one failed download still lets later providers try this record
text, fmt, _pdf_bytes, error = fetcher._materialize(location)
Expand Down
4 changes: 3 additions & 1 deletion src/ai_gene_review/schema/gene_review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ slots:
range: string
description: Supporting text from the publication.
This should be exact substrings. Different substrings can be broken up by '...'s. These substrings will be checked against the actual
text of the paper. If editorialization is necessary, put this in square brackets (this is not checked). For example, you can say
text of the paper. The value must contain verbatim source text, not an empty string or editorial commentary alone.
Square brackets may interpolate editorial clarification inside a real quote; bracketed scientific notation from the source remains literal.
Omit this optional field when no source quotation is being asserted. For example, you can say
'...[CFAP300 shows] transport within cilia is IFT dependent...'
implements:
- oa:exact
Expand Down
Loading
Loading