Skip to content

fix(loaderkit): a real CalVer tag outranks a bare SHA, and the skew names every loser - #549

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/calver-outranks-sha
Nov 16, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/calver-outranks-sha

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Two defects in the candy-version arbiter, both found while advancing a pin in a consumer project
(opencharly/distro-cachyos#184) and both of a kind that silently produces the WRONG image.

1. A bare SHA wins the "newest" arbitration. PickCandyVersion orders candidates with the
lenient kit.CompareCalVer, whose lexical fallback compares 7766a9d06ec5 against
v2026.320.1938 as strings: '7' > '2', so the stale SHA is "newest". A bare commit SHA is
a legitimate pin — the distro-* rule pins SHAs precisely because those commits are untagged —
but it carries no recency at all, so this inverts the arbitration exactly when a project mixes
the two forms.

Measured in opencharly/distro-cachyos: the CDI driver-shadowing fix at
layer-nvidia:v2026.320.1938 lost to the pre-fix commit that a stale require: two hops away
still pinned, and the resolver said so at INFO level:

Notice: candy github.com/opencharly/layer-nvidia resolved to multiple git tags with differing
content within one scope (box=versa); using newest referenced 7766a9d06ec5fe8c276c091a68fb72cea12688e3

spec/calver.ParseCalVer already documents the intended semantics — "a false result is treated
by the freshness comparison as older than every real CalVer"
— so this restores it rather than
inventing a new rule: a parsed CalVer tag outranks a non-CalVer ref, and only two non-CalVer refs
fall back to the legacy lenient order (so a project that pins only SHAs is unaffected). Tags
carry a leading v, so the comparison trims it before parsing — without the trim every tag
parses as non-CalVer and the preference would never apply.

2. The skew diagnostic named only the winner. A message that states a comparison and hides
one side is not actionable: the reader cannot tell which refs disagree, nor where the losing one
came from. The line now appends every losing candidate with its tag, its source, and the box
scopes that named it:

... using newest referenced v2026.320.1938 (from ...); also referenced 7766a9d06ec5
(from ...; scopes: box=versa)

That gap is opencharly/charly#1179, filed from the same episode: finding the losing ref took
bisecting an eighteen-candy box one candy at a time, because the tool named one side of a
two-sided comparison.

How tested

1. The two new cases, and the full package suite:

$ go test ./loaderkit/ -run 'PickCandyVersion|DescribeSkew' -count=1
ok  	github.com/opencharly/sdk/loaderkit

$ go test ./loaderkit/ -count=1
ok  	github.com/opencharly/sdk/loaderkit	5.029s

The new cases assert both halves, and both fail on the pre-change code: the first because the
arbiter returned the SHA, the second because the message carried no loser at all.

2. The whole module, because this is a shared library:

$ go vet ./loaderkit/
(clean)

$ go test ./... -count=1
20 packages ok, 0 FAIL

3. This repo's structural gate, on the committed tree:

$ charly box validate
charly box validate: OK — checked 1 candy, 6 distros, 7 builders; 0 warnings, 0 errors

4. Why no bed. This repo is a library: charly.yml declares one candy and no disposable
deployment, so there is no R10 bed to run here. The behaviour change is exercised by the tests
above, and its consequence for a real project is the measured one in the Summary — it is the
consumer that will show it, in opencharly/distro-cachyos#184.

Rulebook compliance

  • R0 — loaded before the first action: /charly-internals:git-workflow, /charly-internals:go,
    /charly-internals:go-quality, /charly-check:check.
  • R1 — no warnings from any gate. The anomaly that led here is dispositioned in
    fix(resolve): the multi-ref candy error names only the winning ref, never the loser or its referrer charly#1179 (the diagnosability half) and in distro-cachyos#184 (the pin advance it
    blocked); this PR is the root fix for both halves.
  • R2 — one implementation: the preference lives in the single arbiter every candy ref flows
    through; no caller-side special case.
  • R3 — no workaround: the fix restores the comparator's documented semantics instead of
    teaching callers to avoid SHA pins.
  • R4 — product before prose: the code carries the behaviour, and the doc comment explains the
    measured reason at the site.
  • R5 — nothing legacy left: the old ordering call is replaced, not wrapped.
  • R6 — git status --short empty after the commit; fresh worktree off origin/main; nothing
    outside this repo touched.
  • R7 — the tests FAIL without the change (verified by writing them first: the arbitration test
    returned the SHA, and the message test found no loser), and the changed path executes in the
    suite.
  • R8 — no live service boundary in this change.
  • R9 — built and tested with the module's own pinned toolchain; go vet clean.
  • R10 — no disposable target exists in this repo (see item 4); the gate that owns the change
    is the package suite plus charly box validate, both pasted.

