Skip to content

feat(loaderkit): read the per-host clean: section without the deploy projection - #566

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/host-clean-section
Nov 18, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/host-clean-section

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

spec#384 declared clean: as a typed per-host section and opencharly/plugin-clean reads its
ceiling from it — and NO plugin-reachable loader returned it. The mechanism is three layers deep,
and #565 carries the end-to-end measurement (three document shapes, every one
reporting the plugin's 32 GiB fallback):

  1. LoadDeployConfigViaExecutor ends with deploykit.ProjectDeployConfig, which builds
    DeployConfig{Provides, Deploy, Sidecar} — every unnamed per-host section is dropped there;
  2. LoadHostDeployConfigViaExecutor delegates to it, so it inherits the drop;
  3. and the materialize's per-document merge (spec/merge.MergeUnified) does not carry the
    sections forward either — which is why reading LoadUnifiedViaExecutor(dir).Clean directly is
    nil too, even though the field decodes from YAML.

This adds the narrow reader, not the widened view:

func LoadHostCleanSectionViaExecutor(ctx context.Context, ex *sdk.Executor, dir string) (*spec.CleanSection, error)

in loaderkit, beside LoadHostDeployConfigViaExecutor. It reads the per-host document and
returns the section WITHOUT going through ProjectDeployConfig.

Why narrow rather than teaching ProjectDeployConfig to carry it. That constructor is named
for the PROJECT deploy view and is what project-mode commands project; making it a merged
per-host view would make its name a lie, and every caller would silently start receiving state it
never asked for. opencharly/spec#383 records the per-section permission gap one layer up — the
host service promising a plugin its own section; this is that gap's data half, and it belongs at
the section scope, not at the deploy scope.

The contract, which is the consumer's refusal rule. It matches §4.6's "the caller's own
section" and it is the reason a merged view could not have served:

  • an absent per-host document → (nil, nil);
  • a document with no clean: → (nil, nil) — "unset" is a legitimate answer, and the consumer
    applies its own fallback (the 32 GiB ceiling lives in the plugin, never in the contract);
  • an UNREADABLE document, a failed bootstrap leg, or an unresolvable config path → (nil, error).

The last line is the whole point of the section scope: through a merged view, "absent" and "not
parsed" become the same nil, so a consumer cannot refuse an invalid ceiling without also refusing a
machine that simply never set one. Here they stay distinguishable.

The decoding path is the loader's (R2). readConfigStack is the very reader LoadUnified uses
(system layer → in-dir, raw document merge, retired-directive stripping), the bootstrap phase runs
in the same order, and the decode target is the same *spec.UnifiedFile that
loaderkit.MaterializeLoadedProject decodes each document's reserved directives into
(materialize_project.go). There is no second parser, no bespoke struct, and no duplicated file
resolution. What is deliberately NOT reused is the node-form walk + merge.MergeUnified +
ProjectDeployConfig chain — that chain is exactly what loses the section.

Not touched: no schema or wire type (the section already exists in spec v0.2026322.1814, which
go.mod already requires), no ProjectDeployConfig behaviour, no consumer code, no new field
anywhere. Two new files, 259 insertions.

Closes #565 (root fix option 1; option 2 — widening ProjectDeployConfig — is
deliberately not taken, for the reason above).

Head cd0a679a0f37a2a921f76be26b2291f4bf1b59ad.

How tested

The repo's authoritative gate is .github/workflows/ci.yml (gofmt, vet, golangci-lint v2.13.2,
test, and the four-arch cross-compile). Every command ran in
/home/atrawog/Sync/Atrapub/a/dsh/opencharly/.worktrees/clean-section-reader/sdk under
GOWORK=off GOTOOLCHAIN=go1.26.8 GOTMPDIR=~/.cache/go-tmp TMPDIR=/tmp/cs.

$ GOWORK=off go build ./...; echo "exit=$?"
exit=0
$ test -z "$(gofmt -l .)"; echo "exit=$?"
exit=0
$ golangci-lint run ./...; echo "exit=$?"
0 issues.
exit=0
$ go vet ./...; echo "exit=$?"
exit=0
$ for arch in amd64 arm64 arm 386; do GOOS=linux GOARCH=$arch CGO_ENABLED=0 go build ./... && echo "linux/$arch ok"; done
linux/amd64 ok
linux/arm64 ok
linux/arm ok
linux/386 ok
$ git rev-parse HEAD
cd0a679a0f37a2a921f76be26b2291f4bf1b59ad
$ git diff --shortstat $(git merge-base origin/main HEAD)..HEAD
 2 files changed, 259 insertions(+)
