# probablyapigeon/glassbox_lonk architecture

> Architecture diagram of the GitHub repository probablyapigeon/glassbox_lonk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/probablyapigeon/glassbox_lonk
- Repository: https://github.com/probablyapigeon/glassbox_lonk

## Overview

Glassbox Lonk is a prototype for inspecting an agent decision loop. A run loads saved trials and an XC world, obtains a recorded Qwen proposal (or asks local Qwen), scores actions with the frozen or trained Lonk policy, applies each action to the world, and publishes the outcomes and scores as a trace and browser Scope. The core modules also provide XC interpretation and classical state transforms. The README documents separate wrong-item experiments and results. Source excerpts do not show the XC fixtures’ contents, so their internal rules are not expanded here.

Main entry points: [`glassbox.py`](https://github.com/probablyapigeon/glassbox_lonk/blob/main/glassbox.py) (Replay and Scope), [`xc_interpreter.py`](https://github.com/probablyapigeon/glassbox_lonk/blob/main/xc_interpreter.py) (XC interpreter), [`qwen_xc_wrong_item_results.json`](https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_wrong_item_results.json) (Wrong-item results), [`lonk_policy.py`](https://github.com/probablyapigeon/glassbox_lonk/blob/main/lonk_policy.py) (TinyNN policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Agent run"]
  node_glassbox["Replay and Scope<br/>[glassbox.py]"]
  node_trace["Trace and Scope output<br/>[glassbox.py]"]
end

subgraph group_policy["Lonk policy"]
  node_policy_nn["TinyNN policy<br/>[lonk_policy.py]"]
end

subgraph group_xc["XC runtime"]
  node_xc_runner["XC interpreter<br/>[xc_interpreter.py]"]
  node_xc_core["XC state core<br/>[xembra_core.py]"]
  node_search_world["Search world rules<br/>[qwen_xc_search.xc]"]
end

subgraph group_experiments["Experiment records"]
  node_wrong_item_world["Wrong-item fixture"]
  node_wrong_item_results["Wrong-item results"]
  node_stopping_results["Stopping results"]
end

node_engineer(("Run operator"))
node_qwen["Local Qwen"]

node_engineer -->|"runs"| node_glassbox
node_glassbox -.->|"requests proposals"| node_qwen
node_glassbox -->|"scores actions"| node_policy_nn
node_glassbox -->|"loads rules"| node_xc_runner
node_xc_runner -->|"exposes transforms"| node_xc_core
node_xc_runner -->|"executes script"| node_search_world
node_glassbox -->|"loads trials"| node_stopping_results
node_glassbox -->|"publishes outcomes"| node_trace
node_wrong_item_results -->|"records fixture"| node_wrong_item_world

click node_glassbox "https://github.com/probablyapigeon/glassbox_lonk/blob/main/glassbox.py"
click node_policy_nn "https://github.com/probablyapigeon/glassbox_lonk/blob/main/lonk_policy.py"
click node_xc_runner "https://github.com/probablyapigeon/glassbox_lonk/blob/main/xc_interpreter.py"
click node_xc_core "https://github.com/probablyapigeon/glassbox_lonk/blob/main/xembra_core.py"
click node_search_world "https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_search.xc"
click node_trace "https://github.com/probablyapigeon/glassbox_lonk/blob/main/glassbox.py"
click node_wrong_item_world "https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_wrong_item.xc"
click node_wrong_item_results "https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_wrong_item_results.json"
click node_stopping_results "https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_stopping_results.json"

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_glassbox,node_trace toneBlue
class node_policy_nn toneAmber
class node_xc_runner,node_xc_core,node_search_world toneMint
class node_wrong_item_world,node_wrong_item_results,node_stopping_results toneRose
class node_engineer,node_qwen toneIndigo
```

## Components

### Agent run

- [Replay and Scope](https://github.com/probablyapigeon/glassbox_lonk/blob/main/glassbox.py): `glassbox.py`
- [Trace and Scope output](https://github.com/probablyapigeon/glassbox_lonk/blob/main/glassbox.py): `glassbox.py`

### Lonk policy

- [TinyNN policy](https://github.com/probablyapigeon/glassbox_lonk/blob/main/lonk_policy.py): `lonk_policy.py`

### XC runtime

- [XC interpreter](https://github.com/probablyapigeon/glassbox_lonk/blob/main/xc_interpreter.py): `xc_interpreter.py`
- [XC state core](https://github.com/probablyapigeon/glassbox_lonk/blob/main/xembra_core.py): `xembra_core.py`
- [Search world rules](https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_search.xc): `qwen_xc_search.xc`

### Experiment records

- [Wrong-item fixture](https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_wrong_item.xc): `qwen_xc_wrong_item.xc`
- [Wrong-item results](https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_wrong_item_results.json): `qwen_xc_wrong_item_results.json`
- [Stopping results](https://github.com/probablyapigeon/glassbox_lonk/blob/main/qwen_xc_stopping_results.json): `qwen_xc_stopping_results.json`

### Other components

- **Run operator**
- **Local Qwen**

## Connections

- Run operator → Replay and Scope: runs (evidence: `README.md`)
- Replay and Scope → Local Qwen: requests proposals (evidence: `glassbox.py`)
- Replay and Scope → TinyNN policy: scores actions (evidence: `glassbox.py`)
- Replay and Scope → XC interpreter: loads rules (evidence: `glassbox.py`)
- XC interpreter → XC state core: exposes transforms (evidence: `xc_interpreter.py`)
- XC interpreter → Search world rules: executes script (evidence: `README.md`)
- Replay and Scope → Stopping results: loads trials (evidence: `glassbox.py`)
- Replay and Scope → Trace and Scope output: publishes outcomes (evidence: `glassbox.py`)
- Wrong-item results → Wrong-item fixture: records fixture (evidence: `README.md`)
