# muck-or-mack/mas-optimiser architecture

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

- Interactive diagram: https://gitdiagram.com/muck-or-mack/mas-optimiser
- Repository: https://github.com/muck-or-mack/mas-optimiser

## Overview

mas-optimiser improves an LLM agent harness through repeated EnterpriseOps-Gym evaluations and a statistical acceptance gate. The main workflow runs a baseline, analyzes training results, proposes harness changes, evaluates candidates on validation tasks, and opens the test set at the end. CLI commands also support standalone evaluations, scoring, comparisons, calibration, reporting, model status, and self-hosted model servers. Some benchmark modules are represented by their exact source paths, but their internal behavior was not sampled; edges are limited to documented or indexed relationships.

Main entry points: [`src/mas_optimiser/cli.py`](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/cli.py) (Command router), [`src/mas_optimiser/benchmarks/enterpriseops/runner.py`](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/runner.py) (Task evaluation runner), [`src/mas_optimiser/evolve/loop.py`](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/loop.py) (Experiment orchestrator), [`src/mas_optimiser/stats/compare.py`](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/compare.py) (Evaluation comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and model access"]
  node_cli["Command router<br/>[cli.py]"]
  node_model_config["Model configuration"]
  node_server["Model server control<br/>[server.py]"]
  node_status["Model and run status<br/>[status.py]"]
end

subgraph group_benchmark["EnterpriseOps evaluation"]
  node_agent["Default agent harness<br/>[agent.py]"]
  node_runner["Task evaluation runner<br/>[runner.py]"]
  node_checks["SQL check scoring<br/>[checks.py]"]
  node_diagnosis["Failure diagnosis<br/>[diagnosis.py]"]
  node_rebuild["Attempt reconstruction<br/>[rebuild.py]"]
  node_rescore["Evaluation rescoring<br/>[rescore.py]"]
  node_database[("Benchmark database")]
end

subgraph group_evolution["Harness improvement loop"]
  node_evolve["Experiment orchestrator<br/>[loop.py]"]
  node_search_models["Search-role model calls<br/>[models.py]"]
  node_experiment_report["Experiment reporting<br/>[report.py]"]
end

subgraph group_statistics["Statistical analysis"]
  node_outcomes["Task outcomes<br/>[outcomes.py]"]
  node_gate["Acceptance tests<br/>[gate.py]"]
  node_budget["Error budget<br/>[budget.py]"]
  node_compare["Evaluation comparison<br/>[compare.py]"]
  node_calibrate["Gate calibration<br/>[calibrate.py]"]
  node_figures["Statistical figures<br/>[figures.py]"]
  node_markdown["Report formatting<br/>[markdown.py]"]
end

node_user(("Engineer"))

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches runs"| node_runner
node_cli -->|"dispatches experiments"| node_evolve
node_cli -->|"dispatches reports"| node_experiment_report
node_cli -->|"dispatches comparisons"| node_compare
node_cli -->|"dispatches calibration"| node_calibrate
node_cli -->|"dispatches server"| node_server
node_cli -->|"dispatches status"| node_status
node_runner -.->|"evaluates harness"| node_agent
node_runner -->|"checks final state"| node_database
node_runner -.->|"scores tasks"| node_checks
node_checks -.->|"explains failures"| node_diagnosis
node_rebuild -.->|"reconstructs state"| node_database
node_rescore -.->|"recalculates scores"| node_checks
node_evolve -->|"runs evaluations"| node_runner
node_evolve -->|"requests proposals"| node_search_models
node_evolve -->|"allocates error"| node_budget
node_evolve -->|"gates candidates"| node_gate
node_evolve -->|"writes results"| node_experiment_report
node_search_models -->|"loads model settings"| node_model_config
node_outcomes -.->|"reads evaluations"| node_runner
node_compare -->|"pairs task scores"| node_outcomes
node_compare -->|"tests gain"| node_gate
node_compare -.->|"draws comparison"| node_figures
node_compare -.->|"formats output"| node_markdown
node_calibrate -->|"checks gate behavior"| node_gate
node_calibrate -.->|"draws calibration"| node_figures
node_calibrate -.->|"formats output"| node_markdown
node_experiment_report -->|"uses statistical plots"| node_figures
node_experiment_report -->|"reads gate results"| node_gate
node_experiment_report -->|"reads outcomes"| node_outcomes
node_status -->|"reads run usage"| node_runner
node_server -->|"reads server settings"| node_model_config

click node_cli "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/cli.py"
click node_model_config "https://github.com/muck-or-mack/mas-optimiser/tree/main/configs/models"
click node_server "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/server.py"
click node_status "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/status.py"
click node_agent "https://github.com/muck-or-mack/mas-optimiser/blob/main/harnesses/default/agent.py"
click node_runner "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/runner.py"
click node_checks "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/checks.py"
click node_diagnosis "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/diagnosis.py"
click node_rebuild "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/rebuild.py"
click node_rescore "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/rescore.py"
click node_database "https://github.com/muck-or-mack/mas-optimiser/tree/main/data/schemas"
click node_evolve "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/loop.py"
click node_search_models "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/models.py"
click node_experiment_report "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/report.py"
click node_outcomes "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/outcomes.py"
click node_gate "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/gate.py"
click node_budget "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/budget.py"
click node_compare "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/compare.py"
click node_calibrate "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/calibrate.py"
click node_figures "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/figures.py"
click node_markdown "https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/markdown.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_cli,node_model_config,node_server,node_status toneBlue
class node_agent,node_runner,node_checks,node_diagnosis,node_rebuild,node_rescore,node_database toneAmber
class node_evolve,node_search_models,node_experiment_report toneMint
class node_outcomes,node_gate,node_budget,node_compare,node_calibrate,node_figures,node_markdown toneRose
class node_user toneIndigo
```

## Components

### CLI and model access

- [Command router](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/cli.py): `src/mas_optimiser/cli.py`
- [Model configuration](https://github.com/muck-or-mack/mas-optimiser/tree/main/configs/models): `configs/models`
- [Model server control](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/server.py): `src/mas_optimiser/server.py`
- [Model and run status](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/status.py): `src/mas_optimiser/status.py`

### EnterpriseOps evaluation

- [Default agent harness](https://github.com/muck-or-mack/mas-optimiser/blob/main/harnesses/default/agent.py): `harnesses/default/agent.py`
- [Task evaluation runner](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/runner.py): `src/mas_optimiser/benchmarks/enterpriseops/runner.py`
- [SQL check scoring](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/checks.py): `src/mas_optimiser/benchmarks/enterpriseops/checks.py`
- [Failure diagnosis](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/diagnosis.py): `src/mas_optimiser/benchmarks/enterpriseops/diagnosis.py`
- [Attempt reconstruction](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/rebuild.py): `src/mas_optimiser/benchmarks/enterpriseops/rebuild.py`
- [Evaluation rescoring](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/benchmarks/enterpriseops/rescore.py): `src/mas_optimiser/benchmarks/enterpriseops/rescore.py`
- [Benchmark database](https://github.com/muck-or-mack/mas-optimiser/tree/main/data/schemas): `data/schemas`

### Harness improvement loop

- [Experiment orchestrator](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/loop.py): `src/mas_optimiser/evolve/loop.py`
- [Search-role model calls](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/models.py): `src/mas_optimiser/evolve/models.py`
- [Experiment reporting](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/evolve/report.py): `src/mas_optimiser/evolve/report.py`

### Statistical analysis

- [Task outcomes](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/outcomes.py): `src/mas_optimiser/stats/outcomes.py`
- [Acceptance tests](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/gate.py): `src/mas_optimiser/stats/gate.py`
- [Error budget](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/budget.py): `src/mas_optimiser/stats/budget.py`
- [Evaluation comparison](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/compare.py): `src/mas_optimiser/stats/compare.py`
- [Gate calibration](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/calibrate.py): `src/mas_optimiser/stats/calibrate.py`
- [Statistical figures](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/stats/figures.py): `src/mas_optimiser/stats/figures.py`
- [Report formatting](https://github.com/muck-or-mack/mas-optimiser/blob/main/src/mas_optimiser/markdown.py): `src/mas_optimiser/markdown.py`

### Other components

- **Engineer**

## Connections

- Engineer → Command router: runs commands (evidence: `src/mas_optimiser/cli.py`)
- Command router → Task evaluation runner: dispatches runs (evidence: `src/mas_optimiser/cli.py`)
- Command router → Experiment orchestrator: dispatches experiments (evidence: `src/mas_optimiser/cli.py`)
- Command router → Experiment reporting: dispatches reports (evidence: `src/mas_optimiser/cli.py`)
- Command router → Evaluation comparison: dispatches comparisons (evidence: `src/mas_optimiser/cli.py`)
- Command router → Gate calibration: dispatches calibration (evidence: `src/mas_optimiser/cli.py`)
- Command router → Model server control: dispatches server (evidence: `src/mas_optimiser/cli.py`)
- Command router → Model and run status: dispatches status (evidence: `src/mas_optimiser/cli.py`)
- Task evaluation runner → Default agent harness: evaluates harness
- Task evaluation runner → Benchmark database: checks final state (evidence: `README.md`)
- Task evaluation runner → SQL check scoring: scores tasks
- SQL check scoring → Failure diagnosis: explains failures
- Attempt reconstruction → Benchmark database: reconstructs state
- Evaluation rescoring → SQL check scoring: recalculates scores
- Experiment orchestrator → Task evaluation runner: runs evaluations (evidence: `src/mas_optimiser/evolve/loop.py`)
- Experiment orchestrator → Search-role model calls: requests proposals (evidence: `src/mas_optimiser/evolve/loop.py`)
- Experiment orchestrator → Error budget: allocates error (evidence: `src/mas_optimiser/evolve/loop.py`)
- Experiment orchestrator → Acceptance tests: gates candidates (evidence: `src/mas_optimiser/evolve/loop.py`)
- Experiment orchestrator → Experiment reporting: writes results (evidence: `src/mas_optimiser/evolve/loop.py`)
- Search-role model calls → Model configuration: loads model settings (evidence: `src/mas_optimiser/evolve/models.py`)
- Task outcomes → Task evaluation runner: reads evaluations
- Evaluation comparison → Task outcomes: pairs task scores (evidence: `src/mas_optimiser/stats/compare.py`)
- Evaluation comparison → Acceptance tests: tests gain (evidence: `src/mas_optimiser/stats/compare.py`)
- Evaluation comparison → Statistical figures: draws comparison (evidence: `src/mas_optimiser/stats/compare.py`)
- Evaluation comparison → Report formatting: formats output (evidence: `src/mas_optimiser/stats/compare.py`)
- Gate calibration → Acceptance tests: checks gate behavior (evidence: `src/mas_optimiser/stats/calibrate.py`)
- Gate calibration → Statistical figures: draws calibration (evidence: `src/mas_optimiser/stats/calibrate.py`)
- Gate calibration → Report formatting: formats output (evidence: `src/mas_optimiser/stats/calibrate.py`)
- Experiment reporting → Statistical figures: uses statistical plots (evidence: `src/mas_optimiser/evolve/report.py`)
- Experiment reporting → Acceptance tests: reads gate results (evidence: `src/mas_optimiser/evolve/report.py`)
- Experiment reporting → Task outcomes: reads outcomes (evidence: `src/mas_optimiser/evolve/report.py`)
- Model and run status → Task evaluation runner: reads run usage (evidence: `src/mas_optimiser/status.py`)
- Model server control → Model configuration: reads server settings (evidence: `src/mas_optimiser/server.py`)
