What Is Provenance?
Provenance is the systematic recording of where data came from, how it was transformed, and who was responsible for each step in its lifecycle. Unlike ordinary graph metadata that simply describes entities, provenance creates an immutable audit trail that tracks the complete history of every piece of information in your system. Key provenance concepts: Lineage traces the chain of custody from original source through all transformations to the current state, showing exactly how data evolved over time. Source attribution records the specific document, database, API call, or human input that produced each data element, enabling precise citation and verification. Integrity verification uses cryptographic checksums to detect any unauthorized changes to provenance records after they were created. Audit trails provide regulatory compliance by maintaining tamper-evident logs of all data operations, transformations, and decisions. Provenance differs from simple metadata by creating legally defensible, cryptographically verifiable records that answer critical questions: “Where did this come from?”, “Who processed it?”, “When did it change?”, and “Has it been tampered with?”Why Use Provenance?
Compliance with regulatory requirements. Meet FDA 21 CFR Part 11, ICH E6(R2) GCP, Basel III BCBS 239, and defense intelligence sharing agreements that mandate complete data traceability and electronic record integrity. Source attribution and citation. Trace every entity, relationship, and property value back to its exact source document, API response, or human input for scientific reproducibility and legal defensibility. Auditability and transparency. Provide auditors, regulators, and stakeholders with complete visibility into data processing workflows, including who performed each operation and when changes occurred. Conflict resolution and data quality. When multiple sources provide different values for the same property, provenance records enable evidence-based conflict resolution by comparing source credibility, recency, and confidence levels. Tamper detection and forensics. Cryptographic integrity verification detects unauthorized modifications to data records, supporting incident response and forensic analysis in security-sensitive environments. Traceability for data lineage. Answer complex questions about data ancestry, especially in multi-stage processing pipelines where entities undergo extraction, enrichment, fusion, and analysis transformations.When To Use / When Not To Use
Use provenance tracking for:- Regulated environments requiring audit trails (healthcare, finance, defense, pharmaceuticals)
- Multi-source data fusion where conflicting information must be resolved with evidence
- Long-lived knowledge graphs where data quality and source credibility matter
- Production systems where data integrity and tamper detection are critical
- Complex processing pipelines where entities undergo multiple transformations
- Situations requiring legal defensibility of decisions based on extracted data
- Simple prototypes and proof-of-concept demonstrations where compliance is not required
- Ephemeral workflows that process data once and discard results immediately
- Stateless applications that don’t persist data across sessions
- Internal research projects with trusted single-source data
- High-frequency, low-latency operations where provenance overhead impacts performance
- Scenarios where all data comes from a single, highly trusted source that never changes
- Basic metadata (creation timestamp, source file name) provides sufficient traceability
- Data processing is transparent and reproducible through version control alone
- Regulatory compliance does not require cryptographic integrity verification
ProvenanceManager records a W3C PROV-O compliant entry for every entity, relationship, document chunk, and property value — with a SHA-256 checksum for tamper detection and automatic version chaining on every track_entity() call. Use it when you need to answer regulatory questions about where a value came from, who wrote it, and whether it has changed since first ingestion.
The KG pipeline auto-calls
track_entity() and track_relationship() on everything it extracts, so entities that enter through the standard pipeline are already tracked. Use the manual API covered here when you need custom audit integrations, cross-module lineage chains, or fine-grained property-level attribution across multiple sources.Setting up the provenance store
ProvenanceManager supports two storage backends. In-memory storage is zero-dependency and useful for testing. SQLite storage persists across restarts, supports concurrent reads, and gives your compliance team a standard database they can query directly.
storage_path. A SQLite file can be backed up, versioned, and queried with standard tools without requiring a server.
SQLiteStorage automatically configures Write-Ahead Logging (WAL), busy_timeout=5000, and synchronous=NORMAL, and executes read-modify-write operations (like track_entity()) in atomic immediate transactions (BEGIN IMMEDIATE); plain reads (retrieve(), trace_lineage()) use a separate connection without an explicit write lock so they don’t serialize behind writers. Furthermore, ProvenanceManager automatically supports custom storage backends overriding only trace_lineage(self, entity_id) without requiring max_depth in their signature.Recording provenance when ingesting data
The moment data enters your graph is the moment provenance must be recorded.track_entity() captures the source document, the timestamp, the operator or pipeline that ran the extraction, a verbatim quote from the source, and a confidence score. It returns an Optional[ProvenanceEntry] (ProvenanceEntry on success, or None if storage fails on a brand-new entity) with a SHA-256 checksum computed automatically.
track_entity() again on the same entity_id automatically archives the NVD entry as a history record and creates a new current entry linked to it via parent_entity_id:
Tracking multi-source property values
When the same property appears in multiple sources with different values — exactly the CVE score situation — usetrack_property_source() to record each attribution separately. This feeds directly into conflict detection downstream: the conflict module can compare all tracked values for a property and surface disagreements with full source metadata attached.
SourceReference is a structured metadata container that captures exactly where a piece of information came from within a document. It includes the document identifier, specific location (page, section, byte range), confidence level, and custom metadata fields for domain-specific attribution requirements.
commercial_feed_2024-04-12, section cvss_assessment, confidence 0.91, with full metadata showing it was a commercial publisher that reported observed exploitation.
Tracing the lineage of a node
Once you have multiple provenance entries for an entity, you can trace its complete history to understand how it evolved over time. Six months after ingestion, run a lineage trace.get_lineage() returns the full version chain — every state the entity has passed through, oldest to newest — along with summary metadata:
commercial_feed_2024-04-12. The operator was threat_ingest_pipeline_v2. The score has changed — NVD updated their record on July 18 — and the chain shows exactly when.
Verifying integrity
EveryProvenanceEntry carries a SHA-256 checksum computed at write time. If any field is modified after the fact — by a misconfigured pipeline, a database migration, or deliberate tampering — the checksum will not match on recomputation.
Integrity verification is critical for regulatory compliance and forensic analysis. Run integrity checks as part of any compliance audit:
TAMPERED status means the stored hash does not match what would be computed from the current field values — evidence of post-write modification that must be investigated before the record is used for compliance purposes.
Tracking document chunks and their children
Provenance is not just for entities. When a document is split into chunks for retrieval-augmented generation (RAG) or natural language processing workflows, each chunk needs its own provenance record linking it to the source file and byte range. Child chunks (from recursive splitting) link to their parent viaparent_chunk_id, which maps to prov:wasDerivedFrom in the W3C PROV-O standard:
Statistics across the provenance store
After a large ingestion run,get_statistics() gives a summary of everything tracked:
Common Pitfalls
Provenance does not guarantee truth. Provenance records faithfully track where information came from and how it was processed, but it cannot verify that the original sources were accurate. A perfectly documented chain from a flawed or malicious source still produces unreliable data. Reusing generic source identifiers. Using non-specific source IDs like “daily_feed” or “batch_001” makes it impossible to trace individual records back to their exact origins. Always include timestamps, version numbers, or unique batch identifiers in source document names. Bypassing provenance workflows. Manually inserting data or using ad-hoc scripts that skiptrack_entity() calls creates gaps in the audit trail. Ensure all data entry points—automated pipelines, manual corrections, and administrative operations—record appropriate provenance.
Ignoring lineage verification. Provenance chains can become complex in multi-stage processing pipelines. Regularly verify that get_lineage() and trace_lineage() return complete, logical chains without missing links or circular references.
Overusing provenance in low-value scenarios. Recording provenance for every intermediate calculation or temporary variable creates storage overhead without compliance benefit. Focus provenance tracking on entities, relationships, and properties that have legal, regulatory, or business significance.
Failing to validate integrity checksums. Cryptographic integrity verification only works if you actually check it. Include regular compute_checksum() validation in audit workflows and incident response procedures.
Mixing provenance granularities. Tracking some entities at the document level and others at the sentence level creates inconsistent audit trails. Establish consistent granularity standards for each data type and processing workflow.
Domain examples
- Defense — CTI/Threat
- Security — SOC/Incident
- Life Science — Clinical/Pharma
- Banking — Risk/Compliance
A signals intelligence fusion cell tracks custody of every intelligence entity from raw collection through analytic processing to finished product. Each tier of the chain — raw collection, NER extraction, fusion, and finished intelligence — must be recorded separately with the appropriate classification handling and operator identity. The provenance chain is the chain of custody: it proves that a finished intelligence product is traceable to authorized collection and authorized analysis at every step.Under ITAR and intelligence community sharing agreements, the provenance record must show which collection method produced the raw data, which analyst processed it, and which fusion activity combined it with other intelligence before the entity reached the finished product.
track_chunk(), track_entity(), and track_relationship() each correspond to one tier of that chain.The W3C PROV-O mapping
EveryProvenanceEntry maps directly to W3C PROV-O terms. If your compliance team or a regulator requires a PROV-O export, the field mapping is one-to-one:
previous_version_id and derived_from_id are additive alongside parent_entity_id — existing code reading parent_entity_id keeps working unchanged, while new code gets the two relations disambiguated.
The checksum field is not part of the PROV-O standard — it is Semantica’s tamper-detection extension. Every entry’s SHA-256 now also incorporates previous_checksum (the prior entry’s checksum, by insertion order via sequence_id), chaining every entry to the one before it. ProvenanceManager.verify_chain() walks the full chain and reports any break — including a row that was hard-deleted from the underlying table, which a lone per-row checksum can’t detect on its own.
Note: the banking example above passes agent_id="credit_data_service_v2" to track_entities_batch() — this now actually populates the entry’s agent_id field (previously a bug caused batch-level typed kwargs like agent_id/entity_type/activity_id to be silently absorbed into the opaque metadata blob instead).
export_prov() mints entity/agent/activity URIs under ProvenanceManager.DEFAULT_BASE_URI (https://semantica.dev/ns# by default — the same namespace RDFExporter’s NamespaceManager uses for its "semantica" prefix, so KG-exported and PROV-exported URIs for the same entity_id co-resolve) unless overridden via export_prov(base_uri=...) or the CLI’s --base-uri option.
Related Guides
- Semantic Extraction — the NER and relation extraction pipeline that auto-generates provenance entries for every extracted entity
- Conflict Resolution — provenance property sources feed directly into conflict detection; every resolved value is traceable to its source
- Deduplication — merge operations are recorded in merge history; pair with provenance for a complete lineage from source to canonical entity
- Provenance Reference — full storage backend API,
InMemoryStorage,SQLiteStorage, andProvenanceEntryschema
