MIZ OKI SRPVDAL Architecture Diagram

Version: 6.9.1 Last Updated: January 10, 2026

This document provides visual architecture diagrams showing how MIZ OKI's SRPVDAL (Sense-Reason-Decide-Act-Learn) pipeline operates.


1. High-Level SRPVDAL Flow

flowchart TB
    subgraph SENSE["SENSE Stage"]
        S1[/"Events (Web, App, Offline)"/]
        S2["Identity Resolution<br/>SHA256(email) → CrossPlatformID"]
        S3["KG Ingestion<br/>Firestore: kg_events"]
        S1 --> S2 --> S3
    end

    subgraph REASON["REASON Stage"]
        R1["KG Brain<br/>Neuro-Symbolic Fusion"]
        R2["CATE Estimation<br/>Uplift Score Calculation"]
        R3["MOA/MOE Ensemble<br/>4 Virtuoso Models"]
        S3 --> R1
        R1 --> R2
        R2 --> R3
    end

    subgraph DECIDE["DECIDE Stage"]
        D1["ΔROI Calculation<br/>E[revenue_lift] - cost"]
        D2{{"ReLU Gate<br/>ΔROI > 0?"}}
        D3["Guardrail Check<br/>Budget, Consent, Rate"]
        D4["Proposal Queue"]
        R3 --> D1
        D1 --> D2
        D2 -->|PASS| D3
        D2 -->|BLOCK| X1[/"Blocked: Negative ROI"/]
        D3 -->|PASS| D4
        D3 -->|FAIL| X2[/"Blocked: Guardrail"/]
    end

    subgraph ACT["ACT Stage"]
        A1["Idempotency Check<br/>SHA256(action:entity:hour)"]
        A2["Pre-State Capture<br/>Firestore: srpvdal_rollback_state"]
        A3["Platform API Call<br/>Google Ads / Meta / GA4"]
        A4["Post-State Capture"]
        D4 --> A1
        A1 -->|NEW| A2
        A1 -->|DUP| X3[/"Blocked: Duplicate"/]
        A2 --> A3
        A3 --> A4
    end

    subgraph LEARN["LEARN Stage"]
        L1["Outcome Observation<br/>Actual vs Predicted"]
        L2["Reconciliation<br/>Update CATE Models"]
        L3["Audit Log<br/>Firestore: srpvdal_audit_log"]
        L4{{"Performance OK?"}}
        A4 --> L1
        L1 --> L2
        L2 --> L3
        L2 --> L4
        L4 -->|NO| RB["Rollback<br/>platform_rollback_integration"]
        L4 -->|YES| DONE[/"Success"/]
    end

    style SENSE fill:#e1f5fe
    style REASON fill:#fff3e0
    style DECIDE fill:#f3e5f5
    style ACT fill:#e8f5e9
    style LEARN fill:#fce4ec

2. Guard Middleware Architecture

flowchart LR
    subgraph GUARDS["6 Guard Types"]
        G1["Consent Guard<br/>GDPR/CCPA Check"]
        G2["Budget Guard<br/>$50K/day, Per-user caps"]
        G3["Rate Limit Guard<br/>API quotas, User touches"]
        G4["Quality Guard<br/>Min confidence, Model freshness"]
        G5["Circuit Breaker<br/>ROAS < 0.8x → STOP"]
        G6["Geo Routing<br/>EU data residency"]
    end

    ACTION["Proposed Action"]

    ACTION --> G1
    G1 -->|PASS| G2
    G2 -->|PASS| G3
    G3 -->|PASS| G4
    G4 -->|PASS| G5
    G5 -->|PASS| G6
    G6 -->|PASS| EXEC["Execute"]

    G1 -->|FAIL| BLOCK1[/"Blocked"/]
    G2 -->|FAIL| BLOCK2[/"Blocked"/]
    G3 -->|FAIL| BLOCK3[/"Blocked"/]
    G4 -->|FAIL| BLOCK4[/"Blocked"/]
    G5 -->|OPEN| BLOCK5[/"Blocked"/]
    G6 -->|FAIL| BLOCK6[/"Blocked"/]

    style GUARDS fill:#fff9c4

