Repository navigation
fix(deploykit): refuse to persist a degraded per-host config load - #633
Merged
Merged
Conversation
The per-host config's loader can fail OPEN: a deploy entry it cannot unify comes back as an empty or short DeployConfig with no error, and a writer that then saves its own dc erases every entry the loader dropped. Measured on a host, 2026-11-24 (opencharly/charly#1269): ~/.config/charly/charly.yml lost BOTH of its deploy entries (and `system:`) in one run while the containers kept running. SaveDeployConfig now compares the TYPED re-read (the existing fail-safe read, moved and kept inside the locked mutation) with the FILE's own deploy-key count and refuses when the re-read cannot account for the file: refusing to write <path> — it holds N deploy entry(ies) but only M load; this binary would erase the N-M a degraded load dropped … That comparison — not "dc is smaller than the file" — is what keeps deliberate removals working: a removal's caller read the same file, so the re-read and the file agree and only dc shrank. countDeployKeys uses reservedDeployKeys, the same basis removeDeployKeys uses, so the guard and the writer cannot disagree about what a deploy key is. Red proof against main's deploy_file.go with the new test unchanged: FAIL: TestSaveDeployConfigRefusesADegradedLoad — "persisted a degraded load — the file's entries were erased"; green here. Gate on this tree: go build/vet, go test ./... (21 packages ok), gofmt clean, golangci-lint 0 issues on deploykit/. Agent: `ollama-vision-models` · Claude Code session `c765900b-523f-458a-b38f-a0f925f2a9b9` Assisted-by: Claude Code ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (guard + Checklist: All applicable rules PASS or NA.
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
This was referenced Nov 24, 2026
github-actions Bot
pushed a commit
to opencharly/charly
that referenced
this pull request
Nov 24, 2026
…aded config load (#1274) * chore(deps): bump sdk to v0.2026328.1554 so the binary refuses a degraded config load opencharly/sdk#633 (tagged v0.2026328.1554) makes deploykit.SaveDeployConfig refuse to persist a DEGRADED per-host config load: it compares the typed re-read with the file's own deploy-key count and aborts instead of writing the short set. That is the data-safety half of #1269 (the per-host config lost both deploy entries mid-run on 2026-11-24). charly/go.mod and the three tools/* modules that mirror the contract pins (charly task mods-tidy) move to v0.2026328.1554. No charly source change; the guard lives in the SDK. Gate: the repo's full `go` CI job reproduced verbatim (root go test ./charly/..., the tools/* GOWORK=off sweep, gofmt, per-module golangci-lint) plus the R9 worktree build. Agent: `ollama-vision-models` · Claude Code session `c765900b-523f-458a-b38f-a0f925f2a9b9` Assisted-by: Claude Code ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * chore(pr): correct the evidence and the attribution tier — no code change Round-1 review fixes for #1274. - R1/CONC(b): the body referred to a NOTICE "in the build below" that the pasted block did not contain. The NOTICE line is now pasted verbatim, and the finding is filed as REAL issues under `## Filed issues` — #1268 (the drift, fix in PR #1272) and #1273 (the restore-vs-fail policy) — instead of pointing at a PR number. - R10/A1: the untruncated output is pasted for the changed pieces — the two `go test` package lines with real durations, the five `tools/*` module lines from the `GOWORK=off` sweep, `gofmt -l charly tools` empty, and all six `0 issues.` lines from the per-module golangci-lint. - A3/R7: the delivered behaviour (the degraded-load guard) was never executed against this tree's binary — staging a config the loader cannot unify is not something this tree can do without inventing one — so the tier is `analysed on a live system` in the body and in this trailer. Agent: `ollama-vision-models` · Claude Code session `c765900b-523f-458a-b38f-a0f925f2a9b9` Assisted-by: Claude Code ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the fixable half of opencharly/charly#1269.
SaveDeployConfignow REFUSES to persist adegraded load.
The per-host config's loader can fail OPEN: a deploy entry it cannot unify comes back as an empty or
short
DeployConfigwith no error. A writer that then saves its owndcerases every entry theloader dropped. Measured on a host, 2026-11-24:
~/.config/charly/charly.ymllost BOTH of itsdeploy entries (and
system:) in one run while the containers kept running — the overlay, which isthe source of truth for
charly config/status, no longer knew about them.The guard lives inside the same locked mutation as the existing fail-safe re-read, and compares the
typed re-read with the file's own deploy-key count:
Why that comparison and not "dc is smaller than the file": a deliberate removal is exactly a
smaller
dc— the caller read the same file, so the re-read and the file agree, and onlydcshrank. A degraded load is the case where the re-read CANNOT account for the file.
countDeployKeysuses
reservedDeployKeys, the same basisremoveDeployKeysuses, so the guard and the writer cannever disagree about what a deploy key is.
Behaviour change, deliberate and named: a writer running against a config this binary cannot fully
load now fails with an actionable message instead of silently rewriting it.
How tested
The red proof — the new test against
main'sdeploy_file.go, unchanged test file:and green here. Test accounting, stated exactly:
deploykit/deploy_degraded_load_test.go):TestSaveDeployConfigRefusesADegradedLoad— a loader that returns an empty config for a filewith two entries; the save is refused, the message names the degraded load, and the bytes are
byte-identical afterwards.
TestSaveDeployConfigAllowsADeliberateRemoval— a healthy loader that sees both entries; adcwith one remaining entry writes, the removed key is gone, and
system:survives.TestSaveDeployConfigWritesOnAFreshHost— no file, no entries, no false refusal.deploykitsuite includingTestSaveDeployConfig_RoundTrip, thefail-safe tests, and the cross-writer concurrency test.
Rulebook compliance
/charly-internals:go,/charly-internals:git-workflow,/charly-internals:strict-policy.damaged file, the timeline, and the candidate writers; this PR removes the ability to PERSIST a
degraded load, which is the part that is certainly fixable in this library. Which caller produced
the degraded read in the 16:11 window is still being established on the issue.
reservedDeployKeys), reused rather than re-stated.origin/main.the suite.
own pin PR.
existing writer.
Change classification
change.
of erasing the entries it could not read. Every legitimate path (add, delete, remove, reset, fresh
host) is covered by a test and unchanged.
Agent:
ollama-vision-models· Claude Code sessionc765900b-523f-458a-b38f-a0f925f2a9b9Assisted-by: Claude Code ollama-cloud/deepseek-v4.1-flash (fully tested and validated)