# cubiculum-ai/model-lint architecture

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

- Interactive diagram: https://gitdiagram.com/cubiculum-ai/model-lint
- Repository: https://github.com/cubiculum-ai/model-lint

## Overview

model-lint is a Foundation-only Swift library and CLI for auditing local Hugging Face model bundles and safely repairing defects derivable from their files. The workflow is: select roots and options, discover bundles, inspect headers and configuration, classify findings, then render a report or preview/apply repairs. The graph preserves the separate audit, reporting, and repair responsibilities. Some calls are supported by excerpts; unsampled implementation details are not inferred.

Main entry points: [`Sources/ModelLint/Doctor.swift`](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/Doctor.swift) (Safe repairs), [`Sources/ModelLint/BundleReader.swift`](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/BundleReader.swift) (Bundle discovery), [`Sources/ModelLintCLI/ModelLintCLI.swift`](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLintCLI/ModelLintCLI.swift) (CLI options), [`Sources/ModelLint/LintReport.swift`](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/LintReport.swift) (Report rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["CLI options<br/>[ModelLintCLI.swift]"]
end

subgraph group_audit["Bundle audit"]
  node_reader["Bundle discovery<br/>[BundleReader.swift]"]
  node_checks["Packaging checks"]
  node_alignment["Tensor alignment"]
end

subgraph group_outputs["Reports and repair"]
  node_reports["Report rendering<br/>[LintReport.swift]"]
  node_doctor["Safe repairs<br/>[Doctor.swift]"]
end

node_user(("User"))
node_bundles["Local bundles"]
node_output["Audit or repair output"]

node_user -->|"selects options"| node_cli
node_cli -->|"scans roots"| node_reports
node_reports -->|"reads bundles"| node_reader
node_reader -->|"inspects files"| node_bundles
node_reader -->|"audits weights"| node_checks
node_reader -->|"surveys tensors"| node_alignment
node_cli -->|"requests repairs"| node_doctor
node_doctor -->|"repairs files"| node_bundles
node_doctor -->|"verifies shard data"| node_reader
node_doctor -->|"rewrites shards"| node_alignment
node_reports -->|"renders findings"| node_output
node_doctor -->|"returns repair log"| node_output
node_cli -->|"prints result"| node_output

click node_cli "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLintCLI/ModelLintCLI.swift"
click node_reader "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/BundleReader.swift"
click node_checks "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/ModelBundleAudit.swift"
click node_alignment "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/TensorAlignment.swift"
click node_reports "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/LintReport.swift"
click node_doctor "https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/Doctor.swift"

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_reader,node_checks,node_alignment toneAmber
class node_reports,node_doctor toneMint
class node_bundles,node_output toneIndigo
```

## Components

### CLI entry

- [CLI options](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLintCLI/ModelLintCLI.swift): `Sources/ModelLintCLI/ModelLintCLI.swift`

### Bundle audit

- [Bundle discovery](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/BundleReader.swift): `Sources/ModelLint/BundleReader.swift`
- [Packaging checks](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/ModelBundleAudit.swift): `Sources/ModelLint/ModelBundleAudit.swift`
- [Tensor alignment](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/TensorAlignment.swift): `Sources/ModelLint/TensorAlignment.swift`

### Reports and repair

- [Report rendering](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/LintReport.swift): `Sources/ModelLint/LintReport.swift`
- [Safe repairs](https://github.com/cubiculum-ai/model-lint/blob/main/Sources/ModelLint/Doctor.swift): `Sources/ModelLint/Doctor.swift`

### Other components

- **User**
- **Local bundles**
- **Audit or repair output**

## Connections

- User → CLI options: selects options (evidence: `Sources/ModelLintCLI/ModelLintCLI.swift`)
- CLI options → Report rendering: scans roots (evidence: `Sources/ModelLintCLI/ModelLintCLI.swift`)
- Report rendering → Bundle discovery: reads bundles (evidence: `Sources/ModelLint/LintReport.swift`)
- Bundle discovery → Local bundles: inspects files (evidence: `Sources/ModelLint/BundleReader.swift`)
- Bundle discovery → Packaging checks: audits weights (evidence: `Sources/ModelLint/BundleReader.swift`)
- Bundle discovery → Tensor alignment: surveys tensors (evidence: `Sources/ModelLint/BundleReader.swift`)
- CLI options → Safe repairs: requests repairs (evidence: `Sources/ModelLintCLI/ModelLintCLI.swift`)
- Safe repairs → Local bundles: repairs files (evidence: `Sources/ModelLint/Doctor.swift`)
- Safe repairs → Bundle discovery: verifies shard data (evidence: `Sources/ModelLint/Doctor.swift`)
- Safe repairs → Tensor alignment: rewrites shards (evidence: `Sources/ModelLint/Doctor.swift`)
- Report rendering → Audit or repair output: renders findings (evidence: `Sources/ModelLint/LintReport.swift`)
- Safe repairs → Audit or repair output: returns repair log
- CLI options → Audit or repair output: prints result (evidence: `Sources/ModelLintCLI/ModelLintCLI.swift`)
