Plan staged alignment of the shared schemas repository

This commit is contained in:
2026-11-29 02:15:41 +00:00
parent b65f653380
commit 1d09762e31
2 changed files with 554 additions and 0 deletions

View File

@@ -0,0 +1,233 @@
# Shared schemas repository alignment: implementation plan
## Scope and execution
Implement step 1 of the [shared-schema adoption roadmap](schemas.md) in
`../schemas`. This plan is proposed work, not evidence of implementation. The
baseline is schemas commit `9f7744b`, which includes the reviewed decoder fixes.
The initial repository has no published contracts assumed by this plan; recheck
publication state before changing candidate identities.
Run this as one end-to-end sprint. Stages express dependency order and reviewable
outcomes, not mandatory intermediate releases or approval gates. Intermediate
commits need not compile; the completed sprint must satisfy all acceptance checks.
Do not implement application adoption, change domain field meanings, add legacy
readers, adopt ReleaseKit, provision hosting, push, tag, or publish as part of the
sprint. Publication requires a later explicit request.
Planning baseline: start each of the three schemas at `0.1.0`, retaining the
agreed `.v1` document contract generations. This is the recommended initial
version choice for review before implementation, not a claim that it was already
selected in the roadmap. Version `1.0.0` becomes appropriate for each schema when
consumer adoption establishes its stable contract. The directory names in the
roadmap are illustrative, not instructions to declare stability now.
## Stage 1 — Move contracts and establish their identities
Move the current `schemas/*.schema.json`, `docs/{party,campaign,glossary}.md`,
and corresponding examples into these contract roots:
| Schema name | Initial directory | Document contract |
| --- | --- | --- |
| `glossary` | `glossary/v0.1.0/` | `maximumdirect.glossary.v1` |
| `rpg/party` | `rpg/party/v0.1.0/` | `maximumdirect.rpg.party.v1` |
| `rpg/campaign` | `rpg/campaign/v0.1.0/` | `maximumdirect.rpg.campaign.v1` |
Each directory contains `schema.json`, `semantics.md`, and `examples/`. Keep the
weather and sports examples with glossary to demonstrate domain independence.
Keep validation fixtures, tools, and repository-wide guidance outside published
contract directories. Preserve attribution and historical source snapshots under
`docs/origins/`; they are evidence of origins, not active competing contracts.
Set each `$id` to `https://schemas.maximumdirect.net/` plus its repository-relative
schema path. Rename active party/campaign markers in schemas, examples, fixtures,
and documentation. Update relative documentation links and any references affected
by the moves. Remove the obsolete active flat layout; add no redirects or aliases
for unpublished candidate formats. Preserve the CC0 dedication and incorporated
material's attribution.
Acceptance: the three roots contain complete contracts; canonical IDs match file
paths; YAML/JSON examples retain their data except for the intended identifiers.
No domain restrictions or glossary instruction semantics have been introduced.
## Stage 2 — Introduce the version inventory and offline loading
Add root `catalog.json`, with a documented format in `docs/catalog.md`. Use one
record per schema version. A small proposed shape is:
```json
{
"format_version": 1,
"schemas": [
{
"name": "rpg/party",
"version": "0.1.0",
"contract": "maximumdirect.rpg.party.v1",
"id": "https://schemas.maximumdirect.net/rpg/party/v0.1.0/schema.json",
"path": "rpg/party/v0.1.0/schema.json"
}
]
}
```
The real inventory includes all three schemas and, later, retained published
versions. Semantics and examples are adjacent by convention; avoid duplicating
their paths or inferring release status from an entry on `main`. The CalVer tag
identifies the distribution; the inventory need not repeat its version.
Adapt `internal/validation/validate.go` to load the inventory rather than the
fixed `contractNames`, flat paths, and forge URL derived from `VERSION`. Index
compiled schemas by exact identity, allowing multiple versions of one contract.
Register all bundled resources before compiling, retaining Draft 2020-12
meta-validation and the offline loader. Do not fetch schema resources over HTTP.
Check duplicate name/version pairs, duplicate IDs or paths, missing files,
version-directory agreement, and ID/path/contract agreement. Check that active
versioned schema roots are represented in the inventory. Do not treat historical
origin snapshots or negative test fixtures as published schemas. Keep selection
and semantic checks internal; no generic plugin mechanism or consumer SDK.
Acceptance: a fixture inventory containing two versions with the same document
marker loads both without overwriting either. Missing referenced schemas fail
locally. Exact schema IDs remain unchanged when only the distribution version
changes. Inventory errors identify the affected record or file.
## Stage 3 — Make validator version selection explicit
Extend `cmd/validate/main.go` using its existing flag handling and shared validator.
The proposed command is:
```text
go run ./cmd/validate -root . -schema rpg/party@0.1.0 DOCUMENT...
```
Require an exact `name@version` selection for a validation invocation. All supplied
documents are checked against it; use separate invocations for different schemas.
This avoids choosing a moving latest version or guessing from a major marker.
Keep `-root` for an unpacked distribution. Report the selected schema version on
success and preserve checking of later files after a document failure.
Preserve exit distinctions: usage, selection, or unusable distribution errors
return 2; document read/decode/structure/semantic failures return 1; success returns
0. A document marker that disagrees with the selected schema is a structural
failure. Retain glossary ID uniqueness after structure validation, extension
preservation, and the existing JSON/YAML profile. Neither structural nor semantic
validation may normalize, populate defaults, or mutate input data.
Acceptance: focused CLI checks cover exact selection, unknown or missing
selection, marker mismatch, mixed valid/invalid files, and success from an unpacked
root. With two compatible versions sharing a marker, a controlled fixture proves
that selection actually chooses the requested definition. Retain the surrogate
pair, duplicate-key, numeric precision, and malformed tagged-float regressions.
## Stage 4 — Align versioning, release documentation, and immutability
Revise `README.md`, `docs/compatibility.md`, `docs/release.md`, `docs/development.md`,
`docs/validation.md`, and affected inventory/example links. Keep current behavior
accurate as the implementation lands. Explain these independent identities:
CalVer distribution, full per-schema SemVer, document contract generation, and
canonical `$id`. Do not derive the `.v1` marker mechanically from a pre-stable
`0.1.0` version or couple schema versions to Go module major versions.
Use repository tags and `VERSION` in `YYYY.MM.MICRO` format, without a `v` prefix.
Use the UTC publication month and a counter starting at zero; schema directories
retain their `v` prefix. During implementation, record an unpublished candidate
for the current UTC month, and replace the old unpublished `v1.0.0` release note
with the matching CalVer candidate note. Re-evaluate month and counter when an
actual release is requested; an unfinished sprint must not reserve a date.
Record the exact publication date in the release note when preparing the actual
release. Each repository release note identifies changed schema versions and
relevant compatibility/migration information. Preserve already-published version
directories byte-for-byte, including semantics and examples; changes require new
schema versions. Independent stable schemas follow SemVer. Pre-stable breaking
changes still require a new document contract generation under the roadmap's
explicit policy. Document how operators and consumers migrate rather than
introducing conversions.
Keep the source-only release procedure small. Adapt its existing fresh-tag,
clean-candidate, authoritative-remote, fast-forward, validation, and atomic
branch/tag publication checks to CalVer. Before later publication, compare retained
published directories against the inventories in earlier authoritative release
tags; additions are allowed, changes or removals are not. The initial release has
no published baseline. Use focused Git/file checks rather than a new release
framework. Exercise any new check logic with disposable local fixtures, without
publishing this repository.
Explain that hosting directly from `main` is supported: candidate files may be
visible, but only published tags and their inventories establish released
versions. No backend release selector, live website test, or consumer adoption is
a source-publication gate. Source release completes on successful publication;
optional subsequent URL inspection is delivery verification. ReleaseKit remains
deferred. Keep the current internal Go module identity and pinned libraries unless
an actual implementation need justifies a change.
Acceptance: no active instruction assumes a repository SemVer release, rewrites
all schema IDs on every release, or requires release-selected hosting. Consumers
can follow a documented example to pin one schema version from a CalVer archive,
bundle its dependency closure and semantics, and ignore unrelated updates.
## Stage 5 — Align verification, CI, and source distribution
Update `internal/validation/validation_test.go`,
`internal/validation/documentation_test.go`, CLI tests, `scripts/check.sh`, and
`.woodpecker.yml` where their assumptions changed. Retain established parser and
domain tests; replace only obsolete paths, markers, and selection assumptions.
Use synthetic temporary versions for multi-version tests rather than adding fake
released versions to the real catalog.
Verification must cover:
- Every inventoried schema compiles offline and its examples validate under its
exact version; semantic duplicate IDs still fail after structural success.
- Known-field constraints, extensions, omission/null distinctions, YAML/JSON
equivalence, and the two reviewed decoding fixes remain protected.
- Inventory collisions, missing references, path/ID mismatch, and explicit
multi-version selection fail or succeed as specified in stages 2 and 3.
- Published-directory checks detect modifications/removals while permitting a new
version and an otherwise unchanged schema in a later CalVer snapshot.
- Documentation links, semantic documents, examples, license/attribution, catalog,
and candidate release note are present in the unpacked committed archive.
- A local static-file server exposes each schema at the path represented by its
`$id`, returning the same JSON bytes. This needs no production host or external
network access.
Retain the unpacked-archive test: it must work without the original checkout or
Git metadata inside the extracted tree. Keep Git history-based immutability checks
separate from offline distribution checks. Prepare dependencies before validation;
normal checks require no providers, credentials, consumer installs, or live URLs.
Do not build a generic schema compatibility prover or repeat upstream library
suites. Repository CI continues to run the same documented checks.
Acceptance: focused tests pass, then `GOTOOLCHAIN=go1.27.4 go test ./...` and
`GOTOOLCHAIN=go1.27.4 go vet ./...` pass. After committing the intended candidate,
`GOTOOLCHAIN=go1.27.4 sh scripts/check.sh` passes for that exact revision.
## Stage 6 — Audit and hand off the unpublished candidate
Review the final diff against every requirement in roadmap step 1. Check for
stale active forge IDs, old markers, flat-layout commands, SemVer repository
assumptions, and ReleaseKit/hosting release gates. Historical origin records may
retain historical identifiers. Confirm that no compatibility shim, SDK, runtime
network resolution, application migration, tag, or push was introduced.
Record the completed stages, candidate commit, actual initial schema versions,
validation results, and any unresolved limitations. Keep both the schema checkout
and planning changes committed and clean. Stop at a locally validated, unpublished
candidate. A later explicit release task selects the actual CalVer version and
performs publication; it is outside this sprint.
## Completion evidence
| Roadmap requirement | Evidence at sprint completion |
| --- | --- |
| Independent identities and RPG namespace | Version directories, catalog, matching IDs/markers, schema tests |
| URL-aligned hosting from `main` | Direct repository paths and local static-serving check |
| Immutable versions and CalVer snapshots | Compatibility policy, release procedure, focused history-check fixtures |
| Selective offline consumer adoption | Exact validator selection, reference-resolution checks, consumer instructions |
| Complete distribution | Archive checks, versioned semantics/examples, license and attribution |
| No premature publication or consumer work | Reviewed scope diff, unchanged remote publication state, clean local candidate |
No upstream application decisions block this repository alignment. The proposed
initial `0.1.0` versions are the sole pending product choice; the concrete inventory
and CLI spellings above are implementation-plan proposals ready for review.

321
docs/roadmap/schemas.md Normal file
View File

@@ -0,0 +1,321 @@
# Adopt shared domain schemas across the pipeline
## Purpose and status
Operators should maintain one set of domain inputs, primarily in YAML, that
Narratio, Audita, Notarius, and relevant Scriptorium prompts can consume through
published contracts. Consumers own the interpretations and projections needed
for their tasks.
The [schemas repository](https://forge.maximumdirect.net/eric/schemas) is
implemented and reviewed, including fixes for JSON Unicode decoding and malformed
YAML floats. Before its initial release, revise its layout, versioning, inventory,
and release workflow to implement the design below. The initial release remains
pending; this roadmap does not authorize publication.
This roadmap coordinates adoption across repositories. Consumer-specific roadmaps
will define their external interfaces and implementation work. The shared
[contracts and compatibility guidance](https://forge.maximumdirect.net/eric/schemas/src/branch/main/docs/compatibility.md)
remain owned by `schemas`; implementation does not yet establish application
compatibility.
The [staged implementation plan](schemas-implementation.md) covers repository
alignment in step 1. Consumer adoption remains separate work.
## Ownership and delivery
- `schemas` owns domain structures, field meanings, examples, and compatibility.
- ConfigKit owns configuration composition and resolution. Validate completed
domain documents after composition; partial authoring fragments need not
satisfy a complete-document schema.
- Narratio owns preparation, durable shared inputs, domain projections, and
orchestration. Each consumer owns its task requirements and interpretation.
- Shared snapshots preserve extension fields. Task-specific projections may
select a subset without changing the source document's meaning.
Use maintained validation libraries and pin schemas for offline use. The schema
repository's Go harness remains a development tool, not an application SDK or
runtime dependency. Do not add a registry service, runtime schema downloads, or
a second configuration system.
Deliver consumer migrations as complete cutovers with release guidance. Do not
add legacy conversion, compatibility shims, or duplicate operator-maintained
vocabulary. Intermediate implementation commits need not provide a working
mixed-format application.
## 1. Prepare and publish the shared schema collection
### Repository and contract versioning
Release repository snapshots using CalVer `YYYY.MM.MICRO`. Use the UTC release
year and zero-padded month; `MICRO` is a publication counter starting at zero each
month. For example, `2026.11.0`, `2026.11.1`, and `2026.12.0` are successive
releases. The counter carries no compatibility meaning. Record exact publication
dates in release metadata. Select the actual version when preparing the release.
Version each schema independently with full SemVer. A repository release can
contain unchanged versions of most schemas and a new version of just one. Record
compatibility and migration notes per changed schema. Compatible additions and
corrections follow its SemVer policy; incompatible structure or meaning requires
an explicit contract transition. Preserve the distinction between pre-stable
schema development and stable contracts when selecting initial schema versions.
The former repository-wide `v0.1.0` target is replaced by CalVer.
Operator documents continue to declare major contract generations:
| Schema | Document `schema_version` |
| --- | --- |
| RPG party | `maximumdirect.rpg.party.v1` |
| RPG campaign | `maximumdirect.rpg.campaign.v1` |
| Glossary | `maximumdirect.glossary.v1` |
Use the `rpg` namespace for party and campaign to distinguish these contracts
from unrelated domains. The glossary remains domain-neutral. Rename the
unpublished candidate identifiers directly, including examples and fixtures;
no compatibility aliases or version increment are needed for this rename.
Compatible schema updates retain these markers. Incompatible contract changes
change the affected marker, including during pre-stable schema development;
unaffected schemas retain their identifiers. Document markers identify contract
generations, not repository dates or pre-stable release maturity. Schema versions,
repository releases, and application versions evolve independently.
### Layout and canonical identities
Organize the repository root to match canonical URL paths, with no publication
step that rearranges contract files. An illustrative layout is:
```text
glossary/
v1.0.0/
schema.json
semantics.md
examples/
v1.1.0/
schema.json
semantics.md
examples/
rpg/
party/
v1.0.0/
schema.json
semantics.md
examples/
campaign/
v1.0.0/
schema.json
semantics.md
examples/
catalog.json
README.md
```
These version numbers illustrate the layout, not initial stability declarations.
A schema's `$id` identifies its exact version, for example
`https://schemas.maximumdirect.net/glossary/v1.1.0/schema.json`. Repository
snapshots containing that same schema version retain the same `$id` and content.
Pin cross-schema references to exact versioned identities; validate them both
through local registration and the published path layout.
RPG schema URLs mirror their domain-qualified paths, for example
`https://schemas.maximumdirect.net/rpg/party/v1.0.0/schema.json` and
`https://schemas.maximumdirect.net/rpg/campaign/v1.0.0/schema.json`.
Published version directories, including their semantic documentation and
examples, remain immutable and available. Corrections produce a new version
rather than replacing published files. Keep development tooling and tests outside
these directories. A root page or unversioned documentation link may aid discovery;
a moving latest alias must not become a pinned schema identity.
`https://schemas.maximumdirect.net/` serves raw repository content directly from
`main`. This is the supported initial hosting arrangement. Use this domain for
canonical `$id` values; domain setup is no longer pending. Hosting remains
maintained separately. Serving a selected CalVer snapshot is not a publication
prerequisite, and no additional backend publication machinery is required.
Published version directories remain immutable as `main` advances. Unfinished
version directories may also be publicly accessible; URL availability does not
establish release status. Published CalVer tags and their inventories identify
released versions. Verify versioned URLs return schema JSON after the layout
lands as a delivery check, separate from source-release completion.
### Release inventory and consumer updates
Add a machine-readable `catalog.json` listing available schemas and versions,
their document contract identifiers, canonical `$id` values, and relative file
locations. Include retained published versions. The inventory may evolve with
repository releases; its copy in each tagged snapshot is immutable. Document its
format and verify that entries agree with the version directories and schema IDs.
The inventory served from `main` is a development view, not a pinned release
snapshot. Consumers use the inventory and contract files from a published tag.
Consumers select exact versions of the schemas they use and record the source
CalVer distribution. Bundle those schemas, their referenced dependencies, and
relevant semantic documentation for offline use. An unrelated schema's update
does not require a consumer upgrade, and consumers need not import the whole
repository as a Go dependency.
For a relevant update, review that schema's compatibility notes, replace the
bundled contract files, test application behavior, and commit the selected
versions. A manual, documented update process is sufficient initially; do not
build a package manager. Application releases identify supported contract
generations and task-specific requirements. Accepting or preserving an extension
does not imply support for its meaning.
### Required work before the initial release
- Move the three contracts, their semantics, and examples into the versioned root
layout, including the `rpg` namespace for party and campaign. Update their
document identifiers throughout schemas, validation, examples, and documentation.
Select and record their initial independent semantic versions.
- Replace repository SemVer assumptions in `VERSION`, release-note naming,
compatibility guidance, and the release procedure with the CalVer convention.
- Set canonical `$id` values, update references and documentation links, and add
the release inventory. Remove obsolete flat-layout and forge-ID assumptions.
- Adapt the validation harness, fixtures, CI, and archive checks to discover and
validate the versioned contracts. Check inventory consistency, offline reference
resolution, and the correspondence between repository paths and canonical URLs.
- Verify that the tagged source archive contains complete contracts, semantic
documentation, examples, licensing, and the optional validation harness. Retain
the reviewed decoding fixes and validate the intended committed candidate.
Defer ReleaseKit adoption until it supports the selected CalVer repository
workflow. It is not a prerequisite for the initial release. A later upstream
feature request can define that support; do not encode dates as semantic major
versions merely to satisfy existing tooling. In the meantime, keep the
repository's source-only release procedure small, explicit, and appropriate to
CalVer, with fresh immutable tags and validation of the intended candidate.
No validator binary distribution is required.
Update the schema repository's
[release procedure](https://forge.maximumdirect.net/eric/schemas/src/branch/main/docs/release.md)
with these changes before using it. Publish only when requested. Consumer
adoption is not a prerequisite for publishing the independently usable collection,
and publication does not declare existing consumers compatible.
## 2. Plan and implement Notarius adoption
Start consumer design with Notarius because its structured spell input has the
largest remaining semantic difference. Prepare an upstream adoption roadmap
before implementing Narratio bindings around it.
Notarius should accept the shared glossary contract for spell vocabulary and
derive recognition inputs from names, aliases, and relevant provenance. An
operator must not need a second spell overlay containing the same vocabulary.
Notarius continues to own embedded vocabulary, normalization, source precedence,
collisions, and extraction strategy.
Settle collection selection and task-specific provenance requirements, including
how absent provenance is handled. Do not promote those requirements into the
general glossary schema merely to match the existing implementation. Review
party and other reference inputs wherever Notarius relies on their structure;
free-text references need no new typed interface solely for uniformity.
Allow consumers to use the subset of collections relevant to their task. Native
YAML consumption is useful, but a faithful YAML-to-JSON projection by Narratio
is sufficient where required. Format conversion must not require a separately
authored document or move Notarius's recognition policy into Narratio.
## 3. Adopt the glossary contract in Audita and the reference catalog
Audita and catalog work can proceed alongside Notarius once their adoption
interfaces are settled.
Audita should accept the shared glossary envelope and obtain task instructions
from its configuration. Unknown domain fields must not acquire instruction
semantics. Its processing and preflight paths should apply the same input
contract and retain Audita-owned task checks.
The reference catalog should adopt the published glossary schema and semantic
contract instead of maintaining a competing format definition. Keep vocabulary
releases independent of schema releases. ConfigKit continues to compose source
fragments; completed glossary documents carry the shared envelope. Preserve
useful source provenance and extensions.
Each repository updates maintained examples, validation, and migration guidance
with its adoption. Consumer releases establish the supported inputs before
Narratio's cutover relies on them.
## 4. Prepare and implement coordinated Narratio adoption
Prepare a Narratio roadmap against the selected schema and consumer releases.
Cover shared party inputs, glossary preparation, saved projections, downstream
bindings, and affected Scriptorium prompt contracts.
Retain the four glossary collections: `party`, `campaign`, `setting`, and
`spells`. Derive party vocabulary from the canonical roster. Save shared inputs
and any necessary combined or consumer-specific projections through the existing
prepared-input machinery. Supply subsets according to consumer needs; Audita's
four-collection use does not require every subprocess to consume all four.
Keep shared campaign data distinct from operational campaign configuration.
Determine how shared campaign context is supplied without automatically requiring
another operator-maintained file. Preserve the choice of inline campaign
glossary entries or an imported glossary file through native configuration
composition. Validate the completed shared document at the preparation boundary.
Review Narratio-specific roster requirements against the shared party contract.
Keep requirements justified by Narratio's tasks distinct from schema conformance.
Preserve extensions in forwarded inputs and keep downstream interpretation in
the downstream consumer. Reuse existing preparation, artifact, resume, and
preflight paths rather than introducing parallel machinery.
Reconcile the [Notarius roadmap](notarius.md): replace its separate spell-overlay
assumption with the adopted shared input contract, and update readiness planning
to use the now-documented native Notarius preflight interface. Verify the selected
release's contract when drafting the detailed adoption plan.
Update Scriptorium prompts that consume these inputs alongside the prepared
artifact changes. Schema adoption alone does not require a generic Scriptorium
application enhancement.
## 5. Verify the single-source workflow
Use one representative synthetic set of authored YAML inputs to demonstrate the
complete path from preparation to consumer ingestion. Establish that:
- Narratio prepares the roster and shared glossaries without duplicate authored
vocabulary, including a single spell source used by Audita and Notarius.
- Native YAML and any required JSON projections preserve shared values, aliases,
provenance, and extensions; task projections retain the information they need.
- Schema failures and consumer task failures surface through preparation or
native preflight before expensive processing, using the execution inputs.
- Prepared artifacts remain available to relevant Scriptorium prompts and behave
correctly through existing resume and changed-input invalidation paths.
Use focused automated contract checks and controlled integration fixtures.
Routine verification should not require paid provider calls. Update canonical
integration documentation, examples, and release guidance as each implementation
lands. Application compatibility claims should identify the versions actually
verified together.
## Sequence and remaining decisions
Settle initial independent schema versions before implementation. The plan must
also define explicit exact-version selection for the validation harness: a document
major marker alone cannot distinguish multiple compatible schema versions. Inventory
field details and test organization are implementation choices, not additional
product decisions. Direct hosting from `main` requires no release-selection work
before publication.
Consumer planning can proceed before publication, but released consumers should
pin selected schema versions and their published source distribution. Address
Notarius's spell-input semantics first; Audita and catalog adoption can proceed
in parallel. Complete Narratio's cutover against supported upstream interfaces,
then verify the integrated workflow.
The consumer roadmaps must settle:
1. Notarius collection selection, provenance requirements, and their relationship
to its embedded vocabulary and recognition policy.
2. Narratio's acquisition or projection of shared campaign context, while keeping
operational configuration separate and avoiding duplicate authoring.
3. Concrete schema and consumer release baselines, reference bindings, and any
task-specific requirements beyond shared-schema conformance.
Complete the repository changes in step 1 before the initial release, including
selection of initial schema versions. Verify canonical URL delivery separately
after the layout is available.
Notarius's shared-schema adoption roadmap is the first consumer planning task.
Consumer decisions do not by themselves block an independently usable schema
release, and deferred ReleaseKit adoption is not a release gate.