-- The node records: which machines this mesh knows about. -- -- novox/hq ADR 0006 — inventory holds nodes, modules, assignments and versions, and this is the -- first of the four. The others arrive with delivery, which is not built; a table nothing writes -- to is a guess about a shape, and guesses about shapes are what migrations make expensive. create table node ( id uuid primary key default gen_random_uuid(), -- What a person calls this machine. Unique because it is how a node is named when a token is -- issued for it (`token issue --node workstation`), and a name that matched two records would -- make that command ambiguous at exactly the moment it grants access to the mesh. name text not null unique, created timestamptz not null default now(), -- The last profile the node reported: what it can run, which is the input to deciding what it -- should run (novox/hq 09-the-node-lifecycle, step 4). -- -- Held opaquely, as the document the node sent. The host owns that shape and the control -- plane's job here is to keep the last one faithfully, not to have an opinion about it — so a -- host that learns to report something new does not need this schema to change first. profile jsonb, -- When this node was last heard from. -- -- There is no `state` column, and its absence is deliberate. The lifecycle has four states, -- but two of them — unmanaged and hosted — are situations of a *machine* that the mesh has -- not been told about, so they cannot be rows here. The remaining pair, enrolled and -- disconnected, are described in novox/hq ADR 0004 as the same node in two situations rather -- than two kinds of thing, and the difference between them is how long it has been since this -- column moved. -- -- Stored as a state it would have to be written by something noticing a node had gone quiet — -- and nothing notices silence. It would be correct while nodes were talking and wrong exactly -- when it mattered. last_seen timestamptz ); -- "Has this node been unreachable for a week" is the control plane's question by definition -- (novox/hq ADR 0006 — nobody else is watching), so the column it is asked of is indexed. create index node_last_seen on node (last_seen nulls first);