flake-status: compare each pin to the branch its lock names #177
No reviewers
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!177
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/flake-status-locked-ref"
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-status --upstreamnow compares each pin to the head of the branch its own lock names, so anixpkgspin onnixos-26.05is measured againstnixos-26.05and ahome-managerpin at the tip ofrelease-26.05shows no arrow and is left out of theOutdated (external)line.A pin whose lock names no branch is still compared to the remote's default branch, and a pin that names its own revision is never behind.
Nothing changes for a running machine: this is a read-only inspection tool, and the no-argument and named-input tables print exactly as before.
Three other things become visible: the named-input
upstream:verdict is judged against the branch the majority pins rather than the first repo's; the suggestedflake-update-cascadecommand lists inputs in sorted order instead of hash order; and an input the tool cannot read the way the cascade does (dir,host,submodules, or a non-stringref) shows no arrow where it used to.tests/flake/flake-status.shnow pins the behaviour (35 tests, 14 new) and runs undernix flake check; a live--upstreamover the workspace and over a checkout with a stale lock are below.If a pin is arrowed wrongly, compare by hand with
git ls-remote <url> refs/heads/<ref>for therefin the lock'soriginalentry, and revert this PR: the old and new scripts read the same lock, so nothing else depends on it.Closes allod/tools#170
What changed
flake/flake-status:get_upstream_urlbecomesget_upstream_source, returningurl\tref. The ref isoriginal.ref, orHEADwhen the lock names none. A declaration carryingrev, or one that is not a plaingithuborgitreference (registry, tarball,path:, or a reference withdir,hostorsubmodules), yields nothing and gets no arrow. These are the classification rules ofinternal/flakelock/source.go, unchanged; the cascade is out of scope and untouched.timeout 60 git ls-remote --exit-code <url> refs/heads/<ref> refs/tags/<ref>(orHEAD/ a fullrefs/...as given), picking the first spec present and preferring a tag's peeled^{}commit, ascmd/flake-update-cascade/heads.godoes.GIT_TERMINAL_PROMPT=0and stdin from/dev/nullso a remote that wants credentials fails instead of hanging. Resolution is deduplicated byurl\trefrather than by URL, sonixos-26.05andnixos-unstableon the same repository are two reads.upstream:line compares the majority revision to the branch named by a repo that holds that revision. Before, it took the first repo's URL, so a workspace whose first repo pins a different branch of the same repository than the majority got a wrong verdict in exactly the way the issue describes.Outdated (local)andOutdated (external)lines sort their names; Bash associative-array order is unspecified, and the new fixture made that visible.flake/README.mdand--helpdescribe the comparison as against the branch the lock names, and list what the tool cannot read.flake.nix: aflake-status-suitecheck runs the Bash suite in the sandbox with a mock git, so the regression test has a standing witness. The suite's mock git names its interpreter outright, as the other sandboxed suites do, because the sandbox has no/usr/bin/env.Risk
githuborgitreference carryingdir,hostorsubmodules, or with a non-stringref. No workspace lock has one. The README says which inputs show no arrow.git ls-remotecalls for that reason.ls-remoteexit is still parsed (with--exit-codethere is none).Validation
bash tests/flake/flake-status.sh: 35 passed. Each "no arrow" assertion follows one proving the row exists, the tag fixture is behind its tag so only the peeled commit is a passing target, and theOutdatedline is matched exactly. The suite against the pre-change script fails at test 21 (stablearrowed to the default branch); against the first commit of this PR it fails at test 32 (the named-input verdict), so both fixes have an assertion that can fail.nix flake check: all checks passed, including the newflake-status-suite.flake-status --upstreamover the workspace from this branch: no arrows and noOutdatedsection. Cross-checked by hand:nixos-26.05is at6aefcda,nixos-unstableatd6524aa, home-managerrelease-26.05atfd0956c, agenix and disko default branches atb027ee2andff8702b, each equal to the corresponding lock. nixpkgsmasteris at01b3b32, which the old script would have arrowed every nixpkgs row toward.flake-status nixpkgs --upstreamover the workspace:INCONSISTENT (1 repo differs)withallod/tools(which pinsnixos-unstable) marked stale andupstream: up to date at 6aefcda, thenixos-26.05head.allod/vmat commitf1a6fe0, whose lock predates today's cascade:The pre-change script over the same workspace arrows all three toward
master(→ 01b3b32for both nixpkgs rows,→ 14179aefor home-manager) and suggestsflake-update-cascade nixpkgs-unstable home-manager nixpkgs.Follow-up
allod/memoryallod.mdrecords the old behaviour as a gotcha underflake-status; that line should be dropped once this merges.Read-only review pass over the first commit (
1ec997b), and what the second commit (a3891f2) does about each finding.Fixed:
upstream:said the pins were behind although each was at its own head. It now takes the branch from a repo holding the majority revision, and the suite has that exact fixture (charlie, epsilon, zeta onstable).row()returning nothing satisfiedassert_not_contains … "→"forpinnedandtagged, and the tag test could not tell "picked the peeled commit" from "never read tags". Every no-arrow assertion now follows one proving the row exists, the tag fixture is behind its tag so→ 1111111is the only passing target, and the remote log is asserted foracme/tagged refs/heads/v1 refs/tags/v1.Outdated (external)assertion was a substring match, so an extra name passed. It is now an exact line.git ls-remotehad no bound where the cascade uses 60 seconds; it now runs undertimeout 60.--upstreamonly with a named input and wrote the arrow as->; both corrected.Not changed, pre-existing and named in the body under Risk: the arrow compares 7-character prefixes where the Go cascade compares full revisions, and output printed before a non-zero
ls-remoteexit is parsed rather than discarded (empty with--exit-code).Verified by the reviewer: 32 suite tests passing at the time, the pre-change script failing the new assertions,
nix flake checkincluding the newflake-status-suitederivation, and the live workspace run against directgit ls-remotereads. The scratch-workspace run overallod/vmatf1a6fe0was not reproduced by the reviewer and is reported as I ran it.