# lainx06/hexorcist architecture

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

- Interactive diagram: https://gitdiagram.com/lainx06/hexorcist
- Repository: https://github.com/lainx06/hexorcist
- Video tour (about a minute): https://gitdiagram.com/lainx06/hexorcist/video

## Overview

Hexorcist checks compiled ATmega328P firmware against sentence-based rules by running seeded gremlins against a cycle-accurate simulated chip. In the main browser workflow, users configure a program and check, then the worker runs campaigns, reports a verdict, reduces failing input sequences, and supports replay. The CLI and MCP server expose the same headless check. The README documents the major capabilities; source excerpts and the index support some implementation links, while unsampled implementation details are represented only at their documented subsystem paths.

Main entry points: [`src/ui/app/worker/host.ts`](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/worker/host.ts) (Job Host), [`src/ui/app/views/app-page.ts`](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/app-page.ts) (Browser UI), [`src/engine/verdict.ts`](https://github.com/lainx06/hexorcist/blob/main/src/engine/verdict.ts) (Verdict), [`cli/run-check.ts`](https://github.com/lainx06/hexorcist/blob/main/cli/run-check.ts) (Headless Check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Configuration"]
  node_setup["Program Setup<br/>[setup.ts]"]
  node_rules["Rule Language<br/>[parse.ts]"]
  node_gremlins["Gremlin Selection<br/>[catalogue.ts]"]
  node_input_loader["Input Loader<br/>[input-loader.ts]"]
end

subgraph group_checking["Check Engine"]
  node_worker_host["Job Host<br/>[host.ts]"]
  node_campaign["Campaign Runs<br/>[campaign.ts]"]
  node_emulator["Chip Emulator<br/>[emulator-bridge.ts]"]
  node_peripherals["Peripheral Tracking<br/>[peripherals.ts]"]
  node_monitor["Rule Monitoring<br/>[monitors.ts]"]
  node_checker["Verdict Checking<br/>[checker.ts]"]
end

subgraph group_results["Results"]
  node_verdict["Verdict<br/>[verdict.ts]"]
  node_reducer["Trace Reduction<br/>[reducer.ts]"]
  node_replay["Replay Presentation<br/>[playback.ts]"]
end

subgraph group_interfaces["Interfaces"]
  node_browser["Browser UI<br/>[app-page.ts]"]
  node_worker_client["Worker Client<br/>[worker-client.ts]"]
  node_worker["Worker Dispatch<br/>[engine.worker.ts]"]
  node_cli["CLI Runner<br/>[main.ts]"]
  node_run_check["Headless Check<br/>[run-check.ts]"]
  node_mcp["MCP Server<br/>[server.ts]"]
end

node_maker(("Maker"))

node_maker -->|"configures and starts"| node_browser
node_browser -->|"configures program"| node_setup
node_browser -->|"enters rules"| node_rules
node_browser -->|"selects gremlins"| node_gremlins
node_browser -.->|"starts jobs"| node_worker_client
node_worker_client -->|"sends messages"| node_worker
node_worker -->|"dispatches jobs"| node_worker_host
node_worker_host -->|"runs campaigns"| node_campaign
node_worker_host -->|"creates emulator"| node_emulator
node_worker_host -->|"loads generators"| node_gremlins
node_worker_host -->|"compiles rules"| node_monitor
node_worker_host -->|"checks runs"| node_checker
node_emulator -->|"records usage"| node_peripherals
node_campaign -.->|"runs firmware"| node_emulator
node_campaign -.->|"produces outcome"| node_verdict
node_checker -.->|"determines verdict"| node_verdict
node_verdict -->|"displays result"| node_browser
node_verdict -->|"reduces failing trace"| node_reducer
node_reducer -->|"provides reduced trace"| node_replay
node_replay -->|"shows replay"| node_browser
node_maker -->|"runs headless check"| node_cli
node_cli -->|"loads inputs"| node_input_loader
node_cli -->|"starts check"| node_run_check
node_run_check -->|"runs shared jobs"| node_worker_host
node_run_check -->|"consumes inputs"| node_input_loader
node_mcp -->|"loads inputs"| node_input_loader
node_mcp -->|"runs check"| node_run_check
node_setup -.->|"shares input formats"| node_input_loader

click node_browser "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/app-page.ts"
click node_setup "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/setup.ts"
click node_rules "https://github.com/lainx06/hexorcist/blob/main/src/engine/rules/parse.ts"
click node_gremlins "https://github.com/lainx06/hexorcist/blob/main/src/engine/gremlins/catalogue.ts"
click node_worker_client "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/worker-client.ts"
click node_worker "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/worker/engine.worker.ts"
click node_worker_host "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/worker/host.ts"
click node_campaign "https://github.com/lainx06/hexorcist/blob/main/src/engine/campaign.ts"
click node_emulator "https://github.com/lainx06/hexorcist/blob/main/src/engine/emulator-bridge.ts"
click node_peripherals "https://github.com/lainx06/hexorcist/blob/main/src/engine/peripherals.ts"
click node_monitor "https://github.com/lainx06/hexorcist/blob/main/src/engine/rules/monitors.ts"
click node_checker "https://github.com/lainx06/hexorcist/blob/main/src/engine/checker.ts"
click node_verdict "https://github.com/lainx06/hexorcist/blob/main/src/engine/verdict.ts"
click node_reducer "https://github.com/lainx06/hexorcist/blob/main/src/engine/reducer/reducer.ts"
click node_replay "https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/playback.ts"
click node_cli "https://github.com/lainx06/hexorcist/blob/main/cli/main.ts"
click node_input_loader "https://github.com/lainx06/hexorcist/blob/main/cli/input-loader.ts"
click node_run_check "https://github.com/lainx06/hexorcist/blob/main/cli/run-check.ts"
click node_mcp "https://github.com/lainx06/hexorcist/blob/main/mcp/server.ts"

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_setup,node_rules,node_gremlins,node_input_loader toneBlue
class node_worker_host,node_campaign,node_emulator,node_peripherals,node_monitor,node_checker toneAmber
class node_verdict,node_reducer,node_replay toneMint
class node_browser,node_worker_client,node_worker,node_cli,node_run_check,node_mcp toneRose
class node_maker toneIndigo
```

## Components

### Configuration

- [Program Setup](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/setup.ts): `src/ui/app/views/setup.ts`
- [Rule Language](https://github.com/lainx06/hexorcist/blob/main/src/engine/rules/parse.ts): `src/engine/rules/parse.ts`
- [Gremlin Selection](https://github.com/lainx06/hexorcist/blob/main/src/engine/gremlins/catalogue.ts): `src/engine/gremlins/catalogue.ts`
- [Input Loader](https://github.com/lainx06/hexorcist/blob/main/cli/input-loader.ts): `cli/input-loader.ts`

### Check Engine

- [Job Host](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/worker/host.ts): `src/ui/app/worker/host.ts`
- [Campaign Runs](https://github.com/lainx06/hexorcist/blob/main/src/engine/campaign.ts): `src/engine/campaign.ts`
- [Chip Emulator](https://github.com/lainx06/hexorcist/blob/main/src/engine/emulator-bridge.ts): `src/engine/emulator-bridge.ts`
- [Peripheral Tracking](https://github.com/lainx06/hexorcist/blob/main/src/engine/peripherals.ts): `src/engine/peripherals.ts`
- [Rule Monitoring](https://github.com/lainx06/hexorcist/blob/main/src/engine/rules/monitors.ts): `src/engine/rules/monitors.ts`
- [Verdict Checking](https://github.com/lainx06/hexorcist/blob/main/src/engine/checker.ts): `src/engine/checker.ts`

### Results

- [Verdict](https://github.com/lainx06/hexorcist/blob/main/src/engine/verdict.ts): `src/engine/verdict.ts`
- [Trace Reduction](https://github.com/lainx06/hexorcist/blob/main/src/engine/reducer/reducer.ts): `src/engine/reducer/reducer.ts`
- [Replay Presentation](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/playback.ts): `src/ui/app/views/playback.ts`

### Interfaces

- [Browser UI](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/app-page.ts): `src/ui/app/views/app-page.ts`
- [Worker Client](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/views/worker-client.ts): `src/ui/app/views/worker-client.ts`
- [Worker Dispatch](https://github.com/lainx06/hexorcist/blob/main/src/ui/app/worker/engine.worker.ts): `src/ui/app/worker/engine.worker.ts`
- [CLI Runner](https://github.com/lainx06/hexorcist/blob/main/cli/main.ts): `cli/main.ts`
- [Headless Check](https://github.com/lainx06/hexorcist/blob/main/cli/run-check.ts): `cli/run-check.ts`
- [MCP Server](https://github.com/lainx06/hexorcist/blob/main/mcp/server.ts): `mcp/server.ts`

### Other components

- **Maker**

## Connections

- Maker → Browser UI: configures and starts (evidence: `README.md`)
- Browser UI → Program Setup: configures program (evidence: `README.md`)
- Browser UI → Rule Language: enters rules (evidence: `README.md`)
- Browser UI → Gremlin Selection: selects gremlins (evidence: `README.md`)
- Browser UI → Worker Client: starts jobs
- Worker Client → Worker Dispatch: sends messages (evidence: `src/ui/app/worker/engine.worker.ts`)
- Worker Dispatch → Job Host: dispatches jobs (evidence: `src/ui/app/worker/engine.worker.ts`)
- Job Host → Campaign Runs: runs campaigns (evidence: `src/ui/app/worker/host.ts`)
- Job Host → Chip Emulator: creates emulator (evidence: `src/ui/app/worker/host.ts`)
- Job Host → Gremlin Selection: loads generators (evidence: `src/ui/app/worker/host.ts`)
- Job Host → Rule Monitoring: compiles rules (evidence: `src/ui/app/worker/host.ts`)
- Job Host → Verdict Checking: checks runs (evidence: `src/ui/app/worker/host.ts`)
- Chip Emulator → Peripheral Tracking: records usage (evidence: `src/engine/emulator-bridge.ts`)
- Campaign Runs → Chip Emulator: runs firmware
- Campaign Runs → Verdict: produces outcome
- Verdict Checking → Verdict: determines verdict
- Verdict → Browser UI: displays result (evidence: `README.md`)
- Verdict → Trace Reduction: reduces failing trace (evidence: `README.md`)
- Trace Reduction → Replay Presentation: provides reduced trace (evidence: `README.md`)
- Replay Presentation → Browser UI: shows replay (evidence: `README.md`)
- Maker → CLI Runner: runs headless check (evidence: `README.md`)
- CLI Runner → Input Loader: loads inputs (evidence: `cli/main.ts`)
- CLI Runner → Headless Check: starts check (evidence: `cli/main.ts`)
- Headless Check → Job Host: runs shared jobs (evidence: `cli/run-check.ts`)
- Headless Check → Input Loader: consumes inputs (evidence: `cli/run-check.ts`)
- MCP Server → Input Loader: loads inputs (evidence: `mcp/server.ts`)
- MCP Server → Headless Check: runs check (evidence: `mcp/server.ts`)
- Program Setup → Input Loader: shares input formats
