flake-update-cascade: resolve follows edges when reporting revisions #154
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/tools!154
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/cascade-follows-rev"
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?
flake-update-cascadestops dying when an update collapses a pinned input into afollows. It hit this on a real run today, against a privateallod-deploypicking up allod/archetypes#39: Nix wrote the new lock, and the tool then ended withjq: error … Cannot index object with arraybefore committing or pushing it, and before reaching any later repo in the cascade.Nothing about how the tool selects or performs updates changes. The fix is in the helper that reports each path's before and after revision, and the run that failed now completes.
If this is wrong, revert the commit. The tool is a workspace helper; nothing depends on its internals and no lock content changes.
What went wrong
Update paths are discovered from the pre-update lock, then each path's revisions are read from the pre- and post-update locks to report what moved. Between those two reads the update can change the graph's shape.
In a
flake.lockan input edge has two shapes: a pinned input is the target node's name as a string, and afollowsis an absolute path from root as an array.get_update_pathsalready knows this and skips arrays while walking:get_revdid not:So when allod/archetypes#39's
nexus.inputs.vm.follows = "vm"reached a consumer, the patharchetypes/nexus/vm— a real pin before the update — became["archetypes", "vm"]after it. The reduce fed that array back into$lock.nodes[...]and jq exited 5. Underset -euo pipefailthat ends the whole cascade at the worst point: after the new lock is on disk, before it is committed.The same cause produced the run's earlier
warning: 'archetypes/nexus/vm' does not match any input of this flake.What changed
get_revwalks one edge at a time and resolves afollowsarray by restarting the walk from root along it, which also handles a redirect whose target is itself a redirect. A path that no longer resolves yields empty instead of an error.Risk
Low, and bounded to reporting.
get_revfeeds oneechoof the formpath: old → new; it does not decide what is updated, staged, committed or pushed. A path that stops resolving now prints a half-empty line rather than ending the run, which is the intended degradation — the cascade's job is to land the lock, and a cosmetic gap in the summary must not cost that.Recurrence is not hypothetical: allod/archetypes#48's companion adds another
followsredirect, and every future one lands in consumers the same way.Validation
bash tests/flake/flake-update-cascade-follows.sh— new. Builds a lock with twovmnodes, one reached throughnexus, and a mock update that collapses the nested one to["archetypes", "vm"]and deletes its node. Asserts the run exits 0, that noCannot index object with arrayappears, that the still-pinned path reports normally, and that the collapsed path resolves through itsfollowsto the node it now redirects to.tests/flake/flake-status.sh,flake-update-cascade-multiple-inputs.sh,flake-update-cascade-nixconfig.shall pass unchanged.Not covered: no test drives a real
nix flake updateagainst a real forge. The mock reproduces the lock shapes, not Nix's behaviour producing them.