Export the inventory runtime fact through vmFacts #30
No reviewers
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/archetypes!30
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/vmfacts-runtime"
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>.runtimenow reports the machine's inventory runtime, so a host-side tool can tell a libvirt VM from a microvm without evaluating a NixOS configuration.This is the remaining half of contract 1 in the microvm framework adoption plan — inventory's half (the required fact, its enum,
lib.vmSpecsJson, and the committedscripts/vm-specs.json) already landed, and this adds the third source of truth that contract makes agree. It is sequenced ahead of the rest of milestone 4 because contract 18 makes both key-rotation tools dispatch on this exact attribute, so allod/nexus#21 and allod/nexus#22 cannot start until it exists.factForgains one field with a presence guard and a distinct non-stringthrow, in the file's existing helper style. There is no enum inmkVmFactsand no default: inventory owns the runtime enum, which this repo already recorded as a deliberate delegation, and the delegation is now made real on both sides — the pre-existing dependency onruntime-fact-mutationsplus a new one onvm-specs-json, so the committed JSON this check diffs against is known fresh rather than assumed.Plan:
allod/strategydev-plans/vmfacts-runtime-export.md(allod/strategy#31).Risk
R2 Medium.
vmFactsis a public flake output read host-side byallod/nexusduring provisioning, rebuild, and key rotation, so changing its shape is a public interface change with cross-repo ordering. Held below R3 because the output change is purely additive and every consumer across seven repos was enumerated and independently re-derived: none iterates the per-machine attrset's keys, destructures without an ellipsis, pattern-matches, or compares whole objects, and no schema, key-set, or key-count assertion exists anywhere.allod/deployis a bare passthrough. No host command, secret, provisioning action, or persistent state is touched, and rollback is a straight revert.One thing the "additive" framing does not cover, stated plainly:
mkVmFacts's input contract is a breaking change.machines.<name>.runtimeis now required, so a caller passing its own machine set that previously evaluated will now fail withvmFacts.<name>: missing runtime. This is inert today —lib.mkVmFactshas no caller outside this repo — but a deploy flake author driving it directly needs the field.The accepted gap: a caller passing non-inventory data to
lib.mkVmFactsgets presence and type validation but no enum, soruntime = "bhyve"would evaluate. The real export cannot do this — inventory'scheckedMachinestrip-wire forces the enum assert before archetypes reads a value. The mitigation is on the consumer side, and it is a review requirement for the milestone 5 PRs: allod/nexus#21 and allod/nexus#22 must fail closed on an unrecognized runtime rather than defaulting to the libvirt branch.Validation
The libvirt no-op, taken across the change — all four byte-identical to the pre-change values:
allod-dev1lhcxfhy9iddfssp3df3r2zwkwnd3ilmprivacy-1zzzaralwv032jdmbqc1q6ms9fm15w7yfnexusfad4pq24f8iavzr3q369alz8932jq9q3installer2yj5038jnsgzbv6ghhmyafs5kspn9jrgnix flake check --print-build-logsgreen, 10 checks, peak RSS 5.71 GB — unchanged, since this slice adds no derivation that evaluates a NixOS configuration. Contract 1's own acceptance command passes, andvmFactsstill carries no hypervisor entry.Every new assertion has a sabotage fixture verified to go red for its own diagnostic, then restored. Two independent adversarial review passes attacked the checks — neither by the agent that wrote the code under review — and each found the new coverage green where it should have been red. Both rounds are fixed here.
First pass:
factFor. Both real machines and the fixture were"libvirt", so afactForreturning that literal instead ofmachine.runtime— a direct violation of the passthrough rule — left every check green. The fixture now uses a runtime that differs from the real fleet, and that difference is itself asserted rather than commented, so a later migration to microvm cannot silently restore the defect.jqfails inside anifcondition. A name-set mismatch, a malformed fixture, and drift onipalone each satisfied it withruntimeuntouched.Second pass, on the fix commit:
difflines carry no machine context, so any fixture that adds an entry carrying the drift value satisfied the pin with zero drift on a real machine — reproduced by a one-character typo in the fixture's own override key, which turns the override into an addition and passed green. The pin is now two-sided, matching both halves of one changed hunk, so a pure addition (no<line) is rejected.lib.toLowerwas measured leaving both checks green. The comment now claims only what is proven: that no constant survives.Five wrong-reason fixtures now go red — name-set mismatch, malformed candidate,
ip-only drift, added machine carrying the drift value, and the typo case — and both grep patterns were broken deliberately to confirm they fail closed. The drift value is derived from the real one, so a legitimate inventory change cannot turn the fixture into a false alarm.Closes allod/archetypes#27
Refs allod/strategy#20