Change classification

Breaking change + rollback: behaviour changes for exactly one case — a closure that names the
same candy both by CalVer tag and by bare SHA now resolves to the TAG instead of the lexically
greater SHA. That is the intended semantics (a SHA is a pinned old commit, not a newer version),
and it is what a consumer wants: the alternative silently kept pre-fix content. Rollback is
reverting this commit; consumers then resolve to the SHA again, which is the defect.

Change class: library code — unit suite + go vet + the repo's validate gate.

Filed issues

Agent: charly

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

…ames every loser

Two defects in the same arbiter, both found while advancing a pin in a consumer project.

1. A BARE SHA WON THE NEWEST ARBITRATION. PickCandyVersion ordered candidates with the lenient
   kit.CompareCalVer, whose lexical fallback puts 7766a9d06ec5 ABOVE v2026.320.1938 (7 sorts
   after 2). A bare commit SHA is a legitimate pin — the distro-* rule pins SHAs because those
   commits are untagged — but it carries NO recency, so a stale SHA was chosen as the newest
   candidate and the pre-fix content won, with only an INFO line to say so. Measured in
   opencharly/distro-cachyos: the CDI driver-shadowing fix at layer-nvidia v2026.320.1938 lost
   to the pre-fix commit pinned by a stale require: two hops away, so the composed image would
   still have baked the driver user-space. spec/calver.ParseCalVer already documents the
   intended semantics ("a false result is treated as older than every real CalVer"); this
   restores it. Tags carry a leading v, so the comparison trims it before parsing. Two refs that
   are BOTH non-CalVer keep the legacy lenient order, so a project that pins only SHAs is
   unaffected.

2. THE DIAGNOSTIC NAMED ONLY THE WINNER. A message that states a comparison and hides one side
   is not actionable: the reader cannot see which refs disagree or where the losing one came
   from. The skew line now appends every losing candidate with its tag, its source, and the box
   scopes that named it. That gap cost hours on the pin advance above (opencharly/charly#1179:
   the losing ref turned out to be a stale require: in another candy).

Tests: two new cases pin both halves (the loser is named verbatim; the winner is the newest
CalVer tag even when a SHA is lexically greater), and describeSkew is empty when every candidate
is the winner, so an unskewed closure's message is unchanged.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 9596f37768f8c9331941d822d317f2153d310575 (branch: fix/calver-outranks-sha)

Security screen: PASS
Checklist: All applicable rules PASS or NA. Library-code change (sdk loaderkit mechanism kit) — placement correct (sdk, not core); single atomic commit; both new code paths exercised by the new tests (which fail on the pre-change comparator); body supplies all template sections, real filed issues (charly#1179, distro-cachyos#184), no forbidden framing, and ends with the Assisted-by: line. No beds applicable (no disposable target in this library repo) — consistent with the diff. Comment thread empty.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 16, 2026 21:57
@github-actions
github-actions Bot merged commit fe49e52 into main Nov 16, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 16, 2026
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Nov 17, 2026
…ag over a bare SHA (#1186)

Consumes opencharly/sdk#549 (v2026.320.2158): PickCandyVersion preferred a bare commit SHA over a
real CalVer tag, because the lenient comparator's lexical fallback sorts 7766a9d06ec5 above
v2026.320.1938. The OLDER content therefore won the arbitration and the only signal was an INFO
line -- measured in distro-cachyos, where the CDI driver-shadowing fix lost to a pre-fix commit
pinned by a stale require: two hops away. The same release makes the skew diagnostic name every
losing ref with its source and box scopes (#1179).

This repo is a multi-module tree (go.work + tools/*/go.mod) and its own contract test enforces ONE
shared sdk pin across every lockstep module, so the bump is the sdk line plus this repo's own verb:

  [pass] run   -- adopt the shared pins and tidy every lockstep module
  [pass] check -- every lockstep module now carries the shared pins

Ten files: charly/go.mod + go.sum, and the four lockstep tools modules (generate-packages,
golden-cloudinit, golden-compile, gomod-canonical) in go.mod + go.sum each.

Verified before the push: go build ./... clean; go test ./... green in charly/ (2 packages) and in
all five tools modules under GOWORK=off, including gomod-canonical's TestContractPinsMatchShared --
the test that failed on the earlier attempt to bump only charly/go.mod.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant