diff --git a/CHANGELOG.md b/CHANGELOG.md index 4234133..f537ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ All notable changes to this SDK are documented here. Format follows ### Changed - Docs: `sr` (Serbian, answered in the Latin script) is listed among the supported `language` codes; the API now accepts it. No code change: the SDK sends `language` as given. +- Citation checks now cover a reference no sentence of the draft cites and a reference with no URL or DOI, so `metadata`, `registered` and `doi_registered` are no longer "set for a DOI only". The docstrings of `ReviewCitationCheck`, `ReviewCitationRecord`, `ReviewCitation`, `ReviewCitationIssue`, `ReviewMoreCitation` and `ReviewSummary.citations_found` say what such a row carries (`cited_url` and `doi` can both be `None`). No model field changed. + +### Fixed + +- `lenz review`: a "Reference details differ" finding with no listed differences (the page at the reference's address is another work) now prints the page's title under "The page at this address is titled:", instead of the finding with nothing under it. ## [3.6.0] - 2026-10-31 diff --git a/src/lenz_io/cli/review.py b/src/lenz_io/cli/review.py index 7bb6da7..02525d7 100644 --- a/src/lenz_io/cli/review.py +++ b/src/lenz_io/cli/review.py @@ -821,6 +821,12 @@ def _render_citation_issue(out: Output, i: ReviewCitationIssue, total: int) -> N elif i.source == "metadata": for d in i.metadata_differences: _print_text(out, f"Your reference says {d.cited or '(none)'}; the record says {d.registered or '(none)'}.") + # No differences listed: the reference was compared with the page at + # its own address, not with a registry record, and the page is + # another work. + if not i.metadata_differences and i.page_title: + out.console.print(" [dim]The page at this address is titled:[/dim]") + _print_text(out, f"“{i.page_title}”") if i.failure is not None: hint = i.failure.hint or i.failure.code or "failed" out.console.print(f" [yellow]Part of the check failed:[/yellow] {escape(hint)}") diff --git a/src/lenz_io/models.py b/src/lenz_io/models.py index 321bfb6..d6b23cb 100644 --- a/src/lenz_io/models.py +++ b/src/lenz_io/models.py @@ -2353,7 +2353,8 @@ class ReviewSummary(_Lax): assessments: ReviewAssessmentCounts | None = None verifications: ReviewVerificationCounts | None = None issues: int = 0 - #: Citations with a URL or a DOI in the draft (exact; each use counts). + #: Citations found in the draft (exact; each use counts). A reference with + #: no URL or DOI counts when it gives authors, a year and a title. citations_found: int | None = None #: How many of them the review checks: the first, in the draft's order. citations_selected: int | None = None @@ -2694,7 +2695,8 @@ class ReviewCitationResult(_Lax): class ReviewCitationRecord(_Lax): - """A DOI's record in the registry.""" + """The registry's record of the cited work: of the DOI the draft writes, + or of the work found for a reference that has no URL or DOI.""" title: str | None = None authors: list[str] = Field(default_factory=list) @@ -2729,7 +2731,14 @@ class ReviewCitationCheck(_Lax): ``quote`` is ``not_in_source``. - ``doi_registered``, ``metadata`` (``consistent``, ``mismatch`` or ``unchecked``), ``metadata_differences`` and ``registered``: set for a - DOI only. + DOI, and for a reference with no URL or DOI that was found in the + registry by its authors, year and title (the row's ``doi`` stays + ``None``; ``source_url`` links the record). ``metadata`` alone is also + set for a reference no sentence cites that was compared with the page + at its own address: ``consistent`` when the page has the title the + reference gives, ``mismatch`` when the page is another work. That + mismatch has no ``metadata_differences`` and no ``registered``; + ``page_title`` is the title of the page. - ``unchecked_reason`` and ``hint``: why the finding is ``unchecked`` and what to do next. The reasons are an open set, e.g. ``no_text``, ``partial_text``, ``login_required``, ``unsupported_site``, @@ -2760,8 +2769,10 @@ class ReviewCitationCheck(_Lax): class ReviewCitation(_Lax): - """One citation of the draft (a URL or a DOI where the draft uses it), in - the draft's order. Only on a review that asked for the citation check. + """One citation of the draft (a URL, a DOI or a reference where the draft + uses it), in the draft's order. Only on a review that asked for the + citation check. ``cited_url`` and ``doi`` are both ``None`` for a + reference that has neither. ``reference`` is the citation as the draft writes it; ``statement`` the draft's sentence it is attached to, with link syntax reduced to its @@ -2790,8 +2801,10 @@ class ReviewCitationIssue(_Lax): ``snippet`` and ``rationale`` are set only when ``source`` is ``support``. On ``quote_not_in_source``, ``missing_quote`` is the quoted excerpt that was not found. On ``metadata_mismatch``, - ``metadata_differences`` says what differs. ``failure`` is set when another part of the check failed after - the finding was established. + ``metadata_differences`` says what differs from the registry's record; + when it is empty, the reference was compared with the page at its own + address, and ``page_title`` is the title of that page. ``failure`` is set + when another part of the check failed after the finding was established. """ citation_index: int = 0 @@ -2814,7 +2827,9 @@ class ReviewCitationIssue(_Lax): class ReviewMoreCitation(_Lax): """A citation found in the draft past the ones this review checked: found but not checked. Send it in a later request to check it. - ``sentence`` is the draft's sentence around it.""" + ``sentence`` is the draft's sentence around it. ``cited_url`` and ``doi`` + are both ``None`` for a reference that has neither, which cannot be sent + as a pair by its address.""" index: int = 0 reference: str | None = None diff --git a/tests/test_cli_review.py b/tests/test_cli_review.py index c1e0d19..5d73881 100644 --- a/tests/test_cli_review.py +++ b/tests/test_cli_review.py @@ -490,6 +490,23 @@ def test_quote_finding_shows_the_missing_excerpt_only(): assert "found words here" not in text +def test_a_reference_whose_page_is_another_work_shows_the_pages_title(): + # A reference no sentence cites, compared with the page at its own address: + # the API lists no differences and gives the page's title. + body = _load("review_citations_constructed.json") + row = next(i for i in body["citation_issues"] if i["finding"] == "metadata_mismatch") + row.update(metadata_differences=[], doi=None, page_title="Annual rainfall in the Sahel, 1950 to 2020") + buf = io.StringIO() + out = Output(json_mode=False, no_color=True) + out.json_mode = False + out.console = Console(file=buf, no_color=True, width=200, highlight=False) + render_review(out, ReviewFull.model_validate(body)) + text = buf.getvalue() + assert "The page at this address is titled:" in text + assert "“Annual rainfall in the Sahel, 1950 to 2020”" in text + assert "the record says" not in text + + def test_citation_render_issues_only_view_keeps_the_citations(): text = _render("review_citations_constructed.json", issues_only=True) assert "23 sources cited in your draft" in text and "[source 1/10] Contradicted" in text