The Skin
The skin is the organism’s credential, identity, and failure-containment boundary (dna/host/secrets.hl, dna/core/principal.hl, dna/oidc/stub.hl). It provisions and validates secrets in a local or remote Vault, isolates PostgreSQL and NATS credentials per component, authenticates HTTP callers to the head via OIDC, enforces compile-time secret confinement with std::secret::Credential, and records absorbed runtime invariant failures as violation.recorded rows. Every component fails closed if a required secret is missing, and secret values are never written to committed files, record rows, URLs, CLI arguments, or environment variables.
hale dna secrets # check status of all drawn and user-supplied secretshale dna secret set FORGE_TOKEN # populate a secret slot from stdinhale dna secret rotate FORGE_TOKEN # rotate an existing secret slot from stdinThe Vault
Section titled “The Vault”Secrets are stored as raw byte entries in a vault, addressed by slot name:
- Local filesystem vault (default): Stored in
HALE_VAULT_DIR, falling back to$XDG_CACHE_HOME/hale/vaultor~/.cache/hale/vault. Each secret is a mode0600file named after its slot; empty files are treated as missing. Because a local vault directory is readable by any process running under the same OS user, component isolation relies on passing each process only the specific vault slot name it is authorized to resolve. - External Vault server: Configured by setting
HALE_VAULT_ADDRand a per-host token inHALE_VAULT_TOKEN. External vaults are provisioned out of band; DNA startup verifies that all required slots exist and reports any missing entries.
Secret Slots & Drawn Credentials
Section titled “Secret Slots & Drawn Credentials”Run hale dna secrets to list every secret required by the organism and whether it is present in the vault (secret values are never displayed):
$ hale dna secretsthe organism's secrets (the local vault, …): present postgres-dna_35bf…_spine memory: the spine's role present postgres-dna_35bf…_head memory: the head's role present postgres-owner-35bf… memory: its allocation's superuser in the local habitat present nats-dna_35bf…-owner the nerves: the owner's account present nats-dna_35bf…-spine the nerves: the spine's account present nats-dna_35bf…-head the nerves: the head's account present nats-dna_35bf…-reflexes the nerves: the reflexes's account present nats-dna_35bf…-app-refproj the nerves: the application `refproj`'s account present oidc-client-dna-local the skin: the head's OIDC client secret (the local stub's) MISSING forge-token the forge's token — a person supplies it: `hale dna secret set FORGE_TOKEN` present model-HABITAT_35BF… the model map's key for think.deep, think.standard, think.quick (the habitat's models)1 missingEvery vault entry matches one of the following naming patterns (where <identity> is [dna] record, <org> is dna_<identity>, and <id> is the first 12 hex digits of <identity>):
| Vault Slot Name | Provisioning Kind | Owner / Purpose |
|---|---|---|
postgres-dna_<identity>_spine, …_head |
Drawn | PostgreSQL spine and head database roles |
postgres-owner-<id> |
Drawn | Superuser password for the local habitat’s memory-<id> container |
nats-<org>-<role> (owner, spine, head, reflexes) |
Drawn | NATS JetStream role accounts |
nats-<org>-app-<name> |
Drawn | NATS account for attached application <name> |
oidc-client-<client> (dna-local by default) |
Drawn (loopback issuer) or Slot (remote issuer) | OIDC client secret for hale dna head |
oidc-service-<service> (per dna.oidc.service) |
Drawn | Machine-to-machine service client secret |
forge-token |
Slot | GitHub / forge API token (FORGE_TOKEN) |
model-<NAME> (per dna/org/models.hl or dna/org/work.hl) |
Slot | Hosted LLM provider API key (written only when its key was in the vault at graft: no placeholder) |
a category’s key_vault (per latest model.category row naming one) |
Slot | The key the model map asks that endpoint with |
model-HABITAT_<ID> (<id> upper-cased) |
Filled by the habitat | The organism’s key at the habitat’s models (The Habitat’s Models) |
secret-<org>-<name> (per [dna.secrets.<name>] in hale.toml) |
Drawn or Slot, as declared | A secret the seed declares for its own programs and host commands (Declared Secrets) |
secret-<org>-<name>--<label> (per member a person fills) |
Slot (a family) | A member of a secret family the seed declares |
secret-<org>-<name>--<organism> (per tenant of a models provider) |
Drawn (a family) | A tenant’s key at the habitat’s models: a member of the provider’s key family |
- Drawn secrets: Generated automatically by
hale habitat graftandhale dna upgrade(32 random hex characters from/dev/urandom) whenever missing. NATS passwords are rotated on everygraftandupgrade, updating<habitat>/allocations/<id>/nats.secrets.confandpostgres.secrets(mode0600).hale dna runandhale dna devrefuse to start if any drawn secret is missing:
hale dna run: the organism's secrets are not all in the vault: … (`hale dna upgrade` draws them; `hale dna secrets` lists them); nothing starts without them- User-supplied slots: Empty entries that an operator populates manually (
FORGE_TOKEN,OIDC_CLIENT_SECRETfor non-loopback OIDC issuers, and eachmodel-<NAME>key referenced indna/org/models.hlordna/org/work.hl). Missing slots are flagged onhale dna board(missing model keys are reported by the active body host viabody.credential_missing). - Shared-record owner roles: Per-owner head roles (
postgres-<org>_head_<owner>) are provisioned dynamically byhale dna memory migratewhenHALE_DNA_OWNER_KEYSis set (Memory and the Record).
Filling a Slot
Section titled “Filling a Slot”Populate or rotate a user-supplied slot with hale dna secret set or hale dna secret rotate:
hale dna secret set <NAME> [--body <user@host>]hale dna secret rotate <NAME> [--body <user@host>]- Valid
<NAME>identifiers:FORGE_TOKEN,OIDC_CLIENT_SECRET, any credential key declared viaHostedCredential { key: "…" }indna/org/models.hlordna/org/work.hl, the model key of amodel-<NAME>slot a model category asks its endpoint with (HABITAT_<ID>, the habitat’s models’ key, among them), or the name of a slot the seed declares in[dna.secrets](Declared Secrets). Unrecognized names are rejected. - Stdin-only input: The secret value is read from a single line on stdin. Passing
NAME=valueon the command line is rejected to prevent secrets from leaking into shell history orpsoutput.
$ hale dna secret set FORGE_TOKENvalue for FORGE_TOKEN (this machine), on one line:secret set: FORGE_TOKEN is in its slot of the vault, …/forge-token (secret.rotated FORGE_TOKEN; the value is nowhere in the record). A part reads it from the vault where it uses it- Remote host bodies (
--body): When--body <user@host>is passed (ordna.bodyis configured in Git config viahale dna body provision), the secret is piped over SSH stdin directly into the remote host’s vault. - Audit logging: Both
setandrotateappendsecret.rotated <NAME>(recording target host and author, never the secret value) to the record.secret rotatefails if the slot has never been set. - No environment fallback: Model keys and
FORGE_TOKENare read exclusively from the vault. DNA never reads model keys from shell environment variables and never uses ambientghCLI credentials whenforge-tokenis unset.
Declared Secrets
Section titled “Declared Secrets”A seed declares the secrets its own programs and host commands read in its hale.toml, and the habitat keeps each in the organism’s vault and hands it to its readers:
[dna.secrets.operator-token]kind = "drawn" # the habitat draws it (32 hex), at graft and upgradereaders = ["api", "host.node"] # programs by directory name; host commands as host.<command>
[dna.secrets.upstream-key]kind = "slot" # a person fills it: hale dna secret set upstream-keyreaders = ["api"]
[dna.secrets.dashboard]kind = "drawn"person = "read" # hale dna secret show dashboard reveals it
[dna.secrets.model-token]kind = "slot"family = true # several values, each filled under a labelreaders = ["worker"]
[dna.secrets.extra-key]kind = "slot"optional = true # its readers do without itreaders = ["api"]- Names and keys: a name is lowercase letters, digits and
-(a letter first, at most 32 characters, no-last or doubled).kindisdrawnorslot;personisread,write(a person sets it and never reads it back; a slot’s default) ornone(a drawn secret’s default). A drawn secret a person would write, a slot no person may touch, an unknown key, and ahost.<command>reader with no[dna.host.<command>]are all refused.hale dna declared-secretsprints the declaration as the toolchain reads it. - Its vault entry is
secret-<org>-<name>. A drawn one is drawn when missing, byhale habitat graftandhale dna upgrade, and never rotated by them (unlike the NATS passwords):hale dna secret rotate <name>draws it anew.hale dna secret seton a drawn secret is refused. A slot is listed MISSING byhale dna secretsuntilhale dna secret set <name>fills it. - Optional:
optional = trueon a slot (refused on a drawn secret, which always exists) means its readers do without it. Unset,hale dna secretslists itunset (optional)rather than MISSING, nothing refuses on it, and it is not handed: noHALE_SECRET_<NAME>at all. An optional family with no member is handed empty: its variable set, to nothing, so a reader tells “none handed over” from “not declared”. - Show:
hale dna secret show <name>prints the value of a secret declaredperson = "read", and refuses any other, saying why. Through a pointer, run it (andset) ashale habitat organism <organism> dna secret show <name>: it runs on the habitat’s machine, where the vault is. - Families:
family = trueon a slot holds as many values as the deployment needs (several model tokens on one host, say), each a member a person fills under a label:hale dna secret set model-token --member work,rotate … --member work,remove … --member work, andshow … --member workfor a family a person reads. A label is 1 to 63 characters, a lowercase letter or a digit and then lowercase letters, digits and-(^[a-z0-9][a-z0-9-]{0,62}$). Each member is the entrysecret-<org>-<name>--<label>. A family named without--memberis refused, and so is--memberon a secret that is no family.--askeeps its meaning on these verbs too: who acts, as the record’s row names it.hale dna secretslists the family once with its members, and as MISSING while it has none. - Drawn families:
family = trueon a drawn secret is refused unless the seed provides a capability keyed by it ([dna.provides.models] key = "<name>", The Habitat’s Models). Its members are the habitat’s, one per tenant organism, labelled by the organism’s name: drawn when the habitat keys a tenant, removed with it.hale dna secretslists itno tenantuntil the first, never MISSING;rotate <name> --member <organism>draws one anew (the habitat updates the tenant’s copy and the reader vault), andsetandremoveare refused. - Handed to programs: where the organism’s services run (the habitat’s apply, on this machine or an SSH host, and
hale dna dev/runfor a repository), the habitat copies each secret a program reads into a vault directory of the organism’s own there (mode 700, each entry 600;<habitat>/allocations/<id>/vaulthere,~/.hale/habitat/<project>/.vaulton a host, never in a checkout) and hands composeHALE_VAULT_DIR(that directory) andHALE_SECRET_<NAME>(the entry’s name; a family’s, each member’s entry, one a line), and for a familyHALE_SECRET_<NAME>_FAMILY, its members’ common prefix: listHALE_VAULT_DIRby it to see members drawn while the service runs (the habitat rewrites the directory in place when it draws or removes one of a drawn family’s). The compose file passes them to the services that read them and mounts the directory read-only at the same path:
services: api: environment: HALE_VAULT_DIR: ${HALE_VAULT_DIR} HALE_SECRET_OPERATOR_TOKEN: ${HALE_SECRET_OPERATOR_TOKEN} volumes: - ${HALE_VAULT_DIR}:${HALE_VAULT_DIR}:roA program reads it as std::secret::Credential { vault: std::env::var("HALE_SECRET_OPERATOR_TOKEN") }. Compose’s environment is the project’s, so the grant to the declared readers is the compose file’s to keep; a secret no program reads is never handed.
-
Handed to host commands:
hale habitat organism place|unplacehands a command each secret naming it among its readers, for the run alone (The Habitat).placerefuses while a required one is unset;unplacenever does, and goes on without what is missing. -
When no program reads any: the reader vault is reconciled to the empty set, every entry staged before removed; on an SSH host it goes with the project’s withdrawal.
-
Superseded: a host command’s
operator_tokenand{operator_token_file}input are refused; declare the token as a drawn secret withhost.<command>among its readers. -
Held to the code: the checker reads the same thing from the program.
hale check <program> --dump-requirementsprints the requirements artifact, every secret the program reads (a read ofHALE_SECRET_<NAME>is the declared secret<name>, as are astd::secretlocus’s literalvault:,env_var:andkey_file:), with where each is read; and everyhale checkof a program under thishale.tomlwarns where the code and[dna.secrets]disagree:api/main.hl:12:20: warning: secret `upstream-key` is read here (`HALE_SECRET_UPSTREAM_KEY`), but /…/hale.toml declares no `[dna.secrets.upstream-key]`, so no environment hands it: declare it there (…)hale.toml:4:1: warning: `[dna.secrets.operator-token]` names `api` among its readers, but `api` never reads it: no read of `HALE_SECRET_OPERATOR_TOKEN` in its code. (…)A program a host command runs is that command’s reader too: when
[dna.host.node]’sinstallnames the program’s directory or a file in it (hale run node …,sh node/install.sh …), a read innodeagrees withreaders = ["host.node"], and the long-runningnodeneeds no grant of its own. A read the program makes by a name it computes at run time is listed in the artifact asunnamed. Drift is a warning in this release (and failshale verify, as any advisory does); a later release refuses it, and then writes[dna.secrets]from the code (The requirements artifact).
Automated workflow rotation (secret-rotate@1) is present in the workflow catalog but rejected at admission because workflows are not permitted to write to vault:
secret-rotate@1 a secret rotated 0. rotate vault 1. recorded record refused at admission: workflow secret-rotate@1 step 0 (rotate) writes the vault (GH #989), which is not built yetRoles and Accounts
Section titled “Roles and Accounts”Each DNA component receives credentials only for the specific database role and NATS account it requires:
| Component | PostgreSQL Role (memory) |
NATS Account (nerves) |
|---|---|---|
Spine (host supervisor & dna/org) |
dna_<identity>_spine (read/write record & ledger tables) |
spine (publish/consume <org>.dna.>, consume heart durable, publish <org>.head.>) |
Head (hale dna head, CLI) |
dna_<identity>_head (read tables, acquire/fence claims, append to ledger) |
head (subscribe-only; cannot publish) |
Migrations (hale habitat migrate) |
owner DSN (DDL schema migrations; never held by running daemons) |
owner (create/update/delete JetStream stream) |
Application (heart) |
None | app-<name> (publish-only on <org>.app.<name>.>) |
Reflexes (dna/reflexes) |
None | reflexes (publish-only on <org>.app.reflexes.>) |
PostgreSQL DSNs reference their password via &vault=postgres-<role>, and NATS connections take nats://host:port alongside a std::secret::Credential pointing to the vault slot. See Memory and the Record, The Nerves, and The Heart.
OIDC Authentication for the Head
Section titled “OIDC Authentication for the Head”Every HTTP session on hale dna head is authenticated against an OpenID Connect (OIDC) provider and mapped to an organizational member name in Git config:
git config dna.principal oidcgit config dna.oidc.issuer https://id.example.comgit config dna.oidc.client dna-headgit config dna.oidc.redirect https://dna.example.com/auth/callbackgit config --add dna.oidc.member "<subject>=alice"git config dna.oidc.board alicehale dna secret set OIDC_CLIENT_SECRET- Client secret: Stored in the vault at
oidc-client-<client>and revealed inline whenhale dna headexchanges an authorization code for a token. - Authorization: Unmapped OIDC subjects are denied a session. Members listed in
dna.oidc.boardreceive Board authority. Startinghale dna headwithout a configured principal source fails immediately. - Local OIDC stub (
dna-local): When running locally,hale dna head(ordna/face/start.sh) launches a loopback OIDC stub (dna/oidc) using the drawnoidc-client-dna-localsecret and pins the ephemeral signing key indna.oidc.key. - Service tokens: Non-interactive clients authenticate using service tokens mapped via
git config --local --add dna.oidc.service "<subject>=<service>", backed by the drawnoidc-service-<service>vault secret. See The Head and the Face.
Sealed Credentials
Section titled “Sealed Credentials”In Hale code, credentials are never stored in String fields or variables. Instead, components hold a std::secret::Credential { vault: … }—a @sealed locus that resolves the vault entry on demand and reveals its contents only inside the expression that writes to the network wire.
The compiler enforces that .reveal_text() is consumed immediately in the same statement by a wire write, a whole-value equality check, or a @secret parameter; it cannot be bound to a let variable, stored in a struct/locus field, returned from a function, or branched on (Verification: Secrets).
For example, HostedCredential in dna/core/models.hl reveals a model API key directly inside the outbound HTTP request header:
fn model_key_slot(key: String) -> String { return "model-" + key; }
@sealed locus HostedCredential { params { key: String = "OPENAI_API_KEY"; scheme: String = "bearer"; } // the vault's name for it, read where it is presented and nowhere else fn slot() -> String { return model_key_slot(self.key); } fn ready() -> Bool { return std::secret::Credential { vault: self.slot() }.ready(); } // … @effects(is: { secret_use, external_model }) fn post_json(url: String, body: String, extra: String) -> std::http::ClientResponse fallible(std::http::HttpError) { let u = std::http::parse_url(url) or raise; return std::http::request(std::http::ClientRequest { method: "POST", url: u, headers: "Content-Type: application/json\r\n" + extra + (if self.scheme == "x-api-key" { "x-api-key: " } else { "Authorization: Bearer " }) + std::secret::Credential { vault: self.slot() }.reveal_text(), body: std::bytes::from_string(body) }) or raise; }}If .ready() returns false (the vault slot is empty), the model router skips that backend before attempting a network connection. Both pond’s NATS client (CONNECT frame) and hale dna head (OIDC token exchange) use the same inline std::secret::Credential pattern.
Closures and Violations
Section titled “Closures and Violations”When a runtime invariant closure (When Things Fail) fails in a component that cannot recover in place, the owning supervisor absorbs the failure, writes a violation.recorded row ({kind, subject, owner, detail}) to the record, and executes a clean recovery action:
| Violation Kind | Subject | Owner | Trigger & Recovery Action |
|---|---|---|---|
adapter_undeliverable |
nerves |
Node holder (user@host:<clone>) |
A NATS JetStream publish remained unacknowledged past its delivery window. The node stops dna/org and the application, releases the body lease (body.released, why: nerves), and exits 75 so systemd restarts it with a fresh connection. |
lease_unsettled |
Attempt ID | spine |
A worker leg’s attempt lease expired before an outcome was submitted. Logged once per expired lease, after which the attempt is re-dispatched. |
pulse_stopped |
heart |
Spine holder | Pulling from the heart durable consumer failed while the NATS connection remained open. Logged once per outage, after which the host recreates the heart durable and resumes pulling. |
Because every request row is persisted to PostgreSQL before NATS delivery, restarting on a violation never loses state: the restarted node re-relays all unanswered requests.
hale dna board displays the total violation count and the 5 most recent violation.recorded rows:
violations: <n> recorded, each absorbed by its owner (the latest last) <kind> <subject> (<owner>): <detail>Troubleshooting Common Errors
Section titled “Troubleshooting Common Errors”| Symptom | Cause | Resolution |
|---|---|---|
… nothing starts without them |
One or more drawn secrets are missing from the vault | Run hale dna upgrade to regenerate missing drawn secrets |
secret set: … is no slot of the organism's … |
The secret name does not match any declared slot | Run hale dna secrets to list valid slot names |
secret rotate: <NAME> was never set |
Attempted to rotate an empty slot | Use hale dna secret set <NAME> for initial population |
no forge token: the vault holds none … |
The forge-token slot is empty |
Run hale dna secret set FORGE_TOKEN |
hale dna head refuses to start |
No dna.principal configured, or loopback OIDC issuer lacks pinned dna.oidc.key |
Configure OIDC settings in git config as shown above (The Head and the Face) |