deploykit

package
v0.2026191.1056 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 15 Imported by: 19 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package deploykit holds the InstallPlan step VOCABULARY — the 13 concrete InstallStep implementations + their field-structs + the pure classification helpers — that any deploy front-end (charly's host engine, an out-of-tree deploy plugin) imports. Each concrete step implements spec.InstallStep (homed in sdk/spec with the IR enums + the InstallPlan container). deploykit imports spec; the aliases below let the moved code read unchanged.

Index

Constants

View Source
const (
	VenueLocal = kit.VenueLocal

	JumpPodmanExec   = kit.JumpPodmanExec
	JumpDockerExec   = kit.JumpDockerExec
	JumpPodmanRun    = kit.JumpPodmanRun
	JumpDockerRun    = kit.JumpDockerRun
	JumpSSH          = kit.JumpSSH
	JumpVirshConsole = kit.JumpVirshConsole
)
View Source
const (
	PreemptStopShutdown  = spec.PreemptStopShutdown
	PreemptRestoreAlways = spec.PreemptRestoreAlways
)
View Source
const (
	ScopeSystem      = spec.ScopeSystem
	ScopeUser        = spec.ScopeUser
	ScopeUserProfile = spec.ScopeUserProfile

	PhasePrepare = spec.PhasePrepare
	PhaseInstall = spec.PhaseInstall
	PhaseCleanup = spec.PhaseCleanup

	VenueHostNative       = spec.VenueHostNative
	VenueContainerBuilder = spec.VenueContainerBuilder
	VenueSkip             = spec.VenueSkip

	GateNone             = spec.GateNone
	GateAllowRepoChanges = spec.GateAllowRepoChanges
	GateAllowRootTasks   = spec.GateAllowRootTasks
	GateWithServices     = spec.GateWithServices

	StepKindSystemPackages  = spec.StepKindSystemPackages
	StepKindBuilder         = spec.StepKindBuilder
	StepKindOp              = spec.StepKindOp
	StepKindFile            = spec.StepKindFile
	StepKindServicePackaged = spec.StepKindServicePackaged
	StepKindServiceCustom   = spec.StepKindServiceCustom
	StepKindShellHook       = spec.StepKindShellHook
	StepKindShellSnippet    = spec.StepKindShellSnippet
	StepKindRepoChange      = spec.StepKindRepoChange
	StepKindApkInstall      = spec.StepKindApkInstall
	StepKindLocalPkgInstall = spec.StepKindLocalPkgInstall
	StepKindReboot          = spec.StepKindReboot
	StepKindExternalPlugin  = spec.StepKindExternalPlugin

	ReverseOpCoprDisable    = spec.ReverseOpCoprDisable
	ReverseOpPackageRemove  = spec.ReverseOpPackageRemove
	ReverseOpRemoveDropin   = spec.ReverseOpRemoveDropin
	ReverseOpRemoveEnvdFile = spec.ReverseOpRemoveEnvdFile
	ReverseOpRemoveManaged  = spec.ReverseOpRemoveManaged
	ReverseOpRemoveRepoFile = spec.ReverseOpRemoveRepoFile
	ReverseOpRestoreEnabled = spec.ReverseOpRestoreEnabled
	ReverseOpRmFileSystem   = spec.ReverseOpRmFileSystem
	ReverseOpRmFileUser     = spec.ReverseOpRmFileUser
	ReverseOpServiceDisable = spec.ReverseOpServiceDisable
	ReverseOpServiceRemove  = spec.ReverseOpServiceRemove
)
View Source
const ExternalStepKindPrefix = "external:"

ExternalStepKindPrefix marks a StepKind string as an external (plugin-contributed) kind.

View Source
const HomeToken = "{{.Home}}"

HomeToken is the deferred-home placeholder resolved by ResolveHome at emit time.

Variables

View Source
var (
	ExpandPath = kit.ExpandPath

	KwRun = kit.KwRun
)

AllStepKinds is the fixed InstallStep IR vocabulary — the 13 compiled-in concrete step kinds (external:<word> kinds are dynamic and not listed).

View Source
var CompileActOp func(op *Op, layer CandyModel, img *ResolvedBox) InstallStep

CompileActOp lowers a `run:` act op (install verb or `plugin:` verb) into an InstallStep. Provider-coupled (kernel provider registry), so charly owns it and injects it; the compiler calls the seam.

View Source
var CompileServiceSteps func(layer CandyModel, img *ResolvedBox, hostCtx HostContext) []InstallStep

CompileServiceSteps lowers a candy's service: list into install steps. Loader- and service-render-coupled (LoadBuildConfigForBox + RenderService live in charly), so charly owns it and injects it.

View Source
var OpInContext func(op *Op, ctx ExecContext) bool

OpInContext reports whether an op runs in the given exec context. Its fallback consults the kernel VerbCatalog (charly), so charly injects the impl at init.

View Source
var ShellAllowlist = map[string]bool{"bash": true, "zsh": true, "fish": true, "sh": true}

ShellAllowlist enumerates valid per-shell sub-block keys inside `shell:`.

View Source
var VmSshAlias = kit.VmSshAlias

Functions

func AppendOrReplaceEnv added in v0.2026190.848

func AppendOrReplaceEnv(envs []string, entry string) []string

AppendOrReplaceEnv adds or replaces an env var entry (KEY=VALUE) in a slice. If the key already exists, the value is replaced in-place.

func AppendShellPathLines added in v0.2026190.848

func AppendShellPathLines(body string, paths []string, shell, home string) string

AppendShellPathLines appends path_append entries to the snippet body using shell-appropriate syntax. bash/zsh/sh use POSIX `PATH=$PATH:X` exports; fish uses `fish_add_path X`. Idempotent: if body already ends with a newline, no extra blank line is inserted.

func ArgHasImageTag added in v0.2026190.848

func ArgHasImageTag(arg string) bool

ArgHasImageTag reports whether arg's trailing path segment carries a ":tag" — the marker of a registry IMAGE ref (ghcr.io/org/image:tag), as opposed to a github REPO ref (which pins with @version) or a dotted-path deploy address. Shared by CanonicalizeDeployArg + the deploy-name guard (R3).

func BareRef added in v0.2026190.848

func BareRef(ref string) string

BareRef returns the map-key form of a ref (no @ prefix, no :version).

func BedCheckLiveRefs added in v0.2026190.848

func BedCheckLiveRefs(name string, children map[string]*BundleNode) []string

SortedNestedKeys returns the keys of a children map in deterministic order so traversal produces stable output across runs. BedCheckLiveRefs returns the ordered `charly check live` targets for a bed: the substrate itself first, then each nested child as a sorted dotted path. This is the pure list `charly check run` walks so a nested pod's BAKED candy/box check (e.g. the selkies candy's encoder + frame checks on a nested selkies-kde pod) is exercised against its real venue through the chain — not just the parent substrate. Without the nested entries, `charly check run` deploys nested children but never evaluates them. Pure + unit-tested.

func BuilderCtxKey added in v0.2026190.848

func BuilderCtxKey(candy, builder string) string

BuilderCtxKey keys the per-(candy,builder) pre-resolved builder context.

func BundleWalkPostOrder added in v0.2026190.848

func BundleWalkPostOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error

WalkPostOrder invokes fn on every child (recursively, post-order) before invoking fn on this node. Post-order is the delete-order semantic: a child must be torn down while its parent environment is still alive, so the caller reverses leaves first.

func BundleWalkPreOrder added in v0.2026190.848

func BundleWalkPreOrder(n *BundleNode, path string, fn func(path string, node *BundleNode) error) error

WalkPreOrder invokes fn on this node, then recurses into every child in sorted key order. Pre-order is the add-order semantic: a parent's environment must exist before its children can run inside it, so the caller applies deploys root-first.

fn receives the full dotted path to each node (e.g. "stack.web.db"). The root path argument is prepended; callers pass the node's own key as `path`.

When fn returns a non-nil error, traversal stops immediately and the error propagates.

func CandyNeedsBuilderStep added in v0.2026190.848

func CandyNeedsBuilderStep(layer CandyModel, bDef *BuilderDef) bool

CandyNeedsBuilderStep mirrors Generator.candyNeedsBuilder without requiring a Generator receiver — the compiler doesn't have one.

func CanonicalizeDeployArg added in v0.2026190.848

func CanonicalizeDeployArg(arg, instance string) (box, inst string)

CanonicalizeDeployArg splits Pattern A "<base>/<instance>" CLI positional args into their component (image, instance) pair. Idempotent: if the input is already split (instance != "") or contains no slash, returns as-is. Pattern B (FQ ref containing "/") is identified by presence of "@" or ":" suffix on the leftmost segment OR a registry-host pattern (contains "." before the first "/") and passed through untouched.

MUST be called at the top of every CLI verb that takes a positional deploy-arg (`charly config`, `charly start`, `charly stop`, `charly shell`, `charly logs`, `charly update`, `charly status`, `charly remove`) — before any downstream code reads c.Image or c.Instance. Without this, Pattern A instance deploys leak past the canonicalization boundary and downstream code conflates the deploy key with the image short-name (see Bug 2/3 RCA notes — MergeDeployOntoMetadata composes wrong key, port/env overlays drop).

func CascadeTagChain added in v0.2026190.848

func CascadeTagChain(img *ResolvedBox) []string

ResolveCascadePackages is THE single distro-specificity cascade resolver, shared by EVERY package-emitting path — the deploy compiler (CompileSystemPackageSteps) AND the image-build Containerfile emitter (generate.go writeCandySteps). There is exactly one resolution so build and deploy can never diverge.

It computes the primary-format package set for a candy on an image: the candy's top-level `package:` BASE, UNION every matching distro tag section walked most-specific-first over img.Distro (deduped), with the Raw extras repo/copr/options/exclude/module resolved MOST-SPECIFIC-WINS. Returns the package list, the rendered Raw install context (including the unioned `package` list), and whether any tag section matched. CascadeTagChain returns the full per-candy cascade tag chain MOST-SPECIFIC FIRST: the image's distro chain (e.g. [debian:13, debian]) followed by the package-format FAMILY tag (img.Pkg = deb/pac/rpm) as the LEAST-specific level. A `distro: deb:` candy block therefore applies to EVERY deb-format distro (debian + ubuntu + their versions), `pac:` to arch + cachyos, `rpm:` to fedora — the family-generic level of the YAML-configured deb/pac/rpm → distro → version hierarchy. img.Pkg is the primary package format declared by the embedded vocabulary (charly/charly.yml), so the hierarchy lives entirely in YAML.

Distro INHERITANCE is the complementary YAML mechanism: img.Distro is already expanded (at resolve time, ExpandPackageInheritance) to include any `inherit_packages: true` ancestor, so a cachyos image/VM carries [cachyos, …, arch] and a `distro: arch:` block DOES reach cachyos — while ubuntu (no flag) stays isolated from debian. Both knobs live entirely in the embedded vocabulary (charly/charly.yml).

