# von12549/guard architecture

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

- Interactive diagram: https://gitdiagram.com/von12549/guard
- Repository: https://github.com/von12549/guard

## Overview

V4 Guards is a self-contained, profile-driven repository inspection and governance package. Its primary workflow is a user invoking the Host to run a Bootstrap, Analysis, Pre, or Post stage against a read-only Target, with selected modules producing evidence under EvidenceRoot; the Web Companion offers a local UI over Host operations. Separate Host commands support contract validation, queries, state/reset, Profile discovery and promotion, Plan governance, target-trust authorization, and application previews. The graph follows documented capabilities and shown command dispatch; unsampled runtime details are omitted rather than inferred.

Main entry points: [`core/host/V4.Guards.Host/Program.cs`](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/Program.cs) (CLI Host), [`core/host/V4.Guards.Host/StageRuntime.cs`](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/StageRuntime.cs) (Stage execution), [`integrations/web/V4.Guards.WebCompanion/Program.cs`](https://github.com/von12549/guard/blob/main/integrations/web/V4.Guards.WebCompanion/Program.cs) (Companion server), [`core/host/V4.Guards.Host/ContractRuntime.cs`](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ContractRuntime.cs) (Contract validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Interfaces"]
  node_webui["Web Companion UI<br/>[app.js]"]
  node_webserver["Companion server<br/>[Program.cs]"]
  node_host["CLI Host<br/>[Program.cs]"]
end

subgraph group_execution["Inspection runtime"]
  node_stages["Stage execution<br/>[StageRuntime.cs]"]
  node_modules["Registered modules"]
  node_state[("State and reset<br/>[StateRuntime.cs]")]
  node_evidence["Stage evidence"]
end

subgraph group_authority["Local authority"]
  node_contracts["Contract validation<br/>[ContractRuntime.cs]"]
  node_profiles["Profile authority<br/>[ProfileRuntime.cs]"]
  node_application["Application previews"]
  node_queries["Read queries<br/>[QueryRuntime.cs]"]
  node_package["Package authorities"]
end

subgraph group_governance["Governance"]
  node_plans["Plan governance<br/>[PlanRuntime.cs]"]
  node_trust["Target trust"]
end

subgraph group_distribution["Distribution"]
  node_distribution["Install and compose"]
end

node_user(("User"))
node_external_target[("Inspected repository")]
node_powershell["PowerShell runtime"]

node_user -->|"invokes commands"| node_host
node_user -->|"uses locally"| node_webui
node_webui -->|"sends requests"| node_webserver
node_webserver -->|"invokes queries"| node_host
node_host -->|"dispatches"| node_contracts
node_host -->|"dispatches"| node_state
node_host -->|"dispatches"| node_stages
node_host -->|"dispatches"| node_plans
node_host -->|"dispatches"| node_queries
node_host -->|"dispatches"| node_profiles
node_host -->|"dispatches"| node_application
node_host -->|"dispatches"| node_trust
node_stages -.->|"executes selected"| node_modules
node_stages -->|"uses state"| node_state
node_stages -.->|"writes results"| node_evidence
node_stages -->|"inspects"| node_external_target
node_profiles -->|"validates via"| node_contracts
node_queries -->|"reads plan catalog"| node_plans
node_application -->|"uses projections"| node_queries
node_trust -->|"validates plan sets"| node_plans
node_contracts -->|"reads schemas"| node_package
node_distribution -.->|"installs host"| node_host
node_distribution -.->|"packages companion"| node_webserver
node_host -->|"runs validation"| node_powershell

click node_webui "https://github.com/von12549/guard/blob/main/integrations/web/V4.Guards.WebCompanion/wwwroot/app.js"
click node_webserver "https://github.com/von12549/guard/blob/main/integrations/web/V4.Guards.WebCompanion/Program.cs"
click node_host "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/Program.cs"
click node_stages "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/StageRuntime.cs"
click node_modules "https://github.com/von12549/guard/tree/main/modules"
click node_state "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/StateRuntime.cs"
click node_contracts "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ContractRuntime.cs"
click node_profiles "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ProfileRuntime.cs"
click node_application "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ApplicationRuntime.cs"
click node_queries "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/QueryRuntime.cs"
click node_plans "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/PlanRuntime.cs"
click node_trust "https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/TargetTrustRuntime.cs"
click node_evidence "https://github.com/von12549/guard/tree/main/core"
click node_package "https://github.com/von12549/guard/tree/main/core/contracts"
click node_distribution "https://github.com/von12549/guard/tree/main/core/distribution"

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_webui,node_webserver,node_host,node_user toneBlue
class node_stages,node_modules,node_state,node_evidence,node_external_target toneAmber
class node_contracts,node_profiles,node_application,node_queries,node_package toneMint
class node_plans,node_trust toneRose
class node_distribution,node_powershell toneIndigo
```

## Components

### Interfaces

- [Web Companion UI](https://github.com/von12549/guard/blob/main/integrations/web/V4.Guards.WebCompanion/wwwroot/app.js): `integrations/web/V4.Guards.WebCompanion/wwwroot/app.js`
- [Companion server](https://github.com/von12549/guard/blob/main/integrations/web/V4.Guards.WebCompanion/Program.cs): `integrations/web/V4.Guards.WebCompanion/Program.cs`
- [CLI Host](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/Program.cs): `core/host/V4.Guards.Host/Program.cs`

### Inspection runtime

- [Stage execution](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/StageRuntime.cs): `core/host/V4.Guards.Host/StageRuntime.cs`
- [Registered modules](https://github.com/von12549/guard/tree/main/modules): `modules`
- [State and reset](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/StateRuntime.cs): `core/host/V4.Guards.Host/StateRuntime.cs`
- [Stage evidence](https://github.com/von12549/guard/tree/main/core): `core`

### Local authority

- [Contract validation](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ContractRuntime.cs): `core/host/V4.Guards.Host/ContractRuntime.cs`
- [Profile authority](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ProfileRuntime.cs): `core/host/V4.Guards.Host/ProfileRuntime.cs`
- [Application previews](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/ApplicationRuntime.cs): `core/host/V4.Guards.Host/ApplicationRuntime.cs`
- [Read queries](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/QueryRuntime.cs): `core/host/V4.Guards.Host/QueryRuntime.cs`
- [Package authorities](https://github.com/von12549/guard/tree/main/core/contracts): `core/contracts`

### Governance

- [Plan governance](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/PlanRuntime.cs): `core/host/V4.Guards.Host/PlanRuntime.cs`
- [Target trust](https://github.com/von12549/guard/blob/main/core/host/V4.Guards.Host/TargetTrustRuntime.cs): `core/host/V4.Guards.Host/TargetTrustRuntime.cs`

### Distribution

- [Install and compose](https://github.com/von12549/guard/tree/main/core/distribution): `core/distribution`

### Other components

- **User**
- **Inspected repository**
- **PowerShell runtime**

## Connections

- User → CLI Host: invokes commands (evidence: `README.md`)
- User → Web Companion UI: uses locally (evidence: `README.md`)
- Web Companion UI → Companion server: sends requests (evidence: `integrations/web/V4.Guards.WebCompanion/wwwroot/app.js`)
- Companion server → CLI Host: invokes queries (evidence: `integrations/web/V4.Guards.WebCompanion/Program.cs`)
- CLI Host → Contract validation: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → State and reset: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Stage execution: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Plan governance: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Read queries: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Profile authority: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Application previews: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- CLI Host → Target trust: dispatches (evidence: `core/host/V4.Guards.Host/Program.cs`)
- Stage execution → Registered modules: executes selected
- Stage execution → State and reset: uses state (evidence: `core/host/V4.Guards.Host/StageRuntime.cs`)
- Stage execution → Stage evidence: writes results (evidence: `core/host/V4.Guards.Host/StageRuntime.cs`)
- Stage execution → Inspected repository: inspects (evidence: `README.md`)
- Profile authority → Contract validation: validates via (evidence: `core/host/V4.Guards.Host/ProfileRuntime.cs`)
- Read queries → Plan governance: reads plan catalog (evidence: `core/host/V4.Guards.Host/QueryRuntime.cs`)
- Application previews → Read queries: uses projections (evidence: `core/host/V4.Guards.Host/ApplicationRuntime.cs`)
- Target trust → Plan governance: validates plan sets (evidence: `core/host/V4.Guards.Host/TargetTrustRuntime.cs`)
- Contract validation → Package authorities: reads schemas (evidence: `core/host/V4.Guards.Host/ContractRuntime.cs`)
- Install and compose → CLI Host: installs host (evidence: `README.md`)
- Install and compose → Companion server: packages companion (evidence: `README.md`)
- CLI Host → PowerShell runtime: runs validation
