Agent archetypes: how the list stays current
How swarm-controller learns which archetypes the create form offers, and what it stores. The operator's view is the archetypes page.
The refresh
-
swarm-controller asks the builder for the list on the queue subject
$SWARM.builder.archetypesonce the queue connects, and every 10 minutes after that. The controller asks again after a pass that gets no answer or a failed evaluation: after 10 seconds, then 20, doubling up to 10 minutes, until one succeeds. -
The builder evaluates the
metaof eachhyperhiveArchetypesentry on its own hyperhive and nixpkgs sources, and answers with the JSON or the last linesnixprinted:nix eval --json <hyperhive>#hyperhiveArchetypes \ --apply 'builtins.mapAttrs (_: a: a.meta)' -
The controller checks each archetype the way
POST /api/agentschecks its settings and stores the result in theagent-archetypesKV bucket, under the keyhyperhive, when it differs from the stored one. The list leaves out an archetype that fails the check, and its name and reason go into the record'srefusedmap and the controller's journal. An archetype'sflowspass the router's archetype check here too; the notification router reads them from this record. -
GET /api/archetypesanswers from that record, and the create form lists from it.
A builder host redeploy can change the list. The next pass, within 10 minutes, picks it up. When no builder answers, the controller keeps the stored list and logs a warning on each pass. A swarm whose builder connects after the controller has no list until a retry succeeds. A swarm with no builder enabled shows no archetype select.
The stored value:
{
"source": "/nix/store/…-hyperhive-flake-source",
"archetypes": {
"reviewer": {
"description": "…",
"permissions": ["messaging", "inbox", "execution"]
}
},
"refused": { "broken": "limits: …" }
}
The built-in prompts
Each built-in archetype's meta.prompt is builtins.readFile of
nix/archetypes/prompts/<name>.md. The file read gives a plain string, so
meta stays plain data and the nix eval above prints it as JSON. The
controller's check holds the prompt to 64 KiB.