Handle stale documents by defining which source revision applies to the question’s time and scope. The newest indexed document is not automatically correct for a question about a past transaction.
Publication time and effective time differ
A policy can be uploaded today but become effective next month. A customer may ask about an order placed under the previous policy. Record effective periods and relevant scope alongside ingestion time so retrieval can choose the applicable evidence rather than simply sorting by upload date.
Use nonoverlapping applicability where the policy permits it
The fixture defines two synthetic policy periods with an inclusive start and exclusive end. A March transaction selects the earlier policy, while an August transaction selects the later one. If multiple policies match the same period and scope, flag the ambiguity; do not silently choose an arbitrary result.
Test the temporal boundary
- Use questions before, on, and after the effective-date transition.
- Include questions that omit the transaction date and need clarification.
- Verify that permissions still apply to historical documents.
- Inspect cache dependencies and citations so an applicable historical answer does not link to an unrelated current policy.
Keep policy interpretation explicit
Real applicability may depend on contract terms, region, product, or later amendments. Have the responsible policy owner define those rules. The sample implements a simple date-range selection for synthetic records; it is not a legal determination or a general policy-resolution engine.
Run the worked example
Save the synthetic Node.js example and run node handle-stale-and-current-rag-documents.mjs with Node.js 22 or newer. The assertions check the illustrated records and calculations; they do not test a deployed provider, SDK, or access control. No credentials or network connection are needed.
// Synthetic teaching fixture. No credentials, network calls, or production verification.
import assert from 'node:assert/strict';
const policies = [
{ id: 'p1', start: '2026-01-01', end: '2026-07-01' },
{ id: 'p2', start: '2026-07-01', end: '2027-01-01' },
];
const applicable = day => policies.filter(p => p.start <= day && day < p.end);
assert.deepEqual(applicable('2026-03-01').map(p => p.id), ['p1']);
assert.deepEqual(applicable('2026-08-01').map(p => p.id), ['p2']);
assert.deepEqual(applicable('2026-07-01').map(p => p.id), ['p2']);
console.log('Select evidence by the relevant effective period, including the transition boundary.');
References and further reading
Maintained by DriftRail. AI assisted the October 2026 content and template revision. Examples are illustrative; they are not measured product benchmarks. Suggest a correction.