Sloth-ninja puts legal citations to a live check

This fork adds a standalone way to test whether a legal citation matches the current record at legislation.gov.uk.

complianceworkflow

The checker uses the UK government's legislation service as its source, so a user can test citations against live public legislation rather than a locally copied dataset. It also follows a polite rate limit, helping avoid excessive requests to that public service.

More interesting is the defensive work around it. Text submitted for checking is capped at 20,000 characters before citation patterns are searched. That limits the risk that a huge or deliberately awkward submission could tie up the checker.

The GitHub work is worth a look for anyone deciding how much trust to place in automated citation checks.

So what Legal teams building drafting or review workflows should care because verification needs both a reliable public source and sensible safeguards around user-supplied text.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

3 commits from Sloth-ninja/JessicaOSS, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
a84f0465 WS7: Citation Checker - live legislation.gov.uk verification sloth-ninja 2026-07-19 ↗ GitHub
commit body
Backend: new POST /citations/check (requireAuth, own rate limiter
RATE_LIMIT_CITATIONS_MAX default 20/15min, 100k-char cap with 413,
50-citation cap, whole-handler try/catch with fixed generic 500 detail).
Extraction regexes ported from evals/src/citations.ts into
backend/src/lib/citationExtraction.ts (provenance headers both ends; the
evals resolver is NOT ported - verification uses lib/legislation.ts's
verifyCitation, sequential to respect its ~1 req/s politeness bucket).
Neutral-case citations always return "unverifiable" with the fixed
Find Case Law / BAILII copy.

Frontend: /citation-checker page per the approved WS7 mock-up (paste-in
textarea, Check citations action, skeleton checking state, results table
with green Verified rows linking to canonical legislation.gov.uk URLs,
red Not found + reason, amber case-law rows, summary count line, footer
disclaimer), checkCitations in mikeApi.ts, and a "Research" sidebar group
with Citation Checker (ClipboardCheck).

Tests: 25 new vitest cases (extraction fixtures + route tests with mocked
verifyCitation); backend suite 122/122. Docs: env registry + module maps
in CLAUDE.md, .env.example, BUILD_LOG entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1d0b2513 WS7 review fixes: 20k text cap (ReDoS mitigation) + politeness-bucket note sloth-ninja 2026-07-19 ↗ GitHub
commit body
Independent review of PR #24 (approve-with-fixes):

1. Availability: the ported ACT_TITLE regex is O(n^2) and extraction runs
   synchronously before the first await - a pathological 100k paste blocked
   the Node event loop ~6.7s (reviewer-benchmarked), stalling all requests
   including SSE chat. Minimal mitigation: MAX_TEXT_LENGTH lowered from
   100_000 to 20_000 (worst case well under ~0.5s). 413 copy, boundary
   tests (20_000 / 20_001), .env.example and BUILD_LOG updated. The regex
   itself stays byte-identical to evals per the sync mandate; a future
   synced regex fix in both suites remains recommended.

2. Documented the conscious trade-off that verification shares the global
   legislation.gov.uk politeness bucket with the chat tools (one
   50-citation check can queue chat legislation lookups for tens of
   seconds - by design, a single bucket is what politeness to the
   upstream host requires).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a93f6b58 Merge pull request #24 from Sloth-ninja/ws7-citation-checker Ezana.H 2026-07-19 ↗ GitHub
WS7: Citation Checker (live legislation.gov.uk verification)

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-859.md from inside the repo you want the changes in.

⬇ Download capture-thread-859.md