3. ReLU Gate Formula

                    ┌─────────────────────────────────────────────────────────┐
                    │                    ReLU GATE                            │
                    │                                                         │
                    │   ΔROI = E[revenue_with_action] - E[revenue_without]   │
                    │          - incremental_cost                             │
                    │                                                         │
                    │   ┌─────────────────────────────────────┐               │
                    │   │  if ΔROI ≤ 0 → BLOCK (return 0)     │               │
                    │   │  if ΔROI > 0 AND guards_pass → ALLOW│               │
                    │   └─────────────────────────────────────┘               │
                    │                                                         │
                    │   Like neural network ReLU: max(0, x)                   │
                    │   Only positive-ROI actions propagate forward           │
                    └─────────────────────────────────────────────────────────┘

4. Cell Architecture (32 Specialized Cells)

flowchart TB
    subgraph BOSS["Boss Agent Core"]
        BA["boss_agent_core.py<br/>~9000 lines, 197+ MCP tools"]
    end

    subgraph SENSE_CELLS["SENSE Cells (1-5)"]
        C01["Cell 01: Data Ingestion"]
        C02["Cell 02: ETL Processing"]
        C03["Cell 03: KG Brain"]
        C04["Cell 04: Stream Processing"]
        C05["Cell 05: Causal Inference"]
    end

    subgraph REASON_CELLS["REASON Cells (6-12)"]
        C06["Cell 06: MOE Router"]
        C07["Cell 07: Connectors"]
        C08["Cell 08: Graph RAG"]
        C09["Cell 09: Creative Analysis"]
        C10["Cell 10: Audience Segmentation"]
        C11["Cell 11: Budget Optimization"]
        C12["Cell 12: Bid Optimization"]
    end

    subgraph DECIDE_CELLS["DECIDE Cells (13-18)"]
        C13["Cell 13: Risk Assessment"]
        C14["Cell 14: Policy Evaluation"]
        C15["Cell 15: Uplift Scoring"]
        C16["Cell 16: Attribution"]
        C17["Cell 17: Forecasting"]
        C18["Cell 18: Allocation"]
    end

    subgraph ACT_CELLS["ACT Cells (19-22)"]
        C19["Cell 19: Monitoring"]
        C20["Cell 20: Feedback Collection"]
        C21["Cell 21: ML Training"]
        C22["Cell 22: NLP Processing"]
    end

    subgraph LEARN_CELLS["LEARN Cells (23-25)"]
        C23["Cell 23: Vision AI"]
        C24["Cell 24: Observability"]
        C25["Cell 25: Compliance"]
    end

    subgraph META_CELLS["META Cells (26-32)"]
        C26["Cell 26: Journey Analysis"]
        C27["Cell 27: A/B Testing"]
        C28["Cell 28: Anomaly Detection"]
        C29["Cell 29: Cost Optimization"]
        C30["Cell 30: Health Monitoring"]
        C31["Cell 31: Recommendations"]
        C32["Cell 32: Analytics"]
    end

    BA --> SENSE_CELLS
    BA --> REASON_CELLS
    BA --> DECIDE_CELLS
    BA --> ACT_CELLS
    BA --> LEARN_CELLS
    BA --> META_CELLS

    style BOSS fill:#e3f2fd
    style SENSE_CELLS fill:#e1f5fe
    style REASON_CELLS fill:#fff3e0
    style DECIDE_CELLS fill:#f3e5f5
    style ACT_CELLS fill:#e8f5e9
    style LEARN_CELLS fill:#fce4ec
    style META_CELLS fill:#f5f5f5

5. Multi-Model Ensemble (Virtuoso Routing)

flowchart LR
    subgraph VIRTUOSO["Virtuoso Model Ensemble"]
        ROUTER["Virtuoso Router<br/>Category-based routing"]

        subgraph MODELS["4 Specialized Models"]
            GEMINI["Gemini 3.1 Pro Preview<br/>Data Science & Causal"]
            CLAUDE["Claude Opus 4.6<br/>Complex Coding & Architecture"]
            GPT["ChatGPT 5.2<br/>Creative & Vision"]
            GROK["Grok 4.1<br/>High-Speed DevOps"]
        end

        ROUTER --> GEMINI
        ROUTER --> CLAUDE
        ROUTER --> GPT
        ROUTER --> GROK
    end

    INPUT["Task Input"] --> ROUTER
    GEMINI --> OUTPUT["Aggregated Output"]
    CLAUDE --> OUTPUT
    GPT --> OUTPUT
    GROK --> OUTPUT

    style VIRTUOSO fill:#e8eaf6

6. Rollback Flow

sequenceDiagram
    participant SRPVDAL as SRPVDAL Orchestrator
    participant RM as RollbackManager
    participant FS as Firestore
    participant GA as Google Ads API
    participant MA as Meta Ads API

    Note over SRPVDAL: Action Execution
    SRPVDAL->>FS: Save pre_state
    SRPVDAL->>GA: Execute mutation
    GA-->>SRPVDAL: post_state
    SRPVDAL->>FS: Log transition

    Note over SRPVDAL: Performance Check
    SRPVDAL->>SRPVDAL: Check metrics (ROAS, CPA)

    alt Metrics FAIL
        SRPVDAL->>RM: Request rollback
        RM->>FS: Get pre_state
        FS-->>RM: pre_state

        alt Google Ads
            RM->>GA: Revert mutation
            GA-->>RM: Confirmation
        else Meta Ads
            RM->>MA: Revert mutation
            MA-->>RM: Confirmation
        end

        RM->>FS: Log rollback
        RM->>SRPVDAL: Verify success
    else Metrics PASS
        SRPVDAL->>FS: Mark transition SUCCESS
    end

7. Knowledge Graph Schema

erDiagram
    USER ||--o{ SESSION : has
    USER ||--o{ EVENT : performed
    SESSION ||--o{ EVENT : contains
    EVENT }o--|| CAMPAIGN : attributed_to
    CAMPAIGN ||--o{ AD : contains
    CAMPAIGN ||--o{ AUDIENCE : targets
    AD ||--o{ CREATIVE : uses
    EVENT }o--|| PRODUCT : involves
    ORDER ||--o{ PRODUCT : contains
    USER ||--o{ ORDER : placed

    USER {
        string cross_platform_id PK
        string email_hash
        string phone_hash
        string consent_status
        float ltv_score
    }

    CAMPAIGN {
        string campaign_id PK
        string platform
        string status
        int daily_budget_micros
        int max_cpc_micros
        float roas_target
    }

    EVENT {
        string event_id PK
        string event_type
        datetime timestamp
        float value
        string gclid
        string fbp
    }

    AD {
        string ad_id PK
        string status
        float fatigue_score
        datetime last_rotation
    }

8. Firestore Collections

Collection Purpose TTL
kg_events Ingested events 90 days
kg_nodes Entity state snapshots Indefinite
kg_edges Signal relationships 90 days
kg_transitions Policy transitions Indefinite
srpvdal_audit_log Decision traces 90 days
srpvdal_rollback_state Pre-action snapshots 24 hours
srpvdal_idempotency_keys Deduplication keys 24 hours
srpvdal_circuit_breakers CB state Indefinite
platform_rollbacks Rollback history 90 days
mcp_capabilities_v2 MCP tool registry Indefinite
mcp_invocations_v2 Tool audit log 30 days

9. API Endpoints

Boss Agent Core API
├── /health                          GET   Health check
├── /api/v1/chat                     POST  Chat endpoint
├── /api/v1/mcp/tools                GET   List MCP tools
│
├── SRPVDAL Endpoints
│   ├── /api/v1/srpvdal/ingest         POST  Ingest event
│   ├── /api/v1/srpvdal/evaluate       POST  Evaluate action
│   ├── /api/v1/srpvdal/execute        POST  Execute action
│   ├── /api/v1/srpvdal/rollback       POST  Rollback action
│   ├── /api/v1/srpvdal/status         GET   System status
│   └── /api/v1/srpvdal/stream         GET   SSE stream
│
├── Policy Engine Endpoints
│   ├── /api/v1/policy-engine/status         GET   Engine status
│   ├── /api/v1/policy-engine/policies       GET   List policies
│   ├── /api/v1/policy-engine/evaluate       POST  Evaluate entity
│   ├── /api/v1/policy-engine/execute        POST  Execute transition
│   └── /api/v1/policy-engine/rollback       POST  Rollback transition
│
├── KG Brain Endpoints
│   ├── /api/v1/kg-brain/status      GET   KG status
│   ├── /api/v1/kg-brain/reason      POST  Neuro-symbolic reasoning
│   ├── /api/v1/kg-brain/traverse    POST  Graph traversal
│   └── /api/v1/kg-brain/explain     GET   Decision provenance
│
└── Rollback Endpoints (NEW)
    ├── /api/v1/rollback/execute     POST  Execute rollback
    ├── /api/v1/rollback/preview     POST  Preview rollback
    ├── /api/v1/rollback/batch       POST  Batch rollback
    ├── /api/v1/rollback/verify      POST  Verify rollback
    ├── /api/v1/rollback/history     GET   Rollback history
    └── /api/v1/rollback/status      GET   Service status

10. Deployment Architecture

                    ┌─────────────────────────────────────────────────────────┐
                    │                  Google Cloud Platform                   │
                    │                                                          │
                    │  ┌────────────────────────────────────────────────────┐ │
                    │  │              Cloud Run (us-central1)                │ │
                    │  │                                                     │ │
                    │  │  ┌─────────────────┐  ┌─────────────────┐          │ │
                    │  │  │   Boss Agent    │  │    Frontend     │          │ │
                    │  │  │   v6.9.1        │  │    Next.js 14   │          │ │
                    │  │  │   Port 8080     │  │    Port 3000    │          │ │
                    │  │  └────────┬────────┘  └────────┬────────┘          │ │
                    │  │           │                    │                    │ │
                    │  │  ┌────────┴────────────────────┴────────┐          │ │
                    │  │  │         32 Cell Microservices         │          │ │
                    │  │  │    cell01-cell32 (Port 80XX each)     │          │ │
                    │  │  └──────────────────────────────────────┘          │ │
                    │  └────────────────────────────────────────────────────┘ │
                    │                                                          │
                    │  ┌────────────────────────────────────────────────────┐ │
                    │  │                   Firestore                         │ │
                    │  │           28+ Collections (see above)               │ │
                    │  └────────────────────────────────────────────────────┘ │
                    │                                                          │
                    │  ┌────────────────────────────────────────────────────┐ │
                    │  │        External APIs (OAuth 2.0 + RFC 8707)         │ │
                    │  │   ┌──────────┐ ┌──────────┐ ┌──────────┐           │ │
                    │  │   │ Google   │ │   Meta   │ │   GA4    │           │ │
                    │  │   │ Ads v18  │ │ API v21  │ │   MP     │           │ │
                    │  │   └──────────┘ └──────────┘ └──────────┘           │ │
                    │  └────────────────────────────────────────────────────┘ │
                    └─────────────────────────────────────────────────────────┘

Quick Reference: Key Files

File Purpose Lines
boss_agent_core.py Main orchestrator ~9000
srpvdal_autonomous_integration.py SRPVDAL pipeline ~1340
policy_engine_integration.py Policy automation ~1900
knowledge_graph_brain_integration.py KG + neuro-symbolic ~1500
platform_rollback_integration.py Rollback APIs ~1100
mcp_connector_registry_v2.py MCP registry ~2200
agent_simulation_framework.py Simulation sandbox ~2000

Generated by MIZ OKI 3.0 Architecture Documentation System

← All docsView source on GitHub →