# Provenance trace

Live provenance (Candor's ProvenanceOverlay). Hold Option/Alt, or press Trace, and everything dims except each claim and the evidence it rests on, joined by a connector. Hovering or focusing one claim lights just its own evidence. A claim with no evidence is marked as such instead of being drawn as if it had some.

- Registry name: `provenance-trace` (`@candor/provenance-trace`)
- 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/provenance-trace

## Install

```bash
npx candor-ui add provenance-trace
```

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

## Example

```tsx
"use client"

import type { Claim, RetrievedPassage } from "@/lib/know"
import { ProvenanceTrace } from "@/components/provenance-trace"

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

const evidence: RetrievedPassage[] = [
  { id: "p1", sourceId: "k3", title: "Data model notes, §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, readAt: ago(24 * 12) },
  { id: "p2", sourceId: "k1", title: "Job: assign_region (Staging)", excerpt: "assign_region reads customers.region; the partner-tier fallback sits behind a flag that is off.", score: 0.84, cited: true, readAt: ago(5) },
  { id: "p3", sourceId: "k2", title: "Job: assign_region (Production)", excerpt: "Version 6 is deployed to Production; the partner-tier fallback is still on there.", score: 0.69, cited: true, readAt: ago(52) },
]

const claims: Claim[] = [
  { id: "c1", text: "Customers are routed to a data region by region, not partner tier.", evidence: ["p1"] },
  { id: "c2", text: "On Staging the assign_region job only uses the region column;", evidence: ["p2"] },
  { id: "c3", text: "Production is a version behind and still falls back to partner tier.", evidence: ["p3"] },
  { id: "c4", text: "Deploying the new version won't move any existing customer's data.", evidence: [] },
]

export default function Example() {
  return <ProvenanceTrace className="max-w-3xl" claims={claims} evidence={evidence} />
}
```

## <ProvenanceTrace>

Props:

- `claims: Claim[]`: The answer's claims, each with the ids of the passages it rests on.
- `evidence: RetrievedPassage[]`: The passages the claims point to.
- `className?: string | undefined`

## Strings (`provenanceTrace`)

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

- `trace`: Trace
- `orHold`: or hold
- `optionKey`: ⌥ Option
- `noEvidence`: (no evidence)
- `legend`: Dotted underline: a claim the answer makes without citing evidence.

## 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`.
