rag-staleness-auditor-py
Find stale RAG chunks by age, version, and freshness requirements. Run a quick audit over your retrieved documents before stuffing them into a prompt. Flag anything older than your max-age, or anything pinned to a stale version. Zero runtime dependencies.
Python port of @mukundakatta/rag-staleness-auditor.
Install
pip install rag-staleness-auditor-py
Usage
from rag_staleness_auditor import audit, filter_fresh
records = [
{"id": "doc1", "updated_at": "2026-04-01T00:00:00Z", "version": "v3"},
{"id": "doc2", "updated_at": "2024-01-01T00:00:00Z", "version": "v2"},
{"id": "doc3", "updated_at": None, "version": "v1"},
]
report = audit(records, max_age_days=90, current_version="v3")
report.total # 3
report.stale_count # 2
report.fresh_count # 1
report.stale_ids # ["doc2", "doc3"]
report.entries[0].reasons # [] for fresh, e.g. ["too_old", "version_mismatch"] otherwise
# Drop the stale ones from your retrieval result before building the prompt:
fresh = filter_fresh(records, max_age_days=90, current_version="v3")
API
| Symbol | Behavior |
|---|---|
audit(records, *, max_age_days=90, current_version=None, date_field='updated_at', version_field='version', now=None) |
Returns an AuditReport with per-doc verdicts. |
audit_staleness(records, *, max_age_days=30, current_version=None, ...) |
Lower-level helper -- returns list[StalenessEntry] (matches the JS sibling's shape). |
filter_fresh(records, *, ...) |
Returns the input list with stale records dropped. |
AuditReport |
Dataclass with total, stale_count, fresh_count, stale_ids, entries. |
StalenessEntry |
Dataclass with id, stale, age_days, reasons. |
reasons values are "too_old" and "version_mismatch", matching the JS sibling.
date_field and version_field let you swap field names without rewriting your records (e.g. version_field="schema_version").
See the JS sibling's README for the full design notes.
Metadata
Release files for rag-staleness-auditor-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rag_staleness_auditor_py-0.1.0.tar.gz | 6.5 kB | Without provenance | Details for rag_staleness_auditor_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rag_staleness_auditor_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for rag_staleness_auditor_py-0.1.0-py3-none-any.whl |
Total release size: 12.9 kB
Release files / rag_staleness_auditor_py-0.1.0.tar.gz
| Download URL | rag_staleness_auditor_py-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf523b1f9f7123a9d5d3e16de594577b3bc26e52e093e85a9fa59f12efdc03f8
|
|
BLAKE2b-256 checksum How to use checksums |
50d70ee5a521e3fb9e10bfa61fbca5afc17e8fbe8d6d6576b50f31326ba60b4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / rag_staleness_auditor_py-0.1.0-py3-none-any.whl
| Download URL | rag_staleness_auditor_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c0d41ad12c5fe9f03c7196487301881f50305d3d913cc2a59c2985af13bb668
|
|
BLAKE2b-256 checksum How to use checksums |
e5630ff54fb5e281072ddbcef551cb72a3f0557d3cb84d73f39dfaf6f75740bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for rag-staleness-auditor-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.