Skip to content

fix(stats): stop misreporting broken citations for unreadable source meta#469

Open
RealDiligent wants to merge 2 commits into
vouchdev:testfrom
RealDiligent:fix/critical-issue-stats-citation-summary
Open

fix(stats): stop misreporting broken citations for unreadable source meta#469
RealDiligent wants to merge 2 commits into
vouchdev:testfrom
RealDiligent:fix/critical-issue-stats-citation-summary

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

Root cause: citation_summary() (used by vouch stats / kb.stats) built sources_present from store.list_sources(), which skips unreadable meta.yaml files via _load_or_skip. When a source directory exists but its meta is corrupt (hand edit, mojibake), claims citing that source were counted as broken_citation even though the source is on disk.

health.lint() already fixed this asymmetry via _collect_sources_for_lint() — the source id is its directory name, so citations stay honest and lint reports unreadable_source instead of broken_citation.

Fix: Use _collect_sources_for_lint() for the presence set in citation_summary().

Impact: kb.stats citation coverage metrics no longer lie when a source meta is unreadable; operators aren't sent to delete citations for sources that still exist.

Risk / tradeoffs

  • broken_citation may drop for KBs that previously looked worse than lint said — that was the bug. vouch lint remains the repair surface for unreadable metas.

Test plan

  • test_citation_summary_honest_when_source_meta_unreadable (new)
  • tests/test_stats.py pass

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cfd36e4e-b2ad-4c79-b75b-8d01e97555db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 13, 2026
@RealDiligent

Copy link
Copy Markdown
Contributor Author

CI note: the py3.13 failure was an unrelated flaky timing test (\ est_websocket_broadcasts_on_approve\ — broadcast took 1.17s vs 1.0s budget on a loaded runner). py3.11 and py3.12 passed; retriggered CI with an empty commit.

RealDiligent and others added 2 commits July 13, 2026 20:04
citation_summary called list_sources(), which skips unreadable meta
via _load_or_skip. Claims citing those sources were misreported as
broken_citation in kb.stats / vouch stats — lint already treats the
source as present (unreadable_source finding instead).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant