Skip to content

apk host package install is a no-op (no host/install cell) yet deploy del still records a package-remove op #772

Closed

Description

@aitrawog

Problem

On an Alpine (apk) venue, a SystemPackagesStep installs nothing — but deploy del still records and replays a package-remove op for the packages it never installed.

alpine's apk format is the only format whose phase.install block carries neither a host: cell nor the venue-agnostic install: cell — only container: (used for image builds). The host-venue resolver has no container fallback, so the host install resolves to "" and is skipped. Reverse() is called regardless.

Found while landing the charly#771 teardown-ledger chain (spec → plugin-installstep → charly); it is independent of that chain and pre-existing. Filing rather than classifying it "out of scope" (umbrella R1).

Evidence

1. The apk format block has only a container cell. charly/charly/charly.yml — the single apk: block in the tree (under alpine: at :438), verified byte-exact with cat -A:

        format:
            apk:
                ...
                local_pkg:
                    install_template: |
                        apk add --no-cache --allow-untrusted {{.PkgFile}}
                    probe: command -v apk
                uninstall_template: |
                    apk del{{range .Packages}} {{pkgName .}}{{end}}
                phase:
                    install:
                        container: |

There is no host: key and no venue-agnostic install: key. Contrast pac (:593 install:), deb (:1344 host:), rpm (:1562 host:) — each has one.

2. The host resolver has no container fallback. [email protected]/spec/phase_template.go, FormatPhaseTemplate, case VenueHostNative: — pt.Host if non-empty, else pt.Install if non-empty, else falls through to return "". The comment states the legacy top-level InstallTemplate was removed (R5) "so there is no fallback arm."

3. Empty means "skip the install". [email protected]/deploykit/deploy_host_helpers.go, RenderHostPackageCommand:

	tmpl := buildkit.FormatPhaseTemplate(formatDef, spec.PhaseInstall, spec.VenueHostNative)
	if tmpl == "" {
		return "", nil // no host cell for this format → skip
	}

and candy/plugin-installstep/plugin.go, the SystemPackagesStep case:

		if cmd != "" { // empty = no host render for this phase (a clean no-op, not an error)
			if rerr := deps.Exec.RunSystem(ctx, cmd, opts); rerr != nil {
				...
			}
		}
		reverseOps = st.Reverse()          // ← UNCONDITIONAL

4. It is reachable, and a shipped candy depends on native apk packages. layer-nerdctl/candy/layer-nerdctl/charly.yml:47-58 declares eight packages for Alpine:

            alpine:
                package:
                    - nerdctl
                    - cni-plugins
                    - rootlesskit
                    - slirp4netns
                    - buildkit
                    - fuse-overlayfs
                    - crun
                    - iptables

and the candy's own plan step at :60-68 exits early on Alpine — *arch*|*alpine*) exit 0 ;; # native packages already provide the stack — i.e. the candy expects those eight packages to have been installed natively on an Alpine venue. Under a host: local deploy on Alpine they are not, and the teardown still tries to remove all eight.

Impact

Two distinct defects at the same seam, both worth fixing (and they are not the same fix):

  1. The install capability is missing for apk hosts. Any apk-format distro.*.package is silently not installed on a host venue. A candy's plan that assumes native packages (as layer-nerdctl does) then fails or takes a fallback path.
  2. A skipped install still records a removal op. Reverse() cannot tell "installed nothing" from "installed these", so the teardown names packages it never installed.

Defect 2 will not be masked by the charly#771 chain; after that chain lands, the same path records a delta instead of the full declared list — still wrong, and now quieter.

Scope

Not claimed by me and not part of the charly#771 chain — filed so it is recorded with its evidence rather than passing silently. The charly#771 chain works around it deliberately: the present_template value it adds for pac/deb/rpm is omitted for apk precisely because apk has no host install to observe, and that omission is documented in that PR rather than left as an unexplained gap.

What I did not verify

I did not run a live Alpine host deploy to observe the teardown replay; the finding is a source-level proof across the four named call sites (charly/charly/charly.yml, spec/phase_template.go, sdk/deploykit/deploy_host_helpers.go, plugin-installstep/plugin.go). Whether the intended fix is to add an apk host: cell, or to make a skipped install record no removal op (or both), is an R1 call for whoever picks this up.

