Builders should not close over the data inputs #92
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
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#92
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?
Make the three archetype builders pure functions of their arguments, so a builder is structurally incapable of reading the
secrets,profilesorinventoryinputs rather than merely pinned against doing harm with them.Primary goals:
mkDevVm,mkPrivacyVmandmkHypervisortake every data-derived value as a required argument;machines,profiles,secretsInput,piProviderCatalogandpiProviderCredentialsare not in scope inside them.Current state and specifics
allod/archetypes#88 widened the builder seam so a check could construct a fixture machine without borrowing a real machine's name, and a review of that work found the cost:
machineConfigurations(flake.nix:735) mergesprofileDataand inventory'sprofilesettings into builder arguments, so every parameter is also a key the profiles layer can set.productionFactContractcloses that by applying the canonical values after the merge.The guard is correct and is not what this issue changes. What it leaves untouched is that the builders still reach into the data inputs for their defaults:
secrets ? secretsInputflake.nix:321,:525,:561preferencesModule ? profiles.homeModules.preferencesflake.nix:324,:575piCatalog ? piProviderCatalogflake.nix:340piCredentialMap ? piProviderCredentialsflake.nix:341runtime ? machines.${name}.runtimeflake.nix:348,:526platform ? machines.${name}.platformflake.nix:356,:527,:562hardware ? machines.${name}.hardwareflake.nix:563Once
secretsis an argument, the defaults derived from it —runtimeIdentity,gitPolicySource,githubCredentialTargets— follow the argument and are already clean; the same holds for everything derived fromidentity. So the change is the seven rows above becoming required,machineConfigurationssupplyingruntimeandpreferencesModulealongside the values it already pins, and the fixture call sites in the checks passing what they already mostly pass.Two things a future reader should not have to rediscover. First, this does not retire
productionFactContract: what protects a canonical fact fromprofileDatais where the value is applied, after the merge, not whether the parameter carries a default. Second, the builders are internal —libexportscomposeProfileDefinitions,composedLayerCheckandvalidateComposedLayerSources, not the builders — so no consumer outside this repository is affected.The witness is the one allod/archetypes#88 established and needs nothing new: every machine's derivation path must be unchanged,
./check.shgreen,./fork-safety.shgreen.Scope
In scope: the three builder signatures, the argument set
machineConfigurationspasses, and the fixture call sites in the checks that must now be explicit.Tracked elsewhere: moving the inline checks out of
flake.nix(allod/archetypes#93), and whether the fork witness should become a second composition (allod/archetypes#94).Refs allod/archetypes#88