Edge API Server, Web UI, and Reviews (The Head and the Face)

The head (dna/api) is the edge API server for a DNA project. It authenticates callers (via OIDC sessions, bearer tokens, or Unix domain sockets), resolves…

The head (dna/api) is the edge API server for a DNA project. It authenticates callers (via OIDC sessions, bearer tokens, or Unix domain sockets), resolves their held positions from the record, and admits commands (HeadCommands) into the Postgres record with idempotent receipts. The face (dna/face) is the browser UI shell served in front of the head. Neither the head nor the face executes tasks or holds the spine’s database role, model API keys, or GitHub forge tokens.

Terminal window
# Start the project head, standard browser face (port 8792), and local OIDC stub
hale dna head /absolute/path/to/project
# Inspect the Board queue and render or decide a pending Review from the CLI
hale dna board
hale dna review <id>
hale dna review <id> approve --comment "verified semantic diff and test receipts"

Architecture Overview

Section titled “Architecture Overview”
Component Engineering Role Source / Entrypoint
Head (dna/api) Project edge API: serves HTTP read queries and exposes the HeadCommands mutation surface over a Unix socket and HTTP dna/api
Project Head Multi-project server: manages project registry, detached CLI operation receipts, and proxies to each attached project’s API child dna/api/project_service, hale dna head, dna/face/start.sh
Standard Face The browser face in front of the head: the org chart, the board and the knowledge screens, /index and /app/ dna/face
Read-Only UI (hale dna ui) Standalone read-only HTTP server rendering offline CLI projections on port 8790 dna/ui
Board & Reviews Governance queue, 3-view Review rendering, signer routing, and verdict settlement hale dna board, hale dna review, hale dna route, dna/core/review.hl
Forge Mirror Reviews mirrored as pull requests at the organism’s allocated forge, and their verdicts read back hale dna forge sync, dna/core/forgejo.hl, dna/host/forge_github.hl

Starting the Project Head (hale dna head)

Section titled “Starting the Project Head (hale dna head)”

For any project created or attached with hale habitat graft, start the head and browser face with:

Terminal window
hale dna head /absolute/path/to/project

On first run, hale dna head compiles the project head, standard face, project API child, stub OIDC provider (dna/oidc), and reflexes into the toolchain cache (subsequent starts launch immediately until the toolchain version changes) and prints the face’s loopback URL. If invoked without a project path, the server starts detached so you can attach or manage projects from the browser’s Projects workspace.

When developing from a hale compiler checkout, dna/face/start.sh /absolute/path/to/project accepts the exact same flags (--help lists all options) and builds directly from the working tree into temporary storage on each start.

Default Ports and Dynamic Port Binding

Section titled “Default Ports and Dynamic Port Binding”
Default Port Service CLI Flag
8792 Project head serving the standard browser face --port
8793 Project API child (HTTP read endpoints) --api-port
8794 Local stub OpenID Connect provider (dna/oidc) --oidc-port
8795 Project API child (HeadCommands HTTP mutation surface) --commands-port
8796 Internal loopback port where the head listens behind the standard face --head-port

When dna/api/project_service is started with an API port of 0 and no HALE_DNA_COMMANDS_PORT (such as in test fixtures), it passes port 0 for both sockets to the API child. The child binds ephemeral OS ports and reports both back via HALE_DNA_API_PORTS (preventing port-race collisions), printing:

hale dna api: commands http://127.0.0.1:<port>/

The API child serves the same surface over MCP too, for an agent pairing with a person, on an ephemeral port it always picks itself; it reports it as mcp=<port> in HALE_DNA_API_PORTS and prints:

hale dna api: mcp mcp://127.0.0.1:<port>

Database Role and Memory Requirements

Section titled “Database Role and Memory Requirements”

The head reads the record and Knowledge from Postgres under the least-privilege head role (HALE_DNA_MEMORY_DSN_HEAD). hale dna head derives this DSN from an active, migrated memory allocation and passes it exclusively to the head process without printing it; an explicit HALE_DNA_MEMORY_DSN_HEAD in the environment takes precedence.

The head never starts databases, brokers, or the organism body, and never runs schema migrations. If the project’s memory allocation is down or unmigrated, the head refuses to start and directs you to run hale habitat migrate <project>.


The Habitat Face and Operator UI

