Local-first RAG with policy gating and audit-friendly logging — reference implementation
Project description
🛰️ Sovereign AI Stack (Research Preview)
Exploring Deterministic RAG Verification & Forensic Accountability.
[!WARNING] Experimental Alpha: This is a research prototype, not a production-grade security system. It is designed to explore Natural Language Inference (NLI) as a grounding mechanism and Ed25519 signatures for audit integrity. It has not undergone external security audits.
🔬 The Concept
The Sovereign AI Stack is a technical exploration into "Verify then Trust" architectures for local AI. Instead of relying on generative LLM judges—which are slow and prone to their own hallucinations—this stack tests a deterministic pipeline using NLI Cross-Encoders.
Key Hypotheses
- Efficiency: A specialized NLI model (DeBERTa-v3) can verify grounding in 80ms, compared to 2000ms+ for a generative judge.
- Determinism: Cross-encoders provide a repeatable entailment score rather than a generative "grade."
- Accountability: Asymmetric cryptography (Ed25519) can provide non-repudiable audit trails even in local-first environments.
🛠️ Components
- Verify (NLI Gate): An experimental gate that blocks responses if the NLI entailment score between the answer and sources falls below a threshold (default 0.85).
- Audit (Signed Chain): Every decision is cryptographically signed using Ed25519 and linked into a SHA-256 hash chain.
- Govern (ABAC): A simple Attribute-Based Access Control engine to gate retrieval by role and classification.
🚀 Quick Start (Alpha)
1. Install
pip install sovereign-ai-stack==0.1.0a1
2. Basic Usage
from sovereign_ai import SovereignPipeline
# Initializing with default NLI model (deberta-v3-base)
pipeline = SovereignPipeline(tenant_id="research_test")
# Run a governed query
result = pipeline.query("What is the protocol?", role="analyst")
print(f"Verified Answer: {result['answer']}")
print(f"Grounding Score: {result['verification']['score']}")
⚠️ Known Limitations & Experimental Status
- Model Specificity: The default NLI model is trained on general entailment; domain-specific grounding (medical/legal) may require fine-tuning.
- Hardware Binding: While the system uses the OS Keyring, true hardware-level attestation (TPM 2.0) is a roadmap item.
- Security Review: This codebase is for research purposes. Do not use it to secure sensitive production data without a comprehensive security review.
- Adversarial Robustness: We are actively seeking feedback on adversarial prompts that might bypass the NLI gate.
🤝 Contributing & Feedback
This is an open technical exploration. We value "Brutal Feedback" on the architecture, the cryptographic implementation, and the NLI thresholding logic.
- Issues: Report bugs or architectural flaws.
- Discussions: Suggest better verification models or faster forensic methods.
📜 License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sovereign_ai_stack-1.1.0a1.tar.gz.
File metadata
- Download URL: sovereign_ai_stack-1.1.0a1.tar.gz
- Upload date:
- Size: 119.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b4425b6f8c8949ff780591ef8b0683df2fbb981ee3e7b094d5ff12fd620c03
|
|
| MD5 |
72a5cadca88d3ea59fed637dc5e22395
|
|
| BLAKE2b-256 |
485ddab6f2ce18cbe3ba254ab9e039aba286016a81d2f60098bc1f213abe5668
|
File details
Details for the file sovereign_ai_stack-1.1.0a1-py3-none-any.whl.
File metadata
- Download URL: sovereign_ai_stack-1.1.0a1-py3-none-any.whl
- Upload date:
- Size: 139.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81e753eb08c0ea23cf537be5fb1d9ccb4a0248b82bd6d078920091b3d81334a2
|
|
| MD5 |
d4a7541be3cc7e64aafd680e832bc1ad
|
|
| BLAKE2b-256 |
7196723be5b69e700a3df8101cc9bdf115df5b2f2db7c2a4f120ea4c05f400d8
|