Skip to content

fix(loaderkit): structural bodies scan in-body members by the KEY rule, minus the declared input-schema fields - #223

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/structural-key-rule
Sep 6, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/structural-key-rule

Conversation

@atrawog

@atrawog atrawog commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #222 (the parent-disc guard), incorporating the refined design ruling. #222's parent gate alone does NOT fix the live corpus bug: group is a STRUCTURAL kind (plugin-group declares Structural: true, word group, InputDef: #GroupInput), so the #222 scan ran for group bodies and the value-shape channel (isEntityValue) still classified iterate's agent: key as a disc — the fixture had threaded group as a non-structural kind, mis-modeled against the live host.

The refined rule, data-driven from spec.Threaded (zero hardcoded words):

  • SUBSTRATE parent (t.DeploySubstrates) — UNCHANGED: the entity-keyed value-shape scan (discEntityPairs/isEntityValue). Substrate bodies have no colliding declared fields (their unknown keys are already rejected by their own decoders); the authored-depth sidecar shape keeps working.
  • STRUCTURAL parent (t.StructuralKinds) — the KEY rule: an in-body key is a member iff the KEY ITSELF is a memberDisc word, minus the kind's DECLARED input-schema fields — the new spec.Threaded.StructuralDeclaredFields channel (feat(spec): Threaded gains the structural declared-fields channel spec#104, v0.2026249.2030), fed by the host from the registered #XInput schema. A non-kind key is opaque data whose value is NEVER looked inside (no transitive recursion — the iterate:-carrying-agent: collision class dies); a kind-word key that IS a declared field stays data; a kind with NO declared schema threaded falls back to every kind-word key being a member (documented + tested).