Section titled “The Habitat Face and Operator UI”

Because the local habitat is itself a DNA organism, hale habitat up starts the standard face over the habitat’s own head alongside its body. hale habitat status prints the URL on the face line (hale habitat down stops it):

Terminal window
$ hale habitat status
...
face http://127.0.0.1:8864/ (up, compose service face)

Authentication and Principal Mapping

Section titled “Authentication and Principal Mapping”

A head fails closed: it refuses to start without a configured principal source, rejects unmapped callers, and speaks plain HTTP (terminate TLS at a reverse proxy when exposing over a network). Callers authenticate through one of two channels:

1. Local Unix Domain Socket

Section titled “1. Local Unix Domain Socket”

Commands sent by hale dna work (Legs, hands and voice) travel over a per-record Unix domain socket located under $XDG_RUNTIME_DIR/hale/dna/ (or .hale/dna/ in the checkout), advertised in the head’s capabilities. The OS kernel vouches for the peer’s UID, which the head maps to a person via local Git config (written automatically for the current user by hale habitat graft):

Terminal window
git config --local --add dna.unix.member "uid:1000=alice"

2. HTTP and OpenID Connect (OIDC)

Section titled “2. HTTP and OpenID Connect (OIDC)”

Over HTTP, every caller is authenticated against an OIDC identity provider:

Terminal window
git config dna.principal oidc
git config dna.oidc.issuer https://id.example.com
git config dna.oidc.client dna-acme
git config --add dna.oidc.member "<subject>=alice"
hale dna secret set OIDC_CLIENT_SECRET

HeadCommands Surface, Authorization Gates, and Receipts

Section titled “HeadCommands Surface, Authorization Gates, and Receipts”

Every mutation accepted by the record is a member of the HeadCommands API surface. Both the CLI and the browser UI call this exact same generated surface (hale api client --surface HeadCommands; the Hale client for legs is committed in dna/core/legs/head_commands).

Authorization Gates

Section titled “Authorization Gates”

Authorization gates are evaluated identically over the Unix socket and HTTP based on the positions held by the authenticated person in the record:

Gate Required Seat HeadCommands Operations
owner Holder of position:board propose_organization, reassign_task, retire_person
reviewer Holder of position:reviewer verdict
position Holder of any active position propose, attempt lifecycle (claim, outcome, renew, release_attempt, ask_allowance), file_friction, *_knowledge mutations, org structure (open_position, fill, apply_batch)
none Any authenticated person create_task, lookup, lookup_knowledge, preview_batch

Over HTTP, clients invoke POST /call/<member> on the commands port (8795) with a bearer token. For browser sessions, the face server validates CSRF preconditions (exact Origin match, X-Hale-Command: 1 header, and JSON content type) on POST …/commands and relays the request using the session’s token.

Structural Mutations and Batch Previews (preview_batch / apply_batch)

Section titled “Structural Mutations and Batch Previews (preview_batch / apply_batch)”

UI and API calls to open_position, fill, and apply_batch write the exact same rows—and enforce the exact same refusal rules—as hale dna position open, hale dna fill, and hale dna apply (vacate is submitted as a one-step batch: vacate <position> <holder>). Every structural mutation requires record_head (the record digest it was prepared against) and fails with stale_subject if the record has advanced.

Before applying a batch, UIs call preview_batch to compute a read-only diff against the current record head:

preview_batch { steps } → { ok, why, head, before, after, added, removed, unchanged, pending }
apply_batch { request_id, record_head: head, steps, pack: "" }
→ receipt.structure { state: requested, request_id, review_id, … }

The returned receipt’s structure.state begins as requested and transitions to proposed (with review_id) or refused (with why) once the organization processes it; submitting identical steps while a Review is still open returns already_proposed with the existing review_id.

Command and Operation Receipts

Section titled “Command and Operation Receipts”

The Board Queue (hale dna board)

Section titled “The Board Queue (hale dna board)”

hale dna board reads the record offline from any clone and summarizes every item awaiting Board action or operator intervention:

