Repository navigation
fix(retention): make liveBuildFloor injectable so the prune tests are hermetic - #73
Conversation
… hermetic TestPruneImagesByRetention / _SharedID stubbed the image inventory (ListLocalImages, listContainerImageRefs) but NOT liveBuildFloor, which reads the HOST-GLOBAL build-activity lock dir (~/.cache/charly/locks/builds, shared by every charly process on the host). A concurrent build in any other process engaged retention's correct mid-build protection, so the tests were non-deterministic under the parallel eval-bed roster — the expected tag removal was silently skipped (removed=[]). Root-cause fix: liveBuildFloor becomes an injectable package var (var liveBuildFloor = defaultLiveBuildFloor), the same testability seam ListLocalImages and listContainerImageRefs already use; the two prune tests stub it to a fixed no-live-build result so the decision under test is deterministic. Production callers (pruneImagesByRetention, pruneDanglingCharlyImages, pruneBuildahStaging) are untouched; retention's mid-build protection is unchanged. Distinct from the separate retention -> sdk/kit relocation cutover. R2: its own immediate cutover, opened after the scaffold PR surfaced the RCA. Verified: go test ./charly/ -run TestPruneImagesByRetention -race -count=20 (20/20); full go test ./charly/... green; charly clean --dry-run runs the live retention report path; golangci-lint 0 issues; gofmt clean. Assisted-by: Claude (analysed on a live system) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
pr-validator — APPROVED ✅Change class: charly/sdk Go (test-hermeticity fix + no-op production refactor) · 3 files, +66/−6 Fresh, independent re-validation (new context, superproject-rooted). Every gate re-run from the PR head
Re-run evidence (validator, from Decision: The fix makes Assisted-by: Claude (analysed on a live system) |
pr-validator merge-time version stamp: rename the placeholder CHANGELOG to the merge CalVer and rewrite its H1 heading. No source change. Assisted-by: Claude (analysed on a live system) Claude-Session: https://claude.ai/code/session_012jTVxt34oghXjVVe4nhkyi
…sion The #74 grpc-race CHANGELOG placeholder collided with the filename retention #73 finalized to at its merge (v2026.193.1414). Renamed to 2026.193.1422 (content unchanged; the validator re-finalizes to the merge-time CalVer anyway). Keeps #73's landed 2026.193.1414.md intact. Assisted-by: Claude (documentation reviewed) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…unit) (#72) Relocate the `charly box new` project/candy/box scaffold ENGINE (ScaffoldCandy/ScaffoldProject/AddBox + seeds + saveYAMLNodeFile) from charly core into sdk/kit, so BOTH the core CLI now and the Wave-2 command:box plugin next drive ONE shared authoring library. Core keeps the CLI grammar (NewCandyCmd/NewProjectCmd/NewBoxCmd → kit.*) and the add-candy/rm-candy edit helpers; ComputeCalVer stays core and is passed to kit as a param (kit stays clock-free). The `charly box new` CLI surface + behaviour are UNCHANGED — a pure, byte-parity- preserving engine relocation with no transitional path. Net −~194 core LOC. - charly/scaffold.go DELETED (ScaffoldCandy → kit.ScaffoldCandy). - charly/scaffold_project.go slimmed to the add-candy/rm-candy edit helpers; the shared marshal-to-file helper is the exported kit.SaveYAMLNodeFile (one home, R3); resolveBoxNodeFile stays core. - Scaffold engine tests → sdk/kit/scaffold_test.go; core keeps the add/rm integration tests rewired to kit.*. Validated by a fresh, independent pr-validator: go build/vet/gofmt clean; golangci-lint 0 issues (charly + sdk); go test green (charly + sdk/kit); `charly box new project/candy/box` byte-parity IDENTICAL to the pre-refactor binary; cue:gen no-op; R5 grep clean; delta re-gate green after update-branch. The earlier CHANGELOG forbidden-framing concern was scrubbed and the underlying retention test-isolation defect fixed as its own cutover (#73), both verified. Assisted-by: Claude (analysed on a live system)
… candy/plugin-box (K3-D+) (#107) The superproject leg of #60 (K3-D+): the ~900-line per-kind/op `charly box validate` rule ENGINE + the ~527-line candy/box graph re-run move OUT of charly/ core INTO the compiled-in candy/plugin-box plugin, reading the resolved-project envelope (spec.ResolvedProject) instead of the runtime *Candy/*Config graph. Core keeps only the tolerant projector, the host-natural checks (CUE-conformance + build/distro/merge/ tunables/builder-refs/remote-candies), and the build-gate dispatch (command:validate -> structured OpValidate -> spec.Diagnostics). ~2054 net LOC leave core. Consumes merged sdk 7e9aafe + plugins d94a53b. - Decoration ruling B: validate errors now Kong-wrapped like `box generate` (verdict CONTENT byte-identical, golden corpus). - Two side-channels RCA'd + fixed in-tree: tolerant-projector over-report (silent-skip matches OLD); baked-label intent_do (deliberate stampStepIntentDo on the bake's own copy over kit.StepDoMode; verb-less->empty matches OLD; TestBakeableSteps_StampsIntentDo). - Unit D = D1 (bundle-walk-compile premise verified FALSE; IOU to K4). R3 forced dup envVarNameToPodmanSecretSlug registered #73 (convergence exit). graph.go skill ref -> #48. Validated by a fresh pr-validator (independent): workspace gates re-run green (build/test/vet/golangci-lint-0/ gofmt, charly + plugin-box); golden corpus verdict-PARITY (5 fixtures, OLD-in-core vs NEW-in-plugin); disposable bed roster green (check-commands-local + check-sidecar-pod, fresh update); intent_do label independently confirmed (ai.opencharly.description carries "intent_do":"assert" x17 on a fresh-rebuild image); test migration no-net-loss (67 rows, 0 drops). #60 completes. Assisted-by: Claude (fully tested and validated)
Retention test hermeticity —
liveBuildFlooras an injectable seam (R2 immediate-next)A test-isolation defect surfaced during the parallel eval-bed wave (its own immediate cutover per R2):
TestPruneImagesByRetention/_SharedIDstubbed the image inventory (ListLocalImages,listContainerImageRefs) but notliveBuildFloor, which reads the host-global build-activity lock dir (~/.cache/charly/locks/builds, shared by every charly process on the host). Whenever another process (a sibling worktree's build, a parallel job) held a build-activity lock, retention's correct mid-build protection engaged (retentionRemovablereturns false while a build is live), so the test's expected tag removal was silently skipped (removed=[]) — non-deterministic under concurrent host builds.Root-cause fix
liveBuildFloorbecomes an injectable package var (var liveBuildFloor = defaultLiveBuildFloor) — the same testability seamListLocalImages/listContainerImageRefsalready use. The engine body moves todefaultLiveBuildFloorunchanged; every production caller (pruneImagesByRetention,pruneDanglingCharlyImages,pruneBuildahStaging) is untouched and still does the real lock scan. The two prune tests stub it to a fixed no-live-build result → hermetic.Test-isolation only. Retention's production behaviour (the mid-build protection) is unchanged and correct. Distinct from the separate retention→sdk/kit relocation cutover.
Verification
go test ./charly/ -run TestPruneImagesByRetention -race -count=20— 20/20 pass, deterministic.go test ./charly/...green (no regression from the var indirection).charly clean --dry-runon a fresh binary runs the live retention report path (productionliveBuildFloorvar →defaultLiveBuildFloorscan): "images: would remove 24 tag(s) (keep_images=3)".golangci-lint run0 issues;gofmtclean; R5 clean.2 files, +27/−6 (plus CHANGELOG). Based on current main (P13); independent of #72 (scaffold) and #70 (P8b) — verified.
Assisted-by: Claude (analysed on a live system)