# abdumateen/loadlens architecture

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

- Interactive diagram: https://gitdiagram.com/abdumateen/loadlens
- Repository: https://github.com/abdumateen/loadlens

## Overview

LoadLens turns evidence bundles into deterministic comprehension-load scores and rendering decisions. Its main workflow is to normalize a bundle (optionally from a local Git revision range), extract features, score with stored coefficients, and apply calibrated rendering policy. A separate Stage 1 workflow mines reverted commits and matched controls, fits and evaluates a model, then reports a gate verdict. The README also documents Stage 2 study run/analyze commands; that implementation is not sampled, so its internal relationships are omitted.

Main entry points: [`loadlens/cli.py`](https://github.com/abdumateen/loadlens/blob/main/loadlens/cli.py) (Command-line interface), [`loadlens/policy.py`](https://github.com/abdumateen/loadlens/blob/main/loadlens/policy.py) (Rendering policy), [`loadlens/adapters/git_hook.py`](https://github.com/abdumateen/loadlens/blob/main/loadlens/adapters/git_hook.py) (Git hook adapter), [`loadlens/features.py`](https://github.com/abdumateen/loadlens/blob/main/loadlens/features.py) (Feature extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Bundle ingestion"]
  node_cli["Command-line interface<br/>[cli.py]"]
  node_git_adapter["Git hook adapter<br/>[git_hook.py]"]
  node_bundle_schema["Evidence bundle schema<br/>[schema.py]"]
end

subgraph group_scoring["Scoring and rendering"]
  node_features["Feature extraction<br/>[features.py]"]
  node_estimator["Load estimator<br/>[estimator.py]"]
  node_policy["Rendering policy<br/>[policy.py]"]
end

subgraph group_calibration["Stage 1 calibration"]
  node_stage1_mine["History mining<br/>[mine.py]"]
  node_stage1_fit["Model fitting<br/>[fit.py]"]
  node_stage1_report["Gate report<br/>[report.py]"]
end

subgraph group_study["Study tooling"]
  node_study_tools["Study run and analysis"]
end

node_reviewer(("Reviewer or operator"))
node_git_source[("Local Git repository")]

node_reviewer -->|"runs commands"| node_cli
node_cli -->|"requests bundle"| node_git_adapter
node_git_source -->|"provides revisions"| node_git_adapter
node_git_adapter -->|"builds bundle"| node_bundle_schema
node_cli -->|"reads bundle"| node_bundle_schema
node_cli -->|"extracts features"| node_features
node_features -->|"reads fields"| node_bundle_schema
node_cli -->|"scores bundle"| node_estimator
node_estimator -->|"uses vector"| node_features
node_cli -->|"requests decision"| node_policy
node_policy -->|"uses load"| node_estimator
node_policy -->|"renders decision"| node_reviewer
node_cli -->|"starts mining"| node_stage1_mine
node_cli -->|"starts fitting"| node_stage1_fit
node_cli -->|"requests report"| node_stage1_report
node_stage1_mine -.->|"supplies observations"| node_stage1_fit
node_stage1_fit -->|"supplies fit result"| node_stage1_report
node_cli -.->|"runs analysis"| node_study_tools

click node_cli "https://github.com/abdumateen/loadlens/blob/main/loadlens/cli.py"
click node_git_adapter "https://github.com/abdumateen/loadlens/blob/main/loadlens/adapters/git_hook.py"
click node_bundle_schema "https://github.com/abdumateen/loadlens/blob/main/loadlens/schema.py"
click node_features "https://github.com/abdumateen/loadlens/blob/main/loadlens/features.py"
click node_estimator "https://github.com/abdumateen/loadlens/blob/main/loadlens/estimator.py"
click node_policy "https://github.com/abdumateen/loadlens/blob/main/loadlens/policy.py"
click node_stage1_mine "https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/mine.py"
click node_stage1_fit "https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/fit.py"
click node_stage1_report "https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/report.py"
click node_study_tools "https://github.com/abdumateen/loadlens/tree/main/loadlens/study"

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_git_adapter,node_bundle_schema,node_reviewer toneBlue
class node_features,node_estimator,node_policy,node_git_source toneAmber
class node_stage1_mine,node_stage1_fit,node_stage1_report toneMint
class node_study_tools toneRose
```

## Components

### Bundle ingestion

- [Command-line interface](https://github.com/abdumateen/loadlens/blob/main/loadlens/cli.py): `loadlens/cli.py`
- [Git hook adapter](https://github.com/abdumateen/loadlens/blob/main/loadlens/adapters/git_hook.py): `loadlens/adapters/git_hook.py`
- [Evidence bundle schema](https://github.com/abdumateen/loadlens/blob/main/loadlens/schema.py): `loadlens/schema.py`

### Scoring and rendering

- [Feature extraction](https://github.com/abdumateen/loadlens/blob/main/loadlens/features.py): `loadlens/features.py`
- [Load estimator](https://github.com/abdumateen/loadlens/blob/main/loadlens/estimator.py): `loadlens/estimator.py`
- [Rendering policy](https://github.com/abdumateen/loadlens/blob/main/loadlens/policy.py): `loadlens/policy.py`

### Stage 1 calibration

- [History mining](https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/mine.py): `loadlens/stage1/mine.py`
- [Model fitting](https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/fit.py): `loadlens/stage1/fit.py`
- [Gate report](https://github.com/abdumateen/loadlens/blob/main/loadlens/stage1/report.py): `loadlens/stage1/report.py`

### Study tooling

- [Study run and analysis](https://github.com/abdumateen/loadlens/tree/main/loadlens/study): `loadlens/study`

### Other components

- **Reviewer or operator**
- **Local Git repository**

## Connections

- Reviewer or operator → Command-line interface: runs commands (evidence: `README.md`)
- Command-line interface → Git hook adapter: requests bundle (evidence: `loadlens/cli.py`)
- Local Git repository → Git hook adapter: provides revisions (evidence: `README.md`)
- Git hook adapter → Evidence bundle schema: builds bundle (evidence: `loadlens/adapters/git_hook.py`)
- Command-line interface → Evidence bundle schema: reads bundle (evidence: `loadlens/cli.py`)
- Command-line interface → Feature extraction: extracts features (evidence: `loadlens/cli.py`)
- Feature extraction → Evidence bundle schema: reads fields (evidence: `loadlens/features.py`)
- Command-line interface → Load estimator: scores bundle (evidence: `loadlens/cli.py`)
- Load estimator → Feature extraction: uses vector (evidence: `loadlens/estimator.py`)
- Command-line interface → Rendering policy: requests decision (evidence: `loadlens/cli.py`)
- Rendering policy → Load estimator: uses load (evidence: `loadlens/policy.py`)
- Rendering policy → Reviewer or operator: renders decision (evidence: `README.md`)
- Command-line interface → History mining: starts mining (evidence: `loadlens/cli.py`)
- Command-line interface → Model fitting: starts fitting (evidence: `loadlens/cli.py`)
- Command-line interface → Gate report: requests report (evidence: `loadlens/cli.py`)
- History mining → Model fitting: supplies observations
- Model fitting → Gate report: supplies fit result (evidence: `loadlens/stage1/report.py`)
- Command-line interface → Study run and analysis: runs analysis (evidence: `README.md`)
