Skip to main content

groundwright

A retrieval grounding gate — did retrieval return the expected source, by evidence?

groundwright does not judge whether an answer is good (that is answer-quality eval: ragas, deepeval). It checks the step before: for a golden set of questions with the expected source and a text anchor, does your retriever return that source (provenance) and the chunk that actually contains the anchor — and does the run stay above a provenance / source-hit threshold you set (a regression gate)?

from groundwright import evaluate, regression_failures

golden = {
    "kb": "security", "source": "docs/policy.md", "k": 5,
    "cases": [
        {"id": "c1", "question": "what is the data retention policy?",
         "anchor": "retained for 30 days", "source": "docs/policy.md"},
    ],
}

def retrieve(kb, question, k):
    # your retriever -> [{"citation": {"source": ..., "uri"?: ...},
    #                     "content": ..., "metadata"?: {...}}, ...]
    ...

report = evaluate(golden, retrieve)                  # {"summary": {...}, "cases": [...]}
failures = regression_failures(report["summary"])    # [] = the gate passes

The retriever is a plug

Retrieve = (kb, question, k) -> list[hit]. groundwright never talks to a vector DB, an MCP or an index — it measures whatever retriever you give it, so the same gate runs in CI with a fake retriever and in production with the real one.

Metrics

Metric Meaning
provenance_ok every returned hit carries a source (attribution)
source_hit@k the expected source is in the top-k
chunk_hit@{1,3,k} the chunk that contains the anchor is ranked at/within N
mrr_chunk mean reciprocal rank of the anchor chunk
provenance_v2_ok hits carry both metadata and a citation uri (rich provenance)

regression_failures(summary, min_provenance_ok=1.0, min_source_hit=0.8) is the gate: an empty list means the run passes; thresholds are parameters.

Why it exists (and what it is not)

RAG quality has two separate questions. "Is the answer good?" is owned by ragas / deepeval (LLM-as-judge). "Did we retrieve the right source, and can we prove it?" is retrieval provenance — and it is where silent regressions hide: a reindex, a chunker change or a model swap quietly stops returning the authoritative source, and an answer-quality score may still look fine. groundwright gates that, deterministically, with no LLM in the loop. See POSITIONING.md.

API

  • load_golden(data) -> dict — validate a golden set (raises GoldenError)
  • evaluate(golden, retrieve) -> {"summary", "cases"}
  • regression_failures(summary, *, min_provenance_ok=1.0, min_source_hit=0.8) -> list[str]
  • anchor_errors(golden, chunks) -> list[str] — offline: each anchor in exactly one chunk
  • CLI: groundwright validate <golden.json> <chunks.json> · groundwright gate <report.json>

Install

pip install groundwright

MIT licensed. Part of the network-agents-setup ecosystem; extracted from its governed runner's L5 retrieval gate.

Metadata

Release files for groundwright 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for groundwright 0.1.0
File Size Uploaded
groundwright-0.1.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for groundwright 0.1.0
File Interpreter ABI Platform
groundwright-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / groundwright-0.1.0.tar.gz

Download URL groundwright-0.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
73f3969700a46971dee3a5766cc0bb2dae288a0a82c710ed312925e39a02977f
BLAKE2b-256 checksum
How to use checksums
3790a86db6834f4477e3258fbe9120d9d1a9b41e7958f1054b630ecd24284411
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / groundwright-0.1.0-py3-none-any.whl

Download URL groundwright-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4d8919e75ab58f055843e791901a012a0c59204c5aff2018032f9ea04b949a4
BLAKE2b-256 checksum
How to use checksums
5cf3045107ab42b5306bdd82909ca81d64a561c260f6c0b37eecbe901c367046
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page