# captainphantasy/flaude-harness architecture

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

- Interactive diagram: https://gitdiagram.com/captainphantasy/flaude-harness
- Repository: https://github.com/captainphantasy/flaude-harness

## Overview

FLAUDE is a Claude Code harness that preserves the session while routing requests to a selected cloud or local model. Its main workflow is launching Claude Code through a loopback router, resolving the active model, translating and forwarding requests, and applying stewardship checks before work is handed back. The graph also includes model management, local-model discovery, certification, and the in-harness picker. Some router internals and plugin behavior are only indexed or documented, so those links cite the index-listed source or README rather than implying unshown call details.

Main entry points: [`src/router/server.ts`](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/server.ts) (Loopback router), [`src/core/registry.ts`](https://github.com/captainphantasy/flaude-harness/blob/main/src/core/registry.ts) (Model registry), [`src/cli/flaude-admin.ts`](https://github.com/captainphantasy/flaude-harness/blob/main/src/cli/flaude-admin.ts) (Admin commands), [`src/launcher/flaude.ts`](https://github.com/captainphantasy/flaude-harness/blob/main/src/launcher/flaude.ts) (Session launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_session["Session and routing"]
  node_launcher["Session launcher<br/>[flaude.ts]"]
  node_router["Loopback router<br/>[server.ts]"]
  node_translator["Protocol translation<br/>[translate.ts]"]
  node_repair["Request repair<br/>[repair.ts]"]
  node_governor["Failover governor<br/>[governor.ts]"]
  node_residency["Residency policy<br/>[residency.ts]"]
end

subgraph group_models["Model management"]
  node_admin["Admin commands<br/>[flaude-admin.ts]"]
  node_certify["Model certification<br/>[certify.ts]"]
  node_local_scan["Local model scan<br/>[scan.ts]"]
  node_gguf["GGUF metadata<br/>[gguf.ts]"]
  node_local_serve["On-demand serving<br/>[serve.ts]"]
end

subgraph group_steward["Steward workflow"]
  node_steward_hooks["Steward hook logic<br/>[hooks.ts]"]
  node_requirements["Requirement checks<br/>[requirements.ts]"]
  node_verification["Work verification<br/>[verify.ts]"]
  node_stop_hook["Stop hook<br/>[stop.py]"]
  node_session_hook["Session start hook<br/>[session_start.py]"]
end

subgraph group_state["State and security"]
  node_registry[("Model registry<br/>[registry.ts]")]
  node_broker["Credential broker<br/>[broker.ts]"]
  node_redaction["Secret redaction<br/>[redact.ts]"]
end

subgraph group_plugin["Model picker"]
  node_plugin_register["Picker registration<br/>[register.tsx]"]
  node_picker["Model picker<br/>[picker.tsx]"]
  node_plugin_core["Picker helpers<br/>[core.ts]"]
end

node_user(("Engineer"))
node_claude["Claude Code"]
node_vendor["Model providers"]

node_user -->|"starts session"| node_launcher
node_launcher -->|"starts router"| node_router
node_launcher -->|"launches"| node_claude
node_claude -->|"sends requests"| node_router
node_router -->|"uses translation"| node_translator
node_router -->|"uses repair"| node_repair
node_router -->|"consults failover"| node_governor
node_router -->|"checks policy"| node_residency
node_router -->|"forwards requests"| node_vendor
node_router -->|"resolves models"| node_registry
node_admin -->|"manages models"| node_registry
node_admin -->|"runs certification"| node_certify
node_certify -->|"saves grade"| node_registry
node_admin -->|"manages local models"| node_local_scan
node_local_scan -->|"reads metadata"| node_gguf
node_local_scan -->|"registers models"| node_registry
node_local_serve -->|"reads model config"| node_registry
node_router -->|"serves local models"| node_local_serve
node_stop_hook -.->|"runs stop checks"| node_steward_hooks
node_session_hook -.->|"starts steward"| node_steward_hooks
node_steward_hooks -->|"reads requirements"| node_requirements
node_steward_hooks -->|"reads transcript"| node_verification
node_plugin_register -->|"registers picker"| node_picker
node_plugin_register -->|"uses helpers"| node_plugin_core
node_picker -->|"formats models"| node_plugin_core
node_admin -->|"loads broker config"| node_broker
node_router -->|"uses redaction"| node_redaction
node_launcher -->|"loads active model"| node_registry

click node_launcher "https://github.com/captainphantasy/flaude-harness/blob/main/src/launcher/flaude.ts"
click node_router "https://github.com/captainphantasy/flaude-harness/blob/main/src/router/server.ts"
click node_translator "https://github.com/captainphantasy/flaude-harness/blob/main/src/router/translate.ts"
click node_repair "https://github.com/captainphantasy/flaude-harness/blob/main/src/router/repair.ts"
click node_governor "https://github.com/captainphantasy/flaude-harness/blob/main/src/router/governor.ts"
click node_residency "https://github.com/captainphantasy/flaude-harness/blob/main/src/router/residency.ts"
click node_admin "https://github.com/captainphantasy/flaude-harness/blob/main/src/cli/flaude-admin.ts"
click node_certify "https://github.com/captainphantasy/flaude-harness/blob/main/src/cli/certify.ts"
click node_local_scan "https://github.com/captainphantasy/flaude-harness/blob/main/src/local/scan.ts"
click node_gguf "https://github.com/captainphantasy/flaude-harness/blob/main/src/local/gguf.ts"
click node_local_serve "https://github.com/captainphantasy/flaude-harness/blob/main/src/local/serve.ts"
click node_steward_hooks "https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/hooks.ts"
click node_requirements "https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/requirements.ts"
click node_verification "https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/verify.ts"
click node_stop_hook "https://github.com/captainphantasy/flaude-harness/blob/main/steward/hooks/stop.py"
click node_session_hook "https://github.com/captainphantasy/flaude-harness/blob/main/steward/hooks/session_start.py"
click node_registry "https://github.com/captainphantasy/flaude-harness/blob/main/src/core/registry.ts"
click node_broker "https://github.com/captainphantasy/flaude-harness/blob/main/src/core/broker.ts"
click node_redaction "https://github.com/captainphantasy/flaude-harness/blob/main/src/core/redact.ts"
click node_plugin_register "https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/register.tsx"
click node_picker "https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/picker.tsx"
click node_plugin_core "https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/core.ts"

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_launcher,node_router,node_translator,node_repair,node_governor,node_residency toneBlue
class node_admin,node_certify,node_local_scan,node_gguf,node_local_serve toneAmber
class node_steward_hooks,node_requirements,node_verification,node_stop_hook,node_session_hook toneMint
class node_registry,node_broker,node_redaction toneRose
class node_plugin_register,node_picker,node_plugin_core,node_user,node_claude,node_vendor toneIndigo
```

## Components

### Session and routing

- [Session launcher](https://github.com/captainphantasy/flaude-harness/blob/main/src/launcher/flaude.ts): `src/launcher/flaude.ts`
- [Loopback router](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/server.ts): `src/router/server.ts`
- [Protocol translation](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/translate.ts): `src/router/translate.ts`
- [Request repair](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/repair.ts): `src/router/repair.ts`
- [Failover governor](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/governor.ts): `src/router/governor.ts`
- [Residency policy](https://github.com/captainphantasy/flaude-harness/blob/main/src/router/residency.ts): `src/router/residency.ts`

### Model management

- [Admin commands](https://github.com/captainphantasy/flaude-harness/blob/main/src/cli/flaude-admin.ts): `src/cli/flaude-admin.ts`
- [Model certification](https://github.com/captainphantasy/flaude-harness/blob/main/src/cli/certify.ts): `src/cli/certify.ts`
- [Local model scan](https://github.com/captainphantasy/flaude-harness/blob/main/src/local/scan.ts): `src/local/scan.ts`
- [GGUF metadata](https://github.com/captainphantasy/flaude-harness/blob/main/src/local/gguf.ts): `src/local/gguf.ts`
- [On-demand serving](https://github.com/captainphantasy/flaude-harness/blob/main/src/local/serve.ts): `src/local/serve.ts`

### Steward workflow

- [Steward hook logic](https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/hooks.ts): `src/steward/hooks.ts`
- [Requirement checks](https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/requirements.ts): `src/steward/requirements.ts`
- [Work verification](https://github.com/captainphantasy/flaude-harness/blob/main/src/steward/verify.ts): `src/steward/verify.ts`
- [Stop hook](https://github.com/captainphantasy/flaude-harness/blob/main/steward/hooks/stop.py): `steward/hooks/stop.py`
- [Session start hook](https://github.com/captainphantasy/flaude-harness/blob/main/steward/hooks/session_start.py): `steward/hooks/session_start.py`

### State and security

- [Model registry](https://github.com/captainphantasy/flaude-harness/blob/main/src/core/registry.ts): `src/core/registry.ts`
- [Credential broker](https://github.com/captainphantasy/flaude-harness/blob/main/src/core/broker.ts): `src/core/broker.ts`
- [Secret redaction](https://github.com/captainphantasy/flaude-harness/blob/main/src/core/redact.ts): `src/core/redact.ts`

### Model picker

- [Picker registration](https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/register.tsx): `plugin/hooks/register.tsx`
- [Model picker](https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/picker.tsx): `plugin/hooks/picker.tsx`
- [Picker helpers](https://github.com/captainphantasy/flaude-harness/blob/main/plugin/hooks/core.ts): `plugin/hooks/core.ts`

### Other components

- **Engineer**
- **Claude Code**
- **Model providers**

## Connections

- Engineer → Session launcher: starts session
- Session launcher → Loopback router: starts router (evidence: `src/launcher/flaude.ts`)
- Session launcher → Claude Code: launches (evidence: `src/launcher/flaude.ts`)
- Claude Code → Loopback router: sends requests
- Loopback router → Protocol translation: uses translation (evidence: `src/router/server.ts`)
- Loopback router → Request repair: uses repair (evidence: `src/router/server.ts`)
- Loopback router → Failover governor: consults failover (evidence: `src/router/server.ts`)
- Loopback router → Residency policy: checks policy (evidence: `src/router/server.ts`)
- Loopback router → Model providers: forwards requests
- Loopback router → Model registry: resolves models (evidence: `src/router/server.ts`)
- Admin commands → Model registry: manages models (evidence: `src/cli/flaude-admin.ts`)
- Admin commands → Model certification: runs certification (evidence: `src/cli/flaude-admin.ts`)
- Model certification → Model registry: saves grade (evidence: `src/cli/certify.ts`)
- Admin commands → Local model scan: manages local models (evidence: `src/cli/flaude-admin.ts`)
- Local model scan → GGUF metadata: reads metadata (evidence: `src/local/scan.ts`)
- Local model scan → Model registry: registers models (evidence: `src/local/scan.ts`)
- On-demand serving → Model registry: reads model config (evidence: `src/local/serve.ts`)
- Loopback router → On-demand serving: serves local models (evidence: `src/router/server.ts`)
- Stop hook → Steward hook logic: runs stop checks
- Session start hook → Steward hook logic: starts steward
- Steward hook logic → Requirement checks: reads requirements (evidence: `src/steward/hooks.ts`)
- Steward hook logic → Work verification: reads transcript (evidence: `src/steward/hooks.ts`)
- Picker registration → Model picker: registers picker (evidence: `plugin/hooks/register.tsx`)
- Picker registration → Picker helpers: uses helpers (evidence: `plugin/hooks/register.tsx`)
- Model picker → Picker helpers: formats models (evidence: `plugin/hooks/picker.tsx`)
- Admin commands → Credential broker: loads broker config (evidence: `src/cli/flaude-admin.ts`)
- Loopback router → Secret redaction: uses redaction (evidence: `src/router/server.ts`)
- Session launcher → Model registry: loads active model (evidence: `src/launcher/flaude.ts`)
