Files
narratio/docs/roadmap/schemas-implementation.md

15 KiB

Shared schemas repository alignment: implementation plan

Scope and execution

Implement step 1 of the shared-schema adoption roadmap 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.

Execution status

  • Stage 1 complete: schemas commit d4488ab moves the contracts, semantics, and examples to independent v0.1.0 roots and adopts the RPG identifiers. Decoder-profile and numeric-precision regressions pass.
  • Stage 2 complete: schemas commit 2bf4e82 introduces the catalog and offline version-aware loader. Focused catalog tests pass, including two definitions sharing one document marker, inventory failures, and absent offline references.
  • Stage 3 complete: schemas commit f168d01 requires exact name@version CLI selection and reports that selection on success.
  • Stage 4 complete: schemas commit 053219b separates CalVer distributions, independent schema SemVer, document generations, and canonical IDs. Release history checks preserve published records and directory contents, with disposable local Git fixtures covering changes, removals, and additions.
  • Stage 5 complete: schemas commit e2e86a0 aligns all examples and tests, verifies actual CLI selection between two temporary compatible generations, checks canonical paths with a local static server, and retains the reviewed decoder regressions. CI already invokes the unchanged common check script.
  • Stage 6 complete: the locally validated candidate is schemas commit e2e86a0, with distribution candidate 2026.11.0 and all three independent schema versions at 0.1.0. Full tests, vet, repeated race/shuffle tests, exact CLI example invocations, and GOTOOLCHAIN=go1.27.4 sh scripts/check.sh passed. That script also passed from the unpacked committed archive. A local preview archive is available at ../schemas/dist/schemas-2026.11.0.tar.gz.

The final scope review found no domain-field changes beyond the requested unpublished marker/identity transition. The internal module, dependencies, and reviewed decoder implementation remain unchanged. Exact source metadata and historical origin snapshots remain preserved. Narratio application code and the pending consumer/workspace roadmaps are unchanged.

Production URL delivery and CI execution were not performed; local static serving and the documented CI command passed. A later explicit release task must select the actual publication month/counter, record its publication date, and publish. Hosting and consumer adoption remain outside this sprint.

No upstream tags existed when execution began. No tag or push has been made.

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:

{
  "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:

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. Execution selected the plan's initial 0.1.0 versions and exact CLI/catalog conventions. Release publication and application adoption remain separately authorized work.