Document native ConfigKit contracts and dependency attribution

This commit is contained in:
2026-11-29 16:36:50 +00:00
parent 73ed94ea34
commit 83fc22814d
11 changed files with 1006 additions and 115 deletions

View File

@@ -1,111 +1,82 @@
# Validation
Validate a completed domain document after the composing application has resolved
imports, inheritance, and layering. ConfigKit owns those operations; this
repository defines the handoff format. Partial authoring contributions may use
schema definitions for editor assistance without conforming to a complete root.
## Current and historical boundaries
Current tooling uses ConfigKit v1.4.0 for every domain document. The
[pinned input contract](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/config.md)
owns syntax, resolution, resource limits, and native values; its
[consumer guide](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/consumers/README.md)
owns library use.
Published `0.1.0` contracts used a broader decoding profile. Their complete
historical validation requires the
[2026.11.0 guide](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0/docs/validation.md)
and [historical tool](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0/cmd/validate/main.go).
Choosing an older root with this newer binary does not restore a historical
decoder. Historical definitions remain bundled for offline structural use;
current native example checks target the most current local version of each name.
## Command
With Go 1.27 or later, run from the selected schema-set checkout or unpacked
source archive:
With Go 1.27 or later, prepare pinned dependencies and validate:
```sh
go mod download
go run ./cmd/validate -schema rpg/party@0.1.0 rpg/party/v0.1.0/examples/party.yml
go run ./cmd/validate -schema glossary@0.1.0 glossary/v0.1.0/examples/weather.yml
go run ./cmd/validate -schema rpg/party rpg/party/v0.2.0/examples/party.yml
go run ./cmd/validate -schema glossary glossary/v0.2.0/examples/weather.yml
```
Dependencies are pinned in `go.mod` and `go.sum`. Once prepared, validation is
offline. A built tool can select another unpacked distribution:
`-schema NAME` selects that name's highest SemVer in the local
[catalog](catalog.md). It reports the exact selected version and document marker.
There is no historical version flag or `NAME@VERSION` syntax. A checkout may
select unpublished candidates; an immutable distribution has its own catalog.
Selection never downloads a new catalog or retries older schemas after failure.
```sh
go build -o /tmp/schemas-validate ./cmd/validate
/tmp/schemas-validate -root /path/to/distribution -schema glossary@0.1.0 /path/to/completed-glossary.yml
/tmp/schemas-validate -root /path/to/distribution -schema glossary /path/to/glossary.yml
```
Select exactly `name@version` from [catalog.json](../catalog.json). All supplied
documents are validated against that definition, including their document marker.
Separate invocations select different schemas. Success reports the selected version.
Flags precede filenames. All files are checked even if an earlier file fails.
Exit 0 means all documents passed; 1 means a document could not be read or
validated; 2 means invalid command usage, missing/unknown selection, or an unusable distribution. Errors identify
the document and distinguish `decode`, `structure`, and `semantic`. Decoding
errors include field paths and source positions where the YAML library or node
profile provides them. Structural errors include JSON instance locations.
Semantic duplicate-ID errors identify the collection and entry index.
Flags precede filenames. Every document in an invocation uses the selected schema;
later files are still checked after an earlier failure. Exit 0 means success,
1 means document read/load/structural/semantic failure, and 2 means usage,
selection, or distribution failure. Native failures retain library diagnostics
with filename context; schema and semantic failures identify relevant locations.
The harness uses Go's standard JSON decoder for JSON syntax, including Unicode
surrogate-pair escapes, and [go-yaml v4](https://github.com/yaml/go-yaml/tree/v4.0.0)
otherwise. Both paths reject duplicate keys and preserve number precision. It uses
[jsonschema v6](https://github.com/santhosh-tekuri/jsonschema/tree/v6.0.3)
for Draft 2020-12 validation. It performs glossary ID uniqueness after structural
validation. It does not resolve domain references, check resource installation,
infer consumer support, populate defaults, or rewrite files.
## Native domain handoff
## YAML decoding profile
Supply a completed mapping after the composing application has resolved its
inputs. The harness calls native `Load[map[string]any]` on `Bytes`, then passes
`Result.Config` directly to structural and semantic validation. It enables no
imports, discovery, overlays, startup bootstrap, overrides, or application defaults.
Native structural processing still applies: `extends` is a directive and
source-root `config` is a control namespace. Nested ordinary `config` data
follows upstream behavior.
Use one document containing string-keyed mappings, sequences, strings, finite
numbers, booleans, and null. JSON is an equivalent serialization; `.json` files
must use JSON syntax. The same duplicate-key and semantic rules apply to both.
Quote ambiguous strings such as `"yes"`, use supported decimal numeric syntax,
and avoid explicit tags, anchors, and aliases. Dynamic integer syntax binds to
int64; fractional/exponent syntax binds to finite float64 and may round. Native
source limits apply, including the baseline's 8 MiB per source. This repository
does not duplicate those checks or repair rejected inputs. Both YAML and JSON
use the same native loader; JSON is not an escape from native restrictions.
Files ending in `.json` additionally require JSON syntax.
- Duplicate mapping keys are errors at every level. Keys compare as strings.
- Mapping keys must resolve to strings; quote numeric or boolean-looking keys
when they are intended to be names. Mapping order carries no domain meaning.
- `true` and `false` (including YAML case variants) are booleans. `yes`, `no`,
`on`, and `off` remain strings; a schema never coerces them into booleans.
- Date-like and timestamp scalars are strings containing their authored text.
Quote ambiguous values when authoring for other YAML tools with different
scalar-resolution policies.
- `null`, `Null`, `NULL`, `~`, and an empty scalar are null. Quoted forms are
strings. Absence, null, and empty containers are distinct.
- YAML integer spellings supported by go-yaml include decimal, `0x` hexadecimal,
`0o` octal, `0b` binary, legacy leading-zero octal, and separators. Decimal
floats may use a sign, exponent, leading dot, trailing dot, or separators.
Numeric scalar resolution follows go-yaml, with plain JSON number spellings
additionally recognized beyond machine numeric range. The adapter preserves
decimal precision as JSON numbers rather than converting through machine
floating point. NaN and infinities are errors.
Explicitly tagged floats must have valid numeric syntax before normalization;
empty values or incomplete forms such as `!!float e3` are errors.
- Anchors and aliases are accepted and resolved to values. Cycles are errors.
Anchors, aliases, comments, and formatting are serialization details.
- Standard mapping, sequence, string, integer, float, boolean, null, and
timestamp tags have the representations above. Custom tags, binary values,
sets, ordered-map tags, complex keys, and merge keys have no representation
in this completed-document profile. Resolve authoring composition before this
boundary; a quoted string key `"<<"` remains an ordinary extension key.
Full conformance includes native acquisition, JSON Schema structure, and applicable
semantic rules. The harness checks exact glossary entry-ID uniqueness within
each collection. It does not fetch campaign locators, infer consumer support,
populate domain defaults, or mutate the loaded configuration. Extensions preserve
supported resolved values; task projections can omit irrelevant data.
This is an explicit profile, not a promise to accept every YAML feature.
Consumers using other parsers should test the same cases before claiming
compatibility. Native library limits remain implementation safeguards, not
additional domain constraints.
## Offline resources and editors
## Structural and semantic boundaries
Schema resources and catalogs use standard JSON decoding, independently of
domain acquisition. Resource numbers remain exact so schema constraints do not
round. The maintained JSON Schema engine compiles every bundled schema under its
canonical ID, registers dependencies locally, and rejects absent resource loads.
Only current versions' examples are checked through native acquisition.
All defined fields are validated when present. Objects permit extensions unless
a field is itself a named-record mapping, whose values must satisfy that record
schema. For example, every item in `collections` is a collection, not arbitrary
document metadata. Put metadata on the envelope, collection, or entry.
The semantic inventory is in [the initial inventory](inventory.md). The harness
checks entry-ID uniqueness within each glossary collection using exact string
comparison. Party-ID uniqueness is already covered by duplicate-key rejection.
The initial contract defines no cross-document referential-integrity rule.
Structural success alone does not prove these semantic rules or that a consumer
can use the document for a particular operation.
## Offline schema use and editors
Every schema declares Draft 2020-12 and an exact versioned canonical `$id`. The harness
registers the bundled schemas under those IDs before compiling them and rejects
unresolved resource loads. The schema engine supplies the standard meta-schema;
ordinary validation performs no network requests.
Other validators can likewise register local files under their `$id` values.
Bundle the selected version directories and their exact referenced dependencies
from one selected CalVer snapshot, with their adjacent semantic documents. Configure editors
externally to associate document paths with a local schema or its canonical versioned
URL. Operator documents use `schema_version`; they do not need a `$schema` field.
Schema validation supplies editor feedback for known fields. Optional tooling
can warn about likely misspellings without rejecting extensions.
Consumers can pin exact schema versions and a published CalVer archive, bundle
their dependency closure and semantic documents, and register local files under
canonical IDs. Consumer pinning is independent of this CLI's name selection.
Editors can associate documents externally with their selected schema. Structural
editor feedback alone does not prove native acquisition or full conformance.