Claims API and Schema
February 21, 2026 · View on GitHub
Overview
The claims subsystem extracts concise, verifiable factual statements ("claims") from ingested content and makes them searchable and rebuildable. Two usage modes exist:
- Ingestion-time: After chunking, optionally extract a small number of claims per chunk and store them in the Media DB for search/RAG pipelines.
- Answer-time: Extract and verify claims from generated answers (see Claims Engine in design docs), not covered by these endpoints.
This page documents the database schema, configuration, ingestion hook, background service, and the Claims API.
Database Schema (Media DB v2)
Table: Claims
idINTEGER PRIMARY KEY AUTOINCREMENTmedia_idINTEGER NOT NULL (FK -> Media.id, ON DELETE CASCADE)chunk_indexINTEGER NOT NULLspan_startINTEGER NULLspan_endINTEGER NULLclaim_textTEXT NOT NULLconfidenceREAL NULLextractorTEXT NOT NULL (e.g., heuristic|llm|auto|provider)extractor_versionTEXT NOT NULLchunk_hashTEXT NOT NULL (sha256 of the source chunk text)created_atDATETIME NOT NULL DEFAULT CURRENT_TIMESTAMPuuidTEXT UNIQUE NOT NULLlast_modifiedDATETIME NOT NULLversionINTEGER NOT NULL DEFAULT 1client_idTEXT NOT NULLdeletedBOOLEAN NOT NULL DEFAULT 0prev_versionINTEGER NULLmerge_parent_uuidTEXT NULL
Indexes
idx_claims_media_idon(media_id)idx_claims_media_chunkon(media_id, chunk_index)idx_claims_uuidUNIQUE on(uuid)idx_claims_deletedon(deleted)
FTS (SQLite)
claims_fts(FTS5) withclaim_text,content='Claims',content_rowid='id'- Triggers keep
claims_ftssynchronized on INSERT/UPDATE/DELETE ofClaims.
Helpers (MediaDatabase)
upsert_claims(rows) -> intget_claims_by_media(media_id, limit=100) -> List[dict]soft_delete_claims_for_media(media_id) -> intrebuild_claims_fts() -> int
Configuration
Env or [Claims] in Config_Files/config.txt:
ENABLE_INGESTION_CLAIMS(bool, default: false)CLAIM_EXTRACTOR_MODE(heuristic|llm|auto|, default: heuristic) CLAIMS_MAX_PER_CHUNK(int, default: 3)CLAIMS_EMBED(bool, default: false)CLAIMS_EMBED_MODEL_ID(string, optional)CLAIMS_LLM_PROVIDER,CLAIMS_LLM_MODEL,CLAIMS_LLM_TEMPERATURE(used when an LLM extractor is selected)CLAIMS_JSON_PARSE_MODE(lenient|strict, default:lenient)CLAIMS_ALIGNMENT_MODE(off|exact|fuzzy, default:fuzzy)CLAIMS_ALIGNMENT_THRESHOLD(float, default:0.75)CLAIMS_MONITORING_ENABLED(bool)CLAIMS_ADAPTIVE_THROTTLE_ENABLEDwith optional thresholds:CLAIMS_ADAPTIVE_THROTTLE_LATENCY_MSCLAIMS_ADAPTIVE_THROTTLE_ERROR_RATECLAIMS_ADAPTIVE_THROTTLE_BUDGET_RATIO
Provider resolution for ingestion LLM extraction follows this order:
- Use
CLAIMS_LLM_PROVIDER,CLAIMS_LLM_MODEL,CLAIMS_LLM_TEMPERATUREwhen set. - Otherwise use
RAG.default_llm_providerandRAG.default_llm_model. - Finally use
default_apiwith a conservative temperature (default0.1).
Ingestion Hook
If ENABLE_INGESTION_CLAIMS=True, the embeddings pipeline (ChromaDB_Library) will:
- Extract claims from generated chunks using the configured extractor mode.
- Store them in
Claimsand maintainclaims_fts. - Optionally embed claims into a dedicated Chroma collection when
CLAIMS_EMBED=True.
Background Service
ClaimsRebuildService runs in the background to rebuild claims for media items by:
- Chunking saved content
- Extracting claims (
heuristic|llm|auto|provider) - Soft-deleting old entries and inserting new rows with chunk hashes
Exposed via API endpoints to enqueue work per media or in bulk.
API Endpoints
Base prefix: /api/v1/claims
-
GET /{media_id}- List claims for a media item- Optional query params:
limit(default 100)offset(default 0)envelope(default false) - when true, returns an envelope instead of a bare listuser_id(admin only) to select another user’s media DB
- Response:
- when
envelope=false:List[ClaimRow](DB rows excludingdeleted), ordered bychunk_indexthenid - when
envelope=true:{ "items": List[ClaimRow], "next_offset": int|null, "total": int, "total_pages": int, "next_link": string|null }next_linkis a simple link preservinglimit,offset,envelope, andabsolute_links; includesuser_idwhen admin overrides are used.- Add
absolute_links=trueto return a fully qualifiednext_link.
- when
- Optional query params:
-
POST /{media_id}/rebuild- Enqueue rebuild for a media item- Optional (admin):
user_idto target another user DB - Response:
{ "status": "accepted", "media_id": <id> }
- Optional (admin):
-
POST /rebuild/all- Enqueue rebuild across media- Query param
policy:missing(default)|all|stale - Optional (admin):
user_id - Response:
{ "status": "accepted", "enqueued": <count>, "policy": "..." }
- Query param
-
POST /rebuild_fts- Rebuildclaims_ftsfromClaims- Optional (admin):
user_id - Response:
{ "status": "ok", "indexed": <count> }
- Optional (admin):
Security & tenancy
- Endpoints operate on the current user’s Media DB by default.
- Admins can override target user via
user_idfor maintenance tasks.
Examples
List claims
curl -s -H "Authorization: Bearer <JWT>" \
"http://127.0.0.1:8000/api/v1/claims/123?limit=50"
Response (truncated)
[
{
"id": 42,
"media_id": 123,
"chunk_index": 5,
"span_start": null,
"span_end": null,
"claim_text": "Alice founded Acme in 2020.",
"confidence": null,
"extractor": "heuristic",
"extractor_version": "v1",
"chunk_hash": "...",
"created_at": "...",
"uuid": "...",
"last_modified": "...",
"version": 1,
"client_id": "SERVER_API_V1"
}
]
Enqueue rebuild for a single item
curl -s -X POST -H "Authorization: Bearer <JWT>" \
"http://127.0.0.1:8000/api/v1/claims/123/rebuild"
Bulk rebuild for missing claims
curl -s -X POST -H "Authorization: Bearer <JWT>" \
"http://127.0.0.1:8000/api/v1/claims/rebuild/all?policy=missing"
Rebuild FTS
curl -s -X POST -H "Authorization: Bearer <JWT>" \
"http://127.0.0.1:8000/api/v1/claims/rebuild_fts"
Notes
- Ingestion-time extraction can be enabled selectively; not all ingestion paths invoke it by default.
- The answer-time Claims Engine (APS/LLM extractor + Hybrid verifier) is documented in design and is separate from these API endpoints.
GET /status- Claims rebuild worker status (admin only)- Response:
{ "status": "ok", "stats": { "enqueued": int, "processed": int, "failed": int }, "queue_length": int, "workers": int }
- Response:
Monitoring and Alerting
Claims telemetry counters include:
- Provider and budget health:
claims_provider_requests_totalclaims_provider_errors_totalclaims_provider_budget_exhausted_totalclaims_provider_throttled_total
- Structured output and parsing quality:
claims_response_format_selected_totalclaims_output_parse_events_totalclaims_fallback_total
Operational assets:
- Dashboard:
Docs/Monitoring/claims_grafana_dashboard.json - Alert rules:
Docs/Monitoring/claims_alerts_prometheus.yaml - Runbook:
Docs/Operations/Claims_Alerts_Runbook.md