Skip to content

feat: show each citation highlighted to the character in its source - #13

Merged
matheusPavaneli merged 1 commit into
mainfrom
feat/citation-viewer
Sep 18, 2026
Merged

matheusPavaneli merged 1 commit into
mainfrom
feat/citation-viewer

Conversation

@matheusPavaneli

Copy link
Copy Markdown
Owner

What

A static page for the 30 golden questions. Each answer sits beside its source PEP; selecting a citation highlights exactly document[start_char:end_char], next to the span the golden set expected. A second page shows the README's retrieval numbers for all seven configurations, question by question. It deploys to GitHub Pages from main. This closes F7 on the roadmap.

Why

The project's central claim is that every citation resolves to exact characters of its source (ADR 0007). Until now that was a number (0.981 resolved) and a JSON report: nobody reading the repository could see a span without Docker, Python and a key.

How

  • Static, from the gated reports. python -m rageval.site builds the page data from the answer baseline and the three retrieval baselines ci.yml pins, plus four recorded reports, the golden set and documents/. It recomputes the corpus version and the golden-set digest and refuses any mismatch. Reports written before RAG-11 carry no digest; they are accepted only if they answer exactly the golden set's questions, and they are labelled recorded, not gated.
  • Spans are cut in Python. Offsets are code points over the normalised text; JavaScript strings are UTF-16, so slicing in the browser would shift every highlight after an astral character. The exporter splits each document into lines and marked segments itself, and the page only renders them.
  • The source is shown as source. The PEP is shown as its markdown text in a monospace, lines styled by kind and nothing reflowed, so every offset stays checkable by counting. Rendered markdown was rejected: source maps are per block and cannot place a span inside a paragraph.
  • No JavaScript. Astro, prerendered, 33 pages. A citation is a fragment link; :target and :has() emphasise every segment of the span and the chip that points at it.
  • Offset rail. Beside each document, a strip as tall as the document marks every cited and expected span to scale, so a miss shows as two separate places (q26). It began as links; 4 px ticks fail WCAG 2.5.8 target size, so it is a figure with a text description and the chips do the navigation.
  • Live free-form questions were left out. They need pgvector and a Gemini key behind a public endpoint. Reasoning in ADR 0012.

Verification

  • uv run ruff check ., uv run ruff format --check ., uv run mypy: pass
  • uv run pytest: 299 passed. tests/test_site.py covers segmentation (including an astral character before a span, overlapping marks, a mark across a line break), every refusal, and 51/51 exact spans over the committed baseline
  • uv run python -m rageval.site --out web/src/data: 30 questions, 7 configurations, 51 resolved of 52 citations
  • pnpm --dir web install --frozen-lockfile, check (0 errors, 0 warnings), build (33 pages), test (4/4): pass. These four were run by hand. The plan's verifier exited 127 on each because it cannot launch the pnpm.CMD shim on Windows; the new web CI job runs them on Ubuntu.
  • web/test/site.test.mjs checks the built HTML: every resolved citation's marked text equals its span sliced by code point, all 30 expected spans the same way, and no page loads anything from another origin. Moving one citation's start by a single character fails it.
  • axe (WCAG 2.2 AA): 0 violations on the index, two question pages, Numbers and the 404, in light and dark. No horizontal scroll at 320, 390, 768 and 1440 px or at 200 % zoom. 0 KB of JavaScript; fonts 70 KB, self-hosted.

Risk and rollback

No critical zones. No existing behaviour changes: the exporter only reads committed files. Revert the PR and disable Pages; until Pages is enabled, the README link returns 404.

Open questions

  • Pages has to be enabled with GitHub Actions as its source before the pages workflow can deploy. That is a repository setting, left to the author.

The claim that every citation resolves to exact characters was visible
only as a number and a JSON report. A static page now shows each of the
30 golden answers beside its source PEP; selecting a citation highlights
document[start_char:end_char] next to the span the golden set expected.

The exporter (python -m rageval.site) builds the page data from the
reports CI gates and refuses a corpus version or golden-set digest that
does not match. Spans are cut in Python because the offsets are code
points and JavaScript strings are UTF-16. The site is Astro with no
runtime JavaScript, deployed to GitHub Pages from main; a test over the
built HTML checks all 51 resolved citations. Decision record: ADR 0012.

@matheusPavaneli matheusPavaneli left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALR

@matheusPavaneli
matheusPavaneli merged commit fb5fea1 into main Sep 18, 2026
4 checks passed
@matheusPavaneli
matheusPavaneli deleted the feat/citation-viewer branch September 18, 2026 18:35
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.

1 participant