Skip to content

feat(source): report most-cited and orphan sources#450

Open
boskodev790 wants to merge 1 commit into
vouchdev:testfrom
boskodev790:feat/source-usage-report
Open

feat(source): report most-cited and orphan sources#450
boskodev790 wants to merge 1 commit into
vouchdev:testfrom
boskodev790:feat/source-usage-report

Conversation

@boskodev790

@boskodev790 boskodev790 commented Jul 10, 2026

Copy link
Copy Markdown

what

vouch source usage — a read-only report over the source→claim direction the
existing surfaces don't cover.

vouch lint flags dangling citations (a claim pointing at a source that
isn't there) and vouch stats reports the citation coverage rate. neither
answers the inverse: which registered sources back a real claim, and which
back nothing. sources aren't listable at all today.

the command lists:

  • most cited — sources ranked by how many distinct claims rest on them,
    resolving both citation paths vouch allows (a claim naming the source id
    directly, or naming an evidence span that points into it — the same dual
    path stats.citation_summary already honours).
  • orphaned sources — registered, still on disk, cited by no claim and
    referenced by no page. dead provenance: safe to prune, or a prompt to mine
    the material for the claim it should support.

a source a page references but no claim cites is left out of both counts —
neither cited nor orphaned, only in sources_total.

why

closes the source-side blind spot in the citation invariant. an operator
curating a KB can spot load-bearing provenance and prune cruft in one glance,
or from cron via --format json / --format markdown.

surface

strictly a viewport. composes store.list_sources, list_claims,
list_pages, list_evidence; writes nothing, logs no audit event, and never
touches a proposal — nothing here for the review gate to gate. cli-only, so no
new kb.* method (the four-site method surface and test_capabilities are
untouched). no storage, model, migration, or on-disk-layout change — an
existing .vouch/ reads unchanged.

  • src/vouch/source_usage.py — new module: pure build() plus text / markdown
    / json renderers with a stable to_dict() json contract
  • src/vouch/cli.pyvouch source usage under the existing source group
  • tests/test_source_usage.py — 14 tests (direct + via-evidence citation,
    dedup, page-reference exclusion, orphan detection, dangling-citation safety,
    ordering, non-silent truncation, and the cli)
  • CHANGELOG.md[Unreleased]

example

source usage @ 2026-07-10T08:06:44+00:00
sources: 4  cited: 2  orphaned: 1

most cited (2)
     2 claim(s)  6b2179c2b3ca  [file]  architecture-notes
     1 claim(s), 1 span(s)  2cb8c36d136e  [file]  incident-report

orphaned sources (1)
  3cfc497a51f9  [file]  2026-07-10  stale-screenshot

validation

  • python -m pytest tests/ -q --ignore=tests/embeddings → 1101 passed, 37 skipped
  • python -m mypy src → clean
  • python -m ruff check src tests → clean

no linked issue — this is a self-contained read-only viewport that changes
neither the object model, the kb.* surface, the on-disk layout, the bundle
format, nor the audit shape, so per contributing it doesn't need a vep. happy
to open one if you'd rather track it.

reads the source-to-claim direction the existing surfaces don't. `vouch
lint` flags dangling citations and `vouch stats` reports the coverage
rate; neither surfaces a source that is registered and on disk yet cited
by nothing.

`vouch source usage` lists most-cited sources — resolving both direct
citations and citations made through an evidence span — and orphan
sources that no claim cites and no page references, so a reviewer can
prune dead provenance or mine it for the claim it should back. a source
a page references but no claim cites is left out of both counts.

strictly a viewport: composes store.list_sources / list_claims /
list_pages / list_evidence, writes nothing, logs no audit event. cli-only,
no kb.* method surface. adds src/vouch/source_usage.py and
tests/test_source_usage.py (14 tests).
@coderabbitai

coderabbitai Bot commented Jul 10, 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: c3ca1075-13bf-4d9b-ad17-45c714d5f2b7

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 docs documentation, specs, examples, and repo guidance cli command line interface tests tests and fixtures size: M 200-499 changed non-doc lines labels Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli command line interface docs documentation, specs, examples, and repo guidance size: M 200-499 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant