# halofyai/halofy architecture

> Architecture diagram of the GitHub repository halofyai/halofy, 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/halofyai/halofy
- Repository: https://github.com/halofyai/halofy

## Overview

Halofy is an organizational access and governance layer for AI-agent context. An agent or operator enters through MCP or HTTP; the server resolves identity, applies access policy, and invokes the kernel, which governs context writes and reads against organizational storage. Connectors feed the same write path, while retrieval drivers are replaceable and ACL-scoped. The control room exposes administration and operational visibility. The graph preserves README-documented capabilities where implementation excerpts are absent; those links cite the README rather than implying unsampled calls.

Main entry points: [`kernel/src/kernel.ts`](https://github.com/halofyai/halofy/blob/main/kernel/src/kernel.ts) (Kernel runtime), [`kernel/src/write/index.ts`](https://github.com/halofyai/halofy/blob/main/kernel/src/write/index.ts) (Governed writes), [`kernel/src/mcp/server.ts`](https://github.com/halofyai/halofy/blob/main/kernel/src/mcp/server.ts) (MCP server), [`kernel/src/http/server.ts`](https://github.com/halofyai/halofy/blob/main/kernel/src/http/server.ts) (HTTP transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Agent and operator entry"]
  node_mcp["MCP tools<br/>[tools.ts]"]
  node_mcp_server["MCP server<br/>[server.ts]"]
  node_http["HTTP transport<br/>[server.ts]"]
  node_adapter["HTTP adapter<br/>[adapter.ts]"]
  node_discovery["Manifest and discovery<br/>[manifest.ts]"]
end

subgraph group_governance["Identity and governance"]
  node_kernel["Kernel runtime<br/>[kernel.ts]"]
  node_auth["Credential identity<br/>[index.ts]"]
  node_scope["Agent scope<br/>[agent-scope.ts]"]
  node_policy["Access policy<br/>[index.ts]"]
  node_audit["Append-only audit<br/>[index.ts]"]
  node_oauth["OAuth authorization<br/>[server.ts]"]
end

subgraph group_context["Context lifecycle"]
  node_ingest["Ingestion runner<br/>[runner.ts]"]
  node_connectors["Public connectors"]
  node_writes["Governed writes<br/>[index.ts]"]
  node_relationships["Relationship enrichment<br/>[pipeline.ts]"]
  node_erasure["Signed erasure<br/>[index.ts]"]
  node_skills["Agent skills<br/>[vetting.ts]"]
end

subgraph group_data["Storage and retrieval"]
  node_db[("Postgres / PGlite<br/>[client.ts]")]
  node_cold[("Encrypted cold tier<br/>[index.ts]")]
  node_retrieval["Retrieval drivers<br/>[index.ts]"]
  node_search["Search and assembly<br/>[index.ts]"]
end

subgraph group_control["Control room"]
  node_console["Control room shell<br/>[app.js]"]
  node_screens["Admin screens"]
  node_console_api["Console API<br/>[api.ts]"]
end

node_agent(("AI agent"))
node_operator(("Operator"))

node_agent -->|"uses MCP"| node_mcp_server
node_mcp_server -->|"builds tools"| node_mcp
node_mcp_server -->|"boots"| node_kernel
node_agent -->|"sends requests"| node_http
node_http -->|"dispatches"| node_adapter
node_adapter -->|"invokes"| node_kernel
node_kernel -->|"resolves identity"| node_auth
node_kernel -->|"enforces scope"| node_scope
node_kernel -->|"checks policy"| node_policy
node_kernel -->|"records outcomes"| node_audit
node_connectors -->|"submit sources"| node_ingest
node_kernel -->|"runs imports"| node_ingest
node_ingest -->|"feeds write path"| node_writes
node_kernel -->|"governs writes"| node_writes
node_writes -->|"enriches after commit"| node_relationships
node_writes -->|"persists context"| node_db
node_kernel -->|"maintains cold tier"| node_cold
node_kernel -->|"serves reads"| node_search
node_search -->|"delegates retrieval"| node_retrieval
node_search -->|"fetches scoped context"| node_db
node_kernel -->|"performs erasure"| node_erasure
node_operator -->|"uses control room"| node_console
node_console -->|"routes screens"| node_screens
node_screens -.->|"requests operations"| node_console_api
node_console_api -.->|"administers runtime"| node_kernel
node_kernel -.->|"supports OAuth"| node_oauth
node_kernel -.->|"governs skills"| node_skills
node_http -->|"serves manifest"| node_discovery

click node_mcp "https://github.com/halofyai/halofy/blob/main/kernel/src/mcp/tools.ts"
click node_mcp_server "https://github.com/halofyai/halofy/blob/main/kernel/src/mcp/server.ts"
click node_http "https://github.com/halofyai/halofy/blob/main/kernel/src/http/server.ts"
click node_adapter "https://github.com/halofyai/halofy/blob/main/kernel/src/http/adapter.ts"
click node_kernel "https://github.com/halofyai/halofy/blob/main/kernel/src/kernel.ts"
click node_auth "https://github.com/halofyai/halofy/blob/main/kernel/src/auth/index.ts"
click node_scope "https://github.com/halofyai/halofy/blob/main/kernel/src/auth/agent-scope.ts"
click node_policy "https://github.com/halofyai/halofy/blob/main/kernel/src/policy/index.ts"
click node_audit "https://github.com/halofyai/halofy/blob/main/kernel/src/audit/index.ts"
click node_ingest "https://github.com/halofyai/halofy/blob/main/kernel/src/ingest/runner.ts"
click node_connectors "https://github.com/halofyai/halofy/tree/main/kernel/src/ingest/connectors"
click node_writes "https://github.com/halofyai/halofy/blob/main/kernel/src/write/index.ts"
click node_relationships "https://github.com/halofyai/halofy/blob/main/kernel/src/relationships/pipeline.ts"
click node_erasure "https://github.com/halofyai/halofy/blob/main/kernel/src/erasure/index.ts"
click node_db "https://github.com/halofyai/halofy/blob/main/kernel/src/db/client.ts"
click node_cold "https://github.com/halofyai/halofy/blob/main/kernel/src/cold/index.ts"
click node_retrieval "https://github.com/halofyai/halofy/blob/main/kernel/src/driver/index.ts"
click node_search "https://github.com/halofyai/halofy/blob/main/kernel/src/retrieval/index.ts"
click node_console "https://github.com/halofyai/halofy/blob/main/kernel/console/app.js"
click node_screens "https://github.com/halofyai/halofy/tree/main/kernel/console/screens"
click node_console_api "https://github.com/halofyai/halofy/blob/main/kernel/src/console/api.ts"
click node_oauth "https://github.com/halofyai/halofy/blob/main/kernel/src/oauth/server.ts"
click node_skills "https://github.com/halofyai/halofy/blob/main/kernel/src/skills/vetting.ts"
click node_discovery "https://github.com/halofyai/halofy/blob/main/kernel/src/discovery/manifest.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_mcp,node_mcp_server,node_http,node_adapter,node_discovery toneBlue
class node_kernel,node_auth,node_scope,node_policy,node_audit,node_oauth toneAmber
class node_ingest,node_connectors,node_writes,node_relationships,node_erasure,node_skills toneMint
class node_db,node_cold,node_retrieval,node_search toneRose
class node_console,node_screens,node_console_api,node_agent,node_operator toneIndigo
```

## Components

### Agent and operator entry

- [MCP tools](https://github.com/halofyai/halofy/blob/main/kernel/src/mcp/tools.ts): `kernel/src/mcp/tools.ts`
- [MCP server](https://github.com/halofyai/halofy/blob/main/kernel/src/mcp/server.ts): `kernel/src/mcp/server.ts`
- [HTTP transport](https://github.com/halofyai/halofy/blob/main/kernel/src/http/server.ts): `kernel/src/http/server.ts`
- [HTTP adapter](https://github.com/halofyai/halofy/blob/main/kernel/src/http/adapter.ts): `kernel/src/http/adapter.ts`
- [Manifest and discovery](https://github.com/halofyai/halofy/blob/main/kernel/src/discovery/manifest.ts): `kernel/src/discovery/manifest.ts`

### Identity and governance

- [Kernel runtime](https://github.com/halofyai/halofy/blob/main/kernel/src/kernel.ts): `kernel/src/kernel.ts`
- [Credential identity](https://github.com/halofyai/halofy/blob/main/kernel/src/auth/index.ts): `kernel/src/auth/index.ts`
- [Agent scope](https://github.com/halofyai/halofy/blob/main/kernel/src/auth/agent-scope.ts): `kernel/src/auth/agent-scope.ts`
- [Access policy](https://github.com/halofyai/halofy/blob/main/kernel/src/policy/index.ts): `kernel/src/policy/index.ts`
- [Append-only audit](https://github.com/halofyai/halofy/blob/main/kernel/src/audit/index.ts): `kernel/src/audit/index.ts`
- [OAuth authorization](https://github.com/halofyai/halofy/blob/main/kernel/src/oauth/server.ts): `kernel/src/oauth/server.ts`

### Context lifecycle

- [Ingestion runner](https://github.com/halofyai/halofy/blob/main/kernel/src/ingest/runner.ts): `kernel/src/ingest/runner.ts`
- [Public connectors](https://github.com/halofyai/halofy/tree/main/kernel/src/ingest/connectors): `kernel/src/ingest/connectors`
- [Governed writes](https://github.com/halofyai/halofy/blob/main/kernel/src/write/index.ts): `kernel/src/write/index.ts`
- [Relationship enrichment](https://github.com/halofyai/halofy/blob/main/kernel/src/relationships/pipeline.ts): `kernel/src/relationships/pipeline.ts`
- [Signed erasure](https://github.com/halofyai/halofy/blob/main/kernel/src/erasure/index.ts): `kernel/src/erasure/index.ts`
- [Agent skills](https://github.com/halofyai/halofy/blob/main/kernel/src/skills/vetting.ts): `kernel/src/skills/vetting.ts`

### Storage and retrieval

- [Postgres / PGlite](https://github.com/halofyai/halofy/blob/main/kernel/src/db/client.ts): `kernel/src/db/client.ts`
- [Encrypted cold tier](https://github.com/halofyai/halofy/blob/main/kernel/src/cold/index.ts): `kernel/src/cold/index.ts`
- [Retrieval drivers](https://github.com/halofyai/halofy/blob/main/kernel/src/driver/index.ts): `kernel/src/driver/index.ts`
- [Search and assembly](https://github.com/halofyai/halofy/blob/main/kernel/src/retrieval/index.ts): `kernel/src/retrieval/index.ts`

### Control room

- [Control room shell](https://github.com/halofyai/halofy/blob/main/kernel/console/app.js): `kernel/console/app.js`
- [Admin screens](https://github.com/halofyai/halofy/tree/main/kernel/console/screens): `kernel/console/screens`
- [Console API](https://github.com/halofyai/halofy/blob/main/kernel/src/console/api.ts): `kernel/src/console/api.ts`

### Other components

- **AI agent**
- **Operator**

## Connections

- AI agent → MCP server: uses MCP
- MCP server → MCP tools: builds tools (evidence: `kernel/src/mcp/server.ts`)
- MCP server → Kernel runtime: boots (evidence: `kernel/src/mcp/server.ts`)
- AI agent → HTTP transport: sends requests
- HTTP transport → HTTP adapter: dispatches (evidence: `kernel/src/http/server.ts`)
- HTTP adapter → Kernel runtime: invokes (evidence: `kernel/src/http/adapter.ts`)
- Kernel runtime → Credential identity: resolves identity (evidence: `kernel/src/http/adapter.ts`)
- Kernel runtime → Agent scope: enforces scope (evidence: `kernel/src/kernel.ts`)
- Kernel runtime → Access policy: checks policy (evidence: `kernel/src/kernel.ts`)
- Kernel runtime → Append-only audit: records outcomes (evidence: `kernel/src/kernel.ts`)
- Public connectors → Ingestion runner: submit sources
- Kernel runtime → Ingestion runner: runs imports (evidence: `kernel/src/kernel.ts`)
- Ingestion runner → Governed writes: feeds write path
- Kernel runtime → Governed writes: governs writes (evidence: `kernel/src/kernel.ts`)
- Governed writes → Relationship enrichment: enriches after commit (evidence: `kernel/src/relationships/pipeline.ts`)
- Governed writes → Postgres / PGlite: persists context
- Kernel runtime → Encrypted cold tier: maintains cold tier (evidence: `kernel/src/kernel.ts`)
- Kernel runtime → Search and assembly: serves reads (evidence: `kernel/src/kernel.ts`)
- Search and assembly → Retrieval drivers: delegates retrieval
- Search and assembly → Postgres / PGlite: fetches scoped context
- Kernel runtime → Signed erasure: performs erasure
- Operator → Control room shell: uses control room
- Control room shell → Admin screens: routes screens (evidence: `kernel/console/app.js`)
- Admin screens → Console API: requests operations
- Console API → Kernel runtime: administers runtime
- Kernel runtime → OAuth authorization: supports OAuth
- Kernel runtime → Agent skills: governs skills
- HTTP transport → Manifest and discovery: serves manifest (evidence: `kernel/src/http/adapter.ts`)
