Repository navigation
feat(core)!: K3 build-engine core-minimization — reentry-class + render-seam + feature-command - #139
Conversation
#39) Consumer half of the sdk spec.DoMode/spec.ExecContext/spec.StepDoMode move: checkspec.go's local kit.DoMode alias is gone (VerbCatalog/VerbSpec now carry spec.DoMode/spec.ExecContext directly); layers.go, planrun_adapter.go, description_collect.go, and candy/plugin-box/validate_check.go repointed from kit.X/deploykit.X to spec.X. checkspec.go's deploykit.OpInContext DI-hook registration relocated to layers.go (which already imports deploykit for other reasons) so checkspec.go now imports neither kit nor deploykit at all. Assisted-by: Claude Sonnet 5 (analysed on a live system)
…/plugin-box Deletes the __box-labels core reentry: BoxLabelsCmd's whole Run() body was pure container-storage probing (kit.ResolveRuntime/ResolveLocalImageRef/ InspectLabels), zero live-loader coupling — unlike its pkg/inspect-overlay/ list-tags/fetch/refresh siblings, which genuinely need host-coupled state and stay K5-doomed reentries. candy/plugin-box's `labels` command now calls the promoted sdk/kit.InspectImageLabels (prior commit) directly, so the labels word needs no host reentry at all — dispatchLabels drops its hostClient parameter entirely, matching the `new` group's zero-reentry shape. canonicalLabelKey/sortedLabelKeys move with it; the misplaced TestApplySecretRefresh_NamedAllAndUnmatched (actually testing secrets.go's ApplySecretRefresh) moves to secrets_test.go where it belongs. Also fixes a latent FormatCLIError bug this move exposed: its ref-extraction assumed kit.ErrImageNotLocal's message was the WHOLE error text (a bare strings.TrimPrefix), which broke the instant a compiled-in command's error crossed dispatchInProcCommand's generic "command %q: %w" wrap (candy/ plugin-box's labels command is the first ErrImageNotLocal caller to hit that path — every prior caller went through the old __box-labels SUBPROCESS reentry, whose own inner FormatCLIError call never saw the outer wrap). Now finds the marker anywhere in the message via strings.LastIndex, so `charly box labels <missing-image>` renders the friendly "run box pull" recommendation correctly whether ErrImageNotLocal is bare or wrapped. Live-verified on a rebuilt binary against a real check-pod image: happy path (`box labels`, `--format`, `--all`), the missing-image error path (pre- and post-fix), all via box/fedora's check-pod fixture. Metric: kit-importing charly/*.go files 155 -> 154. Assisted-by: Claude Code Claude Sonnet 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
Removes host_build_render_seam.go's RenderSeamRenderService/ RenderSeamDetectionBuilder/RenderSeamExternalBuilder/RenderSeamRewriteHeaderCopy/ RenderSeamValidateEgress cases: candy/plugin-build's render no longer calls back for these (sdk commit — the seams now dispatch directly via InvokeProvider). Their underlying host functions (RenderService, egressValidate/validateTextEgress, resolveDetectionBuilderStageSeam, resolveExternalBuilderStageSeam, rewriteHeaderCopyForRemote) are NOT deleted — they remain load-bearing for toDeploykit(), a SEPARATE, parallel deploykit.Generator construction charly core itself uses for generate.go's helper wrappers (GlobalOrderForBox/GenerateInitFragments/ CollectBuilderRuntimeEnv/BuildStageContext/CandyCopySource) and step_emit_hostbuild.go's live emitTasks/buildStageContext calls — verified by grep before touching anything (caught before an incorrect deletion, R1). So this cutover does NOT retire any whole file from charly/*.go's kit-import list (metric unchanged at 154) — genuine, live-verified decoupling of candy/plugin-build from 5 of 9 render-seam host callbacks, but not a metric-moving change under the "whole files out of core" scoreboard. Live-verified: box/fedora's check-pod bed, full R10 sequence (build through fresh-rebuild), PASS (12/12 steps) — the external-builder splice, the supervisord service render, and the remote header-copy materialization (.build/_buildconfig/templates/supervisord.header.conf) all confirmed correct in the generated Containerfile + runtime checks. Assisted-by: Claude Code Claude Sonnet 5 (fully tested and validated) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…e (K3) computeEffectiveVersions was a 13-line, ONE-caller shim doing nothing but delegating to deploykit.ComputeEffectiveVersions. Inlines the call directly at its sole call site (generate.go's NewGenerator) and deletes the file outright — a whole FILE off charly/*.go's kit-import list, not a partial extraction (per the velocity-correction strategy: the metric is whole files, not LOC/coupling reduction alone). Updated the test file's calls to the direct deploykit form (same behavior, no charly wrapper) and swept the one stale generate.go/unified.go comment reference. Verified: go build/vet/test clean; charly box validate (box/fedora, exit 0) + the check-pod bed's build step both exercise this exact code path live. Metric: 154 -> 153. Assisted-by: Claude Code Claude Sonnet 5 (fully tested and validated) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…t/deploykit Moves the plan-to-summary transform (keyword/text/agent/check flattening + kit.ValidatePlanSteps + deploykit.DescriptionInfo) from host_build_feature.go into candy/plugin-feature/command.go, which already owns the list/pending/validate grammar. The host now enumerates every kind: entity's RAW description + plan (spec.Step, already a plain CUE-sourced wire type) and ships it as-is; the plugin computes summary/steps/validation itself. host_build_feature.go needs no kit/deploykit import as a result -- a genuine whole-file drop off the core kit-import list (not a partial split), per the binding architectural rule that a host-coupled REMAINDER left behind is a failed move: the ONLY thing still core-side is LoadConfig/ScanCandy (the loader Mechanism itself), which the file's own doc comment already named. Updated host_build_feature_test.go to assert on the raw Plan field (and call kit.ValidatePlanSteps directly, matching the plugin's own call); added command_test.go in candy/plugin-feature covering the moved planSteps/summary transform. Live-verified on box/fedora (a real project with 3 baked box entities): `charly feature list` (with/without a kind filter), `charly feature pending`, and `charly feature validate` (correctly flags 2 pre-existing box entities with an empty description: field, unrelated to this refactor -- exit 1, as expected) all render byte-equivalent output to the pre-refactor design. go build/vet/test/golangci-lint clean across sdk, charly, and candy/plugin-feature. Metric: 151 -> 150. Assisted-by: Claude Code Claude Sonnet 5 (fully tested and validated) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…-seam + feature-command Assisted-by: Claude Code Claude Sonnet 5 (documentation reviewed) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…erContext The render-seam production move promoted buildServiceRenderContext/ flattenedEnvMap/sortedEnvList to sdk/deploykit as BuildServiceRenderContext (so both charly's own RenderService and candy/plugin-build's render share one source, R3) but left charly's OWN local copies in place instead of repointing to the promoted version -- a genuine duplicate this cutover introduced, caught while re-auditing per the operator's "keep hunting" directive. RenderService now calls deploykit.BuildServiceRenderContext directly; the file drops its kit import (no longer needs kit.ExpandPath locally) but gains deploykit (needed for the call + the already-present CandyModel-adjacent seam) -- metric-neutral, but a real duplication fix. All 9 existing service_render_test.go tests pass unchanged (byte-identical rendered output through the shared function). Live-verified: box/fedora's check-pod bed (which exercises supervisord service rendering directly), full R10, PASS 12/12. Assisted-by: Claude Code Claude Sonnet 5 (fully tested and validated) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
R5 fix: image.go's BoxCmd migration-inventory comment still named the deleted box_labels_cmd.go (a PR-validation blocker — a false claim would have shipped). Now names labels.go and the 2026-07 K3 externalization. Bucket-1 fold-in (a read-only spike into toDeploykit()'s remaining Generator-consumers): generateInitFragments and candyCopySource have zero non-test callers — their own doc comments named a caller (deploy_target_pod.go) that no longer exists, and candy/plugin-deploy-pod/ overlay.go already calls deploykit.Generator.GenerateInitFragments/ .CandyCopySource directly on its own NewRenderGeneratorFromProject Generator, bypassing these wrappers entirely. Deleted both from charly/generate.go. Their test coverage (TestGenerateInitFragments, TestGenerateRelayInitFragments, TestCandyCopySource) moved WITH the real logic to sdk/deploykit/init_test.go + sdk/deploykit/candy_stage_test.go (sdk commit 95c8577) rather than being discarded, since neither function had any coverage of its own in that package. Metric-neutral (150; both deletions were charly-core-only, no kit/ deploykit import at stake). R10: go build/vet/test clean on both repos (charly 88s full pass, sdk deploykit pass); golangci-lint 0 issues on both. charly check run check-pod (box/fedora, per-worktree binary rebuilt from this branch): PASS, 12/12 steps including the fresh-rebuild gate and post-rebuild feature verification (total 217s), clean teardown. Assisted-by: Claude Sonnet 5 (fully tested and validated)
sdk#65 merged as e779c531 (tagged v0.2026198.254); plugins#81 merged as 4a2ac8d2 (tagged v2026.198.0256). Repoints both submodule pointers from their pre-squash branch tips to the real merged commits (the sdk#63 lesson: a pre-squash tip becomes unreachable after squash-merge). Assisted-by: Claude Sonnet 5 (fully tested and validated)
Independent PR validation — PASSFresh, independent re-derivation across 3 rounds (fresh worktree, trusting no author/orchestrator claims): Round 1 (head fc5906b/771275c/2b68894): metric independently re-walked file-by-file: main=154, branch=150 (confirmed, not trusted). Architecture gate on every kept/touched core file: Found ONE real issue: Round 2 (head 1a03a2e, the R3 self-fix): re-verified build/vet/test/lint clean, metric still 150, the 3 dissolved Round 3 (head 0183b60, the R5 fix + Bucket-1 dead-code deletion): confirmed the Final gitlink bump (6f282d4): repointed sdk → Landing: sdk#65 merged as |
Summary
The charly-side (super) leg of the K3 "build-engine → plugin-build" cutover, part of the ongoing core→plugin metric program (
charly/*.gofiles importingsdk/kit/sdk/deploykit/sdk/buildkit: 157 → 0). Depends on sdk PR opencharly/sdk#65 merging first.Four whole-file / real retirements, no remainders left behind:
charly/box_labels_cmd.godeleted — the hidden__box-labelscore reentry.candy/plugin-box'slabelscommand now callskit.ResolveRuntime/kit.ResolveLocalImageRef/kit.InspectImageLabelsdirectly (pure container-storage probes, zero loader coupling) —dispatchLabelsdrops itshostClientparameter entirely, matching thenewcommand group's already-zero-reentry shape.canonicalLabelKey/sortedLabelKeysmoved with it. Also fixes a latentFormatCLIErrorbug this move exposed (itskit.ErrImageNotLocalref-extraction assumed the sentinel's message was the WHOLE error text — broke the instant the error crossed the compiled-in command dispatcher's generic"command %q: %w"wrap; no prior caller had ever exercised that path). Added the testFormatCLIErrornever had.Render-seam production move —
charly/host_build_render_seam.godrops 5 of its 9 dispatch cases (RenderSeamRenderService/RenderSeamDetectionBuilder/RenderSeamExternalBuilder/RenderSeamRewriteHeaderCopy/RenderSeamValidateEgress):candy/plugin-build's render no longer calls back for these (sdk-side commit wires the directInvokeProviderdispatch). The underlying host functions (RenderService,egressValidate/validateTextEgress,resolveDetectionBuilderStageSeam,resolveExternalBuilderStageSeam,rewriteHeaderCopyForRemote) are not deleted — they remain load-bearing fortasks.go'stoDeploykit(), a separate, paralleldeploykit.Generatorconstruction charly core itself uses forgenerate.go's helper wrappers andstep_emit_hostbuild.go's live calls (found via grep before touching anything, avoiding a real regression). So this piece is metric-neutral by itself (154, unchanged) but is real, live-verified decoupling ofcandy/plugin-buildfrom those 5 host callbacks.charly/effective_version.godeleted — a 13-line, one-caller shim (computeEffectiveVersionsdelegating todeploykit.ComputeEffectiveVersions), inlined at its sole call site ingenerate.go'sNewGenerator.charly/host_build_feature.godrops its kit/deploykit import entirely — its plan-to-summary transform (kit.KeywordOf/kit.ValidatePlanSteps/deploykit.DescriptionInfo) was calling only sdk-portable functions on data already in hand. Moved intocandy/plugin-feature/command.go(which already owns thelist/pending/validategrammar): the host now ships rawspec.FeatureEntitydata (description +[]Step, sdk PR changes the wire shape) and the plugin computes summary/steps/validation itself. What's left host-side is exactlyLoadConfig/ScanCandy— the loader Mechanism, nothing else.Metric
charly/*.gokit-importing files: main = 154 → this branch = 150 (verified against currentorigin/main, branch is 0 commits behind).Test plan
go build/go vet/go test ./...clean acrosscharly,candy/plugin-box,candy/plugin-feature,candy/plugin-buildgolangci-lint run ./...— 0 issues on every touched packagebox/fedora's realcheck-podbed, full R10 sequence (build → check-image → deploy-add → config → start → check-live → feature-run → fresh-rebuild → feature-run-rebuild → cleanup), run twice (once for the render-seam move, once after the final refactor), both PASS 12/12 — confirms the external-builder splice, the supervisord service render, and the remote header-copy materialization all render correctly in the generated Containerfilecharly box labels <ref>(default listing,--format,--all, and the missing-image error path) against a real locally-built image, both before and after theFormatCLIErrorfixcharly feature list(with and without a kind filter),charly feature pending, andcharly feature validateagainstbox/fedora(a real project, 3 baked box entities) — correct output, including a genuine pre-existing validation finding (2 box entities with an emptydescription:) unrelated to this refactorgit grepR5 self-test clean (no stale references to deleted symbols outsideCHANGELOG/)Companion PRs: opencharly/sdk#65 (merge first), a plugins docs leg (stale
charly/effective_version.goskill references).Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif