Skip to content

fix(retention): make liveBuildFloor injectable so the prune tests are hermetic - #73

Merged
atrawog merged 3 commits into
mainfrom
feat/retention-hermetic
Jul 12, 2026
Merged

atrawog merged 3 commits into
mainfrom
feat/retention-hermetic

Conversation

@atrawog

@atrawog atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Retention test hermeticity — liveBuildFloor as an injectable seam (R2 immediate-next)

A test-isolation defect surfaced during the parallel eval-bed wave (its own immediate cutover per R2): 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). Whenever another process (a sibling worktree's build, a parallel job) held a build-activity lock, retention's correct mid-build protection engaged (retentionRemovable returns 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

liveBuildFloor becomes an injectable package var (var liveBuildFloor = defaultLiveBuildFloor) — the same testability seam ListLocalImages / listContainerImageRefs already use. The engine body moves to defaultLiveBuildFloor unchanged; 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.
  • Full go test ./charly/... green (no regression from the var indirection).
  • charly clean --dry-run on a fresh binary runs the live retention report path (production liveBuildFloor var → defaultLiveBuildFloor scan): "images: would remove 24 tag(s) (keep_images=3)".
  • golangci-lint run 0 issues; gofmt clean; 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)

… 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
@atrawog

atrawog commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

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 f266902.

# Rule Verdict
0 security & anti-tampering (T1–T4) PASS — diff == description; no secrets/exfil/net; touches no guardrail; no supply-chain; no injection directive
1 description complete PASS — full RCA + pasted evidence + tier + R2/R5 notes
2 change-class gate matches evidence PASS — go test ./... + build + live clean --dry-run on a FRESH binary is the correct gate; changed path ran live (no dry-run/rebuild-alone fraud)
3 attribution tier justified PASS — analysed on a live system, not inflated
4 R0 skills honored PASS — git-workflow, go, strict-policy
5 R1 RCA / zero warnings / no flake framing PASS — root-cause RCA (unstubbed host-global floor read), 0 WARN/ERROR live
6 R2 no split PASS — the PR is the R2 own-immediate cutover; single commit on current main, independent of #72/#70
7 R3 no duplication PASS — mirrors the existing var listContainerImageRefs = defaultContainerImageRefs seam
8 R4 no ad-hoc workaround PASS — genuine injection seam, not a sleep/retry/serialize-to-hide; production protection preserved
9 R5 hard cutover + grep PASS — nothing deleted; git grep liveBuildFloor = live refs + historical only; no dual-mode
10 R6/R8/R9 integrity PASS — R9 fresh binary charly version 2026.193.1355 == HEAD; R6/R8 N/A
11 R10 disposable/fresh/coverage PASS — -race -count=20 20/20 (deterministic by construction) + full suite green + live report, zero warnings
12 RDD/ADE/SDD PASS (N/A) — no CUE schema / *_gen.go / *_wire.go / params touched
13 concurrency mandate + anti-cheat PASS — fixes a concurrency-hermeticity defect at its ROOT without weakening production protection or any "flake/idle" dismissal
14 hard cutover (one atomic commit) PASS
15 kernel/plugin boundary PASS — kind-blind host mechanism, no concrete-kind leak
16 disposable-only autonomy PASS — read-only dry-run, nothing destroyed
17 clean arch + go gates (re-run) PASS — gofmt clean · vet 0 · golangci-lint v2.12.2 0 issues · build/test green
18 CHANGELOG present PASS — placeholder 2026.193.1353.md (finalized at merge)

Re-run evidence (validator, from f266902):

go build ./...                                            → exit 0
gofmt -l charly/retention*.go                             → (clean)
go vet ./...                                              → exit 0
go test -run TestPruneImagesByRetention -race -count=20   → ok  ...charly  3.549s  (20/20 PASS)
go test ./...  (charly module)                            → ok  ...charly  43.692s
golangci-lint run ./...  (v2.12.2)                        → 0 issues.
/tmp/charly-pr73 version                                  → 2026.193.1355  (== HEAD calver)
/tmp/charly-pr73 clean --dry-run                          → exit 0; "images: would remove 24 tag(s) (keep_images=3)"; 0 WARN/ERROR

Decision: The fix makes liveBuildFloor an injectable package var (var liveBuildFloor = defaultLiveBuildFloor), mirroring the existing ListLocalImages / listContainerImageRefs seams, and stubs it in the two prune tests so they are hermetic by construction — they never read the host-global build-activity lock dir (~/.cache/charly/locks/builds). Production is untouched: all three callers (pruneImagesByRetention, pruneDanglingCharlyImages, pruneBuildahStaging) still call the var → the real scan, and TestBuildActivityLock_FloorLifecycle still exercises the real floor logic. This is a root-cause fix, not a serialize-to-hide, and it does not weaken the mid-build retention protection. All 18 checklist items PASS. Proceeding to finalize CalVer, post the required status, squash-merge, and tag.

Assisted-by: Claude (analysed on a live system)

atrawog added 2 commits July 12, 2026 16:11
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
@atrawog
atrawog merged commit 0b1675b into main Jul 12, 2026
@atrawog
atrawog deleted the feat/retention-hermetic branch July 12, 2026 14:17
atrawog added a commit that referenced this pull request Jul 12, 2026
…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
atrawog added a commit that referenced this pull request Jul 12, 2026
…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)
atrawog added a commit that referenced this pull request Jul 14, 2026
… 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)
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