# Retrieval inspector

The passages behind an answer, in the order the retriever ranked them. Each says whether the answer actually cites it — retrieved-but-unused is shown, not hidden — with its score (or that it wasn't scored), its source and how fresh it is. Expand a passage for the excerpt and why it ranked there.

- Registry name: `retrieval-inspector` (`@candor/retrieval-inspector`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/retrieval-inspector

## Install

```bash
npx candor-ui add retrieval-inspector
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/retrieval-inspector`.
It brings in: collapsible, freshness-stamp, know, knowledge-sources, locale, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import type { KnowSource, RetrievedPassage } from "@/lib/know"
import { RetrievalInspector } from "@/components/retrieval-inspector"

const ago = (h: number) => new Date(Date.now() - h * 3_600_000).toISOString()

const sources: KnowSource[] = [
  { id: "k1", door: "config", label: "Staging: code and schema", readAt: ago(5), everyHours: 24, status: "succeeded" },
  { id: "k2", door: "data", label: "customers, sampled", readAt: ago(5), everyHours: 168, status: "succeeded" },
  { id: "k3", door: "file", label: "Data model notes v3.pdf", addedBy: "Priya", readAt: ago(24 * 12), status: "succeeded" },
  { id: "k4", door: "answer", label: "Answer from Priya", addedBy: "Priya", readAt: ago(24 * 9), status: "succeeded" },
]

const passages: RetrievedPassage[] = [
  { id: "p1", sourceId: "k3", title: "§3.2 Data regions", excerpt: "Customers are routed to a data region by region (us, eu, apac). Partner tier is no longer used for routing.", score: 0.91, cited: true, why: "Matches “data region” and “partner tier”", readAt: ago(24 * 12) },
  { id: "p2", sourceId: "k1", title: "Job: assign_region", excerpt: "assign_region reads customers.region; the partner-tier fallback sits behind a flag that is off.", score: 0.84, cited: true, why: "The job named in the answer", readAt: ago(5) },
  { id: "p3", sourceId: "k4", title: "Answer from Priya", excerpt: "Partner tier is being replaced by region. Keep it on the two partner dashboards until Q1.", score: null, cited: true, why: "Pinned: a person's answer to this exact question", readAt: ago(24 * 9) },
  { id: "p4", sourceId: "k2", title: "Fill rates on customers", excerpt: "region is filled on almost every sampled row; partner_tier_old has no recent writes.", score: 0.71, cited: false, why: "Relevant, but the answer didn't need it", readAt: ago(5) },
]

export default function Example() {
  return <RetrievalInspector className="max-w-2xl" passages={passages} sources={sources} />
}
```

## <RetrievalInspector>

Props:

- `passages: RetrievedPassage[]`: The retrieved passages, in rank order, each marked cited or not.
- `sources: KnowSource[]`: The sources the passages come from, looked up by id for name and freshness.
- `verb?: string | undefined`: The word before each passage's date, for what `readAt` records: "Reviewed", "Published", "Synced". Defaults to FreshnessStamp's "Read".
- `className?: string | undefined`

## Strings (`retrievalInspector`)

The fixed words, English by default. Override any of them under `retrievalInspector` in `<LocaleProvider strings={{ retrievalInspector: { … } }}>`; the table is exported as `retrievalInspectorStrings`.

- `label`: Retrieved passages
- `heading`: What was retrieved
- `passages`: { one: "{count} passage", other: "{count} passages" }
- `cited`: {count} cited
- `citedOnly`: Cited only
- `citedBadge`: Cited
- `notUsed`: Not used
- `notScored`: Not scored
- `why`: Why here: {why}

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
