Repository navigation
fix(loaderkit): the declared-fields channels floor to the CONTRACT at the parse seam — the executor-boundary declared-fields completion - #226
Merged
Conversation
… the parse seam — the executor-boundary declared-fields completion The declared-fields maps (Threaded.StructuralDeclaredFields / DeployDeclaredFields) are host-registry state populated lazily by charly loaderThreaded() from pluginSchemas.inputDefs (the builtin schema gate runs mid-load; an external served schema registers only at connect). A parse consuming a Threaded BEFORE that gate — the executor loader legs (loaderkit.LoadUnifiedViaExecutor, shared by plugin-fleet fleet add, plugin-build build:project, the deploy-target surfaces) and the plugin-side Threaded consumers — receives EMPTY maps and the documented no-declared-schema fallback re-arms the unsafe value-shape scan: a converted tree's declared #Deploy fields re-scan as in-substrate members (the live repro: distro-arch check-agent-live pod body, charly fleet add failing with 'node "sandbox": expected a mapping value, got yaml kind 8' — the #223/#225 regression re-armed at the executor seam). The declared-fields data is CONTRACT data (what each kind schema declares), not registry state: ONE parse lookup (threadedDeclaredFields) now serves both the substrate and the structural branches of parseNode — the threaded (served-schema) entry when present (authoritative; byte-identical host-side behavior), else the contract-declared field set derived from the embedded spec/schema this package already compiles (sharedCueSchema + cueKindDefs — the SAME single source cue:gen derives from); a contract-unknown (external plugin) word floors to nil — the documented fallback, unchanged. Two prior tests fabricated an in-body member keyed 'sidecar:' (a vm-contract-DECLARED field), pinning the pre-floor empty-Threaded divergence; their member key is renamed to a non-declared name with every authored-depth assertion preserved.
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (summary accounts for all 5 files), no secrets/network/new deps, no guardrail weakening, no embedded directives. Checklist: All applicable rules PASS or NA.
Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The declared-fields channels (spec.Threaded.StructuralDeclaredFields from spec #104, spec.Threaded.DeployDeclaredFields from spec #107) are HOST-process registry state: charly's loaderThreaded() snapshots each recognized word's declared input-schema body field names from pluginSchemas.inputDefs, whose population is lazy (the builtin schema gate runs inside loadProjectPlugins, mid-load; an external plugin's served schema registers only at its connect). A parse that consumes a Threaded BEFORE that gate — the executor loader legs (loaderkit.LoadUnifiedViaExecutor's "loader-walk"/"loader-threaded" host legs, shared by plugin-fleet fleet add, plugin-build build:project, and the deploy-target surfaces), the plugin-side Threaded consumers (plugin-box validate, plugin-build resolve), or any process whose load interleaves differently — receives EMPTY declared-fields maps, and the documented no-declared-schema fallback re-arms the unsafe value-shape scan: a converted tree's declared #Deploy fields re-scan as in-substrate members.
Live repro (RCA'd and reproduced on the settled pin set, charly 2026.249.2351): charly fleet add check-agent-pod in distro-arch fails deterministically with:
— the exact regression sdk #223/#225 fixed for the populated host-side parse, re-armed at the executor seam. The walk leg runs host-side, but its Threaded is assembled from the LIVE registry at parse time, so the channel's completeness depends on process-lifecycle timing — violating the design ruling: the declared-fields maps are CONTRACT DATA (what each kind schema declares), not host-registry state.
THE FIX — the declared-fields CONTRACT FLOOR (mechanism (c), proven by RCA): loaderkit already compiles the embedded spec/schema contract lazily (cue_schema.go's sharedCueSchema + the cueKindDefs table). The parse's declared-fields lookup (ONE helper, threadedDeclaredFields, serving both the substrate branch and the structural branch of parseNode) now consults: the threaded (served-schema) entry when present — authoritative, presence wins, byte-identical host-side behavior — else the CONTRACT-declared field set derived from the embedded spec/schema (the SAME single source cue:gen and charly's base-schema splice derive from — R3); a word the contract does not declare (an external plugin kind) floors to nil — the documented no-declared-schema fallback, unchanged. Result: a parse of a converted tree behaves IDENTICALLY at every placement and every registry-timing state — host-side or plugin-side, gate-run or pre-gate — because the tier-1 declared fields never depend on process lifecycle.
Two prior tests (TestParseFold_PreservesAuthoredDepth, TestParse_MemberCarrierKeysStrippedFromBody) fabricated an in-body member keyed
sidecar:— a field the vm contract DECLARES — pinning the pre-floor empty-Threaded divergence. Their in-body member key is renamed to a non-declared name (inbed); every assertion (authored-depth positions, body retention, emitter stripping, nested recursion) is preserved, with the naming rule documented in the test comments.How tested
TDD (red → green), all -count=1:
RED (the fix reverted): the new executor-seam test reproduces the live error verbatim:
go test ./loaderkit/ -run 'TestLoadUnifiedViaExecutorSeam_DeclaredFieldsFloor|TestParse_DeclaredFieldsContractFloor_Substrate' -count=1
declared_fields_executor_test.go:77: LoadUnified (degraded executor Threaded): …/charly.yml:doc0: node "sandbox": expected a mapping value, got yaml kind 8
GREEN (the fix applied):
go build ./... → clean
go vet ./... → clean
go test ./... -count=1 → EXIT:0, 10 packages ok, 0 FAIL
Prior pinned tests stay green (-count=1): TestParseFold_PreservesAuthoredDepth, TestNoDualMapConstruction, TestDeployNodeHasNoDualMaps, TestParse_StructuralDeclaredFieldStaysData, TestParse_SubstrateDeclaredIterateStaysData, the parse-guard suite (8a class), TestParseDoc_*.
LIVE end-to-end proof: a throwaway charly binary built against this sdk checkout (go.mod replace, /tmp clone — charly unmodified) turns the deterministic distro-arch repro from
charly: error: command "fleet": /…/distro-arch/charly.yml:doc0: node "sandbox": expected a mapping value, got yaml kind 8
into a full clean load that proceeds past the parse to actual deployment ("Overlay image ready … To start the container, run: charly start check-agent-pod").
Rulebook compliance
Change classification
Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)