# rick-clinton-jpg/black-mirror architecture

> Architecture diagram of the GitHub repository rick-clinton-jpg/black-mirror, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rick-clinton-jpg/black-mirror
- Repository: https://github.com/rick-clinton-jpg/black-mirror

## Overview

Black Mirror contains untrusted agents behind a Linux process boundary, mediates their requests, and reflects suspicious or locked-session actions into a simulated world. Reviewers can inspect a bounded observation log and a separate tamper-evident trace; trusted host code can authorize narrowly scoped re-entry. A second product layer normalizes traces and evaluates six security invariants. The README documents this workflow and its guarantees; several implementation relationships below are omitted where the sampled source does not establish them.

Main entry points: [`mirror_world/sandbox/governor_process.py`](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/governor_process.py) (Real Governor), [`mirror_world/engine.py`](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/engine.py) (Constitution Engine), [`mirror_world/trace.py`](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trace.py) (Trace Normalizer), [`mirror_world/sandbox/locket.py`](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/locket.py) (Locket Monitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_containment["Agent Containment"]
  node_kernel["Linux Boundary"]
  node_runtime["Agent Runtime<br/>[agent_runtime.py]"]
  node_governor["Real Governor"]
  node_modelgov["Model Governor<br/>[model_governor.py]"]
  node_policy["Sandbox Policy<br/>[policy.py]"]
  node_approvals["Capability Approvals<br/>[authorization.py]"]
  node_signed["Signed Approvals"]
end

subgraph group_mirror["Mirror Mediation"]
  node_locket["Locket Monitor<br/>[locket.py]"]
  node_world[("Simulated Worlds<br/>[mirror_store.py]")]
  node_mirrorlog[("Observation Log<br/>[black_mirror.py]")]
end

subgraph group_audit["Audit and Invariants"]
  node_trace["Trace Normalizer<br/>[trace.py]"]
  node_hashchain["Hash Chain<br/>[hashchain.py]"]
  node_state["Containment State<br/>[state.py]"]
  node_engine["Constitution Engine<br/>[engine.py]"]
  node_authority["Authority Check<br/>[authority.py]"]
  node_chainmail["Delegation Check<br/>[chainmail.py]"]
  node_channel["Channel Check<br/>[channel.py]"]
  node_confidentiality["Confidentiality Check<br/>[confidentiality.py]"]
  node_evaluator["Evaluator Trust Check<br/>[evaluator_trust.py]"]
  node_weave["Mirror Weave Check<br/>[weave.py]"]
end

subgraph group_trials["Research Trials"]
  node_trial["Trial Launcher<br/>[trial_launcher.py]"]
  node_trialprotocol["Trial Protocol<br/>[trial_protocol.py]"]
  node_transcript["Trial Transcript"]
  node_observer["Observer Trial<br/>[observer_trial.py]"]
end

node_agent(("Untrusted Agent"))

node_agent -->|"runs within"| node_kernel
node_kernel -->|"contains"| node_runtime
node_runtime -.->|"sends requests"| node_governor
node_governor -->|"routes through"| node_locket
node_modelgov -->|"mediates with"| node_locket
node_modelgov -->|"dispatches to"| node_governor
node_governor -.->|"serves mirror data"| node_world
node_locket -->|"records observations"| node_mirrorlog
node_locket -->|"requests execution"| node_governor
node_governor -.->|"uses approvals"| node_approvals
node_governor -.->|"checks signed approval"| node_signed
node_governor -->|"records decisions"| node_trace
node_trace -->|"verifies chain"| node_hashchain
node_trace -->|"builds graph"| node_state
node_trace -->|"supplies normalized inputs"| node_engine
node_engine -->|"checks authority"| node_authority
node_engine -->|"checks delegation"| node_chainmail
node_engine -->|"checks channels"| node_channel
node_engine -->|"checks leakage"| node_confidentiality
node_engine -->|"checks attribution"| node_evaluator
node_engine -->|"checks mirror weave"| node_weave
node_trial -.->|"uses protocol"| node_trialprotocol
node_trial -.->|"emits transcript"| node_transcript
node_observer -.->|"observes run"| node_trial

click node_kernel "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/kernel_containment.py"
click node_runtime "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/agent_runtime.py"
click node_governor "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/governor_process.py"
click node_modelgov "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/model_governor.py"
click node_policy "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/policy.py"
click node_locket "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/locket.py"
click node_world "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/mirror_store.py"
click node_mirrorlog "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/black_mirror.py"
click node_approvals "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/authorization.py"
click node_signed "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/signed_approvals.py"
click node_trace "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trace.py"
click node_hashchain "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/hashchain.py"
click node_state "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/state.py"
click node_engine "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/engine.py"
click node_authority "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/authority.py"
click node_chainmail "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/chainmail.py"
click node_channel "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/channel.py"
click node_confidentiality "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/confidentiality.py"
click node_evaluator "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/evaluator_trust.py"
click node_weave "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/weave.py"
click node_trial "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_launcher.py"
click node_trialprotocol "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_protocol.py"
click node_transcript "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_transcript.py"
click node_observer "https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/observer_trial.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_kernel,node_runtime,node_governor,node_modelgov,node_policy,node_approvals,node_signed toneBlue
class node_locket,node_world,node_mirrorlog toneAmber
class node_trace,node_hashchain,node_state,node_engine,node_authority,node_chainmail,node_channel,node_confidentiality,node_evaluator,node_weave toneMint
class node_trial,node_trialprotocol,node_transcript,node_observer toneRose
class node_agent toneIndigo
```

## Components

### Agent Containment

- [Linux Boundary](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/kernel_containment.py): `mirror_world/sandbox/kernel_containment.py`
- [Agent Runtime](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/agent_runtime.py): `mirror_world/sandbox/agent_runtime.py`
- [Real Governor](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/governor_process.py): `mirror_world/sandbox/governor_process.py`
- [Model Governor](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/model_governor.py): `mirror_world/sandbox/model_governor.py`
- [Sandbox Policy](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/policy.py): `mirror_world/sandbox/policy.py`
- [Capability Approvals](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/authorization.py): `mirror_world/authorization.py`
- [Signed Approvals](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/signed_approvals.py): `mirror_world/signed_approvals.py`

### Mirror Mediation

- [Locket Monitor](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/locket.py): `mirror_world/sandbox/locket.py`
- [Simulated Worlds](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/mirror_store.py): `mirror_world/sandbox/mirror_store.py`
- [Observation Log](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/sandbox/black_mirror.py): `mirror_world/sandbox/black_mirror.py`

### Audit and Invariants

- [Trace Normalizer](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trace.py): `mirror_world/trace.py`
- [Hash Chain](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/hashchain.py): `mirror_world/hashchain.py`
- [Containment State](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/state.py): `mirror_world/state.py`
- [Constitution Engine](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/engine.py): `mirror_world/engine.py`
- [Authority Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/authority.py): `mirror_world/invariants/authority.py`
- [Delegation Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/chainmail.py): `mirror_world/invariants/chainmail.py`
- [Channel Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/channel.py): `mirror_world/invariants/channel.py`
- [Confidentiality Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/confidentiality.py): `mirror_world/invariants/confidentiality.py`
- [Evaluator Trust Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/evaluator_trust.py): `mirror_world/invariants/evaluator_trust.py`
- [Mirror Weave Check](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/invariants/weave.py): `mirror_world/invariants/weave.py`

### Research Trials

- [Trial Launcher](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_launcher.py): `mirror_world/trial_launcher.py`
- [Trial Protocol](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_protocol.py): `mirror_world/trial_protocol.py`
- [Trial Transcript](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/trial_transcript.py): `mirror_world/trial_transcript.py`
- [Observer Trial](https://github.com/rick-clinton-jpg/black-mirror/blob/main/mirror_world/observer_trial.py): `mirror_world/observer_trial.py`

### Other components

- **Untrusted Agent**

## Connections

- Untrusted Agent → Linux Boundary: runs within
- Linux Boundary → Agent Runtime: contains
- Agent Runtime → Real Governor: sends requests
- Real Governor → Locket Monitor: routes through (evidence: `mirror_world/sandbox/locket.py`)
- Model Governor → Locket Monitor: mediates with (evidence: `mirror_world/sandbox/model_governor.py`)
- Model Governor → Real Governor: dispatches to (evidence: `mirror_world/sandbox/model_governor.py`)
- Real Governor → Simulated Worlds: serves mirror data
- Locket Monitor → Observation Log: records observations (evidence: `mirror_world/sandbox/locket.py`)
- Locket Monitor → Real Governor: requests execution (evidence: `mirror_world/sandbox/locket.py`)
- Real Governor → Capability Approvals: uses approvals
- Real Governor → Signed Approvals: checks signed approval
- Real Governor → Trace Normalizer: records decisions
- Trace Normalizer → Hash Chain: verifies chain (evidence: `mirror_world/trace.py`)
- Trace Normalizer → Containment State: builds graph (evidence: `mirror_world/trace.py`)
- Trace Normalizer → Constitution Engine: supplies normalized inputs (evidence: `mirror_world/trace.py`)
- Constitution Engine → Authority Check: checks authority (evidence: `mirror_world/engine.py`)
- Constitution Engine → Delegation Check: checks delegation (evidence: `mirror_world/engine.py`)
- Constitution Engine → Channel Check: checks channels (evidence: `mirror_world/engine.py`)
- Constitution Engine → Confidentiality Check: checks leakage (evidence: `mirror_world/engine.py`)
- Constitution Engine → Evaluator Trust Check: checks attribution (evidence: `mirror_world/engine.py`)
- Constitution Engine → Mirror Weave Check: checks mirror weave (evidence: `mirror_world/engine.py`)
- Trial Launcher → Trial Protocol: uses protocol
- Trial Launcher → Trial Transcript: emits transcript
- Observer Trial → Trial Launcher: observes run
