The Habitat Layer: Multi-Organism Infrastructure and Isolation
A habitat is the root DNA organism shipped with the Hale toolchain (spec/habitat.md). Its role is to provision, supervise, and place infrastructure allocations (Postgres memory, NATS JetStream nerves, Prometheus senses stores, and vault roles) for child organisms. Every project organism is born as a child of the habitat via hale habitat graft—the habitat itself is the only organism booted without a parent (hale habitat up).
# 1. Start the local habitat organism, its Compose services, and its operator UI# (named at its birth; `local` when no --name is given, and kept after)hale habitat up --name homelab
# 2. Graft a new application, or a sapling from a nursery the habitat trustshale habitat graft my-servicehale habitat nursery add https://github.com/hale-lang/voicehale habitat graft voice
# 3. Inspect all running allocations, schema versions, and host placementshale habitat statusMore than one habitat on a machine
Section titled “More than one habitat on a machine”A laptop can administer several habitats: a home one and a work one, a throwaway habitat to try a branch beside the real one, or a laptop-only habitat beside one on a server. Each lives in a directory of its own under ${XDG_DATA_HOME:-~/.local/share}/hale/habitat/, and one of them is current: the one every hale habitat and hale dna verb acts on.
hale habitat up --name work # born beside the first habitat, and now currenthale habitat list # each habitat: * current, where it runs, whether its head answershale habitat use home # make another currenthale habitat --habitat work status # one command on another habitatHALE_HABITAT=work hale dna show # the same, for a scriptA machine with one habitat needs nothing of this: with no current habitat named, every verb acts on local, the directory a machine’s first habitat has always had, and a habitat born --name home there is still reached as home. up --host <h> --name <name> keeps the pointer to a habitat on another machine in that name’s directory, so a machine can point at several. The habitats share nothing on the machine: each has its own directory, compose project and record.
How the Habitat Organism Works
Section titled “How the Habitat Organism Works”Unlike an application organism that supervises a user-written application heart, the habitat’s heart slot is empty: what it keeps alive are the infrastructure backends and bodies of its child organisms.
- Fixed Genome and Law: The habitat’s genome is embedded in the
halebinary with fixed positions (placement,backends,identity,admissionfrom thehabitatnursery pack) and thestandardnursery pack as its law. - Root Bootstrap (
hale habitat up): The habitat is the sole organism born without a parent. Runninghale habitat upsupports two profiles:local(built today): Provisions a long-lived Docker Compose project (hale-habitat-local-<hash>) under${XDG_DATA_HOME:-~/.local/share}/hale/habitat/local, and starts the habitat’s backing services alongside its ownbody(hale dna dev) and browserface(hale dna head) as services of that Compose project (built from the embeddedDockerfileandhale.pin, or from a prebuilt local image via--image <tag>/HALE_HABITAT_IMAGEandhale habitat image build). By default (--backends own), it manages its own Postgres, NATS, Prometheus, and Forgejo containers; with--backends operator, it adopts the external servers named byHALE_DNA_MEMORY_DSN_OWNERandHALE_DNA_NATS_URL_OWNER. Thebodyandfacecontainers mount the host’s Docker socket so the habitat can run and probe every organism’s services; that socket is root on the host, so a habitat is trusted as the machine’s administrator is.localon another machine (hale habitat up --host <name> [--user <user>] [--port <n>]): the same habitat on a LAN machine that has Docker and nothing else. (--host localis this machine, as everywhere else:hale habitat up --host localis plainhale habitat up, no SSH.) Your own SSH login reaches it; the toolchain image is used if it is there already, else sent from your Docker, else pulled as the published image when yourhaleis a release’s build, else built there once from yourhale’s commit on GitHub (the machine’s Docker needs itsbuildxplugin; the first build compiles the compiler and takes a while);hale habitat upruns there in that image, its face and head bound to the address<name>resolves to and recorded athttp://<name>:<port>. This machine keeps only a pointer (the name, the host, the head’s URL and launch token, the record’s identity), in its data directory (XDG_DATA_HOMEmoves it, andupandstatussay so when it does). A habitat already running there with no pointer here is never pointed at by itself:up --hostrefuses, naming where the pointer would go, and--attachpoints this machine at it, as you would after losing the pointer or from a second machine. A laterup --hostwith the same name upgrades that habitat in place (a newhale’s image, its services restarted on it), however you name its host:--host rack-areaches a pointer recorded asrack-a.lan. With the pointer:statusasks the head through it,host,graft <sapling>,place,applyandmodel-mapgo to the head as they do locally,downanddown --forgetrun on the habitat’s machine over SSH (the forget still confirmed by its name typed at your terminal, the pointer removed last),graft <dir>ships the directory there (it becomes the organism’s home, the habitat’s copy) and grafts it there,hale habitat organism <name> dna <verb>runs an organism’s own verbs (review,task create,work run) in its directory there, andmigrateandhandoverare refused. You sign in to the remote face from your own browser: the habitat’s OIDC stub records its issuer underhttp://<name>:<port>too, and plain HTTP is accepted for exactly that name (and the loopback), no other host.hosted(roadmap): Connects to an existing platform’s managed Postgres, NATS, Vault, and OIDC identity provider.
- Child Birth via
hale habitat graft: Every other organism is born as a child of the habitat viahale habitat graft. During a graft:- The child’s
record.genesisrow records the habitat’s record identity as its parent. - The habitat allocates the infrastructure roles declared in the child’s
hale.toml([dna] needs:memoryandnervesalways,sensesunless omitted, plus an optional tenantdatabasefor a Hale heart passed asHALE_DNA_DATABASE_DSN) and records those allocations in the habitat’s own record. - The habitat decides the
scopeonapplication.attachedand issues per-client database, broker, and vault credentials. - The habitat proposes the
standardpractices pack to the child’s Board, and a sapling’s own packs after it, withfounderset to the person grafting unless the pin or--setnames another: a pack’s? fill … {founder}lines seat them, the Board’s seat first, so the child settles its Reviews with nobody else asked. A sapling that declares packs declares its chart: the graft proposes the Board’s seat and no other hole, since the pack’s positions are the chart. - On its own backends, the habitat gives the child a user and a repository at its own Forgejo, the local profile’s forge. The forge is a gate, not a store: code goes out through it as branches and verdicts come back through it. GitHub is the allocation when a Board names it (
hale habitat forge <organism> github --repo <owner/name>). - The child’s chart is at the forge too, as people: every position its chart states, its Board, and every person who holds a position there gets a Forgejo user of its own (a persona), with write access to the child’s repository, an avatar drawn from its name, and its own token in the habitat’s vault (
forgejo-<key>-<position>,forgejo-<key>-board,forgejo-person-<member>). A position’s user is named for the organism and the position (shop-<key>-dev,shop-<key>-api_devforapi/dev); a person’s is their member name, one user however many organisms they belong to. The graft makes them, and everyhale habitat applykeeps them in step with the chart: a new position gets its persona, a retired or closed one loses it, and a person’s user goes once no chart has them. A second apply changes nothing, andhale habitat statusshows how many personas each organism has.
- The child’s
- Deployment and Reflexes: For habitat-scoped applications, the habitat elaborates placement declarations into container manifests or Compose configurations, applies them using habitat-held credentials, monitors child readiness, capacity, metrics, and logs, and restarts or rescales child bodies via reflexes.
Hosts, Placement Providers, and Saplings
Section titled “Hosts, Placement Providers, and Saplings”Hosts and Providers (compose and ssh)
Section titled “Hosts and Providers (compose and ssh)”In habitat commands, a host always refers to a physical or virtual machine where allocations can be placed. Providers discover hosts, allocate roles for organisms, render and apply service definitions on a target host, and observe live health (up, degraded, or down). Every host, allocation, and role-to-provider policy is stored as a row in the habitat’s record and exposed on the habitat head’s surface (Commands::hosts, Commands::allocations, Commands::policy).
| Provider / Verb | Behavior |
|---|---|
compose provider (local profile) |
Produces the local host (advertising compose) and runs all habitat and child organism allocations (memory-<id>, nerves-<id>, senses-<id>, forge, and the habitat’s body and face) as Docker Compose services on the local machine. |
hale habitat host add <name> [--user <u>] [--port <n>] |
Probes a LAN machine over SSH using the habitat’s vault-held SSH keypair, pins the first-seen host key in the record (refusing any subsequent host-key mismatch), and, over your own SSH login and with your sudo, makes the habitat an account of its own on <name> (hale-<id>: no sudo, in the docker group, which is root-equivalent on the host) holding its public key, then probes it ready. --user <u> puts the key in that account instead. When your login does not reach <name>, it prints what to do there and marks the host pending-key. |
hale habitat host join <name> |
Run on the machine joining a habitat that runs elsewhere (your laptop, say): records it as a joined host by a name the habitat’s machine reaches it at. The habitat never logs in there (no key, no account, no SSH); it reaches the machine on its services’ ports only, scraping the exporters join installs. Placements there run from the machine itself (--host local on it). |
hale habitat host probe <name> |
Re-probes <name> over SSH. Once ~/.ssh/authorized_keys is updated, transitions the host from pending-key to ready and records its capabilities (docker compose, systemd-user, OS, and CPU architecture). A host left pending-key (an add interrupted, or a login that did not reach it) has its setup finished by the probe, as add does it. |
hale habitat host remove <name> [--plan] |
Removes a registered host from the habitat record, planned first: on a host with allocations the plan lists each one and what stops or is deleted there, and the removal waits for the host’s name typed back at a terminal (--plan prints the plan and exits). |
Machine Readings and Dashboards (node exporters, Grafana)
Section titled “Machine Readings and Dashboards (node exporters, Grafana)”The habitat reads every machine it runs on. hale habitat up (on this machine, or on the machine --host names, over your SSH login) and hale habitat host add (on the new host) install a Prometheus node exporter on :9100: on Linux the container hale-node-exporter, on macOS the release’s own node_exporter under launchd (a LaunchAgent when you are logged in at the Mac, otherwise a LaunchDaemon, for which sudo asks once at your terminal). A container on a Mac would read the VM docker runs in, not the Mac. If an exporter already answers on :9100, the habitat scrapes it as it is and never touches it. host remove and down --forget take the habitat’s own exporter off again, unless another habitat on the machine reads it too: the exporters are the machine’s, shared, and each habitat records itself as an owner, so the last one to leave takes them off.
The habitat’s senses’ store (its Prometheus) scrapes each machine as the job host, with a host label naming the machine. The habitat keeps the target list in step with its hosts: adding or removing a host rewrites it.
A Grafana runs behind the face at /grafana/ (the dashboards link in the operator face), signed in as you through the face’s own sign-in: there is no Grafana login. Its home dashboard, Hosts, opens on a table with one row per machine: its memory and main disk, each total, in use and free and the share used, how busy its CPU has been over the last 5 minutes, and its NVIDIA GPUs: how busy, their memory and memory in use, temperature and power draw (blank on a machine without one). Each share used or busy is a percent with a gauge beside it (amber from 75%, red from 90%), the gauges of a column lined up row under row. Below it, it shows whether each machine answers, its uptime, CPUs and memory, and over time CPU busy, load per core, memory used, disk used, network and disk throughput, for Linux and macOS machines alike, plus a Linux machine’s CPU frequency. up and status print its address:
grafana http://<habitat>:<port>/grafana/ (compose service grafana, behind the face's sign-in; started at its first use, stopped after 15 minutes unused)node local: node_exporter 1.11.1 on :9100, a container of the habitat's (hale-node-exporter)Working on the face against a running habitat. The face reads its browser assets once at start, from the toolchain’s embedded copy. To try a checkout’s dna/face/web on a habitat without rebuilding the image, copy it to <habitat directory>/face-web/ (the directory the face service has as its home) and docker compose restart face; the face’s log says it is serving the override. Remove the directory and restart to return to the embedded assets. HALE_FACE_WEBROOT names any other directory.
Grafana runs only while someone uses it. up creates its service without starting it; the first time you open /grafana/, the face starts it and shows a “starting the habitat’s dashboards” page that reloads itself every few seconds until Grafana answers (if Grafana does not come up within a minute, the page says why and stops reloading; reload it to try again). Once nobody has used it for 15 minutes, the face stops it again. A dashboard left open in a browser tab refreshes itself every 30 seconds, and that counts as use. HALE_DNA_GRAFANA=on keeps Grafana running from up to down instead. The dashboards come with the toolchain: when an up brings dashboards that changed, Grafana shows the new ones from then on (it reads its dashboard files again every 10 seconds, and up restarts a Grafana it leaves running when they changed); an up that changed none restarts nothing.
Beside each node exporter runs a container exporter (cAdvisor, the container hale-cadvisor; on a Mac, inside docker’s VM), and Grafana’s Services dashboard shows what runs where, whatever a machine’s system: every container on every machine with the organism and part it is, its image, uptime, CPU, memory and network, and the restarts and out-of-memory kills in the window, and in the same table and graphs every service the habitat placed on a host with organism place (kind systemd or launchd), read from its own readings: whether it answers (one that does not shows as down), its uptime, memory and CPU. Every container the habitat runs is labelled hale.habitat, hale.organism and hale.role (an organism’s own compose services through an override of the habitat’s, never by editing its files), so the dashboard shows the habitat’s containers by default, organism by organism, with show: everything on the host for whatever else a machine runs beside them.
Every exporter download rides out a short network blip (curl retries the macOS archive, and docker’s image pulls are tried five times). One that still fails says why on the exporter’s own line, never as a stray line of curl’s or docker’s, and what retries it:
node local: no exporter: the download from github.com failed (curl 56: Connection died, tried 5 times before giving up); `hale habitat up` again retries itA Linux machine with an NVIDIA GPU (where nvidia-smi -L lists one) also runs a GPU exporter, nvidia_gpu_exporter (the container hale-gpu-exporter on :9835, its image pinned by digest), which reads nvidia-smi through docker’s NVIDIA runtime, so the machine needs the NVIDIA Container Toolkit; without it, the install says so and runs none. Macs and machines without such a GPU run none and say nothing of it. The senses scrape it as the job gpus: the hosts whose probe found a GPU (a host added before this release is looked at again by hale habitat host probe <name>), a machine that joins with one, and the habitat’s own machine while an exporter answers there. A GPU whose memory is the machine’s (a GB10’s) reports no memory of its own, and the Now table leaves its GPU memory blank rather than invent one: its use shows in the machine’s memory columns.
gpus gpu-box: nvidia_gpu_exporter 1.17.0 on :9835, a container of the habitat's (hale-gpu-exporter)HALE_DNA_NODE_EXPORTER=off (all three exporters) and HALE_DNA_GRAFANA=off leave either out of a run (spec/habitat.md, Readings).
Reflexes and Alerts
Section titled “Reflexes and Alerts”An organism declares what it watches for in its readings as reflexes, under [dna.reflex.<name>] in its manifest: a PromQL condition, how long it must hold, a severity and a summary. They render to standard Prometheus alerting rules, so the same declarations work in a habitat and in a heart you run yourself. Every habitat watches its machines’ disks, memory and CPU by default: a disk more than 90% full for ten minutes, or one that fills within a day at its recent rate; memory more than 90% in use for fifteen minutes; CPUs more than 90% busy for fifteen minutes. The operator face’s alerts screen shows what is firing, and what is about to.
An Organism’s Own Host Commands (organism place)
Section titled “An Organism’s Own Host Commands (organism place)”An organism can declare commands of its own for the habitat to run on a host, in its manifest under [dna.host.<name>]. voice declares node, which turns a machine into a voice node: it installs what the machine needs to serve models, outside compose, and registers it with voice’s api.
hale habitat organism place voice node --host gpu-1.lan --plan # what would run, and wherehale habitat organism place voice node --host gpu-1.lan # asks for the host's sudo password here, when it needs onehale habitat organism unplace voice node --host gpu-1.lanA command declared root = true, and the packages a host lacks, run under your sudo on the host. When that sudo needs a password, place asks for it here before anything runs, as sudo password for you@gpu-1.lan:, on your terminal even when the command’s output is piped or logged, checks it (a wrong one is asked again, three times), and hands it to the host’s sudo over the SSH session’s stdin: never on a command line, in a variable or in a file. Off a terminal (a script, a CI job) a host whose sudo needs a password is refused at once, naming the host; give the login a NOPASSWD rule there, or run it at a terminal. Before each install starts, a line says which host it is on and that it may build for a few minutes, so a long quiet build is not taken for a hang.
local is always the machine you type on. With the habitat on this machine, that is the habitat’s own machine, the host its rows call local: on a laptop with no other hosts, --host local places the command right there, without enabling SSH to yourself or adding the laptop as a host. Every script runs on this machine with sh, as you (sudo asks at this terminal). With the habitat on another machine (up --host rack-a.lan), --host local is still this machine: once you have added it as a host (hale habitat host add <its name>, a name the habitat’s machine reaches it at), its scripts run here and the placement is recorded under that name; until then it is refused, naming that command. The habitat’s own machine is then --host rack-a.lan (or --host rack-a), reached over the login the pointer names. A placement on the habitat’s own machine has the {id} of its name’s first label (local for a habitat on this machine) unless --id says otherwise, its {api_url} the address the services allocation publishes (the loopback is right for a node on the same machine), and it is recorded under local, its readings scraped at host.docker.internal:
hale habitat organism place voice node --host local --plan # a native GPU node on this machine, outside dockerThe command runs in the organism’s own source at the revision the habitat pins, over your SSH login. The host clones that source itself, so a sapling added from a local checkout (hale habitat nursery add /path/to/checkout, whose repository is that path) places only on the machine the path is on, where its scripts run here (--host local); on any other host, the habitat’s own machine through a pointer included (it holds only the nursery’s mirror), place refuses before it runs anything, and says to push the commit and add the nursery as <url>#<commit> (hale habitat nursery add https://…#<sha>). The habitat provisions what it needs to run at all: it installs what the host lacks of hale’s build prerequisites (git, curl, tar, clang, OpenSSL’s and zlib’s headers) with the host’s package manager, and the hale release the organism declares ([dna] toolchain = "v0.30.1" in its hale.toml; else the habitat’s own) into a directory of its own on the host. A declaration’s requires (docker, systemd, nvidia-gpu, apple-silicon, gpu, which an NVIDIA GPU, an Apple Silicon Mac, or on Linux an AMD or Intel GPU meets; a list, or a table by platform such as { linux = ["docker", "gpu"], macos = ["gpu"] }) is checked against the host before anything is installed; --plan shows all of it. Its inputs are the host’s {id} and the {api_url} its api_service publishes. A secret the seed declares with host.<command> among its readers ([dna.secrets.<name>], The Skin) is read from the habitat’s vault (on the habitat’s machine, through a pointer), written over your SSH login’s stdin into ~/.local/share/hale/hosted/<organism>.vault/ on the host (mode 700, each entry 600), handed to the command as HALE_VAULT_DIR and HALE_SECRET_<NAME> through env (so sudo keeps them), and removed when it ends; every run is also handed the habitat’s name as HALE_DNA_HABITAT_NAME, and HALE_DNA_HOST_RESERVED_BYTES, the memory the habitat’s own containers on that host may hold (the sum of their compose mem_limits: on the habitat’s own machine its memory, nerves, senses’ store, forge and Grafana, which counts though it starts on demand; on any host the organisms’ allocations applied there; 0 when it runs nothing there that declares one), which a provider’s node subtracts from the memory it offers models, so a node on the habitat’s own machine does not promise models what the habitat may take (--plan names it on its reserve line); a value is never on a command line or this machine’s disk. --plan names each secret it would hand over, a family with its members’ labels, and each it skips; place refuses while a required slot is unfilled or a required family has no member, an optional = true one is done without (an unset slot not handed, a family with none handed empty), and unplace is never refused for a missing secret. The old operator_token key and {operator_token_file} input are refused: declare the token as a drawn secret instead. When the declaration names its service (voice’s is voice-node-<id>, a systemd unit on Linux and a launchd service on macOS), place ends by asking the host’s service manager that it runs, and unplace that it is gone (spec/habitat.md, Host commands).
The habitat remembers what it placed: place records a habitat.placed row through the head once the service runs (unplace a habitat.unplaced one), and hale habitat status lists each placement under its host. A declaration that says where its service serves its readings watches it without polling anything:
[dna.host.node]service = "voice-node-{id}"readings = 9464 # the service's std::observe::Scrape port--plan and place name the endpoint (http://gpu-1.lan:9464/metrics), which the head registers with the habitat’s senses as it records the placement; every Hale program serving a std::observe::Scrape carries the runtime’s own memory, CPU time and start time, which the Services dashboard charts. Removing the host, the organism or the whole habitat runs each placement’s own uninstall first, over your SSH login (sudo asks at your terminal), and then removes the organism’s checkout and the toolchain it installed there once nothing placed there uses them; a placement it cannot take off is named with the exact unplace that does, and the rest goes on.
Saplings and Nurseries (hale habitat nursery / graft <sapling>)
Section titled “Saplings and Nurseries (hale habitat nursery / graft <sapling>)”While a pack is a reusable template of rows adopted inside an existing organism (positions, mandates, practices, knowledge), a sapling is a complete, prebuilt organism template published in a nursery and pinned by repository URL, Git revision, file tree SHA-256 digest, and default packs.
hale habitat nursery listhale habitat nursery add https://example.com/nursery.githale habitat nursery refreshhale habitat nursery ratify <sapling>hale habitat nursery add https://github.com/hale-lang/voice # voice is its own nursery, at its default branchhale habitat nursery add https://github.com/hale-lang/voice#v0.1.4 # or pinned at a release tag (or a commit)hale habitat graft voice --host rack-a.lan --plan # the plan, part by part; nothing graftedhale habitat graft voice --host rack-a.lan # prints the plan and asksA graft plans each body part first. The organism plane (its record in memory, its nerves, its senses) reuses the habitat’s, on the habitat’s machine; --own memory=rack-b.lan gives it a server of its own on a host instead. The application plane is the organism’s own: its compose services on the --host machine (with no --host, the habitat’s own machine, exactly as --host local places them there; the graft says where they went), and the database or broker it brings ([dna] brings in its hale.toml, as voice brings its own Postgres and NATS); --reuse database has the habitat provision one instead.
The habitat runs a sapling’s body. An organism grafted from a sapling lives in the habitat’s store, where nobody runs hale dna dev for it, so the habitat does: its body is an allocation (<key>/body) on the habitat’s own machine, a compose service body-<key> beside the habitat’s own body, from the same image and with the same mounts and environment, running hale dna dev <its directory> --no-iris. That is what runs its organization, so the verdicts its graft recorded (its packaging ratified) are executed and its Reviews settle with no hand step. The graft starts it (body its body (<key>/body) on <machine>); up and apply bring it back and record it for an organism grafted before bodies were kept; organism upgrade restarts it on the new revision; down stops it, drained, and organism remove and down --forget remove it. hale habitat status shows it under the organism (body body-<key> up (…)), and hale dna status in the organism’s directory says running. Its face and head run beside it as face-<key> (hale dna head <its directory>, on the ports its graft recorded, signing in through the habitat’s identity), so the face and head the habitat’s Organization screen lists for it answer; they come and go with the body. Both are told the habitat they live in, HALE_DNA_HABITAT_NAME and HALE_DNA_HABITAT_FACE (the habitat face’s origin, http://<address>:<port>, as hale habitat status prints it on its face line), so the organism’s own face knows its habitat: its org read (Commands::org, what its Organization screen draws) answers habitat: { name, face }, from which the face links back through <face>/organisms/<name>/face. Both are "" on the habitat’s own face and for an organism you run outside a habitat. Its face lists the habitat’s other organizations too: the face’s Index read carries organizations, the habitat first and then each organism with the link that hands you into its face (its own entry marked current: true), which its head reads from the habitat’s head at most every 30 seconds (showing a proof of its own launch token, which only the faces the habitat keeps hold). The list is empty while the habitat does not answer, and the read answers anyway. It stays on the habitat’s machine wherever the organism’s services go (moving it is not built), and a habitat started with up --no-body runs none. A directory you graft from your own checkout is yours to run.
The habitat tells the application’s compose which of those roles it runs itself: every time it brings the compose project up (at the graft, apply, a host’s re-apply, an upgrade) it sets COMPOSE_PROFILES to database, broker, both (database,broker) or none, from the graft’s choices. Put the application’s own Postgres under profiles: ["database"] and its own NATS under profiles: ["broker"], and they run only when the application provides that role; services with no profiles: always run. The habitat’s value wins over a COMPOSE_PROFILES in a .env at the application’s root, so a .env saying COMPOSE_PROFILES=database,broker is a safe default for an older hale that sets none. With --reuse database (or broker), the habitat hands the application’s compose HALE_DNA_DATABASE_DSN (or HALE_DNA_BROKER_URL, _USER, _VAULT, _SUBJECTS, _NODE_USER, _NODE_VAULT), puts the passwords those name in the reader vault HALE_VAULT_DIR names, and joins the habitat’s Postgres and NATS to a network of the application’s own as hale-database:5432 and hale-broker:4222, which its services join. That is for services on the habitat’s own machine; a graft whose services go on another machine is refused --reuse of a role it brings. --reuse is also refused, before anything is made, when the compose file never reads HALE_DNA_DATABASE_DSN (or HALE_DNA_BROKER_URL): the habitat’s server would sit unused beside the application’s own. --own database keeps the application’s own.
-
Grafting by name (
hale habitat graft <sapling>): Pass a bare sapling name (hale, the one the toolchain carries, or one a trusted nursery offers, such asvoice;./<name>denotes a local directory). A repository can be its own nursery: anursery.tomlat its root whose[[sapling]]saysrepo = "."(and no revision or digest) offers the repository itself, pinned at the commit the habitat reads. That is howhale-lang/voiceis offered; the toolchain bundles no application. The habitat fetches the pinned revision into<habitat>/saplings/<name>, verifies its file digest against the nursery pin (aborting on any mismatch), grafts it as a child of the habitat, proposes its bundled packs, and records the sapling name, revision, and digest on the graft row. Thehalesapling (the organism that works on the Hale toolchain) is a tree the toolchain itself carries, with no remote.hale habitat graft halemakes it the organism’s own repository in the habitat and checks its digest the same way. Like every graft, it mirrors that repository to the habitat’s Forgejo; nothing of an organism’s own goes to GitHub unless its Board allocates GitHub later. -
A genome’s codebases attach at its graft: a
[[dna.codebase]]list in the sapling’shale.toml(each withname,repo,branch,build,test,toolchain) becomescodebase.attachedrows of the grafted organism’s record, once each; nothing is cloned until a leg works one. The toolchain nursery’shalesapling is the hale organism: its genome is its own small repository, and its codebases arehale-lang/haleandhale-lang/voice. -
Updating sapling pins (
refreshandratify): Runninghale habitat nursery refresh(also run duringhale habitat up) inspects all trusted nurseries. Newly discovered saplings are pinned automatically; if an already-pinned sapling offers a newer revision, the habitat files it for the Board without moving existing organisms. Runhale habitat nursery ratify <sapling>to pin the newer revision for future grafts. A git nursery can be trusted at a revision (<url>#<tag-or-commit>); adding the same repository again at another revision re-pins it (the earlier source is retired, sorefreshreads the revision named last), which is how an organism grafted from one release moves to the next without a reset:Terminal window hale habitat nursery add https://github.com/hale-lang/voice#v0.1.4hale habitat nursery refresh && hale habitat nursery ratify voicehale habitat organism upgrade voice -
Moving a grafted organism to the ratified revision (
organism upgrade): an organism already grafted stays where it was grafted until you move it, keeping its record, its data and its allocations:Terminal window hale habitat organism upgrade voice --plan # from -> to, the migrations, the services rebuilt, the placements re-runhale habitat organism upgrade voiceThe upgrade fetches the pinned revision into
<habitat>/saplings/<name>and checks its digest exactly as a graft does (a mismatch moves nothing), checks the organism’s tree out there with what its graft wrote carried (the record’s pin in itshale.toml, the tables and.gitignorelines the graft added), re-materializesvendor/dna, runs the heart’s declared migrations, re-applies its services allocation (its images pulled for the new revision, or built from the new tree when it publishes none; see below), and records ahabitat.organism.upgradedrow. Anything else changed in that checkout is carried only when it applies cleanly at the new revision; otherwise the upgrade refuses before anything moves. Last, each host command placed for it (organism place) that is behind the pinned revision runs itsinstallagain at it, over your SSH logins. A placement records the revision it installed once its install succeeds, so if an upgrade stops part way (a host that does not answer, a build that fails, Ctrl-C), runninghale habitat organism upgrade <name>again re-places only the placements it did not reach;--planlists them, andhale habitat statusshows a placement’s revision when it is not its organism’s. A placement recorded before placements named their revision is re-placed when the organism moves, and named with itsplaceline otherwise. An organism already at the pinned revision with nothing behind is refused, naming a newer revision that waits forratify. Through a pointer, everything but the placements runs on the habitat’s machine. -
A nursery in a local directory:
hale habitat nursery add ./my-nurserytrusts a directory as a nursery. Its saplings are pinned at the directory’s committedHEAD, never its working tree: commit first, since uncommitted changes and untracked files are not part of any sapling. The habitat stages a copy of the nursery and a mirror of each sapling repository on your machine under its own directory (nurseries/<key>andnurseries/repos/<key>), and grafts and upgrades fetch from that mirror. This works for a habitat on another machine too (one you brought up withhale habitat up --host <machine>):nursery addstages the directory on your machine, then ships the staged copy and its mirrors to the habitat’s machine over the same SSH login the pointer uses, into the habitat’s directory there, before the Board trusts it. A later commit reaches the habitat throughnursery refresh, which stages and ships every trusted directory nursery again before it reads them, so the new commit is filed for the Board to ratify:Terminal window hale habitat nursery add ./my-nursery # staged here, shipped there, trusted, readgit -C ./my-nursery commit -am "next" # a new revision of its own saplinghale habitat nursery refresh # shipped again; the new commit filed for the Boardhale habitat nursery ratify my-app && hale habitat organism upgrade my-app
Released Organisms Run from Published Images
Section titled “Released Organisms Run from Published Images”An organism’s compose services are applied with HALE_DNA_REVISION set to the full commit its sapling is pinned at (its host commands and heart migrations get it too). A compose file that names its images by it, beside its build:,
services: api: build: . image: ghcr.io/hale-lang/voice:${HALE_DNA_REVISION:-dev}is applied without --build: compose pulls the revision’s published image and builds from the context only when none is published, so an organism grafted at a release comes up with nothing compiled on the host. An image named by its revision is that revision’s, so nothing stale under one tag is reused; a compose file that does not name its images this way is built from its context at every apply, as before. voice publishes ghcr.io/hale-lang/voice:<commit> for every commit on its main branch and every tag, for linux/amd64 and linux/arm64, and its node install fetches a prebuilt voice-node the same way. Build what you publish with hale build (portable by default since v0.32.1; --target-cpu native only for a binary that runs where it is built).
The Habitat’s Models
Section titled “The Habitat’s Models”The default model backend of every organism the habitat grafts is the habitat’s own: an organism that declares in its hale.toml that it provides models (voice does), with no person minting a key. No hosted placeholder is written at graft: an organism grafted with no model key in the vault gets no hosted backend at all (a harness on PATH, else the desk), and hale dna secrets lists no model key for it.
[dna.provides.models]service = "api" # the compose service that serves itpath = "/v1/chat/completions" # the defaultmodels_path = "/v1/models" # the defaultkey = "tenant-key" # a drawn family: a member per tenant
[dna.secrets.tenant-key]kind = "drawn"family = truereaders = ["api"]Once the provider’s services are applied (a sapling grafted, on its --host or the habitat’s own machine), for every organism the habitat holds, the provider among them, and for the habitat itself (its own infrastructure, whose key is labelled habitat):
- a member of
tenant-keylabelled by the organism’s name (the habitat’s own,habitat) is drawn into the vault and staged in the provider’s reader vault where its services run, in place, so its running api reads it (compose hands itHALE_VAULT_DIR,HALE_SECRET_TENANT_KEYandHALE_SECRET_TENANT_KEY_FAMILY, the members’ common prefix); - the value is copied into the organism’s own slot,
model-HABITAT_<KEY>; - the provider is asked what it serves (
GET <its link>/v1/models, the organism’s key as a bearer token; each model says whether the key may use it,available, and whether it returns tool calls,capabilities.tools: voice keeps both under each entry’svoiceobject and says so withextension = "voice"); - the organism’s model map is seeded in the name
hale habitat:think.*to the first model served,tools.*anddo.*to the first that returns tool calls (none when none does), each at the provider’s/v1/chat/completionswith the key’s slot. A category a person mapped is never written over.
The graft does this, and grafting the provider does it for every organism already there (and so does hale habitat apply when it applies the provider’s services). The habitat never grants an account at the provider: who pays is yours to decide. So when the provider serves an organism nothing yet, the graft (or the apply) ends in a next line in the provider’s words (its grant, where {organism} stands for the organism and {habitat} for the habitat’s name), naming where the provider answers. Voice gives a new tenant no accounts until its operator does, and every tenant inherits the habitat’s own project, so a first graft of voice ends:
next voice serves no model to voice and habitat yet, and who pays is yours to decide: grant home-habitat's project accounts in voice's admin UI (Projects) (voice answers at http://<habitat>:<port>/), then `hale habitat models --all`hale habitat status asks the provider too, with the habitat’s own key, and says the same next line while it serves the habitat nothing. Once an account is granted (and a model placed), hale habitat models <organism>|--all [--plan] does it again. hale dna secret rotate tenant-key --member <organism> in the provider draws an organism’s key anew (the habitat updates its copy), and removing an organism removes its key. A habitat holds one models provider: grafting a second is refused, naming the first. --all includes the habitat itself, and hale habitat models habitat maps it alone. A provider names what it keeps for each tenant by its label (voice’s projects are <habitat>-<label>, the habitat’s name from HALE_DNA_HABITAT_NAME), so no organism may be called habitat: grafting one (a directory or a sapling of that name) is refused.
Every organism the habitat grafted has its services handed the habitat’s name as HALE_DNA_HABITAT_NAME (what hale habitat up --name named it; local by default), wherever they run, and so does a repository body’s compose when the habitat grafted it. As with its secrets, the compose file passes it to the services that read it:
services: api: environment: HALE_DNA_HABITAT_NAME: "${HALE_DNA_HABITAT_NAME}"Pairing an Agent with a Person (MCP)
Section titled “Pairing an Agent with a Person (MCP)”The habitat’s head serves its command surface over MCP as well as over its socket and its HTTP commands port, with the same bearer and the same roles. hale habitat status prints the endpoint as mcp://127.0.0.1:<port>. An agent’s host connects with the person’s ID token, the bearer their face session holds:
HALE_API_TOKEN=<the person's ID token> hale mcp --app mcp://127.0.0.1:<port>The agent’s tools are the head’s rows that person may call (Commands__hosts, Commands__add_host, …). A row they may not call is refused unauthorized, exactly as the face is refused, and every act is a row in their name. hale habitat brief (the row Commands__brief) is where such an agent starts: the Board’s charter, the rules it works by, and the live state. agents/operator.md is the agent’s own brief: the words, the rules, and which rows read, act or propose.
Publishing to GitHub (hale habitat forge publish)
Section titled “Publishing to GitHub (hale habitat forge publish)”Work on an organism lands and is reviewed at the habitat’s own Forgejo. GitHub, when you want the code there too, is a sink you feed explicitly and in batches: each publish is one pull request on GitHub, from your own token.
# once: where the organism's main goes, and the vault slot of the tokenhale habitat forge shop github --repo acme/shop --publish # --key-vault <slot>; forge-token by defaulthale dna secret set FORGE_TOKEN # in the organism's directory: fills forge-token
# then, whenever you want GitHub to catch uphale habitat forge publish shop --dry-run # what it would push, and the pull request's bodyhale habitat forge publish shop # push sync/<today> and open (or update) the pull request--publish leaves the organism’s forge alone: the Forgejo stays where reviews happen, and the setting only says where a publish goes (none --publish stops publishing). A publish pushes the internal main to GitHub as the branch sync/<YYYY-MM-DD> (UTC; --branch <name> for another) and opens one pull request against GitHub’s main. Its body lists the internal pull requests merged since the last publish, by title and internal number, with no links into the private forge; the first publish lists everything since GitHub’s main. Publishing again the same day moves the branch forward and updates that pull request instead of opening a second one.
Internal titles are made inert on the way: a zero-width joiner follows every # and @, so #12 links none of GitHub’s issues and @alice notifies no one, though both read as written.
A publish never force-pushes and never touches the internal main. When GitHub’s main has commits the internal one lacks (its merge queue merges the last publish’s pull request with a merge commit), the branch it pushes is a merge of the internal main and GitHub’s, authored as the owner of the GitHub token; if the two conflict, it stops and names the files, to be resolved in the internal forge. It also stops, saying what to do, when the organism has no Forgejo allocation, names no GitHub repository, or the vault holds no GitHub token. With a habitat on another machine (up --host), the publish runs there, in the habitat’s toolchain image, where its vault and Forgejo are; you see its output here.
Walkthrough: Deploying and Querying voice in a Habitat
Section titled “Walkthrough: Deploying and Querying voice in a Habitat”This walkthrough covers taking a machine with hale, docker compose, git, and a browser from a cold start to streaming an LLM completion response through voice, grafted from its own repository as a nursery.
1. Start the Habitat and Inspect Status
Section titled “1. Start the Habitat and Inspect Status”hale habitat uphale habitat statushale habitat up initializes the root habitat organism (if not already initialized), starts its Postgres (memory), NATS JetStream (nerves), Prometheus (senses), and Forgejo (forge) containers alongside the habitat’s body and face containers under a single Docker Compose project, registers the local host, and records the head’s URL on the profile row and in head.url (override on any hale habitat or hale dna verb with --head <url> or HALE_DNA_HEAD_URL). status prints the genome, body status, active allocations, and operator face URL:
face http://127.0.0.1:<port>/ (up, ...)2. Sign In to the Operator Face
Section titled “2. Sign In to the Operator Face”Open the face URL in your browser. On a local habitat, the head redirects through the local OIDC identity provider, signs you in automatically as local-sub (mapped to your local user for an 8-hour session with no password setup required), and displays the four screens: habitat (its name, and the web UIs of every organism with their links: Web UIs on the Home Screen), hardware, infrastructure, and organisms (The head and the face), with links to the organization shell and the habitat’s dashboards (Grafana).
3. Graft the voice Sapling (Local or LAN Host)
Section titled “3. Graft the voice Sapling (Local or LAN Host)”Trust voice’s repository as a nursery (it offers itself), then graft it onto the local machine:
hale habitat nursery add https://github.com/hale-lang/voicehale habitat nursery listhale habitat graft voicegraft fetches the pinned revision of voice into <habitat>/saplings/voice, verifies its SHA-256 tree digest, grafts it as a child organism of the habitat, and allocates its requested roles (memory, nerves, heart database, and broker).
To place voice onto a remote LAN host over SSH instead (register the host with host add and host probe first):
# Register the LAN host; over your own SSH login it authorizes the habitat's key there and probes it:hale habitat host add rack-a.lan --user ops
# Verify SSH connectivity and host capabilities (docker compose, OS, arch):hale habitat host probe rack-a.lan
# Graft voice onto rack-a.lan:hale habitat graft voice --host rack-a.lan4. Apply Allocations and Start voice Services
Section titled “4. Apply Allocations and Start voice Services”hale habitat apply materializes each placed allocation on its target host via that host’s provider and reports live health (up, degraded, or down):
# Materialize placed allocations and print health pulse:hale habitat applyWhere each allocation runs is a row the Board writes: hale habitat place <key>/<role> <host>. hale habitat apply makes it so. It takes each moved allocation down where it ran and brings it up on its new host with that host’s provider, then prints what each allocation looks like now (up, degraded or down). An allocation on another machine is reached at that machine’s name and the port it publishes there, so the DSN and the nerves’ URL follow it.
The habitat keeps what it applies running. Every long-running service gets the restart policy unless-stopped: the memory, nerves, senses’ store and forge it writes itself, and an organism’s own compose services through an override file of the habitat’s (the organism’s compose file is never edited). A crash is a restart docker makes, and so is a reboot of the host; a service the habitat stops or withdraws stays stopped. A policy the organism’s compose file states (restart: or deploy.restart_policy) is left as it is, and a one-shot, a service another waits on with condition: service_completed_successfully (a migration), gets none, so it never runs again after it finished. A one-shot nothing waits on looks long-running to the habitat: give it restart: "no" in your compose file.
hale habitat status and apply say what a crash left. A service that exited is named with its code, degraded (3 of 4 running; not running: api (exited 139)); one docker is restarting with its code and count, api (restarting, exited 139, 7 restarts); one running again after docker restarted it with its count, restarted: api (2 restarts). A service that came back only seconds ago keeps the allocation degraded, so a crash loop never reads as up.
A moved memory starts empty, because nothing migrates. A memory that holds its organism’s record moves only with hale habitat apply --fresh, and the habitat’s own memory does not move at all. hale habitat graft <sapling> --host <name> grafts an organism straight onto a host: its memory, nerves and services run there from the start, and its record is born there.
(To move an allocation to another host before applying: hale habitat place <key>/<role> <host>, then hale habitat apply. Moving a stateful memory allocation across hosts requires hale habitat apply --fresh, which initializes a fresh store on the destination host.)
voice’s image downloads the released Hale toolchain itself when it is built (its Dockerfile), so the first apply needs the network and takes a few minutes; nothing is staged by hand. The head runs the apply in a process of its own, so the face and every other command keep answering while it builds; hale habitat apply follows it, says which allocation it is applying, and prints the pulse when it ends. One apply runs at a time: a second apply while one runs follows the running one and says so.
The operator face’s organisms screen lists each of voice’s allocations with what its services publish: a link where the port is reachable from your machine (api opens voice’s console, its admin UI served at the api’s /), and loopback only on <host> for a port bound to that host’s loopback.
Web UIs on the Home Screen
Section titled “Web UIs on the Home Screen”A link to a grafted organism’s face from the habitat’s org chart goes through the habitat head’s /organisms/<name>/face, which hands you in signed in (the organism’s face has its own launch-token gate, as every face does). The operator face’s first screen, habitat, lists the web UIs across all your organisms: each organism’s face (voice face), and each UI an organism declares in its hale.toml, with its label, its organism, its link and how to sign in:
[dna.ui.console]label = "voice console" # what the home screen calls itservice = "api" # the compose service that serves itpath = "/" # where under that service's address (default "/")login = "operator-token" # optional: a declared secret (person = "read") you sign in withThe link is the address the organism’s services publish for that service, as the organisms screen links it, with path after it; a service published only on its host’s loopback is shown as loopback only on <host>. A UI with a login says which command prints the secret from your machine, hale habitat organism <organism> dna secret show <login> (the secret must be declared under [dna.secrets.<login>] with person = "read", The Skin); the value itself is never shown. The declaration is read from the organism’s directory each time the screen asks, so an upgrade’s is the one listed. hale habitat graft refuses a manifest whose UIs are refused (an unknown key, no label or service, a path not starting with /, a login naming no readable declared secret), and hale dna declared-uis prints the declaration as the toolchain reads it.
voice’s Compose definition publishes its api (port 8080) and its NATS (port 4222) on the listen address of the host it is placed on (HALE_DNA_HOST_LISTEN), so a browser or a node on another machine reaches them at the host’s name; on this machine they stay on 127.0.0.1. Every plane of the api takes a bearer, so nothing rests on loopback: a project key on /v1, a node’s enrollment token on /node/v1, and the operator token on /admin/v1. Name the api’s address once (localhost:8080 when voice runs on this machine, rack-a.lan:8080 when it is placed there) and check that it answers:
api=http://rack-a.lan:8080 # or http://localhost:8080 on this machinecurl $api/healthzvoice mints its operator token on its first start and keeps it in its Postgres; it is never in the environment or a log. Print it on the host running voice (use docker compose ls there to find the compose project name; its api container is <project>-api-1):
(umask 077; ssh ops@rack-a.lan docker exec <project>-api-1 voice-api admin-token > admin.token) # created mode 600The console (the api’s /, the organisms screen’s api link) asks for this token once and keeps it in the browser.
5. Configure a Model, Project Key, and Node Seat on voice
Section titled “5. Configure a Model, Project Key, and Node Seat on voice”Configure a model (echo-1), billing account, project API key, and worker node seat via voice’s admin API (or via the console at $api/, which asks for the operator token). Every admin call presents the operator token, here from a header file so it is on no command line. Using the built-in static engine requires no external weights or GPU:
json='content-type: application/json'(umask 077; printf 'Authorization: Bearer %s\n' "$(cat admin.token)" > admin.h)curl -X POST $api/admin/v1/models -H @admin.h -H "$json" -d '{"id": "echo-1"}'curl -X POST $api/admin/v1/accounts -H @admin.h -H "$json" -d '{"id": "static", "name": "Static"}'curl -X POST $api/admin/v1/projects -H @admin.h -H "$json" -d '{"id": "work", "name": "Work"}'curl -X POST $api/admin/v1/projects/work/keys -H @admin.h -H "$json" -d '{"name": "laptop"}'curl -X POST $api/admin/v1/nodes -H @admin.h -H "$json" -d '{"id": "local"}'curl -X POST $api/admin/v1/nodes/local/seats -H @admin.h -H "$json" -d '{ "id": "static", "engine": "static", "account": "static", "serves": [{"model": "echo-1"}], "config": {"text": "hello from voice"}}'- Save the
"secret": "vk-..."token returned by/admin/v1/projects/work/keys. - Save the
"enrollment_token": "vn-..."returned by/admin/v1/nodesand startvoice’s node container with it (usedocker compose lsto find the compose project name):
# on the host running voice:VOICE_ENROLLMENT_TOKEN=vn-... docker compose -p <project> up -d node(To serve a live local LLM, replace "engine": "static" with an "openai-compatible" seat pointed at a local Ollama or vLLM endpoint.)
6. Point Every Organism’s Model Map at voice
Section titled “6. Point Every Organism’s Model Map at voice”voice provides the habitat’s models (The Habitat’s Models): its graft keyed every organism the habitat holds and mapped each one’s model map at it, or said that it serves none yet. Once the seat above serves echo-1, map them again and probe one:
hale habitat models --allhale habitat model-probe voice think.standardA map you point elsewhere by hand is kept: hale habitat model-map <organism> think.standard <model> --endpoint <url> --key-vault <slot>, the key in a vault slot (hale dna secret set <SLOT> in the organism’s directory).
7. Send a Streaming Completion Request
Section titled “7. Send a Streaming Completion Request”Query voice’s OpenAI-compatible /v1/chat/completions endpoint directly with curl -N:
curl -N $api/v1/chat/completions \ -H 'Authorization: Bearer vk-...' \ -H 'content-type: application/json' \ -d '{"model": "echo-1", "stream": true, "messages": [{"role": "user", "content": "hi"}]}'voice streams back Server-Sent Event chunks (data: {...} with chat.completion.chunk) terminated by data: [DONE], and records usage under GET /admin/v1/usage (under the operator token).
Operational Notes
Section titled “Operational Notes”- Stopping and restarting:
hale habitat statusreports any degraded or stopped allocations, with the exit code and restart count of a service that crashed (docker restarts a long-running one itself).hale habitat downstops the body, the face, the organisms’ bodies and every service and removes nothing;hale habitat upbrings it back online. - Forgetting a habitat:
hale habitat down --forgetremoves the habitat whole, plan first, like terraform. It prints everything it would remove, grouped: the habitat’s record and memory (row count, organisms, newest row), each grafted organism (record, genome repository, Forgejo repository, allocations by host), the compose projects and volumes, the vault slots (by name, never a value), the Forgejo instance and its accounts, the hosts, and what it runs on each host over SSH, each line with its size or count and whether it is recoverable. Nothing is touched until you type the habitat’s name back at a terminal; there is no--yes, and without a terminal it refuses.--planprints the plan and exits. A forget that fails part way says what was done and what was not, and running it again plans from what remains. The habitat cannot remove the line each host’s~/.ssh/authorized_keystook, so the CLI does, over your own SSH login, by the key’shabitat-<id>comment; a host your login does not reach keeps it, the CLI names the line, and the next plan shows the note until a forget clears it. A host that does not answer is planned asunreachable: left on <host>: the habitat’s side goes and what is left there is named. The services placed on the hosts are taken off first (each one’suninstall, then what placing installed there); through a pointer your machine does that over your login before the forget on the habitat’s machine runs, and asks for the habitat’s name for that step. The notes a forget keeps (forgotten-notes.jsonl) last only while something in them is undone: once your machine has taken a host’s key line off, its note goes, and the file and the emptied habitat directory go with the last. The vault’s nerves accounts go too, an application’s among them under every name it was attached by. Slots a person supplied (a GitHub token, a--key-vaultslot) are kept. If anything changes between the plan and your confirmation, the act refuses withplan_changedand you plan again. - Removing an organism:
hale habitat organism remove <name>plans and confirms the same way (its record and memory, genome repository, Forgejo repository and account with its chart’s personas (a person’s user only when no other organism has them), allocations by host, compose services and its body, vault slots), typed back by the organism’s name; the organisms screen of the operator face offers the same. - When
upfails: an allocation that does not come up is reported in its own words: for each containerupwaited on that is restarting, exited with a failure or unhealthy, its state and the last lines it wrote (a full Docker disk shows up as Postgres’sNo space left on device, not as a refusedexec). Fix the cause and runhale habitat upagain: it picks up where the failed one stopped. A firstupwhose memory never came up left no record, so the second draws a new identity for the habitat and clears what was made for the first (its containers and volumes, its vault slots); theupafter that changes nothing. Such a half-made habitat can also be forgotten:hale habitat down --forgetplans from what is on this machine (its directory, its compose projects and volumes, the vault slots named for it) and says that it did. - Resuming interrupted grafts:
hale habitat graftverifies pinned file digests before grafting and resumes cleanly from its last completed step if interrupted. - Model map and graft log rows:
model-mapandmodel-probeare the head’sCommands::set_model_mapandCommands::probe_model; a key is named only by its vault slot.modelsis the habitat’s own act (no head row): through a pointer it runs on the habitat’s machine. The face follows a graft’s log throughCommands::graft_log, which reads only the log of a graft the habitat itself started. - No model: every face screen works with the models catalog empty. Without a model, asks and leg work become handed Tasks that a person takes and reports done as text from the face; nothing waits on a model or times out into a leg (Workflows: with no model).
- SSH host key verification:
hale habitat host proberejects any host whose SSH host key has changed sincehost add; a host inpending-keystate is waiting for the habitat’s public key line in~/.ssh/authorized_keys. - Agent operator brief:
hale habitat briefprints the Board’s live context package (hosts, allocations, organisms, saplings, and pending Board items). It reads the record alone, never the vault.
Running on a Small Machine
Section titled “Running on a Small Machine”A habitat fits on a laptop. Measured on a running habitat (docker stats), with Grafana stopped, which is how it spends most of its time:
| Service | Memory |
|---|---|
face (the face, the head and its children) |
about 105 MiB |
forge (Forgejo) |
about 98 MiB |
body |
about 91 MiB |
| the habitat’s memory (Postgres) | about 81 MiB |
| the habitat’s senses (Prometheus) | about 45 MiB |
hale-cadvisor (the container exporter) |
about 20 MiB |
| the habitat’s nerves (NATS) | about 7 MiB |
| the habitat | about 450 MiB |
grafana, while someone uses it |
about 170 MiB more (capped at 384 MiB) |
Before Grafana ran on demand and was trimmed, it alone held about 500 MiB, half the habitat.
An organism grafted with the habitat’s defaults adds no server of its own for its record or its nerves: its record is a schema on the habitat’s Postgres and its organization an account on the habitat’s NATS. It adds only its own services (voice’s coordinator holds about 200 MiB). An organism grafted with --own memory or --own nerves, or one that needs senses of its own, adds that server: a Postgres about 80 MiB, a NATS under 10 MiB, a Prometheus about 45 MiB.
On a Mac, the containers run inside Docker Desktop’s VM, so the VM’s memory is the habitat’s budget. 3 GB is enough for the habitat, a few organisms and the VM’s own needs (Docker Desktop → Settings → Resources → Memory). A model served by a node outside Docker (voice’s node placed on the Mac itself, for example) uses the Mac’s unified memory directly, not the VM’s, so leave room for it outside the VM: on a 16 GB MacBook Air, a 3 GB VM leaves the rest for macOS and the model.
Two things need more than that, once:
- Building the habitat’s image. A released
halepulls its own image (ghcr.io/hale-lang/hale:<version>, published for linux/amd64 and linux/arm64, so a Mac’s docker VM pulls its own), checks that it runs the same toolchain, and uses it, so nothing is built. Ahalebuilt from source has no published image and builds it once per toolchain commit: it compiles the compiler and then the head’s seven programs in parallel, the largest of which alone peaks near 4.5 GB. For that build, raise the VM (8 GB or more) and lower it afterwards, or build the image on a larger machine and start the habitat from it with--image <tag>(orHALE_HABITAT_IMAGE). - A face that has to build the head. The image already holds the head’s programs, so the face starts without compiling. A face whose image does not hold them (an image of another toolchain commit) builds them on its first start, which takes the same several GB. That is why the face and body have no memory cap: a cap below the build’s peak would kill the build.
Multi-Record Isolation, Sharing, and Identity
Section titled “Multi-Record Isolation, Sharing, and Identity”Records as the Unit of Isolation
Section titled “Records as the Unit of Isolation”The fundamental unit of isolation in DNA is a record: an append-only chain of cryptographically signed rows stored in a dedicated Postgres schema (dna_<record-identity>) paired with isolated NATS JetStream, secret vault, and Prometheus senses allocations. A Git repository is the genome whose hale.toml ([dna] record) pins which record it belongs to.
- Multiple people can collaborate on one record, and one person can participate in multiple records.
- Every Git clone accesses the shared record in Postgres under its assigned database role (
headorspine) rather than maintaining an uncoordinated local database replica. - Every row hashes its predecessor’s digest and carries its author’s signature, preserving provenance whenever rows are exported or inspected.
Deliberate Cross-Record Publication (connect and handoff)
Section titled “Deliberate Cross-Record Publication (connect and handoff)”Two organizations never merge their private records or read each other’s database schemas. Instead, cross-organization collaboration works through deliberate publication:
- Two records establish a Board-ratified connection (
hale dna connect), or two firms maintain private records and agree on a third shared record. - Selected facts (tasks or evidence receipts) are published across the connection via
hale dna handoffas signed envelopes over NATS JetStream, carrying explicit origin, lineage, and purpose metadata. - Sharing a record’s tasks, owners, or grants never exposes either participant’s private context, internal administration, or financial books.
Enforced Visibility and Sealed Protected Evidence
Section titled “Enforced Visibility and Sealed Protected Evidence”Because any principal with read access to record_rows or ledger_rows can read row payloads in plaintext, view-level filtering is never used for confidentiality. Sensitive payloads—along with derived artifacts such as summaries, embeddings, prompts, and worker context hats—are stored outside the row stream as protected evidence (customer or confidential receipts), encrypted at rest in the record’s Postgres memory under HALE_DNA_RECEIPT_KEY, and accessed strictly through an audited, principal-checked boundary (hale dna receipt disclose / show).
Orthogonal Deployment and Trust Axes
Section titled “Orthogonal Deployment and Trust Axes”Every organism independently configures three operational axes:
| Axis | Supported Options |
|---|---|
| Participation | Single individual; a team sharing one record; multiple firms collaborating via a shared record (dna.owner) |
| Deployment | Local workstation (local); remote server body (remote-body); multi-node fleet (hale node) |
| Principal Source | Explicit local UID trust (dna.trust = local, dna.unix.member); verified OpenID Connect provider (dna.principal = oidc) |
Layered Structural Operations
Section titled “Layered Structural Operations”As an organization evolves, capabilities routinely move across process boundaries, ownership boundaries inside an organism, or record boundaries across a habitat. Every structural refactoring operation follows three invariants:
- One operation = one Review: The Board votes on the high-level operation (for example, extracting a service), while the resulting low-level graph rows serve as the execution receipt.
- Explicit change class: Each operation maps to a change class that determines its required ratification authority.
- Pre-proposal invariant checks: Operations validate their preconditions upfront and refuse invalid cuts with a specific diagnostic before opening a Review.
| Layer | Boundary Moved | Operations |
|---|---|---|
| 1. Hale Program | Process & thread placement (code behavior unchanged) | Serve (place a locus subtree behind unix, http, or nats RPC via its api surface), Unserve (return a remote surface in-process), Place (move a locus between thread pools or binaries within the same organism). |
| 2. Single Organism | Responsibility & contract ownership within one record (hale dna apply) |
Open (open), Fill / Vacate (fill, vacate), Merge (merge), Split (split), Assign (assign), Adopt / Retire Pack (hale dna pack apply|retire), Expose (expose), Depend (depend), Externalize (externalize), Internalize (internalize). |
| 3. Multi-Record Habitat | Ownership across separate records (parent/child organisms) | Graft (hale habitat graft), Extract (externalize a part in the source organism and birth a child organism from the copied subgraph with provenance), Absorb (internalize a child organism’s contract back into its parent and retire the child), Re-parent (move a child organism under a new parent ceiling and Board). |
Note that Externalize requires only a single organism: once a capability is externalized (externalize seed:<name>), the organism depends solely on its contract:<path> regardless of whether that contract is served by a sibling organism, a third-party SaaS API, or another internal team.
Authority in the Compiler Graph (runs_under) and Financial Books
Section titled “Authority in the Compiler Graph (runs_under) and Financial Books”Principal-Typed Authority (runs_under Design)
Section titled “Principal-Typed Authority (runs_under Design)”While the compiler today tracks locus ownership (the Σ-tower) and reachable effect classes (@effects), the authority architecture extends the compiler graph with a runs_under(locus, principal) relation (where each locus inherits its parent’s principal unless narrowed, and no locus may claim a principal its owner does not hold):
- Static Principal Claims: Secret slot accesses carry the principal they require, enabling compile-time constitutional claims such as “only code running under the
reviewerprincipal may reachFORGE_TOKEN” (Claims & the law). - Generated Backend Policies: Vault policies, Postgres roles, NATS account ACLs, and GitHub team permissions become deterministic projections of each principal’s reachable closure rendered at placement time, rather than hand-edited configuration files.
- Dynamic Per-Attachment Credentials: In the record, holding a position is an appointment row (
holds), while a live worker process or browser session acting under that seat is a time-bounded attachment. Short-lived credentials are minted for the specific attachment (narrowed to the attachment’s scope and revoked when the attachment ends), and every runtime effect is logged against its attachment ID.
Replaceable Providers and Financial Discipline
Section titled “Replaceable Providers and Financial Discipline”Providers are replaceable
Section titled “Providers are replaceable”External dependencies—LLM backends, databases, OIDC issuers, communication channels, payment rails, accounting ledgers, and compute hosts—bind through Hale interfaces and perspectives (Perspectives). Each provider capability tracks three distinct states: implemented in code, available on the current account, and authorized by grant. Swapping a provider preserves the organization’s record, authority structure, and history.
Financial Capture and Books (Design)
Section titled “Financial Capture and Books (Design)”Financial operations follow four structural rules:
- Distinct pipeline stages: Raw source receipts -> observations -> economic events -> approved ledger postings or external acknowledgements.
- Single book authority: Each book is designated as capture-only, managed by the organism’s own posting service, or owned by an external accounting platform.
- Exact decimal arithmetic: Monetary quantities use
Decimalwith an explicit currency and rounding policy—never binary floating-point. - Five separated budget states: Permitted budget, reserved capacity (
spend.reserved), observed usage, booked expense, and cash settlement (spend.settled/spend.compensated) are tracked separately so a reservation is never mistaken for an expense.
Implementation Status
Section titled “Implementation Status”| Capability | Status in the Repository Today |
|---|---|
| Per-repository append-only signed record | Built: Memory and the record |
Deliberate cross-record publication (connect & handoff) |
Built: hale dna connect and hale dna handoff (Memory and the record) |
Sealed protected evidence (customer, confidential) |
Built: hale dna receipt encrypted in Postgres memory (Memory and the record) |
Deployment profiles (local, remote-body) |
Built: hale habitat graft --profile local|remote-body and hale dna profile (Getting started) |
Root habitat organism (hale habitat up, status, down) |
Built for the local profile (Docker Compose body and face services); hosted profile is not built |
Habitat child birth & role allocation (hale habitat graft) |
Built: Allocates [dna] needs (memory, nerves, senses, heart database), links parent genesis, and proposes standard pack |
Habitat standard & operator browser face (/index, /app/) |
Built: Started automatically by hale habitat up (The head and the face) |
Hosts, compose provider, and ssh host registration |
Built: compose provider places on local; hale habitat host add|probe|remove registers LAN hosts over SSH and placing allocations on them is built (hale habitat place, apply, graft --host) |
An agent pairing with a person (MCP, hale habitat brief) |
Built: the head’s commands over mcp::Rpc under the person’s bearer and roles (hale mcp --app, the endpoint hale habitat status prints), every act a row in their name; agents/operator.md |
Saplings & nurseries (hale habitat graft <sapling>, nursery) |
Built: Digest-pinned [[sapling]] entries, hale habitat nursery add|refresh|list|ratify; a repository as its own nursery (repo = "."), as hale-lang/voice is |
| Verified OIDC principal source | Built: git config dna.principal oidc (The head and the face, The skin) |
| Per-client backend roles (Postgres, NATS, Vault) | Built: Separate owner, spine, head, reflexes, and per-app roles (The skin) |
| Monetary grant reservations & window enforcement | Built: spend.reserved, spend.settled, spend.compensated (The spine) |
| Serving API surfaces & locus placement | Built: api::serve over Unix/HTTP (API) and placement { } (Concurrency & placement) |
Opening and filling positions (position open, fill, vacate) |
Built: Board-ratified graph nodes, mandates, and holds edges (Positions and fill) |
Atomic structural batches (hale dna apply) |
Built: open, fill, fill *, vacate, practice, law, idea, assign, close, merge, split, expose, depend, externalize, internalize |
Adopting and retiring nursery packs (hale dna pack) |
Built: hale dna pack list|show|apply|retire and hale dna nursery add|list |
runs_under principal graph, projected ACLs, attachment tokens |
Not built (tracked in compiler registry design) |
Cross-record habitat operations (extract, absorb, re-parent) |
Not built |
| Standard equipment libraries & financial books | Not built (standard nursery pack is built and proposed at graft) |