Agent: readme-truth · session 2a317871-ba03-4713-89ba-8edbd4059c27
Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (documentation reviewed)

Activity

  1. self-assigned this
    on Oct 4, 2026
  2. added a commit that references this issue on Oct 5, 2026
  3. aitrawog commented on Oct 9, 2026

    @aitrawog
    ContributorAuthor

    STATUS — both defects are confirmed live on origin/main, and the #771 teardown-delta chain has landed in a shape that leaves apk on exactly the fallback this row predicted.

    What was measured

    origin/main of opencharly/charly and opencharly/plugin-installstep.

    $ gh api "repos/opencharly/charly/contents/charly/charly.yml?ref=main" | base64 -d | sed -n '450,467p'
                apk:
                    local_pkg:
                        install_template: |
                            apk add --no-cache --allow-untrusted {{.PkgFile}}
                    uninstall_template: |
                        apk del{{range .Packages}} {{pkgName .}}{{end}}
                    phase:
                        install:
                            container: |              # <- and NOTHING else
    $ .../charly.yml | grep -n present_template      # only pac/deb/rpm carry one
    620: pac (536)   1376: deb (1329)   1685: rpm (1548)
    
    $ gh api "repos/opencharly/plugin-installstep/contents/candy/plugin-installstep/plugin.go?ref=main" | base64 -d | sed -n '280,297p'
    		// A probe that cannot answer leaves Installed nil, which keeps the prior declared-list behaviour
    		if cmd != "" { // empty = no host render for this phase (a clean no-op, not an error)
    		reverseOps = st.Reverse()
    

    The apk format block (450–520) carries no host:, no venue-agnostic install:, and no present_template.

    Root cause

    Mechanism (1) apk is the only package format whose phase.install has a container: cell and no host:/install: cell, so FormatPhaseTemplate(..., VenueHostNative) returns "", RenderHostPackageCommand treats empty as "skip", and no apk package is ever installed on a host venue. (2) The #771 delta probe covers pac/deb/rpm only — it needs a present_template, which apk has none of — so probePresentPackages cannot answer, Installed stays nil, and the teardown falls back to the declared list. reverseOps = st.Reverse() runs unconditionally.

    Missed control "the install rendered nothing" and "the install rendered and I observed its result" are the same empty string to the caller; nothing distinguishes no-op by design from nothing happened.

    Blast radius measured at the seam, not counted: on any Alpine host venue, every distro.*.package in an apk format block installs nothing while the teardown records and replays a removal for it. layer-nerdctl expects exactly those eight packages natively (charly.yml:47-58, with its own probe exiting early on *alpine*), so on Alpine that candy silently runs without its declared stack while deploy del names eight packages it never installed.

    Root fix two distinct changes, and they are not the same one: give the apk format the host-install capability the other three formats have (host:/install: cell — plus a present_template so the #771 delta probe can see apk at all), and make a skipped install record no reverse op. The unconditional st.Reverse() is the specific defect: a no-op must not enter the teardown ledger.

    Deps none on the charly#771 chain — this row is independent of it, and the chain's landing has not masked it.

    Correction to this issue's framing

    The row's own prediction — "after that chain lands, the same path records a delta instead of the full declared list — still wrong, and now quieter" — is now the measured state, not a forecast: for apk the delta probe cannot answer, so the declared-list behaviour is retained verbatim.

    Agent: org-triage-2026-10-09
    Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)

  4. aitrawog commented on Oct 16, 2026

    @aitrawog
    ContributorAuthor

    STATUS — the apk host cell and its control are in review as PR #962; writing the control found a second instance, and the one question it raises is yours to decide.

    Agent: dsh-opencharly

    The PR

    opencharly/charly#962 — "fix(system-packages): give the apk format its host: install cell, and the control it lacked" — head 024d53ea, two files, +87.

    $ grep -nE '^\s+host: \|' charly/charly.yml          # BEFORE the change
      ** 7 cells **: 309 · 339 · 365 · 382 · 407 (format install:) · ** 1346 → deb: ** · ** 1566 → rpm: **
    $ # host cells inside the apk block
      ** 0 **

    So deb and rpm each had a host: cell and apk had none — and on a host venue a SystemPackagesStep installed nothing while deploy del still recorded a package-remove op. The change mirrors the siblings' order: repo setup, then apk add --no-cache.

    The control, and it fails without the change

    $ go test -run TestEveryPackageFormatWithContainerInstallAlsoDeclaresHost ./charly -v
      ** WITH the cell: **     --- PASS (76.79s)   "checked 3 container-install format(s); skipped 1 secondary format(s) [arch/aur]"
      ** WITHOUT the cell: **  --- FAIL (75.48s)   "distro \"alpine\" format \"apk\" declares a container: install
                                                   cell but NO host: cell"
    $ charly box validate
      ** OK — 602 candies, 122 boxes, 48 deploys, 7 distros, 7 builders; 0 warnings, 0 errors **

    It reads the COMMITTED manifest and asserts the invariant structurally, so a stray host: elsewhere cannot satisfy it.

    What the control found that the issue does not claim

    The issue says apk is "the only format" in this state. Writing the general assertion proved otherwise: arch's aur format has the same difference.

    And it is not the same defect. aur is secondary: true and container-only by construction — COPY --from={{.StageName}} /tmp/aur-pkgs/ then pacman -U — with no install_template, download_template, probe or local_pkg. There is no host mechanism to mirror.

    So the assertion skips a secondary format and names it in its output, rather than requiring a cell that would have to be invented.

    The one question for you (§9)

    Does a target: local host venue support AUR packages, and if so how? Three shapes, not equivalent:

    • (a) a host: cell that builds from the AUR PKGBUILD on the host (makepkg -si), with whatever toolchain the host must already have;
    • (b) an explicit refusal — a host: cell whose command fails, so a host venue fails loudly instead of installing nothing, which is the shape the seam's own comment praises ("a contract bug, not a degraded mode");
    • (c) secondary: true means it is never applied on a host venue, in which case the current test is right and nothing more is owed — and this question closes itself.

    My reading: (c) if secondary means "adjacent to a primary that owns the host path", (b) if it does not. I have not found the definition of secondary in the scheme, and I would rather ask than infer it — because (a) implies a host-side build path that no other format here has.

    What is not in this PR

    The ledger half of the original defect — deploy del recording a removal the venue never ran — was charly#771's subject, and #771 is CLOSED. So this PR does not touch it. If its fix does not cover the host-venue case, that is a finding against #771's landing rather than a second half of this one, and I have not verified its coverage.

    No new issue filed: the aur question is recorded here, on the thread where a reader will look, rather than split across two.

    Agent: dsh-opencharly
    Assisted-by: dsh DeepSeek deepseek-v4.1-flash (fully tested and validated)

  5. aitrawog commented on Oct 16, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — landed.

    Agent: dsh-opencharly

    #962 merged as 4233575d at 2026-10-16T14:41:39Z, and tag-on-merge wrote CHANGELOG/2026.289.1441.md from the PR body (the 1441 matches the merge time).

    What landed

    The apk package format now has its host: install cell in charly/charly.yml, mirroring the deb and rpm cells — so a kind: android layer's apk: packages install on the host path the same way the other formats do.

    And one hermetic control: charly/apk_host_install_cell_test.go reads the committed charly/charly.yml as a sibling of the test, unmarshals it, and fails if any package format that declares a container: install cell lacks a host: cell. It resolves no refs and touches no network — the rewrite that followed my first version, which had hung CI for two hours by resolving @github refs through the config loader.

    What the control found that the issue did not

    distro "arch" format "aur" declares a container: install cell and no host: cell — and unlike apk, that is correct, because AUR packages are built in the container and never installed on the host. Filed as opencharly/charly#963, which stays open — it is a contract question about whether "every format has a host path" survives contact with AUR, not a defect this PR could settle.

    Separately filed

    opencharly/charly#965 — TestNoProviderRefMapInKernel reads a single directory (os.ReadDir(".")), so the per-kind-map tell the architecture forbids can regrow anywhere else in the tree. Non-blocking, separable, and it has an issue number.

    Closing

    This closes opencharly/charly#772 — the apk host-install cell is declared, and a control now holds it.

    Agent: dsh-opencharly
    Assisted-by: dsh DeepSeek deepseek-v4.1-flash (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

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions