How to Implement Decision Intelligence with Traceable, Auditable AI Decisions in Semantica
Semantica enables decision intelligence by linking LLM-generated rationales to immutable provenance records and vector embeddings, creating a fully auditable trail for every AI decision.
Semantica is a modular framework for building knowledge-driven AI pipelines that combine large language model reasoning with graph-based knowledge representation. To implement decision intelligence with traceable, auditable AI decisions, the framework weaves together provenance tracking, vector storage, and cryptographic integrity guarantees.
The Architecture of Auditable Decision Intelligence
Semantica implements decision intelligence through three interconnected subsystems that ensure every AI decision is recorded, searchable, and tamper-evident.
Provenance and Auditing
The provenance subsystem captures immutable metadata for every operation. Located in semantica/provenance/manager.py, this module stores decision records, timestamps, and execution graphs. Cryptographic integrity is enforced via semantica/provenance/integrity.py, which generates hashes that guarantee tamper-evidence for all decision records.
Decision Vector Store
Decisions persist as high-dimensional embeddings alongside their semantic payload in the decision vector store. The decision_vector_methods.py API provides methods like quick_decision, find_precedents, explain, and similar_to that write to any configured vector backend located in semantica/vector_store/*.py. Decision records link to provenance IDs through record_decision in semantica/context/decision_context.py.
LLM-Powered Reasoning
The reasoning layer generates decision content using modules such as semantica/reasoning/reasoner.py and semantica/reasoning/explanation_generator.py. These components produce human-readable rationales that the system stores together with vector embeddings, ensuring that every decision carries its full reasoning context.
The Decision Recording Workflow
Understanding the execution flow reveals how traceability is maintained from invocation to audit.
When an application calls quick_decision(scenario, outcome, reasoning, …) from semantica/vector_store/decision_vector_methods.py, the system executes the following pipeline:
-
Reasoning Phase: The input forwards to the LLM reasoner, which may query the knowledge graph via
semantica/reasoning/graph_reasoner.pyto enrich the answer. -
Provenance Capture: Before persisting, the manager creates a decision provenance record in
semantica/provenance/manager.py. This record includes a UUID, raw LLM output, vector-store ID, execution timestamps, and a cryptographic hash ensuring integrity. -
Embedding and Storage: The decision text embeds via the configured vector backend—such as Pinecone, Qdrant, or local FAISS—and stores through
semantica/vector_store/decision_vector_methods.py. The vector entry maintains a reference to the provenance ID. -
Retrieval and Auditing: Consumers query precedents using
find_precedentsor request explanations viaexplain. The system traces from the vector entry back to the provenance record, delivering a complete audit trail.
Implementing Traceable Decisions: Code Examples
Recording a Decision
Use the quick_decision function to capture a decision with full provenance:
from semantica.vector_store.decision_vector_methods import quick_decision
decision_id = quick_decision(
scenario="Approve loan for applicant X",
outcome="approved",
reasoning="Credit score > 750, income stable, debt‑to‑income < 30%",
metadata={"applicant_id": "X123", "loan_amount": 150000},
)
print(f"Decision recorded with ID: {decision_id}")
This call automatically embeds the decision text, stores the embedding in the configured vector store, and creates a provenance entry in semantica/provenance/manager.py.
Finding Similar Past Decisions
Retrieve precedents using vector similarity search:
from semantica.vector_store.decision_vector_methods import find_precedents
precedents = find_precedents(
query="loan approval with high credit score",
limit=5,
filter={"outcome": "approved"},
)
for p in precedents:
print(p["decision_id"], p["scenario"], p["metadata"]["loan_amount"])
The find_precedents function executes a vector similarity search through semantica/vector_store/hybrid_search.py and resolves each hit to its corresponding provenance record.
Auditing Decisions with Explanations
Extract the full audit trail and reasoning for any decision:
from semantica.vector_store.decision_vector_methods import explain
explanation = explain(decision_id="123e4567-e89b-12d3-a456-426614174000")
print("Decision provenance:")
print(explanation["provenance"])
print("\nLLM reasoning:")
print(explanation["reasoning"])
The explain function retrieves the provenance object from semantica/provenance/manager.py and returns the original LLM reasoning alongside the immutable audit trail.
Configuring Vector Store Backends
Switch between local and remote storage by setting the global vector store:
from semantica.vector_store.decision_vector_methods import set_global_vector_store
from semantica.vector_store.pinecone_store import PineconeVectorStore
store = PineconeVectorStore(
api_key="YOUR-PINECONE-KEY",
environment="us-west1-gcp",
index_name="semantica-decisions",
)
set_global_vector_store(store)
All subsequent calls to quick_decision and find_precedents transparently use the new backend.
Summary
- Provenance tracking in
semantica/provenance/manager.pycreates immutable, cryptographically hashed records for every decision. - Vector storage via
decision_vector_methods.pyembeds decisions for similarity search while maintaining links to provenance IDs. - LLM reasoning modules generate human-readable rationales that persist alongside embeddings for complete context.
- Auditability is guaranteed through cryptographic integrity checks and the ability to trace any vector entry back to its original provenance record.
Frequently Asked Questions
How does Semantica ensure decision records cannot be tampered with?
Semantica uses cryptographic hashing implemented in semantica/provenance/integrity.py to generate tamper-evident signatures for every provenance record stored in semantica/provenance/manager.py. Any modification to a decision record would invalidate its hash, making unauthorized alterations immediately detectable during audit operations.
Can I use Semantica with my existing vector database?
Yes. The framework supports multiple backends including Pinecone, Qdrant, and local FAISS through the registry in semantica/vector_store/registry.py. You can configure any supported backend using set_global_vector_store() from semantica/vector_store/decision_vector_methods.py, and all decision operations will transparently use your chosen storage layer.
What information is captured in a decision provenance record?
Each provenance record contains a unique UUID, the raw LLM output, the corresponding vector-store ID, execution timestamps, and a cryptographic hash. This metadata is created by the provenance manager before storage and linked to the vector embedding via record_decision in semantica/context/decision_context.py.
How do I retrieve the reasoning behind a specific AI decision?
Use the explain() function from semantica/vector_store/decision_vector_methods.py, passing the decision UUID. This retrieves the provenance object from semantica/provenance/manager.py and returns both the immutable audit trail and the original LLM reasoning generated by semantica/reasoning/explanation_generator.py.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →