Skip to content

feat(deploykit): VM box image emitter + reader — EmitVmBox / VmCapabilitiesFromLabels - #202

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/vm-box-emit
Sep 3, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/vm-box-emit

Conversation

@atrawog

@atrawog atrawog commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Task 2 (sdk half) of the VM-box cutover (plan/vm-from-box-layering.md §2.1: "a VM box is an OCI image whose labels carry the VM metadata contract and whose layers carry the disk artifact"). The spec half (spec PR #90, MERGED) landed spec.VmBoxMetadata + VmBoxSource + LabelVmBox = "ai.opencharly.vm.box" + the VmBoxLabelMap completeness gate; this PR lands the sdk emitter/reader that bakes and reads that contract on real box images.

Changes (4 files, +275):

  • go.mod / go.sum — bump github.com/opencharly/spec v0.2026243.707 → v0.2026246.554 (the tag-on-merge tag of spec PR fix(spec): CUE-convert the arbiter wire types + remove the qemu-shutdown-only state_dir field #90's merge commit; carries VmBoxMetadata + LabelVmBox + VmBoxLabelMap). go mod tidy clean.
  • deploykit/vm_box_emit.go (new) — the VM box image emitter + reader:
    • EmitVmBox(engine, ref, meta, diskPath): stages a temp Containerfile (FROM scratch, COPY <disk> /disk.qcow2, LABEL ai.opencharly.vm.box=<whole-struct JSON> + ai.opencharly.version=<meta.Version> + ai.opencharly.description=<JSON>), runs podman build -t <ref> with the disk's own directory as the build context (the disk is never copied), removes the temp Containerfile. The disk COPY is the layer; the labels are the contract. Engine binary via container.EngineBinary; label values quoted with spec/shellquote.ShellQuote exactly like the pod-side WriteLabels emitter.
    • VmCapabilitiesFromLabels(engine, ref): container.InspectLabels (the same inspect seam CapabilitiesFromLabels→ExtractMetadata uses) → reads ai.opencharly.vm.box → unmarshal into *spec.VmBoxMetadata. Mirrors the ErrImageNotLocal wrap when the image is absent locally.
  • deploykit/vm_box_emit_test.go (new):
    • TestVmBoxMetadataLabelRoundTrip — marshal a populated VmBoxMetadata → unmarshal → DeepEqual (the label contract round-trips through the sdk's pinned spec).
    • TestVmBoxLabelCompleteness — spec.CheckVmBoxLabelCompleteness() nil (every field covered by the label map).
    • TestVmBoxEmitReadBackRoundTrip — LIVE integration test (podman IS available on this host): emits a 1-byte fixture "disk" with a fully-populated metadata contract into local podman storage, reads it back, asserts DeepEqual equality, and asserts the image has exactly ONE layer (the disk COPY). Skips with t.Skip when podman is absent.

How tested

go build ./... — exit 0 (no output). gofmt -l . — empty. go test ./... — all packages ok:

$ cd sdk && go test ./...
ok  github.com/opencharly/sdk  0.069s
ok  github.com/opencharly/sdk/agentkit  0.875s
ok  github.com/opencharly/sdk/buildkit  0.006s
ok  github.com/opencharly/sdk/candywalk  0.002s
ok  github.com/opencharly/sdk/deploykit  1.902s
ok  github.com/opencharly/sdk/enginekit  0.004s
ok  github.com/opencharly/sdk/kit  0.580s
ok  github.com/opencharly/sdk/loaderkit  0.015s
ok  github.com/opencharly/sdk/packagekit  0.012s
ok  github.com/opencharly/sdk/vmshared  0.113s

New tests, verbosely (from the committed tree, R10):

$ go test ./deploykit/ -run 'VmBox' -v -count=1
=== RUN   TestVmBoxMetadataLabelRoundTrip
--- PASS: TestVmBoxMetadataLabelRoundTrip (0.00s)
=== RUN   TestVmBoxLabelCompleteness
--- PASS: TestVmBoxLabelCompleteness (0.00s)
=== RUN   TestVmBoxEmitReadBackRoundTrip
--- PASS: TestVmBoxEmitReadBackRoundTrip (1.29s)
PASS
ok  github.com/opencharly/sdk/deploykit  1.297s

Podman availability finding: podman version 6.1.0 IS present on this host (/usr/bin/podman, rootless store /home/atrawog/.local/share/containers/storage), so the integration test ran LIVE — a scratch image with the fixture disk layer + labels was actually built in local podman storage and inspected back. golangci-lint run ./deploykit/: zero findings on the new files (the 2 remaining repo findings are pre-existing in init.go gocyclo and oci_target_user_reset_test.go staticcheck — untouched files).

Rulebook compliance

  • R1 (RCA every anomaly): HOW — one implementation failure occurred: the first write of the Go sources landed with template-literal escape corruption (backslash-n inside Go string literals decoded to raw characters). RCA: the file content was authored inside a TS template literal, which interprets backslash escapes; the fix re-authored both files line-by-line with TS-escaped literals so the bytes on disk are exactly the Go source, and the build/test gate then passed. Not a retry of the same edit — the authoring mechanism changed.
  • R3 (no duplication): HOW — reads via the existing container.InspectLabels / LocalImageExists inspect seam (the same one deploykit.ExtractMetadata re-exports); the completeness gate is imported from spec (CheckVmBoxLabelCompleteness), not re-implemented; label quoting reuses spec/shellquote.ShellQuote. No second inspect implementation.
  • R4 (no workarounds): N/A — no sleeps, retries, or hand-pins; the spec pin is the merged tag-on-merge tag v0.2026246.554.
  • R5 (delete legacy): N/A — additive (new file + new tests); no legacy path replaced.
  • R6 (git safety): HOW — feat/vm-box-emit branched from origin/main (verified base: origin/main == merge-base == 7fe92b7), no force-push, no direct main push, no hook bypass. Working tree clean after commit; git show --stat confirms exactly the 4 intended files.
  • R7/R10 (prove the gate): HOW — full go build ./... + go test ./... + gofmt -l . all green FROM THE COMMITTED TREE (re-run after git commit, output above), including the live podman integration test.

Change classification

  • change_class: feature (sdk contract-consumer + emitter/reader pair)
  • verification_gate: go build ./... + go test ./... (full module) + gofmt -l . on the committed tree; live podman integration test ran
  • attribution_tier: fully tested and validated

Assisted-by: pi ollama-cloud/deepseek-v4-flash:0731 (fully tested and validated)

…litiesFromLabels

Task 2 (sdk half) of the VM-box cutover: a VM box is an OCI image whose
labels carry the VM metadata contract (spec.VmBoxMetadata, whole-struct JSON
on ai.opencharly.vm.box) and whose layer carries the disk artifact.

- bump github.com/opencharly/spec to v0.2026246.554 (the tag-on-merge tag of
  spec PR #90, which landed VmBoxMetadata/VmBoxSource/LabelVmBox/VmBoxLabelMap)
- EmitVmBox: scratch Containerfile (COPY disk /disk.qcow2 + vm.box/version/
  description labels) via podman build into local storage
- VmCapabilitiesFromLabels: engine inspect -> ai.opencharly.vm.box -> unmarshal
- tests: label round-trip, spec completeness gate, live podman emit/read-back
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: ae578d8c0976 (branch: feat/vm-box-emit)

Security screen: PASS — no embedded instructions, no scope mismatch (all 4 files accounted for in the body), no secrets/exfiltration, no weakened guardrails, spec dependency bump is a legitimate tag-on-merge pin for the new functionality.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3: body accounts for all files, pasted go build/go test/gofmt output from the committed tree, live podman integration test executed the new code paths — "fully tested and validated" tier justified; Assisted-by: footer present in exact form.
  • R1: RCA given for the template-literal escape incident; zero warnings in gate output. The two golangci-lint findings are in untouched files outside this PR's scope (transparent disclosure, not a defect in touched modules).
  • R3/R4: reuses container.InspectLabels/LocalImageExists/shellquote.ShellQuote/spec.CheckVmBoxLabelCompleteness — no duplication, no workarounds.
  • R10: full-module tests green; new tests (round-trip, completeness gate, live emit/read-back with single-layer assertion) prove the new functionality and would fail without it.
  • B16 placement: CORRECT — EmitVmBox/VmCapabilitiesFromLabels in deploykit mirror the established pod-side WriteLabels/CapabilitiesFromLabels pair; a reusable mechanism consumed by candies, consistent with the sdk's deploy kit layer.
  • R6/R8/R9, ADE/SDD, concurrency, disposable-only: N/A or satisfied.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 3, 2026 06:12
@github-actions
github-actions Bot merged commit 5e5c55f into main Sep 3, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 3, 2026
@aitrawog
aitrawog deleted the feat/vm-box-emit branch September 25, 2026 19:08
github-actions Bot pushed a commit that referenced this pull request Oct 8, 2026
…egs) (#358)

* chore(deps): adopt spec v0.2026280.2244 (the sdk#315 and sdk#253 consumer legs)

Bumps `require github.com/opencharly/spec` v0.2026276.0 -> v0.2026280.2244 via
`go get` + `go mod tidy` (the toolchain, never a hand-pin) and adapts the two
consumer surfaces the adopted range changes:

1. spec#208 removed `spec.LocalPkgInstallStep.Version` (with its view
   round-trip) after #354 deleted the field's only writer. The
   dead-vestige guard added in that PR asserted the field was EMPTY, which no
   longer typechecks; it now asserts STRUCTURALLY that the type has no `Version`
   field at all — a reinstated assignment is a compile error, and the reflection
   check keeps the vestige from creeping back as a field without a writer.

2. spec#202 made a ref's identity its PROJECT identity, not the enclosing
   repository (the fix for the false import back-edge sdk#253 measured as three
   namespace failures). `loaderkit.RepoIdentity` is a plain alias of
   `spec.RepoIdentity`, so the stale expectation in `TestRepoIdentity` is updated
   to the project identity and the reason is recorded at the assertion: stripping
   `@github.com/o/r/candy/x:v1.2.3` to `github.com/o/r` is the PRE-#202
   behaviour.

This closes the residual the sdk#253 dossier named — "sdk's own go.mod still pins
spec v0.2026276.0 (a pin bump, not the defect)" — in the same range.

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

* docs(deploykit): reconcile one retirement's provenance to what is retained

The validator's R1/R5 finding is correct and the divergence was introduced by this
hunk: one event — "the field lost its only writer" — was attributed three ways
(sdk#315 in the new comment, sdk#313 in the new error string directly beneath it, and
sdk#354 in the PR body), and the guard-adding PR was attributed to #354.

Measured, rather than picked from the three:
  - #315 does NOT resolve as a pull request; it is the ISSUE, now CLOSED:
    "deploykit: install_build.go still assigns the now-unpopulated EffectiveVersion
    (dead after sdk#313)".
  - the assertion this change replaces — the retained evidence, itself tagged sdk#315 —
    said the box's EffectiveVersion "lost its only writer in sdk#313".
  - opencharly/spec#208 is the spec-side PR of that retirement (the field and its view
    round-trip), which is what this change adapts to.
  - #354 is a loaderkit fix ("the candy-manifest fallback runs the one
    desugar step (#323, #315)"), not the field's retirement, so naming it as the writer's
    deleter or the guard's author was false.

The comment and the error string now both say the same thing: the writer was already
lost in sdk#313; the retirement is tracked by ISSUE sdk#315 and landed on the spec side
as spec#208. No PR number is invented for the guard: the commit that added it could not
be measured from this checkout (`git log -S` on its text finds nothing here), so the
text names the issue instead of guessing a number.

Refs #315, opencharly/spec#208

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
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.

1 participant