# iokuru/brio architecture

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

- Interactive diagram: https://gitdiagram.com/iokuru/brio
- Repository: https://github.com/iokuru/brio

## Overview

Brio is a command-line grader for AI-agent trajectories: users provide a YAML ruleset and one or more JSONL traces, and Brio evaluates the recorded steps and reports pass/fail results. The main path runs through CLI input handling, specification parsing and rule construction, trace parsing, rule evaluation, and formatted reporting. The README also documents starter-spec generation and text, JSON, and GitHub output. The sampled source shows the CLI orchestration and core rule/trace behavior; report-format details are represented from documented capabilities.

Main entry points: [`cmd/brio/main.go`](https://github.com/iokuru/brio/blob/main/cmd/brio/main.go) (Brio CLI), [`internal/spec/spec.go`](https://github.com/iokuru/brio/blob/main/internal/spec/spec.go) (Rule construction), [`internal/trace/trace.go`](https://github.com/iokuru/brio/blob/main/internal/trace/trace.go) (Trace parsing), [`internal/rules/required_calls.go`](https://github.com/iokuru/brio/blob/main/internal/rules/required_calls.go) (Required calls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["Brio CLI<br/>[main.go]"]
end

subgraph group_inputs["Specification and traces"]
  node_spec["Spec parsing<br/>[spec.go]"]
  node_trace["Trace parsing<br/>[trace.go]"]
end

subgraph group_grading["Trajectory grading"]
  node_rulebuild["Rule construction<br/>[spec.go]"]
  node_required["Required calls<br/>[required_calls.go]"]
  node_forbidden["Forbidden calls<br/>[forbidden_calls.go]"]
  node_order["Call ordering<br/>[order.go]"]
  node_subsequence["Call subsequence<br/>[subsequence.go]"]
  node_argmatch["Argument matching<br/>[arg_match.go]"]
  node_limits["Execution limits<br/>[limits.go]"]
end

subgraph group_reporting["Results"]
  node_report["Report formatting"]
end

node_user(("CLI user"))
node_specfile["YAML specification"]
node_tracefile["JSONL trace"]
node_output["Grade output"]

node_user -->|"runs commands"| node_cli
node_cli -->|"writes starter spec"| node_specfile
node_cli -->|"loads spec"| node_spec
node_specfile -->|"provides YAML"| node_spec
node_cli -->|"parses traces"| node_trace
node_tracefile -->|"provides JSONL"| node_trace
node_spec -->|"builds rules"| node_rulebuild
node_cli -->|"requests rules"| node_rulebuild
node_rulebuild -->|"constructs"| node_required
node_rulebuild -->|"constructs"| node_forbidden
node_rulebuild -->|"constructs"| node_order
node_rulebuild -->|"constructs"| node_subsequence
node_rulebuild -->|"constructs"| node_argmatch
node_rulebuild -->|"constructs"| node_limits
node_cli -->|"checks trace"| node_required
node_cli -->|"checks trace"| node_forbidden
node_cli -->|"checks trace"| node_order
node_cli -->|"checks trace"| node_subsequence
node_cli -->|"checks trace"| node_argmatch
node_cli -->|"checks trace"| node_limits
node_required -->|"reads tool calls"| node_trace
node_forbidden -->|"reads tool calls"| node_trace
node_order -->|"reads tool calls"| node_trace
node_subsequence -->|"reads tool calls"| node_trace
node_argmatch -->|"reads arguments"| node_trace
node_limits -->|"reads steps"| node_trace
node_cli -->|"creates reports"| node_report
node_report -->|"renders results"| node_output

click node_cli "https://github.com/iokuru/brio/blob/main/cmd/brio/main.go"
click node_spec "https://github.com/iokuru/brio/blob/main/internal/spec/spec.go"
click node_trace "https://github.com/iokuru/brio/blob/main/internal/trace/trace.go"
click node_rulebuild "https://github.com/iokuru/brio/blob/main/internal/spec/spec.go"
click node_required "https://github.com/iokuru/brio/blob/main/internal/rules/required_calls.go"
click node_forbidden "https://github.com/iokuru/brio/blob/main/internal/rules/forbidden_calls.go"
click node_order "https://github.com/iokuru/brio/blob/main/internal/rules/order.go"
click node_subsequence "https://github.com/iokuru/brio/blob/main/internal/rules/subsequence.go"
click node_argmatch "https://github.com/iokuru/brio/blob/main/internal/rules/arg_match.go"
click node_limits "https://github.com/iokuru/brio/blob/main/internal/rules/limits.go"
click node_report "https://github.com/iokuru/brio/tree/main/internal/report"

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_user toneBlue
class node_spec,node_trace toneAmber
class node_rulebuild,node_required,node_forbidden,node_order,node_subsequence,node_argmatch,node_limits toneMint
class node_report toneRose
class node_specfile,node_tracefile,node_output toneIndigo
```

## Components

### CLI workflow

- [Brio CLI](https://github.com/iokuru/brio/blob/main/cmd/brio/main.go): `cmd/brio/main.go`

### Specification and traces

- [Spec parsing](https://github.com/iokuru/brio/blob/main/internal/spec/spec.go): `internal/spec/spec.go`
- [Trace parsing](https://github.com/iokuru/brio/blob/main/internal/trace/trace.go): `internal/trace/trace.go`

### Trajectory grading

- [Rule construction](https://github.com/iokuru/brio/blob/main/internal/spec/spec.go): `internal/spec/spec.go`
- [Required calls](https://github.com/iokuru/brio/blob/main/internal/rules/required_calls.go): `internal/rules/required_calls.go`
- [Forbidden calls](https://github.com/iokuru/brio/blob/main/internal/rules/forbidden_calls.go): `internal/rules/forbidden_calls.go`
- [Call ordering](https://github.com/iokuru/brio/blob/main/internal/rules/order.go): `internal/rules/order.go`
- [Call subsequence](https://github.com/iokuru/brio/blob/main/internal/rules/subsequence.go): `internal/rules/subsequence.go`
- [Argument matching](https://github.com/iokuru/brio/blob/main/internal/rules/arg_match.go): `internal/rules/arg_match.go`
- [Execution limits](https://github.com/iokuru/brio/blob/main/internal/rules/limits.go): `internal/rules/limits.go`

### Results

- [Report formatting](https://github.com/iokuru/brio/tree/main/internal/report): `internal/report`

### Other components

- **CLI user**
- **YAML specification**
- **JSONL trace**
- **Grade output**

## Connections

- CLI user → Brio CLI: runs commands (evidence: `README.md`)
- Brio CLI → YAML specification: writes starter spec (evidence: `cmd/brio/main.go`)
- Brio CLI → Spec parsing: loads spec (evidence: `cmd/brio/main.go`)
- YAML specification → Spec parsing: provides YAML (evidence: `README.md`)
- Brio CLI → Trace parsing: parses traces (evidence: `cmd/brio/main.go`)
- JSONL trace → Trace parsing: provides JSONL (evidence: `README.md`)
- Spec parsing → Rule construction: builds rules (evidence: `internal/spec/spec.go`)
- Brio CLI → Rule construction: requests rules (evidence: `cmd/brio/main.go`)
- Rule construction → Required calls: constructs (evidence: `internal/spec/spec.go`)
- Rule construction → Forbidden calls: constructs (evidence: `internal/spec/spec.go`)
- Rule construction → Call ordering: constructs (evidence: `internal/spec/spec.go`)
- Rule construction → Call subsequence: constructs (evidence: `internal/spec/spec.go`)
- Rule construction → Argument matching: constructs (evidence: `internal/spec/spec.go`)
- Rule construction → Execution limits: constructs (evidence: `internal/spec/spec.go`)
- Brio CLI → Required calls: checks trace (evidence: `cmd/brio/main.go`)
- Brio CLI → Forbidden calls: checks trace (evidence: `cmd/brio/main.go`)
- Brio CLI → Call ordering: checks trace (evidence: `cmd/brio/main.go`)
- Brio CLI → Call subsequence: checks trace (evidence: `cmd/brio/main.go`)
- Brio CLI → Argument matching: checks trace (evidence: `cmd/brio/main.go`)
- Brio CLI → Execution limits: checks trace (evidence: `cmd/brio/main.go`)
- Required calls → Trace parsing: reads tool calls (evidence: `internal/rules/required_calls.go`)
- Forbidden calls → Trace parsing: reads tool calls (evidence: `internal/rules/forbidden_calls.go`)
- Call ordering → Trace parsing: reads tool calls (evidence: `internal/rules/order.go`)
- Call subsequence → Trace parsing: reads tool calls (evidence: `internal/rules/subsequence.go`)
- Argument matching → Trace parsing: reads arguments (evidence: `internal/rules/arg_match.go`)
- Execution limits → Trace parsing: reads steps (evidence: `internal/rules/limits.go`)
- Brio CLI → Report formatting: creates reports (evidence: `cmd/brio/main.go`)
- Report formatting → Grade output: renders results (evidence: `README.md`)