Also bumps the spec pin to v0.2026249.2030 (the channel's contract change).

How tested

The refined fixture under the CORRECT live threading (group STRUCTURAL + declared fields threaded) — the exact distro-arch check-agent-live shape parses as DATA:

  • TestParse_StructuralDeclaredFieldStaysData — group body's iterate: block (scalar sandbox, agent list, plateau_iteration, prompt, note, env) parses clean; the only child is the deploy-level sibling watcher; the full iterate body travels intact.
  • TestParse_StructuralKindWordKeysAreMembers — the documented no-declared-schema fallback: an in-body kind-word key is a member.
  • TestParse_StructuralDeclaredKindWordKeyStaysData — the channel's direct proof: a declared field NAMED like a kind word stays data.

All prior surfaces stay green (full gate on the FINAL COMMITTED tree, -count=1):

$ go build ./... && go vet ./... && go test ./... -count=1
ok  \tgithub.com/opencharly/sdk\t0.080s
ok  \tgithub.com/opencharly/sdk/agentkit\t0.786s
ok  \tgithub.com/opencharly/sdk/buildkit\t0.006s
ok  \tgithub.com/opencharly/sdk/candywalk\t0.003s
ok  \tgithub.com/opencharly/sdk/deploykit\t2.011s
ok  \tgithub.com/opencharly/sdk/enginekit\t0.006s
ok  \tgithub.com/opencharly/sdk/kit\t1.198s
ok  \tgithub.com/opencharly/sdk/loaderkit\t0.044s
ok  \tgithub.com/opencharly/sdk/packagekit\t0.017s
ok  \tgithub.com/opencharly/sdk/vmshared\t0.118s

including TestParseFold_PreservesAuthoredDepth (substrate sidecar + bare sibling, recursive), TestParse_MemberCarrierKeysStrippedFromBody, TestMemberDisc_Unity, TestParse_ExternalStructuralChildUnderExternalStructuralParent (8a), TestNoDualMapConstruction. No code was removed in this change (no removal sweep due); the body emitters derive member-owned keys from pn.Children, so the refined rule flows through them unchanged (R3).

Rulebook compliance

  • R0 — git-workflow skill loaded; contract-first landing order (spec feat(spec,proto,deploykit,buildkit)!: wave-3 sdk leg — K4 candy/box selection wire + build:ensure wire contract #104 merged + tagged BEFORE this pin bump).
  • R1 — RCA'd: the fix(loaderkit): the in-body member scan fires only where member nesting is meaningful — the parent-disc guard #222 fixture's Threaded mis-modeled the live host (group IS structural); the refined rule fixes the live bug at the key-rule level, with the schema channel as the grounded discriminator.
  • R3 — one implementation per behavior: the emitters consume pn.Children; the channel reuses the plugin's registered schema.
  • R4 — no workarounds; the channel is DATA, never a hardcoded collision table.
  • R5 — nothing removed (the substrate arm keeps discEntityPairs/isEntityValue).
  • R6 — branch-per-change, no force-push, no direct main push; clean tree verified post-commit.
  • R7/R10 — the full gate pasted above, run on the final committed tree.
  • R8 — attribution footer below.
  • R9 — scope: loaderkit parse + its tests + the spec pin bump; the HOST-side feed of the channel (charly's loaderThreaded reading registered #XInput field names) is a separate charly consumer change, deliberately NOT widened into this PR.
  • R10 — fresh proof from the committed tree, never an edited state.

Change classification

  • Change class: Go parse-correctness fix + regression tests + contract pin bump — no CUE schema change, no migration.
  • Verification gate: full module gate (build/vet/test -count=1) on the committed tree — pasted above.
  • Attribution tier: fully tested and validated.

Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)

…e, minus the declared input-schema fields

Follow-up to #222 (parent-disc guard), incorporating the refined design
ruling. #222's parent gate alone does not fix the live corpus bug: group is a
STRUCTURAL kind (plugin-group declares Structural:true, #GroupInput), so the
#222 scan ran for group bodies and the value-shape channel
(isEntityValue) still classified iterate's `agent:` key as a disc. The
fixture threaded group as a non-structural kind — mis-modeled against the
live host.

The refined rule, data-driven from Threaded (zero hardcoded words):

- SUBSTRATE parent (t.DeploySubstrates) — UNCHANGED: the entity-keyed
  value-shape scan (discEntityPairs/isEntityValue). Substrate bodies have no
  colliding declared fields (their unknown keys are already rejected by their
  own decoders); the authored-depth sidecar shape keeps working.
- STRUCTURAL parent (t.StructuralKinds) — the KEY rule: an in-body key is a
  member iff the KEY ITSELF is a memberDisc word, minus the kind's DECLARED
  input-schema fields (new spec.Threaded channel StructuralDeclaredFields,
  fed by the host from the registered #XInput schema — spec#104,
  v0.2026249.2030). A non-kind key is opaque data whose value is NEVER looked
  inside (no transitive recursion — the `iterate:`-carrying-`agent:` collision
  class dies); a kind-word key that IS a declared field stays data; a kind
  with NO declared schema threaded falls back to every kind-word key being a
  member (documented + tested).

Tests rebuilt around the live threading: the exact distro-arch iterate fixture
(group STRUCTURAL + declared fields threaded) parses as DATA; the no-schema
fallback and the kind-word-named declared-field exclusion each pinned; all
prior surfaces (authored depth, member-carrier stripping, memberDisc unity,
8a external-structural, no-dual-map) stay green.

Gate: go build/vet/test ./... -count=1 green on the committed tree.
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 17274e7865c7 (branch: fix/loaderkit-structural-key-rule)

Security screen: PASS — no scope mismatch (parse fix + spec pin bump match the description), no secrets/exfiltration, no weakened guardrails, no supply-chain red flags (spec pin bump is the documented contract change for the new StructuralDeclaredFields channel).

Checklist: All applicable rules PASS or NA.

  • A1/A3 — Body complete: Summary, How tested with pasted gate output, rulebook compliance, change classification, and the *Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)* footer. Tier justified: the new structural KEY-rule branch executed via the three new unit tests against the committed tree.
  • A2/B12 — Library parse fix; module gate (go build/vet/test -count=1) pasted, internally consistent (real package names, plausible counts). New behavior has tests that would fail without the change (TestParse_StructuralDeclaredFieldStaysData fails under the old entity-pairs scan with group threaded structural).
  • B13 SDD — No CUE/generated-file changes; StructuralDeclaredFields is a data channel from the spec module, not a hand-written wire type.
  • B16 Architecture — placement: CORRECT. Parse logic belongs in loaderkit; no new core imports, no alias files, no re-coupled seam.
  • B5/B14 — RCA provided (the fix(loaderkit): the in-body member scan fires only where member nesting is meaningful — the parent-disc guard #222 fixture mis-modeled group as non-structural); no forbidden framing, no concurrency issue.
  • B15 — Single atomic commit; no partial/split work.
  • B18 — Go code clean, no gofmt/lint issues visible in the diff.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 6, 2026 20:36
@github-actions
github-actions Bot merged commit 9b79563 into main Sep 6, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 6, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 6, 2026
…d #Deploy fields — the deploy-declared-fields channel (sdk #221 class) (#225)

The #222/#223 parent-disc + key-rule guards fixed the STRUCTURAL arm, but the
SUBSTRATE arm (t.DeploySubstrates) still scanned disc values by VALUE SHAPE
(discEntityPairs/isEntityValue): a declared #Deploy field whose value mapping
carries a kind-word key classified as an IN-SUBSTRATE MEMBER. The proven
repro (the canonical charly-cli ADE iterate-entity bed): a pod primary body
with iterate: {sandbox: check-agent-pod, agent: [check-agent-live-claude],
plateau_iteration: 1, ...} — `agent` is a kind word, so `iterate:` classified
as a member named "iterate", parseNode("iterate") took `agent` as ITS disc,
and the scalar `sandbox:` hard-failed "expected a mapping value, got yaml
kind 8". Renaming the key to agentsX got past the raw parse (then CUE:
field not allowed) — isolating the parse class.

Same mechanism as #223, extended to deploy substrates: membership semantics
live in the PARENT kind's declared schema — for substrates that is #Deploy's
OWN CUE schema. The new spec.Threaded.DeployDeclaredFields channel
(opencharly/spec#107, v0.2026249.2215 — the #104 StructuralDeclaredFields
twin) is consulted by the substrate branch: a pair whose KEY is a declared
#Deploy field is DATA — its value is never looked inside; every other
entity-keyed value-shape member (web:/chrome:/sidecar:) stays a member. A
substrate word with NO declared schema threaded keeps the plain value-shape
scan (the documented no-declared-schema fallback). Zero hardcoded lists.

Also pins spec v0.2026249.2215 (the channel's contract change).

Gate: go build/vet/test ./... -count=1 green on the committed tree; the
repro fixture + the full corpus (authored-depth, 8a external-structural,
TestParse_StructuralDeclaredFieldStaysData, TestNoDualMapConstruction) green.
github-actions Bot pushed a commit that referenced this pull request Sep 7, 2026
… the parse seam — the executor-boundary declared-fields completion (#226)

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.
@aitrawog
aitrawog deleted the feat/structural-key-rule branch September 25, 2026 19:08
github-actions Bot pushed a commit that referenced this pull request Nov 13, 2026
…e, not the moved #Pod (#504)

opencharly/spec#304 unit 3, leg 3. The contract module deleted `#Pod` and
`#PodValue` (opencharly/spec#307, tag v0.2026317.703), and this module named them
in two places.

`vmshared/spec_aliases.go`: `PodSpec = spec.PodSpec` was an UNUSED zero-churn
alias (the only `PodSpec` occurrence in this module is its own definition), so it
goes with the type it named.

`loaderkit/cue_schema.go`: `cueKindDefs["pod"] = "#Pod"` indexes the EMBEDDED
contract schema, and `sharedCueSchema()` fail-fasts on an absent def, so with the
moved def the parse panicked at init — `loaderkit: CUE kind "pod": definition
#Pod not found`. The entry now names `#ResolvedPod`, the resolve-to-envelope form
the contract KEEPS: the same def the contract keeps `#PodSidecar` for.

Dropping the entry instead is the silent option, and it is the one this repo's
own gate forbids. That table is the source of the declared-fields CONTRACT FLOOR
(loaderkit/declared_fields_floor.go), whose header records the live repro it
exists to prevent — distro-arch check-agent-live's pod body, an `iterate:` key
carrying an `agent:` kind-word key, failing `charly deploy add` with `expected a
mapping value` (sdk#221/#223/#225) — and TestContractDeclaredFields_Floor pins
`pod` as a non-empty floor. A nil floor would re-arm exactly that bug.

Two consequences are deliberate, bounded, and written beside the table rather
than discovered later: the floor for `pod` gains the resolved-only `raw` (which
the pod value gate still rejects as `field not allowed`, so the extra name cannot
admit a document), and `env_default`'s type differs between the authored
`#StrVal` and the envelope's `string` — which would matter only to a CONCRETE
unify (`ValidateEntityClosedCUE("pod", ...)` / `ApplyCueDefaults("pod")`), and no
caller in the tree passes "pod" to either.

`require github.com/opencharly/spec` advances to v0.2026317.703.

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (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