Skip to content

plugin-substrate

Placement compiled-in (in-process)
Source github.com/opencharly/plugin-substrate/candy/plugin-substrate
Candy plugin-substrate

This plugin is listed in charly/charly.yml’s compiled_plugins:, so its providers are compiled into the charly binary and register in-process.

The reserved words this plugin serves:

  • firecracker — kind class
  • kindcluster — kind class
  • kubernetes — kind class
  • kubevirt — kind class
  • local — kind class
  • pod — kind class
  • vm — kind class

The SUBSTRATE structural deploy KINDS — pod / vm / kubernetes / local / kubevirt / kindcluster / firecracker — relocated into ONE candy (C2-substrate; formerly the shared built-in standaloneKind). Each substrate kind is BOTH a standalone TEMPLATE (a bare vm:/pod: block → the typed template map uf.Pod/uf.VM/…, the PRIMARY VM authoring form) AND a DEPLOY (from:/image: cross-ref or resource members → uf.Deploy). Its value is RICH + core-referencing (#Vm/#Deploy/#LibvirtDomain/…), so — unlike group’s small self-contained #GroupInput — it cannot be re-decoded from op.Params nor validated by a self-contained plugin schema. So the HOST pre-decodes the CANONICAL node via the core loader (buildDeployNode / decodeNodeValue — the single decode source of truth), validates its value against the KEPT #Value core def, and threads it in op.Env; this plugin’s OpLoad ECHOES it and the host folds the echo into uf.Deploy (deploy) or the typed template map (template — the C2-substrate TEMPLATE fold arm extending F5’s deploy-only fold), byte-equivalent to the former in-proc standaloneKind decode. COMPILED-IN (in the embedded compiled_plugins:), like the tier-1 kinds and group, because these are core deploy primitives every box/submodule must always resolve; also serves out-of-process via cmd/serve. P14a added the COLLECTOR OpStatusCollect on the same kind-provider Invoke (dispatched by word pod/vm/kubernetes/local/kubevirt/kindcluster/firecracker): the cleanly-movable status collectors — pod live (snapshot + live mounts + tool probes) + local (install-ledger) + the probes — relocated here from charly core, reached by the host’s charly status fan-out; the deploy-cone-coupled enrichment + the vm/kubernetes/kubevirt collectors live here too (relocated from core in K5), as do the kindcluster and firecracker collectors (later waves). kubevirt is the cluster-scheduled VM substrate (a KubeVirt VM on a cluster), declaring the ssh venue WITHOUT exclusive_venue + a deep OpValidate (the source-arm XOR + GPU resource XOR).

The CUE schema below is the authoritative grammar for this plugin’s input. It is the same single source that generates the plugin’s Go parameter types and answers the runtime Describe RPC, so this page cannot disagree with either.

// schema/firecracker.cue — the `kind: firecracker` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE. This plugin's `kind: firecracker` capability declares the gate def
// (`plugin.go`: `InputDef: "#FirecrackerValue"`), so the host resolves it from that DECLARATION and
// reads it out of the schema composed from the base and every served plugin unit.
// opencharly/spec#304 unit 7 moved it here.
//
// WHAT CAME WITH IT: thirty-two `#Firecracker*` defs — the top-level `#Firecracker`, thirty named
// sub-defs, and the `#FirecrackerValue` twin, which lives at the foot of this file. What STAYS in
// the contract and is CITED in this file's code — `schema.#Step` (the plan), `schema.#VmCloudInit`
// (cloud_init) and `schema.#DeployValue` (the twin's other arm) — is spelled `schema.#…`.
//
// THE BODY DESCRIBES A HOST, not a running guest: the VMM, the kernel, the network, containerd and
// the runner pools are the host's capabilities; the microVM shape rides beside them. Its resolve
// envelope therefore carries the RAW body and nothing projected — the venue fills the host.
import "github.com/opencharly/spec/schema"
#Firecracker: {
description?: string
plan?: [...schema.#Step]
// --- the HOST side: how this KVM host runs microVMs -------------------------
// vmm pins the Firecracker release installed on the host; absent → the host's
// own `firecracker` from PATH (the upstream default).
vmm?: #FirecrackerVMM @go(VMM,optional=nillable)
kernel: #FirecrackerKernel @go(Kernel)
network?: #FirecrackerNetwork @go(Network,optional=nillable)
containerd?: #FirecrackerContainerd @go(Containerd,optional=nillable)
fireactions?: #FirecrackerFireactions @go(Fireactions,optional=nillable)
// --- the microVM INSTANCE --------------------------------------------------
// image is required of a DEPLOY and optional here, because a host-only template is
// a legal authored shape: it names the kernel and the host's capabilities, and the
// instances it serves bring their OWN image (the `firecracker-host` profile plus a
// deploy that names it via `from:`). The plugin's OpValidate enforces "a deploy has
// an image"; the schema keeps the host form authorable.
image?: #FirecrackerImage @go(Image,optional=nillable)
machine?: #FirecrackerMachine @go(Machine,optional=nillable)
mmds?: #FirecrackerMMDS @go(MMDS,optional=nillable)
cloud_init?: schema.#VmCloudInit @go(CloudInit,optional=nillable)
vsock?: #FirecrackerVsock @go(Vsock,optional=nillable)
console?: #FirecrackerConsole @go(Console,optional=nillable)
snapshot?: #FirecrackerSnapshot @go(Snapshot,optional=nillable)
}
// #FirecrackerVMM pins the VMM release and its integrity, and selects the jailer
// posture. The jailer is OFF by default: it is Firecracker's production hardening
// posture (a privileged jailer drops privileges and execs the VMM), and the
// integration's upstream orchestrator runs the VMM as a plain process.
#FirecrackerVMM: {
version: string & !="" // e.g. "v1.17.0"
sha256?: string // the release tarball digest, verified before install
binary_path?: string // where the binary lands on the host
jailer?: #FirecrackerJailer @go(Jailer,optional=nillable)
}
#FirecrackerJailer: {
enabled: *false | true @go(Enabled,type=bool)
// One jail per microVM needs its OWN uid and gid; uid_base/gid_base are the
// allocation floor the substrate increments per VM (required when enabled).
uid_base?: int & >=1 @go(UIDBase,type=int)
gid_base?: int & >=1 @go(GIDBase,type=int)
chroot_base?: string
cgroup_version?: *"2" | "1" @go(CgroupVersion)
// resource_limits are the jailer's own rlimits, `<resource>=<value>` verbatim
// (fsize, no-file).
resource_limits?: [...string] @go(ResourceLimits)
}
// #FirecrackerKernel is the guest kernel the microVMs boot. `from` is an artefact
// reference (an OCI artefact whose layer carries the kernel, or a pinned URL);
// `path` is a file already present on the host. At most one form is meaningful — set
// `from` OR `path`, never both — but neither is REQUIRED by this closed schema: a template
// that names neither inherits the host's own kernel, which is what an operator-managed
// firecracker host already carries. (The earlier text claimed "exactly one is required",
// which no enforcer anywhere made true; the schema is the authority and this states it.)
#FirecrackerKernel: {
from?: string & !="" // artefact ref / URL
path?: string & !="" // host path
sha256?: string // integrity for either form
// cmdline — the kernel command line. The guest's IP, when the network is a
// TAP, arrives HERE (`ip=<guest>::<host>:<mask>::<iface>:off`), the same
// channel the CNI path uses; the substrate defaults it when absent.
cmdline?: string
initrd?: string
}
// #FirecrackerNetwork is how guests reach the network. `tap` (the default) is one
// TAP device per microVM with the guest's address delivered on the kernel command
// line; `cni` is the netns+bridge+tc-redirect-tap path the upstream orchestrator
// uses, which needs CAP_SYS_ADMIN.
#FirecrackerNetwork: {
mode: *"tap" | "cni"
tap?: #FirecrackerTAP @go(Tap,optional=nillable)
cni?: #FirecrackerCNI @go(CNI,optional=nillable)
// egress_iface is the host uplink to masquerade through; "auto" = the
// default-route interface.
egress_iface?: *"auto" | string @go(EgressIface)
forwarding?: #FirecrackerForwarding @go(Forwarding,optional=nillable)
// resolver — the guest's /etc/resolv.conf servers. A stock Firecracker guest
// image ships none, so IP egress can work while DNS does not; naming them here
// is what makes the difference checkable.
resolver?: [...string] @go(Resolver)
mtu?: int & >=68 & <=65535 @go(MTU,type=int)
}
#FirecrackerTAP: {
// name is a template; `{n}` is replaced by the per-lease index.
name?: string
// subnet + prefix allocate one /prefix per microVM (host_offset is the host's
// own address inside it).
subnet?: string
prefix?: *30 | int & >=8 & <=30 @go(Prefix,type=int)
host_offset?: *1 | int & >=1 @go(HostOffset,type=int)
}
#FirecrackerCNI: {
network_name?: string
conf_dir?: string
bin_dir?: string
cache_dir?: string
subnet?: string
}
// #FirecrackerForwarding is the host forwarding posture. `append-accept` inserts an
// ordered FORWARD accept (the host's own policy may be DROP, which a separate nft
// table cannot override); `netns` puts guest traffic in a namespace whose
// forwarding the substrate controls.
#FirecrackerForwarding: {
ip_forward: *true | false @go(IPForward,type=bool)
policy?: *"append-accept" | or(_firecrackerForwardingPolicyWord) @go(Policy)
}
// #FirecrackerMachine is the microVM shape. vcpu_count and mem_size_mib mirror
// Firecracker's own machine-config (vcpu_count is 1–32, and either 1 or even; smt is
// x86-only).
#FirecrackerMachine: {
vcpu_count?: int & >=1 & <=32 @go(VCPUCount,type=int)
mem_size_mib?: int & >=128 @go(MemSizeMiB,type=int)
smt?: bool
huge_pages?: *"None" | or(_hugePagesWord) @go(HugePages)
// cpu_template mirrors Firecracker's (deprecated) CpuTemplate enum; it exists
// for snapshot/clone portability across hosts.
cpu_template?: *"None" | or(_cpuTemplateWord) @go(CPUTemplate)
drives?: [...#FirecrackerDrive] @go(Drives)
// rate_limits bound the interfaces and the root drive; an omitted bucket is
// unlimited (Firecracker's own semantics).
rate_limits?: #FirecrackerRateLimits @go(RateLimits,optional=nillable)
}
// #FirecrackerDrive is one virtio-block device. The root drive is built from the
// image; extra drives are named here.
#FirecrackerDrive: {
drive_id!: string & !="" @go(DriveID)
path?: string @go(Path)
is_root_device?: bool @go(IsRootDevice)
is_read_only?: bool @go(IsReadOnly)
cache_type?: *"Unsafe" | "Writeback" @go(CacheType)
// io_engine Async needs a host kernel newer than 5.10.51.
io_engine?: *"Sync" | "Async" @go(IOEngine)
blk_size?: int & >=512 @go(BlkSize,type=int)
// discard is only honoured by a writable virtio-block device on the Sync engine.
discard?: bool @go(Discard)
rate_limiter?: #FirecrackerRateLimiter @go(RateLimiter,optional=nillable)
}
#FirecrackerRateLimits: {
network_in?: #FirecrackerRateLimiter @go(NetworkIn,optional=nillable)
network_out?: #FirecrackerRateLimiter @go(NetworkOut,optional=nillable)
rootfs?: #FirecrackerRateLimiter @go(Rootfs,optional=nillable)
serial?: #FirecrackerRateLimiter @go(Serial,optional=nillable)
}
// #FirecrackerRateLimiter is Firecracker's token bucket: the rate is
// size/refill_time, consumption below the refill rate is unbounded (bursts).
#FirecrackerRateLimiter: {
bandwidth?: #FirecrackerTokenBucket @go(Bandwidth,optional=nillable)
ops?: #FirecrackerTokenBucket @go(Ops,optional=nillable)
}
#FirecrackerTokenBucket: {
size: int & >0 @go(Size,type=int)
refill_time: int & >0 @go(RefillTime,type=int) // milliseconds
one_time_burst?: int & >=0 @go(OneTimeBurst,type=int)
}
// #FirecrackerImage is the microVM root drive: the artefact charly BUILT (a
// kind:firecracker deploy's image is a charly-produced rootfs, not somebody else's
// container export). `format` is what the artefact's labels declare; a raw ext4
// rootfs is the file-backed form, and `resize` grows the inner filesystem to
// disk_mib on first boot (Firecracker attaches FILES — a truncated file alone does
// not grow the filesystem inside it).
#FirecrackerImage: {
from: string & !="" @go(From)
format?: *"ext4" | "raw" @go(Format)
disk_mib?: int & >=128 @go(DiskMiB,type=int)
resize?: *true | false @go(Resize,type=bool)
}
// #FirecrackerMMDS is the metadata service inside the guest. V2 is a session-token
// IMDSv2 shape; the upstream orchestrator reads exactly
// latest/meta-data/fireactions/{runner_jit_config,hostname,shutdown_on_exit} from
// it, which is why the tree is authored under `latest/meta-data` here.
#FirecrackerMMDS: {
version?: *"V2" | "V1" @go(Version)
ipv4_address?: string @go(IPv4Address)
// metadata is the tree under latest/meta-data (typed-open: its shape is the
// consumer's business — the orchestrator's, the candy's, the operator's).
metadata?: {[string]: _} @go(Metadata)
}
#FirecrackerVsock: {
// guest_cid must be >= 3 (2 is the host); the substrate allocates one per
// microVM when absent, since one device serves all guests.
guest_cid?: int & >=3 @go(GuestCID,type=int)
uds_path?: string @go(UDSPath)
}
#FirecrackerConsole: {
serial_out_path?: string @go(SerialOutPath)
rate_limiter?: #FirecrackerRateLimiter @go(RateLimiter,optional=nillable)
log_path?: string @go(LogPath)
log_level?: *"Info" | or(_firecrackerConsoleLogLevelWord) @go(LogLevel)
metrics_path?: string @go(MetricsPath)
}
#FirecrackerSnapshot: {
create?: bool @go(Create)
mem_file_path?: string @go(MemFilePath)
snapshot_path?: string @go(SnapshotPath)
snapshot_type?: *"Full" | "Diff" @go(SnapshotType)
resume?: *true | false @go(Resume,type=bool)
}
// #FirecrackerContainerd is the containerd this host runs for image storage: the
// connection, and the SNAPSHOTTER that backs a microVM root drive. Firecracker
// attaches a block device or a FILE, so only the two file/device-backed
// snapshotters can serve a root drive: `devmapper` (an LVM thin pool on a dedicated
// block device — the upstream default) and `blockfile` (a file per snapshot, which
// needs neither LVM nor a spare device). A snapshotter whose mount is a directory
// (overlayfs, native) can never work.
#FirecrackerContainerd: {
address?: string @go(Address)
namespace?: string @go(Namespace)
snapshotter: *"devmapper" | "blockfile" @go(Snapshotter)
// manage says how charly treats an existing /etc/containerd/config.toml:
// `merge` (default) keeps every setting it does not model, `full` takes the
// file over, `adopt` changes nothing and only reports.
manage?: *"merge" | or(_manageWord) @go(Manage)
version?: int & >=2 & <=3 @go(Version,type=int)
root?: string @go(Root)
state?: string @go(State)
oom_score?: int @go(OOMScore,type=int)
grpc?: #FirecrackerContainerdGRPC @go(GRPC,optional=nillable)
devmapper?: #FirecrackerDevmapper @go(Devmapper,optional=nillable)
// plugins is a typed-open passthrough for any containerd plugin table charly
// does not model yet.
plugins?: {[string]: _} @go(Plugins)
registry_mirrors?: [...#FirecrackerRegistryMirror] @go(RegistryMirrors)
service?: #FirecrackerContainerdService @go(Service,optional=nillable)
}
#FirecrackerContainerdGRPC: {
address?: string @go(Address)
uid?: int & >=0 @go(UID,type=int)
gid?: int & >=0 @go(GID,type=int)
}
// #FirecrackerDevmapper is the devmapper snapshotter's pool. `device` is the block
// device the thin pool is created on — charly provisions it (pvcreate/vgcreate/
// lvcreate + the autoextend profile) rather than leaving it to a hand-typed
// command, and refuses with a visible skip when the host cannot satisfy it.
#FirecrackerDevmapper: {
pool?: string @go(Pool)
root_path?: string @go(RootPath)
base_image_size?: string @go(BaseImageSize)
discard_blocks?: bool @go(DiscardBlocks)
fs_type?: *"ext4" | "xfs" @go(FSType)
device?: string @go(Device)
profile?: #FirecrackerThinPoolProfile @go(Profile,optional=nillable)
}
#FirecrackerThinPoolProfile: {
thin_pool_autoextend_threshold?: int & >=1 & <=100 @go(ThinPoolAutoextendThreshold,type=int)
thin_pool_autoextend_percent?: int & >=1 & <=100 @go(ThinPoolAutoextendPercent,type=int)
}
#FirecrackerRegistryMirror: {
host: string & !="" @go(Host)
endpoint?: string @go(Endpoint)
insecure?: bool @go(Insecure)
}
#FirecrackerContainerdService: {
// unit distro → keep the distribution's own containerd unit; charly → render
// one (the mixed-entry service polymorphism, per distro).
unit?: *"distro" | "charly" @go(Unit)
limits?: {[string]: _} @go(Limits)
}
// #FirecrackerFireactions is the OPTIONAL runner-pool orchestrator on this host. Its
// pools are a policy for how microVMs are created and registered as GitHub Actions
// runners; the substrate RENDERS this into the orchestrator's own configuration
// (validated before it is written) and supervises it — it does not reimplement the
// scheduler.
#FirecrackerFireactions: {
version?: string & !="" @go(Version)
install?: #FirecrackerFireactionsInstall @go(Install,optional=nillable)
// bind_address defaults to LOOPBACK: the orchestrator's API is plaintext and
// unauthenticated upstream, so naming a wider address is a deliberate act.
bind_address?: *"127.0.0.1:8080" | string @go(BindAddress)
metrics?: #FirecrackerFireactionsMetrics @go(Metrics,optional=nillable)
log_level?: *"info" | or(_firecrackerFireactionsLogLevelWord) @go(LogLevel)
github?: #FirecrackerFireactionsGitHub @go(GitHub,optional=nillable)
pools: [...#FirecrackerPool] @go(Pools)
}
#FirecrackerFireactionsInstall: {
// from_source builds the pinned tag (the upstream release binaries carry no
// version stamp without the release toolchain's ldflags).
from_source?: *true | false @go(FromSource,type=bool)
go?: string @go(Go)
}
#FirecrackerFireactionsMetrics: {
enabled: *true | false @go(Enabled,type=bool)
address?: string @go(Address)
}
// #FirecrackerFireactionsGitHub names the GitHub App credential. The private key is
// NEVER authored here: it is a secret reference resolved from the credential store
// at deploy time.
#FirecrackerFireactionsGitHub: {
app_id?: int & >0 @go(AppID,type=int)
app_private_key_secret?: string @go(AppPrivateKeySecret)
}
// #FirecrackerPool is one runner pool: a label set + a runner image + a machine
// shape, kept at a replica count.
#FirecrackerPool: {
name: string & !="" @go(Name)
replicas?: int & >=0 @go(Replicas,type=int)
shutdown_on_exit?: *true | false @go(ShutdownOnExit,type=bool)
runner: #FirecrackerRunner @go(Runner)
firecracker?: #FirecrackerPoolMachine @go(Firecracker,optional=nillable)
}
#FirecrackerRunner: {
name?: string @go(Name)
// image is a runner guest image: charly's own (a box built into a rootfs
// artefact) or an upstream-compatible one.
image: string & !="" @go(Image)
image_pull_policy?: *"IfNotPresent" | or(_imagePullPolicyWord) @go(ImagePullPolicy)
// organization is ORGANISATION-scoped: the orchestrator's GitHub calls are
// org-level only (a repository-scoped runner is not expressible).
organization?: string @go(Organization)
group_id?: int & >=0 @go(GroupID,type=int)
labels: [...string] @go(Labels)
}
#FirecrackerPoolMachine: {
machine_config?: #FirecrackerMachine @go(MachineConfig,optional=nillable)
metadata?: {[string]: _} @go(Metadata)
rate_limits?: #FirecrackerRateLimits @go(RateLimits,optional=nillable)
}
// --- vocabulary tables (S3) --------------------------------------------------
// Every closed set of words is a table keyed by word, `<x>Word` is derived from it,
// and the enum an author meets is `or(<x>Word)` — so the table and the enum cannot
// disagree and a new word is ONE row here. `@vocab` names the owner (§3.1): these
// sets are compiled into THIS plugin's module since opencharly/spec#304 unit 7 moved them with
// the body, so the owner is `plugin-substrate`.
//
// Each table is named after its word when that name is unique in the schema, and
// `<definition><Field>` when it is not; the comment above it names its site.
// #FirecrackerForwarding.policy
_firecrackerForwardingPolicy: {"append-accept": {}, netns: {}, deny: {}} @vocab(plugin-substrate)
_firecrackerForwardingPolicyWord: [for w, _ in _firecrackerForwardingPolicy {w}]
// #FirecrackerMachine.huge_pages
_hugePages: {"None": {}, "Transparent": {}, "2M": {}} @vocab(plugin-substrate)
_hugePagesWord: [for w, _ in _hugePages {w}]
// #FirecrackerMachine.cpu_template
_cpuTemplate: {
"None": {}
"C3": {}
"T2": {}
"T2S": {}
"T2CL": {}
"T2A": {}
"V1N1": {}
} @vocab(plugin-substrate)
_cpuTemplateWord: [for w, _ in _cpuTemplate {w}]
// #FirecrackerConsole.log_level
_firecrackerConsoleLogLevel: {
"Info": {}
"Error": {}
"Warning": {}
"Debug": {}
"Trace": {}
"Off": {}
} @vocab(plugin-substrate)
_firecrackerConsoleLogLevelWord: [for w, _ in _firecrackerConsoleLogLevel {w}]
// #FirecrackerContainerd.manage
_manage: {merge: {}, full: {}, adopt: {}} @vocab(plugin-substrate)
_manageWord: [for w, _ in _manage {w}]
// #FirecrackerFireactions.log_level
_firecrackerFireactionsLogLevel: {info: {}, debug: {}, warn: {}, error: {}} @vocab(plugin-substrate)
_firecrackerFireactionsLogLevelWord: [for w, _ in _firecrackerFireactionsLogLevel {w}]
// #FirecrackerRunner.image_pull_policy
_imagePullPolicy: {"IfNotPresent": {}, "Always": {}, "Never": {}} @vocab(plugin-substrate)
_imagePullPolicyWord: [for w, _ in _imagePullPolicy {w}]
// #FirecrackerValue — the HOST-SIDE value gate def for the `firecracker` kind (the `#PodValue` /
// `#KubevirtValue` analogue). @go(-): the plugin keeps no typed Go body for it; the resolve
// envelope carries the raw bytes.
#FirecrackerValue: (#Firecracker | schema.#DeployValue) @go(-)
// schema/kindcluster.cue — the `kind: kindcluster` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE. This plugin's `kind: kindcluster` capability declares the gate def
// (`plugin.go`: `InputDef: "#KindclusterValue"`). opencharly/spec#304 unit 5 moved it here.
//
// THE MODULE'S SINGLE IMPORT LIVES IN `firecracker.cue`, which sorts FIRST in this schema
// directory (opencharly/spec#304 unit 7 moved it there when the firecracker body landed).
// spec/schemaconcat.ConcatSchema concatenates a module's files in sorted order with only the
// package clause stripped, so the one `import` must precede every declaration of the module.
//
// WHAT STAYED IN THE CONTRACT: `schema.#Step`, `schema.#Deploy`, `schema.#DeployValue`, `schema.#EngineName`,
// `schema.#KubernetesDeploy` are cited as `schema.#…`. The `#Kubernetes*` policy sub-defs are this
// module's own now (they arrived with `kubernetes.cue`).
// CUE schema for the `kindcluster` kind. #Kindcluster validates ONE value of the
// `kindcluster:` map — a local Kubernetes-in-Docker cluster provisioned by the
// upstream `kind` tool (kubernetes-sigs/kind), the local-cluster sibling of the
// `kubernetes:` cluster template. CLOSED — every Kindcluster field is modeled, so
// an unknown key is a typo. The shared defs it cites are `schema.#…`; the cluster-policy
// sub-blocks (storage/ingress/image_default/pod_default/defaults) are the SAME
// defs the `kubernetes:` template uses (R3 — one policy surface for both).
//
// The word is `kindcluster`, NOT `kind`: the bare word collides with this schema's
// own `source: {kind: …}` discriminator and with kind's own `kind: Cluster` config
// field.
//
// Template vs deploy: like every substrate kind, the value is the disjunction
// `#Kindcluster | schema.#DeployValue` (see #KindclusterValue below), routed by SHAPE in
// the loader — a TEMPLATE carries the cluster config (engine/node_image/nodes); a
// DEPLOY carries `from:`/`image:` + the deploy config (`engine:`, `deploy:`). The
// workload the cluster runs reuses schema.#KubernetesDeploy (schema.#Deploy.deploy:) unchanged —
// the same Kustomize tree the `kubernetes:` substrate generates.
#Kindcluster: {
// May be empty (a cluster-policy-only template runs no workload itself).
box: string @go(Box)
// engine selects the container engine kind provisions its node containers with.
// The authored field is the charly schema.#EngineName vocabulary (podman/docker/
// containerd); the plugin maps `containerd` to kind's own provider word
// (KIND_EXPERIMENTAL_PROVIDER=nerdctl) at the edge. Absent → the resolved
// runtime engine (engine.run).
engine?: schema.#EngineName @go(Engine)
// node_image is the digest-pinned kind node image (kindest/node:vX@sha256:…).
// Empty → the plugin's pinned default (the kind release's default node image).
// A digest pin is required for reproducibility (kind's own guidance).
node_image?: string @go(NodeImage)
// nodes is the cluster topology. Absent → a single control-plane node.
nodes?: [...#KindclusterNode] @go(Nodes)
// kubeconfig_context is the kubeconfig context this cluster deploys to. kind
// writes the context named after the cluster; a deploy may override it.
kubeconfig_context?: string @go(KubeconfigContext)
// default_namespace mirrors the kubernetes template's default namespace.
default_namespace?: *"default" | (string & =~"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") @go(DefaultNamespace)
// admission_policy mirrors the kubernetes template's admission policy (read by
// candy/plugin-k8sgen to set the pod security context).
admission_policy?: or(_kindclusterAdmissionPolicyWord) @go(AdmissionPolicy)
// Cluster policy — the SAME defs the `kubernetes:` template uses (R3).
storage?: #KubernetesStorage @go(Storage,optional=nillable)
ingress?: #KubernetesIngressDefaults @go(Ingress,optional=nillable)
image_default?: #KubernetesImagesDefaults @go(ImageDefault,optional=nillable)
pod_default?: #KubernetesPodDefaults @go(PodDefault,optional=nillable)
defaults?: #KubernetesResourceDefaults @go(Defaults)
plan?: [...schema.#Step] @go(Plan)
}
// #KindclusterNode — one node in the cluster topology. role discriminates the
// control plane from workers; kind names control-plane nodes `<cluster>-control-plane`
// and workers `<cluster>-worker`, `<cluster>-worker2`, …
#KindclusterNode: {
role: *"worker" | "control-plane" @go(Role)
// image overrides the cluster-level node_image for this node.
image?: string @go(Image)
// extra_port_mappings maps node ports to host ports (kind extraPortMappings) —
// the ingress/NodePort reach path. Bind a high host port to avoid needing
// net.ipv4.ip_unprivileged_port_start lowered for 80/443.
extra_port_mappings?: [...#KindclusterPortMapping] @go(ExtraPortMappings)
}
#KindclusterPortMapping: {
container_port: int & >0 & <=65535 @go(ContainerPort,type=int)
host_port: int & >0 & <=65535 @go(HostPort,type=int)
listen_address: *"0.0.0.0" | string @go(ListenAddress)
protocol: *"TCP" | "UDP" @go(Protocol)
}
// --- vocabulary tables (S3) --------------------------------------------------
// Every closed set of words is a table keyed by word, `<x>Word` is derived from it,
// and the enum an author meets is `or(<x>Word)` — so the table and the enum cannot
// disagree and a new word is ONE row here. `@vocab` names the owner (§3.1): these
// sets are compiled into THIS plugin's module since opencharly/spec#304 unit 5 moved them
// with the body, so the owner is `plugin-substrate`.
//
// Each table is named after its word when that name is unique in the schema, and
// `<definition><Field>` when it is not; the comment above it names its site.
// #Kindcluster.admission_policy
_kindclusterAdmissionPolicy: {restricted: {}, baseline: {}, privileged: {}} @vocab(plugin-substrate)
_kindclusterAdmissionPolicyWord: [for w, _ in _kindclusterAdmissionPolicy {w}]
// #KindclusterValue — the HOST-SIDE value gate def for the `kindcluster` kind; the same shape
// as its siblings (see kubernetes.cue's note beside #KubernetesValue).
#KindclusterValue: (#Kindcluster | schema.#DeployValue) @go(-)
// schema/kubernetes.cue — the `kind: kubernetes` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE, not in the contract module: a `kind` body belongs with the plugin
// that serves the kind. This plugin's `kind: kubernetes` capability declares the gate def
// (`plugin.go`: `InputDef: "#KubernetesValue"`), so the host resolves `#KubernetesValue` from
// that DECLARATION and reads it out of the schema composed from the base and every served
// plugin unit. opencharly/spec#304 unit 5 moved it here.
//
// WHAT CAME WITH IT, and why: the five `#Kubernetes*` sub-defs and the four vocabulary tables
// are cited ONLY by this body, so they move with it (a table cited from nowhere else is the
// body's own enum, not a shared vocabulary). What STAYS in the contract — `schema.#Step`, `#Deploy`,
// `#DeployValue`, `#EngineName`, `#KubernetesDeploy` — is cited as `schema.#…`.
//
// THE IMPORT LIVES IN `firecracker.cue`: that file sorts FIRST in this directory, and
// spec/schemaconcat.ConcatSchema concatenates a module's files in sorted order with only the
// package clause stripped, so a CUE `import` must precede every declaration of the module.
// CUE schema for the `kubernetes` kind. #Kubernetes validates ONE value of the
// `kubernetes:` map (KubernetesSpec; absorbed the former ClusterProfile). CLOSED —
// every KubernetesSpec field is
// modeled, so an unknown key is a typo. The documented enum domains + sub-object
// shapes are constrained. ONE exception: `pod_default.tolerations` stays OPEN —
// it is a genuine passthrough of raw Kubernetes Toleration objects
// ([]map[string]any). Plural field names that mirror Kubernetes output keys are
// preserved verbatim. The ONE shared def it cites is `schema.#Step` (the contract's),
// spelled with the `schema.` prefix because a plugin's CUE module can import only the
// contract module.
#Kubernetes: {
// May be empty (a cluster-policy-only template runs no workload itself).
box: string
kubeconfig_context?: string @go(KubeconfigContext)
// kubeconfig — the kubeconfig FILE this cluster is reached through. An
// externally-managed cluster (OVH / GKE / EKS / on-prem) is usually addressed
// by a per-cluster file rather than by the ambient `$KUBECONFIG` /
// `~/.kube/config`; without this field the only handle a deploy has is a
// context NAME, which cannot be resolved against a file charly was never
// told about. Empty keeps the ambient file that plain `kubectl` reads — what
// a charly-created k3s/kind cluster relies on.
kubeconfig?: string @go(Kubeconfig)
admission_policy?: or(_kubernetesAdmissionPolicyWord) @go(AdmissionPolicy)
default_namespace?: *"default" | (string & =~"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") @go(DefaultNamespace)
storage?: #KubernetesStorage
ingress?: #KubernetesIngressDefaults
image_default?: #KubernetesImagesDefaults @go(ImageDefault)
pod_default?: #KubernetesPodDefaults @go(PodDefault)
// kubevirt — cluster-specific KubeVirt knobs (the kind:kubevirt substrate's
// cluster side). Mirrors the storage/ingress "one cluster template owns the
// cluster-specific policy" partition: a kind:kubevirt VM names its cluster by
// `cluster:` and these knobs apply.
kubevirt?: #KubernetesKubeVirt @go(KubeVirt)
defaults?: #KubernetesResourceDefaults
}
// #KubernetesKubeVirt — the KubeVirt platform knobs a cluster template carries.
// The kubevirt-operator install + the kind:kubevirt substrate's defaults resolve
// from here.
#KubernetesKubeVirt: {
// enabled — whether this cluster has KubeVirt available (informational;
// the operator candy owns the actual install).
enabled?: bool
// cdi_enabled — whether CDI is installed (needed for a data_volume boot).
cdi_enabled?: bool @go(CDIEnabled)
cdi_namespace?: string @go(CDINamespace)
// use_emulation runs KubeVirt's software emulation (no /dev/kvm on the node).
// The R10 bed uses REAL KVM, so this defaults false.
use_emulation?: bool @go(UseEmulation)
default_storage_class?: string @go(DefaultStorageClass)
default_instancetype?: string @go(DefaultInstancetype)
default_preference?: string @go(DefaultPreference)
// snapshot_class names the VolumeSnapshotClass a VirtualMachineSnapshot uses.
snapshot_class?: string @go(SnapshotClass)
// virtctl_version pins the virtctl CLI release the operator candy installs.
virtctl_version?: string @go(VirtctlVersion)
feature_gates?: [...string] @go(FeatureGates)
}
#KubernetesStorage: {
class_default?: string @go(ClassDefault)
class_cheap?: string @go(ClassCheap)
class_encrypted?: string @go(ClassEncrypted)
class_fast?: string @go(ClassFast)
access_mode_default?: or(_accessModeDefaultWord) @go(AccessModeDefault)
}
#KubernetesIngressDefaults: {
enabled?: bool
class?: string
cert_issuer?: string @go(CertIssuer)
path_type_default?: or(_pathTypeDefaultWord) @go(PathTypeDefault)
}
#KubernetesImagesDefaults: {
pull_policy?: or(_kubernetesImagesDefaultsPullPolicyWord) @go(PullPolicy)
pull_secrets?: [...string] @go(PullSecrets)
}
#KubernetesPodDefaults: {
priority_class?: string @go(PriorityClass)
// Raw Kubernetes Toleration objects (Go []map[string]any) — genuine
// passthrough, so each element stays OPEN.
tolerations?: [...{...}]
node_selector?: {[string]: string} @go(NodeSelector)
}
#KubernetesResourceDefaults: {
labels?: [string]: string
annotations?: [string]: string
}
// --- vocabulary tables (S3) --------------------------------------------------
// Every closed set of words is a table keyed by word, `<x>Word` is derived from it,
// and the enum an author meets is `or(<x>Word)` — so the table and the enum cannot
// disagree and a new word is ONE row here. `@vocab` names the owner (§3.1): these
// sets are compiled into THIS plugin's module since opencharly/spec#304 unit 5 moved them
// with the body, so the owner is `plugin-substrate`.
//
// Each table is named after its word when that name is unique in the schema, and
// `<definition><Field>` when it is not; the comment above it names its site.
// #Kubernetes.admission_policy
_kubernetesAdmissionPolicy: {restricted: {}, baseline: {}, privileged: {}} @vocab(plugin-substrate)
_kubernetesAdmissionPolicyWord: [for w, _ in _kubernetesAdmissionPolicy {w}]
// #KubernetesStorage.access_mode_default
_accessModeDefault: {
"ReadWriteOnce": {}
"ReadWriteMany": {}
"ReadOnlyMany": {}
"ReadWriteOncePod": {}
} @vocab(plugin-substrate)
_accessModeDefaultWord: [for w, _ in _accessModeDefault {w}]
// #KubernetesIngressDefaults.path_type_default
_pathTypeDefault: {"Prefix": {}, "Exact": {}, "ImplementationSpecific": {}} @vocab(plugin-substrate)
_pathTypeDefaultWord: [for w, _ in _pathTypeDefault {w}]
// #KubernetesImagesDefaults.pull_policy
_kubernetesImagesDefaultsPullPolicy: {
"IfNotPresent": {}
"Always": {}
"Never": {}
} @vocab(plugin-substrate)
_kubernetesImagesDefaultsPullPolicyWord: [for w, _ in _kubernetesImagesDefaultsPullPolicy {w}]
// #KubernetesValue — the HOST-SIDE value gate def for the `kubernetes` kind (the
// #Candy / #<Kind>Value analogue). @go(-): the plugin keeps no typed Go body for it — the
// OpResolve arm decodes the authored template straight into the contract's
// #ResolvedKubernetes envelope. Its NAME is the contract the `kind` capability declares.
#KubernetesValue: (#Kubernetes | schema.#DeployValue) @go(-)
// schema/kubevirt.cue — the `kind: kubevirt` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE. This plugin's `kind: kubevirt` capability declares the gate def
// (`plugin.go`: `InputDef: "#KubevirtValue"`), so the host resolves it from that DECLARATION and
// reads it out of the schema composed from the base and every served plugin unit.
// opencharly/spec#304 unit 6 moved it here.
//
// WHAT CAME WITH IT: the twelve `#Kubevirt*` sub-defs and the node sub-def `#KubevirtSource`
// (cited only by this body) plus the `#KubevirtValue` twin, which now lives at the foot of this
// file. What STAYS in the contract — `schema.#DistroID`, `schema.#Step`, `schema.#VmBoxMetadata`,
// `schema.#VmCloudInit`, `schema.#VmSize`, `schema.#VmSource` — is cited as `schema.#…`.
//
// THE DEEP VALIDATION STAYS WHERE IT WAS: the cross-rules CUE cannot express (exactly-one boot
// arm, GPU resource_name XOR device_name, instancetype XOR explicit cpu/memory) are enforced by
// `candy/plugin-kubevirt`'s OpValidate, which is also the authored Go type's heaviest consumer.
#KubeVirt: {
// cluster — a kind:kubernetes cluster template name (the SAME cluster model the
// Kubernetes deploy substrate uses). kube_context pins a concrete kubeconfig
// context directly, bypassing the template lookup.
cluster?: string & !=""
kube_context?: string @go(KubeContext)
namespace?: string & =~"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
storage_class?: string @go(StorageClass)
description?: string
plan?: [...schema.#Step]
// source — the boot medium. Exactly one arm (enforced in OpValidate).
source: #KubevirtSource @go(Source,type=KubevirtSource)
// distro / ssh_user — the GUEST identity of the boot medium: the same pair
// schema.#VmBoxMetadata carries for a containerDisk's OCI label (same Go field names,
// one vocabulary). A `container_disk` source reads them from the VM box's
// labels (deploykit.VmCapabilitiesFromLabels); every OTHER arm (data_volume /
// pvc / clone) is a bare disk with no metadata to read, so it MUST declare them
// here. An explicit value always wins over box metadata.
//
// Both are plain `string`, deliberately, exactly as schema.#VmBoxMetadata.distro is:
// the schema.#DistroID vocabulary def is `@go(-)` (it generates no Go type), so a field
// that references it emits an undefined Go identifier. The id is validated
// against schema.#DistroID — and required for every non-containerDisk arm — by
// candy/plugin-kubevirt's OpValidate, beside the exactly-one-boot-arm and
// GPU/instancetype XOR rules this file's header documents as its home.
distro?: string @go(Distro)
ssh_user?: string @go(SSHUser)
// --- domain shape ---
memory?: schema.#VmSize @go(Memory)
cpu?: #KubevirtCPU @go(CPU,optional=nillable)
machine?: "q35" | "pc-i440fx" | "" @go(Machine)
firmware?: #KubevirtFirmware @go(Firmware,optional=nillable)
devices?: #KubevirtDevices @go(Devices,optional=nillable)
// gpus — KubeVirt host-device passthrough. Each entry names EITHER a cluster
// device-plugin resource (resource_name: "nvidia.com/gpu") XOR a specific host
// device (device_name), enforced in OpValidate. Maps requires_exclusive: to
// KubeVirt's spec.domain.devices.gpus — the cluster device plugin owns the
// physical card (no host arbiter involvement, unlike the vm substrate).
gpus?: [...#KubevirtGPU] @go(GPUs)
cloud_init?: schema.#VmCloudInit @go(CloudInit,optional=nillable)
network?: #KubevirtNetwork @go(Network,optional=nillable)
instancetype?: string
preference?: string
run_strategy?: *"Always" | or(_runStrategyWord) @go(RunStrategy)
eviction_strategy?: or(_evictionStrategyWord) @go(EvictionStrategy)
termination_grace_period_seconds?: int & >=0 @go(TerminationGracePeriodSeconds,type=int)
node_selector?: {[string]: string} @go(NodeSelector)
// affinity — a raw Kubernetes Affinity object; genuine passthrough.
affinity?: {...}
migration?: #KubevirtMigration @go(Migration,optional=nillable)
snapshot?: [...#KubevirtSnapshot] @go(Snapshots)
}
// 4-way discriminated union on source.kind; each arm pins kind, requires its
// fields, forbids cross-branch fields via _|_, and is CLOSED.
#KubevirtSource:
{
kind: "container_disk"
// image is an OCI image whose layers carry the disk — a charly VM box
// (its ai.opencharly.* labels carry the VM metadata contract) or any
// KubeVirt containerDisk image.
image: string & !=""
pull_policy?: or(_kubevirtSourcePullPolicyWord) @go(PullPolicy)
pull_secret?: string @go(PullSecret)
// disk_path_in_image points KubeVirt at the disk's location INSIDE the image
// when it is NOT the scanned default (/disk/disk.img) — e.g. a charly VM box
// whose emission places the disk at /disk.qcow2. Renders the VMI
// `containerDisk.path`. Empty → KubeVirt scans /disk (the /disk/disk.img
// contract).
disk_path_in_image?: string @go(DiskPathInImage)
data_volume?: _|_
pvc?: _|_
clone?: _|_
size?: _|_
} | {
kind: "data_volume"
// source — the CDI import source (http/registry/pvc/blank). Typed-open:
// the CDI DataVolume source vocabulary is CDI's business.
data_volume: {[string]: _}
size: string & !=""
storage_class?: string @go(StorageClass)
content_type?: or(_contentTypeWord) @go(ContentType)
image?: _|_
pull_policy?: _|_
pull_secret?: _|_
pvc?: _|_
clone?: _|_
} | {
kind: "pvc"
pvc: string & !=""
image?: _|_
pull_policy?: _|_
pull_secret?: _|_
data_volume?: _|_
size?: _|_
clone?: _|_
} | {
kind: "clone"
// clone — create a DataVolume as a clone of an existing VM/DataVolume.
clone: { from: string & !="" }
size?: string
storage_class?: string @go(StorageClass)
image?: _|_
pull_policy?: _|_
pull_secret?: _|_
data_volume?: _|_
pvc?: _|_
} @go(-) // gengotypes: hand KubevirtSource (spec/union_types.go) — flat discriminated struct
#KubevirtCPU: {
cores?: int & >=1 @go(,type=int)
sockets?: int & >=1 @go(,type=int)
threads?: int & >=1 @go(,type=int)
model?: string @go(Model)
dedicated_cpu_placement?: bool @go(DedicatedCPUPlacement)
}
#KubevirtFirmware: {
// bootloader selects BIOS or UEFI. Required-with-default so the efi-secure
// cross-rule below can reference it (an optional field errors when absent).
bootloader: *"bios" | "efi" @go(Bootloader)
efi_secure_boot?: bool @go(EFISecureBoot)
// Secure Boot needs UEFI.
if efi_secure_boot == true {
bootloader: "efi"
}
}
#KubevirtDevices: {
// autoattach_* mirror the KubeVirt autoattach toggles.
autoattach_pod_interface?: bool @go(AutoattachPodInterface)
autoattach_graphics_device?: bool @go(AutoattachGraphicsDevice)
autoattach_serial_console?: bool @go(AutoattachSerialConsole)
// rng adds a virtio-rng device (entropy for a cloud-init guest).
rng?: bool
// disks/filesystems are the extra (non-boot) volumes, typed-open passthrough.
disks?: [...{[string]: _}]
// host_devices is KubeVirt host-device passthrough (spec.domain.devices.hostDevices).
// It is the ONLY way a guest gets its own /dev/kvm, which is what nested virtualisation
// needs; a CPU feature alone is not enough. The device vocabulary belongs to the
// cluster's device plugin — on quant-dev it advertises `devices.kubevirt.io/kvm`, so the
// entry is `{device_name: "kvm", name: "kvm"}`.
host_devices?: [...#KubevirtHostDevice]
inputs?: [...#KubevirtInput]
watchdog?: #KubevirtWatchdog @go(Watchdog,optional=nillable)
}
#KubevirtInput: {
type: or(_kubevirtInputTypeWord)
bus?: or(_busWord)
}
#KubevirtHostDevice: {
// device_name is the resource the cluster's device plugin advertises, without its
// `devices.kubevirt.io/` prefix — `kvm`, `nvidia.com/gpu`, …
device_name: string
// name is the device's label inside the guest; KubeVirt defaults it to device_name.
name?: string
}
#KubevirtWatchdog: {
model: or(_kubevirtWatchdogModelWord)
action?: or(_kubevirtWatchdogActionWord)
}
#KubevirtGPU: {
resource_name?: string & !="" @go(ResourceName)
device_name?: string & !="" @go(DeviceName)
}
#KubevirtNetwork: {
// pod is the default KubeVirt network (a masquerade interface over the pod net).
interface?: *"masquerade" | or(_interfaceWord) @go(Interface)
model?: *"virtio" | or(_kubevirtNetworkModelWord) @go(Model)
// ports declare named ports on the interface (informational for a Service).
ports?: [...#KubevirtPort]
}
#KubevirtPort: {
name?: string
port: int & >=1 & <=65535 @go(,type=int)
protocol?: *"TCP" | "UDP" @go(Protocol)
}
#KubevirtMigration: {
allow_auto_converge?: bool @go(AllowAutoConverge)
allow_post_copy?: bool @go(AllowPostCopy)
bandwidth_per_migration?: string @go(BandwidthPerMigration)
completion_timeout_seconds?: int @go(CompletionTimeoutSeconds,type=int)
}
#KubevirtSnapshot: {
name: string & !=""
description?: string
// snapshot_class names the VolumeSnapshotClass; empty → the cluster default.
snapshot_class?: string @go(SnapshotClass)
}
// --- vocabulary tables (S3) --------------------------------------------------
// Every closed set of words is a table keyed by word, `<x>Word` is derived from it,
// and the enum an author meets is `or(<x>Word)` — so the table and the enum cannot
// disagree and a new word is ONE row here. `@vocab` names the owner (§3.1): these sets are
// compiled into THIS plugin's module since opencharly/spec#304 unit 6 moved them with the body,
// so the owner is `plugin-substrate`.
//
// Each table is named after its word when that name is unique in the schema, and
// `<definition><Field>` when it is not; the comment above it names its site.
// #KubeVirt.run_strategy
_runStrategy: {
"Always": {}
"Halted": {}
"Manual": {}
"RerunOnFailure": {}
"Once": {}
} @vocab(plugin-substrate)
_runStrategyWord: [for w, _ in _runStrategy {w}]
// #KubeVirt.eviction_strategy
_evictionStrategy: {
"None": {}
"LiveMigrate": {}
"LiveMigrateIfPossible": {}
"External": {}
} @vocab(plugin-substrate)
_evictionStrategyWord: [for w, _ in _evictionStrategy {w}]
// #KubevirtSource.pull_policy
_kubevirtSourcePullPolicy: {"Always": {}, "IfNotPresent": {}, "Never": {}} @vocab(plugin-substrate)
_kubevirtSourcePullPolicyWord: [for w, _ in _kubevirtSourcePullPolicy {w}]
// #KubevirtSource.content_type
_contentType: {kubevirt: {}, archive: {}} @vocab(plugin-substrate)
_contentTypeWord: [for w, _ in _contentType {w}]
// #KubevirtInput.type
_kubevirtInputType: {tablet: {}, mouse: {}, keyboard: {}} @vocab(plugin-substrate)
_kubevirtInputTypeWord: [for w, _ in _kubevirtInputType {w}]
// #KubevirtInput.bus
_bus: {virtio: {}, usb: {}, ps2: {}} @vocab(plugin-substrate)
_busWord: [for w, _ in _bus {w}]
// #KubevirtWatchdog.model
_kubevirtWatchdogModel: {i6300esb: {}, diag288: {}} @vocab(plugin-substrate)
_kubevirtWatchdogModelWord: [for w, _ in _kubevirtWatchdogModel {w}]
// #KubevirtWatchdog.action
_kubevirtWatchdogAction: {poweroff: {}, reset: {}, shutdown: {}} @vocab(plugin-substrate)
_kubevirtWatchdogActionWord: [for w, _ in _kubevirtWatchdogAction {w}]
// #KubevirtNetwork.interface
_interface: {masquerade: {}, bridge: {}, pod: {}} @vocab(plugin-substrate)
_interfaceWord: [for w, _ in _interface {w}]
// #KubevirtNetwork.model
_kubevirtNetworkModel: {virtio: {}, e1000: {}, rtl8139: {}} @vocab(plugin-substrate)
_kubevirtNetworkModelWord: [for w, _ in _kubevirtNetworkModel {w}]
// #KubevirtValue — the host-side value gate def for the `kubevirt` kind (the `#PodValue` /
// `#LocalValue` analogue). @go(-): the plugin keeps no typed Go body for it; a consumer that
// needs the full authored shape decodes the opaque body into its own view.
#KubevirtValue: (#KubeVirt | schema.#DeployValue) @go(-)
// schema/local.cue — the `kind: local` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE, not in the contract module: a `kind` body belongs with the
// plugin that serves the kind. This plugin's `kind: local` capability declares the gate def
// (`plugin.go`: `InputDef: "#LocalValue"`), so the host resolves `#LocalValue` from that
// DECLARATION and looks it up in the schema composed from the base and every served plugin
// unit — no kernel change and no def-name knowledge in the host.
// opencharly/spec#304 unit 4 moved it here.
//
// WHAT STAYS IN THE CONTRACT, and why: the shared defs this body uses — `#CandyRef`,
// `#InstallOpts`, `#StrVal`, `#Step` — and the `#DeployValue` disjunct are all cited from
// the contract module (`schema.#…`), because a plugin's CUE module can import ONLY the
// contract module. `#DeployValue` is the contract's deploy arm, not a second body: a
// `local:` node whose body has the deploy shape is gated by the SAME def, so the arm is
// cited rather than restated here.
//
// THE IMPORT RESOLVES OFFLINE. spec/schemacompose serves
// `github.com/opencharly/spec/schema` from the spec Go module the binary already links — no
// network, no module cache, no `cue.mod`, no published CUE module — on the serve side
// (sdk.BuildCapabilitiesWithRequires → ServedSchema) AND on the host side, which composes
// the SAME body under the DERIVED module declaration (registerPluginUnitSchema →
// ServedText).
//
// FILE ORDER IS LOAD-BEARING. spec/schemaconcat.ConcatSchema sorts a schema dir's files and
// concatenates them, stripping only the package clause, and a CUE `import` must precede
// every declaration. So the module's single import lives in the file that sorts FIRST:
// `firecracker.cue`, which sorts before this file and every other, and CARRIES it since the
// `kind: firecracker` body landed (opencharly/spec#304 unit 7). Renaming any file without
// re-checking the order makes the served schema uncompilable at load time.
// #Local validates ONE entry of the `local:` map (a target:local candy stack). CLOSED — the
// Go loader decodes with KnownFields(true), so an unknown key is an error. Shared defs
// REFERENCED, not redefined (R3).
#Local: {
// Ordered candy stack applied to the host. Required (empty list permitted — a staged
// name-reservation stub; the loader warns, not errors).
candy!: [...schema.#CandyRef]
install_opts?: schema.#InstallOpts @go(InstallOpts,optional=nillable)
env?: {PATH?: _|_, [string]: schema.#StrVal} @go(Env,type=map[string]string)
description?: string & !=""
plan?: [...schema.#Step]
}
// #LocalValue — the HOST-SIDE value gate def for the `local` kind (the #Candy /
// #<Kind>Value analogue). @go(-): the plugin keeps no typed Go body for it — the one
// consumer, resolve.go's OpResolve leg, decodes the authored template straight into the
// contract's #ResolvedLocal envelope. Its NAME is the contract the `kind` capability
// declares (plugin.go's InputDef), which is how the HOST resolves the gate for this kind
// without carrying any knowledge of it.
//
// The #DeployValue disjunct is the contract's deploy arm, NOT a second body (see above).
#LocalValue: (#Local | schema.#DeployValue) @go(-)
// schema/pod.cue — the `kind: pod` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE, not in the contract module: a `kind` body belongs with the
// plugin that serves the kind. This plugin's `kind: pod` capability declares the gate def
// (`plugin.go`: `InputDef: "#PodValue"`), so the host resolves `#PodValue` from that
// DECLARATION and looks it up in the schema composed from the base and every served plugin
// unit — no kernel change and no def-name knowledge in the host.
// opencharly/spec#304 unit 3 moved it here.
//
// WHAT STAYS IN THE CONTRACT, and why: `#PodSidecar` is cited by the contract's own
// `#ResolvedPod` (spec/schema/substrate_template.cue) — the resolve envelope the kernel
// reads — so the def is referenced here as `schema.#PodSidecar` and stays where it is. A
// plugin's CUE module can import ONLY the contract module, which is exactly why that
// reference settles the question rather than taste.
//
// THE IMPORT RESOLVES OFFLINE. spec/schemacompose serves
// `github.com/opencharly/spec/schema` from the spec Go module the binary already links — no
// network, no module cache, no `cue.mod`, no published CUE module — on the serve side
// (sdk.BuildCapabilitiesWithRequires → ServedSchema) AND on the host side, which composes
// the SAME body under the DERIVED module declaration (registerPluginUnitSchema →
// ServedText).
//
// FILE ORDER IS LOAD-BEARING. spec/schemaconcat.ConcatSchema sorts a schema dir's files and
// concatenates them, stripping only the package clause, and a CUE `import` must precede
// every declaration. So the module's single import lives in the file that sorts FIRST:
// `firecracker.cue` (which carries the `kind: firecracker` body and with it the import),
// before every other file. Renaming any of them without re-checking that order makes the
// served schema uncompilable at load time.
// #Pod validates ONE entry of the `pod:` map (PodSpec). Most projects declare no kind:pod
// entries (the real corpus is all `pod: {}`); the schema is modeled directly from the
// struct. CLOSED — every PodSpec field is modeled, so an unknown key is a typo. Shared defs
// REFERENCED, not redefined (R3): schema.#Step / schema.#CandyRef (the contract's),
// schema.#DeploySecret from deploy.cue, schema.#Sidecar from sidecar.cue.
#Pod: {
// References a kind:box (bare lowercase-hyphenated name or remote ref).
// Optional: the Go field has no non-empty validator.
box?: schema.#CandyRef
// Each entry is a SidecarConfig wrapper: a single-key map of named
// sidecar templates (PodSpec.Sidecar []SidecarConfig).
sidecar?: [...schema.#PodSidecar]
secret?: [...schema.#DeploySecret]
env_default?: {[string]: schema.#StrVal} @go(EnvDefaults,type=map[string]string)
plan?: [...schema.#Step]
}
// #PodValue — the HOST-SIDE value gate def for the `pod` kind (the #Candy / #<Kind>Value
// analogue). @go(-): the plugin keeps no typed Go body for it — the one consumer,
// resolve.go's OpResolve leg, decodes the authored template straight into the contract's
// #ResolvedPod envelope. Its NAME is the contract the `kind` capability declares
// (plugin.go's InputDef), which is how the HOST resolves the gate for this kind without
// carrying any knowledge of it.
//
// The #DeployValue disjunct is the contract's deploy arm, NOT a second body: a `pod:` node
// whose body has the deploy shape (from:/image:/members) is gated by the SAME def, so the
// arm is cited from the contract rather than restated here.
#PodValue: (#Pod | schema.#DeployValue) @go(-)
// plugin-substrate's OWN CUE schema (with schema/pod.cue) — the SINGLE SOURCE for this
// plugin's served declaration surface (there is no schema-less plugin: every plugin ships a
// non-empty schema over Describe).
//
// ONE CUE MODULE PACKAGE, EIGHT FILES. This file carries the declaration surface and
// references no base def; `firecracker.cue` carries the `kind: firecracker` ENTITY body and
// the module's single contract import, `kindcluster.cue` the `kind: kindcluster` body,
// `kubernetes.cue` the `kind: kubernetes` body (with its own policy sub-defs and vocabulary
// tables), `kubevirt.cue` the `kind: kubevirt` body (with its twelve sub-defs), and
// `local.cue` / `pod.cue` / `vm.cue` their bodies.
// The module composes as ONE package — `schemaconcat.ConcatSchema` concatenates a schema
// dir's files in sorted order and strips only the package clause, so the single `import`
// lives in the file that sorts FIRST (`firecracker.cue`, before the other seven). It is composed by
// the SAME code on both sides of the wire — spec/schemacompose on the serve side
// (sdk.BuildCapabilitiesWithRequires → ServedSchema) and on the host side
// (registerPluginUnitSchema → ServedText, which unifies the unit onto the base); a unit that
// will not compose alone or will not splice is a LOUD load failure, never a silent skip.
//
// NO GO CONSUMER: the plugin declares no typed `plugin_input` (its authored input is
// its pass-through CLI grammar), so this schema generates NO `params` package and has
// NO `cue exp gengotypes` artifact — it is the SERVED documentation/config surface,
// not a code-generation source. The pod body's one consumer (resolve.go) decodes the
// authored bytes straight into the contract's `#ResolvedPod` envelope, so it needs no
// generated type either.
//
// It DOCUMENTS the substrate provider's kind/command/verb words and the deploy traits they carry. The rich substrate VALUES are validated HOST-SIDE against the kept `#<Kind>Value` defs. EVERY served kind declares `InputDef:"#<Word>Value"` and owns its body in this schema dir (`schema/<word>.cue`), so the host resolves the gate def from that DECLARATION and reads it out of the composed unit rather than the base's `spec.KindValueDefs` compatibility fallback.
// ⚑ PLUGIN-SCOPED NAME. This def used the plugin word unprefixed, which the POD kind's plugin
// also declares; the host splice unifies same-name definitions across sources, so the merged shape
// matched neither plugin's input and `charly deploy add` refused the whole deploy plugin set
// (opencharly/plugin-substrate#53). Two consumers name it today — charly's
// kind_value_composed_test.go resolves it, and the CHANGELOG records it — so a rename must
// move them in the same wave. Never rename it back to a name another plugin declares.
#SubstrateProvider: {
// The structural deploy kind words this provider serves.
kinds: [...string]
// The command words this provider serves (reap-orphans).
commands: [...string]
// The internal-only verb words this provider serves (status-fanout).
verbs: [...string]
// What this provider does, in one line (the public-docs surface).
contract: string & !=""
// The configuration surface: env var names the collectors read.
config?: [string]: string
}
// schema/vm.cue — the `kind: vm` ENTITY body, owned by the plugin that SERVES the kind.
//
// THE KIND BODY LIVES HERE. This plugin's `kind: vm` capability declares the gate def
// (`plugin.go`: `InputDef: "#VmValue"`), so the host resolves it from that DECLARATION and
// reads it out of the schema composed from the base and every served plugin unit.
// opencharly/spec#304 unit 8 moved it here.
//
// WHAT CAME WITH IT: `#Vm` alone, plus the `#VmValue` twin at the foot — nothing else. Six defs that
// arrived with it in #42 (`#VmBackend`, `#VmBackendName`, `#VmChecksum`, `#VmInstaller`,
// `#VmKeyInjection`, `#VmCharlyInstall`) turned out to be keepers: the contract's own keepers and
// the `spec.VmBackends` generator cite them, so the contract keeps them and this file cites them as
// `schema.#…`. The pin wave's D-PAT control is what made the duplication visible, and this leg
// removed it.
//
// WHAT STAYED IN THE CONTRACT, and why the line falls here: the resolve ENVELOPE, `#ResolvedVm`,
// type-cites `#VmSource`, `#VmNetwork`, `#VmSsh`, `#VmCloudInit`, `#VmKrun`, `#VmSnapshot` and
// `#LibvirtDomain` (with its sixty-def domain family), and that envelope is a WIRE type read by
// charly's fallback resolver, plugin-check (through `vmshared.VmSpec`) and plugin-deploy-vm. A
// wire type's citations pin their defs in the contract; the body cites them as `schema.#…`.
//
// THE EIGHT VOCABULARY WORDS are cited as `schema.#Vm<X>Word` — the PUBLIC re-exports
// opencharly/spec#320 added, because a plugin cannot reference a private `_<x>Word` and the
// private tables are shared with the keepers above.
//
// THE MODULE'S SINGLE IMPORT STAYS IN `firecracker.cue` (the file that sorts FIRST);
// spec/schemaconcat.ConcatSchema concatenates a module's files in sorted order, and `vm.cue`
// sorts LAST.
#Vm: {
source: schema.#VmSource @go(Source,type=VmSource)
disk_size?: string @go(DiskSize)
ram?: string
cpu?: int & >=1 @go(Cpus,type=int) // yaml key is singular `cpu` (VmSpec.Cpus yaml:"cpu")
machine?: or(_machineWord)
// firmware is REQUIRED-with-default (not optional): an if-guard can only
// reference a field that always resolves to a concrete value, and an
// OPTIONAL field — even one carrying a default — errors with "cannot
// reference optional field" when absent. Required-with-default materializes
// "bios" on omission (matching the Go empty→bios behavior) AND stays
// referenceable by the uefi-secure cross-rule below.
firmware: *"bios" | or(_vmFirmwareWord)
backend: schema.#VmBackend
autostart: *false | true
// autostart:true requires an authoring backend word: the guard is `or(_backendWord)`, whose
// rows are `auto` and `libvirt`. `auto` resolves by detection at apply time, so `libvirt` is
// the explicit choice; a `krun` guest has no persistent daemon at all (and `qemu` is a
// PROVIDER word in `schema.#VmBackendName`, not a row of this authoring table).
if autostart {
backend: or(_backendWord)
}
// krun carries the krun backend's knobs. Optional and ignored by the other
// backends; the consumer applies its defaults when the resolved backend is
// krun and the block is absent.
krun?: schema.#VmKrun @go(Krun,optional=nillable)
// A krun guest's root is a containerd snapshot, not a libvirt domain: its
// source must be an OCI-image arm (`container_disk` / `bootc`), and the
// libvirt/qemu-only fields are rejected. `firmware` and `autostart` are
// required-with-default in this def, so they are VALUE-pinned to their
// defaults here: an authored uefi-* firmware or autostart:true conflicts,
// while the materialized defaults pass. Each rejection is deliberately a
// FIELD-named conflict (null for the struct-valued fields, a negated enum for
// machine) rather than a bare `_|_`, whose error names only #Vm.
if backend == "krun" {
source: schema.#VmSource & {kind: or(_vmKindWord)}
libvirt?: null
autostart: false
firmware: "bios"
machine?: !~"^(q35|virt|i440fx|pc)$"
cloud_init?: null
}
// Secure Boot needs Q35 SMM — i440fx can't supply it.
// machine stays OPTIONAL (Go allows empty machine with uefi-secure), so the
// constraint is `machine?: !=…`, not `machine: !=…` (the latter would force
// machine present and false-reject the common omit-machine uefi-secure case).
if firmware == "uefi-secure" {
machine?: !="i440fx"
// Secure Boot requires SMM: the renderer does NOT
// auto-enable SMM for uefi-secure (buildDomainFeatures only sets it from an
// explicit libvirt.features.smm), so the user MUST declare it. The `!`
// required-field markers force libvirt/features/smm to be EXPLICITLY present
// (a plain `smm: true` would auto-fill and silently pass) and pinned true.
libvirt!: features!: smm!: true
}
network?: schema.#VmNetwork @go(Network,optional=nillable)
ssh?: schema.#VmSsh @go(SSH,type=*VmSsh)
// The explicit pointer type keeps the generated Go field as *VmCloudInit even
// though the krun guard above adds the `null` arm (a bare `optional=nillable`
// degrades to an anonymous struct in that case).
cloud_init?: schema.#VmCloudInit @go(CloudInit,type=*VmCloudInit)
// mcp_provide: a kind:vm entity declares its MCP servers (e.g. the
// systemd-started charly mcp server) exactly like a box does — the P4
// substrate-neutral surface.
mcp_provide?: [...schema.#CandyMCPProvide] @go(MCPProvide)
libvirt?: schema.#LibvirtDomain @go(Libvirt,type=*LibvirtDomain)
plan?: [...schema.#Step]
snapshot?: [...schema.#VmSnapshot] @go(Snapshots)
}
// #VmValue — the HOST-SIDE value gate def for the `vm` kind (the `#PodValue` analogue). @go(-):
// the plugin keeps no typed Go body for it; the resolve envelope carries the raw bytes.
#VmValue: (#Vm | schema.#DeployValue) @go(-)
// --- vocabulary tables (S3), moved with the body ---------------------------------
// The four sets the vm BODY cites and nothing else did (opencharly/spec#304 unit 8): the
// contract keeps only the tables its own keepers cite. `@vocab` names the owner (§3.1):
// these sets are compiled into THIS plugin's module now.
_machine: {q35: {}, virt: {}, i440fx: {}, pc: {}} @vocab(plugin-substrate)
_machineWord: [for w, _ in _machine {w}]
_vmFirmware: {bios: {}, "uefi-insecure": {}, "uefi-secure": {}} @vocab(plugin-substrate)
_vmFirmwareWord: [for w, _ in _vmFirmware {w}]
_backend: {auto: {}, libvirt: {}} @vocab(plugin-substrate)
_backendWord: [for w, _ in _backend {w}]
_vmKind: {container_disk: {}, bootc: {}} @vocab(plugin-substrate)
_vmKindWord: [for w, _ in _vmKind {w}]

See also the candy reference for this candy’s install surface.