Sovereign Security Stack
LYDOS ships 13 sovereign security engines as first-class platform components. They form an interlocking trust chain from hardware root of trust through key sovereignty, quorum consensus, settlement, and global collective intelligence. All 174 sovereign tests are green on every release.
Overview
The sovereign stack follows a layered composition model. Each engine extends the engines below it โ no parallel re-implementation is permitted. A new engine must integrate with the existing DPI/DEC/AAE/NNE/LSSA/FIN/KSL/LSIA/GCI layers and document its integration matrix before merging.
All engines require a live PostgreSQL connection at LYDOS_PG_DSN (port 5434). Silent SQLite fallback is explicitly prohibited โ if the DSN is absent the engine fails hard. This is by design.
Integration Chain
Hardware Root of Trust (LocalSec + DPI-H)
|
+--> Enclave Attestation (CC โ SGX/SEV seal)
|
+--> Key Hierarchy (DPI-H: root -> intermediate -> node)
|
+--> Key Sovereignty (KSL: client-only privkey, device-bound JWT)
|
+--> Multi-Node Quorum (DPI: 2/3 BFT consensus)
| |
| +--> State Consistency (GCE: drift detection + isolation)
|
+--> 10-Layer Security (LSSA: HW root to trust graph)
|
+--> Financial Ledger (FIN: double-entry + per-tx proof)
|
+--> Settlement (DSL: signed + approved + proven = settled)
|
+--> Threat Response (ASR: behavioral detection + quarantine)
|
+--> Global Intelligence (GCI: privacy-first pattern consensus)
|
+--> Immunity Override (LSIA: OPERATIONAL/DEGRADED/SAFE/LOCKDOWN)
|
+--> Trusted Deployment (TUP: sig + hash + role quorum)Engine Reference
Each engine below lists its source file, API route prefix, number of PostgreSQL tables, and its key invariant.
Multi-node Byzantine-fault-tolerant quorum consensus. Every critical decision requires 2/3 quorum across registered nodes. All quorum events are hash-chained.
decentralized_protocol.py/api/dpi/*10-layer security stack from hardware root of trust through the full trust graph. Each layer attests the layer above it. Compromise of one layer triggers isolation of dependent layers.
lssa.py/api/lssa/*Private keys never leave the client device. The server only ever sees public keys and signed challenges. Device-bound JWT tokens bind identity to IP+UA hash. Critical operations require KSL device signature.
ksl.py/api/ksl/*All production deployments require a TUP manifest: release key signature + role-diverse quorum (security + ops) + binary hash match. Unsigned or hash-mismatched artifacts are rejected at the gate.
tup.py/api/tup/*Cross-node state synchronization with automatic drift detection. Nodes that diverge beyond the threshold are marked DEGRADED and excluded from quorum until re-synced.
gce.py/api/gce/*Behavioral threat detection with autonomous response. Evidence is hash-chained and immutable. Response actions: MONITOR, THROTTLE, QUARANTINE. No offensive counter-attack โ white-hat only.
asr.py/api/asr/*Atomic transaction settlement with the invariant: signed + approved + proven = settled. No alternative paths exist. Failed settlement rolls back atomically โ no partial state.
dsl.py/api/settlement/*System-wide veto and sacrifice authority. Four immunity modes: OPERATIONAL, DEGRADED, SAFE_MODE, CRITICAL_LOCKDOWN. In CRITICAL_LOCKDOWN, LSIA vetoes all AAE/DEC/FIN/DSL operations โ this override cannot be bypassed.
immunity_engine.py/api/immunity/*Privacy-preserving pattern consensus across nodes. Only hashed patterns, /24 IP prefixes, and amount buckets are shared โ never raw email, IP, user_id, or payload. One node's detection becomes every node's defense.
global_brain.py/api/gci/*On-device node runtime with device-bound JWT, signed artifact verification, and offline trust anchors. Operates without network access and maintains local trust state independently.
local_security.py/api/local-security/*Root-to-intermediate-to-node key hierarchy enforcement for DPI nodes. Validates the full certificate chain on every node registration and quorum participation attempt.
dpi_hardening.py/api/dpi/hardening/*SGX/SEV enclave attestation and secret sealing. Secrets are sealed to the enclave measurement โ they can only be unsealed by code with an identical measurement. Supports remote attestation verification.
confidential_compute.py/api/cc/*Double-entry accounting ledger with per-transaction cryptographic proof. Every debit has a matching credit. Ledger entries are immutable โ corrections are made via reversal entries with audit trail.
financial_infra.py/api/{ledger,finance}/*Critical-action approval gate. Four risk tiers (low/medium/high/critical) โ quorum + role-diverse vote ledger. LSIA should_veto runs at request time (KURAL 22). KSL signature mandatory for high/critical. Insert-event hash chain proves order + inputs immutably; status transitions live on the row but never rewrite the chain. Workers must call check_approved_or_raise() before applying side effects.
approval_workflow.py/control/governance/approvals/*Per-region rolling 60s health beacon โ p50/p95/p99/error_rate/RPS sampled from every request via outermost middleware. Background task persists every 15s. Drives Q229 multi-region routing decisions and failover chains: a region is unavailable when error_rate โฅ 5% or p95 โฅ 1s. Aggregated into the unified /control/infra panel (registry + live + traffic + immunity mode).
region_heartbeat.py/control/infra/*API Usage Examples
DPI โ Quorum status
# Check quorum node health
curl -s http://localhost:8888/api/dpi/nodes \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
# Submit a decision for quorum vote
curl -s -X POST http://localhost:8888/api/dpi/decisions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"decision_type": "policy_change", "payload": {...}, "require_quorum": true}' \
| python3 -m json.toolKSL โ Device-bound authentication
# Register a device (generates device_id bound to hardware fingerprint)
curl -s -X POST http://localhost:8888/api/ksl/devices/register \
-H "Content-Type: application/json" \
-d '{"public_key": "<base64-encoded-pubkey>", "device_fingerprint": "<fp>"}' \
| python3 -m json.tool
# Sign a critical operation challenge
curl -s -X POST http://localhost:8888/api/ksl/sign \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"operation": "payment_initiate", "challenge": "<server-challenge>", "signature": "<device-sig>"}' \
| python3 -m json.toolLSIA โ Immunity mode
# Check current immunity mode
curl -s http://localhost:8888/api/immunity/status \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
# Example response:
# {
# "mode": "OPERATIONAL",
# "veto_active": false,
# "quarantined_nodes": [],
# "last_mode_change": "2026-04-21T08:00:00Z"
# }
# In CRITICAL_LOCKDOWN all AAE/DEC/FIN/DSL calls return:
# { "error": "lsia:lockdown_veto", "mode": "CRITICAL_LOCKDOWN" }ASR โ Threat detection
# List active threats
curl -s http://localhost:8888/api/asr/threats \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
# Get hash-chained audit decision log
curl -s http://localhost:8888/api/asr/decisions \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
# Example decision entry:
# {
# "id": "dec_0042",
# "action": "QUARANTINE",
# "target": "node_x7",
# "evidence_hash": "sha256:9b2c...",
# "prev_hash": "sha256:3f4a...",
# "timestamp": "2026-04-21T09:45:00Z"
# }TUP โ Deployment verification
# Verify a deployment manifest before apply
curl -s -X POST http://localhost:8888/api/tup/verify \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"manifest_url": "https://releases.example.com/v12.3.0/manifest.json",
"release_signature": "<sig>",
"binary_hash": "sha256:<hash>"
}' | python3 -m json.tool
# Response if valid:
# { "verified": true, "quorum_approved": true, "hash_match": true }
# Response if invalid:
# { "verified": false, "reason": "hash_mismatch" }PostgreSQL Tables Overview
The sovereign stack creates 76+ tables across the federation database. All migrations are version-controlled in scripts/migrations/ and are applied in dependency order.
| Engine | Key Tables | Migration File |
|---|---|---|
| DPI | dpi_nodes, dpi_decisions, dpi_audit_chain | 001_decentralized_protocol.sql |
| LocalSec | local_security_devices, ls_trust_anchors | 002_local_security.sql |
| DPI-H | dpi_key_hierarchy, dpi_certificates | 003_dpi_hardening.sql |
| CC | cc_enclaves, cc_measurements, cc_sealed_secrets | 004_confidential_compute.sql |
| FIN | fin_ledger, fin_accounts, fin_transactions, fin_proofs | 005_financial_infra.sql |
| LSSA | lssa_layers, lssa_attestations, lssa_trust_graph | 006_lssa.sql |
| ASR | asr_threats, asr_decisions, asr_evidence_chain | 008_asr.sql |
| DSL | dsl_settlements, dsl_settlement_proofs | 009_dsl.sql |
| LSIA | lsia_mode_log, lsia_quarantine, lsia_veto_log | 010_lsia.sql |
| GCI | gci_patterns, gci_consensus, gci_node_reports | 011_gci.sql |
| Governance | governance_approvals, governance_approval_votes, region_heartbeats, region_health_latest (view) | 2026_04_25_global_governance.sql |
python3 -m pytest tests/test_decentralized_protocol.py tests/test_local_security.py tests/test_dpi_hardening.py tests/test_confidential_compute.py tests/test_financial_infra.py tests/test_lssa.py tests/test_sovereign_v2_asr_dsl.py tests/test_lsia_gci.py -vโ 174 tests, ~22s on a live PG connection.