Repository navigation
fix(vm): clear the managed save image when undefining a domain - #49
Conversation
A VM running when the host rebooted became unremovable by every charly verb. libvirt's shutdown handler managed-saves running domains, and libvirt refuses to undefine a domain holding a managed save image. undefineDomain passed only DomainUndefineNvram, so charly could reach a state it could not exit. All five cleanup paths funnel through that one helper, so all five were bricked: charly vm destroy, the defineAndStartDomain drifted-UUID self-heal (hence charly vm create / charly update), charly vm clean-orphans, the documented check-bed orphan cleanup, and vmRebuild -- the disposable-VM-bed fresh-rebuild R10 gate itself. Charly contains no managed-save code; the state is created outside it. Fixing the one shared helper repairs all five call sites at once (R3). Claim-keyed sweep (R1/R5): runCleanOrphans in charly/vm.go documented the flag set it delegates to, which this change makes false. The comment now states the behaviour instead of mirroring a constant, so it cannot drift again. Check-coverage: TestUndefine_ClearsManagedSaveImage starts a domain, managed-saves it (the exact state a host reboot leaves), asserts the save image is present, then requires undefineDomain to succeed. It FAILS against the pre-fix flag set with the verbatim production error and passes with the fix. R10: check-charly-vm bed, final code, exit 0, zero warnings, six steps incl. the 88s fresh-rebuild update; domain destroyed and no save files left behind. Live: charly vm destroy on the stranded domain went exit 1 -> exit 0, removing it and its 848 MB save file. Assisted-by: Claude (fully tested and validated)
pr-validator — APPROVED ✅Change class: charly/sdk Go (vm plugin behavior fix + core comment sweep + test + CHANGELOG) Fresh, independent re-derivation — I trusted none of the author's claims and re-ran the checks myself.
Independent verification run: Non-blocking notes for the author's next cutover (do NOT reopen this PR — file as own cutovers):
Decision: The fix is correct and minimal — Assisted-by: Claude (analysed on a live system) |
pr-validator finalizes the merge-time version for PR #49 (author-time placeholder 2026.191.0950 -> merge CalVer 2026.191.0818). No behavior change. Assisted-by: Claude (fully tested and validated) Claude-Session: https://claude.ai/code/session_01W8GPhuyWWs5XwJyJYtCaxE
Fold into the CalVer stamp; the heading now matches the merge-time filename. Assisted-by: Claude (fully tested and validated) Claude-Session: https://claude.ai/code/session_01W8GPhuyWWs5XwJyJYtCaxE
…D2 plugins half (#49) The chain-final pointer bump: plugins #42 (the boundary-law plugin-host skill rewrite, the pr-validator ARCHITECTURE GATE, the orchestrator integrity duty + responsibility matrix) merged as b7082ae on plugins main; this superproject commit pins it. Pure submodule-pointer bump to an all-documentation submodule commit — the narrative lives in the plugins CHANGELOG and the superproject 2026.194.0751 entry from the first commit. Assisted-by: Claude (documentation reviewed) Claude-Session: https://claude.ai/code/session_017rPy3PE6EuVHWsBbAUvxxL
…ks-doctrine enumeration (#49) R5 fix (V-D2chain CHANGES-REQUESTED on #88): the Hooks-doctrine PreToolUse-gate enumeration named 6 gates but omitted the 7th this cutover adds — the ZERO-ALIASES no-new-alias block. Appended it (declaration-form, tier-independent, fail-open, allows residual kit imports/calls) so CLAUDE.md matches the hook gate-set and the merged #42 agents-skill layer-1 enforcement wording. Docs-only; the hook files are unchanged (no gate re-run needed). Assisted-by: Claude (documentation reviewed) Claude-Session: https://claude.ai/code/session_017rPy3PE6EuVHWsBbAUvxxL
… pre-commit ZERO-ALIASES teeth (#49) The superproject half of #49 (D2, operator-directed v2-architecture governance). The plugins half (boundary-law sweep + the `## Target architecture (v2)` design section + the pr-validator ARCHITECTURE GATE + the agents responsibility matrix) landed first (v2026.194.0753); this bumps the plugins gitlink to it (b7082ae) and adds the CLAUDE.md contract + the runtime pre-commit teeth. - CLAUDE.md — the Key Rule renamed/rewritten to "Core is a PLUGIN HOST; EVERY capability is a plugin candy" (plugin-host fabric only; imports sdk/spec+proto only; everything else = tracked K-wave migration inventory); the two standing rules (IMPORT-PURITY + ZERO-ALIASES) + the P16 TRIPLE gate; boundary-law (M) drops "spine-irreducible", (D) gains loaderkit.Threaded; R5 corollary; the agents RESPONSIBILITY MATRIX pointer; the Hooks-doctrine gate enumeration extended with the 7th (ZERO-ALIASES) gate. - .claude/hooks/pre-commit-gate.sh — new ZERO-ALIASES teeth (assert_no_new_alias; tier-independent; fail-open): blocks a NEW charly/*_aliases.go file or a declaration-form kit-alias line; a plain residual kit call/import is ALLOWED (the migration-pattern exception). - .claude/hooks/gate_test.py — +4 cases (both directions), 81/81 green. - VISION.md — R5 cross-ref pointer sweep only. - plugins gitlink → b7082ae (the merged D2 plugins half). Validated by a fresh independent pr-validator: gitlink verified == the real merged plugins main; gate_test.py run LIVE (81/81, both directions); the hook change is a strengthening (no existing gate weakened); the R5 hooks-doctrine sweep miss was caught and fixed in place before merge. Assisted-by: Claude (analysed on a live system)
…reconciliation (guidance fix) (#123) feat(hooks): ZERO-ALIASES pre-commit gate + CLAUDE.md hooks-doctrine reconciliation (guidance fix) The superproject leg (B2 leg 2) of the guidance-level fix for the RCA finding (task #49): a fresh pr-validator let an alias/boundary violation pass with NO mechanical backstop — a prior feat-branch CLAUDE.md hooks doctrine claimed a "v2 ZERO-ALIASES gate" that DID NOT EXIST in the actual pre-commit-gate.sh. This leg adds the deterministic hook floor + reconciles the doctrine; the plugins leg (#66) strengthens the validator spec. Fix 1 — the ZERO-ALIASES hook gate (pre-commit-gate.sh + gate_test.py): alias_gate(repo) blocks a NEW charly/*_aliases.go file (status A; alias files have NO migration exception), a declaration-form kit-alias line in any staged charly/*.go (type X = kit.Y / var x = kit.Y), and a grouped alias line in a GROWN charly/*_aliases.go. A plain residual kit IMPORT/CALL is ALLOWED — only alias FORMS block (IMPORT-PURITY of a plain import/call stays validator-judged). Fail-open for non-charly repos; tier-independent. gate_test.py gains 8 ZERO-ALIASES cases + a charly_repo() helper (charly-superproject shape, no go.mod, isolating the alias gate from the lint gate): 32/32 PASS — the changed alias_gate code path executed LIVE against real staged charly/*_aliases.go files. Fix 2 — CLAUDE.md hooks-doctrine reconciliation: the mechanics list now names the ZERO-ALIASES gate (fail-open; plain residual kit import/call ALLOWED, only alias FORMS block — the mechanical floor under the pr-validator architecture gate, never a substitute). Attribution/CHANGELOG/architecture/R0–R10 proof remain validator-judged — the doctrine is reconciled with what the hooks ACTUALLY enforce. The plugins gitlink bump to the merged #66 commit (c30881e — all-documentation pr-validator.md strengthening) is appended as a follow-up commit on this branch before merge (B2: the super pointer must reference a commit on plugins main, which only the #66 merge produces). The squash-merge folds the hook+CLAUDE.md commit + the gitlink-bump commit + the version-stamp into the one main commit. Change class: hook SCRIPT (code/config class) — not documentation-only; the CLAUDE.md docs ride along. R10 = parse + execute the changed script live: python3 -B gate_test.py -> 32/32 PASS. Tier: analysed on a live system (the changed hook code ran live with output pasted; no disposable bed applies to a pre-commit hook). Tagged at merge as v2026.196.1205. Assisted-by: Claude GLM 5.2 Cloud (analysed on a live system)
…ctResolvedProjectWithBoxes wrapper (#55 step3-II) Validator CHANGES-REQUESTED on PR #196 (head 2786ceb): the R5 self-test for the deleted NewGenerator only covered the resolved-project identifiers, not NewGenerator itself. Fixes both blocking findings in one commit: 1. Whole-tree grep sweep of stale present-tense "NewGenerator is/does X" claims across every file touched by the deletion AND untouched siblings that named it (claim-keyed, not file-keyed, per R5): - charly/generate.go (comments on RequestedBoxes/dkGen/ newCandyScanGenerator's doc) - charly/resolved_project_host.go, charly/validate_project_host.go, charly/tasks.go, charly/plugin_loader.go (untouched siblings the validator named) - charly/host_build_render_seam.go, charly/build_emit_test.go, charly/deploy_target_pod_test.go (further hits the sweep caught) - candy/plugin-build/charly.yml + resolve.go (from the K3 cutover, #49 — predates this cutover but carried the same "NewGenerator stays host" claim, now false) - candy/plugin-example-builder/plugin.go, candy/plugin-example-step/ plugin.go (named a since-deleted generate.go connect seam + emitExternalBuilderStages/emitExternalBuilderArtifacts) Self-test: `git grep -n 'NewGenerator' -- charly/ candy/ ':!CHANGELOG/'` now returns ONLY historical/deleted-marked mentions — verified. 2. Deleted projectResolvedProjectWithBoxes (charly/resolved_project_host.go): production-dead once 3-II's own commit (6bc7b38) relocated its last production caller (the pod-overlay seam) plugin-side — the validator correctly flagged this as radical-dead-code-removal territory rather than an acceptable "R3 test harness". fillNamespacedBoxes stays (a genuinely live production capability via host_build_buildengine.go's hostBuildNamespaced). The two former test callers are repointed: - resolved_project_namespace_test.go's namespaced-box test now drives the LIVE hostBuildNamespaced directly (a better test target than the dead wrapper — it's the actual production function). - resolved_project_host_test.go's + plugin_installstep_envelope_parity_ test.go's generic-envelope-projection use (no live production equivalent left in charly core — the real replacement, candy/plugin- build's resolveBuildEngine, is a different Go module) now share ONE test-local reproduction, testProjectResolvedProjectWithBoxes (resolved_project_host_test.go), matching the established test-only-reproduction pattern this cutover already uses elsewhere (R3 — one helper, not two duplicated copies). Also caught + fixed two more stale references to the deleted wrapper surfaced by the same grep: candy/plugin-bundle/candy_select.go (repointed to the wrapper's real underlying mechanism, sdk/loaderkit's ProjectResolvedProject) and charly/validate_project_host.go (repointed the "overlay seam calls this fail-fast" claim to the actual current fail-fast caller, hostBuildNamespaced). Gates re-run: go build/vet clean (charly + candy/plugin-build + candy/plugin-bundle), all 85 candy modules build+vet clean standalone (GOWORK=off), gofmt -l clean tree-wide, go test ./charly/... 0-fail (194.4s) including the repointed namespace/parity/projection tests, TestPluginsGenReproducible PASS, box validate exit 0 (root + box/fedora), fresh task build:binary clean. No runtime behavior change (comments + test-only code), so no bed re-run required per the R10 gate-by-change-class matrix. Assisted-by: Claude Code Sonnet 4.5 (analysed on a live system)
Summary
A VM that was running when the host rebooted could not be removed by any charly verb:
undefineDomain(candy/plugin-vm/vm_libvirt.go) passed onlyDomainUndefineNvramandomitted
DomainUndefineManagedSave. libvirt refuses to undefine a domain holding a managedsave image, and the host libvirt shutdown handler managed-saves every running domain across
a reboot. Charly contains zero managed-save code (exhaustive grep for
DomainManagedSave/DomainSave/DomainSaveFlagsis empty; the graceful-stop path isDomainShutdown→DomainDestroy, neither of which saves memory) — the state is createdoutside charly, and the bug is that charly could not clear it.
Lifecycle asymmetry: charly could reach a state no charly verb could exit. All five
cleanup paths funnel through that one helper, so all five were bricked for a
rebooted-while-running domain:
charly vm destroydefineAndStartDomaindrifted-UUID self-heal → hencecharly vm create/charly updatecharly vm clean-orphansvmRebuild→charly vm destroy— the disposable-VM-bed fresh-rebuild R10 gate itselfFixing the single shared helper repairs all five call sites at once (R3).
Change class
charlyGo code (plugin + core comment). Gate:go test+task build:charly(R9) + a VMbed whose teardown drives
undefineDomain.Claim-keyed sweep (R1 / R5)
runCleanOrphans(charly/vm.go) documented the flag set it delegates to —DomainUndefineFlags(libvirt.DomainUndefineNvram)— which this change makes false. Thecomment now states the behaviour rather than mirroring a constant, so it cannot drift out
of lockstep with the plugin again.
git grep 'DomainUndefineNvram)'afterwards returns onlythe CHANGELOG's historical quotation.
Check-coverage (the differential — the test has teeth)
TestUndefine_ClearsManagedSaveImage(candy/plugin-vm/vm_managedsave_test.go) starts aminimal domain, managed-saves it (the exact state a host reboot leaves), asserts the save
image is really present, then requires
undefineDomainto succeed.Against the pre-fix flag set it fails with the verbatim production error:
With the fix:
R10 evidence
Exploratory (live, on the stranded domain). Pre-fix binary → exit 1 (above). Post-fix,
rebuilt binary → the domain and its 848 MB save file are gone:
Fresh-rebuild bed gate —
check-charly-vm, against the FINAL code (flag fix + commentsweep, binary rebuilt; the earlier run was deliberately stopped and relaunched so the gate
ran on the final code, not an intermediate state):
Zero warnings in the entire run (
grep -icE '\[WARN|warning:'→ 0). Post-action host statehealthy: no domains defined, no managed-save files left.
Full suites:
go test ./charly/...ok;GOWORK=off go test .incandy/plugin-vmok.R0–R10
root-cause-analyzerbefore any fix. It overturned myassumption (I believed a force-kill caused the managed save; the host reboot at 09:20 did).
charly/vm.gocomment surfaced during this cutover and is fixed here(blocking: it is a false claim on this change's own surface). The
summary.ymlverdictdefect and two teardown defects are genuinely separable and filed as immediate-next cutovers.
than source before the live run.
disposable: truebed, final code, both exploratory and fresh-rebuild outputspasted, zero warnings.
Tier
fully tested and validated— all ten standards met, the new code path executed live againstthe fresh rebuild, both outputs pasted.
Assisted-by: Claude (fully tested and validated)