Repository navigation
fix(kit): persist RemoveVmSshStanza removals while sibling stanzas exist - #371
Conversation
saveStanzas re-merged the caller's map into a fresh `loadStanzas` read, so RemoveVmSshStanza's delete was re-added from disk whenever any sibling stanza remained — only the single-stanza `len==0 → os.Remove` arm hid it. `charly vm destroy` therefore reported success yet left the alias behind. Do the read-modify-write UNDER the fragment file lock and write the authoritative set (no fresh-load re-merge); the concurrency guarantee is preserved by loading under the lock, not by re-merging without it. Adds a removal regression test and points the concurrency test at the real API. Refs #370
|
Live confirmation of the fix on the real fragment this bug was found on. Host The Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated) |
Review — PASSHead SHA: Security screen: PASS — no secrets/egress, no guardrail or validator-spec change, no new deps; diff touches only Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
* chore(deps): adopt sdk v0.2026286.849 (ssh stanza removal fix) Bumps github.com/opencharly/sdk to the tag carrying the RemoveVmSshStanza persistence fix (opencharly/sdk#371): with sibling stanzas present, `charly vm destroy` now prunes the managed ssh_config Host stanza instead of resurrecting it. spec cascades to v0.2026280.2244. Refs opencharly/sdk#370, opencharly/sdk#371 * docs: re-freeze gate on the corrected PR body (no code change) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
* chore(deps): adopt sdk v0.2026286.849 (ssh stanza removal fix) Bumps github.com/opencharly/sdk to the tag carrying the RemoveVmSshStanza persistence fix (opencharly/sdk#371), so the vm deploy teardown prunes the managed ssh_config Host stanza instead of resurrecting it while sibling stanzas remain. spec cascades to v0.2026280.2244. Refs opencharly/sdk#370, opencharly/sdk#371 * docs: re-freeze gate on the corrected PR body (no code change) * docs: re-freeze gate after round RCA + filed R10 gap (no code change) * docs: add the check-local-vm bed evidence for the R10 finding (no code change) * docs: add the isolated deploy-del teardown proof for the R10 finding (no code change) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
Summary
kit.RemoveVmSshStanzanever persisted a removal while any sibling stanza remained, socharly vm destroy(and avm:deploy's teardown) reportedDestroyed VM <name>yet leftthe managed
Hostalias behind in~/.config/charly/ssh_config.Root cause.
saveStanzasre-merged the caller's map into a freshloadStanzas(path)read. That merge is upsert-only, so the just-deleted alias was re-added from disk whenever
another stanza existed — only the single-stanza
len==0 → os.Remove(frag)arm hid it.Fix.
WriteVmSshStanzaandRemoveVmSshStanzanow do their read-modify-write underthe fragment file lock (
lockStanzas) and write the authoritative set (writeStanzasLocked,no re-merge). The concurrency guarantee that motivated the merge (no lost alias under N
concurrent writers — the measured 16-lane check-run stalls) is preserved by loading under
the lock instead of re-merging without it.
Closes #370.
How tested
All commands run on the committed tree
a7448c55cda48fc0902447ac58e150b1ac8c3c29(
git status --shortempty), changed fileskit/sshconfig.go+kit/sshconfig_test.go.Reproduction before the fix (worktree at
origin/main, test added, source unpatched):After the fix:
Full module gate on the committed tree:
Live evidence that motivated the fix (host
no, 2026-10-13): on a 20-stanza fragment,charly vm destroy ubuntu-ci --diskprintedDestroyed VM charly-ubuntu-ciand removed thelibvirt domain, the ~116 GiB disk and the
vm:ubuntu-cideploy entry — butgrep charly-ubuntu-ci ~/.config/charly/ssh_configstill matched after the run; the fragmentmtime advanced (a rewrite happened) yet the alias survived, i.e. the removal was written and
then resurrected by the re-merge.
Rulebook compliance
/charly-internals:git-workflow,/charly-internals:plugin,/charly-internals:gobefore any change.saveStanzas; reproduced with a failing test before touching the fix.writeStanzasLockedis the single authoritative fragment writer; the re-mergingsaveStanzasis deleted, not left beside it.sdk/kit), not the caller.main; work done in thefeat/ssh-stanza-pruneworktree.a7448c5; the changed path executes live in the regression test.sdkis the producer; consumers (plugin-vm,plugin-deploy-vm,plugin-kubevirt) adopt through a normalgithub.com/opencharly/sdkpin bump after this merges and tags.Change classification
sdk/kit), no schema or wire-type change.go build ./...+go test ./...+gofmt+go vet+ the Linux cross-compile matrix (amd64/arm64/arm/386), all on the committed tree.fully tested and validated.Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)