# towa0/bruise architecture

> Architecture diagram of the GitHub repository towa0/bruise, 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/towa0/bruise
- Repository: https://github.com/towa0/bruise

## Overview

bruise is a TypeScript/Vitest change-testing tool: it scopes a Git diff, then checks changed code with Stryker mutation testing and fault-injected outgoing calls, within a preset time budget, before reporting findings. Its plan mode estimates work without running checks; baseline support filters known findings, and test-only changes use import-graph scoping. Edges follow shown imports and documented capabilities; several internal implementations were not excerpted, so those relationships are omitted rather than inferred.

Main entry points: [`src/orchestrator/index.ts`](https://github.com/towa0/bruise/blob/main/src/orchestrator/index.ts) (Run orchestration), [`src/cli/run.ts`](https://github.com/towa0/bruise/blob/main/src/cli/run.ts) (Run command), [`src/fault-injector/inject.ts`](https://github.com/towa0/bruise/blob/main/src/fault-injector/inject.ts) (Fault injection), [`src/plan/index.ts`](https://github.com/towa0/bruise/blob/main/src/plan/index.ts) (Plan estimation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and planning"]
  node_cli["CLI commands<br/>[main.ts]"]
  node_runcli["Run command<br/>[run.ts]"]
  node_planner["Run orchestration<br/>[index.ts]"]
  node_plan["Plan estimation<br/>[index.ts]"]
  node_mutantcount["Mutant counting<br/>[mutants.ts]"]
end

subgraph group_scope["Change scoping"]
  node_diffscope["Diff scoping<br/>[index.ts]"]
  node_testscope["Test-only scoping<br/>[index.ts]"]
end

subgraph group_checks["Test checks"]
  node_stryker["Mutation testing<br/>[index.ts]"]
  node_faults["Fault test runs<br/>[run.ts]"]
  node_recon["Fault reconstruction<br/>[inject-session.ts]"]
  node_protocol["Fault protocol<br/>[protocol.ts]"]
  node_callsite["Call-site capture<br/>[call-capture.ts]"]
  node_injection["Fault injection<br/>[inject.ts]"]
  node_interception["HTTP interception<br/>[interception.ts]"]
  node_responseuse["Response-use tracking<br/>[response-use.ts]"]
  node_malformed["Malformed JSON fault<br/>[malformed-json.ts]"]
end

subgraph group_findings["Findings and state"]
  node_baseline[("Baseline storage<br/>[file.ts]")]
  node_severity["Severity ranking<br/>[prior.ts]"]
end

subgraph group_output["Progress and reporting"]
  node_events["Progress events<br/>[events.ts]"]
  node_reporter["Report rendering<br/>[text.ts]"]
  node_terminal["Terminal display<br/>[theme.ts]"]
end

node_user(("Engineer"))

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches"| node_runcli
node_runcli -->|"runs checks"| node_planner
node_runcli -->|"requests plan"| node_plan
node_runcli -->|"renders report"| node_reporter
node_runcli -->|"shows progress"| node_events
node_planner -->|"scopes changes"| node_diffscope
node_planner -->|"loads baseline"| node_baseline
node_planner -->|"scopes test-only"| node_testscope
node_planner -->|"runs mutation checks"| node_stryker
node_planner -->|"runs fault checks"| node_faults
node_plan -->|"scopes changes"| node_diffscope
node_plan -->|"checks baseline"| node_baseline
node_plan -->|"counts mutants"| node_mutantcount
node_faults -->|"reconstructs faults"| node_recon
node_recon -->|"uses protocol"| node_protocol
node_recon -->|"captures calls"| node_callsite
node_recon -->|"installs faults"| node_injection
node_injection -->|"installs capture"| node_callsite
node_injection -->|"watches responses"| node_responseuse
node_injection -->|"uses paths"| node_interception
node_injection -->|"supports fault kind"| node_malformed
node_planner -->|"emits progress"| node_events
node_reporter -->|"summarizes baseline"| node_baseline
node_reporter -->|"uses severity"| node_severity
node_terminal -->|"uses severity theme"| node_severity
node_events -->|"renders progress"| node_terminal

click node_cli "https://github.com/towa0/bruise/blob/main/src/cli/main.ts"
click node_runcli "https://github.com/towa0/bruise/blob/main/src/cli/run.ts"
click node_planner "https://github.com/towa0/bruise/blob/main/src/orchestrator/index.ts"
click node_plan "https://github.com/towa0/bruise/blob/main/src/plan/index.ts"
click node_mutantcount "https://github.com/towa0/bruise/blob/main/src/plan/mutants.ts"
click node_diffscope "https://github.com/towa0/bruise/blob/main/src/diff-scoper/index.ts"
click node_testscope "https://github.com/towa0/bruise/blob/main/src/test-only-scoper/index.ts"
click node_stryker "https://github.com/towa0/bruise/blob/main/src/stryker-adapter/index.ts"
click node_faults "https://github.com/towa0/bruise/blob/main/src/fault-run/run.ts"
click node_recon "https://github.com/towa0/bruise/blob/main/src/fault-recon/inject-session.ts"
click node_protocol "https://github.com/towa0/bruise/blob/main/src/fault-recon/protocol.ts"
click node_callsite "https://github.com/towa0/bruise/blob/main/src/fault-injector/call-capture.ts"
click node_injection "https://github.com/towa0/bruise/blob/main/src/fault-injector/inject.ts"
click node_interception "https://github.com/towa0/bruise/blob/main/src/fault-injector/interception.ts"
click node_responseuse "https://github.com/towa0/bruise/blob/main/src/fault-injector/response-use.ts"
click node_malformed "https://github.com/towa0/bruise/blob/main/src/fault-injector/malformed-json.ts"
click node_baseline "https://github.com/towa0/bruise/blob/main/src/baseline/file.ts"
click node_severity "https://github.com/towa0/bruise/blob/main/src/severity/prior.ts"
click node_events "https://github.com/towa0/bruise/blob/main/src/progress/events.ts"
click node_reporter "https://github.com/towa0/bruise/blob/main/src/reporter/text.ts"
click node_terminal "https://github.com/towa0/bruise/blob/main/src/terminal/theme.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_cli,node_runcli,node_planner,node_plan,node_mutantcount toneBlue
class node_diffscope,node_testscope toneAmber
class node_stryker,node_faults,node_recon,node_protocol,node_callsite,node_injection,node_interception,node_responseuse,node_malformed toneMint
class node_baseline,node_severity toneRose
class node_events,node_reporter,node_terminal,node_user toneIndigo
```

## Components

### CLI and planning

- [CLI commands](https://github.com/towa0/bruise/blob/main/src/cli/main.ts): `src/cli/main.ts`
- [Run command](https://github.com/towa0/bruise/blob/main/src/cli/run.ts): `src/cli/run.ts`
- [Run orchestration](https://github.com/towa0/bruise/blob/main/src/orchestrator/index.ts): `src/orchestrator/index.ts`
- [Plan estimation](https://github.com/towa0/bruise/blob/main/src/plan/index.ts): `src/plan/index.ts`
- [Mutant counting](https://github.com/towa0/bruise/blob/main/src/plan/mutants.ts): `src/plan/mutants.ts`

### Change scoping

- [Diff scoping](https://github.com/towa0/bruise/blob/main/src/diff-scoper/index.ts): `src/diff-scoper/index.ts`
- [Test-only scoping](https://github.com/towa0/bruise/blob/main/src/test-only-scoper/index.ts): `src/test-only-scoper/index.ts`

### Test checks

- [Mutation testing](https://github.com/towa0/bruise/blob/main/src/stryker-adapter/index.ts): `src/stryker-adapter/index.ts`
- [Fault test runs](https://github.com/towa0/bruise/blob/main/src/fault-run/run.ts): `src/fault-run/run.ts`
- [Fault reconstruction](https://github.com/towa0/bruise/blob/main/src/fault-recon/inject-session.ts): `src/fault-recon/inject-session.ts`
- [Fault protocol](https://github.com/towa0/bruise/blob/main/src/fault-recon/protocol.ts): `src/fault-recon/protocol.ts`
- [Call-site capture](https://github.com/towa0/bruise/blob/main/src/fault-injector/call-capture.ts): `src/fault-injector/call-capture.ts`
- [Fault injection](https://github.com/towa0/bruise/blob/main/src/fault-injector/inject.ts): `src/fault-injector/inject.ts`
- [HTTP interception](https://github.com/towa0/bruise/blob/main/src/fault-injector/interception.ts): `src/fault-injector/interception.ts`
- [Response-use tracking](https://github.com/towa0/bruise/blob/main/src/fault-injector/response-use.ts): `src/fault-injector/response-use.ts`
- [Malformed JSON fault](https://github.com/towa0/bruise/blob/main/src/fault-injector/malformed-json.ts): `src/fault-injector/malformed-json.ts`

### Findings and state

- [Baseline storage](https://github.com/towa0/bruise/blob/main/src/baseline/file.ts): `src/baseline/file.ts`
- [Severity ranking](https://github.com/towa0/bruise/blob/main/src/severity/prior.ts): `src/severity/prior.ts`

### Progress and reporting

- [Progress events](https://github.com/towa0/bruise/blob/main/src/progress/events.ts): `src/progress/events.ts`
- [Report rendering](https://github.com/towa0/bruise/blob/main/src/reporter/text.ts): `src/reporter/text.ts`
- [Terminal display](https://github.com/towa0/bruise/blob/main/src/terminal/theme.ts): `src/terminal/theme.ts`

### Other components

- **Engineer**

## Connections

- Engineer → CLI commands: runs commands (evidence: `src/cli/main.ts`)
- CLI commands → Run command: dispatches (evidence: `src/cli/main.ts`)
- Run command → Run orchestration: runs checks (evidence: `src/cli/run.ts`)
- Run command → Plan estimation: requests plan (evidence: `src/cli/run.ts`)
- Run command → Report rendering: renders report (evidence: `src/cli/run.ts`)
- Run command → Progress events: shows progress (evidence: `src/cli/run.ts`)
- Run orchestration → Diff scoping: scopes changes (evidence: `src/orchestrator/index.ts`)
- Run orchestration → Baseline storage: loads baseline (evidence: `src/orchestrator/index.ts`)
- Run orchestration → Test-only scoping: scopes test-only (evidence: `src/orchestrator/index.ts`)
- Run orchestration → Mutation testing: runs mutation checks (evidence: `src/orchestrator/index.ts`)
- Run orchestration → Fault test runs: runs fault checks (evidence: `src/orchestrator/index.ts`)
- Plan estimation → Diff scoping: scopes changes (evidence: `src/plan/index.ts`)
- Plan estimation → Baseline storage: checks baseline (evidence: `src/plan/index.ts`)
- Plan estimation → Mutant counting: counts mutants (evidence: `src/plan/index.ts`)
- Fault test runs → Fault reconstruction: reconstructs faults
- Fault reconstruction → Fault protocol: uses protocol (evidence: `src/fault-recon/inject-session.ts`)
- Fault reconstruction → Call-site capture: captures calls (evidence: `src/fault-recon/inject-session.ts`)
- Fault reconstruction → Fault injection: installs faults (evidence: `src/fault-recon/inject-session.ts`)
- Fault injection → Call-site capture: installs capture (evidence: `src/fault-injector/inject.ts`)
- Fault injection → Response-use tracking: watches responses (evidence: `src/fault-injector/inject.ts`)
- Fault injection → HTTP interception: uses paths (evidence: `src/fault-injector/inject.ts`)
- Fault injection → Malformed JSON fault: supports fault kind (evidence: `src/fault-injector/injectors.ts`)
- Run orchestration → Progress events: emits progress (evidence: `src/orchestrator/index.ts`)
- Report rendering → Baseline storage: summarizes baseline (evidence: `src/reporter/text.ts`)
- Report rendering → Severity ranking: uses severity (evidence: `src/reporter/text.ts`)
- Terminal display → Severity ranking: uses severity theme (evidence: `src/terminal/theme.ts`)
- Progress events → Terminal display: renders progress (evidence: `src/progress/render.ts`)
