DEV Community

prabhakar srivastava
prabhakar srivastava

Posted on

TruthGraph: the right rule depends on when—and for whom

Sanity Challenge Path One Submission

This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content.

What I Built

Ask what happens when a goalkeeper holds the ball too long. Then ask the same question about a match on 1 March 2025.

The wording barely changes. The applicable rule does.

TruthGraph is an evidence agent that works out which rule applies to your situation. It uses Sanity Context to retrieve evidence, then checks dates, match conditions, and relationships between claims before composing an answer with sources.

I built three sports collections: football, cricket, and chess. They contain short, structured claims linked to official rulebooks and announcements. These domains make the problem tangible: the newest rule can be wrong for an older match, and a rule for international play may not apply to a club game.

Every result includes a comparison with a simple keyword baseline over the same claims. When that baseline agrees, the app says so. When it disagrees, you can inspect the condition or relationship that changes the answer.

Demo

Open TruthGraph · Watch the 1 minute 42 second walkthrough

The walkthrough includes English narration and captions. Download the MP4 or read the transcript.

Watch the TruthGraph walkthrough

How judges can try it

  1. Open the app and choose Start the guided tour. No account or access code is needed.
  2. Try the historical goalkeeper question, then the substitutes question. Inspect the answer, keyword comparison, and supporting claims.
  3. For a custom question, choose a collection and paste this application access code into Access code:
   989d7decc7cf43958bbad8e3eca301c8c8fce67dc3eb09ec
Enter fullscreen mode Exit fullscreen mode

Try an everyday question about offside, LBW, or castling in the corresponding collection. Custom questions use the live model and Sanity Context; the code does not grant content-management access.

Three moments worth exploring

1. A relevant rule can be wrong for the date.

For the historical goalkeeper example, TruthGraph selects the six-second rule and indirect free kick that applied on 1 March 2025. The keyword baseline selects the newer eight-second rule and corner kick. The effective-date fields explain the difference.

Historical match date: the applicable rule differs from the newest keyword match

2. Missing context should trigger a question.

“How many substitutes can a team use?” needs a match type. TruthGraph asks for that context instead of treating one match category's rule as universal.

TruthGraph asks which kind of match before selecting a substitutes rule

3. You can inspect what changes the evidence.

The Evidence Lab lets you supply a hypothetical condition, such as “club friendly,” and see how it changes the applicability of retrieved claims. It operates on the retrieved snapshot without another model call. The comparison is labelled hypothetical, and the original answer stays visible.

The Evidence Lab evaluates a hypothetical club-friendly condition

Code

Public GitHub repository: prabhakarcs786/truthgraph

The README includes setup instructions, architecture notes, and commands for unit and browser checks.

Built with Next.js, React, TypeScript, Sanity, the Vercel AI SDK with Gemini, Zod, and semver. I used GitHub Copilot and Codex during development and submission preparation.

How I Used Sanity

I pointed a Sanity Knowledge Base at structured records in Content Lake: sources, claims, and collections. The agent accesses it through a Knowledge Base-only Sanity Context MCP endpoint.

The investigation flow is:

  1. Read the Knowledge Base outline with initial_context.
  2. Retrieve relevant entries with knowledge_base_read.
  3. Extract the question's intent and select claim IDs. The server restricts retrieval to the configured Knowledge Base.
  4. Check that each selected claim is cited by a retrieved entry.
  5. Evaluate the canonical claims against dates, versions, named conditions, and explicit replacement or correction relationships.
  6. Compose the answer from those canonical statements and source URLs, with an inspectable trace.

The model helps navigate and select evidence. Deterministic code evaluates applicability and unresolved conflicts. A generated paragraph alone is not accepted as evidence.

The trace shows the recorded Sanity Context retrieval and citation validation

Why the structure matters

Record Information the agent can use
tgSource Official URL, publisher, authority, and publication/review dates
tgClaim Statement, subject, property, value, effective dates, optional version range, named conditions, and supersedes/corrects references
tgKnowledgeBase Collection purpose, Context Knowledge Base mapping, and guided examples

These fields let the application explain why a retrieved statement applies. It can retain an older rule for historical questions, ask for an absent match condition, and show conflicting evidence when there is no recorded resolution.

The optional Curate workflow stores precedence decisions as relationships on Sanity claims. Content management is disabled on the public deployment; the local setup supports it with separate administrator credentials.

Sanity Project Details

  • Project ID: d7k23z8r
  • Dataset: production (public)
  • Sanity Context Knowledge Base: TruthGraph (kb0JA1DdQw6D)
  • Sports corpus: three collections, 34 source records, and 91 claims
  • Current document count: 143 of the 150-document budget, including recorded tour data

Football sources include IFAB; cricket sources include MCC and ICC; chess sources include the FIDE Handbook. Each claim links to its source so readers can inspect the underlying publication.

What Is Live, What Is Recorded, and Current Limits

The guided tour replays labelled investigations previously run through Sanity Context to conserve the model's free-tier quota. Cached answers are reused only while the relevant question and content checks still match. The result and trace identify recorded runs. Custom questions run live.

The video demonstrates those recorded tour results and uses a synthetic Microsoft Ava voice.

The collections are deliberately small. They are not complete rulebooks. The system can return insufficient evidence, and different phrasings can affect what the model retrieves. Unsupported or uncited selections are rejected; that does not make retrieval infallible. Free-tier provider limits can also temporarily prevent a live response.

The repository includes unit checks for reasoning, grounding, and access controls, plus desktop/mobile browser checks. The deployed recording, screenshots, and public media links were checked on 2 October 2026.

My aim with TruthGraph is to make the path from question to applicable evidence visible: which claim was retrieved, which conditions mattered, and which source supports the answer.

Top comments (0)