build agents from internal/meta when it pins their config
A rebuild's MetaSync resolves the head of the swarm's internal/meta once and records it; the prebuild and the swap build that flake instead of the hive's own, and a first deploy does the same in Create. hive-priv takes the commit as a validated meta_rev on UpdateContainer and CreateContainer and builds from its own forge URL (HIVE_PRIV_FORGE_URL). The head is used only when its flake lists the agent at the config commit the forge's main is at; otherwise, and when the repo has no commit or this hive has no core token file for nix's git, the hive renders locally as before. hive-c0re's and hive-priv's gitconfig now share the forge credential helper and rewrite the forge's https URLs to http, which hive-priv lacked.
This commit is contained in:
parent
22e2d30581
commit
7c0a622d41
19 changed files with 831 additions and 64 deletions
|
|
@ -123,7 +123,8 @@ declares one flake input per agent (`agent-<n>.url =
|
|||
address) aren't in it:
|
||||
`hive-priv` writes them to the container's `/etc/hyperhive-hive-facts` at
|
||||
start (see `docs/process/conventions.md`).
|
||||
Containers run against `--flake /var/lib/hyperhive/meta#<n>`.
|
||||
Containers run against `--flake /var/lib/hyperhive/meta#<n>`, or against
|
||||
`internal/meta` when it pins the agent ([below](#the-swarms-meta-flake)).
|
||||
|
||||
The declared input url is the head of `main` on the agent's forge config repo
|
||||
(`agent-configs/<n>`, the one config PRs merge into), which `sync_agents`
|
||||
|
|
@ -161,6 +162,43 @@ resolves which sha the flake pins each agent at right now.
|
|||
Dashboard surfaces the same info as a `deployed:<sha12>` chip
|
||||
per container row.
|
||||
|
||||
## The swarm's meta flake
|
||||
|
||||
swarm-controller also commits a meta flake of its own, `internal/meta`, with
|
||||
the same renderer: one `flake.nix` and `flake.lock` for every agent any hive
|
||||
places (the pins: [`docs/swarm/builder.md`](../swarm/builder.md#meta-flake-lock)).
|
||||
A hive builds an agent from it when the repo has a commit that pins the
|
||||
agent's current config, and from its own meta flake above otherwise, so a hive
|
||||
older or newer than the controller keeps building.
|
||||
|
||||
- **Choosing the commit.** The rebuild's `MetaSync` node reads the repo's
|
||||
default-branch head with the hive's read token (`forge::reader_token()`)
|
||||
and takes it when its `flake.nix` lists the agent and, for a custom agent,
|
||||
pins the config commit at the head of `agent-configs/<n>` `main` now.
|
||||
A hive without the `core` token file that nix's git reads, a repo with no
|
||||
commit, a head that lacks the agent and a head behind the config all select
|
||||
the hive's own flake. `MetaSync` records the commit under the agent's
|
||||
runtime directory; `Prebuild` and `Swap` read that record, so
|
||||
both build one flake. A first deploy resolves the commit in its `Create`
|
||||
node, since it has no `MetaSync`.
|
||||
- **The build.** `hive-c0re` prebuilds
|
||||
`git+<forge>/internal/meta.git?rev=<commit>#nixosConfigurations.<n>…` and
|
||||
names the commit to `hive-priv` (`meta_rev` on `UpdateContainer` and
|
||||
`CreateContainer`). `hive-priv` accepts only a 40-digit lowercase hex
|
||||
commit and builds the flake from its own forge URL
|
||||
(`HIVE_PRIV_FORGE_URL`); the URL never comes from a request. On the wire the
|
||||
`hive_priv_sock::PrivRequest` variants carry an optional field:
|
||||
`{"op":"update_container","name":"atlas","stream":true,"meta_rev":"<40 hex>"}`.
|
||||
Without it, as from a hive-c0re that predates the field, hive-priv builds the
|
||||
hive's own flake.
|
||||
- **Fetching.** nix fetches the forge's inputs with `git`. Both `hive-c0re`
|
||||
and `hive-priv` carry a `$HOME/.gitconfig` that answers for the forge host
|
||||
through `git-credential-hive-forge` (the `core` token file) and rewrites the
|
||||
forge's `https` URL, which `internal/meta`'s lock names its inputs by, to
|
||||
`http`.
|
||||
- **Hyperhive.** The commit pins one hyperhive rev for the swarm, so an agent
|
||||
runs the hyperhive of the controller's deploy, not its hive's.
|
||||
|
||||
## Two repos per agent
|
||||
|
||||
```
|
||||
|
|
@ -195,7 +233,7 @@ proposed tree. The applied repo is never bind-mounted (except
|
|||
the read-only `.git` exposure described below) so a destructive
|
||||
move inside the container can't reach it.
|
||||
|
||||
The container's `--flake` ref is `/var/lib/hyperhive/meta#<name>`
|
||||
The container's `--flake` ref is `/var/lib/hyperhive/meta#<name>` (or `internal/meta`)
|
||||
(see "Meta flake" above). The agent's own `applied/<n>/flake.nix`
|
||||
is a fixed boilerplate that exports `nixosModules.default =
|
||||
import ./agent.nix`; the meta flake imports that module and
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ forge container:
|
|||
- seeding `proposed` from `agent-configs/<agent>` on first deploy
|
||||
- cloning and pulling `/knowledge`
|
||||
|
||||
The builds themselves read as `core`. nix fetches the config inputs and
|
||||
`internal/meta` with `git`, and `git` gets its credential from
|
||||
`git-credential-hive-forge`, which reads the `core` token file. A hive without
|
||||
that file fetches nothing private through nix, whatever its own token reads, so
|
||||
it builds from its own meta flake rather than `internal/meta`.
|
||||
|
||||
Roll a change to any of this out store host first (its granter writes the
|
||||
controller's grant on `swarm/hives/+/forge/token`), then the controller host,
|
||||
then the hives. A hive that starts before its token exists reads with the
|
||||
|
|
|
|||
Loading…
Reference in a new issue