# fudandisc/maser architecture

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

- Interactive diagram: https://gitdiagram.com/fudandisc/maser
- Repository: https://github.com/fudandisc/maser

## Overview

MASER generates legal-interaction dialogues by configuring a case scenario, creating plaintiff and lawyer agents, and running their exchanges under supervisory checks; the resulting histories support synthetic legal-scene data. Model engines provide interchangeable LLM backends. The README also describes MILE’s interaction and goal evaluation phases. The graph reflects documented and excerpted relationships; some runtime wiring is dynamic or unsampled, so those links are omitted or marked unverified. Training is represented only as a documented capability, not as a delivery pipeline.

Main entry points: [`src/legal/law_fact.py`](https://github.com/fudandisc/maser/blob/main/src/legal/law_fact.py) (Case Scenario), [`src/agents/supervisor.py`](https://github.com/fudandisc/maser/blob/main/src/agents/supervisor.py) (Dialogue Supervisor), [`src/agents/lawyer_fact.py`](https://github.com/fudandisc/maser/blob/main/src/agents/lawyer_fact.py) (Lawyer Agent), [`src/evaluation/src_eval/eval.py`](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/eval.py) (Interaction Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Legal Simulation"]
  node_entry["Run Entry<br/>[run_law_fact.py]"]
  node_configuration["Scenario Configuration"]
  node_scenario["Case Scenario<br/>[law_fact.py]"]
  node_registry["Class Registry<br/>[register.py]"]
end

subgraph group_agents["Interaction Agents"]
  node_agentbase["Agent Memory<br/>[base_agent.py]"]
  node_plaintiff["Plaintiff Agent<br/>[plaintiff_fact.py]"]
  node_lawyer["Lawyer Agent<br/>[lawyer_fact.py]"]
  node_supervisor["Dialogue Supervisor<br/>[supervisor.py]"]
  node_guidance["Dialogue Guidance<br/>[guider.py]"]
  node_style["Speech Styling<br/>[styler.py]"]
  node_factperturb["Fact Perturbation<br/>[tamperer.py]"]
end

subgraph group_models["Model Engines"]
  node_enginebase["Engine Interface<br/>[base_engine.py]"]
  node_engines["LLM Backends"]
end

subgraph group_evaluation["MILE Evaluation"]
  node_interactioneval["Interaction Evaluation<br/>[eval.py]"]
  node_goaleval["Goal Evaluation<br/>[eval.py]"]
  node_evalprompts["Evaluation Prompts<br/>[prompts.py]"]
  node_evalutils["Evaluation Utilities<br/>[utils.py]"]
  node_evalrunner["Evaluation Runner<br/>[main.py]"]
  node_miledata["MILE Evaluation Data"]
end

subgraph group_data["Data and Training"]
  node_profiles["Case Profiles<br/>[legal.json]"]
  node_history["Dialog Histories<br/>[law_fact.py]"]
  node_synthlaw["SynthLaw Dataset<br/>[legal.json]"]
  node_training["Fine-tuning Configs"]
end

node_user(("Researcher"))

node_user -->|"runs"| node_entry
node_entry -->|"loads options"| node_configuration
node_entry -->|"starts scenario"| node_scenario
node_configuration -->|"resolves classes"| node_registry
node_scenario -->|"loads cases"| node_profiles
node_scenario -->|"queries"| node_plaintiff
node_scenario -.->|"conducts interview"| node_lawyer
node_scenario -->|"requests review"| node_supervisor
node_scenario -.->|"records dialogue"| node_history
node_plaintiff -->|"inherits"| node_agentbase
node_lawyer -->|"inherits"| node_agentbase
node_supervisor -->|"inherits"| node_agentbase
node_supervisor -->|"uses guidance"| node_guidance
node_supervisor -->|"applies style"| node_style
node_supervisor -->|"perturbs facts"| node_factperturb
node_lawyer -->|"resolves engine"| node_registry
node_supervisor -->|"resolves engine"| node_registry
node_registry -.->|"selects backend"| node_engines
node_engines -->|"implements"| node_enginebase
node_lawyer -->|"requests responses"| node_engines
node_supervisor -.->|"requests responses"| node_engines
node_scenario -.->|"generates dialogues"| node_synthlaw
node_synthlaw -->|"supports fine-tuning"| node_training
node_evalrunner -->|"runs evaluation"| node_interactioneval
node_evalrunner -->|"runs evaluation"| node_goaleval
node_interactioneval -->|"formats prompts"| node_evalprompts
node_interactioneval -->|"requests scoring"| node_evalutils
node_goaleval -->|"formats prompts"| node_evalprompts
node_goaleval -->|"requests scoring"| node_evalutils
node_evalrunner -.->|"evaluates against"| node_miledata
node_history -.->|"scores dialogues"| node_interactioneval
node_history -.->|"scores goals"| node_goaleval

click node_entry "https://github.com/fudandisc/maser/blob/main/src/run_law_fact.py"
click node_configuration "https://github.com/fudandisc/maser/blob/main/src/utils/options_law_fact.py"
click node_scenario "https://github.com/fudandisc/maser/blob/main/src/legal/law_fact.py"
click node_profiles "https://github.com/fudandisc/maser/blob/main/src/data/legal.json"
click node_history "https://github.com/fudandisc/maser/blob/main/src/legal/law_fact.py"
click node_agentbase "https://github.com/fudandisc/maser/blob/main/src/agents/base_agent.py"
click node_plaintiff "https://github.com/fudandisc/maser/blob/main/src/agents/plaintiff_fact.py"
click node_lawyer "https://github.com/fudandisc/maser/blob/main/src/agents/lawyer_fact.py"
click node_supervisor "https://github.com/fudandisc/maser/blob/main/src/agents/supervisor.py"
click node_guidance "https://github.com/fudandisc/maser/blob/main/src/utils/guider.py"
click node_style "https://github.com/fudandisc/maser/blob/main/src/utils/styler.py"
click node_factperturb "https://github.com/fudandisc/maser/blob/main/src/utils/tamperer.py"
click node_registry "https://github.com/fudandisc/maser/blob/main/src/utils/register.py"
click node_enginebase "https://github.com/fudandisc/maser/blob/main/src/engine/base_engine.py"
click node_engines "https://github.com/fudandisc/maser/tree/main/src/engine"
click node_interactioneval "https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/eval.py"
click node_goaleval "https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/eval.py"
click node_evalprompts "https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/prompts.py"
click node_evalutils "https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/utils.py"
click node_evalrunner "https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/main.py"
click node_synthlaw "https://github.com/fudandisc/maser/blob/main/src/data/legal.json"
click node_training "https://github.com/fudandisc/maser/tree/main/src/train"
click node_miledata "https://github.com/fudandisc/maser/tree/main/src/evaluation/data"

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_entry,node_configuration,node_scenario,node_registry toneBlue
class node_agentbase,node_plaintiff,node_lawyer,node_supervisor,node_guidance,node_style,node_factperturb toneAmber
class node_enginebase,node_engines toneMint
class node_interactioneval,node_goaleval,node_evalprompts,node_evalutils,node_evalrunner,node_miledata toneRose
class node_profiles,node_history,node_synthlaw,node_training,node_user toneIndigo
```

## Components

### Legal Simulation

- [Run Entry](https://github.com/fudandisc/maser/blob/main/src/run_law_fact.py): `src/run_law_fact.py`
- [Scenario Configuration](https://github.com/fudandisc/maser/blob/main/src/utils/options_law_fact.py): `src/utils/options_law_fact.py`
- [Case Scenario](https://github.com/fudandisc/maser/blob/main/src/legal/law_fact.py): `src/legal/law_fact.py`
- [Class Registry](https://github.com/fudandisc/maser/blob/main/src/utils/register.py): `src/utils/register.py`

### Interaction Agents

- [Agent Memory](https://github.com/fudandisc/maser/blob/main/src/agents/base_agent.py): `src/agents/base_agent.py`
- [Plaintiff Agent](https://github.com/fudandisc/maser/blob/main/src/agents/plaintiff_fact.py): `src/agents/plaintiff_fact.py`
- [Lawyer Agent](https://github.com/fudandisc/maser/blob/main/src/agents/lawyer_fact.py): `src/agents/lawyer_fact.py`
- [Dialogue Supervisor](https://github.com/fudandisc/maser/blob/main/src/agents/supervisor.py): `src/agents/supervisor.py`
- [Dialogue Guidance](https://github.com/fudandisc/maser/blob/main/src/utils/guider.py): `src/utils/guider.py`
- [Speech Styling](https://github.com/fudandisc/maser/blob/main/src/utils/styler.py): `src/utils/styler.py`
- [Fact Perturbation](https://github.com/fudandisc/maser/blob/main/src/utils/tamperer.py): `src/utils/tamperer.py`

### Model Engines

- [Engine Interface](https://github.com/fudandisc/maser/blob/main/src/engine/base_engine.py): `src/engine/base_engine.py`
- [LLM Backends](https://github.com/fudandisc/maser/tree/main/src/engine): `src/engine`

### MILE Evaluation

- [Interaction Evaluation](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/eval.py): `src/evaluation/src_eval/eval.py`
- [Goal Evaluation](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/eval.py): `src/evaluation/src_eval/eval.py`
- [Evaluation Prompts](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/prompts.py): `src/evaluation/src_eval/prompts.py`
- [Evaluation Utilities](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/utils.py): `src/evaluation/src_eval/utils.py`
- [Evaluation Runner](https://github.com/fudandisc/maser/blob/main/src/evaluation/src_eval/main.py): `src/evaluation/src_eval/main.py`
- [MILE Evaluation Data](https://github.com/fudandisc/maser/tree/main/src/evaluation/data): `src/evaluation/data`

### Data and Training

- [Case Profiles](https://github.com/fudandisc/maser/blob/main/src/data/legal.json): `src/data/legal.json`
- [Dialog Histories](https://github.com/fudandisc/maser/blob/main/src/legal/law_fact.py): `src/legal/law_fact.py`
- [SynthLaw Dataset](https://github.com/fudandisc/maser/blob/main/src/data/legal.json): `src/data/legal.json`
- [Fine-tuning Configs](https://github.com/fudandisc/maser/tree/main/src/train): `src/train`

### Other components

- **Researcher**

## Connections

- Researcher → Run Entry: runs (evidence: `README.md`)
- Run Entry → Scenario Configuration: loads options (evidence: `src/run_law_fact.py`)
- Run Entry → Case Scenario: starts scenario (evidence: `src/run_law_fact.py`)
- Scenario Configuration → Class Registry: resolves classes (evidence: `src/utils/options_law_fact.py`)
- Case Scenario → Case Profiles: loads cases (evidence: `src/legal/law_fact.py`)
- Case Scenario → Plaintiff Agent: queries (evidence: `src/legal/law_fact.py`)
- Case Scenario → Lawyer Agent: conducts interview
- Case Scenario → Dialogue Supervisor: requests review (evidence: `src/legal/law_fact.py`)
- Case Scenario → Dialog Histories: records dialogue (evidence: `src/legal/law_fact.py`)
- Plaintiff Agent → Agent Memory: inherits (evidence: `src/agents/plaintiff_fact.py`)
- Lawyer Agent → Agent Memory: inherits (evidence: `src/agents/lawyer_fact.py`)
- Dialogue Supervisor → Agent Memory: inherits (evidence: `src/agents/supervisor.py`)
- Dialogue Supervisor → Dialogue Guidance: uses guidance (evidence: `src/agents/supervisor.py`)
- Dialogue Supervisor → Speech Styling: applies style (evidence: `src/agents/supervisor.py`)
- Dialogue Supervisor → Fact Perturbation: perturbs facts (evidence: `src/agents/supervisor.py`)
- Lawyer Agent → Class Registry: resolves engine (evidence: `src/agents/lawyer_fact.py`)
- Dialogue Supervisor → Class Registry: resolves engine (evidence: `src/agents/supervisor.py`)
- Class Registry → LLM Backends: selects backend (evidence: `src/engine/base_engine.py`)
- LLM Backends → Engine Interface: implements (evidence: `src/engine/LawLLM.py`)
- Lawyer Agent → LLM Backends: requests responses (evidence: `src/agents/lawyer_fact.py`)
- Dialogue Supervisor → LLM Backends: requests responses
- Case Scenario → SynthLaw Dataset: generates dialogues (evidence: `README.md`)
- SynthLaw Dataset → Fine-tuning Configs: supports fine-tuning (evidence: `README.md`)
- Evaluation Runner → Interaction Evaluation: runs evaluation (evidence: `src/evaluation/src_eval/main.py`)
- Evaluation Runner → Goal Evaluation: runs evaluation (evidence: `src/evaluation/src_eval/main.py`)
- Interaction Evaluation → Evaluation Prompts: formats prompts (evidence: `src/evaluation/src_eval/eval.py`)
- Interaction Evaluation → Evaluation Utilities: requests scoring (evidence: `src/evaluation/src_eval/eval.py`)
- Goal Evaluation → Evaluation Prompts: formats prompts (evidence: `src/evaluation/src_eval/eval.py`)
- Goal Evaluation → Evaluation Utilities: requests scoring (evidence: `src/evaluation/src_eval/eval.py`)
- Evaluation Runner → MILE Evaluation Data: evaluates against (evidence: `README.md`)
- Dialog Histories → Interaction Evaluation: scores dialogues (evidence: `README.md`)
- Dialog Histories → Goal Evaluation: scores goals (evidence: `README.md`)
