Repository navigation
fix(container): refuse a stale short-name election in the build-scope verdict resolver - #29
Conversation
… verdict resolver `charly check box <box>` could certify an image that was not the one you built, report every step green, and give no sign. Measured 2026-08-15: a fresh build tagged :2026.227.0836 while `check box fedora-nonfree` ran :2026.216.1908 and reported 5 passed, 0 failed against the OLD baked plan. Two shapes reach that outcome, both live on a multi-worktree host: - the label family (`ai.opencharly.box == <short>`) is taken WHOLE and the name family discarded, so a build whose label disagrees with its own repo name is invisible to a resolve of that name (the emitter half is fixed in sdk); - the election's PRIMARY key is the content-derived `ai.opencharly.version` label with the build tag only as a tiebreak, so an image built from a differently-versioned source tree outranks a newer build outright. ResolveLocalImage returns the full answer (elected Ref + NewestBuildRef across BOTH families + Pinned); ResolveLocalImageRef and the new ResolveBuiltImageRef are thin wrappers over that one body (R3). ResolveBuiltImageRef refuses when the election is not the newest local BUILD, wrapping the new spec.ErrStaleLocalImage and naming both refs plus the pinned re-invocation. The election itself is unchanged: every consumption path (deploy, vm build, builder bootstrap) keeps it. Changing its primary key would change what `charly update` and the deploy paths resolve to — broader than this defect justifies, and with its own wrong case. A stale check that errors is recoverable; one that PASSes is not. Escapes (pre-existing): a full ref, or the `<box>:<calver>` pin — which is why the R10 bed sequence, which pins `<image>:<run-tag>`, never reaches the guard. Coverage: five tests over a fixture reproducing the measured storage; the gate fails on the pre-fix body (returns :2026.216.1908, nil error). Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
|
… blind to bed tags The first version of this guard was blind on exactly the builds it most needed to see, and a validator proved it live: `check box docs-site-app` certified an image ~17 hours old, green, exit 0. Root cause, and it is not new. `ExtractCalVerTag` is not total over the tags charly mints: `charly box build --tag` REPLACES the CalVer tag, so every bed build carries `check-<bed>-<calver>`, which is not three decimal dot-parts and reports as EMPTY. With the content label tied across one source tree and the tag key empty for every candidate, the election fell through to a lexicographic last resort and picked the OLDEST build. That was already root-caused on 2026-08-05 for the LIVE path (candy/plugin-check/live_image.go names the mechanism verbatim, including "the OLDEST local build of the box won") — that fix routed AROUND this resolver by asking the container, so the flaw survived here, and the guard was built on top of it. Three shapes, one key: - blind: all candidates bed-tagged → no tag CalVer anywhere → oldest elected, and newestBuildRef returned "" which the guard read as "nothing to worry about"; - misdirecting: a fresh bed-tagged build beside an older plain-CalVer one → the old image elected (an empty tag sorts last) and, depending on label versions, either silently certified or named as the "newest build" the operator should re-run against — a guard pointing at the artifact it exists to avoid; - unknowable: permissive-on-unknown, which is the same class as the original silent-pick defect. The fix keys build recency on the image's CREATION TIME (LocalImageInfo.Created, read from the `images --format json` rows Size already comes from — no extra process, no extra call). It is the only key total over arbitrary --tag values, agrees with the tag CalVer wherever that worked, and does not tie. The content label stays the election's primary key; creation time replaces the tag as the tiebreak, with the tag retained as a tertiary for sub-second parallel builds. Two properties creation time makes possible: - SameArtifact: many tags on ONE image id are one artifact — nothing older or newer to arbitrate, so the guard stays silent instead of refusing a box against itself; - OrderKnown: when any candidate reports no creation time the guard REFUSES with an explicit "could not establish which build is newest" rather than passing. Coverage: eight tests over fixtures reproducing the measured host, including all three shapes above. The three new gates fail on the blocked body — the bed-tag election returns the 08-14 ref, the mirror case returns the stale plain-CalVer ref, and the unknown-order case does not refuse at all. Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
The CHANGELOG entry described the first fix's tag-keyed ordering, which a validator blocked as blind to bed tags. Updated to describe what the branch actually ships — creation-time ordering, the SameArtifact exemption, and refuse-on-unknown — plus the six new coverage gates. Assisted-by: Claude Code Anthropic Claude Opus 5 (documentation reviewed) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
…rrect a false comment
Two validator findings.
The election's final tiebreak is ascending ref; newestBuild's was descending.
They diverge only when two DISTINCT images tie on every recency key — same label
version, same creation second, no CalVer tag — but there they name different
refs, and RefuseIfStale compares refs rather than keys, so the guard refused a
pair in which neither is newer than the other. Distinct builds do share a
creation second under parallel load, so it was reachable, not theoretical.
newestBuild now uses the election's ascending last resort; gated by
TestResolveBuiltImageRef_TiedKeysDoNotRefuse, which fails with the descending
form (it refuses, naming one twin "a newer local build").
The comment "podman and docker both emit it" — the sentence justifying
refuse-on-unknown — was false. Measured: podman 427/427 rows, docker 0/3
(`docker images --format json` emits CreatedAt/CreatedSince). Docker's path is
degenerate well upstream of recency: JSON-LINES rather than the JSON ARRAY this
parser unmarshals, and no Names/RepoTags/Labels either. So refusing on unknown is
the correct behaviour there rather than an accident. The sibling claim in the same
function ("docker uses RepoTags" — that is the INSPECT shape) is corrected too:
an authoritative comment that does not match the system is the shape this cutover
exists to remove.
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
…nd newestBuild The two sides each defined their own last resort — the election ascending by ref, newestBuild descending — so for two DISTINCT images tying on every recency key they named different refs, and RefuseIfStale compares refs rather than keys: the guard refused a pair in which neither was newer. Aligning the two definitions would have fixed today's divergence while leaving two definitions of one order that can re-diverge. moreRecent is now THE definition, used by both (R3). The arbitrary last resort is fine precisely because it is shared: whatever it picks, both callers agree, so an all-keys tie can never read as 'one of these is newer'. Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
…ade the guard a tautology Unifying electionOrder and buildOrder into a single moreRecent was a regression, and it shipped GREEN. Sharing the comparator made cands[0] identically the maximum the newest-build scan returns, so NewestBuildRef == Ref always and RefuseIfStale had nothing to compare: the staleness guard could never fire. Every refusal test survived it because they all use the two-family label split, where the newest-build scan walks the WIDER union and can still differ. No test covered a SINGLE-family stale election — the exact scenario the guard's own doc comment names — so the suite was green on a dead guard. The two orderings must differ in their PRIMARY key, because the difference IS the mechanism: - electionOrder, primary labelCalVer — which artifact does this NAME mean; - buildOrder, primary created, blind to the content label — which was BUILT most recently; - orderTail, the shared deterministic last resort. Arbitrary is fine; DISAGREEING is not, and that was the genuine duplication (two last resorts that disagreed refused a pair in which neither was newer). R3 applies to the tail. It does not apply to two answers that are supposed to be able to contradict each other; deduplicating those deletes the contradiction the guard exists to detect. Coverage: TestResolveBuiltImageRef_SingleFamilyStaleElectionRefuses fails against the unified comparator and passes here. Each ordering level is now independently mutation-gated — dropping the election's created key fails the bed-tag tests, sharing the comparator fails the single-family test, flipping the tail's ref direction fails the tied-keys test. Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
Renames the placeholder CHANGELOG stamp to the CalVer generated at merge and rewrites its H1 to match. Documentation only — no code, schema, or test changes; the validated tree is byte-identical to 91c7d20 apart from this rename. Assisted-by: Claude Code Anthropic Claude Opus 5 (documentation reviewed) Claude-Session: https://claude.ai/code/session_01Rt9KMZF6v3x1iL24M74dN2
Summary of changes
charly check box <box>could certify an image that was not the one you built, report every step green, and give no sign. This is the resolver half of the fix; the emitter half isopencharly/sdk, the call sites areopencharly/charly.Measured 2026-08-15 (day 227): a
check:step was added to a candy, the box rebuilt asghcr.io/opencharly/fedora-nonfree:2026.227.0835/:0836, andcharly check box fedora-nonfreeprintedImage: ghcr.io/opencharly/fedora-nonfree:2026.216.1908with5 passed, 0 failed— the OLD baked plan, the new step absent entirely. Two shapes inResolveLocalImageRefreach that outcome, both traced against the real image store rather than reasoned about:ai.opencharly.box == <short>) and a NAME family (trailing repo segment matches); the label family is taken WHOLE and the name family discarded (cands := labelCands; if len(cands)==0 { cands = nameCands }). A build whose label disagrees with its own repo name lands in the name family and is dropped regardless of how much newer it is.ai.opencharly.versionlabel with the per-build tag only a tiebreak, so an image built from a differently-versioned source tree (a sibling worktree, a pulled release) outranks a newer build regardless of when either was produced.Concrete edits, all in
container/local_image_coneb.go+spec/image_errors.go:LocalImageResolution— the full answer: the electedRef, theNewestBuildRef(highest build-tag CalVer across BOTH candidate families), andPinned.ResolveLocalImage— the single body doing the candidate gather, the ordering, and the ambiguity error.ResolveLocalImageRefbecomes a thin wrapper returning.Ref(R3 — one gather, one ordering).ResolveBuiltImageRef— resolves, then REFUSES when the elected image is not the newest local BUILD, wrappingspec.ErrStaleLocalImageand naming both refs plus the runnable pinned re-invocation.LocalImageResolution.RefuseIfStale+newestBuildRefhelper.spec.ErrStaleLocalImage— new sentinel next toErrImageNotLocal.container/local_image_coneb_test.go— five tests over a fixture reproducing the measured storage byte-for-byte.The election itself is UNCHANGED. Every consumption path (deploy,
charly vm build, builder bootstrap, kube preresolve) keeps the lenientResolveLocalImageRef; only the verbs that pronounce a verdict on an artifact opt into the guard. Changing the primary key globally would change whatcharly updateand the deploy paths resolve to — far broader than this defect justifies, and with its own wrong case (a colleague's build from older sources winning). A stale check that errors is recoverable; one that PASSes is not.Change class
cross-repo —
charly-or-sdk Go.Landing order (producer → consumer):
spec(this PR) →sdk→plugins→docs→charly.opencharly/spec— this PR (the resolver + the sentinel).opencharly/sdk—deploykitemits the box's LEAF name intoai.opencharly.box;kitre-exports the new resolver surface.opencharly/plugins,opencharly/docs— regenerated skill + site page.opencharly/charly— the three call sites, the check skill source, the gitlink bumps.How R10-tested — exact gate, commands, and pasted output
charly check run <bed>on a bed that exercises the changed path, plus per-modulego test/golangci-lint. The bed ischeck-marketplace, chosen deliberately: its plan runscharly box labels marketplace-apphost-side with a BARE short name, so it is the bed that could actually REGRESS from this guard — not the most convenient green one. Picking the bed that can fail is the point.check-marketplace | pod | ok | 13 steps | 370s— run calver.check/check-marketplace/2026.227.1148/, binarycharly version=2026.227.1116(the one binary every step below ran on). Single-bed gate: this change is a resolver used identically by every bed's PINNED check step, andcheck-marketplaceis the only bed whose plan reaches it UNPINNED. Not a concurrency-class change (see below), so no roster batch.task build:binaryand./bin/charly versionreports2026.227.1116; no.gofile under the changed packages is newer thanbin/charly. The bed's ownupdate(97s) +check-live-rebuild(37s) legs are the fresh-rebuild gate and both passed, at ZERO warnings.RefuseIfStalefired live on real podman storage, and the success path ran in the bed. One caveat, stated plainly: inopencharly/charlyone of the three call sites (box feature run) could not execute because that verb is unreachable for a separate pre-existing reason — that caps the tier atanalysed on a live system. Nothing in THIS repo's diff is unexecuted.N/A— this changes a read-only probe of local image storage (podman images+ label decode). It takes no lock, mutates no shared state, and touches neither the loader walk, the deploy ledger, the resource arbiter, nor any build lock.Attribution tier
analysed on a live system.Every changed path in THIS repo executed live, including the new error branch, and the R10 bed passed with its fresh-rebuild leg. The tier is nevertheless not
fully tested and validated, because the cutover spans repos and one of its three call sites inopencharly/charly(box feature run) could not be exercised: that verb is unreachable on a clean baseline (it routes to the top-levelcharly featuregrammar) and its hidden engine leafcheck __feature-boxis not reachable either — verified, not assumed. The table requires changed paths executed live; one did not, so the whole cutover claims the lower tier.Stated so the validator is not misled in the other direction: the lower tier's own wording ("the complete fresh-rebuild R10 did not pass") understates this case — the R10 bed DID pass. The downgrade rests purely on that one unexecuted call site.
Trailer:
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system).Harness rulebook compliance — state HOW each is satisfied
/charly-check:check(the verb surface + the R10-gate-by-change-class matrix that selected the bed),/charly-internals:go,/charly-internals:plugin,/charly-internals:git-workflow,/charly-internals:strict-policy,/charly-build:build(the CalVer-only tagging contract this resolver implements).podman image inspectagainst the live store (the label valuesfedora.fedora-nonfreevsfedora-nonfree, and the label-vs-tag CalVer split across:2026.227.0945/:2026.227.0942) — not inferred from reading. Further anomalies surfaced mid-work and were each RCA'd before being classified, none dismissed as flake or environmental (see R2). Bed output has zero warnings (grep -rin warn .check/check-marketplace/2026.227.1148/*.log→ empty).candy/plugin-clean's retention sort sharing this cutover's ordering blind spot — was found late and FOLDED INTO this cutover rather than named as separable, because it is the only surface here that DESTROYS an artifact rather than producing a false answer, and it consumes the same struct on the same root cause. The other three are RCA'd to file:line, named in the superprojectCHANGELOG/<CalVer>.md"Separable findings" section, and reported to the orchestrator, which has assigned owners: (1) an imported box bakes NOai.opencharly.description(CollectDescriptions→cfg.BoxConfig/WalkBaseChain, flat map lookups with no namespace descent) — opened as its OWN cutover; (2)charly box feature rununreachable; (3)spec/proc.SweepStaleTempsglobs a hardcoded/tmp/while its creators honour$TMPDIR— both joined the check-verb-correctness batch. Finding 1 was deliberately NOT widened into: its fix is making the deploykit collector family namespace-aware, an architectural change outside check-verb correctness.ResolveLocalImageRefandResolveBuiltImageRefare both thin wrappers over ONEResolveLocalImagebody — one candidate gather, one ordering, one ambiguity error. No second copy of the resolution logic, and the guard is at the resolver rather than repeated at each of the three call sites. This also retires a per-caller workaround: the R10 bed sequence already pinned<image>:<run-tag>for exactly this reason (candy/plugin-check/bed_run.go'srunTaggedImageRef, with a comment saying so) — the same problem, second surface, so the fix belongs here.charlyverbs (box build,box list tags,box labels,check box) except the read-onlypodman image inspectdiagnostics used during RCA, which observe rather than operate.ResolveLocalImageRefintentionally survives as the lenient form for every consumption path, and its doc comment now says so explicitly rather than leaving the split implicit. No transitional or dual-mode path exists in the final code: the guard is either called or not, per call site.git statuschecked before every destructive action. The one stash used (an RCA baseline check) wasgit stash push+popwith the tree verified clean on both sides. The temporary fix-reverts used to produce the failing-test proof were restored withgit checkout -- <file>and the tree re-verified0 dirtyin all five repos.charly check run check-marketplaceend to end (build → check box → deploy → check live → fresh update → check-live-rebuild → teardown), not justgo test. Output pasted above.N/Afor this repo's diff (no generation change here). The companionsdkPR carries the label assertion, read back post-build withcharly box labels.task build:binary,charly version=2026.227.1116, andfind <changed pkgs> -name '*.go' -newer bin/charlyis empty. No new runtime OS dependency, sopkg/arch/PKGBUILDis untouched.check-marketplaceisdisposable: true(pod:withdisposable: true,lifecycle: dev); no non-disposable target was touched. Fresh rebuild via the bed's ownupdateleg, zero warnings. Coverage that fails without the change is pasted above and DISCRIMINATES — exactly one of seven tests moves when the guard is removed.N/Afor this repo (no candy in the diff); the superproject PR's candy edit keeps itsdescription:+plan:andcharly box validateexits 0. SDD —N/A, no.cueedit; the new sentinel is a plain Go error var alongside the existingErrImageNotLocal, not a schema-shaped type.N/A — no kernel change.This is thespec/containerfabric slice, a kind-blind host primitive (container-CLI probes + ref-shape predicates). No concrete-kind schema, kind-word switch, or per-kind map is introduced;charly/import purity is untouched (this repo isgithub.com/opencharly/spec, whichcharly/is explicitly permitted to import).check-marketplacebed, declareddisposable: true. The live refusal experiment created image TAGS only (viacharly box build) and destroyed nothing.gofmt -l .empty;golangci-lint run ./...→0 issues, exit 0;go vetclean;go test ./...green. One honest note:spec/procfails two tests in a session whoseTMPDIRis exported, and passes underenv -u TMPDIR— that is separable finding 3 (the sweep hardcodes/tmp/), unrelated to this diff and reported for its own cutover.CHANGELOG/2026.227.1157.mdstaged — placeholder CalVer, the pr-validator finalizes it at merge.Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)