# samudralaajaykumarrr/delegationproof architecture

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

- Interactive diagram: https://gitdiagram.com/samudralaajaykumarrr/delegationproof
- Repository: https://github.com/samudralaajaykumarrr/delegationproof

## Overview

DelegationProof is an offline CLI that validates a declared delegation model and, on verification, reports violations of applicable authority-safety invariants. The documented workflow runs from a model file through loading and version dispatch, delegation-graph analysis, verification, and deterministic text or JSON output. The graph preserves the distinct checks added across schema versions, including bounded lifecycle exploration for temporal approvals. Source excerpts are partial; some subsystem links rely on the README’s documented architecture and capabilities.

Main entry points: [`cmd/delegationproof/main.go`](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/cmd/delegationproof/main.go) (Command handler), [`internal/report`](https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/report) (Finding contract), [`internal/loader`](https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/loader) (Load and validate), [`internal/graph/graph.go`](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/graph/graph.go) (Delegation graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflow"]
  node_cli["Command handler<br/>[main.go]"]
end

subgraph group_input["Model input"]
  node_loader["Load and validate"]
  node_models["Versioned models"]
  node_limits["Resource bounds<br/>[limits.go]"]
end

subgraph group_analysis["Delegation analysis"]
  node_graph["Delegation graph<br/>[graph.go]"]
  node_explore["Lifecycle BFS<br/>[explore.go]"]
end

subgraph group_checks["Safety checks"]
  node_verify_v1["Authority preservation<br/>[verify.go]"]
  node_verify_v2["Target binding<br/>[verify_v2.go]"]
  node_verify_v3["Requester authorization<br/>[verify_v3.go]"]
  node_verify_v4["Delegation depth<br/>[verify_v4.go]"]
  node_verify_v5["Approval preservation<br/>[verify_v5.go]"]
  node_verify_v6["Temporal approvals<br/>[verify_v6.go]"]
end

subgraph group_output["Findings"]
  node_findings["Finding contract"]
  node_text_render["Text renderer<br/>[text.go]"]
  node_json_render["JSON renderer<br/>[json.go]"]
end

node_user(("CLI user"))
node_model_file["Model JSON"]
node_result["CLI result"]

node_user -->|"invokes"| node_cli
node_user -->|"provides"| node_model_file
node_cli -->|"loads path"| node_loader
node_loader -->|"reads"| node_model_file
node_loader -->|"checks bounds"| node_limits
node_loader -->|"decodes model"| node_models
node_loader -->|"checks acyclicity"| node_graph
node_loader -->|"returns document"| node_cli
node_cli -->|"dispatches v1"| node_verify_v1
node_cli -->|"dispatches v2"| node_verify_v2
node_cli -->|"dispatches v3"| node_verify_v3
node_cli -->|"dispatches v4"| node_verify_v4
node_cli -->|"dispatches v5"| node_verify_v5
node_cli -->|"dispatches v6"| node_verify_v6
node_verify_v1 -->|"sorts and traces"| node_graph
node_verify_v2 -->|"sorts and traces"| node_graph
node_verify_v3 -->|"sorts and traces"| node_graph
node_verify_v4 -->|"sorts and traces"| node_graph
node_verify_v5 -->|"sorts and traces"| node_graph
node_verify_v6 -->|"sorts and traces"| node_graph
node_verify_v6 -->|"checks lifecycle"| node_explore
node_verify_v1 -->|"creates findings"| node_findings
node_verify_v2 -->|"creates findings"| node_findings
node_verify_v3 -->|"creates findings"| node_findings
node_verify_v4 -->|"creates findings"| node_findings
node_verify_v5 -->|"creates findings"| node_findings
node_verify_v6 -->|"creates findings"| node_findings
node_cli -->|"renders text"| node_text_render
node_cli -->|"renders JSON"| node_json_render
node_findings -->|"formats findings"| node_text_render
node_findings -->|"encodes findings"| node_json_render
node_cli -->|"writes output"| node_result
node_result -->|"reports outcome"| node_user

click node_cli "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/cmd/delegationproof/main.go"
click node_loader "https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/loader"
click node_models "https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/model"
click node_limits "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/limits/limits.go"
click node_graph "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/graph/graph.go"
click node_verify_v1 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify.go"
click node_verify_v2 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v2.go"
click node_verify_v3 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v3.go"
click node_verify_v4 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v4.go"
click node_verify_v5 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v5.go"
click node_verify_v6 "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v6.go"
click node_explore "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/explore/explore.go"
click node_findings "https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/report"
click node_text_render "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/report/text.go"
click node_json_render "https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/report/json.go"

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_loader,node_models,node_limits toneAmber
class node_graph,node_explore toneMint
class node_verify_v1,node_verify_v2,node_verify_v3,node_verify_v4,node_verify_v5,node_verify_v6 toneRose
class node_findings,node_text_render,node_json_render,node_model_file,node_result toneIndigo
```

## Components

### CLI workflow

- [Command handler](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/cmd/delegationproof/main.go): `cmd/delegationproof/main.go`

### Model input

- [Load and validate](https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/loader): `internal/loader`
- [Versioned models](https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/model): `internal/model`
- [Resource bounds](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/limits/limits.go): `internal/limits/limits.go`

### Delegation analysis

- [Delegation graph](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/graph/graph.go): `internal/graph/graph.go`
- [Lifecycle BFS](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/explore/explore.go): `internal/explore/explore.go`

### Safety checks

- [Authority preservation](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify.go): `internal/verify/verify.go`
- [Target binding](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v2.go): `internal/verify/verify_v2.go`
- [Requester authorization](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v3.go): `internal/verify/verify_v3.go`
- [Delegation depth](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v4.go): `internal/verify/verify_v4.go`
- [Approval preservation](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v5.go): `internal/verify/verify_v5.go`
- [Temporal approvals](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/verify/verify_v6.go): `internal/verify/verify_v6.go`

### Findings

- [Finding contract](https://github.com/samudralaajaykumarrr/delegationproof/tree/main/internal/report): `internal/report`
- [Text renderer](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/report/text.go): `internal/report/text.go`
- [JSON renderer](https://github.com/samudralaajaykumarrr/delegationproof/blob/main/internal/report/json.go): `internal/report/json.go`

### Other components

- **CLI user**
- **Model JSON**
- **CLI result**

## Connections

- CLI user → Command handler: invokes
- CLI user → Model JSON: provides
- Command handler → Load and validate: loads path
- Load and validate → Model JSON: reads
- Load and validate → Resource bounds: checks bounds
- Load and validate → Versioned models: decodes model
- Load and validate → Delegation graph: checks acyclicity
- Load and validate → Command handler: returns document
- Command handler → Authority preservation: dispatches v1
- Command handler → Target binding: dispatches v2
- Command handler → Requester authorization: dispatches v3
- Command handler → Delegation depth: dispatches v4
- Command handler → Approval preservation: dispatches v5
- Command handler → Temporal approvals: dispatches v6
- Authority preservation → Delegation graph: sorts and traces
- Target binding → Delegation graph: sorts and traces
- Requester authorization → Delegation graph: sorts and traces
- Delegation depth → Delegation graph: sorts and traces
- Approval preservation → Delegation graph: sorts and traces
- Temporal approvals → Delegation graph: sorts and traces
- Temporal approvals → Lifecycle BFS: checks lifecycle
- Authority preservation → Finding contract: creates findings
- Target binding → Finding contract: creates findings
- Requester authorization → Finding contract: creates findings
- Delegation depth → Finding contract: creates findings
- Approval preservation → Finding contract: creates findings
- Temporal approvals → Finding contract: creates findings
- Command handler → Text renderer: renders text
- Command handler → JSON renderer: renders JSON
- Finding contract → Text renderer: formats findings
- Finding contract → JSON renderer: encodes findings
- Command handler → CLI result: writes output
- CLI result → CLI user: reports outcome