$ grep -n 'opencharly/spec ' go.mod; grep -c replace go.mod
18:	github.com/opencharly/spec v0.2026322.1814
0

The six arms of the reader's contract, driven through the real reverse channel
(sdk.NewInProcExecutor; the only double is the host's loader-bootstrap leg, which echoes):

$ go test ./loaderkit/ -run 'TestLoadHostCleanSection' -count=1 -v; echo "rc=$?"
rc=0
=== RUN   TestLoadHostCleanSectionReadsTheAuthoredBudget
--- PASS: TestLoadHostCleanSectionReadsTheAuthoredBudget (0.00s)
=== RUN   TestLoadHostCleanSectionAbsentSectionIsNil
--- PASS: TestLoadHostCleanSectionAbsentSectionIsNil (0.00s)
=== RUN   TestLoadHostCleanSectionAbsentDocumentIsNil
--- PASS: TestLoadHostCleanSectionAbsentDocumentIsNil (0.00s)
=== RUN   TestLoadHostCleanSectionUnreadableIsAnError
--- PASS: TestLoadHostCleanSectionUnreadableIsAnError (0.00s)
=== RUN   TestLoadHostCleanSectionResolvesTheStandardPath
--- PASS: TestLoadHostCleanSectionResolvesTheStandardPath (0.00s)
=== RUN   TestLoadHostCleanSectionNilExecutorIsLoud
--- PASS: TestLoadHostCleanSectionNilExecutorIsLoud (0.00s)

The red arm that proves these tests are not testing a getter. The reader's last step is
replaced by the delegating projection — deploykit.ProjectDeployConfig(&uf).Clean — and exactly
the two arms that carry a VALUE go red with the drop's own signature (the section was dropped),
while the four contract arms (absent section, absent document, unreadable, nil executor) still pass
because they never depended on the value. Restoring the committed file makes the package green
again:

$ go test ./loaderkit/ -run 'TestLoadHostCleanSection' -count=1; echo "rc=$?"
rc=1
--- FAIL: TestLoadHostCleanSectionReadsTheAuthoredBudget (0.00s)
    host_config_section_test.go:83: Clean = <nil>, want the authored store budget (the section was dropped)
--- FAIL: TestLoadHostCleanSectionResolvesTheStandardPath (0.00s)
    host_config_section_test.go:145: Clean = <nil>, want the authored store budget from /home/atrawog/.cache/go-tmp/TestLoadHostCleanSectionResolvesTheStandardPath904513861/001/charly.yml
$ git restore loaderkit/host_config_section.go
$ echo "dirty=$(git status --porcelain | wc -l)"; go test ./loaderkit/ -run 'TestLoadHostCleanSection' -count=1; echo "rc=$?"
dirty=0
ok  	github.com/opencharly/sdk/loaderkit	0.004s
rc=0

go test -count=1 ./... is RED on this host, and the red is pre-existing and environmental.
The one failure is deploykit.TestResolveBoxRef_BoxShortName — two readers of one engine store
disagreeing (#562, open since the previous leg and RCA'd there). It reproduces on a
pristine origin/main tree and skips on a host with no local images, i.e. on CI's runners. With
that single arm excluded the suite is green:

$ GOWORK=off go test -count=1 ./... > /tmp/cs/hc-g2.log 2>&1; echo "rc=$?"; echo "ok-packages=$(grep -cE '^ok' /tmp/cs/hc-g2.log)"; grep -E '^(FAIL|--- FAIL)' /tmp/cs/hc-g2.log
rc=1
ok-packages=20
--- FAIL: TestResolveBoxRef_BoxShortName (0.44s)
FAIL
FAIL	github.com/opencharly/sdk/deploykit	7.001s
FAIL
$ GOWORK=off go test -count=1 ./... -skip 'TestResolveBoxRef_BoxShortName' > /tmp/cs/hc-skip.log 2>&1; echo "rc=$?"; echo "ok-packages=$(grep -cE '^ok' /tmp/cs/hc-skip.log)"
rc=0
ok-packages=21

Rulebook compliance

  • R0 — the skills the dispatcher selects were loaded before the first tool call (plugin, go, install-plan, git-workflow, strict-policy, root-cause-analyzer, cutover-policy, check), plus this repo's AGENTS.md in the worktree.
  • R1 — no new anomaly: the build, lint, vet, gofmt and cross-compile gates are clean, and the new tests pass. The one red is the pre-existing, environment-dependent TestResolveBoxRef_BoxShortName, which is RCA'd in deploykit: TestResolveBoxRef_BoxShortName fails on any store holding a name the contract's resolver cannot find (two readers of one store disagree) #562 (two readers of one store; it skips on a host with no images) and listed under ## Filed issues rather than absorbed or retried.
  • R2 — one implementation per behaviour: the reader reuses readConfigStack, the bootstrap phase and the spec.UnifiedFile directive decode instead of opening its own file read or its own YAML schema, and it adds no second section type — spec.CleanSection is the only one. ProjectDeployConfig keeps its single meaning rather than gaining a second.
  • R3 — no workaround: no cache of a section value, no fallback that would report a default as if authored, no retry, no suppression. The seam double in the test answers ONLY the bootstrap leg and panics on any other kind, so a future widening of the reader cannot pass silently through it.
  • R4 — the product is fixed at the layer that owns it (the loader surface a plugin can reach); no documented command, doc or comment is used to route around the defect, and nothing in the prose claims the knob works before the consumer leg lands.
  • R5 — nothing is removed, so nothing is left behind: the change is additive and names no retired identifier; ProjectDeployConfig's behaviour is untouched by design, recorded in the code comment and in this body rather than silently diverged from.
  • R6 — git status --short was empty before the commit and after every gate; only this worktree's own two new files changed; the mutation round was restored from the committed blob and the tree proved clean (dirty=0) before the push; nothing was force-pushed.
  • R7 — coverage fails without the change, proven twice: the reader's arms are green on the committed tree, and the delegating projection makes the two value-carrying arms red with the drop's own message. The changed path executes for real (a real *sdk.Executor from NewInProcExecutor, the real readConfigStack/YAML/bootstraps path); the emitted artifact under test is the section the consumer will read.
  • R8 — no live service is crossed by this change; the one host-coupled leg is the bootstrap seam, and the test double is a seam double declared as such, not a mocked product path.
  • R9 — no binary is built or deployed and no runtime OS dependency is added; packaging: is untouched.
  • R10 — the gate that owns this change class is this repo's ci.yml, and every step of it ran on the committed head: gofmt, vet, golangci-lint v2.13.2, go test (with the one pre-existing, environment-dependent arm named and filed), and the four-arch cross-compile.
  • HC — one coherent scope: the reader and its tests in one change, no shim, no follow-up inside this repo. The consumer leg (plugin-clean's pin bump) is another repository and consumes the tag this PR produces — the producer-first order.

DESIGN.md, cited: opencharly/spec#383's §4.6 section-scope promise is the row this implements the data half of; D-STORE-7 is the ceiling the section carries; the placement (a plugin-reachable read belongs in loaderkit, not in deploykit, which cannot import it) follows the boundary law /charly-internals:plugin states, and it is why the helper lives beside deploy_config_executor.go rather than in the constructor it replaces.

Change classification

Go library addition (loaderkit/, two new files) — not documentation, so documentation reviewed is
not claimed. The tier claimed is fully tested and validated: every step of the change-class gate
passed on this head, and the reader's own path executed live through the real reverse-channel
plumbing. One clause diverges — the full suite carries one pre-existing, environment-dependent red
arm (#562), named and filed rather than absorbed.

Breaking change + rollback: none — the change only ADDS an exported function; no existing
signature, behaviour or wire shape moves, ProjectDeployConfig is untouched, and a consumer that
does not call the new reader is byte-identically unaffected. Until a consumer pins this tag, the
machine-scoped ceiling keeps falling back exactly as it does today, which is the behaviour the
issue measured. Rollback is to drop the branch.

Filed issues

Agent: sdk-store
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

…y projection

spec#384 declared `clean:` as a typed per-host section, and no plugin-reachable loader returned
it (#565): `LoadDeployConfigViaExecutor` ends with
`deploykit.ProjectDeployConfig`, which builds `DeployConfig{Provides, Deploy, Sidecar}` and drops
every unnamed per-host section; `LoadHostDeployConfigViaExecutor` delegates to it and inherits the
drop; and the materialize's per-document merge (`spec/merge.MergeUnified`) does not carry the
sections forward either, so even the unified document yields nil. The end-to-end measurement — a
document authoring a 256 GiB ceiling reporting the plugin's 32 GiB fallback in three shapes — is in
the issue.

`LoadHostCleanSectionViaExecutor` answers the section question directly: one per-host document,
one decode, the section (or nil). It is deliberately NOT a widened deploy view — `ProjectDeployConfig`
is named for the PROJECT deploy view, and teaching it to carry per-host state would make that name
a lie (opencharly/spec#383 records the per-section permission gap one layer up; this is its data
half).

The contract is the consumer's refusal rule: an absent document, or a document with no `clean:`,
answers (nil, nil) so the consumer applies its own fallback (the 32 GiB ceiling lives in the
plugin, never in the contract); an unreadable document, a failed bootstrap leg or an unresolvable
config path answers (nil, error), because a config that cannot be READ must never be mistaken for
one that says NOTHING — that is the failure mode a missing machine-scoped knob hides behind.

The decoding path is the loader's, not a second one (R2): `readConfigStack` is the very reader
`LoadUnified` uses, the bootstrap phase runs in the same order it runs there, and the decode target
is the same `*spec.UnifiedFile` the materialize decodes each document's reserved directives into.
What is NOT reused is the walk + merge + projection chain — precisely the chain that loses the
section.

The tests are the contract's four arms plus the resolved-standard-path and the nil-executor arms;
the PR body runs the red arm that replaces the reader's last step with the delegating projection,
which is what proves they are not testing a getter.

Refs: #565, opencharly/spec#384, opencharly/spec#383
Agent: sdk-store
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: cd0a679a0f37a2a921f76be26b2291f4bf1b59ad (branch: feat/host-clean-section)

Security screen: PASS — no secrets/egress, no new deps, no guardrail weakening; scope matches the stated "narrow reader only" intent (no schema/wire/deploy behaviour touched).

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3 — body accounts for both files; gate (repo ci.yml) named with pasted output; changed path (LoadHostCleanSectionViaExecutor) actually executed; red-arm proves the tests fail without the change; tier fully tested and validated is justified for a library addition. Bed run NA — pure library addition, no deployable artifact/consumer exists yet (consumer pin bump is a separate repo).
  • R1 — the one red (TestResolveBoxRef_BoxShortName) is RCA'd (two readers of one engine store), genuinely pre-existing (cannot be caused by an additive loaderkit function), and filed as deploykit: TestResolveBoxRef_BoxShortName fails on any store holding a name the contract's resolver cannot find (two readers of one store disagree) #562 under ## Filed issues — not a hand-wave.
  • R2 — reuses readConfigStack, bootstrap phase, and spec.UnifiedFile decode; no second parser/section type.
  • R3/R5/R6/R7/R8/R9 — no workaround, additive only, git safety stated, coverage proven by red arm, seam double is a local host leg (not a network/LLM/GitHub boundary), no binary/packaging change.
  • SDD/ADE — NA, no schema/cue/proto/generated/candy change.
  • ARCH — placement: CORRECT: a plugin-reachable loader mechanism belongs in the loaderkit sdk kit (not deploykit, which the boundary law keeps out of plugin reach); no charly alias growth, no core import of an sdk kit, no *Legacy* identifier.
  • Comment thread empty — nothing to disposition.

Tool-limited (non-blocking): the Assisted-by model string is unverifiable from the supplied context; the footer is format-compliant and the Agent line is coordination metadata, not a finding.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 18, 2026 19:12
@github-actions
github-actions Bot merged commit c353e56 into main Nov 18, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 18, 2026
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.

loaderkit: a plugin cannot read the per-host clean: section — both reachable loaders drop it

1 participant