Skip to content

fix(deploykit)!: persist a bed member's from: cross-reference - #651

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/bed-vm-crossref
Nov 27, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/bed-vm-crossref

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Persist a bed member's from: same-kind cross-reference when the check runner seeds the per-host deploy overlay, so the member survives the persist→load round-trip.

deploykit.PersistBedDeployOverrides built its SaveDeployStateInput from the bed node's image and target but never set VmCrossRef. A member declared from: <vm> has no image (node.Image is empty), so the written entry was vm: {disposable: true} with no source; the next load dropped it as a degraded entry, and the SDK save guard refused the following write:

refusing to write …/charly.yml — it holds 2 deploy entr(y|ies) but only 1 load

That is how charly check run check-sidecar-pod failed at [config] for its ephemeral-VM member check-sidecar-pod-ephvm (opencharly/charly#1299).

  • deploykit/bed_session.go — set VmCrossRef: node.From in the SaveDeployStateInput at the one call site; applyDeployState already maps it onto entry.From (deploykit/deploy_state.go:519-520).
  • deploykit/bed_session_test.go — the round-trip test: a from: eval-vm member saved through PersistBedDeployOverrides must still name its source on reload and must not be dropped as degraded.

Head 62d4ea83937b4f3a185d3f8d82832b71419c09f2; two files changed (+129/−10).

How tested

The change-class gate ran on the committed tree (the head this PR publishes):

# head 62d4ea83937b4f3a185d3f8d82832b71419c09f2
== gofmt -l . ==
(empty)
== go vet ./... ==
vet_exit=0
== go build ./... ==
build_exit=0
# head 62d4ea83937b4f3a185d3f8d82832b71419c09f2
ok  	github.com/opencharly/sdk	0.141s
ok  	github.com/opencharly/sdk/agentkit	0.867s
ok  	github.com/opencharly/sdk/artifactkit	0.037s
ok  	github.com/opencharly/sdk/auditkit	0.104s
ok  	github.com/opencharly/sdk/buildcache	0.656s
ok  	github.com/opencharly/sdk/buildkit	0.023s
ok  	github.com/opencharly/sdk/buildkitdrive	0.032s
ok  	github.com/opencharly/sdk/candywalk	0.037s
ok  	github.com/opencharly/sdk/charlylib	0.012s
ok  	github.com/opencharly/sdk/checkkit	0.007s
ok  	github.com/opencharly/sdk/cmd/charly-lib-gen	0.003s
ok  	github.com/opencharly/sdk/deploykit	12.302s
ok  	github.com/opencharly/sdk/enginekit	0.008s
?   	github.com/opencharly/sdk/internal/spectest	[no test files]
ok  	github.com/opencharly/sdk/kit	12.838s
ok  	github.com/opencharly/sdk/llmkit	2.221s
ok  	github.com/opencharly/sdk/loaderkit	1.066s
ok  	github.com/opencharly/sdk/packagekit	0.037s
ok  	github.com/opencharly/sdk/rawbody	0.004s
ok  	github.com/opencharly/sdk/storekit	0.734s
ok  	github.com/opencharly/sdk/vmshared	0.118s
ok  	github.com/opencharly/sdk/workflowkit	0.003s
test_exit=0

golangci-lint v2.13.2 (the pin in .github/workflows/ci.yml) also passed on the same tree; the host's default GOROOT is go1.27.4 while the installed lint binary was built with go1.26.8, so it is invoked against the matching toolchain:

$ GOTOOLCHAIN=go1.26.8 golangci-lint run ./...
0 issues.
lint_exit=0

Spike

R12 candidates, each checked against the real code and real behaviour:

(a) Set VmCrossRef: node.From at the call site — WORKS (winner, implemented). A focused spike called SaveDeployState with VmCrossRef: node.From for a {From:"eval-vm", Target:"vm", Disposable:true} node; the written overlay was:

ephvm:
    vm:
        from: eval-vm
        disposable: true

The permanent test then proves the full PersistBedDeployOverrides round-trip (persist → reload → the member keeps its source and the next save is not refused).

(b) Resolve the cross-ref inside SaveDeployState from the node itself — FAILS. SaveDeployState(boxName, instance string, input SaveDeployStateInput, marshalNode, read, ctx) (deploykit/deploy_state.go:464) receives no node, so there is nothing to resolve from; handing it one is candidate (c)'s API change, and it would duplicate the semantic SaveDeployStateInput.VmCrossRef already owns — applyDeployState already writes entry.From from it.

(c) Have the bed session pass the full node rather than its image — ALREADY TRUE, and not the defect. PersistBedDeployOverrides(ctx, name string, node DeployNode, …) already receives the full node (deploykit/bed_session.go:63); the defect is the field mapping inside it (Box: node.Image, no VmCrossRef), not the parameter type. Making SaveDeployState take a node is (b) again.

Only (a) is implemented.

Mutation evidence (the test fails without the change)

Committed head with the VmCrossRef line removed (mutation):

# head 62d4ea83937b4f3a185d3f8d82832b71419c09f2 (mutation: VmCrossRef line removed)
=== RUN   TestPersistBedDeployOverrides_PersistsVmCrossRef
    bed_session_test.go:94: persisted member From = "", want eval-vm — the entry loses its source and the load drops it as degraded; overlay:
        check-sidecar-pod-ephvm:
            vm:
                disposable: true
        web:
            pod:
                image: web
--- FAIL: TestPersistBedDeployOverrides_PersistsVmCrossRef (0.00s)
FAIL
mutation_test_exit=1

Committed head with the fix restored:

# head 62d4ea83937b4f3a185d3f8d82832b71419c09f2 (fix restored)
=== RUN   TestPersistBedDeployOverrides_PersistsVmCrossRef
--- PASS: TestPersistBedDeployOverrides_PersistsVmCrossRef (0.00s)
PASS
restored_test_exit=0

Rulebook compliance

  • R0 — the four dispatched skills were loaded before the first action (git-workflow, go, cutover-policy, strict-policy).
  • R1 — the root cause was established in the SDK tree, not assumed (evidence above): PersistBedDeployOverrides never set VmCrossRef, applyDeployState already reads it. Zero warnings. The one anomaly surfaced was a host toolchain mismatch (the installed golangci-lint was built with go1.26.8 while the host GOROOT is go1.27.4, so it panicked file requires newer Go version go1.27); RCA: external environment condition, not a repo defect, resolved by GOTOOLCHAIN=go1.26.8 (exit 0, 0 issues), so no issue was filed.
  • R2 — one call site, one field mapping; no duplicate implementation and no sibling path carries the same omission (grep -rn 'SaveDeployStateInput{' --include=*.go . matches only deploykit/bed_session.go:75).
  • R3 — no workaround: the degraded-load guard is untouched; the persist names the source instead of relaxing the guard.
  • R4 — no documentation routes around the defect.
  • R5 — no identifier is removed or renamed, so there is no stale reference to sweep.
  • R6 — git status --porcelain was empty before the commit and after it; no force-push, no direct push to main; PR only.
  • R7 — the new test fails without the change (mutation pasted above) and passes with it.
  • R8 — no live service boundary is involved; the test is a pure in-process round-trip.
  • R9 — a library change; no binary is deployed, and no runtime OS dependency is added.
  • R10 — gofmt -l . empty, go vet ./..., go build ./..., go test -count=1 ./... and golangci-lint all exit 0 on the committed tree.
  • R11 — conforms to D-DEP-1 (a vm is written with the same from: a pod is written with; the member's from: now survives persistence rather than being dropped). No DESIGN amendment is needed.
  • R12 — the spike round above; only the working candidate is implemented.

Change classification

Change class: SDK library fix (deploykit) with a Go test; no schema or wire-shape change.

Breaking change + rollback: the ! marks a consumer-visible behaviour change — a bed member's from: is now persisted, so the follow-up charly config no longer trips the degraded-load refusal that previously failed the bed. The exported API and SaveDeployStateInput are unchanged. Rollback is reverting this commit: the prior behaviour (a source-less persisted entry, and with it the refusal at the next save) returns, and beds with a from: member fail again at [config].

Relates to opencharly/charly#1299
Relates to opencharly/opencharly#1318

A3 — the trailer names the model the harness reports for this session (deepseek-v4.1-flash:cloud); the org validator's own signature reads ollama-cloud/deepseek-v4.1-flash. Harness: Claude Code.

Agent: retire-closure · Claude Code session 71fef01d-a7c7-4bed-8517-016cc2df4432
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

PersistBedDeployOverrides seeded the per-host deploy entry from a bed node's
image + target but never its same-kind cross-ref. A bed member declared
`from: <vm>` has NO image (node.Image is empty), so the written entry was
`vm: {disposable: true}` with no source. The next load drops that entry as a
degraded load, and the SDK save guard (deploykit/deploy_file.go, the
DEGRADED-LOAD GUARD) refuses the following write:

  refusing to write …/charly.yml — it holds 2 deploy entr(y|ies) but only 1 load

That is how `charly check run check-sidecar-pod` failed at [config] with its
ephemeral-VM member `check-sidecar-pod-ephvm` (opencharly/charly#1299).

applyDeployState already maps SaveDeployStateInput.VmCrossRef onto entry.From
(deploykit/deploy_state.go:519), so the root fix is to persist the node's From
at the one call site. The degraded-load refusal disappears because the entry
now names its source and loads.

The new test (deploykit/bed_session_test.go) fails without the change: the
persisted member is source-less, the reload drops it (1 of 2 entries), and the
follow-up save is refused; with the change the entry keeps `from: eval-vm` and
both entries load.

Relates to opencharly/charly#1299
Relates to opencharly/opencharly#1318

Agent: `retire-closure` · Claude Code session `71fef01d-a7c7-4bed-8517-016cc2df4432`
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 62d4ea83937b4f3a185d3f8d82832b71419c09f2 (branch: fix/bed-vm-crossref)

Security screen: PASS — no secrets, no egress, no weakened guardrail (the degraded-load guard is untouched), no supply-chain change; body is untrusted data and contains no directive to me.
Checklist: A1–A3, R0–R12, PIL, CONC, HC, ARCH (placement CORRECT — sdk deploykit mechanism, no alias/core growth), DISP, QUAL, COORD, comment intake (0 comments): all applicable PASS or NA. Diff matches the description; the new test fails without the change and passes with it (mutation evidence pasted); spike block present with winner (a) implemented; attribution analysed on a live system is honest and not inflated. Tool-limited: I cannot re-run the Go suite/lint, but the pasted output is internally consistent with the diff and file counts (+129/−10).

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 27, 2026 12:43
@github-actions
github-actions Bot merged commit 40457db into main Nov 27, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 27, 2026
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Nov 27, 2026
…ed, group bed green (#1304)

github.com/opencharly/sdk v0.2026331.837 -> v0.2026331.1243 (opencharly/sdk#651,
tag v0.2026331.1243): deploykit.PersistBedDeployOverrides now persists
SaveDeployStateInput.VmCrossRef (node.From), so a bed's deploy-level `from:`
member keeps its same-kind source when it is written to the per-host overlay.

Before (recorded at .check/check-sidecar-pod/2026.331.1146/config.log:10, main
without this pin): `charly check run check-sidecar-pod` failed at [config] with
"refusing to write /tmp/charly-bed-cfg-check-sidecar-pod-.../charly.yml — it
holds 2 deploy entr(y|ies) but only 1 load".

After: [config] PASS; [deploy-add] PASS; [bring-up-members] PASS;
ephemeral-register-roundtrip PASS.

The same pin moves in the three in-repo tools modules that carry it, aligned with
`charly task mods-tidy`; tools/gomod-canonical's TestContractPinsMatchShared
polices the lockstep.

Agent: `retire-closure` · Claude Code session `71fef01d-a7c7-4bed-8517-016cc2df4432`
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
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