diff --git a/docs/roadmap/configkit-alignment.md b/docs/roadmap/configkit-alignment.md new file mode 100644 index 0000000..59e8cc0 --- /dev/null +++ b/docs/roadmap/configkit-alignment.md @@ -0,0 +1,245 @@ +# Align shared schemas with ConfigKit + +Status: proposed; open decisions appear at the end. + +## Objective and ownership + +Make all three shared contracts usable through ConfigKit's existing public +loading and handoff APIs. ConfigKit defines supported input syntax, values, and +configuration resolution. The schemas collection defines domain structure and +meaning within that boundary. Consumers own task-specific interpretation. + +The schemas must conform to ConfigKit, not require ConfigKit to adopt the +collection's broader decoding profile. Do not add consumer compatibility +adapters, a replacement parser, scalar repair, arbitrary-precision handling, or +serialization round trips to bridge a difference. Unsupported capabilities must +be removed from the new contracts' promises. + +This work covers glossary, RPG party, RPG campaign, their documentation and +examples, and the repository's validation harness. Consumer adoption and release +publication remain separate work. The contracts remain language-neutral; +ConfigKit's Go API is the reference implementation used by this repository's +internal tooling, not a schema SDK for consumers. + +## Reviewed baseline + +- Schemas distribution `2026.11.0`, commit + `1b8430bdcbf04eb98c8d45c98a1cb986a9e6d477`: all three schemas are `0.1.0`. +- ConfigKit `v1.4.0`, commit + `4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3`: + [configuration contract](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/config.md) + and [consumer guide](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/consumers/README.md). + +Review included the three schemas and semantic documents, the custom decoder, +validation and CLI paths, maintained fixtures, and temporary executable probes +using ConfigKit's public `Load[map[string]any]` and `Bytes` APIs. No ConfigKit +change is required for the proposed loading path. + +### Findings + +| Area | Current schemas behavior | ConfigKit boundary and required alignment | +| --- | --- | --- | +| YAML scalars | Case variants of booleans/null and unquoted `yes`, `no`, `on`, `off` are accepted under the local profile. | Follow native scalar classification. Quote these words when intended as strings; do not translate unsupported spellings. | +| YAML numeric syntax | Hexadecimal, octal, binary, separators, leading plus, and leading/trailing decimal dots are normalized. | Use ConfigKit's accepted JSON decimal number spellings. Remove normalization. | +| Tags and aliases | Standard explicit tags and acyclic aliases are accepted. | ConfigKit rejects explicit tags, anchors, and aliases. New examples and fixtures must reflect this. | +| Mapping keys | The local profile permits a quoted `<<` extension key. | ConfigKit rejects that key even when quoted. Duplicate keys and non-string keys remain errors. | +| Numeric values | `json.Number` preserves arbitrary precision, including integers beyond `int64` and `1e500`. | The native dynamic handoff uses `int64` integers and finite `float64` fractional/exponent values. Oversized values can fail; decimal precision can change. Do not promise exact authored numeric preservation. | +| Party class levels | Positive integers have no upper bound. | Bound the defined field to the supported dynamic integer range; retain its positive-integer domain rule. | +| Extension fields | All objects allow extensions and promise broad value preservation. | Keep extensions, but apply native value limits and reserved controls recursively. Preserve resolved supported values, not every authored representation. | +| Configuration controls | Completed documents are treated as arbitrary data mappings. | `extends` is always structural input; source-root `config` is a control namespace. Disabling imports does not make these ordinary extension data. | +| JSON | A separate JSON decoder accepts forms rejected by ConfigKit's parser. | Route JSON documents through the same native boundary. Do not promise acceptance of every JSON serialization. | +| Harness | A custom YAML node walker and JSON token walker implement a broader profile. | Replace domain decoding with native ConfigKit loading; retain maintained JSON Schema validation and domain semantic checks. | + +Probes confirmed that a maximum `int64` succeeds while the next integer and +`1e500` fail; `0.123456789012345678901234567890` becomes +`0.12345678901234568`. They also confirmed that `extends: null` is consumed, +sibling inheritance resolves without enabling imports, and root +`config: {note: ordinary}` fails. A JSON surrogate-pair escape fails while the +equivalent literal Unicode character succeeds. These findings identify the +baseline's limits; do not turn incidental error wording into repository policy. + +Glossary and campaign defined fields already use supported strings, objects, +arrays, and null where specified. Their changes concern the common loading, +extension, and preservation contract. Party additionally needs the explicit +class-level bound. Existing domain meanings need no redesign. + +## Required work + +### 1. Establish the common boundary + +Replace the independently specified broad YAML profile with a short description +that delegates to the pinned ConfigKit contract. Record the supported ConfigKit +baseline and link its canonical guidance. Future schema additions and updates +must be checked against that boundary before publication. + +Distinguish three checks: + +1. Native ConfigKit acquisition, resolution, and dynamic value binding. +2. JSON Schema validation of the completed result. +3. Schema-specific semantic validation, such as glossary entry-ID uniqueness. + +JSON Schema success alone does not establish ConfigKit compatibility. JSON +Schema cannot express all serialization, number-spelling, or resolution rules. +Do not build a recursive substitute for ConfigKit's value checker in JSON +Schema or application code. Published semantics must state that native loading +is part of full conformance. + +Use one common mapping-root handoff: string-keyed mappings, sequences, and +native dynamic scalar values. Do not derive stronger precision guarantees from +ConfigKit's private tree retaining original numeric spelling. Typed consumer +destinations can impose further task constraints; they do not broaden the +shared dynamic-value contract. + +### 2. Add aligned versions of all three contracts + +Create new version directories, canonical IDs, examples, and catalog records. +Leave every published `0.1.0` directory byte-for-byte unchanged. + +- **Glossary:** retain the envelope, general-purpose collection model, nullable + aliases/plural, provenance, and per-collection exact ID uniqueness. Replace + broader syntax and preservation promises with the common native boundary. +- **RPG party:** retain optional players/classes and existing identity rules. + Set the class-level maximum to `9223372036854775807`, with minimum `1`. + Explain that JSON Schema evaluates integer values after native binding; + do not introduce a separate schema-owned numeric spelling parser. +- **RPG campaign:** retain domain context and locator semantics. References + remain data; schema validation does not fetch them or check installation. + +Keep unknown domain fields allowed. Extension names and values are subject to +ConfigKit's native restrictions, including reserved `extends` and source-root +`config` controls. Those controls cannot be promised as opaque preserved data. +Nested ordinary `config` data follows upstream rules; do not ban that name +everywhere. Task instructions remain outside the shared domain contract. + +Replace blanket preservation language with preservation of supported values +in the resolved handoff. No trimming, case folding, or domain defaults are +introduced by schema validation. Native resolution and numeric binding retain +their upstream meaning. Task projections may omit irrelevant fields as before. + +Each new version's semantics must identify its ConfigKit baseline with an +immutable upstream reference. Mutable repository-wide guidance must not be able +to silently redefine a published contract. No new catalog format or independently +versioned serialization-profile system is needed. + +### 3. Simplify the validation harness + +Adopt ConfigKit `v1.4.0` as a pinned dependency. Load each supplied document +through `Load[map[string]any]` using `Bytes` for the already-read document, then +pass `Result.Config` directly to the existing JSON Schema engine and semantic +checks. A public-API probe has established that this path is supported. + +The default validator remains for completed documents. Do not enable import +traversal, discovery, overlays, secrets bootstrap, environment overrides, or +application defaults/resolvers. Native structural processing still applies; +do not implement a pre-parser to disable or reinterpret it. Application +composition remains the consuming application's job, and authored partial +contributions need not pass complete-document validation. + +Remove the custom domain YAML/JSON decoders, alias traversal, numeric +normalization, and arbitrary-precision helpers. Do not retain a fallback for +documents rejected by ConfigKit. Keep a simple JSON syntax check for `.json` +files if preserving that filename convention; it must not provide an alternate +decoding path or bypass native restrictions. + +Retain exact `name@version` selection, offline schema registration and reference +resolution, maintained JSON Schema validation, and exact glossary ID checks. +Do not coerce, default, or mutate the native result during validation. Keep +schema resource/catalog JSON decoding separate from operator-domain loading; +JSON Schema files themselves are not ConfigKit configuration documents. + +Preserve useful filename and schema-selection context around native errors. +Distinguish native load failures from structural and semantic failures without +reconstructing parser diagnostics or promising the previous decoder's positions +and wording. Retain the CLI's existing overall success/failure convention. + +Remove the direct YAML dependency if it is no longer used; ConfigKit may retain +it transitively. Update module metadata and attribution for the actual dependency +set. The harness stays internal; no shared Go SDK or alternate consumer loader +is introduced. + +### 4. Align documentation and maintained examples + +Update the README, validation guide, development guide, compatibility guidance, +and new versioned semantics together. Identify the native loading baseline and +explain the distinction between structural validity and full conformance. + +Document supported YAML authoring with short examples and upstream links: +quote ambiguous string values, use supported numeric syntax, and avoid aliases +and explicit tags. Explain native numeric limits, reserved controls, and JSON +limitations without reproducing ConfigKit's entire manual. Do not recommend +JSON as a universal escape from ConfigKit restrictions. + +Keep historical inventory, origins, release notes, and published contracts +accurate to their original releases. Existing semantic documents link to the +mutable validation guide: preserve a clear pointer there to the original +`2026.11.0` guide and tool, rather than retrospectively assigning old contracts +the new boundary. + +New examples remain synthetic, with glossary examples covering non-RPG domains. +Update current fixtures that rely on aliases or exact arbitrary precision. +Retain useful historical fixtures as historical evidence, not expectations for +the new decoder. Consumer migration notes should identify the new exact versions, +marker changes, affected authoring forms, and the absence of compatibility shims. + +### 5. Verify alignment and prepare downstream handoff + +Use focused public-API tests for the integration boundary, not a copy of +ConfigKit's parser suite: + +- All three new contracts' examples validate through native loading, structural + validation, and applicable semantic checks. +- Required fields, unknown supported extensions, omitted/null/empty distinctions, + and glossary ID uniqueness retain their intended domain behavior. +- Representative unsupported syntax, duplicate/non-string keys, integer + overflow, and exponent overflow fail through ConfigKit. +- Numeric tests assert native handoff behavior rather than exact authored decimal + precision. Party levels test the positive bound, maximum, and failures. +- Reserved controls follow native behavior. Completed results are validated; + directives are not silently treated as preserved extension data. +- Supported YAML and JSON representations produce equivalent domain values; + unsupported JSON forms have no alternate success path. +- Validation remains offline, selected schema references resolve from bundled + files, and neither schema selection nor campaign locators trigger network access. +- Published directories and existing catalog records remain unchanged. The + unpacked distribution retains everything needed for its supported validator. + +Run `go test ./...` and `go vet ./...`, then the existing archive checks at +release preparation. Reuse the current release process and publication guards; +this roadmap does not authorize publishing. + +After the aligned versions are published, provide their exact schema versions, +document markers, source CalVer snapshot, and ConfigKit baseline to Narratio, +Notarius, Audita, and the reference catalog. Update their adoption plans to +remove broader-profile obligations and custom compatibility work. Those +repository changes remain separately scoped. + +## Open decisions + +### OD-1: New versions and document generations + +**Recommendation:** release each aligned schema as `0.2.0`, with markers +`maximumdirect.glossary.v2`, `maximumdirect.rpg.party.v2`, and +`maximumdirect.rpg.campaign.v2`. The accepted input/value contract narrows, so +the existing compatibility policy requires a new generation even before `1.0.0`. +Select the new distribution's CalVer at release preparation. + +**Alternative:** retain `.v1` only after explicitly changing the compatibility +policy to separate serialization compatibility from document generations. +New immutable schema versions are still required. Do not call this a compatible +documentation correction or modify the published versions in place. + +### OD-2: Historical validation in the new tool + +**Recommendation:** keep all published definitions in the catalog and available +for offline structural use, but make the new CLI's full-validation support +explicitly target the aligned versions. Selecting an unsupported historical +version should explain that its original full decoding contract requires the +validator from `2026.11.0`. Do not retain two decoding implementations. + +**Alternative:** allow historical schema selection through the new native loader, +but clearly report that it checks the old structure under the current ConfigKit +boundary, not full historical conformance. This preserves more CLI selections +at the cost of a less straightforward meaning of validation success. + +Neither choice removes old catalog records, changes their canonical identities, +or requires applications to support multiple generations at runtime.