Skip to content

fix(config): write the deploy entry image before any other per-deploy overlay write - #95

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/config-new-deploy-entry
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/config-new-deploy-entry

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

charly config could 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 with resolved_port: alone (no image:), and the project-declared-volume write that followed re-read the file through deploykit.SaveDeployConfig's degraded-load guard, which refuses to write a file holding an entry the loader cannot read:

charly: error: command "config": deploy:pod config: … persisting project-declared volumes:
refusing to write /home/atrawog/.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

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):

$ charly -C /tmp/nr-genproof config nrgenproof
charly: error: … persisting project-declared volumes: refusing to write
/home/atrawog/.config/charly/charly.yml — it holds 2 deploy entr(y|ies) but only 1 load

After, with the patched plugin served from a baked binary (CHARLY_PLUGIN_DIR, log line confirmed):

$ charly -C /tmp/nr-genproof2 config nrgenproof2
Resolved ports for nrgenproof2: 33043:2283, 46451:3003, 35427:5432, 37355:6379
Env provides injected: IMMICH_API_URL=http://charly-nrgenproof2:2283/api
Provisioning container secrets:
  charly-nrgenproof2-db-password           → created (from auto-generated)
Wrote /home/atrawog/.config/containers/systemd/charly-nrgenproof2.container
Reloaded systemd user daemon
(exit 0)

The persisted entry is loadable and complete:

nrgenproof2:
    pod:
        image: ghcr.io/opencharly/immich-cdi:2026.328.1448
        resolved_port: [33043:2283, 46451:3003, 35427:5432, 37355:6379]
        volume: [{name: external, type: bind, host: /tmp/nr-genproof2/ext, …}]
        volume_project_checked: true

A second config run on the same deploy exits 0 and rewrites nothing but the unit; charly remove nrgenproof2 then cleaned the unit and the entry, and no nrgenproof key remains in ~/.config/charly/charly.yml.

Unit arms. TestEnsureDeployEntryImage_FirstConfigStaysWritable starts from an absent overlay, asserts the entry carries the resolved image, then runs resolveDeployPorts and asserts the image survives and a pin is resolved. TestEnsureDeployEntryImage_HealsPartialAndLeavesComplete covers the heal (resolved_port: only → image added) and the no-op (complete entry → no write).

Gates on the committed tree (a737e8a9d853f5113498c43d9ab2265f5b31c4c4, clean worktree):

$ gofmt -l .                    # no output
$ go vet ./...                  # clean
$ go test ./... -count=1
ok  	github.com/opencharly/plugin-deploy-pod/candy/plugin-deploy-pod	0.187s
$ GOTOOLCHAIN=go1.26.8 golangci-lint run ./...
0 issues.

Runtime (A3) — the authoring runtime's identification:

$ env | grep -E '^(ANTHROPIC_BASE_URL|ANTHROPIC_DEFAULT_[A-Z]+_MODEL|CLAUDE_CODE_SESSION_ID)='
ANTHROPIC_BASE_URL=http://127.0.0.1:11434
ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4.1-flash:cloud
ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4.1-flash:cloud
ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4.1-flash:cloud
CLAUDE_CODE_SESSION_ID=113f762e-5d70-484a-9ed9-e34c6423c926

Rulebook compliance

  • R0 — /charly-core:charly-config, /charly-internals:go, /charly-internals:install-plan, this repo's AGENTS.md.
  • R1 — the defect was found live, reproduced three times, and fixed at the writer sequence rather than by relaxing the guard.
  • R2 — one helper (ensureDeployEntryImage) in front of all three entry-creating writers; no per-writer duplication.
  • R3 — no workaround: the guard stays strict, and the write order is what changes.
  • R4 — no documented command changed; a documented command now completes.
  • R5 — nothing legacy added.
  • R6 — branch off fresh origin/main; no force-push, no push to main.
  • R7 — the arm fails without the change (the helper does not exist pre-fix), and the real command was executed before and after with outputs pasted.
  • R8 — no mocked service: the run used the real engine, the real image store and the real per-host config.
  • R9 — the plugin is a baked binary; the local build was exercised through CHARLY_PLUGIN_DIR (no released artifact claimed).
  • R10 — the module gate above passed on the exact committed tree.
  • R11 — no DESIGN requirement touched: an existing writer sequence, no new field or shape. The deploy entry gains nothing it did not already declare.

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 session 113f762e-5d70-484a-9ed9-e34c6423c926
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

…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)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: a737e8a9d853f5113498c43d9ab2265f5b31c4c4 (branch: fix/config-new-deploy-entry)

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.
Change class: code (Go plugin) — behavioral fix in the per-host config writer sequence.
Checklist: All applicable rules PASS or NA (R0–R11 answered in-body; R10 coverage = unit arms that fail without the helper + real before/after runtime run with pasted output; placement: CORRECT — helper stays in the candy/plugin-deploy-pod plugin, not core/sdk). Comment thread empty; nothing to disposition.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 24, 2026 20:58
@github-actions
github-actions Bot merged commit 6dd8a20 into main Nov 24, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 24, 2026
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.

charly config cannot configure a NEW deploy: resolved_port is persisted before image:, and its own volume write then refuses the partial entry

1 participant