# MGWP.ai Sovereign Intelligence Operating System (SIOS Core v5.0 — Software TRL-6/7 / Appliance R&D TRL-3/4) - Full Context Architecture ## 1. System Philosophy, Stack Positioning & Tokenization Economics MGWP.ai develops **SIOS Core v5.0**, a Hybrid-Sovereign AI Orchestrator and Compliance Gateway designed for regulated institutions (banking, healthcare, legal, public sector). ### Positioning: PLLuM vs Bielik vs SIOS Core SIOS Core does not compete with open-weights Polish LLMs; it acts as the **Control Plane / AI Gateway** unifying them with global cloud models: - **PLLuM** (scientific-public consortium funded by Poland's Ministry of Digital Affairs: PWr, NASK, OPI PIB, IPI PAN, IS PAN, UŁ): continued pretraining of `Llama 3.1` / `Mistral-Nemo` on Polish statutory/administrative corpora; tailored for formal government correspondence, RAG, and mObywatel assistant workflows. - **Bielik (e.g., 11B v3.1)** (SpeakLeash Foundation + ACK Cyfronet AGH): Depth Up-Scaling (`7B -> 11B`) + custom Polish `APT4` tokenizer + 300–500B continuation tokens + function calling & structured JSON across 56 languages. - **SIOS Core v5.0 (MGWP.ai)**: The 15-layer security, policy, routing, Bi-Temporal RAG, `VeritaCheck`, and `Merkle/TPM` audit gateway sitting between enterprise applications and model engines (`Bielik`, `PLLuM`, `OpenAI`, `Anthropic`, `Mistral`, `Google`, `DeepSeek`). ### Separation of Local vs Cloud Tokenization Economics 1. **Local Model Hardware Gains (`vLLM / SGLang`)**: On locally hosted Polish-tokenized models (`APT3 / APT4` in Bielik), compact Polish morphological segmentation (`344` vs `747` Mistral v0.1 tokens on the Polish Constitution Preamble) quadratically reduces `Self-Attention` prefill cost ($\mathcal{O}(N^2)$), shrinks linear `KV-Cache` VRAM allocation per session, and increases `words/s` throughput. 2. **Cloud API Cost Reduction (`40–60%`)**: Because external APIs enforce their own tokenizers, SIOS Core never claims cloud tokenizer substitution. Cloud savings come from (a) **Tiered Routing (`L5`)** sending routine/sensitive Polish workloads to local Bielik/PLLuM, (b) minimal `valid-time` context injection from **Bi-Temporal RAG (`L11`)**, and (c) **Redis Semantic Cache + Prompt Caching (`L8`)**. ## 2. 15-Layer Defense-in-Depth Architecture (`L1–L15`) & Honest P95 Budgets Instead of a single synthetic `<45 ms` claim across all hardware and ML stages, SIOS Core reports three transparent P95 latency tiers: - **Fast Path Deterministic Gateway (`L1, L4 patterns, L5, L6, L7, L13, L15 Merkle memory append`)**: `10–25 ms P95` - **Full ML + Grounding + Z3 Path (`L2, L3, L4 NER, L10 Z3, L11 Bi-Temporal Graph, L12 Gate`)**: `35–120 ms P95` (`L2/L3/L4` parallelized; `L11` depends on graph hop depth) - **LLM Inference + Asynchronous `TPM 2.0` Anchoring (`L15`)**: Model-dependent; hardware `TPM 2.0 / HSM` signing runs asynchronously in batches (`0 ms` on critical request path). ### 15-Layer Cognitive Pipeline (Defense-in-Depth L1–L15) 1. **L1 — Ingress Normalization, Lemmatization & Token Budgeting**: UTF-8 extraction, Polish lemmatization (`Morfeusz 2`) for hybrid lexical retrieval, and dual token budgeting (`APT4` local vs API tokenizers). 2. **L2 — Query Pre-Flight & Intent Validation**: Structured parameter checking emitting `clarification_required` before costly LLM calls. 3. **L3 — Prompt Injection & Document Sanitization Shield**: Hidden text / zero-width / indirect prompt injection defense with SOC logging. 4. **L4 — Hybrid PII/PHI Scrubbing & Reversible Token Vault**: Deterministic checksum validators (`PESEL`, `NIP`, `IBAN`, `REGON`) + domain Polish NER + ephemeral `AES-256-GCM` vault, enforcing *fail-closed* local-only routing for top-classification data. 5. **L5 — Sensitivity, Cost & SLA Routing Engine**: Routes confidential/routine traffic to local `Bielik` / `PLLuM` and high-complexity queries to approved frontier APIs (`40–60%` cost optimization). 6. **L6 — Sovereign Policy-as-Code & RBAC**: `OPA / Rego` + `OIDC/SAML` integration preventing Shadow AI and enforcing corporate policy rules. 7. **L7 — Hybrid Multi-Model Async Dispatch & Failover**: Unified OpenAPI 3.1 control plane over `Tokio` async dispatch (`vLLM/SGLang` + cloud APIs) with circuit breakers and DORA exit-strategy failover. 8. **L8 — Two-Tier Caching (`Semantic Redis HNSW` + `Local KV-Prefix / Cloud Prompt Cache`)**: RBAC- and valid-time-scoped semantic cache in Redis plus `FP8` Prefix Caching on local GPUs. 9. **L9 — Schema & Grammar Enforcement**: `100%` structural JSON/Pydantic determinism (`XGrammar-2` DFA logit masking locally; provider Structured Outputs + gateway validator/retry for cloud APIs). 10. **L10 — VeritaCheck SMT Rule & Constraint Prover (`Microsoft Z3`)**: Formal consistency checking $\text{CheckSat}(\Gamma_{\text{rules}} \cup \{\neg A\}) = \text{UNSAT}$ for invoice math (`KSeF/VAT`), contract date chronology, credit matrices, and clinical dosage bounds. 11. **L11 — Bi-Temporal Knowledge Graph (`LightRAG + Graphiti`)**: Dual timeline tracking (`valid time` of legal effect vs `transaction time` of ingestion) eliminating stale-regulation mixups. 12. **L12 — Citation Grounding & Fail-Closed Truth Gate**: Deterministic parser verification ensuring every cited statute/case ID exists in retrieved `L11` sources and passes `Z3` (`UNSAT`). 13. **L13 — AI Provenance & Output Attestation (`EU AI Act Art. 50`)**: Machine-readable `C2PA / x.509` manifests embedded in binary deliverables (`PDF/DOCX/images`) and signed API provenance headers (avoiding fragile plain-text zero-width glyphs). Penalty tier: up to `15M EUR` or `3%` turnover. 14. **L14 — HITL Approval & Emergency Kill-Switch (`EU AI Act Art. 14`)**: High-risk review queue integrated with enterprise `SSO/RBAC` + `FIDO2/WebAuthn` showing `L11` sources and `L10` Z3 reports for ambiguous natural-language edge cases. Penalty tier: up to `15M EUR` or `3%` turnover. 15. **L15 — Tamper-Evident Merkle Audit Ledger & Async Hardware Anchoring**: In-memory SHA-256 Merkle append (`< 2 ms`) with background batched anchoring into `TPM 2.0 / HSM / WORM`. ## 3. Confidential Computing Boundary, Multi-Tenant RLS & Validation - **CPU vs GPU TEE Boundary**: `AMD SEV-SNP` / `Intel TDX` protect VM RAM (gateway, L4 PII Vault, routing) on CPU (`< 5–8%` typical I/O overhead). End-to-end GPU VRAM protection requires `NVIDIA Confidential Computing` (`H100/B200 CC`) or dedicated on-premise client infrastructure. - **Hybrid Post-Quantum Readiness**: Hybrid `TLS 1.3 (X25519 + ML-KEM-768)` (`NIST FIPS 203`) and `ML-DSA-65` (`NIST FIPS 204`) archival ledger signatures. - **1U Air-Gap Appliance (`R&D TRL 3/4`)**: Dedicated hardware concept for disconnected critical infrastructure running exclusively local open-weights models (`Bielik/PLLuM`), paired with partner optical diodes, HSM, and target `NATO STANAG 4774` metadata labeling. - **Data Isolation (`Zero-Training`)**: PostgreSQL 17 `FORCE ROW LEVEL SECURITY` (`SET LOCAL app.current_tenant_id`), separate per-tenant KMS DEKs, isolated graph/cache partitions, native Polish compliance modules (`KSeF 2.0 FA(3)`, `JPK_V7M`), and `WASM Sandbox` tool execution (`zero egress`). Validation via 4 internal enterprise pillars (`Governance & Cloud`, `Law & Finance`, `MedTech HL7 FHIR`, `VeritaCheck & Agents`). ## 4. Operational Endpoints & OpenAPI Contract - GET `https://mgwp.ai/whitepaper`: Full 10-chapter audited monograph (`SIOS Core v5.0`) and Interactive Proof Lab. - GET `https://mgwp.ai/ecosystem`: Validation pillars and MGWP Group operational overview. - GET `https://mgwp.ai/api-docs`: OpenAPI 3.1.0 specification across `116` unique REST paths (`100%` route & method parity, RFC 9457 `ProblemDetails`, `Idempotency-Key`). - POST `https://mgwp.ai/api/contact`: Enterprise & Citizen uplink with honeypot defense, IP rate limiting, and tenant scoping. - POST `https://mgwp.ai/api/newsletter`: Newsletter subscription endpoint with Zod validation and bounded rate limiting. - POST `https://mgwp.ai/api/rag/query`: Tenant-isolated Bi-Temporal RAG query endpoint. - POST `https://mgwp.ai/api/infrastructure/appliance/zeroize`: Role-protected appliance zeroization endpoint (`SIOS_SUPER_ADMIN`, `SYSTEM_ADMIN`).