# tbreijm/brixms architecture

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

- Interactive diagram: https://gitdiagram.com/tbreijm/brixms
- Repository: https://github.com/tbreijm/brixms

## Overview

BrixMS is a language and runtime for decisions over incomplete or changing information. The principal workflow is source model → parse and import resolution → lowering and evaluation → settled, explainable decision; facts can also be synchronized into revisioned worlds for incremental queries and checks. The CLI exposes these flows, plus source description, audit verification, and a host-scoped query interface. The README and excerpts support the major stages and capabilities; some runtime and storage links are documented rather than verified against their implementation excerpts.

Main entry points: [`crates/brix-cli/src/commands/mod.rs`](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/mod.rs) (Command handlers), [`crates/brix-cli/src/pipeline.rs`](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/pipeline.rs) (Source pipeline), [`crates/brix-lower/src/l3_v2.rs`](https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/l3_v2.rs) (Program lowering), [`crates/brix-kb/src/world/session.rs`](https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/session.rs) (World session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Model authoring"]
  node_describe["Context map<br/>[context.rs]"]
end

subgraph group_language["Language processing"]
  node_pipeline["Source pipeline<br/>[pipeline.rs]"]
  node_syntax["Parser and AST<br/>[parser.rs]"]
  node_lower["Program lowering<br/>[l3_v2.rs]"]
  node_kernel["Type checker<br/>[check.rs]"]
  node_semantic["Semantic model"]
end

subgraph group_decision["Decision runtime"]
  node_finite["Finite decisions<br/>[plan.rs]"]
  node_evidence["Decision evidence<br/>[evidence.rs]"]
  node_soc["SOC execution<br/>[engine.rs]"]
  node_history["Decision history<br/>[history.rs]"]
end

subgraph group_worlds["Persistent worlds"]
  node_world[("World session<br/>[session.rs]")]
  node_world_batch["Fact batches<br/>[batch.rs]"]
  node_scoped["Scoped queries<br/>[scoped_query.rs]"]
  node_world_checks["World checks<br/>[world_checks.rs]"]
end

subgraph group_interfaces["Host interfaces"]
  node_cli["Brix CLI<br/>[main.rs]"]
  node_commands["Command handlers<br/>[mod.rs]"]
  node_audit["Audit and verify<br/>[audit.rs]"]
  node_python["Python client<br/>[client.py]"]
end

node_user(("Model author"))
node_host(("Embedding host"))

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_commands
node_commands -->|"runs stages"| node_pipeline
node_pipeline -->|"parses source"| node_syntax
node_pipeline -->|"lowers program"| node_lower
node_pipeline -->|"builds runtime"| node_finite
node_syntax -->|"provides AST"| node_lower
node_lower -->|"checks terms"| node_kernel
node_lower -.->|"uses semantics"| node_semantic
node_finite -.->|"executes decisions"| node_soc
node_soc -.->|"records history"| node_history
node_commands -->|"collects evidence"| node_evidence
node_user -->|"supplies facts"| node_world_batch
node_commands -->|"opens worlds"| node_world
node_world_batch -->|"commits batches"| node_world
node_world -->|"serves queries"| node_scoped
node_commands -->|"runs checks"| node_world_checks
node_user -->|"requests map"| node_describe
node_describe -.->|"inspects source"| node_pipeline
node_commands -->|"audits decisions"| node_audit
node_audit -->|"writes bundle"| node_evidence
node_host -->|"embeds client"| node_python
node_python -.->|"uses protocol"| node_cli
node_host -->|"authorizes scope"| node_scoped

click node_cli "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/main.rs"
click node_commands "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/mod.rs"
click node_pipeline "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/pipeline.rs"
click node_syntax "https://github.com/tbreijm/brixms/blob/main/crates/brix-syntax/src/parser.rs"
click node_lower "https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/l3_v2.rs"
click node_kernel "https://github.com/tbreijm/brixms/blob/main/crates/brix-kernel/src/check.rs"
click node_semantic "https://github.com/tbreijm/brixms/blob/main/crates/brix-semantic/src/context_contract.rs"
click node_finite "https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/finite_decision/plan.rs"
click node_evidence "https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/evidence.rs"
click node_soc "https://github.com/tbreijm/brixms/blob/main/crates/soc-core/src/engine.rs"
click node_history "https://github.com/tbreijm/brixms/blob/main/crates/soc-core/src/history.rs"
click node_world "https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/session.rs"
click node_world_batch "https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/batch.rs"
click node_scoped "https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/scoped_query.rs"
click node_world_checks "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/world_checks.rs"
click node_describe "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/context.rs"
click node_audit "https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/audit.rs"
click node_python "https://github.com/tbreijm/brixms/blob/main/bindings/python/brix/client.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_describe toneBlue
class node_pipeline,node_syntax,node_lower,node_kernel,node_semantic toneAmber
class node_finite,node_evidence,node_soc,node_history toneMint
class node_world,node_world_batch,node_scoped,node_world_checks toneRose
class node_cli,node_commands,node_audit,node_python,node_user,node_host toneIndigo
```

## Components

### Model authoring

- [Context map](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/context.rs): `crates/brix-cli/src/commands/context.rs`

### Language processing

- [Source pipeline](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/pipeline.rs): `crates/brix-cli/src/pipeline.rs`
- [Parser and AST](https://github.com/tbreijm/brixms/blob/main/crates/brix-syntax/src/parser.rs): `crates/brix-syntax/src/parser.rs`
- [Program lowering](https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/l3_v2.rs): `crates/brix-lower/src/l3_v2.rs`
- [Type checker](https://github.com/tbreijm/brixms/blob/main/crates/brix-kernel/src/check.rs): `crates/brix-kernel/src/check.rs`
- [Semantic model](https://github.com/tbreijm/brixms/blob/main/crates/brix-semantic/src/context_contract.rs): `crates/brix-semantic/src/context_contract.rs`

### Decision runtime

- [Finite decisions](https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/finite_decision/plan.rs): `crates/brix-lower/src/finite_decision/plan.rs`
- [Decision evidence](https://github.com/tbreijm/brixms/blob/main/crates/brix-lower/src/evidence.rs): `crates/brix-lower/src/evidence.rs`
- [SOC execution](https://github.com/tbreijm/brixms/blob/main/crates/soc-core/src/engine.rs): `crates/soc-core/src/engine.rs`
- [Decision history](https://github.com/tbreijm/brixms/blob/main/crates/soc-core/src/history.rs): `crates/soc-core/src/history.rs`

### Persistent worlds

- [World session](https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/session.rs): `crates/brix-kb/src/world/session.rs`
- [Fact batches](https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/batch.rs): `crates/brix-kb/src/world/batch.rs`
- [Scoped queries](https://github.com/tbreijm/brixms/blob/main/crates/brix-kb/src/world/scoped_query.rs): `crates/brix-kb/src/world/scoped_query.rs`
- [World checks](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/world_checks.rs): `crates/brix-cli/src/commands/world_checks.rs`

### Host interfaces

- [Brix CLI](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/main.rs): `crates/brix-cli/src/main.rs`
- [Command handlers](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/mod.rs): `crates/brix-cli/src/commands/mod.rs`
- [Audit and verify](https://github.com/tbreijm/brixms/blob/main/crates/brix-cli/src/commands/audit.rs): `crates/brix-cli/src/commands/audit.rs`
- [Python client](https://github.com/tbreijm/brixms/blob/main/bindings/python/brix/client.py): `bindings/python/brix/client.py`

### Other components

- **Model author**
- **Embedding host**

## Connections

- Model author → Brix CLI: invokes (evidence: `README.md`)
- Brix CLI → Command handlers: dispatches (evidence: `crates/brix-cli/src/main.rs`)
- Command handlers → Source pipeline: runs stages (evidence: `crates/brix-cli/src/commands/mod.rs`)
- Source pipeline → Parser and AST: parses source (evidence: `crates/brix-cli/src/pipeline.rs`)
- Source pipeline → Program lowering: lowers program (evidence: `crates/brix-cli/src/pipeline.rs`)
- Source pipeline → Finite decisions: builds runtime (evidence: `crates/brix-cli/src/pipeline.rs`)
- Parser and AST → Program lowering: provides AST
- Program lowering → Type checker: checks terms
- Program lowering → Semantic model: uses semantics
- Finite decisions → SOC execution: executes decisions
- SOC execution → Decision history: records history
- Command handlers → Decision evidence: collects evidence (evidence: `crates/brix-cli/src/commands/mod.rs`)
- Model author → Fact batches: supplies facts (evidence: `README.md`)
- Command handlers → World session: opens worlds (evidence: `README.md`)
- Fact batches → World session: commits batches (evidence: `README.md`)
- World session → Scoped queries: serves queries (evidence: `crates/brix-kb/src/world/session.rs`)
- Command handlers → World checks: runs checks (evidence: `README.md`)
- Model author → Context map: requests map (evidence: `README.md`)
- Context map → Source pipeline: inspects source
- Command handlers → Audit and verify: audits decisions (evidence: `README.md`)
- Audit and verify → Decision evidence: writes bundle (evidence: `README.md`)
- Embedding host → Python client: embeds client (evidence: `README.md`)
- Python client → Brix CLI: uses protocol
- Embedding host → Scoped queries: authorizes scope (evidence: `crates/brix-kb/src/world/scoped_query.rs`)
