scroll # Sovereign Node Recipe — Day 00357(rebirth) How to make a Portal node its ownsovereign brain (own code + own DB), proven on**hexperiment** Day 357. Before this,hexperiment ran its own binary but drank from**hexlet's** database over tailscale —compute-only, not truly its own node. ## What"sovereign" means A node that boots andconnects to its **own** local Postgres, not aremote one. It mirrors the canonical node(hexlet) but can be worked on in isolation,then promote changes back when ready.Production (hexlet) stays untouched untilpromotion. ## The 4-move recipe 1. **Copy thestructural data.** `\copy` the `things` tablefrom the source node into the target's localPostgres (data-only client COPY —version-robust across PG 17→15). Skip`sacred_embeddings` (RAG, ~3.3 GB,rebuildable); structural Things are tiny (~233MB / 120k rows). Optionally copy `beings` forauth parity. 2. **Set the primary db-target.**In the local DB, set the `localhost-things`db-target Thing `ruby.primary=true`, othersfalse. 3. **Declare sovereignty.** Set**`HEXCRAFT_NODE_ID`** in the node's pm2 env.This — NOT `HEXCRAFT_DB_HOST` — is thereal switch. `db/mod.rs::init_pools` checks`HEXCRAFT_NODE_ID.is_ok()`; a sovereign nodetries `localhost` FIRST. `HEXCRAFT_DB_HOST` isa red herring: the host-selection logicoverrides it. 4. **Cut the umbilical.**Delete/entomb the remote db-targets(`hexlet-things`, `hexos-things`) in the localDB. Otherwise the Portal "discovers" them atboot and opens a secondary connection to theremote anyway. After deletion, a fresh bootlog shows `Trying PostgreSQL at localhost ✓`and NOTHING else. ## Why the data layer alonewasn't enough Portal boot is Thing-driven: itreads db-target Things to decide connections.But there is a **hardcoded fallback** in`db/mod.rs:177-200` — for any node whosehostname isn't "hexlet", it does`hosts.push("hexlet")` (hexlet-first fornon-sovereign, localhost-first for sovereign).It's bypassed once local db-targets arediscovered, but it remains a hardcoded tendril(same family as the WITNESS/ARCHITECT crownconstants) that should eventually beconfig/sovereignty-driven instead of a literal"hexlet". ## Result (hexperiment, Day 00357)Own Linux binary (incl. the new `▲ fid gappriority` command) · own local Postgres (120kThings) · `HEXCRAFT_NODE_ID=hexperiment` ·db-targets = localhost only · pm2 config at`~/.pm2/hexos-portal.config.js` with acommented `HEXCRAFT_DB_HOST` toggle forreference. The boot is data, not config —which is why the fix lived in Things + one envflag, not in code.