Darkmind / Issue 018

Put a Time Gate Before Retrieval

Filter a knowledge base to the sources that could still be valid before semantic ranking decides what looks relevant.

Oct 25, 20265 min readGrounded retrieval

A retrieval system can give an answer that is well written, cited, and wrong for today. The source may be an old price list, a superseded policy, a release note for a retired version, or a contract whose effective period ended last month. Semantic search did not necessarily fail: it found text that means nearly the right thing. The failure is that relevance was allowed to decide a question that first needed a validity boundary.

The practical move is to put a time gate before retrieval. Store a small set of source-lifecycle fields with every document or chunk, turn the user’s time requirement into an explicit filter, and only then let keyword or vector ranking choose evidence. Ask first, “Which sources could still govern this answer?” Then ask, “Which of those sources best answers the question?”

This is not a request to sort search results by the newest timestamp. A document can be recently uploaded while describing an old policy; an older document can remain the current authoritative one. The useful fields describe the source’s business validity, not merely index activity. OpenAI’s file-search tool supports metadata filters on vector-store files, which makes source boundaries part of the search request rather than an instruction the model may overlook.[1] Azure AI Search likewise applies filters to nonvector fields to include or exclude documents in a vector query; it documents prefiltering as the mode that restricts candidates before the vector search runs.[2]

Separate source age from source authority

Give each source a stable identity and distinguish at least three dates:

Also record status such as current, superseded, draft, archived, or unknown, plus a supersedes_id when a newer document replaces an older one. These fields are not prose the model has to interpret. They are queryable metadata controlled by the system that manages the corpus.

Consider a question: “What refund window applies to Enterprise customers today?” An index might contain a current policy, an old FAQ copied into a support note, and a new policy that has been approved but is not effective yet. Ranking all three and asking the model to “use the latest information” turns a hard rule into a judgment call. A time gate can instead allow only status=current, the right plan, and documents whose validity range covers the answer date. If that filter returns nothing, that absence is a useful result: do not fill it with a plausible older rule.

Copy this temporal-retrieval contract

Use this before an agent answers a time-sensitive question from an internal knowledge base, product documentation set, or policy archive.

QUESTION: [user's exact request]
AS_OF: [today | user-supplied date | named historical date]
SCOPE: [tenant, product, plan, region, permissions]

REQUIRED METADATA PER SOURCE
- source_id: stable ID
- authority: primary_policy | approved_docs | support_note | draft
- status: current | superseded | draft | archived | unknown
- published_at: ISO date or null
- valid_from: ISO date or null
- valid_to: ISO date or null
- observed_at: ISO timestamp
- supersedes_id: source_id or null

GATE BEFORE RANKING
1. Apply access, tenant, product, plan, and region boundaries.
2. Exclude status=superseded, draft, and archived unless the question asks
   for history.
3. Require valid_from <= AS_OF and (valid_to is null or valid_to >= AS_OF).
4. Prefer the stated authority tier; do not let a support note override policy.
5. If required metadata is missing or competing primary sources survive,
   return needs_verification rather than a rule.

THEN RETRIEVE
- Run keyword/vector retrieval only inside the eligible set.
- Return source_id, title, validity fields, and supporting excerpt.
- State the AS_OF date used in the answer.

SAFE EMPTY RESULT
"No source verified as governing this scope on [AS_OF]. Escalate to the
content owner; do not infer from an expired or undated source."

The ordering is the point. Metadata filters are boundaries, while similarity scores are relevance signals. Azure notes that filters operate on filterable nonvector fields and that prefiltering applies the filter during candidate traversal; documents outside the filter do not become candidates merely because they are semantically close.[2] In a system where a wrong policy answer matters, that is usually the desired behavior.

Make “as of” explicit in the answer path

A user asking “What is the policy?” often means “What applies now.” But historical questions are legitimate too: “What policy applied on the renewal date?” or “Why did the old invoice use a different limit?” Do not hard-code today silently. Resolve an AS_OF value at the start: use the user’s date when supplied, use the request date for a current-state question, and ask for a date when a historical decision cannot be identified safely.

Return the governing source’s title, version or effective date, and source ID with the answer. This lets a reviewer see whether the system answered from a current rule or simply found a related paragraph. It also makes drift diagnosable: if yesterday’s answer changes after a policy update, you can identify which metadata transition changed the eligible set.

Failure mode: treating metadata as proof

A time gate is only as good as the source lifecycle data. An incorrectly labeled current document can still win; a policy may apply differently by country, product edition, contract, or customer exception. Filters can also become so narrow that they hide the only useful evidence. Do not invent dates during ingestion merely to make every source eligible.

Audit metadata changes, preserve the original document and its version, and test the gate with three fixtures: an expired rule, a future-dated rule, and two overlapping current rules. For high-impact answers, require a source owner or second verification when the filter leaves an ambiguity. The goal is not to make retrieval return something every time. It is to make the system honest about whether it found a source that could actually govern the question.

The habit to keep

before AI ranks what sounds relevant, filter for what could still be true for this scope and date. A smaller eligible set is often the difference between a fluent answer and an applicable one.

Sources

  1. OpenAI, “File search”
  2. Microsoft Learn, “Add a filter to a vector query in Azure AI Search”