Skip to content

config drops resolved_image on a fresh add_candy pod: the first charly config after deploy add runs the base image #84

Done

Description

@aitrawog

Finding (R1)

The first charly config <pod> after charly deploy add <pod> on an add_candy pod drops the overlay ref that deploy add just persisted. It then renders a quadlet that runs the base image. The add_candy candies never run, and nothing fails.

Reproduction (deterministic, on merged main: charly 2026.325.1102)

A throwaway project (a copy of distro-arch) with one disposable pod:

overlay-plain:
    pod:
        image: arch
        disposable: true
        add_candy: [arch-pac-test]

Reading ~/.config/charly/charly.yml's overlay-plain.pod after each step:

$ charly deploy add overlay-plain    # exit 0, "Overlay image ready: overlay-plain-overlay:30a99f0cef8c"
main-after-add:    resolved_image= overlay-plain-overlay:30a99f0cef8c keys= ['resolved_image']
$ charly config overlay-plain        # exit 0
main-after-config: resolved_image= None keys= ['image', 'network', 'security']
$ grep Image= ~/.config/containers/systemd/charly-overlay-plain.container
Image=ghcr.io/opencharly/arch:check-openclaw-pod-2026.325.1414

The deploy-name alias and the overlay image exist, but the quadlet runs the base. In this case that's an unrelated bed's alias tag of arch, because the short name arch re-resolves by sort.

The second config keeps the ref. When the entry already carries image/network/security (from a prior config), a fresh deploy add then config keeps resolved_image, and the quadlet runs the overlay (measured on the same pod). So the drop happens exactly when the entry holds only resolved_image, which is the state deploy add creates for a new pod.

Not yet root-caused

The write that drops it is in the config save path (config_setup.go → deploykit.SaveDeployConfig / deploy_save_state.go). The likely mechanism, not yet proven: an entry with no image is treated as new and rebuilt whole, so resolved_image is lost. Found while proving the pod-overlay builder fix of opencharly/sdk#608 (unrelated to it, and present on main). Filed per R1, not fixed in that cutover.

Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
Assisted-by: Claude Code Claude Opus 5.5 (analysed on a live system)

Activity

  1. atrawog commented on Nov 22, 2026

    @atrawog
    Contributor

    CLAIM

    Investigating the loss of resolved_image during the first configuration of a fresh overlay deployment. I will trace the state writer and identify the owning repository before implementing a fix. Next status within 60 minutes.

    Agent: pod-overlay-state · Codex session 01a20222-d383-71a1-bfd7-7ba65d9d7f2a
    Assisted-by: Codex OpenAI GPT-6 (analysed on a live system)

  2. self-assigned this
    on Nov 22, 2026
  3. atrawog commented on Nov 22, 2026

    @atrawog
    Contributor

    STATUS

    Source trace: the ordinary overlay state patch contains only resolved_image. The unified loader classifies that pod body as a standalone template because it lacks image or from, so it does not enter the deploy map; the first config cannot see the overlay and the later save omits it. The likely root fix is to seed the base image and pod target whenever the plugin writes an overlay state patch. I am preparing the isolated plugin worktree and will verify the loader round trip and live first-config path. Next update within 60 minutes.

    Agent: pod-overlay-state · Codex session 01a20222-d383-71a1-bfd7-7ba65d9d7f2a
    Assisted-by: Codex OpenAI GPT-6 (analysed on a live system)

  4. added
    category:delivery
    type:fix
    on Nov 23, 2026
  5. aitrawog commented on Nov 26, 2026

    @aitrawog
    ContributorAuthor

    CLAIM

    CLAIM — taking this fix, with the mechanism now localised.

    I hit exactly this on a live host and traced it end to end; the two halves #84 covers are:

    1. The state patch omits box/target, so the entry is written with no image:.
    prepareVenueState (lifecycle.go:482-509) sets in.Box + in.Target only inside
    if in.Engine != ""
    (line 494). An add_candy: overlay build with no authored engine:
    therefore emits {"resolved_image": "…"} alone, and that is what the earlier discriminator fix
    classified as pod: — a pod body the validator requires to carry image:.

    2. The resulting entry makes the whole per-host config unwritable.
    applyDeployState (sdk/deploykit/deploy_state.go:502-514) sets entry.Image only when
    input.Box != "" but writes ResolvedImage unconditionally; the node-form marshaller drops the
    empty image: (omitempty). ValidateDeployRequiresBox (spec/spec/deploy_tree_validate.go:87)
    then drops the entry at load, and SaveDeployConfig (sdk/deploykit/deploy_file.go:233) refuses
    every later write to that file:

    charly: error: … refusing to write /home/<user>/.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
    (fix the config first, e.g. `charly migrate`, or remove it to regenerate)
    

    Neither remedy the message names can be executed for that entry: charly deploy reset <name> is a
    no-op on an entry the loader dropped (it mutates only the loaded map), and a bare charly deploy reset deletes the WHOLE file, taking the good entries with it.

    Planned fix (this session): prepareVenueState sets Box/Target whenever it writes
    ResolvedImage (baseName is already in scope at lifecycle.go:450), so the patch always carries
    the image the entry needs; plus the round-trip test the tree lacks —
    TestPrepareVenueState_DecodesIntoTheHostsWireType currently calls the helper with box ""/node
    nil and asserts only ResolvedImage, i.e. it locks the broken shape in.

    Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

    Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

  6. self-assigned this
    on Nov 26, 2026
  7. aitrawog commented on Nov 26, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED

    RESOLVED — fixed by #98, merged as 0e1a429a and tagged v2026.330.1320. prepareVenueState now sets box/target on every emitted state patch, so an add_candy: overlay build with no engine selector can no longer write an entry with no image: — the entry that made a host's per-host config unwritable. The regression test fails without the change; the disposable bed check-pod-overlay passed with this branch served via LOCAL OVERRIDE.

    Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

category:deliverytype:fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions