Skip to content

feat(schema): W3.1 selection surfaces — deploy rootful, containerd namespace, VM-backend vocabulary - #275

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/w31-selection-surfaces
Oct 23, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/w31-selection-surfaces

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

The producer leg for W3.1's selection model. The plan's one precedence rule — flag > deploy entity > env > settings file > built-in default — had no schema-owned source at two of its levels, and the VM-backend vocabulary had no generated Go accessor, so a resolver would have had to carry word literals. This change supplies all three surfaces in the contract module, CUE first:

  1. #RootfulMode + #Deploy.rootful (schema/engine.cue, schema/deploy.cue) — the CLOSED rootful-launch vocabulary auto | machine | sudo | native, already the set plugin-settings accepts for engine.rootful, now also the per-deploy selector. #DeployTraits.selectors gains "rootful", so the loader can reject it on a substrate that does not declare it without switching on a substrate name.
  2. #VmBackendName + #VmBackend (schema/vm.cue) — the provider words libvirt | qemu | krun are now their own def; #VmBackend keeps auto as the resolution default. schemagen emits spec.VmBackends and spec.RootfulModes, so --backend / CHARLY_VM_BACKEND / vm.backend and --rootful / CHARLY_ENGINE_ROOTFUL / engine.rootful are validated against the schema, never a literal.
  3. containerd.namespace (hostenv/runtime_config.go) — ContainerdConfig.Namespace, RuntimeConfig.Containerd, and ResolvedRuntime.Namespace, resolved as settings > the engine capability's namespace fact (containerd: "default"). No env mirror, matching the plan's table (containerd.namespace | — | namespace: | --namespace).

Generated artifacts (spec/cue_types_gen.go, spec/vocab_gen.go) are the charly task cue-gen output, committed; a second run is byte-identical (hashes below).

Scope boundary: this is the producer. The sdk resolvers (ResolvePodEngine, ResolveVmBackend, ResolveContainerdTarget) are the next leg and will bump to this merge's tag; the plugin-substrate pod traits must declare "rootful" in a consumer leg before the loader admits a per-deploy rootful: on a pod; plugin-settings gains the containerd.namespace key as a consumer leg. No consumer repo is touched here.

How tested

Every command below ran on the committed tree.

# head 74c8bc1e3ee89e0d4202b63d6293bb1f5b087170 (git rev-parse HEAD)
# tree 41e7a66ae8f6e9b2c19c65c21459cf3a77564e72 (git rev-parse HEAD^{tree})
$ cd spec && GOWORK=off gofmt -l .
(no output)                                                # rc 0, 0 files

$ GOWORK=off go build ./...
rc 0

$ GOWORK=off go vet ./...
rc 0

$ GOWORK=off go test ./...
rc 0   # schema 24.3s, hostenv 0.02s, spec 3.6s, all packages ok

$ golangci-lint (v2.13.2) run ./...
0 issues.                                                  # rc 0

charly task cue-gen twice is a no-op. Both runs exited 0 and each run's own check: regen is reproducible — TestGenReproducible step passed. The generated files' hashes are identical across the two runs:

5734e9a10163e8ee85faab7ae7f2db4f29f2d48c514dae986af954ac2564658c  spec/cue_types_gen.go
afbea6ca9ee1656640a5e0203520cec3cd7a4f9af6ccd335c9e71d39955deefc  spec/vocab_gen.go

charly box validate: rc 0 — OK — checked 1 candy, 7 distros, 7 builders; 0 warnings, 0 errors.

Coverage fails without the change. The new tests were copied onto a throwaway worktree at origin/main (3099d05) and run there:

--- FAIL: TestDeployRootfulVocabulary
    #Deploy rejects rootful: "auto": #Deploy.rootful: field not allowed
    #RootfulMode is not defined in the shipped schema
--- FAIL: TestVmBackendNameIsProviderWordsOnly
    #VmBackendName is not defined in the shipped schema
--- FAIL: TestDeployTraitsSelectorData
    #DeployTraits rejects {selectors: ["rootful"]}: ... 2 errors in empty disjunction

hostenv/runtime_config_namespace_test.go:36:8: rt.Namespace undefined (type *ResolvedRuntime has no field or method Namespace)
FAIL	github.com/opencharly/spec/hostenv [build failed]

All pass on this head. The namespace tests pin all three arms: the settings value wins; the capability default applies when unset; a plausible env var (CHARLY_CONTAINERD_NAMESPACE) is ignored, so no accidental env level.

Two environment notes, both RCA'd, neither a code finding:

  • The host's Go is 1.27.3 (export-data format 5), which the pinned golangci-lint v2.13.2 cannot typecheck (export data version 5 is greater than maximum supported version 4). CI uses setup-go from go.mod (go 1.26.0); running lint locally with the go1.26.0 toolchain gives 0 issues. The initial failure was a toolchain mismatch that died before analysis — it never produced a finding.
  • schema/*.cue is not cue fmt-clean on pristine origin/main (every file listed). The W3.1-added constructs are absent from cue fmt --diff after alignment; the pre-existing drift is filed as opencharly/spec#274 rather than riding this contract change.

Rulebook compliance

  • R0: loaded /charly-internals:go, plugin, git-workflow, strict-policy, root-cause-analyzer, go-quality, cutover-policy, plus this repo's AGENTS.md.
  • R1: the lint toolchain mismatch and the pre-existing cue fmt drift are the only anomalies; each has an RCA above, and the drift is filed (#274). No warnings survive the gate.
  • R2: one source per vocabulary — #RootfulMode and #VmBackendName are CUE defs, their Go lists are generated; no hand-written parallel list.
  • R3: no workaround. Running lint under the go.mod toolchain reproduces CI; no linter was installed manually (~/go/bin was already present), no suppression added.
  • R4: n/a (no documented command changed).
  • R5: purely additive — nothing deleted, no stale identifier introduced. #VmBackend's word set is unchanged semantically (auto | libvirt | qemu | krun).
  • R6: worktree .worktrees/w31/spec off fresh origin/main; git status clean before and after; one commit; no submodule checkout edited.
  • R7: see the fail-without block — every new schema assertion is red on origin/main and green here; the namespace resolution runs live in hostenv tests.
  • R8: n/a (no external service boundary).
  • R9: not applicable — spec is a Go module, no binary; no new runtime OS dependency.
  • R10: this repo carries no candy/disposable bed (AGENTS.md: the merge gate is the org-wide charly/pr-validator, and .github/workflows/ci.yml is the module's gate). The CI gate ran on the committed tree, and charly box validate is 0 warnings / 0 errors.
  • SDD: CUE first; Go generated (cue_types_gen.go, vocab_gen.go); cue-gen twice is a no-op.
  • HC: one commit, one cutover.

Change classification

Additive contract producer (spec): three new surfaces plus their generated artifacts. No authored key is removed or reshaped, so no migration entry is owed; #VmBackend keeps its meaning and default. Downstream order: this merge → tag → sdk bumps its require github.com/opencharly/spec and lands W3.1 → consumer legs (plugin-substrate selector declaration, plugin-settings containerd.namespace, plugin-deploy-pod/plugin-pod resolver adoption).

Filed issues

  • opencharly/spec#274 — schema/*.cue is not cue fmt-clean on pristine main; pre-existing, non-blocking, fix is one formatting commit plus a CI step.

Closes #273

Agent: containerd-crabbox-program/w31 · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

…d namespace, VM-backend vocabulary

W3.1's one precedence rule (flag > deploy entity > env > settings file >
built-in default) had no schema-owned source at two of its levels, and the
VM-backend vocabulary had no generated Go accessor, so a resolver would have
had to carry word literals. This is the producer leg that supplies them.

- `#RootfulMode` — the CLOSED rootful-launch vocabulary
  (auto | machine | sudo | native) shared by `engine.rootful`,
  `CHARLY_ENGINE_ROOTFUL` and the new per-deploy `rootful:`; cue-gen emits it
  as spec.RootfulModes.
- `#Deploy.rootful` — the per-deploy level, admitted as a deploy selector
  (`#DeployTraits.selectors` gains "rootful") so the loader can reject it on a
  substrate that does not declare it, without a substrate-name switch.
- `#VmBackendName` — the VM-backend PROVIDER words (libvirt | qemu | krun);
  `#VmBackend` keeps `auto` as its resolution default. cue-gen emits
  spec.VmBackends, so `--backend` / `CHARLY_VM_BACKEND` / `vm.backend` are
  validated against the schema, never a literal.
- `hostenv.ContainerdConfig.Namespace` + `RuntimeConfig.Containerd` +
  `ResolvedRuntime.Namespace` — the settings-file level, resolved as
  settings > the engine capability's `namespace` fact (containerd: "default");
  no env mirror, per the plan's table.

The generated files are the `charly task cue-gen` output; a second run is a
no-op (spec.TestGenReproducible). The new schema tests fail on the pre-change
tree (field not allowed / def missing / selector rejected) and the namespace
tests fail to compile there (no ResolvedRuntime.Namespace).

Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

I reviewed all 9 changed files against the PR body and re-derived every claim. The change is a coherent, additive contract-producer leg with matching tests and generated artifacts.

Correctness

  • schema/engine.cue adds #RootfulMode: ("auto" | "machine" | "sudo" | "native"), and schema/vm.cue splits #VmBackend into #VmBackendName: ("libvirt" | "qemu" | "krun") plus #VmBackend: *"auto" | #VmBackendName. The value set and "auto" default are semantically preserved, matching the body's "R5: purely additive / unchanged meaning" claim.
  • schema/deploy.cue adds rootful?: #RootfulMode @go(Rootful) and extends #DeployTraits.selectors with "rootful", exactly as described.
  • hostenv/runtime_config.go adds ContainerdConfig.Namespace, RuntimeConfig.Containerd, ResolvedRuntime.Namespace, and resolves it as settings → engine capability fact, with no env mirror. This matches the body's precedence statement and the "no env column" plan table. The block is inserted after RunEngine resolution and before run-mode detection, so the capability lookup is well-ordered.
  • Generated artifacts (spec/cue_types_gen.go, spec/vocab_gen.go) are consistent with the CUE sources and internal/schemagen/main.go: RootfulModes/VmBackends are emitted in the same order the CUE disjunctions list them, and Deploy.Rootful/DeployTraits.Selectors doc comments track the source. The type placement (e.g. RootfulMode emitted after the Deploy struct that references it, VmBackendName — referenced only by the #VmBackend definition — appended near Vm) is consistent with a deterministic "emit referenced defs near their referencing struct, append otherwise" generator, so the reproducibility claim is plausible rather than a hand-edit.

Tests

The new tests are substantive and would fail without the change:

  • TestDeployRootfulVocabulary, TestVmBackendNameIsProviderWordsOnly, and the extended TestDeployTraitsSelectorData assert the closed vocabularies and the rootful selector.
  • hostenv/runtime_config_namespace_test.go pins all three arms (settings wins, capability default, env ignored).

The body's fail-without evidence is internally consistent: the quoted build error runtime_config_namespace_test.go:36:8: rt.Namespace undefined matches the actual line 36 (if rt.Namespace != "k8s.io" {) of the committed test, and the schema failure messages (#Deploy.rootful: field not allowed, #RootfulMode is not defined, #DeployTraits rejects {selectors: ["rootful"]}) correspond to the pre-change schema. This is strong corroboration that the "How tested" block reflects real runs.

Security & scope

No secrets, no injection surface (the namespace is an inert string from settings), no new dependencies, and no consumer repos touched — consistent with the stated scope boundary.

Comments

There are zero comments in the thread, so nothing to disposition. No maintainer sign-off is present, and none is required for the change to stand on its own evidence, which it does.

Minor (non-blocking) observations

  • The unverifiable dependency is container.EngineCapabilityFor(...).Namespace; since no container-package file is in the 9-file set, that symbol must already exist on main, and the consistent test evidence supports that it compiles. No action needed here, but worth noting it is an assumed pre-existing fact.
  • ContainerdConfig is a value (not pointer) field with omitempty; omitempty does not elide empty structs in yaml, but this mirrors the existing Vm RuntimeVmConfig style, so it is consistent with the file's conventions.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 23, 2026 10:36
@github-actions
github-actions Bot merged commit a431987 into main Oct 23, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 23, 2026
github-actions Bot pushed a commit to opencharly/sdk that referenced this pull request Oct 23, 2026
…ontainerd target (#457)

* feat(deploykit): the W3.1 selection resolvers — engine, VM backend, containerd target

W3.1 replaces the divergent per-consumer selection paths with three canonical
resolvers over ONE precedence rule:

    flag > deploy entity > env > settings file > built-in default

- ResolvePodEngine(flag, deploy, rt) — the engine word; `auto` detects (podman
  then docker); a candy's engine: is a CONSTRAINT checked after resolution,
  never an override.
- ResolveVmBackend(flag, deploy, rt) — the VM backend; `auto` detects in the
  schema's own word order (libvirt then qemu), and krun is explicit-only.
- ResolveContainerdTarget(engine, deploy, rt) — {engine, rootful, address,
  namespace, privilegePrefix}; rootful is capability-checked and `native`
  applies no privilege prefix; namespace defaults to the capability fact.

The env > settings fold is hostenv.ResolveRuntime's, not a second copy; the
tests drive it end-to-end. Vocabularies are schema-owned (spec.EngineNames,
spec.VmBackends, spec.RootfulModes), and the spec pin advances to
v0.2026296.1036 (opencharly/spec#275), which added the deploy rootful selector,
the containerd namespace setting and the VM-backend vocabulary.

Tests: per-level precedence tables for all three resolvers, env-over-settings
and settings-over-default through ResolveRuntime, the candy constraint, the
capability refusals, a probe-vocabulary drift guard, and a mutant that swaps
every adjacent precedence pair plus a production mutation (flag/deploy
reversed) that fails the table.

Consumer migration (filed, not touched): opencharly/opencharly#589.

Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

* fix(deploykit): delete the dead precedence-level machinery and the unreachable namespace guard

Review round 1 found two dead-code defects in the new selection module.

1. `selectionSource.level` (with the whole `selectionLevel` type and its four
   constants) was written but never read. It was the remnant of the first
   iteration's `(value, level)` return, whose return the local `unparam` gate
   had made me delete. The tests permute the chain by INDEX, so nothing ever
   consulted the field. Removed entirely: the chain is now a positional
   `[]string` and `firstSet(values ...string)`; the mutation helper asserts the
   positional order directly, so no identity can drift from the order.

2. `ResolveContainerdTarget`'s `namespace == "" && capability.Namespace != ""`
   guard was unreachable: `containerdNamespaceSources` already appends
   `capability.Namespace` as its last source, so the default always arrives
   through the chain. Removed; the chain is the one mechanism that supplies it.

Gate on this tree: gofmt clean, build/vet/test rc 0, `go test -race ./...` rc 0,
golangci-lint 0 issues, four-arch cross-compile rc 0. The production mutation
was re-proved on the simplified chain (flag/deploy swapped fails the precedence
table; restored passes).

Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

---------

Co-authored-by: Andreas Trawoeger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

W3.1 consumer surfaces are absent: deploy rootful:, containerd.namespace, and an emitted VmBackend vocabulary

2 participants