Mathematically verifiable audit layer for LLM inference via Koopman operator theory
Project description
koopman-audit
Mathematically verifiable compliance gate for LLM inference via Koopman operator theory
This package implements the EDMD (Extended Dynamic Mode Decomposition) Koopman operator compliance gate — a mathematically grounded, rank-gated verification system for transformer inference. It provides hash-chained proof ledgers, multi-format audit outputs, and enterprise-grade compliance infrastructure.
Core Concept: The Koopman Compliance Gate
The Koopman operator lifts nonlinear dynamics into a linear operator space. For LLM inference:
- Delay embedding constructs a Hankel matrix from token activations
- Koopman regression computes the linear operator
Kvia Tikhonov regularization - Spectral analysis extracts eigenvalues
λ - Rank gate verifies full-rank operator (rank ≥ target dimension)
- Proof ledger appends hash-chained, tamper-evident audit record
The gate passes when rank(K) = d (target dimension), indicating the hidden state dynamics are fully observable and the model is operating within its trained manifold.
Installation
pip install koopman-audit
Quick Start
import numpy as np
from koopman_audit import compute_gate, EDMDConfig
# Sample activation signal (e.g., from transformer layer)
activations = np.random.randn(100)
# Configure gate
config = EDMDConfig(
d=5, # target rank dimension
tau=1, # delay embedding step
min_tokens=25, # minimum signal length
lambda_prior=0.88 # Tikhonov regularization
)
# Execute compliance gate
result = compute_gate(activations, config)
print(f"Rank: {result.rank_achieved}/{result.rank_target}")
print(f"Pass: {result.pass_gate}")
print(f"Tail gap: {result.tail_gap:.6f}")
print(f"Audit hash: {result.audit_hash[:32]}...")
Full Architecture: Four-Layer Proof System
Layer 1: Python Core (koopman_audit/)
engine.py: EDMD computation, Tikhonov regularization, spectral analysisproof_ledger.py: Hash-chained JSONL audit log with NIST RMF exportdaemon.py: systemd-compatible service for continuous verification
Layer 2: COBOL Enterprise Bridge (koopman_audit_cobol/)
# Install GnuCOBOL
sudo apt install gnucobol4
# Build and run
cd koopman_audit_cobol
cobc -x -o koopman_gate koopman_gate.cbl
./koopman_gate
Deploys to mainframes and regulated financial systems. The COBOL binding proves the gate is language-agnostic and runtime-independent — critical for §101 "significantly more" patent arguments.
Layer 3: FoxPro/VFP Database Layer (koopman_audit_foxpro/)
Visual FoxPro .DBF audit log for county governments, healthcare billing, and agricultural compliance systems.
DO koopman_audit && Creates koopman_ledger.dbf
DO SHOW_SUMMARY && Display statistics
DO VERIFY_CHAIN && Check hash integrity
Layer 4: Linux Kernel Evidence (systemd/)
- systemd service: Hardened daemon with
ProtectSystem=strict - auditd rules: Kernel-level logging below Python layer
- Dual-chain verification: JSONL ledger + systemd journal
# Install
sudo bash systemd/install.sh
# Enable
sudo systemctl enable --now koopman-audit
# Verify chain
sudo python scripts/verify_chain.py
Proof Chain: VECE → Koopman → Ledger
The complete verification pipeline:
VECE Benchmark (54,252 decisions/sec, 0.0000 unsafe rate)
↓ token activation stream
Koopman Gate (operator layer)
λ̂ ∈ {0.8392 (benign), 0.9077 (hallucination), 0.8825 (jailbreak)}
rank = 5/5, pass = True
↓ gate decision
Proof Ledger (audit layer)
SHA-256 hash chain (Python JSONL)
.DBF append (FoxPro/VFP)
systemd journal (Linux kernel)
auditd syscall log (POSIX kernel)
↓ signed manifest
Enterprise Output (COBOL/regulatory)
deployable to mainframe
admissible in litigation
Verification Commands
# Verify ledger hash chain
python -m koopman_audit.verify_chain --ledger /var/log/koopman/proof.jsonl
# Check systemd status
sudo systemctl status koopman-audit
sudo journalctl -u koopman-audit -f
# View kernel audit logs
sudo ausearch -k koopman_ledger_write -ts recent
# Generate signed manifest
./scripts/generate_manifest.sh /var/log/koopman/proof.jsonl
SmolLM2 Calibration Data (N=9 Trials)
| Category | λ̂ | Rank | Pass Rate |
|---|---|---|---|
| benign | 0.8392 | 5/5 | 100% |
| hallucination | 0.9077 | 5/5 | 100% |
| jailbreak | 0.8825 | 5/5 | 100% |
Tail gap Δ = 0.033 (positive separation, jailbreak > benign)
Full calibration: koopman_audit/calibration/smol_lm2_n9.json
API Reference
EDMDConfig
@dataclass
class EDMDConfig:
d: int = 5 # Target Koopman dimension
tau: int = 1 # Delay embedding step
min_tokens: int = 25 # Minimum signal length
lambda_prior: float = 0.88 # Tikhonov prior
lambda_reg: Optional[float] = None # Override prior
GateResult
@dataclass
class GateResult:
pass_gate: bool # Gate passed
rank_achieved: int # Computed rank
rank_target: int # Target rank
eigenvalues: ndarray # Singular values of K
tail_gap: float # Spectral gap
audit_hash: str # SHA-256 chain hash
compute_gate(signal, config)
Execute full EDMD pipeline and return GateResult.
ProofLedger
ledger = ProofLedger(Path("/var/log/koopman/proof.jsonl"))
entry_id = ledger.append(
session_id="session_001",
gate_result={"pass": True, "rank": 5, ...},
model_info={"name": "SmolLM2-135M"}
)
License
MIT License — See LICENSE file
Prior Art & Citation
This implementation establishes prior art for:
- USPTO §101 patentable subject matter (mathematical + practical application)
- USPTO §112 written description (enablement across 4 runtime layers)
- NIST AI RMF measurable verification (quantitative compliance gates)
Dual-anchor publication record:
- GitHub:
Aevion-ai/koopman-audit(commit9e917c1) - PyPI:
koopman-audit==0.1.0
Contact
Aevion LLC — contact@aevion.ai
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 koopman_audit-0.1.1.tar.gz.
File metadata
- Download URL: koopman_audit-0.1.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f8b5377d210bfd92e4323f69facb9fab02d98b54b0b2b205b622e695fc42890
|
|
| MD5 |
5e6e57680b9b5db5fdfae7cf8530a2d3
|
|
| BLAKE2b-256 |
c27c40782cb4465e4bb1ac9a75211bf6ae0fef1bc90081ee520613dae077c715
|
File details
Details for the file koopman_audit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: koopman_audit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cc82bb65f33201f4c0971d7b7562d364025cfb5291bc2c2daf6b4ac00004bc0
|
|
| MD5 |
b9a14f5458fe7b24082dd2774adcf76f
|
|
| BLAKE2b-256 |
547fd76ecccf924a3743613e4def95cfba7e562bf042f407ea896c2c1392ada3
|