Skip to main content

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

  1. Efficiency: A specialized NLI model (DeBERTa-v3) can verify grounding in 80ms, compared to 2000ms+ for a generative judge.
  2. Determinism: Cross-encoders provide a repeatable entailment score rather than a generative "grade."
  3. Accountability: Asymmetric cryptography (Ed25519) can provide non-repudiable audit trails even in local-first environments.

🛠️ Components

  1. 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).
  2. Audit (Signed Chain): Every decision is cryptographically signed using Ed25519 and linked into a SHA-256 hash chain.
  3. 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==1.1.0a2

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sovereign_ai_stack-1.1.0a2.tar.gz (119.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sovereign_ai_stack-1.1.0a2-py3-none-any.whl (139.0 kB view details)

Uploaded Python 3

File details

Details for the file sovereign_ai_stack-1.1.0a2.tar.gz.

File metadata

  • Download URL: sovereign_ai_stack-1.1.0a2.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

Hashes for sovereign_ai_stack-1.1.0a2.tar.gz
Algorithm Hash digest
SHA256 8416680d90c9669c4f8a91cb0794bfbbaff9ac007e8b369698cd27a7f0df0b88
MD5 f53e7cbc67d333ae3d11779f7db7727e
BLAKE2b-256 3ff888dc19d13f3bd4e3417ccfd307ba964f657a88b2a4ffc6ec9b17ec203add

See more details on using hashes here.

File details

Details for the file sovereign_ai_stack-1.1.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for sovereign_ai_stack-1.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 02d2617cefb41d5b89669b9b89b21b40faeb87925f33ce8b4f271a6a3216c9e9
MD5 29633d5f606364562251ee40940fb035
BLAKE2b-256 ad7e480077a1eeb62ad3b4d9ebcc4a90f9b983c241a82a17090b07b9b837ae8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page