Use native ConfigKit loading for shared references

This commit is contained in:
2026-11-29 16:33:35 +00:00
parent ea163dd5dd
commit bfd9556a9e
2 changed files with 188 additions and 151 deletions

View File

@@ -4,8 +4,8 @@
Implement [Shared Domain Schema Adoption](shared-domain-schemas.md). That roadmap
owns the target state, intent, and approved input cutover. This document owns the
ordered implementation tasks. The baseline is `3ba68e6`; application code still
uses the private spell overlay and text party/glossary references.
ordered implementation tasks. The planning baseline is `ea163dd`; application
code still uses the private spell overlay and text party/glossary references.
Each numbered stage is one Luna implementation prompt. Execute in order during
one end-to-end sprint. Intermediate stages may leave callers or tests broken;
@@ -20,22 +20,38 @@ authorize future implementation, not implementation during the planning pass.
## Resolved Design Details
- Adopt `glossary@0.1.0` and `rpg/party@0.1.0` from schemas distribution
`2026.11.0`, commit `1b8430bdcbf04eb98c8d45c98a1cb986a9e6d477`.
Use that revision's schemas, semantics, and license terms. Its validation
profile is reference context, not a requirement to expand native YAML support.
- Adopt published ConfigKit-aligned glossary and RPG party contracts. The reviewed
`0.1.0` schemas in `2026.11.0` predate that alignment and are not the target.
Stage 1 verifies the new publication and records exact versions before reader
implementation. Do not implement a local bridge while awaiting publication.
- Bundle content under `assets/shared-domain/`, retaining upstream paths
`glossary/v0.1.0/` and `rpg/party/v0.1.0/`. Add a small source/version record
and the selected validation/compatibility documents. Keep the existing single
assets Go file content-only; extend its embed declaration as necessary.
- Put reusable decoding, validation, and retained document types in
`internal/integrations/domainrefs`. Put D&D contextual projections in
`internal/modules/dnd/shared`; spell recognition remains catalog-owned.
No dependency on upstream internal Go packages or runtime schema downloads.
`glossary/v<selected-version>/` and `rpg/party/v<selected-version>/`. Include
schema files, adjacent semantics, and a small source/version record. Link
upstream manuals rather than copying them. Keep the single assets Go file
content-only; extend its embed declaration as necessary.
- Put a small native-load/schema-validation integration in
`internal/integrations/domainrefs`. Use ConfigKit `v1.4.0`'s public
`Load[map[string]any](configkit.Bytes(label, content))` for both JSON and YAML.
Pass `Result.Config` directly to JSON Schema validation. Keep that resolved
mapping as the document; build narrow D&D projections in
`internal/modules/dnd/shared` and recognition views in the spell catalog.
No custom parser, generic document SDK, or upstream internal-package import.
- Use a single-source native load with no enabled imports, selected overlay,
defaults, application resolver, overrides, or secrets bootstrap. Native
structural behavior still applies, including `extends` and source-root `config`
controls. Do not pre-parse, disable, or reinterpret native reserved controls.
Retain wrapped native causes instead of reconstructing parser diagnostics.
This is a reference-document load, not another load of application settings.
- Keep native dynamic number binding (`int64`/finite `float64`) and native value
limits. Retain supported resolved extensions, not exact authored numeric
spelling/precision or consumed controls. Do not create serialization/forwarding
APIs or marshal/reload documents merely to construct typed views. Existing
reference items retain original bytes independently where needed.
- External reference objects gain `collections: [name, ...]`. Omission or null
means slot defaults. Explicit `[]` selects no collections. Preserve this
distinction through conversion, cloning, resolution, and inspection. Use a
presence-aware document field and a runtime nil-versus-empty slice; do not
distinction through conversion, cloning, resolution, and inspection. Use
ordinary ConfigKit-bound nullable fields and its native presence/inspection
behavior, then a runtime nil-versus-empty slice; do not add a presence tracker or
collapse an explicit empty slice with `append(nil, values...)`.
- Collection names compare exactly, without trimming or case folding. Empty
names cannot identify a valid upstream collection and are input errors.
@@ -62,19 +78,19 @@ authorize future implementation, not implementation during the planning pass.
forms when supplied. Party context projects names, aliases, player relationships,
and classes/levels when supplied. Sort roster keys for presentation but omit
those IDs from model content. Preserve distinct same-name roster entries.
Unknown extensions remain retained data, not interpreted instructions. Full
document forwarding preserves extensions; these task views omit them.
Ordinary extensions remain native resolved data, not model instructions;
these task views omit them. Native reserved controls keep their upstream meaning.
- Spell context projects canonical names/aliases only. Embedded vocabulary keeps
display precedence. For new external names, traverse collections and entries
in exact collection-name/entry-ID order so map/list order does not select the
display spelling. Use existing lookup normalization; trim surrounding whitespace
in the recognition view without changing authored data. A name/alias that
in the recognition view without changing the resolved document. A name/alias that
becomes unusable after normalization is a task suitability error. Preserve
existing same-spell alias augmentation and cross-spell collision rejection.
- Structured media types are `application/json`, `application/yaml`, and
`application/x-yaml`, matching existing file-extension materialization. JSON
media requires JSON syntax; YAML uses existing parser capabilities. Do not
bridge ConfigKit's narrower YAML language to the full shared-schema profile.
media requires JSON syntax via a standard `json.Valid` check, followed by the
same native load used for YAML. Neither serialization bypasses native limits.
Keep current byte bounds rather than adding new ones. Do not infer old text or
overlay formats, require optional provenance/rulesets, or add a campaign reader.
- Validate completed documents before task selection. Configuration composition
@@ -82,97 +98,76 @@ authorize future implementation, not implementation during the planning pass.
construction shared by run and explicit preflight, before domain inference.
Keep ordinary offline pipeline validation free of reference-file reads.
## Stage 1 — Bundle The Selected Contract Content
## Stage 1 — Confirm And Bundle The Aligned Contracts
**Goal:** Make exact adopted contracts available offline without behavioral asset
registration.
**Goal:** Pin released aligned definitions and make essential contracts available
offline without behavioral asset registration.
**Inspect:** `assets/package.go`, schemas tag/catalog and selected version
directories in `../schemas`, `docs/policy/oss.md`, and current attribution.
**Work:**
1. Copy the two schema directories, including adjacent semantics and synthetic
examples, from the exact source revision into the selected asset subtree.
Copy selected validation/compatibility documentation into its `docs/` folder,
preserving contract text and identifying its source. Keep schemas verbatim;
repair documentation links to pinned upstream sources for targets not bundled,
recording those navigation adaptations in the material identification. Do not
copy the full catalog as though the unbundled campaign schema were supported.
2. Record distribution, revision, exact schema versions and canonical IDs in a
small content record. No runtime release discovery or inventory framework.
3. Extend the existing embed declaration. Update asset-package commentary to
1. Verify publication of a ConfigKit-aligned schema distribution. At preparation
time only the pre-alignment `2026.11.0` source tag was available. If alignment
is not published yet, report that prerequisite and stop schema-dependent work;
do not silently select old contracts, unpublished candidates, or local patches.
2. Select the most current glossary and party versions from that published
distribution's catalog and review their semantics against ConfigKit `v1.4.0`.
Record distribution, full source commit, versions, document markers, and
canonical IDs in the feature roadmap, this plan, and a small asset source record.
No runtime release discovery or inventory framework.
3. Copy only the selected schema files and adjacent semantics, plus exact schema
dependencies if any, into the asset subtree. Keep schema files verbatim; link
nonbundled documentation targets to the selected upstream revision and record
any navigation adaptations. Do not copy upstream parser manuals, full example
archives, or a catalog advertising unbundled campaign support.
4. Extend the existing embed declaration. Update asset-package commentary to
recognize shared input contracts as well as LLM content.
4. Add the incorporated material's attribution and applicable CC0 license text
using the existing OSS conventions and commit-pinned links.
5. Add the incorporated material's attribution and applicable license text using
the selected release's actual terms, existing OSS conventions, and pinned links.
**Acceptance:** The packaged filesystem contains the selected schemas and
semantics; `assets` still has no business logic or kit dependency. Source/license
records describe only incorporated material.
**Acceptance:** Published aligned versions are pinned, and the packaged filesystem
contains their schemas and semantics; `assets` still has no business logic or kit
dependency. Source/license records describe only incorporated material.
**Validation:** `go test ./assets`; inspect copied files against `git show` at the
selected upstream commit, and `git diff --check`.
## Stage 2 — Implement Lossless JSON Document Decoding
## Stage 2 — Load Shared References Through ConfigKit
**Goal:** Establish the reusable completed-document representation and JSON path.
**Goal:** Delegate parsing and resolution for both serializations to ConfigKit.
**Inspect:** Selected validation profile, existing jsonschema dependency usage,
and upstream decoder behavior for guidance only.
**Inspect:** ConfigKit's pinned public `Load`, `Bytes`, and dynamic-value contracts;
the aligned schemas' semantics; existing reference byte/media-type transport.
**Work:**
1. Create `internal/integrations/domainrefs` with a decoder accepting bytes and
media type and retaining string-keyed objects, arrays, strings, booleans,
null, and exact JSON numbers. Retain a complete document separately from any
later typed view; no general import/composition machinery.
2. Use standard JSON token decoding with `UseNumber` to reject duplicate keys at
every depth, including equivalent escaped spellings, before a map loses them.
Require one complete JSON value; invalid JSON must not fall back to YAML when
the declared media type is JSON.
3. Return contextual decode errors using existing error wrapping, not a public
taxonomy. Add ordinary serialization/forwarding support that preserves values
and extensions without promising original whitespace or key order.
1. Create a small shared-reference loader in `internal/integrations/domainrefs`
that accepts already-materialized bytes, media type, and a useful diagnostic
label. For JSON media, use only `json.Valid` to enforce JSON syntax. Then call
the public native byte-source load for either media type.
2. Return the native resolved mapping for subsequent schema/domain validation.
Do not recreate a raw/typed document hierarchy, custom JSON token walker,
direct YAML-library decoder, numeric adapter, or generic conversion API.
3. Use the single-source selections above. Native parsing, structural resolution,
scalar binding, limits, and error details remain authoritative. Wrap failures
with reference context and retain their causes; do not create an error taxonomy.
4. Add a few public-API integration tests: ordinary equivalent YAML/JSON input,
one representative native rejection, resolved numeric/extension values, and
native reserved-control handling. Do not reproduce ConfigKit's parser matrix.
An `instruction` extension remains ordinary data. JSON receives no fallback
path when ConfigKit rejects a syntactically valid document.
**Acceptance:** Precision-sensitive extension values survive a decode/encode
round trip. Duplicate keys, trailing values, and invalid JSON fail distinctly
from subsequent schema validation.
**Acceptance:** Both serializations use one native loading boundary. No exact
numeric-preservation guarantee, independent parser, or configuration reconstruction
has been introduced. ConfigKit failures remain distinguishable from later schema
and domain checks without reimplementing native error semantics.
**Validation:** `go test ./internal/integrations/domainrefs` with focused JSON
fixtures; no network, engine, or credentials.
**Validation:** `go test ./internal/integrations/domainrefs`; no network, engine,
or credentials.
## Stage 3 — Add Straightforward YAML Input Support
**Goal:** Accept ordinary supported YAML without a custom compatibility parser.
**Inspect:** Pinned `go.yaml.in/yaml/v4` capabilities and ConfigKit's documented
YAML boundary. Keep the broader shared-schema profile as context only.
**Work:**
1. Use the existing YAML library's ordinary decoder for completed reference
documents, with native duplicate-key checking and a single-document boundary.
Convert supported decoded containers to the Stage 2 representation only as
needed for validation. No copied upstream decoder, custom node interpreter,
`math/big` scalar adapter, or full-profile compatibility layer.
2. Do not extend ConfigKit's parser or recreate configuration loading for these
domain files. ConfigKit continues to own application configuration composition;
domain reference loading does not execute imports or directives.
3. Retain useful native decode errors. Document supported serialization behavior
and recommend ordinary quoted strings/JSON-compatible scalars or JSON where
the broader shared-schema YAML language would need extra machinery.
4. Test representative ordinary YAML/JSON equivalents and native failure cases.
Do not require aliases, alternate numeric spellings, arbitrary-precision YAML
numbers, or other broader-profile forms merely because upstream supports them.
**Acceptance:** Supported YAML and JSON produce equivalent task views. Native
parser capabilities define serialization support; neither code nor documentation
claims full upstream YAML-profile compatibility. Supported decoded extension
values survive forwarding without additional interpretation.
**Validation:** `go test ./internal/integrations/domainrefs`.
## Stage 4 — Add Offline Shared Validation And Typed Views
## Stage 3 — Validate Resolved Shared Documents
**Goal:** Separate shared conformance from consumer requirements.
@@ -184,9 +179,13 @@ values survive forwarding without additional interpretation.
jsonschema library. Compile once with safe shared reuse; configure unresolved
resource loads to fail locally. Do not enumerate unrelated schemas or query
canonical URLs at runtime.
2. Provide glossary/party readers that decode and validate the complete envelope,
then expose typed known-field views alongside the retained full document.
Validate all known fields and all collections, not only selected entries.
Schema resource JSON remains owned by the schema engine's resource loader,
preserving exact numeric constraints; it is not a domain document to load
through ConfigKit.
2. Validate the Stage 2 native mapping directly. Check the complete resolved
envelope, all known fields, and all collections, not only selected entries.
Do not decode a second typed copy or marshal/reload subtrees. Add narrow typed
accessors/projections only where needed by the concrete consumers.
3. Check glossary entry-ID uniqueness within each collection using exact strings.
Do not add name uniqueness, global ID uniqueness, required player/classes, or
cross-document reference checks.
@@ -195,15 +194,15 @@ values survive forwarding without additional interpretation.
as task errors, not upstream schema errors.
5. Cover omitted/null/empty aliases, permitted extensions at all relevant levels,
invalid optional-field types, empty collections/rosters, shared IDs across
collections, and duplicate IDs within a collection. Include a forwarding test
showing that an `instruction` extension stays ordinary retained data.
collections, and duplicate IDs within a collection. Retain supported resolved
extensions in the mapping without inventing a forwarding subsystem.
**Acceptance:** Both readers conform offline to their exact selected contracts;
typed projection neither discards forwarded extensions nor alters authored data.
**Acceptance:** The native resolved mapping is validated offline against the exact
aligned contracts. Domain checks add no new authoring format or decoding path.
**Validation:** `go test ./internal/integrations/domainrefs`.
## Stage 5 — Carry Collection Selection Through Configuration
## Stage 4 — Carry Collection Selection Through Configuration
**Goal:** Preserve binding selection and its presence through normal configuration
resolution without changing ConfigKit ownership.
@@ -217,6 +216,8 @@ in `internal/framework/contracts/contracts.go`.
1. Add the presence-aware `collections` field to external reference documents,
runtime `ReferenceSource`, and resolved `ReferenceBinding`. Extend existing
external-source constructors as needed; avoid duplicate legacy source types.
Use ordinary typed ConfigKit binding and inspection. Do not create another
presence index, source tracker, configuration merge, or cloning framework.
2. Keep the reference source union explicit: collection selection accompanies
`path`, not `artifact`. Reject wrong selection types and empty names; preserve
null/omitted versus explicit empty according to the resolved design.
@@ -235,7 +236,7 @@ explicit `[]` does not turn into defaults.
`go test ./internal/core/config ./internal/framework/pipeline`. Temporary failures
from later wiring must be identified, not hidden with compatibility scaffolding.
## Stage 6 — Preserve Selections Through CLI And Materialization
## Stage 5 — Preserve Selections Through CLI And Materialization
**Goal:** Deliver selected input views consistently to consumers.
@@ -267,7 +268,7 @@ or configuration composition mechanism is introduced.
**Validation:** Focused tests in `./internal/framework/pipeline` and
`./internal/cli` for reference handling.
## Stage 7 — Cut Spell Recognition Over To Shared Glossaries
## Stage 6 — Cut Spell Recognition Over To Shared Glossaries
**Goal:** Replace the private overlay format across the whole spell family.
@@ -300,7 +301,7 @@ no durable spell shape or evidence rule changes.
**Validation:** `go test ./internal/modules/dnd/spells/... ./internal/modules/dnd/extract/spells ./internal/modules/dnd/normalize/spells ./internal/modules/dnd/validate/spells/...`
and focused CLI spell-catalog tests after their fixture migration.
## Stage 8 — Prepare Shared Context For Scenes And Registry Lanes
## Stage 7 — Prepare Shared Context For Scenes And Registry Lanes
**Goal:** Establish one reusable context preparation path and migrate its first
coherent consumer group.
@@ -311,7 +312,8 @@ and `assets/dnd/shared/prompts/common-dnd-references.md`.
**Work:**
1. Add a constructor-time shared context preparer using the Stage 4 readers.
1. Add a constructor-time shared context preparer using Stage 3's validated native
mappings and narrow task views.
Prepare fixed party/glossary/player material and combine it with each operation's
current transcript material. Keep generated references separate and dynamic.
2. Change party/roster/glossary declarations to structured media; retain text
@@ -333,7 +335,7 @@ missing optional context is supported and same-name roster members remain distin
**Validation:** Shared projection tests plus scene chunker and four migrated
extractor package tests. Update obsolete text fixtures for these consumers.
## Stage 9 — Migrate All Remaining D&D Context Consumers
## Stage 8 — Migrate All Remaining D&D Context Consumers
**Goal:** Complete context cutover without leaving a text-input bypass.
@@ -343,7 +345,7 @@ calls and grounding helpers, including enemy-event material assembly.
**Work:**
1. Migrate these six extractors to the Stage 8 prepared context facility. Keep
1. Migrate these six extractors to the Stage 7 prepared context facility. Keep
their generated registry/scene/combat handoffs and operation-local inputs intact.
2. Audit production calls to `shared.PromptInputs`, `ReferencePromptMaterial`,
and `ReferencePromptInput`. Remove the obsolete party/glossary raw-text path;
@@ -361,7 +363,7 @@ validation simply because no chunks execute or accepted artifacts are cached.
**Validation:** `go test ./internal/modules/dnd/... ./internal/modules/integration`.
## Stage 10 — Verify Assembled Run And Preflight Behavior
## Stage 9 — Verify Assembled Run And Preflight Behavior
**Goal:** Prove the public workflow through real internal collaborators and fake
provider boundaries.
@@ -378,7 +380,7 @@ provider boundaries.
2. Prove run and explicit preflight reject malformed party/glossary documents,
duplicate IDs, absent explicit collections, and spell collisions before any
fake domain inference/provider smoke call. Use representative cases rather
than rerunning the decoder matrix in CLI tests.
than rerunning ConfigKit's parser matrix in CLI tests.
3. Prove valid shared inputs reach the expected tasks; use a controlled empty
model extraction with populated references to verify the application does not
synthesize reference-only events. Do not assert live model quality guarantees.
@@ -393,7 +395,7 @@ the final ordinary pipeline remains usable with optional references omitted.
**Validation:** `go test ./internal/cli ./internal/preflight ./internal/framework/pipeline`.
## Stage 11 — Migrate Maintained Examples And Canonical Documentation
## Stage 10 — Migrate Maintained Examples And Canonical Documentation
**Goal:** Make the supported workflow discoverable without duplicating upstream
schema manuals.
@@ -418,6 +420,8 @@ and the documentation/OSS policies.
subprocess examples, and relevant internal ownership docs. Include a concise
migration section: new envelopes, existing slot names, collection selection,
nullable aliases, optional provenance, and roster-derived player relationships.
Link native loading, numeric binding, limits, and reserved controls to the
pinned ConfigKit documentation rather than maintaining a second manual.
5. Recheck attribution and copied content. Do not publish a release, preselect a
version, or claim other applications already support the shared format.
@@ -429,7 +433,7 @@ docs describe the implemented cutover, not legacy support or future campaigns.
local link checks and searches for retired example paths/overlay marker. Intentional
migration explanations are not stale references to delete.
## Stage 12 — Final Contract And Regression Pass
## Stage 11 — Final Contract And Regression Pass
**Goal:** Finish the end-to-end sprint with all target behavior verified.
@@ -442,6 +446,10 @@ migration explanations are not stale references to delete.
2. Check for accidental extra requirements: mandatory context/player/classes,
trimmed authored strings, extra name/ID uniqueness, extension rejection,
ruleset/provenance requirements, custom composition, new caps or retries.
Confirm no parallel parser, scalar adapter, subtree conversion round trip,
generic document/forwarding SDK, or copied upstream parser suite remains.
Native reserved controls and dynamic-value limits are upstream behavior, not
locally reimplemented restrictions or guarantees.
Check durable outputs, session identity, native reports and cache policy remain
unchanged. Remove temporary migration scaffolding and obsolete fixtures.
3. Run `gofmt` on modified Go files, then `go test ./...`, `go vet ./...`, and
@@ -455,4 +463,5 @@ migration explanations are not stale references to delete.
**Acceptance:** All stages' outcomes and the feature-roadmap acceptance criteria
are satisfied; repository-wide checks pass and no compatibility reader or
duplicated authoring workflow remains. No blocking design question is known.
duplicated authoring workflow remains. No blocking product decision is known;
the aligned-schema publication prerequisite must have been satisfied in Stage 1.