Repository navigation
fix(config): write the deploy entry image before any other per-deploy overlay write - #95
Merged
Merged
Conversation
…oy overlay write
`charly config` could not configure a deploy that was not already in the
per-host config. Two writes in one run: the port resolver created the entry
with `resolved_port:` alone (no `image:`), and the project-declared-volume
write that followed re-read the file through deploykit's degraded-load
guard, which refuses to write a file holding an entry the loader cannot read:
charly: error: persisting project-declared volumes: refusing to write
~/.config/charly/charly.yml — it holds 2 deploy entr(y|ies) but only 1
load; this binary would erase the 1 a degraded load dropped
Every retry recreated the same partial entry, so the deploy was permanently
unconfigurable (#93).
`image:` is what makes a pod deploy loadable, so it now goes FIRST, in its own
locked mutation, before ports / resource caps / project-declared volumes. It is
a no-op when the entry already carries its image, and it heals an entry an
older run left partial.
Measured, same project and deploy shape, fresh name:
$ charly -C /tmp/nr-genproof2 config nrgenproof2 # before
charly: error: ... refusing to write ... 2 deploy entr(y|ies) but only 1 load
$ charly -C /tmp/nr-genproof2 config nrgenproof2 # after
Resolved ports for nrgenproof2: 33043:2283, 46451:3003, 35427:5432, 37355:6379
Wrote .../charly-nrgenproof2.container
(exit 0)
The persisted entry is loadable and complete:
nrgenproof2:
pod:
image: ghcr.io/opencharly/immich-cdi:2026.328.1448
resolved_port: [...]
volume: [{name: external, type: bind, ...}]
volume_project_checked: true
The arm `TestEnsureDeployEntryImage_FirstConfigStaysWritable` asserts the entry
created for a deploy absent from the overlay carries its image and keeps it
through port resolution; a second arm covers the heal and the no-op.
Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926`
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no embedded directives, no secrets/egress, no guardrail weakening (the strict degraded-load guard is preserved; only write order changes), no supply-chain edits. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
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
charly configcould not configure a deploy that was not already in the per-host config — a first deploy, a renamed deploy, a fresh host. It ran two writes in one pass: the port resolver created the overlay entry withresolved_port:alone (noimage:), and the project-declared-volume write that followed re-read the file throughdeploykit.SaveDeployConfig's degraded-load guard, which refuses to write a file holding an entry the loader cannot read:image:is mandatory on a pod deploy, so the entry the port step wrote could never load; every retry recreated it, and the deploy was permanently unconfigurable (#93).image:now goes first, in its own locked mutation (ensureDeployEntryImage), before ports, resource caps and project-declared volumes — every writer that can create the entry from nothing on a first-time config. It is a no-op when the entry already carries its image (the mutation reports no change, so nothing is written), and it heals an entry an older run left partial.How tested
The real command, before and after, on the same project and deploy shape with a fresh name. Before (recorded in #93, reproduced three times):
After, with the patched plugin served from a baked binary (
CHARLY_PLUGIN_DIR, log line confirmed):The persisted entry is loadable and complete:
A second
configrun on the same deploy exits 0 and rewrites nothing but the unit;charly remove nrgenproof2then cleaned the unit and the entry, and nonrgenproofkey remains in~/.config/charly/charly.yml.Unit arms.
TestEnsureDeployEntryImage_FirstConfigStaysWritablestarts from an absent overlay, asserts the entry carries the resolved image, then runsresolveDeployPortsand asserts the image survives and a pin is resolved.TestEnsureDeployEntryImage_HealsPartialAndLeavesCompletecovers the heal (resolved_port:only → image added) and the no-op (complete entry → no write).Gates on the committed tree (
a737e8a9d853f5113498c43d9ab2265f5b31c4c4, clean worktree):Runtime (A3) — the authoring runtime's identification:
Rulebook compliance
/charly-core:charly-config,/charly-internals:go,/charly-internals:install-plan, this repo'sAGENTS.md.ensureDeployEntryImage) in front of all three entry-creating writers; no per-writer duplication.origin/main; no force-push, no push tomain.CHARLY_PLUGIN_DIR(no released artifact claimed).Change classification
Behavioral fix in the config writer sequence; no wire, schema or CLI surface change. Rollback: revert — the first-time config fails again.
Closes #93.
Agent:
immich-consolidation· Claude Code session113f762e-5d70-484a-9ed9-e34c6423c926Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)