$ hale dna board
board: 16 review(s) need your verdict
k:05cecb18af4e ratify the design practice `design/software-delivery`: For an appendage or a product: process boundaries first (what runs, fail…
k:076fd6de2420 ratify the design practice `design/standard-equipment`: Every part that supervises others is born with its architect: the positi…
…
secret: the forge's token is not in the vault (forge-token); `hale dna secret set FORGE_TOKEN` fills it
decide with `hale dna review <id> approve|revise|reject`; `hale dna review <id>` renders one

The output includes:


Reviews, Verdicts, and Signer Routing

Section titled “Reviews, Verdicts, and Signer Routing”

Every Review (dna/core/review.hl) governs a single candidate digest, tracking the required authority or signer positions and all submitted verdicts.

Terminal window
hale dna review # list all pending Reviews grouped by family
hale dna review <id> # render a Review offline (question, 3 views, and status)
hale dna review <id> --iris # inspect a code change's semantic diff in the Iris review view

hale dna review groups pending Reviews by family in proposal order: purpose, design, operating, using, library, holes (where each proposed position is immediately followed by its mandate/<position> Review so hale dna review holes approve ratifies and binds them in sequence), practices, holds, positions, changes, and ingest.

The Three Review Views

Section titled “The Three Review Views”

When rendering a code mutation Review, hale dna review <id> displays the mutation metadata (class, author, grant disposition, and magnitude vector) followed by three mandatory views computed offline from the record and its receipts:

  1. Source Diff (git diff): Base-to-candidate line diff—the only view that exposes handler logic tweaks, literal changes, or unused struct fields.
  2. Semantic Diff (hale model diff): Structural summary of added, removed, renamed, or moved declarations, contract/effect class shifts, and constitutional claims whose verification status changed.
  3. Evidence Table: Pass/fail (yes / NO) table for every verification step executed by the toolchain (fmt, check, verify, test, fleet, replay, rollback), linked to its output receipt digest.

Submitting Verdicts

Section titled “Submitting Verdicts”
Terminal window
hale dna review <id> approve --comment "fine"
hale dna review <id> approve --digest <sha> # explicitly pin the candidate digest you inspected
hale dna review <id> reject --no-wait # write verdict row and return without waiting for settlement
hale dna review design approve # approve every pending Review in the `design` group sequentially
Flag / Argument Description
approve|revise|reject|abstain Verdict decision (approve on a code change also triggers genome application; revise and reject close the Review without touching the genome; abstain records a note and leaves the Review open).
--as <reviewer> Reviewer identity (defaults to $USER).
--authority <a> Claimed authority level (defaults to board). Ranks: board / maintainer (4) > leader (3) > supervisor (2) > reviewer (1).
--comment <c> Justification recorded in review.reasoned.
--digest <sha> Expected candidate digest (defaults to the Review’s pinned digest).
--no-wait Do not block waiting for the organization to settle the review.verdict row.

A Review admits a verdict only if all three conditions hold:

  1. Candidate digest match: --digest matches the Review’s pinned candidate (otherwise refused with digest mismatch: …).
  2. Sufficient authority or signer seat: If the Review is routed to specific signer positions, the reviewer must hold one of those required positions; otherwise, the reviewer’s claimed --authority rank must be greater than or equal to the Review’s required authority (authority <a> does not satisfy <required>).
  3. Author separation (two-person rule): The reviewer must not be the author of the candidate (reviewer <who> authored the candidate). The sole exception is a Board-level governance proposal (filling or opening a position, or a graph proposal), where the proposer may also ratify as the Board (Positions and fill).

Signer Routing (hale dna route)

Section titled “Signer Routing (hale dna route)”

For code changes, required signers and CI gates are computed deterministically from reviews edges in the Postgres memory graph:

Terminal window
hale dna route main.hl
hale dna route --diff main..HEAD
hale dna route --json main.hl

hale dna route prints every position that must sign the change (with its current holders and the graph edge that triggered it), the required verification gates, any unreviewed paths, and the fallback authority. (Because routing queries the memory graph, running hale dna route without HALE_DNA_MEMORY_DSN_HEAD prints an error directing you to run hale habitat migrate <organism>.)

When a Review opens, it records this routing calculation as a review.routed row:


Browser Surfaces: Standard Face, /index, Named Faces, and hale dna ui

Section titled “Browser Surfaces: Standard Face, /index, Named Faces, and hale dna ui”

The forge mirror (hale dna forge sync)

Section titled “The forge mirror (hale dna forge sync)”

The forge is a gate, not a store. Code goes out through it as branches and verdicts come back through it; the organism reads nothing from it that it did not already decide. A Review lives in the record, its candidate is a branch in git, and the pull request is a mirror of it. The record wins.

Which forge stands in the gate is an allocation, a role the habitat allocates as it allocates memory. On your machine it is the habitat’s own Forgejo: hale habitat up brings it up with memory and the nerves, and a graft gives the organism a Forgejo user and a repository there, its token in the vault (forgejo-<id>), and a user for each position of its chart, its Board and each person who holds a position, each writing to that repository (the chart’s personas, kept in step by hale habitat apply). Nothing to set up:

Terminal window
hale habitat graft chat
hale dna forge sync # the branch goes out; pending Reviews become pull requests

GitHub is the allocation when the Board names it:

Terminal window
git remote add origin git@github.com:acme/chat.git
hale habitat forge chat github --repo acme/chat --key-vault forge-token
git config dna.github.board alice,bob # whose GitHub reviews carry the Board's authority
hale dna secret set FORGE_TOKEN
hale dna forge sync

Moving a project from the local forge to GitHub is exactly that: change the remote, change the allocation, sync. A Review still open reappears as a pull request on GitHub; nothing migrates, and the Forgejo pull request is left as it was. none (a bare remote, Reviews decided in the organism’s own face or CLI) is there when there is no forge at all, and hale dna forge sync then says forge: no forge allocated.

Against whichever forge is allocated, hale dna forge sync (or the host, on each tick under hale dna dev / hale dna run):

  1. Pushes each pending change Review’s candidate commit to branch dna/<id>, opens a pull request with the three Review views as its description, and records github.pr in the record.
  2. Reads every review on it back as a review.verdict in the reviewer’s login (board when dna.github.board lists the login, reviewer otherwise, each once).
  3. Records the gate runs it finds at the candidate as gate.observed rows.
  4. Once a change is applied, comments the settlement (github.commented) and pushes the genome on approval.

A leg’s review at an attached codebase comes back as task.delivered when merged and task.refused when closed, the comments on it as receipts. Each forge acts as its allocation’s token alone, the vault slot it names. A practice never names a forge: “open a review” is the verb, and the allocation answers it.

At the habitat’s Forgejo a leg’s work goes out as the persona of the position it is for: whether a person or a harness made the branch, the leg pushes it with that persona’s token (forgejo-<id>-<position>), opens the pull request as that persona’s user, and authors any commit of its own as the persona (what was left uncommitted becomes one such commit on top). The commits it was handed stay on the branch as they were made, the same shas and authors, never squashed; whether to squash is decided when the pull request is merged. A position with no persona yet (before hale habitat apply has made it) falls back to the organism’s own user, and the leg says so once:

hale dna work: note: no persona of position:api/dev is in the habitat's ledger yet (`hale habitat apply` makes it), so the organism's own Forgejo user shop-<id> acts for it

Troubleshooting the Head, Face, and Reviews

Section titled “Troubleshooting the Head, Face, and Reviews”
Diagnostic / Symptom Cause & Resolution
Head refuses to start (trusted-local is a fixture's mode… or the issuer … is not usable) Missing dna.principal = oidc, non-HTTPS external issuer, unreachable JWKS keys, or a loopback issuer without a pinned dna.oidc.key. Configure OIDC or start via hale dna head / dna/face/start.sh.
not a member: subject … maps to no one The authenticated OIDC sub claim is not mapped in git config. Run git config --add dna.oidc.member "<subject>=<person>".
Command refused with forbidden The caller does not hold a position required by the HeadCommands gate (owner, reviewer, position), or the caller is a service: principal.
commands_unavailable The head process was started without a commands port (--commands-port / HALE_DNA_COMMANDS_PORT).
Read or command answered 503 as the head stops (head_api_unavailable, commands_unavailable) A head stopped while waiting on its API child answers in-flight requests immediately with 503 and exits rather than holding its shutdown; retry once the replacement head is up.
Verdict refused (digest mismatch, authority … does not satisfy …, reviewer … authored the candidate) Inspect hale dna review <id> under refused a verdict:. Re-render to check the current candidate digest, claim an authority rank that satisfies the Review, or have a second person review your code change.
no forge token Store a GitHub token in the vault with hale dna secret set FORGE_TOKEN.