Skip to content

feat(spec)!: K-wave seam-death terminus — loader seams, deploy/check wire vocabulary, service hooks, defect closures - #17

Merged
atrawog merged 37 commits into
mainfrom
feat/v2-kwave-terminus
Aug 5, 2026
Merged

atrawog merged 37 commits into
mainfrom
feat/v2-kwave-terminus

Conversation

@atrawog

@atrawog atrawog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The spec leg of the K-wave seam-death terminus (everything-is-a-plugin 100%, the #55 successor): 34 commits across the five program waves + the terminus defect-closure arc.

Highlights (full narrative in CHANGELOG/2026.999.0001.md, per-commit bodies carry the RCAs):

  • Loader seam family (K1): the ProjectLoader seam gains the full loader-orchestration surface (DecodeEntityViaCUE, CueSchema handle + CUE-validate methods, kind-decode/tree-builder/box-validate-walk/remote-fetch seams) so plugins load projects themselves.
  • Deploy+check wire vocabulary: 8 pod-lifecycle types unified; endpoint/image-label resolve + drain ops added; check-bed session dissolved with shared predicates promoted; dead wire shapes deleted (DeployEntityResolve, render-service, DeployMembers, hostprobe, …); PhasePreflight + OpPreflight; RequestedBoxes.
  • Terminus closures: RunCharlySubcommand via os.Executable(); flock-held temp roots (the live-build sweeper kill); RunBootstrapPhase loud failure; the alias-immune untagged image resolve (the cross-bed image-crossing D2 fix); exec_start_pre/post service hooks (the k3s cpuset-guard/CRD-healer carriers).

Proof: the 28-bed disposable roster at measured caps (run 3: 23/28 with all 5 tails dispositioned + re-proven green — three-bed acceptance sets pasted in the session record), zero warnings, full test/lint/validate gates green. Breaking changes carry ! per commit.

B2 chain: this spec leg lands FIRST; sdk (pins spec), plugins, box/fedora, and the superproject follow in order.

Assisted-by: Claude Code Anthropic Fable 5 (fully tested and validated)

https://claude.ai/code/session_015CXB8CkzwZeXPzbqKjsuYj

atrawog added 30 commits August 3, 2026 22:19
…der seam

The per-entity CUE decode mechanism (shorthand normalize + CUE-ingest +
Decode) relocates out of charly core to sdk/loaderkit (K1 loader keystone,
task #12). This adds the typed seam method every kind/candy/node-form decode
in core now routes through, mirroring LoadUnified's placement — compiled-in
only, no wire envelope.

Rides the terminus B2 chain: charly's super leg repoints layers.go/
node_build.go through this seam and deletes cue_normalize.go/cue_loader.go
in the same program.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…ethods

The CUE-validate mechanism (entity closedness, the #NodeDoc load-time gate,
schema-defaults fill, YAML->cue.Value ingest) relocates out of charly core to
sdk/loaderkit (task #12). Unlike unit 1's DecodeEntityViaCUE, these functions
Unify against the host's compiled sharedCueSchema — cue.Value instances only
interoperate within the cue.Context that built them, so loaderkit cannot
compile an independent copy the way unit 1 safely did. This adds CueSchema
(Ctx/Root/KindDef) as the threaded handle to the host's process-wide compiled
schema, plus ValidateEntityClosedCUE/CueDocFromYAML/ValidateNodeDocCUE/
ApplyCueDefaults on ProjectLoader.

Rides the terminus B2 chain: charly's super leg wires candy/plugin-loader and
keeps thin same-named core wrappers (R3) that build CueSchema from the
still-core D-data (cueSchemaCtx/sharedCueSchema/cueKindDef) and call through
the seam.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…#AndroidEntityResolution

The "deploy-entity-resolve" HostBuild seam's own CUE doc pre-argued a clause-D
defense for a kernel switch on `kind` that the K-wave boundary audit refuted
(tell #2 of the boundary law's self-test: a switch on a kind word is BY
DEFINITION an R-item that leaked, regardless of the header's framing).

- Add ProjectTemplates.ByKind(kind) — the generic, kind-blind accessor the
  kernel now uses to pull a template's raw body instead of switching on kind
  Go-side. Purely additive: k8s already got namespace-qualified lookup via
  ProjectTemplates; vm/android now get the same (previously a bare, non
  namespace-aware uf.VM()/uf.Android() lookup).
- Delete #AndroidEntityResolution: its one-off wrapper existed only to thread
  google-play credentials through this seam, a purpose that already moved to
  a direct peer InvokeProvider(verb:credential) call. Once that was gone the
  wrapper carried zero information a bare #ResolvedAndroid didn't already —
  the LAST per-kind asymmetry forcing a Go branch in the host handler.
  `entity` now ships every kind:<word> lookup's Resolved* envelope JSON
  unwrapped, uniformly.
- Fix a genuine documentation divergence found while touching this doc: the
  seam's own comment still described a "local" kind:<word> arm as live; it
  was retired in K4 unit A (candy/plugin-bundle's lookupLocalTemplate reads
  the resolved-project envelope directly now, no HostBuild round-trip).

BREAKING: the `entity` field of a kind="android" DeployEntityResolveReply is
now the bare ResolvedAndroid JSON, not the #AndroidEntityResolution wrapper.
The one consumer (candy/plugin-adb) is updated in the same K-wave W0 unit.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…ort seam methods

Adds 5 ProjectLoader methods for the bundle/resource-member kind-decode
SUPPORT helpers (task #12): IsResourceDisc / BundleTargetForDisc /
SetBundleCrossRef / IsStandaloneResourceKind / FoldStandaloneTemplateReply.
Each is a pure function of a discriminator word + the registry-derived
Threaded snapshot (DeploySubstrates/DeployTraits, already filled by
loaderThreaded()) — never a live registry query, mirroring the existing
DeployTraits/ExternalDeploySubstrates threading precedent on Threaded.

Rides the terminus B2 chain: charly's super leg wires candy/plugin-loader
and keeps thin same-named core wrappers over the new seam methods.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…der seam methods

Adds 9 ProjectLoader methods for the entity-body assembly + bundle/
resource-member tree-builder mechanism (task #12): AssembleEntityBody /
DecodeNodeValue / EntityBodyJSON / BuildBundleNode / BuildResourceMemberChildren
/ BuildBundleNodeInto / IsDeployShape / DecodeStandaloneTemplateJSON /
ResourceChildren. All operate on ParsedNode (the wire-safe parsed-entity
shape), never charly core's *genericNode — genericNode is a host-internal
reconstruction that stays core solely for the TRUE clause-M dispatch's
bootstrap-critical candy/box routing (candyIsImage/buildCandy, clause B).

Also fixes a stale schema/node.cue comment naming the (now relocated)
buildResourceMemberChildren as core-resident (R1 documentation-divergence
sweep).

Rides the terminus B2 chain: charly's super leg wires candy/plugin-loader
and threads pn straight through provider_kind_invoke.go's dispatch, with
genericNode surviving in exactly one local reconstruction (foldCandyKind).

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
Adds 2 ProjectLoader methods completing the K1 unit 2 deferral (task #12):
ValidateCandyManifestCUE / ValidateNodeFormSteps — the `charly box validate`
candy-manifest entry point + its node-form step-typo walk. Both take the
host-supplied Threaded snapshot + resolved DocParser (registry-derived DATA
the host already builds for the parse) — loaderkit never queries the
registry itself.

Rides the terminus B2 chain: charly's super leg wires candy/plugin-loader
and keeps thin core wrappers over the new seam methods.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…hods

Adds spec.RefsCollectSeams (the host-supplied callbacks for everything
registry-coupled: the resolved RefsDownloader, the migrate-command
dispatch, the local-template substrate resolve, and the raw
CHARLY_REPO_OVERRIDE env value) + 2 ProjectLoader methods:
EnsureRepoDownloaded / CollectRemoteRefsOpts (task #12).

Rides the terminus B2 chain: charly's super leg wires candy/plugin-loader
and keeps thin core wrappers over the new seam methods.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…d seam schema

#RawProjectRequest / #RawProject had zero production HostBuild callers
anywhere in the tree (verified whole-tree, per-submodule grep) — the
seam was superseded before any plugin ever dialed it. Deleted the CUE
schema block and regenerated spec/cue_types_gen.go via task cue:gen
(SDD: generated code is never hand-edited). #ProjectTemplates stays —
it is genuinely shared D-fact consumed by deploy-entity-resolve,
sidecar, and k8s-status seams.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…sumer projection

Extends #ArbiterInvokeInput (spec/schema/arbiter.cue) with an optional node
projection (is_group/is_pod_member/security_devices) so the compiled-in
verb:arbiter can compute its own implied-GPU-consumer token on the
acquire-shared action, instead of the in-core proxy computing it via a
LoadUnified(".")-coupled read (the former charly/gpu_imply.go). A legal
field addition on an existing wire input, not a new action — task cue:gen
regenerated spec/spec/cue_types_gen.go cleanly (no drift beyond the 3 new
fields; every other generated file, including all plugin params/, is a
byte-for-byte no-op).

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…ge metadata fields

BaseUser/BaseSecurity/BaseRegistry on #OverlayBuildReply existed only because the
host-side pod-overlay build prep (charly/build_overlay.go) ran `podman inspect`
on the candy's behalf, on the (refuted) claim that "a sdk-only candy cannot exec
podman inspect itself" — spec/container.ExtractMetadata is already re-exported as
sdk/deploykit.ExtractMetadata / sdk/kit.ExtractMetadata, so candy/plugin-deploy-pod
reads this metadata plugin-side from reply.BaseImage directly. CUE is the single
source of truth (schema/buildwire.cue); cue_types_gen.go regenerated via
`task cue:gen` (exact 3-field deletion, no other diff).

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…image/-ssh-key wire types

#PodConfigEnsureImageRequest/Reply and #PodConfigSSHKeyRequest/Reply
(spec/schema/seam.cue) have zero consumers left: both HostBuild seams they
served died in this cutover (candy/plugin-deploy-pod now drives podman +
build:ensure and reads the SSH-key host FS itself — see the charly commit).
Both deleted types' own header comments argued permanence ("a plugin cannot
resolve the local podman image store namespace itself"; "kept as a narrow
host seam rather than adding a crypto dependency") — both claims are
refuted by the move, not just superseded (spec/sshx already pulls
golang.org/x/crypto transitively via other consumers, so the SSH-key
seam's stated crypto-avoidance rationale was never actually achieved).

task cue:gen regenerated spec/spec/cue_types_gen.go cleanly — no drift
beyond the 4 removed fields; every other generated file (all plugin
params/) is a byte-for-byte no-op.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…robe" seam + dead device-patterns schema

The former "hostprobe" HostBuild kind's wire types (#HostProbeRequest/#HostProbeReply/
#HostProbeDevice/#HostProbeDistro) are gone: candy/plugin-doctor now gathers every host
fact itself (own embed for the data tables, peer InvokeProvider to candy/plugin-gpu's
verb:gpu and candy/plugin-secrets' verb:credential) instead of round-tripping through a
core-only seam. #GpuProbeInput drops its three data-table fields (device_patterns/
gpu_vendors/pci_class_labels) for the same reason — plugin-gpu now carries its own copy,
the one actual detection consumer (R3), rather than threading a core-owned copy over the
wire on every call.

#NodeDoc's 7 corresponding directive fields (install_hints/device_descriptions/
device_patterns/gpu_vendors/pci_class_labels/distro_package_managers/distro_family_map)
are deleted too — they were used by no charly.yml ever, project or box, only charly-core's
own embedded default config, which no longer carries this data.

Also deletes #DevicePatternsRequest/#DevicePatternsReply (seam.cue) — found DEAD during
this cutover's R1 sweep: a fully-generated, fully-documented CUE type describing a PLANNED
"device-patterns" HostBuild seam with ZERO Go implementation or callers anywhere in the
tree. Orphaned scaffolding, never a live seam.

#CredentialHealth is kept — still the shared verb:credential health-probe reply shape,
consumed by charly-core's credential_plugin.go and candy/plugin-doctor's own peer call.

task cue:gen: clean regeneration, reproducible.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…n additive)

Adds only_ids to #VerifyChecksRequest (spec/schema/checkresult.cue): the
plugin-side check-filter subset the former core-side unified_targets.go
pre-filter loop applied before dispatch. OPT-IN ADDITIVE by construction —
unset/empty runs every op, byte-identical to check_cmd.go's
runLocalDeployScopePlan, the request's only other caller, which never sets
it.

task cue:gen regenerated spec/spec/cue_types_gen.go cleanly — no drift
beyond the 1 new field; every plugin params/ file is a byte-for-byte no-op.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…ase + OpPreflight selector

Adds phase.PhasePreflight ("preflight"), placed FIRST in PhaseOrder: it fires even earlier
than PhaseBootstrap, before Kong even parses a project, since it isn't about project-loading
lifecycle at all — it's the entry point for a plugin that must run BEFORE ANY command
dispatch, regardless of whether a project even loads. candy/plugin-doctor's new
verb:freshness-guard capability (companion charly/candy commit) is the first consumer,
replacing charly/main_freshness.go's core-only guard.

Adds ops.OpPreflight ("preflight"), the wire selector a phase.PhasePreflight provider's
Invoke compares req.GetOp() against — mirroring ops.OpBootstrap's shape exactly (a
kernel-driven pre-pass hook, not a caller-initiated verb dispatch).

Both are plain hand-written Go constants (neither ops nor phase is CUE-generated — the
existing OpBootstrap/PhaseBootstrap precedent already establishes this), so no task cue:gen
was needed.

Gate: spec/ build+test all green (whole module); ops/phase package tests updated for the new
selector/phase (TestOpSelectorsStable/TestOpSelectorsDistinct/TestPhaseOrderAscending).

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
K-wave W3a A3-phase-2: the "deploy-entity-resolve" HostBuild seam these
types served is deleted (charly/host_build_deploy_entity_resolve.go) —
its k8s/android/vm consumers now self-load the project plugin-side via
sdk/loaderkit's new Resolve{Vm,K8s,Android}EntityViaExecutor helpers
(built on W1's LoadUnifiedViaExecutor), reached over
InvokeProvider("kind", <word>, OpResolve, ...) instead of a host round
trip. Also fixes a pre-existing stale doc comment on
#K8sGenerateKustomizeRequest/Reply (described a defunct
"k8s-generate-kustomize" seam and non-existent charly/k8s_generate.go;
rewritten to describe the actual current materializeKustomize peer
dispatch) and a VmBackend field comment. Regenerated via task cue:gen.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
The wait-ready session op only ever read nodeTraits(&s.node).Venue and
s.bedDomain — both already returned in the setup reply as (implicitly)
IsVM and BedDomain — so the round-trip through the host session was never
load-bearing. Drops wait-ready from CheckBedRequest's op enum; the
consuming plugin now calls spec/exec's readiness gates directly. Also
corrects the stale "statekit" reference (delivered as spec/lock, not a
future sdk/statekit — already flagged once in CHANGELOG/2026.194.2051.md).

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…op dead DeployMembers wire types

Adds spec.IsVmVenue/IsContainerVenue (mirroring the already-promoted
spec.HostRooted, #55 U4) — the ONE shared venue-classification predicate
BringUpMembers/TearDownMembers now use, resolving the R3 3-way audit's
finding that a naive relocation would have added a FOURTH near-duplicate
"resolve a member's venue trait" implementation (core's nodeTraits,
candy/plugin-check/venue.go's registry-free twin, and a naive new copy).

DeployMembersRequest/DeployMembersReply removed: the deploy-members-up/
deploy-members-down HostBuild seam they served is deleted (super leg
landing alongside this commit) - candy/plugin-bundle calls
sdk/deploykit.BringUpMembers/TearDownMembers directly now.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…te shared predicates

The "check-bed" host-session HostBuild seam dies entirely (super leg landing
alongside this commit deletes charly/host_build_check_bed.go and
charly/check_bed_run.go). CheckBedRequest removed; CheckBedReply/
CheckBedMember/CheckBedPrereqSkip stay as plain plugin-internal value
types (SDD: still useful named shapes, never marshaled over a wire
anymore). New CheckBedGpuPrereqRequest/Reply for the ONE narrow seam
surviving dissolution - GPU host-DETECTION is the project's explicitly
operator-dropped exception (fenced from this cutover, gpu_shim.go's own
header).

New shared predicates (mirroring the already-promoted spec.HostRooted,
#55 U4), resolving R3 risks a naive relocation would have hit:

  - spec.ExternalInPlaceVenue: the plugin-reachable equivalent of the
    former core-private bedExternalInPlace(target), which queried the
    live provider registry. Every node reaching this predicate is
    already Descent-stamped, so the registry round-trip was redundant -
    the same finding candy/plugin-bundle/members_persist.go already
    proved for a bed's sibling MEMBERS (externalInPlaceFromDescent,
    now deleted there and in candy/plugin-check/bed_persist.go, both
    repointed to this ONE shared predicate instead of a third/fourth
    copy).

spec/proc gains SelfSuperprojectOverridePair/MergeRepoOverrides/
RepoOverrideEnv (promoted from charly/refs.go) - pure git-shelling +
string manipulation with zero registry coupling, needed by BOTH
charly/plugin_loader.go's deployNodePluginContext and
candy/plugin-check/bed_session.go's bedSetup, which computes its own
repo-override before self-loading the project.

charly/deploy_tree.go's nodeTraits/effectiveTarget deleted as dead code
(R1 sweep after the deletions above removed their last core caller) -
every surviving consult site reads node.Descent directly now, stamped
by the loader; a plugin-side node is always Descent-stamped (candy/
plugin-check/venue.go's own registry-free twin already proved this).
deploykit.ResolveBedCheckLevel deleted as dead code too - zero
remaining callers once bedCheckLevel's port to bed_session.go inlined
to the spec.* helpers directly, matching what core's own check_bed_run.go
had already done.

R1 sweep also fixed several already-stale comments this touch surfaced
(spec/loader_seam.go, spec/vm_domain.go, spec/hostenv/libvirt_session.go,
sdk/vmshared/vm_domain_reexport.go, spec/exec/venue_wait.go) claiming
host_build_check_bed.go / ResolveBedCheckLevel as live current callers.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…nces

VerifyChecksRequest's "plan" drive shape caller relocated from charly's
check_cmd.go (runLocalDeployScopePlan) to candy/plugin-bundle's
verify_local.go (super leg landing alongside this commit) - a peer
plugin reaching command:check via InvokeProvider now, not core.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
…ire shape

Team-lead's ruling on UnifiedDeployTarget.Test (charly's B3 caller 2):
precheck its own real production callers first. Zero found anywhere in
the tree (charly check live never reaches it; its one caller was a unit
test) - triple-delete Test/runUnifiedTargetChecks/the dead "test" op
per the ruling's zero-callers branch.

#DeployTargetDispatchRequest's op! enum drops "test" (candy/plugin-bundle
never wired a case for it). #VerifyChecksRequest drops the ops/only_ids
fields - the raw-Ops drive shape they fed (runUnifiedTargetChecks's sole
caller) is gone; the plan shape (candy/plugin-bundle/verify_local.go)
is the one surviving caller. #DeployTargetTestOpts deleted too - already
dead wire vocabulary before this cutover (never wired to any op).

Assisted-by: Claude Code Sonnet 5 (fully tested and validated)
… wire types

#RenderServiceRequest/#RenderServiceReply carried the "render-service"
HostBuild seam charly/host_build_render_service.go served. That seam is
gone (sdk/deploykit's CompileServiceSteps reaches candy/plugin-init's
OpResolve + candy/plugin-egress's OpValidate via two direct
InvokeProvider peer-dispatch calls now, reusing
render_generator_from_project.go's renderSeamCaller.renderService - a
pre-existing implementation of the exact same sequence for the
build-time init-assembly path). Their own "TWO registry consults a
plugin cannot do itself" framing was stale: both providers are
compiled-in, reachable from any connected plugin already holding a live
*sdk.Executor.

Assisted-by: Claude Code Sonnet 5 (fully tested and validated)
…e ops

New spec/ops entries (OpResolveEndpoint, OpResolveImageLabel,
OpDrainEndpointCleanups) and CUE types (#CheckEndpointResolveRequest/Reply,
#CheckImageLabelResolveRequest/Reply, #CheckDrainEndpointCleanupsRequest)
backing the reverse-RPC resolution bodies relocating from charly core to
candy/plugin-check (compiled-in-REQUIRED placement class). Also fixes two
stale header comments in container/image_inspect.go that attributed the
caller to charly's check_endpoint_resolve.go (now candy/plugin-check's
resolve_endpoint.go).

Assisted-by: Claude Sonnet 5 (fully tested and validated)
…ly CUE types

Replaces #PodStartRequest/#PodStopRequest/#PodShellRequest/#PodLogsRequest/
#PodUpdateRequest/#PodServiceRequest/#PodRemoveRequest/#PodCmdRequest (+ their
8 empty Reply siblings) with ONE #PodLifecycleRequest{op, box, instance,
node?, payload} envelope and #PodLifecycleReply{exit_code?}, plus 7
#PodXPayload types carrying each op's own fields. Converges the seam on the
codebase's own established op-discriminated wire idiom (#ArbiterInvokeInput's
flat action-multiplexed shape; charly/provider.go's own Operation.Params
json.RawMessage envelope) — the former 8-per-verb family was the last
outlier against it, each redeclaring box/instance/node.

Assisted-by: Claude Sonnet 5 (fully tested and validated)
…table()

os.Args[0] is whatever string invoked the process — a bare PATH-resolved
"charly" (the historically-masking common case) or a relative path like
"./bin/charly". A relative os.Args[0] resolves against the CURRENT working
directory at fork time, not the directory captured at start, so a caller
that os.Chdir()s (e.g. `charly -C box/fedora …`) before RunCharlySubcommand
forks a child (e.g. bundle-member bring-up's `charly config <member>`)
sends the child hunting for a path relative to the NEW cwd — ENOENT.
os.Executable() resolves absolutely and is chdir-immune; os.Args[0] is now
only the fallback on its (rare) error, matching the pattern already
established for charly/unified_targets.go's hostEnvJSON (CHANGELOG
2026.187.1656) and host_build_cli.go's hostBuildCli.

Pre-existing on main since the #55-step1 relocation kept the plain
os.Args[0] form; first exercised by the `-C` + member-fork combination
under #55 W3's cross-pod-cdp bed.

Assisted-by: Claude Sonnet 5 (fully tested and validated)
… its error

Widens the interface method from `RunBootstrapPhase(data []byte) []byte` to
`([]byte, error)` so an out-of-process implementer can report a genuine
HostBuild/IPC failure instead of the caller having no way to distinguish
"transformed" from "silently unchanged".

Part of the K-wave terminus RCA for #20 (confirmed wave regression, bisected
to e0edc38d): sdk/loaderkit's executorLoaderExecutor was the ONE LoaderExecutor
leg that swallowed a HostBuild failure and fell back to raw, un-bootstrapped
bytes with zero visible signal — every sibling leg (WalkProject,
MaterializeLoadedProject, ValidateAndroidDevices, ValidatePreemptible) already
propagates such a failure as a hard error. This leg-only interface change is
step 1 of the fix: make the failure loud. The underlying trigger — why the
call fails deterministically on a `charly update`-driven reentrant self-load
but not on the original deploy-add's — is still under investigation; leading
suspect is charly/plugin_prescan.go's inKindConnectPassFlag, a process-global
guard designed for one outer connect pass with nested (same-call-stack) inner
loads, not two independent self-loads (candy/plugin-bundle's pre-existing
tree-walk self-load and vmPrepareVenue's new e0edc38d self-load) landing in
one host process per `charly bundle add`.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
Threads the explicit build/generate targets (charly box generate <name>)
across the plugin-build <-> host wire so the host's remote-ref collection
leg (loaderkit.CollectRemoteRefsOpts, sdk leg of this fix) can seed its
reachability walk from an on-demand namespace-qualified target that is
otherwise unreachable from any root-owned image's base/builder chain.

Assisted-by: Claude Code Sonnet 5 (analysed on a live system)
atrawog added 5 commits August 4, 2026 18:28
SweepStaleTemps removes a temp older than a five-minute floor that no process
holds open. Both guards answer "stale" for a LIVE long-running build, and the
32-bed roster proved it by killing two beds mid-flight: one died at stage age
5m05s with its source tree gone, another watched its files vanish during
package(). A cross-process RemoveAll landed inside a running makepkg.

Verified on the host before writing the fix, not inferred:

  - The age guard reads the temp ROOT's mtime, and a directory's mtime only
    changes when its own entries change. A stage tree writes into src/ and pkg/,
    so the root's mtime stays frozen at creation — measured identical before and
    after a deep write.
  - The open-fd guard walks /proc/<pid>/fd. A build holds its stage tree as CWD,
    which lives at /proc/<pid>/cwd — a process whose CWD was the directory
    contributed zero matching fd entries.

Raising the floor is the workaround R4 forbids: it cannot distinguish abandoned
from slow, because age is not the property in question. Liveness is. So the
creator now holds an exclusive flock on an open descriptor of the temp root for
the operation's lifetime, and the sweep probes non-blocking and skips anything
held. The kernel releases an flock when the holding descriptor closes — including
when the process is SIGKILLed with no chance to clean up, which is precisely the
case the sweep exists for. Spiked before building on it: FREE with no holder,
BUSY while a live process holds it, FREE again after that process was killed
without unlocking.

MkdirTempHeld / CreateTempHeld / TempIsHeld are the one helper set every
sweepable-namespace creator uses (R3). release drops ONLY the hold — deletion and
cleanup-unregistration stay per-caller, because a site that keeps its artifacts
on success also keeps its signal-cleanup registration, and folding those in would
have changed behavior silently.

Honest accounting of what each guard now contributes, since they overlap: routing
a creator through the helper fixes the deletion twice over, because the hold keeps
a descriptor OPEN — the very thing the pre-existing /proc walk looked for and
never found, since the old creators opened nothing. Removing only the TempIsHeld
probe does NOT resurrect the defect on a host with a readable /proc. The probe
earns its place by not depending on /proc being readable or unnamespaced (a build
inside a container against a bind-mounted host stage dir is exactly that case) and
by stating liveness rather than inferring it from an incidental descriptor.

Coverage: a held, backdated temp survives the sweep; a released one is still
reaped; a temp younger than the floor is still kept; and the hold really does
release when its holder is SIGKILLed. The decisive control is the CREATOR shape —
TestSweepStaleTemps_UnheldCreatorIsSwept reproduces the deletion with a bare
os.MkdirTemp, exactly as the roster's builds were lost.

Also: the charly-aur- pattern's comment named a source file that no longer creates
any temp. The pattern stays (it still reaps leftovers from older binaries); the
false attribution is gone.

Assisted-by: Claude Code Claude Opus 5 (analysed on a live system)
…t's alias

`tagDeployAlias` mints `<registry>/<DEPLOY-NAME>:<CalVer>` on family images, and those
images inherit the base box's `ai.opencharly.image` label — so every sibling
deployment's alias landed in the label-family candidate set when resolving the BASE
box's short name. The label-CalVer is content-derived, so the whole family shares one
value and the tag-CalVer tiebreak decided the winner: whichever sibling deployment was
(re)deployed most recently.

Measured on a dev host, `charly box list tags check-pod` returned 40 refs, every one
labelled check-pod with the identical label-CalVer 2026.209.1500 — among them
check-preempt-arbiter-pod:2026.216.2124 and check-stepkind-emit-pod:2026.216.2120
alongside the base check-pod:2026.216.2119. An untagged resolve of `check-pod`
therefore returned the arbiter deployment's image.

A prefer-the-exact-name tiebreak already existed at the end of the sort, but it was too
weak by construction: it only broke EXACT CalVer ties, so a sibling alias with a newer
tag-CalVer won outright and the tiebreak never ran. It is promoted from a tie ordering
to a candidate FILTER — a candidate ref must itself be NAMED the requested short name.
The name-fallback branch already required exactly that, so both candidate sets now
share one rule, and the invariant is simply: an untagged resolve of box B returns a ref
named B, or nothing.

Aliases remain resolvable by their OWN deploy name through the name-fallback, which is
their entire purpose (deploy-name-keyed `charly config` / `charly start`). Filtering at
the resolver also makes the fix retroactive: alias tags already sitting in a local store
can no longer pollute a resolve, so the alias namespace is left where it is rather than
moved.

R3: the filter subsumes the tiebreak, so the tiebreak is deleted along with its inline
copy of the trailing-segment predicate — a second, subtly different implementation that
mis-stripped a `host:port` registry port. One predicate survives (shortNameMatchesRef,
over a new refRepoName), hardened for registry ports and digests now that it gates
candidacy rather than ordering.

TestResolveLocalImageRef_NeverReturnsSiblingDeployAlias reproduces the measured store
shape and fails without the filter, returning
ghcr.io/opencharly/check-preempt-arbiter-pod:2026.216.2124 for an untagged check-pod
resolve; it also asserts the aliases stay resolvable by their own deploy name.
TestRefRepoName covers the port and digest shapes.

Assisted-by: Claude Code Anthropic Opus 5 (fully tested and validated)
… on a candy service entry

Adds two ordered command lists to #CandyService, threaded through
#ServiceRenderContext so an init system's service_template can emit them
(systemd: ExecStartPre= / ExecStartPost=, one line per element, authored order).

WHY A NEW FIELD RATHER THAN A PLAN STEP. A plan step runs ONCE, at deploy. These
guards belong to the SERVICE's lifecycle: a pre-start hook must re-assert a host
precondition on EVERY start, restarts included, and a post-start hook is the only
place a guard can run ALONGSIDE the daemon it guards — the sole vantage from which
that daemon's own socket/API is reachable at all. Both are init-supervised, so a
failure shows up in the unit's status rather than being swallowed.

The motivating consumer is candy/k3s-server (landed in the superproject leg), which
needs exactly both halves:

  * a cgroup-v2 cpuset-delegation assertion BEFORE k3s execs. kubelet runs with
    --cgroup-driver=systemd and no --cgroup-root, so it creates the top-level
    kubepods.slice and validates that the ROOT cgroup delegates cpuset. systemd
    populates subtree_control lazily, so on a cold boot k3s can start first and
    kubelet dies with:
      failed to initialize top level QOS containers: error validating root container
      [kubepods] : cgroup ["kubepods"] has some missing controllers: cpuset

  * a CRD-establishment wedge heal AFTER k3s starts. If that crash lands in the ~1s
    window between k3s creating its embedded CRDs and their establishment, the
    apiserver's EstablishingController never re-queues them (upstream defect,
    filings tracked in task #29). The CRD freezes at NamesAccepted=True /
    Established=False permanently and every later start dies after its fixed 60s
    wait, producing a ~68s crash loop that keeps process= and port= probes GREEN
    while the cluster never bootstraps. The heal needs the apiserver, and between
    restarts there is none — only a post-start hook runs while k3s is up.

Both measured on a live wedged bed VM: one cpuset crash 15s into the first-ever
start, then 49 restarts with an empty kube-system and a Ready node.

Systemd-only by design: supervisord has no equivalent directive and its template
simply does not reference the fields, exactly as it already ignores
wanted_by/before. Declaring them still renders cleanly there, so a candy carrying
hooks stays deployable on a supervisord venue.

The generated Go types come from `task cue:gen` — never hand-transcribed.

Assisted-by: Claude Code Anthropic Claude Opus 5 (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