func ClassifyTarget added in v0.2026190.848

func ClassifyTarget(node *BundleNode) string

ClassifyTarget normalizes the Target field for dispatch. Empty Target falls back to "pod" (the default for named deploys); otherwise Target is the canonical source of truth (pod|vm|k8s|local|android — set from the node-form kind by bundleTargetForDisc; no name-prefix heuristic).

func ComputeDeployID added in v0.2026190.848

func ComputeDeployID(box string, layers, addCandies []string) string

ComputeDeployID returns a deterministic hex hash that identifies a specific deploy (image + ordered candy set + add_candy). Used as the ledger key so re-deploys of the same config are recognizable and candy-refcount bookkeeping is stable.

func DeployKey added in v0.2026190.848

func DeployKey(boxName, instance string) string

DeployKey returns the charly.yml map key for an image, optionally qualified by instance. Base images use just the image name; instances use "image/instance".

func DescribePlan added in v0.2026190.848

func DescribePlan(p *InstallPlan) string

DescribePlan returns a short human-readable summary of a plan. Used by --dry-run table output and by TestDescribePlan for golden comparison.

func DropMappingKey added in v0.2026190.848

func DropMappingKey(m *yaml.Node, key string)

marshalBundleNodeLegacy yaml-marshals a BundleNode into the LEGACY struct body shape — re-injecting the now-yaml:"-" structural fields (`target:`, `nested:`, `peer:`) that no longer marshal off the struct. This reproduces exactly the input migrateDeployEntity expects (the body it converts into node-form tree children), so the per-host overlay writer round-trips the deployment tree even though Target/Children/Members are no longer authored/marshaled fields (Risk 5a). Recurses so nested children + members at every depth are preserved. DropMappingKey removes a key (and its value) from a YAML mapping node in place.

func EnsureServiceSuffix added in v0.2026190.848

func EnsureServiceSuffix(unit string) string

EnsureServiceSuffix adds `.service` if missing. Distinguishes unit types: if the caller already included a suffix (e.g. "foo.timer", "foo.socket"), leave it alone.

func EnvKey added in v0.2026190.848

func EnvKey(entry string) string

EnvKey extracts the KEY part from a KEY=VALUE string.

func ExtractStringSlice added in v0.2026190.848

func ExtractStringSlice(m map[string]any, key string) []string

ExtractStringSlice returns m[key] as []string or nil if absent. Accepts []string and []interface{} (as produced by yaml.v3) inputs.

func GateEnabled added in v0.2026190.848

func GateEnabled(g Gate, opts EmitOpts) bool

GateEnabled returns whether the given gate is permitted under opts. GateNone is always enabled; named gates require the corresponding opt-in flag.

func IsAutoVmDeployEntry added in v0.2026190.848

func IsAutoVmDeployEntry(entry BundleNode) bool

IsAutoVmDeployEntry reports whether a VM deploy entry carries NOTHING beyond the fields saveVmDeployState auto-sets — target: vm, vm:, and vm_state. Such an entry is a pure runtime-state record (e.g. a disposable check-bed VM) that `charly vm destroy` should delete so it doesn't accumulate. Any OTHER non-zero field means operator-authored per-host config (preemptible, env, tunnel, port, security, …) that MUST survive a destroy→create cycle. Compares against the zero node after blanking the three auto-set fields, so a newly-added per-host field is covered automatically (no remembered append — same drift-proof discipline as MergeBundleNode).

func IsExternalStepKind added in v0.2026190.848

func IsExternalStepKind(k StepKind) bool

IsExternalStepKind reports whether k is an external (plugin-contributed) step kind.

func IsRemoteCandyRef added in v0.2026190.848

func IsRemoteCandyRef(ref string) bool

IsRemoteCandyRef reports whether a ref is an @-prefixed remote ref.

func MergeEnvVars added in v0.2026190.848

func MergeEnvVars(existing, newVars map[string]string) map[string]string

MergeEnvVars merges new env vars into existing ones (upsert by key). New vars override existing vars with the same key.

func ParseDeployKey added in v0.2026190.848

func ParseDeployKey(key string) (boxName, instance string)

ParseDeployKey splits a charly.yml map key back into image name and instance. "selkies-desktop" → ("selkies-desktop", "") "selkies-desktop/foo" → ("selkies-desktop", "foo")

func PathIsSystemScoped

func PathIsSystemScoped(p string) bool

PathIsSystemScoped returns true for paths under /etc, /usr, /var, /opt, /root, /boot and similar system locations. Used to classify FileStep scope when the compiler hasn't explicitly tagged it.

func PreemptEffectiveRestore added in v0.2026190.848

func PreemptEffectiveRestore(p *PreemptibleConfig) string

EffectiveRestore returns the configured restore policy with the default.

func PreemptEffectiveStop added in v0.2026190.848

func PreemptEffectiveStop(p *PreemptibleConfig) string

EffectiveStop returns the configured stop mechanism with the default.

func PrimaryDistroTag added in v0.2026190.848

func PrimaryDistroTag(img *ResolvedBox, hostCtx HostContext) string

PrimaryDistroTag picks the distro tag this plan is materialized against. img.Distro is the AUTHORITATIVE deploy-target distro chain and always wins: syntheticHostBox sets the operator host's tags, syntheticVmBox the GUEST's, and ResolveBox the image's — so a vm deploy resolves the guest distro, a host deploy the operator's, a pod/image deploy the image's. For a host deploy img.Distro[0] == hostCtx.Distro (both from DetectHostDistro; PrimaryTag() == Tags[0]), so this is byte-identical to the old host path while fixing vm deploys (whose hostCtx.Distro is the OPERATOR's distro, NOT the guest's — the detectHostContext default). hostCtx.Distro is only a fallback when img carries no distro. (Package resolution already uses img via CompileSystemPackageSteps, so making the plan's distro img-authoritative also removes a latent inconsistency, never introduces one.)

func RejectImageRefAsDeployName added in v0.2026190.848

func RejectImageRefAsDeployName(box string) error

RejectImageRefAsDeployName fails a deploy-CREATION command (config setup / start) whose positional is a tagged registry image ref used AS the deploy NAME. The ref's registry-host dots make an invalid charly.yml deploy key (dots are reserved for dotted-path addressing), so the deploy would save and the NEXT config load would hard-fail (the 2026-07 `charly config ghcr.io/…:tag` corruption). A registry image needs an explicit short deploy name. Gated on BOTH a dot (invalid key) AND an image `:tag` (so a github repo ref, which pins with @version, and a bare dotted-path address are untouched).

func ResolveCascadePackages added in v0.2026190.848

func ResolveCascadePackages(layer CandyModel, img *ResolvedBox) (pkgs []string, raw map[string]any, matched bool)

func ResolveDeployChain added in v0.2026190.848

func ResolveDeployChain(roots map[string]BundleNode, dotted string, root DeployExecutor) (*BundleNode, DeployExecutor, error)

ResolveDeployChain walks `dotted` through `roots` (typically the merged deployment tree from resolveTreeRoot) and returns the leaf BundleNode + a composed DeployExecutor chain that reaches it from `root`.

`root` is typically &ShellExecutor{} (the operator's host, or the harness-sandbox context the harness loop runs in). Pass nil to substitute ShellExecutor.

For each path segment, a single hop is added based on the node's target classification:

target: pod / container → NestedExecutor with JumpPodmanExec /
                          JumpDockerExec into "charly-<flat-path>".
                          Container name flattens dot-separated
                          paths to underscore-separated to remain
                          a legal podman container name.
target: vm              → plain SSHExecutor when the parent chain
                          is local (no wrapper overhead), otherwise
                          NestedExecutor with JumpSSH on top.
target: host            → no hop (host nodes share the parent
                          venue).
target: k8s             → error (k8s manifests are leaves; not
                          traversable as exec targets).

Returns clear errors with available-name hints when a segment fails to resolve.

func ResolveHome added in v0.2026190.848

func ResolveHome(p *spec.InstallPlan, home string)

ResolveHome substitutes the deferred HomeToken with a concrete home in every home-bearing step field, in place. Each DeployTarget calls this once at emit time with the home of its real destination: img.Home for the OCI/pod-overlay build, the host home for the external local deploy, the GUEST home (SSH executor ResolveHome) for the external vm deploy. Idempotent — fields without the token are left untouched, so a second call is a no-op.

Covered fields: ShellHookStep env values + PathAdd, ShellSnippetStep Snippet + Destination + PathAppend, FileStep.Dest. OpStep cmd/content bodies are intentionally NOT touched — `~`/`$HOME` there shell-expand at runtime on the destination as the deploy user, which is already correct on every venue. BuilderStep is also untouched — its home is resolved separately by renderBuilderScript against the builder/guest home (see execBuilder).

A free function (not a method on spec.InstallPlan) because it type-switches the concrete step vocabulary, which lives in deploykit.

func ResolveNodePath added in v0.2026190.848

func ResolveNodePath(roots map[string]BundleNode, path string) (*BundleNode, []*BundleNode, error)

ResolveNodePath walks roots[path0].Children[path1]...[pathN] and returns the targeted node plus its parent chain (root-first, excluding the target itself). Returns a descriptive error when any path segment is missing so the user sees which segment doesn't exist.

An empty path is invalid — callers dispatch to WalkPreOrder/WalkPostOrder against a named root instead of resolving "".

func ServiceEntryAppliesToDistro added in v0.2026190.848

func ServiceEntryAppliesToDistro(entry *ServiceEntry, distros []string) bool

ServiceEntryAppliesToDistro reports whether a service entry should render for the given distro tag chain. An entry with an EMPTY distro: list applies to EVERY distro (the backward-compatible default — every pre-existing candy's services keep rendering everywhere). A non-empty list restricts the entry to the named distros, matched against either a bare distro name ("debian") or a full versioned tag ("debian:13") anywhere in the chain. This is the service analogue of a check step's exclude_distros: — the mechanism that lets ONE candy carry per-distro-divergent packaged units (modular virtqemud.socket on Fedora/Arch vs monolithic libvirtd.socket on Debian/Ubuntu) without a <name>-host sibling candy (CLAUDE.md R3).

func ServiceRenderDistros added in v0.2026190.848

func ServiceRenderDistros(img *ResolvedBox, hostCtx HostContext) []string

compileServiceSteps turns the candy's service declarations into IR steps. Preference order:

  1. Unified `services:` list (Task 6) — preferred when present. Each entry becomes either a ServicePackagedStep (use_packaged:) or a ServiceCustomStep (full spec).

compileServiceSteps — unified schema only. Each ServiceEntry becomes either a ServicePackagedStep (use_packaged:) or a ServiceCustomStep (custom exec). Legacy fields (raw-INI service:, system_services:) are gone — external candies must run `charly migrate`.

**Init-system polymorphism filter (2026-05).** When a candy declares the same service `name:` twice — once with `use_packaged:` and once with custom `exec:` (the mixed-entry polymorphism pattern documented in CLAUDE.md "Init-system polymorphism via mixed `service:` entries" and `/charly-build:layer` "Service Declaration") — the compiler picks ONE based on the target's init system:

  • systemd target (host / vm) → emit the packaged form, SKIP the custom-exec sibling (the packaged unit handles the daemon).
  • supervisord target (oci/pod build) → SKIP the packaged form (supervisord can't consume systemd units), emit the custom form.

For singleton entries (no mixed pair), each entry renders as-is on the matching init system; mismatched singletons (e.g. a lone `use_packaged:` entry on a supervisord target) are silently skipped.

For systemd targets, the compiler ALSO pre-populates UnitText/UnitPath on the ServiceCustomStep by calling RenderService, so executors don't need a runtime lazy-render step. This consolidates what used to live in three different places (the deleted in-proc VM-target lazy fallback, the OCI build's per-entry routing, and the legacy nothing-rendered path on the local deploy target) into ONE compile-time filter. ServiceRenderDistros returns the distro tag chain a service entry's distro: filter is matched against for a deploy target. img.Distro is the AUTHORITATIVE deploy-target chain and always wins (mirrors PrimaryDistroTag): syntheticVmBox sets the GUEST chain (e.g. ["debian:13","debian"]), syntheticHostBox the operator host's, ResolveBox the image's. Using hostCtx.Distro here was the bug that made a vm deploy filter services against the OPERATOR's distro (arch) instead of the guest's (debian) — detectHostContext defaults hostCtx.Target to "host" + the operator distro even for a vm deploy, so a hostCtx-wins rule mis-scoped every vm/pod service. For a host deploy img.Distro is the operator's own tag chain (a SUPERSET of the single PrimaryTag, so arch-derivative hosts like cachyos now also match `arch:` entries). hostCtx.Distro is only a fallback when img carries no distro.

func SortedNestedKeys added in v0.2026190.848

func SortedNestedKeys(children map[string]*BundleNode) []string

func SplitDottedPath added in v0.2026190.848

func SplitDottedPath(path string) []string

SplitDottedPath splits a dotted deployment path into segments. An empty input or a path with any empty segment (leading/trailing/ doubled dots) yields nil so callers can flag the error at their layer with the original offending path string.

func StepToView added in v0.2026190.848

func StepToView(step InstallStep) spec.InstallStepView

StepToView projects one concrete InstallStep onto its serializable wire view.

func StepsToView added in v0.2026190.848

func StepsToView(steps []InstallStep) []spec.InstallStepView

StepsToView / stepsFromView convert a whole ordered slice. Order is preserved (the InstallPlan's step ordering is load-bearing — see ResolveHome / StepsByVenue).

func StringSliceFromYAML added in v0.2026190.848

func StringSliceFromYAML(v any) ([]string, bool)

StringSliceFromYAML coerces a YAML-decoded value into []string. The decoder produces []interface{} for sequences; we tolerate already- stringified slices for callers that pre-process.

func StripSecretEnvNames added in v0.2026190.848

func StripSecretEnvNames(env map[string]string, blocked []string) map[string]string

StripSecretEnvNames removes any KEY=VAL entries from env whose KEY is in the blocked list. The blocked list is expected to be short (one entry per secret_* declaration on the image), so a per-entry delete is fine.

func StripVersion added in v0.2026190.848

func StripVersion(ref string) (string, string)

StripVersion splits an @-prefixed ref into its bare form and pinned version. A non-@ ref returns (ref, "").

func WalkDeploymentTree added in v0.2026190.848

func WalkDeploymentTree(rootPath string, root *BundleNode, parentExec DeployExecutor, visit DeployTreeVisitor) error

WalkDeploymentTree performs a pre-order walk rooted at the given node, calling visit on each node. Dotted-path accumulation is handled internally: the root's `rootPath` argument seeds the identifier; children are rendered as `<parent>.<childKey>`.

Errors short-circuit: as soon as any visit call returns a non-nil error, the walk stops and that error propagates.

func WalkDeploymentTreePostOrder added in v0.2026190.848

func WalkDeploymentTreePostOrder(rootPath string, root *BundleNode, parentExec DeployExecutor, visit DeployTreeVisitor) error

WalkDeploymentTreePostOrder is the post-order analogue used by BundleDelCmd. Children are visited before their parent, so a parent's venue can still accept the teardown commands for its children.

func WireView added in v0.2026190.848

func WireView(p *spec.InstallPlan) spec.InstallPlanView

WireView projects the rich in-core spec.InstallPlan onto the JSON-roundtrippable spec.InstallPlanView the host marshals into an external deploy/step provider's op.Params. The Steps interface slice round-trips through the SINGLE StepsToView / stepsFromView converter (step_view.go) — an external deploy/step plugin walks the same ordered step IR the in-proc DeployTargets walk and EXECUTES it on the venue (R3; proven by the step-IR round-trip test). The remaining fields are identity + provenance.

A free function (not a method on spec.InstallPlan) because it type-switches the concrete step vocabulary via StepsToView — that lives in deploykit, so spec never imports deploykit.

Types

type AliasYAML added in v0.2026190.848

type AliasYAML = spec.AliasYAML

type ApkInstallStep

type ApkInstallStep struct {
	Packages  []ApkPackageSpec
	CandyName string
	CandyDir  string // candy source dir — anchors relative committed-APK paths
}

ApkInstallStep installs Android apps onto a `kind: android` device. It is the IR form of a candy's `apk:` package section — the apk "package format" (parallel to SystemPackagesStep for rpm/deb/pac, and BuilderStep for aur).

Unlike every other step, an apk install lands on a RUNNING Android device, not the build/host filesystem. `target: android` is an EXTERNAL deploy substrate (F1): NO in-proc DeployTarget executes this step — the host-side android deploy preresolver (collectAndroidInstalls, android_deploy_preresolve.go) READS it to collect the apk install specs and ships them to the deploy:android plugin (candy/plugin-adb: apkeep + adb), which drives the device. Every DeployTarget SKIPS it — OCITarget emits nothing (no device at image-build time), and Local/Vm/Pod targets record a skip (a host/VM/pod is not an Android device). This is the same "wrong venue → skip" shape `aur:` uses off-Arch, expressed as a clean recorded skip rather than an error (an image legitimately builds without installing apps).

func (*ApkInstallStep) Kind

func (s *ApkInstallStep) Kind() StepKind

func (*ApkInstallStep) RequiresGate

func (s *ApkInstallStep) RequiresGate() Gate

func (*ApkInstallStep) Reverse

func (s *ApkInstallStep) Reverse() []ReverseOp

Reverse returns no STATIC ledger ops — Android teardown ops are DYNAMIC, recorded from the deploy:android plugin's OpExecute reply (the uninstall reverse ops) at deploy time, replayed at `charly bundle del` like any external deploy substrate.

func (*ApkInstallStep) Scope

func (s *ApkInstallStep) Scope() Scope

Scope is system — installing an app mutates device-global package state.

func (*ApkInstallStep) Venue

func (s *ApkInstallStep) Venue() Venue

Venue is host-native — the android deploy preresolver reads this step from the host (the install itself runs in the deploy:android plugin over the wire).

type ApkPackageSpec

type ApkPackageSpec = spec.ApkPackageSpec

type ArtifactRef

type ArtifactRef struct {
	ContainerPath string // path inside the builder stage/container
	HostPath      string // path on the deploy target (host fs or final-image fs)
	Chown         bool   // whether to re-own to the target user
}

ArtifactRef describes an output path from a builder that needs to be extracted back to the host or copied into the final OCI image.

For user-scope pixi/npm/cargo on the host target: the host path is bind-mounted into the builder, so there's no "extraction" — the Artifacts list is empty because the bind-mount already put the files in place. For aur: the list contains /tmp/aur-pkgs/*.pkg.tar.zst, which the host target pulls out to a staging dir then hands to pacman.

type BuilderDef

type BuilderDef = spec.BuilderDef

type BuilderPreresolved added in v0.2026190.848

type BuilderPreresolved struct {
	Context map[string]any
	Reverse []ReverseOp
}

BuilderPreresolved is one candy×builder's pre-resolved payload. The Candy-coupled functions that BUILD it stay in charly; the compiler only reads it.

type BuilderRunOpts added in v0.2026190.848

type BuilderRunOpts = spec.BuilderRunOpts

type BuilderStep

type BuilderStep struct {
	Builder      string        // "pixi" | "npm" | "cargo" | "aur"
	BuilderImage string        // resolved image ref (e.g. "fedora-builder:2026.04")
	CandyName    string        // layer that triggered this builder (for ledger)
	CandyDir     string        // absolute layer source path (bind-mounted as /work)
	Phase        Phase         // typically PhaseInstall
	Artifacts    []ArtifactRef // outputs to extract (empty for user-scope pixi/npm/cargo; populated for aur)

	// Builder-specific template context — the compiler populates this from
	// the candy's manifest files + the embedded builder definition (charly/charly.yml).
	RawStageContext map[string]any

	// LocalPkg is the package format's localpkg contract, populated by the
	// compiler for the `aur` builder only. The aur builder produces package
	// files (.pkg.tar.zst) that the host/VM deploy targets install onto the
	// venue via the SAME config-driven transfer+install leg the localpkg step
	// uses (R3) — so the install command + package glob come from
	// the embedded `pac.local_pkg` vocabulary, never a hardcoded literal. Nil for
	// pixi/npm/cargo (home-artifact builders, no package-file install).
	LocalPkg *LocalPkgDef

	// BuilderDef is the resolved builder definition from the embedded build vocabulary (charly/charly.yml) for this builder
	// (img.BuilderConfig.Builder[Builder]), populated by the compiler. The
	// host-venue deploy targets render its phase.install.host cell via
	// renderBuilderScript — the plain-shell analog of the container stage — so the
	// host build script is config-driven, not hardcoded Go. nil only on
	// synthetic test paths that don't supply a BuilderConfig.
	BuilderDef *BuilderDef

	// PreResolvedReverse is the builder's teardown ops, resolved HOST-SIDE in the build
	// PRE-PASS (builder_preresolve.go → the externalized builder plugin's OpReverse) and stashed
	// here so Reverse() is a PURE getter — the per-builder reverse-op KIND (pixi-env-remove /
	// package-remove / …) is exactly the logic externalized out-of-process, and Reverse() runs
	// host-side (step-view projection + RunHostStep) with no registry handle. Carried across the
	// wire on InstallStepView.ReverseOps (the host-computed teardown field) and restored by
	// stepFromView. Nil for a custom candy builder / a direct compile with no pre-pass.
	PreResolvedReverse []ReverseOp
}

BuilderStep runs a multi-stage builder (pixi/npm/cargo/aur). On the OCI target this emits a FROM + RUN stage plus a final-stage COPY --from. On the host target this emits a `podman run <builder>` with HOME-remap and appropriate bind-mounts.

func (*BuilderStep) Kind

func (s *BuilderStep) Kind() StepKind

func (*BuilderStep) RequiresGate

func (s *BuilderStep) RequiresGate() Gate

func (*BuilderStep) Reverse

func (s *BuilderStep) Reverse() []ReverseOp

func (*BuilderStep) Scope

func (s *BuilderStep) Scope() Scope

func (*BuilderStep) Venue

func (s *BuilderStep) Venue() Venue

type BundleConfig added in v0.2026190.848

type BundleConfig struct {
	Provides *ProvidesConfig       `yaml:"provides,omitempty" json:"provides,omitempty"`
	Bundle   map[string]BundleNode `yaml:"deploy" json:"deploy"`
	// Sidecar carries the project's sidecar-template library as OPAQUE bodies
	// (the raw PluginKinds["sidecar"] map). candy/plugin-sidecar's OpResolve merges
	// these UNDER each deploy node's own overrides; the kernel reads no fields
	// (the sidecar de-type, Cutover D).
	Sidecar map[string]json.RawMessage `yaml:"sidecar,omitempty" json:"sidecar,omitempty"`
}

--- BundleConfig state container (moved from charly/deploy.go, P4) --- BundleConfig represents per-machine deployment overrides (~/.config/charly/charly.yml). Only runtime/deployment fields are supported — build-time fields are structurally excluded.

Schema v4: the top-level map key is `deployment:` (singular, flat). The legacy `images:` / `deployments.images.*` nesting is gone — all target kinds (host / vm / pod / k8s) live under the single `deployment:` map.

func MergeDeployConfigs added in v0.2026190.848

func MergeDeployConfigs(configs ...*BundleConfig) *BundleConfig

MergeDeployConfigs merges multiple DeployConfigs left-to-right. Later configs take precedence (field-level replace per image). The merge walks every yaml-tagged field of BundleNode via reflect: a field copies from src → dst when src's value is non-zero (string != "", slice/map/ptr not nil, bool != false, numeric != 0). This makes adding a new field to BundleNode automatically merge-correct — the pre-2026-05 hand-rolled per-field merge silently dropped 19+ fields (ResolvedPort, Description, Secret, Sidecar, Shell, Kubernetes, ForwardGpgAgent, ForwardSshAgent, Kind, Replica, Restart, Schedule, Resources, Expose, Storage, Probes, Cpus, Ram, DiskSize) whenever any merge → save cycle ran.

The yaml tag `-` (currently only BundleNode.Inside, a derived runtime field) skips the merge. Untagged fields are also skipped.

func (*BundleConfig) DeployedContainerNames added in v0.2026190.848

func (dc *BundleConfig) DeployedContainerNames() []string

DeployedContainerNames returns the sorted, de-duplicated container names for every bundle entry.

func (*BundleConfig) GlobalEnvForImage added in v0.2026190.848

func (dc *BundleConfig) GlobalEnvForImage(consumerKey, ctrName string, acceptedEnv map[string]bool) []string

GlobalEnvForImage builds the env-var injection list for a consumer container from the deploy state's env + MCP provides, filtered by the consumer's accepts.

func (*BundleConfig) Lookup added in v0.2026190.848

func (dc *BundleConfig) Lookup(deployName, instance string) (BundleNode, bool)

Lookup returns the BundleNode for (deployName, instance), or (zero, false) when the entry is absent. Safe to call on a nil *BundleConfig — lets callers chain `loadDeployConfigForRead(...).Lookup(deployName, instance)` without a separate nil check. deployName is the charly.yml key base the caller is operating on (typically c.Image), NOT the baked image short-name — for a kind:check bed or Pattern-B deploy the two differ. Pass the deploy key, never a value derived from an image label (see MergeDeployOntoMetadata).

func (*BundleConfig) LookupKey added in v0.2026190.848

func (dc *BundleConfig) LookupKey(key string) (BundleNode, bool)

LookupKey looks up a deploy entry by its full charly.yml key (e.g. "foo", "foo/instance", "vm:name"). Safe on nil receiver.

func (*BundleConfig) OccupiedHostPorts added in v0.2026190.848

func (dc *BundleConfig) OccupiedHostPorts(excludeKey string) map[int]bool

OccupiedHostPorts returns the set of host ports already claimed by bundle entries other than excludeKey (resolved pins preferred over authored).

type BundleNode added in v0.2026190.848

type BundleNode = spec.BundleNode

func FindVmDeployNode added in v0.2026190.848

func FindVmDeployNode(deploys map[string]BundleNode, name, vmName string) (BundleNode, bool)

FindVmDeployNode finds the BundleNode for a vm-target deploy. It is THE shared "which deploy entry backs this VM" lookup used by both `charly bundle add` (artifact-env collection) and `charly check live` (tests overlay), so the two never diverge. Resolution order:

  1. by deploy NAME (the entry key) — the precise match;
  2. by the legacy "vm:<name>" key form;
  3. by scanning for any target:vm entry whose `vm:` field == vmName (or == name) — the fallback when the caller only knows the vm entity.

Keying by the deploy NAME first is load-bearing: a bed whose key differs from its vm entity (e.g. check-k3s-vm -> vm: k3s-vm) is found by its key, not mis-resolved via the vm entity name.

func MergeBundleNode added in v0.2026190.848

func MergeBundleNode(dst, src BundleNode) BundleNode

MergeBundleNode applies non-zero fields from `src` onto `dst` and returns the merged copy. Walks every yaml-tagged field via reflect; the yaml `-` tag (derived/runtime-only fields) is skipped. Same precedence rule as the underlying merge: src non-zero wins, otherwise dst passes through. Per R3 the single helper replaces the hand-rolled per-field merges that previously lived in MergeDeployConfigs (drift-prone — every new struct field needed a remembered append, and 19+ were missed).

type CacheMountDef

type CacheMountDef = spec.CacheMount

type CacheMountSpec

type CacheMountSpec struct {
	Dst     string
	Sharing string // "locked" | "private" | "shared" | ""
}

CacheMountSpec mirrors the BuildKit cache-mount configuration carried in the embedded build vocabulary's format/builder definitions (charly/charly.yml). The OCI target renders these as `--mount=type=cache,...`; the host target ignores them.

type CandyArtifact added in v0.2026190.848

type CandyArtifact = vmshared.CandyArtifact

type CandyCapabilities added in v0.2026190.848

type CandyCapabilities = spec.CandyCapabilities

type CandyModel added in v0.2026190.848

type CandyModel interface {
	GetName() string
	GetSourceDir() string
	GetVersion() string
	Vars() map[string]string
	PlanSteps() []Step
	Reboot() bool
	Apk() []ApkPackageSpec
	EnvConfig() (*EnvConfig, error)
	Service() []ServiceEntry
	Shell() *ShellConfig
	TopPackages() []string
	FormatSection(name string) *PackageSection
	LocalPkg(format string) string
	TagSection(tag string) *TagPkgConfig
	HasFile(filename string) bool
}

candy_model.go — CandyModel, the read-only view of a runtime candy that the deploy-plan compiler (BuildDeployPlan) consumes. The concrete runtime Candy lives in charly and implements this interface; the compiler depends on the abstraction (kernel/plugin boundary law: a Mechanism consumes an interface, the concrete kind implements it), so the candy struct + its whole test suite stay in charly with zero cross-package churn.

type CandyPluginDecl added in v0.2026190.848

type CandyPluginDecl = vmshared.CandyPluginDecl

type CandyRef added in v0.2026190.848

type CandyRef struct {
	Raw string // original ref, e.g. "@github.com/org/repo/candy/x:v1" or bare "x"
	// Resolved is the qualified candy-map key assigned when a freshly-fetched
	// remote candy's plain-name sibling deps are qualified to
	// "<repo>/<subpathprefix><name>" (qualifyRemoteSiblingDeps). Empty for every
	// other ref, where the map key derives from Raw.
	Resolved string
}

CandyRef is a single candy reference as authored in the candy manifest `require:` / `candy:` (or charly.yml `candy:`). It carries the ORIGINAL ref string — with any `@repo` prefix and `:version` suffix — as the single source of truth; the bare map-key form (.Bare()) and the pinned version (.Version()) are DERIVED on demand, so a ref's identity and its version can never drift apart.

func ToCandyRefs added in v0.2026190.848

func ToCandyRefs(raw []string) []CandyRef

ToCandyRefs wraps raw ref strings into CandyRef values. Returns nil for a nil/empty input so an absent list stays absent.

func (CandyRef) Bare added in v0.2026190.848

func (r CandyRef) Bare() string

Bare returns the candy-map key (no @ prefix, no :version) — the form used for dependency resolution and graph keying.

func (CandyRef) IsRemote added in v0.2026190.848

func (r CandyRef) IsRemote() bool

IsRemote reports whether this is an @-prefixed remote ref.

func (CandyRef) Version added in v0.2026190.848

func (r CandyRef) Version() string

Version returns the pinned version (the ":vX" suffix), or "" for an unpinned remote ref or a local (bare-name) ref.

type CandyYAML added in v0.2026190.848

type CandyYAML = spec.Candy

type DataYAML added in v0.2026190.848

type DataYAML = spec.DataYAML

type DeployExecutor added in v0.2026190.848

type DeployExecutor = spec.DeployExecutor

func AppendHopForFlatPath added in v0.2026190.848

func AppendHopForFlatPath(chain DeployExecutor, node *BundleNode, flatPath, leaf string) (DeployExecutor, error)

AppendHopForFlatPath stacks one executor hop so commands land inside `node`'s substrate. flatPath is the dotted path with dots replaced by underscores — the host-side container name suffix; leaf is the final path segment (the node's own key), used for a pod deployed STANDALONE inside a VM guest (which has no parent-path concept — see the pod case).

func ContainerChain added in v0.2026190.848

func ContainerChain(engine, containerName string) DeployExecutor

ContainerChain returns a one-hop chain that exec's into a single named running container (`<engine> exec <name> bash`). Convenience for the simple `charly check live <name>` path where there is no nested dotted path to walk — equivalent to ResolveDeployChain on a single-segment dotted path that resolves to a pod node, but skips the tree lookup.

func DeriveChildExecutor added in v0.2026190.848

func DeriveChildExecutor(node *BundleNode, parentExec DeployExecutor, deployName string) (DeployExecutor, error)

DeriveChildExecutor computes the DeployExecutor that this node's children should use, given this node's target and the parent executor. Pure (no side effects) so it can be called from the post-order path before the node itself is dispatched.

Semantics by target:

host:       children share the parent venue (host applies candies
            in-place). Child executor = parentExec or
            ShellExecutor at the root.
container:  wrap parent with NestedExecutor{JumpPodmanExec}.
vm:         wrap parent with NestedExecutor{JumpSSH} when parent
            is non-nil; otherwise the child executor is a plain
            SSHExecutor built from the VM's deploy state.
kubernetes: children are K8s manifests — not executed. Returns
            nil + error when non-empty Children.

Returns (parentExec, nil) for nodes with no children — no composition needed.

func ImageChain added in v0.2026190.848

func ImageChain(engine, imageRef string) DeployExecutor

ImageChain builds a one-hop chain that runs commands inside a freshly- spawned disposable container (`<engine> run --rm <imageRef> bash`). Used by `charly check box --section box` to replace the deleted ImageExecutor — same semantics, expressed via the unified chain primitive.

engine defaults to "podman" when empty. imageRef is passed verbatim (full registry refs and short local names both work as long as `<engine> run --rm` accepts them).

func RootExecutorForDeployNode added in v0.2026190.848

func RootExecutorForDeployNode(node *BundleNode) (DeployExecutor, error)

RootExecutorForDeployNode selects the ROOT DeployExecutor for a `target: local` deployment node from its `host:` field — the single source of truth for "where does a local deploy's work run?", shared by `charly bundle add` (the local deploy target.Add) and `charly check live` (runLocalCheck) so neither re-implements the selection (R3):

host: ""  / "local"        → ShellExecutor{} (this machine, direct shell)
host: "<user>@<machine>"   → &SSHExecutor{User, Host, Port, …}
host: "<machine>" + user:  → SSHExecutor with User from node.User

It does NOT handle the nested-inside-a-parent case (opts.ParentExec); that stays in the local deploy target.Add because it's deploy-execution-specific. Returns ShellExecutor{} for a nil node.

func VmChildExecutor added in v0.2026190.848

func VmChildExecutor(node *BundleNode, parentExec DeployExecutor, deployName string) (DeployExecutor, error)

VmChildExecutor wraps parentExec with an SSH jump into the VM represented by this node. At the root (parentExec == nil or ShellExecutor), the child gets a plain SSHExecutor — no nesting overhead for the common case of a VM on localhost.

The SSH alias keys off node.From (the kind:vm entity name), NOT deployName (the bed name) — `charly vm create <vm>` writes the managed stanza for `charly-<vm>`. Falling back to deployName here would produce a `charly-<bed>` alias with no matching stanza (e.g., bed `arch-vm` → `charly-arch-vm`, but the stanza is `charly-arch`). deployName is kept for log messages where the deployment identity matters.

type DeployTarget added in v0.2026190.848

type DeployTarget = spec.DeployTarget

type DeployTreePhase added in v0.2026190.848

type DeployTreePhase int

DeployTreePhase indicates which lifecycle phase the walker is in. Pre-order for add; post-order for delete.

const (
	DeployTreePhaseAdd DeployTreePhase = iota
	DeployTreePhaseDel
)

type DeployTreeVisitor added in v0.2026190.848

type DeployTreeVisitor func(path string, node *BundleNode, parentExec DeployExecutor) (childExec DeployExecutor, err error)

DeployTreeVisitor is invoked once per node in the walk. It receives the node's dotted path, the node itself, and the parent executor (nil at the root). The return value is the DeployExecutor that this node's CHILDREN should use as their parent. A host-target node returns the same executor it was given (candies applied in-place on the parent venue); a container or vm node returns a NestedExecutor that drills into the newly-created environment.

Returning (nil, nil) for a node with children is an error — it means "cannot compute child executor", which the walker surfaces with the offending path.

type EmitOpts added in v0.2026190.848

type EmitOpts = spec.EmitOpts

func InstallOptsApplyTo added in v0.2026190.848

func InstallOptsApplyTo(o *InstallOptsConfig, opts EmitOpts) EmitOpts

ApplyTo merges install_opts settings into an EmitOpts. CLI flags still win — charly.yml provides defaults, not overrides. Nil receiver is a no-op.

type EnvConfig added in v0.2026190.848

type EnvConfig = kit.EnvConfig

type EnvDependency added in v0.2026190.848

type EnvDependency = vmshared.EnvDependency

type EnvProvideEntry added in v0.2026190.848

type EnvProvideEntry struct {
	Name   string `yaml:"name" json:"name"`
	Value  string `yaml:"value" json:"value"`
	Source string `yaml:"source" json:"source"`
}

EnvProvideEntry is a resolved env_provides entry in charly.yml.

func PodAwareEnvProvides added in v0.2026190.848

func PodAwareEnvProvides(entries []EnvProvideEntry, consumerKey, ctrName string) []EnvProvideEntry

PodAwareEnvProvides rewrites same-deploy env values to localhost and dedups cross-deploy entries by name (local wins).

func (EnvProvideEntry) GetName added in v0.2026190.848

func (e EnvProvideEntry) GetName() string

func (EnvProvideEntry) GetSource added in v0.2026190.848

func (e EnvProvideEntry) GetSource() string

type ExecContext added in v0.2026190.848

type ExecContext string

ExecContext + Ctx consts — the op-context classification enum, moved from charly with the compiler.

const (
	CtxBuild   ExecContext = "build"
	CtxDeploy  ExecContext = "deploy"
	CtxRuntime ExecContext = "runtime"
)

type ExternalPluginStep

type ExternalPluginStep struct {
	Op           *Op      // the run: step op — Plugin (verb word) + PluginInput + RunAs
	CandyName    string   // owning candy (provenance + the ledger CandyRecord key)
	ResolvedUser string   // uid:gid or "root" after resolveUserSpec — drives Scope
	Distros      []string // the image's distro tag chain (img.Tags) for the build-emit BuildEnv
}

ExternalPluginStep is the install-timeline IR node for a `run: plugin: <verb>` step whose verb is served by an EXTERNAL (out-of-process) plugin — a grpcProvider, not a built-in TypedStepProvider (package/service) or ProvisionActor (the state-provision shell verbs) or the `command` install verb. compileActOp routes it here; the Invoke op is picked per venue, placement-agnostic above the registry:

  • the DEPLOY venue (the install runs ON the target, not into an image): BOTH target:local AND target:vm externalized, so an ExternalPluginStep on a deploy is reached by the external local/vm plugin's kit.WalkPlans, which routes it through the host's RunHostStep (the nested ExternalPluginStep case) → executeExternalPluginStep → Invoke(OpExecute) WITH the live DeployExecutor on the go-plugin broker (the E3b reverse channel), so the plugin runs its deploy-context effect (RunSystem/RunUser) on the real venue and RETURNS its teardown ReverseOps which the host records into the ledger (record-and-replay — only recorded ops are reversed at `charly bundle del`). This is the deploy-context counterpart of the build-context OpEmit leg (tasks.go emitPluginFragment), reusing the SAME spec.DeployReply / ReverseOp wire as the external deploy TARGET (deploy_target_external.go) — R3.
  • EmitOCI (a BUILD venue — the pod-overlay Containerfile): Invoke(OpEmit) via the SHARED emitPluginFragment, splicing the plugin's Containerfile FRAGMENT verbatim — it cannot deploy-execute at build (no live venue). Identical behaviour to the box-build path (writeCandySteps → emitTasks `case "plugin"`), just relocated. EmitOCI is the ONLY in-proc Emit* this provider still implements.

Reverse() is static-nil: the reversal ops are DYNAMIC — they come from the plugin's OpExecute reply at emit time, recorded by the host's RunHostStep handler into the CandyRecord (the externalDeployTarget record-and-replay pattern).

func (*ExternalPluginStep) Kind

func (s *ExternalPluginStep) Kind() StepKind

func (*ExternalPluginStep) RequiresGate

func (s *ExternalPluginStep) RequiresGate() Gate

RequiresGate is GateNone — an external plugin verb-step is operator-authorized build/deploy-time plugin execution (the candy author opted into it), mirroring the external deploy TARGET which is ungated; the plugin picks its own privilege via RunSystem/RunUser on the reverse channel.

func (*ExternalPluginStep) Reverse

func (s *ExternalPluginStep) Reverse() []ReverseOp

Reverse is static-nil: the teardown ops are recorded DYNAMICALLY from the plugin's OpExecute DeployReply at emit time (EmitLocal/EmitVM append reply.ReverseOps to the CandyRecord), exactly like the external deploy target — never recomputed.

func (*ExternalPluginStep) Scope

func (s *ExternalPluginStep) Scope() Scope

Scope classifies by the step's user context — the SAME rule OpStep uses (OpStepScope): root/empty → system, a named/numeric non-root user → user. The plugin then chooses RunSystem vs RunUser on the reverse channel per its own effect; this scope drives only the ledger reverse-op privilege bookkeeping.

func (*ExternalPluginStep) Venue

func (s *ExternalPluginStep) Venue() Venue

type ExternalStep added in v0.2026190.848

type ExternalStep struct {
	Word       string          // the reserved step word; Kind() = "external:" + Word
	ScopeV     Scope           // plugin-declared (StepContract.scope)
	VenueV     Venue           // plugin-declared (StepContract.venue)
	GateV      Gate            // plugin-declared (StepContract.gate) — the step SKIPs if the gate is not enabled
	Payload    json.RawMessage // opaque per-kind input — the OpExecute params
	CandyName  string          // owning candy (provenance + the ledger CandyRecord key)
	ReverseOps []ReverseOp     // set DYNAMICALLY from the plugin's OpExecute reply (record-and-replay)
}

ExternalStep is an EXTERNAL, plugin-CONTRIBUTED install-step KIND: a step whose Kind() is "external:<word>", carried OPAQUELY (Payload) and whose Scope/Venue/Gate come from the serving class:step plugin's DECLARED StepContract. Its host EXECUTION funnels through the OpExecute-to-the-serving-plugin path; teardown ops are DYNAMIC (recorded from the OpExecute reply), so Reverse() returns the recorded slice.

func (*ExternalStep) Kind added in v0.2026190.848

func (s *ExternalStep) Kind() StepKind

func (*ExternalStep) RequiresGate added in v0.2026190.848

func (s *ExternalStep) RequiresGate() Gate

func (*ExternalStep) Reverse added in v0.2026190.848

func (s *ExternalStep) Reverse() []ReverseOp

func (*ExternalStep) Scope added in v0.2026190.848

func (s *ExternalStep) Scope() Scope

func (*ExternalStep) Venue added in v0.2026190.848

func (s *ExternalStep) Venue() Venue

type ExtractYAML added in v0.2026190.848

type ExtractYAML = spec.ExtractYAML

type FileStep

type FileStep struct {
	Source    string      // path to source content (under layer dir or .build/_inline/)
	Dest      string      // absolute destination path
	Mode      os.FileMode // permissions
	Owner     string      // "root" or "uid:gid" or the invoking user's name
	CandyName string      // for ledger
}

FileStep places a single file. The compiler may emit these for candy-declared file directives that aren't wrapped as tasks (e.g. supervisord fragment assembly). Today's tasks.go handles most file placement via OpStep; FileStep exists for cases where the compiler synthesizes file writes that weren't in the candy manifest (e.g. service unit files, managed-block contents).

func (*FileStep) Kind

func (s *FileStep) Kind() StepKind

func (*FileStep) RequiresGate

func (s *FileStep) RequiresGate() Gate

func (*FileStep) Reverse

func (s *FileStep) Reverse() []ReverseOp

func (*FileStep) Scope

func (s *FileStep) Scope() Scope

func (*FileStep) Venue

func (s *FileStep) Venue() Venue

type Gate

type Gate = spec.Gate

type HooksConfig added in v0.2026190.848

type HooksConfig = spec.HooksConfig

type HostContext added in v0.2026190.848

type HostContext struct {
	// Target selects compilation mode. "" or "oci" means "compile for
	// container build"; "host" means "compile for direct host execution".
	// Primarily affects which steps get VenueSkip (container-only fields
	// like ports:/volumes: are skipped on "host").
	Target string

	// Distro is the resolved host distro tag, e.g. "fedora:43". Used to
	// pick the right format section when compiling for a host target
	// whose distro differs from the image's primary distro.
	Distro string

	// GlibcVersion is the host's glibc major.minor as reported by
	// `ldd --version`. Used by the host target's preflight check against
	// the selected builder image. Optional; empty means skip the check.
	GlibcVersion string

	// BuilderImage overrides the default builder-image selection for
	// VenueContainerBuilder steps. Populated from --builder-image. ""
	// means "use the embedded build vocabulary's default".
	BuilderImage string

	// BuilderContext carries the host-side build PRE-PASS result: each externalized
	// detection-builder's per-candy stage context + teardown ops, keyed by
	// BuilderCtxKey(candy, builder). Populated by preresolveBuilderContexts BEFORE
	// this pure compile (the deploy command path); read by collectBuilderContext +
	// compileBuilderSteps so the compiler NEVER dials a builder plugin (purity). Nil
	// when no pre-pass ran (a direct BuildDeployPlan caller / test) or no externalized
	// builder is triggered → the affected builder gets base-only context, no teardown.
	BuilderContext map[string]BuilderPreresolved
}

HostContext carries host-side information the compiler needs to decide (a) which format section to pick for the host target, (b) which builder image to run user-scope builders in, (c) whether to gate AUR-specific steps, etc. For the OCI target, the caller passes a zero-value HostContext (the compiler ignores host-only choices when Target is "oci").

type InstallOptsConfig added in v0.2026190.848

type InstallOptsConfig = vmshared.InstallOptsConfig

type InstallPlan added in v0.2026190.848

type InstallPlan = spec.InstallPlan

func BuildDeployPlan added in v0.2026190.848

func BuildDeployPlan(layer CandyModel, img *ResolvedBox, hostCtx HostContext) (*InstallPlan, error)

BuildDeployPlan compiles one Candy into an InstallPlan.

For whole-image deploys, the caller iterates the ordered candy list (from ResolveCandyOrder) and builds one plan per candy, then merges them. Keeping one plan per candy makes refcounting trivial in the ledger: each candy's teardown is independent.

func MergePlan added in v0.2026190.848

func MergePlan(plans []*InstallPlan, image string, addCandies []string) *InstallPlan

MergePlan combines a list of per-candy plans into one whole-image plan. Used by deploy targets that want to see all steps in one sequence (for sudo batching, overall dry-run display, etc.) while preserving per-candy provenance for the ledger.

type InstallStep added in v0.2026190.848

type InstallStep = spec.InstallStep

func CompileApkStep added in v0.2026190.848

func CompileApkStep(layer CandyModel) InstallStep

CompileApkStep turns a candy's `apk:` package list into a single ApkInstallStep, or nil if the candy declares no apk packages. The `apk` format is target-agnostic at compile time — the step carries the specs and each DeployTarget decides whether to execute (android) or skip (everything else), exactly as the IR intends for venue-specific work.

func CompileLocalPkgStep added in v0.2026190.848

func CompileLocalPkgStep(layer CandyModel, img *ResolvedBox, _ HostContext) InstallStep

CompileLocalPkgStep turns a candy's `localpkg:` field into a single LocalPkgInstallStep, or nil if the candy declares none. Like CompileApkStep it is target-agnostic at compile time — the step carries the author's PKGBUILD hint plus the candy dir AND the deploy project dir (os.Getwd, the same handle compileServiceSteps reads) as the two anchors the emit-time walk-up search uses to locate the PKGBUILD. Each DeployTarget decides whether to build+install (localpkg-capable host/guest), skip (image build, non-pac targets, android, k8s).

The localpkg mechanism is fully config-driven: the format's `local_pkg:` block (resolved here via DistroDef.LocalPkgFormat, the SAME DistroDef the system-package steps read) supplies the build/install templates, package glob, foreign-deps query, probe, and dependency-builder name. BuilderImage is resolved for that block's DepBuilder the same way builder steps resolve theirs (resolveBuilderImage) so the executor can build the package's dependency closure through the EXISTING builder before installing. When the distro declares no localpkg-capable format, LocalPkg is nil and the executor skips; when no dep builder resolves, BuilderImage is "" and the dep-build is skipped with a clear log (the candy's own curl/COPY fallback still covers non-localpkg targets).

func CompileOpSteps added in v0.2026190.848

func CompileOpSteps(layer CandyModel, img *ResolvedBox) []InstallStep

CompileOpSteps turns the candy's install timeline into InstallSteps. The timeline is the candy's `plan:` `run:` steps (StepKind()==KwRun) whose context includes build/deploy, in declared (cache-stable) order — the fold that retired the separate `task:` list. Each run op either LOWERS into an existing typed step (the `plugin: package` verb → SystemPackagesStep and the `plugin: service` verb → ServicePackagedStep, each via its TypedStepProvider) so emit + reversal are REUSED, or stays a generic OpStep (install verbs + command + the RenderProvisionScript plugin verbs). A run: step scoped runtime-only is plan-runtime provisioning the check Runner executes — NOT the install timeline — and is skipped here (avoids double-execution); check:/agent-*/ include: steps are never lowered.

func CompileShellSnippetSteps added in v0.2026190.848

func CompileShellSnippetSteps(layer CandyModel, img *ResolvedBox, hostCtx HostContext) []InstallStep

CompileShellSnippetSteps returns one ShellSnippetStep per (candy, shell) pair the candy contributes. Selection rule (mirrors TagPkgConfig):

  1. If layer.Shell.ByShell[shell] exists, render it.
  2. Else if layer.Shell.Init is non-empty, render the generic body with ${SHELL_NAME} substituted to the active shell name.
  3. Else this shell gets nothing from this candy.

path_append entries are rendered into the snippet body using shell-appropriate syntax (PATH=... for bash/zsh/sh, fish_add_path for fish) before the step is emitted, so each DeployTarget emitter can write the snippet bytes verbatim.

Destination resolution is target-aware:

  • Container build (hostCtx.Target empty / "oci"): system-wide drop-in (/etc/profile.d/charly-<candy>-<shell>.sh, /etc/fish/conf.d/ charly-<candy>.fish). UseDropin=true.
  • target:local, target:vm (hostCtx.Target = "host" or "vm"): bash/zsh/sh → managed-block append in the user's rc file (UseDropin =false); fish → per-candy drop-in in ~/.config/fish/conf.d/ (UseDropin=true).

Returns nil when the candy has no shell: block.

func CompileSystemPackageSteps added in v0.2026190.848

func CompileSystemPackageSteps(layer CandyModel, img *ResolvedBox, _ HostContext) []InstallStep

CompileSystemPackageSteps emits SystemPackagesStep(s) for the candy's package sections, honoring the distro-tag-wins-over-build-format rule from today's writeCandySteps.

Phase 1: walk img.Distro tags in order; first match wins. If a tag section is found, emit ONE install step using that section and stop.

Phase 2: if no tag matched, walk img.BuildFormats in order; emit one install step per format section that has packages. (Today's writeCandySteps does this to support images that install both rpm and aur packages, for example.)

For the IR we additionally break each install into the three-phase structure (prepare/install/cleanup) so the host target can gate PhasePrepare on --allow-repo-changes. The embedded vocabulary (charly/charly.yml) currently has only one phase per format (the monolithic install_template); Task 4 will split templates into phases. Until then, we emit everything as PhaseInstall. CompileSystemPackageSteps resolves a candy's package surface for an image via the distro-specificity CASCADE and emits ONE SystemPackagesStep for the image's primary format. img.Distro is the most-specific-first tag chain (e.g. [debian:13, debian] or [ubuntu:24.04, ubuntu]); the candy's top-level package: list (layer.TopPackages) is the always-included BASE.

  • packages = UNION of the base + every matching tag section's packages (dedup), so a shared package at one level plus extras at another accumulate.
  • repo/copr/options/exclude/module = the MOST-SPECIFIC matching level that declares the field wins (a version's repo overrides the bare distro's).

img.Distro is most-specific-first, so iterating it in REVERSE (least → most specific) and letting later writes win yields most-specific-wins for the Raw extras while packages union regardless of order. fedora/arch reach their packages via the bare-distro tag (img.Distro = [fedora] / [arch]); there is no format-section fallback — the deb collapse that caused non-deterministic repo selection is gone (per-distro tag sections never share a mutable section).

func StepFromView added in v0.2026190.848

func StepFromView(v spec.InstallStepView) (InstallStep, error)

StepFromView reconstructs the concrete InstallStep a view projects. An unknown Kind is a hard error (the wire carried a step kind this charly does not know — a genuine version/contract breach, never silently dropped).

type JumpKind added in v0.2026190.848

type JumpKind = kit.JumpKind

type LocalPkgDef

type LocalPkgDef = spec.LocalPkg

type LocalPkgInstallStep

type LocalPkgInstallStep struct {
	PkgbuildRef string // the layer's `localpkg:` value (e.g. "pkg/arch") — a hint, resolved at emit
	CandyName   string
	CandyDir    string // layer source dir — one anchor for the relative PKGBUILD search
	ProjectDir  string // the deploy project dir (os.Getwd() at deploy time) — the other anchor

	// Format is the package-format name whose `local_pkg:` config drives this
	// step (e.g. "pac"). "" when the target distro declares no localpkg-capable
	// format — the executor then treats the step as a clean no-op.
	Format string

	// LocalPkg is the format's localpkg contract resolved from the embedded build vocabulary (charly/charly.yml) at
	// compile time (DistroDef.LocalPkgFormat). It carries the build/install
	// templates, package glob, source-dir sentinel, and probe command — so the
	// executor renders every package-manager command from config instead of
	// hardcoding build/install/glob literals. The install command auto-resolves
	// the package's dependencies from the target's repos (pacman -U / dnf
	// install / apt-get install), so there is no dep-closure builder. Nil when
	// Format == "".
	LocalPkg *LocalPkgDef
}

--------------------------------------------------------------------------- LocalPkgInstallStep — build a bundled PKGBUILD on the host (makepkg) and install the resulting `.pkg.tar.zst` onto a pac-based deploy target. ---------------------------------------------------------------------------

LocalPkgInstallStep is the IR form of a candy's `localpkg:` field — a pointer at a bundled Arch PKGBUILD directory (relative to the candy dir or the project root). It is the proper-package counterpart of the charly candy's ad-hoc curl-a-binary `cmd:` task: on an Arch/CachyOS DEPLOY target the package is built from the repo's bundled PKGBUILD on the HOST (`makepkg`), the resulting artifact is transferred to the target, and `pacman -U`-installed — so `charly` lands as the tracked `opencharly-git` package at /usr/bin/charly rather than an untracked binary at /usr/local/bin/charly.

Like ApkInstallStep, the step is compiled REGARDLESS of target and each DeployTarget decides whether to execute or skip:

  • the external local deploy (Arch/CachyOS host) and external vm deploy (Arch/CachyOS guest) EXECUTE it via the RunHostStep host-engine leg (build on host → transfer → pacman -U on the target).
  • On a NON-pac deploy target the executor records a clean skip (a Fedora / Debian host has no pacman; the candy's own `cmd:` task curls the binary there as the documented fallback).
  • The IMAGE build (generate.go writeCandySteps) AND the pod-overlay build-emit RENDER the localpkg IMAGE install via renderLocalPkgImageInstall: a PRODUCTION box DOWNLOADS the published release, a DISPOSABLE check bed BUILDS the in-development package on the host and COPYs it in (both install via the SAME dep-resolving install template). The pod-overlay build-emit routes through candy/plugin-installstep's `step:local-pkg-install` OpEmit, which calls back the host `step-emit` seam (stepEmitLocalPkgInstall) — the build engine stays in core. A distro with no localpkg-capable format (LocalPkg==nil) renders nothing; the candy's own COPY/curl `cmd:` task is the fallback there.
  • the android / k8s substrates (external) SKIP it (no Arch package surface).

The PKGBUILD location is resolved at EMIT time (not compile time), so the step carries only the author's hint (`PkgbuildRef`) plus the candy's source dir + the deploy project dir for the walk-up search. When no PKGBUILD is found the step is a no-op (the candy's existing curl/COPY task is the fallback).

func (*LocalPkgInstallStep) Kind

func (s *LocalPkgInstallStep) Kind() StepKind

func (*LocalPkgInstallStep) RequiresGate

func (s *LocalPkgInstallStep) RequiresGate() Gate

func (*LocalPkgInstallStep) Reverse

func (s *LocalPkgInstallStep) Reverse() []ReverseOp

Reverse returns no ledger ops — the package is the deploy substrate's own pacman-tracked package, removed (if ever) via `pacman -R opencharly-git` by the operator, not by deploy teardown. Mirrors ApkInstallStep's empty Reverse.

func (*LocalPkgInstallStep) Scope

func (s *LocalPkgInstallStep) Scope() Scope

Scope is system — installing a pacman package mutates global package state.

func (*LocalPkgInstallStep) Venue

func (s *LocalPkgInstallStep) Venue() Venue

Venue is host-native — makepkg runs on the host (like the aur builder), then the artifact is shipped to the target and installed via pacman.

type MCPProvideEntry added in v0.2026190.848

type MCPProvideEntry = spec.MCPProvideEntry

type MCPServerYAML added in v0.2026190.848

type MCPServerYAML = spec.MCPServerYAML

type NestedExecutor added in v0.2026190.848

type NestedExecutor = kit.NestedExecutor

type NestedJump added in v0.2026190.848

type NestedJump = kit.NestedJump

type Op

type Op = spec.Op

type OpStep

type OpStep struct {
	Op           *Op
	CandyName    string
	CandyDir     string
	CtxPath      string // absolute layer-dir path replacing "/ctx/" on host
	ResolvedUser string // uid:gid or "root" after resolveUserSpec

	// To is the home-resolved copy/download destination for the DEPLOY path.
	// The compiler tokenizes the task's `to:` (~ / ${HOME} / $HOME → {{.Home}})
	// here; InstallPlan.ResolveHome substitutes the destination's real home at
	// emit. execTask uses this (not the raw Task.To) for PutFile, so a
	// `copy: to: ${HOME}/...` lands in the actual guest/host home instead of a
	// literal "${HOME}" directory under sudo (HOME=/root). Empty when the task
	// has no `to:`. The OCI build emitter reads Task.To directly (build-time
	// ENV expands ${HOME}), so it is unaffected by this field.
	To string

	// CandyVars are the candy manifest `vars:` map propagated into the task
	// script as exports. Build-time gets these via Containerfile ENV
	// directives (emitVarsEnv); host/local-deploy time has no equivalent
	// mechanism, so the renderer emits `export K=V` lines from this field.
	// Without this, candies like `kubernetes` whose download URLs reference
	// ${K3D_VERSION} fetched an empty path-component at deploy time and
	// curl 404'd.
	CandyVars map[string]string

	// Distros is the image's distro tag chain (img.Tags), carried so the act-emit
	// enabler can pass it to a state-provision plugin verb's RenderProvisionScript
	// (e.g. the cross-distro package resolution). Empty for non-plugin ops; the
	// unix_group act ignores it, but a future package/service state-provision plugin
	// reads it.
	Distros []string
}

OpStep wraps a raw Op so the IR compiler doesn't have to transform it further. The OCI target and host target both understand Op shapes (cmd / mkdir / copy / write / link / download / setcap / build) and emit the appropriate directives. CtxPath substitutes for /ctx/ in cmd bodies on the host target (container RUN directives keep /ctx via bind-mount, which doesn't exist on the host).

func (*OpStep) Kind

func (s *OpStep) Kind() StepKind

func (*OpStep) RequiresGate

func (s *OpStep) RequiresGate() Gate

func (*OpStep) Reverse

func (s *OpStep) Reverse() []ReverseOp

func (*OpStep) Scope

func (s *OpStep) Scope() Scope

func (*OpStep) Venue

func (s *OpStep) Venue() Venue

type PackageItem added in v0.2026190.848

type PackageItem = vmshared.PackageItem

type PackageSection added in v0.2026190.848

type PackageSection struct {
	FormatName string         // "rpm", "deb", "pac", "aur", etc.
	Packages   []string       // extracted from Raw["package"] for quick access
	Raw        map[string]any // all fields from YAML, passed to templates
}

PackageSection represents a generic format-specific package config in the candy manifest. All fields from the YAML section are available in Raw for template rendering.

type Phase

type Phase = spec.Phase

type PortSpec added in v0.2026190.848

type PortSpec = spec.PortSpec

type PreemptibleConfig added in v0.2026190.848

type PreemptibleConfig = spec.PreemptibleConfig

type ProvidesConfig added in v0.2026190.848

type ProvidesConfig struct {
	Env []EnvProvideEntry `yaml:"env,omitempty" json:"env,omitempty"`
	MCP []MCPProvideEntry `yaml:"mcp,omitempty" json:"mcp,omitempty"`
}

ProvidesConfig holds all resolved provides entries in charly.yml.

type RebootStep

type RebootStep struct {
	CandyName string
}

RebootStep requests a reboot of the deploy target after this candy's steps. It is emitted (last in the candy) when a candy declares `reboot: true` — the canonical case is a kernel-module candy (e.g. nvidia-open-dkms) whose module only loads on a fresh boot with nouveau blacklisted.

Only a rebootable venue acts on it: the external vm deploy reboots the guest over SSH (the host's RunHostStep RebootStep handler, gated on the rebootable-venue flag the vm substrate sets) and waits for the boot_id to change. OCITarget / PodDeployTarget have no machine to reboot at build time and skip it (the external k8s substrate does not consume the IR at all); the external local deploy refuses to reboot the host venue unattended (skip + note). Mirrors the ApkInstallStep "only one target executes" pattern.

func (*RebootStep) Kind

func (s *RebootStep) Kind() StepKind

func (*RebootStep) RequiresGate

func (s *RebootStep) RequiresGate() Gate

func (*RebootStep) Reverse

func (s *RebootStep) Reverse() []ReverseOp

Reverse is empty — a reboot is not a persistent artifact to undo.

func (*RebootStep) Scope

func (s *RebootStep) Scope() Scope

func (*RebootStep) Venue

func (s *RebootStep) Venue() Venue

type RepoChangeStep

type RepoChangeStep struct {
	Format    string // "rpm" | "deb" | "pac"
	File      string // absolute path of the repo file
	Content   string // rendered repo file body
	Checksum  string // sha256 of Content, for idempotency check at install
	CandyName string
}

RepoChangeStep records a repo config file mutation (e.g. adding rpmfusion-free.repo to /etc/yum.repos.d/). Distinct from SystemPackagesStep's PhasePrepare because the compiler often synthesizes these from `cmd:` tasks that happen to install a -release.rpm — we want them tracked separately so `charly bundle del` can reverse them precisely.

func (*RepoChangeStep) Kind

func (s *RepoChangeStep) Kind() StepKind

func (*RepoChangeStep) RequiresGate

func (s *RepoChangeStep) RequiresGate() Gate

func (*RepoChangeStep) Reverse

func (s *RepoChangeStep) Reverse() []ReverseOp

func (*RepoChangeStep) Scope

func (s *RepoChangeStep) Scope() Scope

func (*RepoChangeStep) Venue

func (s *RepoChangeStep) Venue() Venue

type RepoSpec

type RepoSpec struct {
	// Fields captured verbatim from the candy manifest. Different formats use
	// different subsets (rpm has url/id/key; deb has suite/components;
	// pac has url/keys). Carried as map so the template-rendered host
	// and container forms can pick what they need.
	Raw map[string]any
}

type ResolvedBox added in v0.2026190.848

type ResolvedBox = buildkit.ResolvedBox

type ReverseOp

type ReverseOp = spec.ReverseOp

type ReverseOpKind

type ReverseOpKind = spec.ReverseOpKind

type RouteConfig added in v0.2026190.848

type RouteConfig struct {
	Host string
	Port string
}

RouteConfig represents a route file declaration.

type SSHExecutor added in v0.2026190.848

type SSHExecutor = kit.SSHExecutor

func SSHParamsForVm added in v0.2026190.848

func SSHParamsForVm(deployName string) *SSHExecutor

SSHParamsForVm returns an SSHExecutor pointing at the VM's managed ssh-config alias (charly-<deployName>). All connection details — User, Port, IdentityFile, host-key checking — live in the Host stanza that `charly vm create` / `charly bundle add` published into ~/.config/charly/ssh_config; ssh(1) reads them from there. Our SSHExecutor needs only the alias as Host.

type Scope

type Scope = spec.Scope

func OpStepScope

func OpStepScope(userDir string) Scope

func ScopeFromName added in v0.2026190.848

func ScopeFromName(name string) Scope

type SecretYAML added in v0.2026190.848

type SecretYAML = spec.SecretYAML

type SecurityConfig added in v0.2026190.848

type SecurityConfig = spec.SecurityConfig

type ServiceCustomStep

type ServiceCustomStep struct {
	Name        string // e.g. "charly-ollama-ollama"
	UnitText    string // fully rendered unit content
	UnitPath    string // absolute install path
	TargetScope Scope  // ScopeSystem or ScopeUser
	Enable      bool
	CandyName   string
}

ServiceCustomStep writes and enables a full service definition. The unit text is already rendered by the compiler from the candy's generic `services:` entry via the target init system's service_template.

func (*ServiceCustomStep) Kind

func (s *ServiceCustomStep) Kind() StepKind

func (*ServiceCustomStep) RequiresGate

func (s *ServiceCustomStep) RequiresGate() Gate

func (*ServiceCustomStep) Reverse

func (s *ServiceCustomStep) Reverse() []ReverseOp

func (*ServiceCustomStep) Scope

func (s *ServiceCustomStep) Scope() Scope

func (*ServiceCustomStep) Venue

func (s *ServiceCustomStep) Venue() Venue

type ServiceEntry added in v0.2026190.848

type ServiceEntry = spec.ServiceEntry

type ServicePackagedStep

type ServicePackagedStep struct {
	Unit          string // e.g. "postgresql.service"
	TargetScope   Scope  // ScopeSystem → /etc/systemd/system/; ScopeUser → ~/.config/systemd/user/
	Enable        bool
	OverridesText string // rendered drop-in (.conf) content; "" if no overrides
	OverridesPath string // computed absolute path for the drop-in file
	CandyName     string // for ledger + drop-in naming
	PriorEnabled  bool   // populated at install time (before enable); used for teardown restore
}

ServicePackagedStep enables a systemd unit that arrived via a distro package (e.g. postgresql.service). Optional drop-in overrides are written alongside the packaged unit without touching it. This step is only emitted when rendering to a systemd-based init system; supervisord targets emit a warning-and-skip.

func (*ServicePackagedStep) Kind

func (s *ServicePackagedStep) Kind() StepKind

func (*ServicePackagedStep) RequiresGate

func (s *ServicePackagedStep) RequiresGate() Gate

func (*ServicePackagedStep) Reverse

func (s *ServicePackagedStep) Reverse() []ReverseOp

func (*ServicePackagedStep) Scope

func (s *ServicePackagedStep) Scope() Scope

func (*ServicePackagedStep) Venue

func (s *ServicePackagedStep) Venue() Venue

type ShellConfig added in v0.2026190.848

type ShellConfig = vmshared.ShellConfig

type ShellExecutor added in v0.2026190.848

type ShellExecutor = kit.ShellExecutor

type ShellHookStep

type ShellHookStep struct {
	CandyName string
	EnvVars   map[string]string
	PathAdd   []string // already {{.Home}}-substituted to absolute paths
	EnvFile   string   // computed path (~/.config/opencharly/env.d/<candy>.env); populated at install
}

ShellHookStep records the env vars and PATH contributions a candy makes to the user's shell environment. On the OCI target these translate to `ENV K=V` directives in the Containerfile. On the host target they become `~/.config/opencharly/env.d/<candy>.env` plus a managed block in the user's shell init that sources the env.d directory.

func CompileShellHookStep added in v0.2026190.848

func CompileShellHookStep(layer CandyModel, _ *ResolvedBox) *ShellHookStep

CompileShellHookStep returns a ShellHookStep for the candy's env: and path_append: fields, or nil if the candy contributes neither.

Home resolution is DEFERRED: `~`/`$HOME` are rewritten to the literal `{{.Home}}` token rather than expanded against img.Home. Each DeployTarget resolves the token at emit time against the home of the actual deploy destination — img.Home for the OCI/pod-overlay build, the host home for the local deploy target, and the GUEST home (via the SSH executor's ResolveHome) for the vm deploy. Baking img.Home here was wrong for VM deploys: the synthetic plan's Home was the host operator's home, so env.d on the guest pointed at /home/<operator> instead of /home/<guest-user>. See InstallPlan.ResolveHome.

func (*ShellHookStep) Kind

func (s *ShellHookStep) Kind() StepKind

func (*ShellHookStep) RequiresGate

func (s *ShellHookStep) RequiresGate() Gate

func (*ShellHookStep) Reverse

func (s *ShellHookStep) Reverse() []ReverseOp

func (*ShellHookStep) Scope

func (s *ShellHookStep) Scope() Scope

func (*ShellHookStep) Venue

func (s *ShellHookStep) Venue() Venue

type ShellSnippetStep

type ShellSnippetStep struct {
	CandyName   string   // candy this snippet belongs to (also Marker source)
	Origin      string   // "<candy>" or "box" or "deploy" (for ledger refcount + LabelShell origin)
	Shell       string   // bash | zsh | fish | sh
	Snippet     string   // rendered body, ${SHELL_NAME}-substituted, ready to write
	PathAppend  []string // already rendered into Snippet by the compiler; tracked here for label round-trip / overlay
	Destination string   // resolved per-target at compile time; absolute path on the target
	Marker      string   // managed-block marker tag (= CandyName) — consumed by the kit walk's managed-block splice (sdk/kit/profile.go)
	UseDropin   bool     // true: write whole file (fish, container drop-in); false: managed-block append into existing rc file
	Priority    int      // load-order hint, 0 = default
}

ShellSnippetStep records a per-(candy, shell) init snippet emitted from a candy's `shell:` block. The compiler emits one step per (candy, shell) pair after applying the selection rule (per-shell ByShell entry wins over generic, with ${SHELL_NAME} substitution).

Per-target rendering:

  • OCITarget: snippet bytes are content-address-staged and COPYed to a system-wide drop-in (/etc/profile.d/charly-<candy>.sh for bash/zsh/sh, /etc/fish/conf.d/charly-<candy>.fish for fish).
  • the external local / vm deploy (kit.WalkPlans on the venue): managed-block append to the user's rc file (~/.bashrc, ~/.zshrc, ~/.profile) keyed by `# opencharly:begin <Marker>` fence; for fish, a per-candy drop-in at ~/.config/fish/conf.d/charly-<candy>.fish (no fence needed, file IS the unit). UseDropin discriminates the two paths.
  • the external k8s substrate: does not consume the InstallPlan IR at all (the host generates a Kustomize tree separately — no shell snippet).

func (*ShellSnippetStep) Kind

func (s *ShellSnippetStep) Kind() StepKind

func (*ShellSnippetStep) RequiresGate

func (s *ShellSnippetStep) RequiresGate() Gate

func (*ShellSnippetStep) Reverse

func (s *ShellSnippetStep) Reverse() []ReverseOp

func (*ShellSnippetStep) Scope

func (s *ShellSnippetStep) Scope() Scope

Scope: SnippetStep is system-wide for build-mode (Container drop-ins live under /etc/profile.d/ — root-owned), and user-profile for host/vm deploy- mode (managed block in ~/.bashrc etc.). The compiler picks the right Scope when constructing the step based on the destination path; the step records the choice so each emitter doesn't have to re-derive it.

func (*ShellSnippetStep) Venue

func (s *ShellSnippetStep) Venue() Venue

type ShellSpec added in v0.2026190.848

type ShellSpec = vmshared.ShellSpec

func ResolveShellSpec added in v0.2026190.848

func ResolveShellSpec(cfg *ShellConfig, shell string) (*ShellSpec, string, []string, bool)

ResolveShellSpec applies the per-shell-wins-over-generic selection rule. Returns the resolved spec, the rendered init body (with ${SHELL_NAME} substituted for the generic case), the path_append slice, and whether the shell has anything to contribute. Generic init wins when no per-shell override exists; per-shell wins otherwise.

type Step added in v0.2026190.848

type Step = vmshared.Step

type StepBatch added in v0.2026190.848

type StepBatch = spec.StepBatch

type StepKind

type StepKind = spec.StepKind

type SystemPackagesStep

type SystemPackagesStep struct {
	Format   string     // "rpm" | "deb" | "pac"
	Phase    Phase      // PhasePrepare | PhaseInstall | PhaseCleanup
	Packages []string   // package names (for Reverse)
	Repos    []RepoSpec // repository entries from the candy manifest (drives PhasePrepare)
	Options  []string   // format-specific install flags
	Copr     []string   // RPM-only: COPR repos to enable/disable
	Modules  []string   // RPM-only: DNF modules to enable
	Exclude  []string   // RPM-only: packages to exclude
	Keys     []string   // PAC-only: GPG keys to trust

	// CacheMounts and RawInstallContext are passed to template rendering.
	// These are populated by the compiler and consumed by the OCI target;
	// the host target ignores CacheMounts (no BuildKit outside containers).
	CacheMount        []CacheMountSpec
	RawInstallContext map[string]any
}

SystemPackagesStep installs packages via a distro package manager. One step typically expands to (PhasePrepare + PhaseInstall + PhaseCleanup) stages; the compiler emits one SystemPackagesStep per phase so the host target can gate PhasePrepare on --allow-repo-changes.

func BuildSystemPackagesStep added in v0.2026190.848

func BuildSystemPackagesStep(format string, phase Phase, packages []string, raw map[string]any, cacheMounts []CacheMountDef) *SystemPackagesStep

BuildSystemPackagesStep constructs a SystemPackagesStep from a PackageSection's Raw map, extracting the well-known structured fields (repos, options, copr, modules, exclude, keys) for gate checkuation while also preserving the full Raw map for template rendering later.

func (*SystemPackagesStep) Kind

func (s *SystemPackagesStep) Kind() StepKind

func (*SystemPackagesStep) RequiresGate

func (s *SystemPackagesStep) RequiresGate() Gate

func (*SystemPackagesStep) Reverse

func (s *SystemPackagesStep) Reverse() []ReverseOp

func (*SystemPackagesStep) Scope

func (s *SystemPackagesStep) Scope() Scope

func (*SystemPackagesStep) Venue

func (s *SystemPackagesStep) Venue() Venue

type TagPkgConfig added in v0.2026190.848

type TagPkgConfig struct {
	Package []string       `yaml:"package,omitempty" json:"package,omitempty"`
	Raw     map[string]any `yaml:"-"`
}

TagPkgConfig is a distro/version-specific package config (e.g. `debian:13:`, `ubuntu:24.04:`, `fedora:43:`). Packages are installed using the primary format's tool (dnf, apt, pacman). Raw captures the full YAML so that tag sections can carry `repos:`, `options:`, `keys:` — the same schema as the generic format section — for version-specific upstream repo configurations.

type Venue

type Venue = spec.Venue

type VolumeYAML added in v0.2026190.848

type VolumeYAML = spec.VolumeYAML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL