# arifOS Constitutional Control Plane - Architecture Diagram
# Render with Mermaid: https://mermaid.live

graph TB
    subgraph "Human Sovereign (F13)"
        HUMAN[👤 Human Operator]
    end

    subgraph "4 Constitutional Agents"
        ARCH[🏛️ A-ARCHITECT<br/>READ-PLAN]
        ENG[⚙️ A-ENGINEER<br/>EDIT-WRITE]
        AUD[🔍 A-AUDITOR<br/>READ-REVIEW]
        VAL[✓ A-VALIDATOR<br/>DEPLOY-SEAL]
    end

    subgraph "Execution Controller"
        EC[execution-controller.py]
        ID[agent-identity.yaml]
        CM[capability-manifest.yaml]
    end

    subgraph "Memory & Events"
        ML[memory-ledger.yaml<br/>Unified Memory Spine]
        EB[event-bus.yaml<br/>Event Bus]
        FR[forensic-replay.yaml<br/>Immutable Replay]
    end

    subgraph "VAULT999"
        V[VAULT999<br/>Merkle Chain Ledger]
    end

    HUMAN -->|Approval| VAL

    ARCH -->|Design| ENG
    ENG -->|Implement| AUD
    AUD -->|VOID or Pass| VAL
    VAL -->|SEAL| V

    ARCH -.->|Identity Check| EC
    ENG -.->|Identity Check| EC
    AUD -.->|Identity Check| EC
    VAL -.->|Identity Check| EC

    EC -->|Validate| ID
    EC -->|Capability Check| CM

    ARCH -.->|Observations| ML
    ENG -.->|Observations| ML
    AUD -.->|Observations| ML
    VAL -.->|Observations| ML

    EB -->|Triggers| ARCH
    EB -->|Triggers| ENG
    EB -->|Triggers| AUD
    EB -->|Triggers| VAL

    ARCH -.->|Forensic Log| FR
    ENG -.->|Forensic Log| FR
    AUD -.->|Forensic Log| FR
    VAL -.->|Forensic Log| FR

    EC -->|Receipt| V
    FR -->|Replay Data| V

    style HUMAN fill:#gold,stroke:#333,stroke-width:3px
    style VAL fill:#lightgreen,stroke:#333,stroke-width:2px
    style AUD fill:#lightyellow,stroke:#333,stroke-width:2px
    style V fill:#lightblue,stroke:#333,stroke-width:2px
