asmit dash
Open-source library

staleness

Open source · shipped to PyPI

Corpus freshness and drift linter.

What it is

A deterministic freshness and drift linter for RAG knowledge bases. staleness inspects timestamps and metadata - it does not call any LLM, embed chunks, or hit a vector DB. Pure Python stdlib, sub-second on 100k chunks.

Why it's needed

A RAG corpus that was fresh on launch day quietly rots. Six months in, a documentation chunk says 'the API takes parameter X' - but parameter X was renamed in the last release. News retrieval returns last year's market summary because no one indexed this quarter. A chunk's timestamp is silently None, so the model treats stale and current content as equivalent. Clock-skew bugs in ingestion produce future-dated chunks that artificially rank well. Your embed model was trained in 2021 and your corpus is mostly 2025, so half your domain language doesn't embed well. These are operational bugs; retrievers don't fix them.

What it does

staleness catches missing or unparsable timestamps, chunks older than max_age_days, future-dated chunks from clock skew, severe age skew (most content clustered inside a tiny slice of the time span), coverage gaps in the recent window, embed-model-vs-corpus age mismatch, and topic-localised staleness where one topic is much older than the corpus median. Timestamps can be datetimes, epoch seconds (ms auto-detected), or ISO 8601 strings.

How to use it

Install it:

pip install staleness

Then call it:

import staleness
from datetime import datetime, timezone

report = staleness.check_corpus(
    chunks,
    max_age_days=365,
    embed_model_name="text-embedding-3-small",
    now=datetime.now(timezone.utc),
)
print(report)
if not report.ok():
    raise SystemExit("Refresh stale chunks before relying on this corpus.")

Links