Retrieval and RAGRanking, evidence and groundingStaff
How should citations preserve the original evidence when extraction offsets or source content change?
By Amit Kumar4 min readWorked answer includedReviewed 27 Sept 2026
The question
Interview question
An answer quoted paragraph 18 of PDF revision 12. Reprocessing the same bytes moves the passage to paragraph 27, and a later source edit changes its meaning while keeping the public URL. Define the source/span identity a citation needs, distinguish safe parser reanchoring from source replacement, and handle repeated text, revoked access and historical corrections.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The public URL identifies a document location, not the exact evidence that supported yesterday's sentence. Paragraph number and byte offset can change when extraction changes. A quote can remain identical while its section heading or exception changes its meaning. I would store a citation as a relation among the answer claim, source document ID, immutable source revision, extracted span or quote, surrounding context, extraction version, and any location needed to render it. That lets us say exactly what the assistant saw then.
The W3C Web Annotation Data Model describes text position and text quote selectors. Position is brittle as content changes. A quote with surrounding context is a better reanchoring candidate, but it is not a proof of unchanged meaning. If the source PDF bytes are the same and only the parser's offsets shifted, compare the exact quote, nearby words, section and page image. A unique match can be reanchored to the new extraction while retaining the old source revision and recording the parser mapping. If there are two identical clauses under different sections, stop. Choosing the first match would quietly change the evidence.
A citation resolver can treat source revision and extraction revision as separate coordinates. If the source-byte digest matches revision 12 but the extraction version differs, it can attempt a mapping between old and new spans. Validate the exact quote with surrounding text and section identity. Record that mapping as a new resolver artifact instead of erasing the old selector. If the source digest differs, branch into source-version handling before trying a convenient text match.
Suppose the phrase “up to thirty days” appears in both refunds and warranty sections. A quote-only selector has two matches and cannot decide which one supported the answer. Prefix/suffix context and a section anchor may disambiguate it. If the heading’s meaning changed, even an identical quote is insufficient for automatic repair. The resolver should display the historical revision where permitted or a clear unavailable/stale-citation state, rather than silently opening the first current match.
If the PDF itself changed, do not overwrite yesterday's evidence pointer with the new paragraph. The historical answer should continue to cite revision 12 where retention and current access rules permit. A new answer can evaluate revision 13, including its effective date and changed meaning. If the product wants to show a correction beside an old answer, make it a new dated notice linked to the old one. The source corrected yesterday's data. Should the assistant rewrite yesterday's answer? covers corrected answers after source changes. Here the narrower failure is that a citation resolver points to a different span while the answer text appears unchanged.
There are privacy and retention edges. If revision 12 was deleted under a binding restriction, the service may not be allowed to display the archived bytes merely to keep a citation working. It can show that the historical citation is no longer available, and follow the applicable correction or takedown path. A content hash without retained bytes can detect that something differs, but cannot reconstruct the passage for a reader. A protected snapshot is useful only if retention is allowed.
Versioned evidence storage introduces cost and access responsibilities. Keep the archived source behind current authorization, even when the answer was originally public to a broader group. Test the resolver through a real citation click with a caller whose access changed. A correct span mapping and a successful HTTP response are necessary technical checks, while permission and claim support remain separate gates.
I would test a table inserted before the quote, OCR whitespace changes, repeated boilerplate, a moved paragraph under a new heading, an actual wording change and an access revocation. Measure citation resolution to the intended span, not just “URL returns 200.” A user updates a document and search answers from the old revision asks why search is serving the wrong document revision. This question asks what a citation means when document identity stays fixed but the span representation moves. A relevant page is still an inadequate citation if it cannot lead the reader to the evidence that supported the claim.
Related questions
Keep practising retrieval and rag
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux