Typed provenance and confidence downgrades for LLM claim envelopes.
Stop surfacing unsupported claims as observed facts.
llm-claim-governor is a small TypeScript package that applies governance rules
to structured LLM output. It preserves typed sources, downgrades confidence when
evidence is weak or indirect, and marks unverified research as provisional.
Most agent stacks can generate claims faster than they can justify them.
This package focuses on the output layer:
- unsupported observed facts are downgraded
- indirect-only evidence cannot stay high confidence
- unverified research is marked provisional
- stale evidence cannot remain at maximum confidence
- Typed claim envelopes for
observed_fact,inferred_conclusion,hypothesis, andrecommendation - Built-in source classes such as
repo_file,test_result,runtime_probe,recall_fast, andresearch_unverified - Configurable direct-source policy
- Zero runtime dependencies
- Small API surface:
governClaimEnvelope(...),inferRecallSourceType(...), andClaimGovernor
npm install llm-claim-governorThis repo includes a static demo that runs the built package in the browser and is configured for Vercel deployment.
Local preview:
npm install
npm run dev:demoVercel uses vercel.json and builds the deployable demo output into
site/ with:
npm run build:demoimport { ClaimGovernor } from 'llm-claim-governor';
const governor = new ClaimGovernor();
const governed = governor.enforce({
claims: [
{
text: 'The database schema changed last week.',
type: 'observed_fact',
confidence: 'high',
freshness: 'live',
sources: [],
},
{
text: 'The migration should be reviewed before deployment.',
type: 'recommendation',
confidence: 'high',
freshness: 'live',
sources: [{ type: 'repo_file', ref: 'migrations/schema.sql' }],
},
],
});
console.dir(governed, { depth: null });Example result:
{
"claims": [
{
"text": "The database schema changed last week.",
"type": "hypothesis",
"confidence": "insufficient",
"freshness": "live",
"sources": []
},
{
"text": "The migration should be reviewed before deployment.",
"type": "recommendation",
"confidence": "high",
"freshness": "live",
"sources": [
{
"type": "repo_file",
"ref": "migrations/schema.sql"
}
]
}
],
"governor_note": "Observed fact without source was downgraded to hypothesis."
}More examples:
import {
ClaimGovernor,
governClaimEnvelope,
inferRecallSourceType,
type ClaimEnvelope,
type ClaimGovernorOptions,
} from 'llm-claim-governor';governClaimEnvelope(envelope, options?)
- Applies the governance rules directly to a
ClaimEnvelope
new ClaimGovernor(options?)
- Class wrapper over the same rules
govern(envelope)andenforce(envelope)are equivalent
inferRecallSourceType(recallTelemetry?)
- Returns
recall_fastwhen telemetry indicates a fast-recall path - Returns
recall_directotherwise
The default governor behavior is:
observed_factwith no sources becomeshypothesis- high-confidence claims backed only by
recall_fastare downgraded tomedium - high-confidence claims without a direct source are downgraded to
medium research_unverifiedclaims are marked provisional and reduced tolow- stale high-confidence claims are downgraded to
medium
The default direct-source set is:
repo_filetest_resultruntime_proberecall_directresearch_verified
You can extend or replace that list through ClaimGovernorOptions.directSourceTypes.
npm install
npm test
npm run buildDemo build:
npm run build:demoGitHub Actions runs test and build on pushes and pull requests via .github/workflows/ci.yml.