Minimal example of using Proof-Carrying Numbers (PCN) in a React app: a claims manager, provider, and ClaimMark components so numeric claims show ✓ (verified) or ⚠ (pending) against cached tool data.
- ClaimsManager – Created once, with a
createDataPointExtractorfor a fakeget_datatool that returns{ data: [{ claim_id, OBS_VALUE, REF_AREA, TIME_PERIOD, ... }] }. - ClaimsProvider – Wraps the app so components can read claims and the manager.
- Simulated tool result – On mount, the app calls
manager.ingest("get_data", mockResult)with two data points (poverty rate 42%, GDP per capita 2.1k). Those claims are cached. - Message with claims – A simple message uses
ClaimMarkfor:- 42% (policy
percent) — cached as 0.42 → ✓ verified - 2.1k (policy
abbr) — cached as 2100 → ✓ verified - about 5.2% (policy
rounded, decimals 1) — no cached claim → ⚠ pending
- 42% (policy
From the repository root (so workspace deps resolve):
pnpm install
pnpm --filter pcn-example-chat-app devThen open http://localhost:5173.
Or from this directory after root install:
cd examples/chat-app
pnpm install
pnpm devpnpm --filter pcn-example-chat-app build
pnpm --filter pcn-example-chat-app preview- @pcn/core –
ClaimsManager,createDataPointExtractor,compareByPolicy - @pcn/ui –
ClaimsProvider,ClaimMark,useClaimsManager