Export the inventory runtime fact through vmFacts #27
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/archetypes#27
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
archetypes.vmFacts.<name>carries every provisioning fact the hypervisor needs except the one that decides how a machine boots. Export the inventoryruntimefact through it, so host-side tooling can dispatch on the same discriminator the flake already uses at build time to pick a guest module.Primary goals:
runtimebecomes a first-class vmFact —vmFacts.<name>.runtimeis"libvirt"or"microvm"for every non-hypervisor machine, read from inventory and never defaulted.runtime, a non-string value, or a value outside the enum throws with a named diagnostic rather than producing a fact the host would act on.vm-facts-coherencecomparesruntimeagainst the committedscripts/vm-specs.jsonso vmFacts and inventory cannot drift apart silently.vm-facts-negativegains fixtures for the new validation, and the coherence comparison gets its own negative proof, each verified to go red when the thing it checks is removed.toplevelderivations stay byte-identical.Current state and specifics
vmFactsis built atflake.nix:42frommkVmFactsinnix/vm-facts.nix.factForatnix/vm-facts.nix:76-87emits exactly five per-machine fields —ip,username,forgeKey,hostKeys,hostKeySecretFile— andruntimeis not among them, even though the flake already readsmachines.${name}.runtimeatflake.nix:434to select a guest module. The fact exists in the data and is used at build time; it just never reaches the host.Hypervisors are excluded from vmFacts by
includeMachineatnix/vm-facts.nix:45-51, which is what keeps this consistent with inventory's own design: inventory actively rejects a hypervisor that declaresruntime, so no hypervisor entry needs a fake guest runtime.The comparison data already exists.
allod/inventoryscripts/vm-specs.jsoncarriesruntimeper machine — both public examples are"libvirt"— and its key set is exactly the non-hypervisor machines, the same setmkVmFactsproduces.The
vm-facts-coherencecheck atflake.nix:960-1014projects an explicit field set before each diff:{ ip: .value.ip, forge_key: .value.forgeKey }againstvm-specs.json, and{ active, staged }againstmachine-host-keys.json. Because the projections enumerate fields rather than passing the object through, an added key passes silently and stays unverified. The projection has to nameruntimefor the three sources to be provably in agreement.The
vm-facts-negativecheck atflake.nix:1016-1071holds fiveexpectFailurefixtures over a syntheticbaseData, each forcing one field of one machine throughbuiltins.tryEval (builtins.deepSeq value true)and reporting the fixture name when evaluation wrongly succeeds. Itsalpha-devmachine carries noruntimetoday. Validation innix/vm-facts.nixis lexicalthrowthrough named helpers (requireIpat:21-25,requireHostKeysat:27-43), not NixOSassertions, so a new failure mode there is athrowin the same shape.Neither existing check proves its own comparator works:
vm-facts-negativeobserves only that evaluation failed, andvm-facts-coherencediffs real data that already agrees, so deleting a projection field leaves it green. Anything added here has to come with the negative case that would catch its own removal.vmFactsis a public flake output read host-side byallod/nexusas<flake>#vmFacts(README.md:46), andmkVmFactsis re-exported inlib, so adding a field is a public interface change and is reviewed as one.Scope
In scope:
nix/vm-facts.nixfor the new fact and its validation, andflake.nixfor the two checks that must cover it.Out of scope and tracked elsewhere: guest-module selection, which already reads
runtimedirectly from inventory and does not change here; consuming the new fact host-side, which is the runtime-aware key rotation work in allod/nexus#21 and allod/nexus#22; andallod/inventory, whose half of this contract has already landed.Part of allod/strategy#20