# camdenleibee/miniharness architecture

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

- Interactive diagram: https://gitdiagram.com/camdenleibee/miniharness
- Repository: https://github.com/camdenleibee/miniharness

## Overview

MiniHarness is an interactive scripted-conversation CLI: it reads user turns, obtains streamed assistant replies from a model client, maintains the conversation, and stops on a sentinel, turn limit, user exit, or client error. The CLI can save the resulting transcript. Scripted and replay clients are distinct model backends. The harness, conversation, and scanner implementations were not sampled, so their internal call wiring is shown only where the available interfaces and README support it.

Main entry points: [`src/harness.cpp`](https://github.com/camdenleibee/miniharness/blob/main/src/harness.cpp) (Turn orchestrator), [`src/main.cpp`](https://github.com/camdenleibee/miniharness/blob/main/src/main.cpp) (CLI entry), [`src/scripted_client.cpp`](https://github.com/camdenleibee/miniharness/blob/main/src/scripted_client.cpp) (Scripted client), [`include/model/model_client.h`](https://github.com/camdenleibee/miniharness/blob/main/include/model/model_client.h) (Model interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_main["CLI entry<br/>[main.cpp]"]
end

subgraph group_runtime["Conversation runtime"]
  node_harness["Turn orchestrator<br/>[harness.cpp]"]
end

subgraph group_core["Conversation core"]
  node_scanner["Sentinel scanner"]
  node_conversation["Conversation store<br/>[conversation.cpp]"]
  node_message["Role message<br/>[message.h]"]
end

subgraph group_models["Model clients"]
  node_modelapi["Model interface<br/>[model_client.h]"]
  node_tokensink["Token sink<br/>[model_client.h]"]
  node_scripted["Scripted client"]
  node_replay["Replay client<br/>[replay_client.cpp]"]
  node_modelbase["Response collector<br/>[model_client.cpp]"]
end

node_user(("Terminal user"))
node_stdin(("Terminal input"))
node_stdout(("Terminal output"))
node_scriptfile["Script file<br/>[greeting.script]"]
node_transcript["Transcript file"]

node_user -->|"enters text"| node_stdin
node_main -->|"reads through"| node_stdin
node_main -->|"constructs"| node_scripted
node_scriptfile -->|"loads script"| node_scripted
node_main -->|"starts"| node_harness
node_harness -->|"reads turns"| node_stdin
node_harness -->|"writes replies"| node_stdout
node_harness -->|"requests replies"| node_modelapi
node_scripted -->|"implements"| node_modelapi
node_replay -->|"implements"| node_modelapi
node_modelapi -->|"streams chunks"| node_tokensink
node_scripted -->|"emits chunks"| node_tokensink
node_replay -->|"emits chunks"| node_tokensink
node_modelbase -->|"collects chunks"| node_tokensink
node_modelbase -->|"returns reply"| node_message
node_harness -->|"maintains turns"| node_conversation
node_harness -->|"checks sentinel"| node_scanner
node_conversation -->|"stores"| node_message
node_main -->|"reads for saving"| node_conversation
node_main -->|"writes transcript"| node_transcript

click node_main "https://github.com/camdenleibee/miniharness/blob/main/src/main.cpp"
click node_scriptfile "https://github.com/camdenleibee/miniharness/blob/main/scripts/greeting.script"
click node_harness "https://github.com/camdenleibee/miniharness/blob/main/src/harness.cpp"
click node_scanner "https://github.com/camdenleibee/miniharness/blob/main/src/sentinel_scanner.cpp"
click node_conversation "https://github.com/camdenleibee/miniharness/blob/main/src/conversation.cpp"
click node_message "https://github.com/camdenleibee/miniharness/blob/main/include/core/message.h"
click node_modelapi "https://github.com/camdenleibee/miniharness/blob/main/include/model/model_client.h"
click node_tokensink "https://github.com/camdenleibee/miniharness/blob/main/include/model/model_client.h"
click node_scripted "https://github.com/camdenleibee/miniharness/blob/main/src/scripted_client.cpp"
click node_replay "https://github.com/camdenleibee/miniharness/blob/main/src/replay_client.cpp"
click node_modelbase "https://github.com/camdenleibee/miniharness/blob/main/src/model_client.cpp"

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_main,node_user toneBlue
class node_harness toneAmber
class node_scanner,node_conversation,node_message toneMint
class node_modelapi,node_tokensink,node_scripted,node_replay,node_modelbase toneRose
class node_stdin,node_stdout,node_transcript toneIndigo
class node_scriptfile toneTeal
```

## Components

### CLI

- [CLI entry](https://github.com/camdenleibee/miniharness/blob/main/src/main.cpp): `src/main.cpp`

### Conversation runtime

- [Turn orchestrator](https://github.com/camdenleibee/miniharness/blob/main/src/harness.cpp): `src/harness.cpp`

### Conversation core

- [Sentinel scanner](https://github.com/camdenleibee/miniharness/blob/main/src/sentinel_scanner.cpp): `src/sentinel_scanner.cpp`
- [Conversation store](https://github.com/camdenleibee/miniharness/blob/main/src/conversation.cpp): `src/conversation.cpp`
- [Role message](https://github.com/camdenleibee/miniharness/blob/main/include/core/message.h): `include/core/message.h`

### Model clients

- [Model interface](https://github.com/camdenleibee/miniharness/blob/main/include/model/model_client.h): `include/model/model_client.h`
- [Token sink](https://github.com/camdenleibee/miniharness/blob/main/include/model/model_client.h): `include/model/model_client.h`
- [Scripted client](https://github.com/camdenleibee/miniharness/blob/main/src/scripted_client.cpp): `src/scripted_client.cpp`
- [Replay client](https://github.com/camdenleibee/miniharness/blob/main/src/replay_client.cpp): `src/replay_client.cpp`
- [Response collector](https://github.com/camdenleibee/miniharness/blob/main/src/model_client.cpp): `src/model_client.cpp`

### Other components

- **Terminal user**
- **Terminal input**
- **Terminal output**
- [Script file](https://github.com/camdenleibee/miniharness/blob/main/scripts/greeting.script): `scripts/greeting.script`
- **Transcript file**

## Connections

- Terminal user → Terminal input: enters text
- CLI entry → Terminal input: reads through
- CLI entry → Scripted client: constructs
- Script file → Scripted client: loads script
- CLI entry → Turn orchestrator: starts
- Turn orchestrator → Terminal input: reads turns
- Turn orchestrator → Terminal output: writes replies
- Turn orchestrator → Model interface: requests replies
- Scripted client → Model interface: implements
- Replay client → Model interface: implements
- Model interface → Token sink: streams chunks
- Scripted client → Token sink: emits chunks
- Replay client → Token sink: emits chunks
- Response collector → Token sink: collects chunks
- Response collector → Role message: returns reply
- Turn orchestrator → Conversation store: maintains turns
- Turn orchestrator → Sentinel scanner: checks sentinel
- Conversation store → Role message: stores
- CLI entry → Conversation store: reads for saving
- CLI entry → Transcript file: writes transcript
