# krishna-shetty29/verified-auth architecture

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

- Interactive diagram: https://gitdiagram.com/krishna-shetty29/verified-auth
- Repository: https://github.com/krishna-shetty29/verified-auth

## Overview

Verified Auth is a small authorization-policy compiler and verifier. Its main workflow accepts a policy and request through the CLI, parses and type-checks the policy, then executes it; verification instead searches for violations with Z3, validates and replays any counterexample through the runtime, and reports or exports the confirmed result. The graph preserves the documented compiler stages and both security rules. Relationships are based on the README and sampled source; unsampled internals are not inferred beyond those documented stages.

Main entry points: [`src/verified_auth/cli.py`](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/cli.py) (CLI commands), [`src/verified_auth/verifier.py`](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/verifier.py) (Rule verifier), [`src/verified_auth/models.py`](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/models.py) (Request models), [`src/verified_auth/reporting.py`](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/reporting.py) (Verification reporting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Command interface"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_entry["Module entry<br/>[__main__.py]"]
end

subgraph group_frontend["Policy front end"]
  node_parser["Policy parser<br/>[parser.py]"]
  node_grammar["Policy grammar<br/>[grammar.lark]"]
  node_ast["Policy AST<br/>[ast_nodes.py]"]
  node_typecheck["Name and type checking<br/>[typecheck.py]"]
  node_ir["Typed policy IR<br/>[ir.py]"]
end

subgraph group_execution["Authorization runtime"]
  node_models["Request models<br/>[models.py]"]
  node_runtime["Runtime compiler<br/>[runtime.py]"]
end

subgraph group_verification["Security verification"]
  node_symbolic["Symbolic compiler<br/>[symbolic.py]"]
  node_verifier["Rule verifier<br/>[verifier.py]"]
  node_reporting["Verification reporting<br/>[reporting.py]"]
  node_counterexample["Counterexample JSON"]
end

node_operator(("CLI user"))

node_operator -->|"runs module"| node_entry
node_entry -->|"calls CLI"| node_cli
node_operator -->|"submits commands"| node_cli
node_cli -->|"parses policy"| node_parser
node_parser -->|"loads grammar"| node_grammar
node_parser -->|"builds AST"| node_ast
node_cli -->|"lowers policy"| node_typecheck
node_typecheck -->|"reads AST"| node_ast
node_typecheck -->|"produces typed IR"| node_ir
node_cli -->|"loads request"| node_models
node_cli -->|"executes policy"| node_runtime
node_runtime -->|"compiles IR"| node_ir
node_runtime -->|"reads request"| node_models
node_cli -->|"selects rule"| node_verifier
node_verifier -->|"builds solver expression"| node_symbolic
node_symbolic -->|"translates IR"| node_ir
node_symbolic -->|"uses domain values"| node_models
node_verifier -->|"replays counterexample"| node_runtime
node_verifier -->|"validates candidate"| node_models
node_cli -->|"formats result"| node_reporting
node_reporting -->|"confirms result"| node_verifier
node_reporting -->|"serializes request"| node_models
node_reporting -->|"writes JSON"| node_counterexample
node_cli -->|"exports confirmed result"| node_counterexample

click node_cli "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/cli.py"
click node_entry "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/__main__.py"
click node_parser "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/parser.py"
click node_grammar "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/grammar.lark"
click node_ast "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/ast_nodes.py"
click node_typecheck "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/typecheck.py"
click node_ir "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/ir.py"
click node_models "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/models.py"
click node_runtime "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/runtime.py"
click node_symbolic "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/symbolic.py"
click node_verifier "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/verifier.py"
click node_reporting "https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/reporting.py"

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_entry,node_operator toneBlue
class node_parser,node_grammar,node_ast,node_typecheck,node_ir toneAmber
class node_models,node_runtime toneMint
class node_symbolic,node_verifier,node_reporting,node_counterexample toneRose
```

## Components

### Command interface

- [CLI commands](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/cli.py): `src/verified_auth/cli.py`
- [Module entry](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/__main__.py): `src/verified_auth/__main__.py`

### Policy front end

- [Policy parser](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/parser.py): `src/verified_auth/parser.py`
- [Policy grammar](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/grammar.lark): `src/verified_auth/grammar.lark`
- [Policy AST](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/ast_nodes.py): `src/verified_auth/ast_nodes.py`
- [Name and type checking](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/typecheck.py): `src/verified_auth/typecheck.py`
- [Typed policy IR](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/ir.py): `src/verified_auth/ir.py`

### Authorization runtime

- [Request models](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/models.py): `src/verified_auth/models.py`
- [Runtime compiler](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/runtime.py): `src/verified_auth/runtime.py`

### Security verification

- [Symbolic compiler](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/symbolic.py): `src/verified_auth/symbolic.py`
- [Rule verifier](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/verifier.py): `src/verified_auth/verifier.py`
- [Verification reporting](https://github.com/krishna-shetty29/verified-auth/blob/main/src/verified_auth/reporting.py): `src/verified_auth/reporting.py`
- **Counterexample JSON**

### Other components

- **CLI user**

## Connections

- CLI user → Module entry: runs module (evidence: `README.md`)
- Module entry → CLI commands: calls CLI (evidence: `src/verified_auth/__main__.py`)
- CLI user → CLI commands: submits commands (evidence: `README.md`)
- CLI commands → Policy parser: parses policy (evidence: `src/verified_auth/cli.py`)
- Policy parser → Policy grammar: loads grammar (evidence: `src/verified_auth/parser.py`)
- Policy parser → Policy AST: builds AST (evidence: `src/verified_auth/parser.py`)
- CLI commands → Name and type checking: lowers policy (evidence: `src/verified_auth/cli.py`)
- Name and type checking → Policy AST: reads AST (evidence: `src/verified_auth/typecheck.py`)
- Name and type checking → Typed policy IR: produces typed IR (evidence: `src/verified_auth/typecheck.py`)
- CLI commands → Request models: loads request (evidence: `src/verified_auth/cli.py`)
- CLI commands → Runtime compiler: executes policy (evidence: `src/verified_auth/cli.py`)
- Runtime compiler → Typed policy IR: compiles IR (evidence: `src/verified_auth/runtime.py`)
- Runtime compiler → Request models: reads request (evidence: `src/verified_auth/runtime.py`)
- CLI commands → Rule verifier: selects rule (evidence: `src/verified_auth/cli.py`)
- Rule verifier → Symbolic compiler: builds solver expression (evidence: `src/verified_auth/verifier.py`)
- Symbolic compiler → Typed policy IR: translates IR (evidence: `src/verified_auth/symbolic.py`)
- Symbolic compiler → Request models: uses domain values (evidence: `src/verified_auth/symbolic.py`)
- Rule verifier → Runtime compiler: replays counterexample (evidence: `src/verified_auth/verifier.py`)
- Rule verifier → Request models: validates candidate (evidence: `src/verified_auth/verifier.py`)
- CLI commands → Verification reporting: formats result (evidence: `src/verified_auth/cli.py`)
- Verification reporting → Rule verifier: confirms result (evidence: `src/verified_auth/reporting.py`)
- Verification reporting → Request models: serializes request (evidence: `src/verified_auth/reporting.py`)
- Verification reporting → Counterexample JSON: writes JSON (evidence: `src/verified_auth/reporting.py`)
- CLI commands → Counterexample JSON: exports confirmed result (evidence: `src/verified_auth/cli.py`)
