DNA Architecture & Runtime Overview

In Hale, an organism combines your application with a self-governing runtime control plane (dna/org), an append-only event log and operational state store…

In Hale, an organism combines your application with a self-governing runtime control plane (dna/org), an append-only event log and operational state store in PostgreSQL (memory), a NATS JetStream event broker (nerves), a Prometheus metrics store (senses), and a credential boundary (skin). When you submit a request, the runtime plans the work, proposes code changes in a sandboxed Git worktree, verifies the candidate with the Hale toolchain, routes the diff and evidence for review, applies approved commits, and monitors the deployed process.

Terminal window
hale habitat up
hale habitat graft demo
hale dna dev demo
hale dna task create --as alice "document the Echo locus in main.hl"

System Components

Section titled “System Components”

Every DNA component maps to a specific software service or source module in your repository and local habitat:

Component Infrastructure / Role Source / Habitat Location Chapter
Habitat Control plane (Docker Compose, on this machine or another reached over SSH) that provisions and supervises organisms ${XDG_DATA_HOME:-~/.local/share}/hale/habitat/local The Habitat
Genome Git repository containing application source, organization config (dna/org/), and vendored core (vendor/dna); nodes pull from the forge’s default branch Repository root; host Git wrapper in dna/host/genome.hl Shaping and Governing
Record Append-only audit log (record_rows table in PostgreSQL schema dna_<identity>), storing one signed row per governance or mutation event dna/core/record.hl, dna/host/record.hl Memory and the Record
Memory Operational PostgreSQL state store (schema dna_<identity>, with owner, spine, and head DB roles) holding the daily ledger, organizational graph, and sealed receipt evidence dna/core/memory_spine.hl, dna/host/memory.hl; habitat service memory-<id> Memory and the Record
Nerves NATS JetStream broker (DNA_<ID> stream, one user per role) relaying durable events between host, spine, heart, and reflexes after rows land in PostgreSQL dna/core/nerves.hl, dna/host/nerves.hl; habitat service nerves-<id> The Nerves
Face Browser web UI served in front of the edge API for viewing state and submitting intent dna/face/ The Head and the Face
Head Edge HTTP and Unix socket API handling sessions, principals, and command submissions answered with receipts; never executes workflows dna/api/ The Head and the Face
Body Host supervisor holding the active record lease in PostgreSQL and expressing code changes (via local restart, ShellDeployment, or hale node fleet) dna/core/infrastructure.hl, dna/host/infra.hl The Heart and the Body
Spine Node runtime (hale dna dev or hale dna run) that relays unanswered requests onto NATS, projects the record into the PostgreSQL graph, enforces budgets/leases, and executes workflows dna/host/host.hl supervising dna/org/main.hl The Spine
Legs Stateless worker processes (hale dna work) that claim workflow attempts through the head, load a context hat, run tools, and submit outcomes dna/core/legs/, performers in dna/org/work.hl Legs, Hands, and Voice
Hat Content-addressed context bundle assembled per unit of work dna/core/hat.hl Legs, Hands, and Voice
Hands Sandboxed tool capabilities granted by a work’s output contract: Git, Forge, Hale toolchain, and record reads dna/core/contracts.hl, dna/core/tools.hl, dna/core/legs/hands.hl Legs, Hands, and Voice
Voice Model routing layer, catalog, provider adapters, and call recording tape dna/core/models.hl, dna/core/model_map.hl, dna/core/tape.hl, dna/org/models.hl Legs, Hands, and Voice
Heart The supervised Hale application publishing <org>.app.<name>.<event> over NATS, persisted by the host as reading.recorded rows Application seed; host ingestion in dna/host/pulse.hl The Heart and the Body
Senses Prometheus metrics store scraping /metrics from long-running DNA components dna/core/senses.hl; habitat service senses-<id> Senses and Reflexes
Reflexes Automated health daemon querying Prometheus for instance.down (dna_instance_up == 0) and triggering instance restarts dna/reflexes/main.hl, node handler in dna/host/reflex.hl Senses and Reflexes
Skin Security boundary: Vault secret slots (~/.cache/hale/vault or HALE_VAULT_ADDR + std::secret::Credential), DB/NATS role grants, OIDC authentication, and absorbed closure violations (violation.recorded) dna/host/secrets.hl, dna/core/principal.hl, dna/oidc/stub.hl The Skin

Recurring workflow triggers and conveners are covered in Schedules.

Documentation Map

Section titled “Documentation Map”

Core Execution Invariants

Section titled “Core Execution Invariants”

Every component in the DNA runtime enforces two persistence rules so that crashes and restarts never leave partial state or lost work:

  1. One store per workflow step: Every workflow step declares a single target store (record, forge, genome, heart, graph, nerves, memory, vault, or host) and writes exclusively through that store’s designated writer. The next step reads what the previous step made durable. Workflow definitions that name zero or multiple stores for a step are rejected before execution. Concurrent writes whose target state moved since being read are rejected and re-evaluated, avoiding distributed transactions across stores. See The Spine.
  2. Row-first persistence: Every state transition or user command writes a durable row to PostgreSQL before any live notification is sent. CLI commands write a request row and wait; a running node relays unanswered rows onto NATS JetStream until an answering row lands in the record. NATS messages carry row IDs, deliver at least once, and are deduplicated idempotently by ID. External application events from the heart are persisted as reading.recorded rows before any workflow or reflex acts on them. See The Nerves.

Trust Tiers & Credential Isolation

Section titled “Trust Tiers & Credential Isolation”

Components are partitioned into eight trust tiers defined by which credentials they receive and which resources they cannot access:

Tier Component / Actor Credentials & Access Granted Access Explicitly Denied
Devices User’s web browser Session cookie from the head Private keys, Git access, shell access, NATS broker
Identity & Forge OpenID provider; GitHub (gh via core Forge interface) User identity assertions; genome/record Git pushes and pull request verdicts Operational runtime credentials or databases
The Head Edge API (dna/api/) and web UI (dna/face/) User sessions; principal-to-position mappings; local record checkout; PostgreSQL head role (claim fencing, reads, ledger appends on behalf of users); subscribe-only NATS user PostgreSQL spine role; NATS publish permissions
The Body Spine runtime (hale dna run or hale dna dev) PostgreSQL spine role; NATS spine user; active body lease PostgreSQL and NATS owner and head credentials
The Body’s Legs Worker processes (hale dna work) Lease on the claimed attempt; model API keys from the local machine’s vault Direct PostgreSQL role (all reads and writes go through the head API)
The Heart Supervised Hale application Application-owned database and secrets; NATS app-<name> user restricted to publishing on <org>.app.<name>.> DNA record, DNA PostgreSQL schema, DNA vault entries, <org>.dna.> NATS subjects
Private Services PostgreSQL (memory), NATS (nerves), Vault, Prometheus (senses), dna/reflexes Loopback-only listeners (127.0.0.1); reflexes receive Prometheus read URL and NATS reflexes publish-only user Direct network reachability from external user devices
External APIs Hosted LLM providers Single prompt and API key per HTTP request Any repository files or state not explicitly included in the prompt

Capabilities & Non-Goals

Section titled “Capabilities & Non-Goals”

What DNA Does

Section titled “What DNA Does”

What DNA Refuses to Do

Section titled “What DNA Refuses to Do”

The formal specification for the DNA runtime is maintained in spec/dna.md.