Establish shared domain schemas and offline validation
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/dist/
|
||||
9
.woodpecker.yml
Normal file
9
.woodpecker.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
steps:
|
||||
- name: validate
|
||||
image: golang:1.27.4
|
||||
commands:
|
||||
- go mod download
|
||||
- sh scripts/check.sh
|
||||
|
||||
when:
|
||||
- event: [push, pull_request, tag, manual]
|
||||
11
AGENTS.md
Normal file
11
AGENTS.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Contributor orientation
|
||||
|
||||
Read `docs/development.md` first. The schemas and their semantic documentation
|
||||
jointly define the public contracts. Keep examples synthetic and validate changes
|
||||
with `go test ./...` before committing focused work with a plain English message.
|
||||
|
||||
Use maintained YAML and JSON Schema libraries. Keep the Go harness internal to
|
||||
this repository. Application composition, consumer migrations, prompts, and
|
||||
reference vocabulary belong elsewhere. Preserve the selected CC0 license and
|
||||
record the terms of incorporated material. Publishing requires an explicit
|
||||
release request; see `docs/release.md`.
|
||||
11
COPYRIGHT
Normal file
11
COPYRIGHT
Normal file
@@ -0,0 +1,11 @@
|
||||
Maximum Direct shared schemas
|
||||
Copyright 2026 Eric Rakestraw
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
The original schemas, documentation, examples, fixtures, and validation tooling
|
||||
in this repository are dedicated to the public domain under CC0 1.0 Universal.
|
||||
See LICENSE for the complete text.
|
||||
|
||||
Third-party material retains its applicable terms. See
|
||||
docs/oss/attribution.md for attribution and license links.
|
||||
56
README.md
56
README.md
@@ -1,2 +1,56 @@
|
||||
# campaign-schemas
|
||||
# Maximum Direct shared schemas
|
||||
|
||||
Language-neutral contracts for shared domain inputs. Author information once in
|
||||
YAML or JSON, validate the completed document, and let each consumer derive the
|
||||
view required by its task.
|
||||
|
||||
| Document | Contract | Semantics | Schema |
|
||||
| --- | --- | --- | --- |
|
||||
| Party | `maximumdirect.party.v1` | [Party](docs/party.md) | [party.schema.json](schemas/party.schema.json) |
|
||||
| Campaign | `maximumdirect.campaign.v1` | [Campaign](docs/campaign.md) | [campaign.schema.json](schemas/campaign.schema.json) |
|
||||
| Glossary | `maximumdirect.glossary.v1` | [Glossary](docs/glossary.md) | [glossary.schema.json](schemas/glossary.schema.json) |
|
||||
|
||||
Start with the synthetic [examples](examples/). Every standalone document has a
|
||||
`schema_version`. Glossaries contain named collections under `collections`.
|
||||
Additional fields are permitted; consumers define which extensions they support.
|
||||
Application settings, prompts, credentials, and reference vocabulary belong in
|
||||
their respective repositories.
|
||||
|
||||
## Validate
|
||||
|
||||
Install Go 1.27 or later and prepare the pinned dependencies:
|
||||
|
||||
```sh
|
||||
go mod download
|
||||
go run ./cmd/validate examples/party.yml examples/campaign.yml examples/glossary.yml
|
||||
go test ./...
|
||||
```
|
||||
|
||||
[Validation](docs/validation.md) defines the YAML profile, command, and semantic
|
||||
checks. ConfigKit owns composition before the completed-document boundary.
|
||||
The Go harness is a development tool, not a consumer SDK.
|
||||
|
||||
## Select a distribution
|
||||
|
||||
`VERSION` identifies the schema-set candidate, initially `v1.0.0`. Publication is
|
||||
separate from implementation. Select an immutable tag using the
|
||||
[release procedure](docs/release.md), then bundle the complete `schemas/`
|
||||
directory and [semantic documentation](docs/compatibility.md) for offline use.
|
||||
For example, after publication:
|
||||
|
||||
```text
|
||||
https://forge.maximumdirect.net/eric/schemas/archive/v1.0.0.tar.gz
|
||||
https://forge.maximumdirect.net/eric/schemas/raw/tag/v1.0.0/schemas/glossary.schema.json
|
||||
```
|
||||
|
||||
The raw URL is also that schema's `$id`. Its tag identifies the schema-set
|
||||
release; document headers carry only the major contract version. Existing
|
||||
applications require their own adoption work. See the
|
||||
[consumer compatibility inventory](docs/compatibility.md#existing-consumers).
|
||||
|
||||
Contributors start with [development](docs/development.md).
|
||||
|
||||
Original material is dedicated to the public domain under [CC0 1.0](COPYRIGHT).
|
||||
|
||||
[Open Source attribution notices](docs/oss/attribution.md) identify incorporated material and dependencies.
|
||||
|
||||
|
||||
62
cmd/validate/main.go
Normal file
62
cmd/validate/main.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// validate checks completed domain documents against a local schema distribution.
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"forge.maximumdirect.net/eric/schemas/internal/validation"
|
||||
)
|
||||
|
||||
func main() { os.Exit(run(os.Args[1:], os.Stdout, os.Stderr)) }
|
||||
|
||||
func run(args []string, stdout, stderr io.Writer) int {
|
||||
flags := flag.NewFlagSet("validate", flag.ContinueOnError)
|
||||
flags.SetOutput(stderr)
|
||||
root := flags.String("root", ".", "unpacked schema-set root (contains VERSION and schemas/)")
|
||||
flags.Usage = func() {
|
||||
fmt.Fprintln(stderr, "Usage: validate [-root DIRECTORY] DOCUMENT...")
|
||||
flags.PrintDefaults()
|
||||
}
|
||||
if err := flags.Parse(args); err != nil {
|
||||
if err == flag.ErrHelp {
|
||||
return 0
|
||||
}
|
||||
return 2
|
||||
}
|
||||
if flags.NArg() == 0 {
|
||||
flags.Usage()
|
||||
return 2
|
||||
}
|
||||
set, err := validation.Load(os.DirFS(*root))
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "schema set: %v\n", err)
|
||||
return 2
|
||||
}
|
||||
status := 0
|
||||
for _, file := range flags.Args() {
|
||||
data, err := os.ReadFile(file)
|
||||
if err == nil && strings.EqualFold(filepath.Ext(file), ".json") && !json.Valid(data) {
|
||||
err = fmt.Errorf("decode: expected JSON syntax")
|
||||
}
|
||||
var value any
|
||||
if err == nil {
|
||||
value, err = validation.Decode(data)
|
||||
}
|
||||
if err == nil {
|
||||
err = set.Validate(value)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "%s: %v\n", file, err)
|
||||
status = 1
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(stdout, "%s: valid (%s)\n", file, value.(map[string]any)["schema_version"])
|
||||
}
|
||||
return status
|
||||
}
|
||||
48
cmd/validate/main_test.go
Normal file
48
cmd/validate/main_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommand(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
args []string
|
||||
code int
|
||||
out string
|
||||
err string
|
||||
}{
|
||||
{"valid", []string{"-root", "../..", "../../examples/party.yml"}, 0, "valid (maximumdirect.party.v1)", ""},
|
||||
{"continue after failure", []string{"-root", "../..", "../../tests/invalid/semantic-duplicate-id.yml", "../../examples/weather.json"}, 1, "weather.json: valid", "semantic:"},
|
||||
{"structural", []string{"-root", "../..", "../../tests/invalid/structure-missing-name.yml"}, 1, "", "structure:"},
|
||||
{"decode", []string{"-root", "../..", "../../tests/invalid/decode-duplicate-key.yml"}, 1, "", "decode:"},
|
||||
{"file missing", []string{"-root", "../..", filepath.Join(t.TempDir(), "missing.yml")}, 1, "", "missing.yml"},
|
||||
{"no documents", nil, 2, "", "Usage:"},
|
||||
{"bad flag", []string{"-unknown"}, 2, "", "flag provided"},
|
||||
{"help", []string{"-h"}, 0, "", "Usage:"},
|
||||
{"missing set", []string{"-root", t.TempDir(), "../../examples/party.yml"}, 2, "", "schema set:"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := run(test.args, &stdout, &stderr)
|
||||
if code != test.code || !strings.Contains(stdout.String(), test.out) || !strings.Contains(stderr.String(), test.err) {
|
||||
t.Fatalf("exit=%d, stdout=%q, stderr=%q", code, &stdout, &stderr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestJSONSyntax(t *testing.T) {
|
||||
file := filepath.Join(t.TempDir(), "document.json")
|
||||
if err := os.WriteFile(file, []byte("schema_version: maximumdirect.campaign.v1\nid: sample"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var stdout, stderr bytes.Buffer
|
||||
if run([]string{"-root", "../..", file}, &stdout, &stderr) != 1 || !strings.Contains(stderr.String(), "decode: expected JSON syntax") {
|
||||
t.Fatalf("expected JSON syntax failure, got %q", &stderr)
|
||||
}
|
||||
}
|
||||
37
docs/campaign.md
Normal file
37
docs/campaign.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Campaign contract
|
||||
|
||||
Contract: `maximumdirect.campaign.v1`. [Schema](../schemas/campaign.schema.json).
|
||||
The [validation profile](validation.md) and [compatibility rules](compatibility.md)
|
||||
apply. See the [example](../examples/campaign.yml).
|
||||
|
||||
| Field | Required | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `schema_version` | Yes | Exactly `maximumdirect.campaign.v1`. |
|
||||
| `id` | Yes | Nonempty stable campaign identity, independent of its display name. |
|
||||
| `name` | No | Nonempty campaign display name. |
|
||||
| `description` | No | Free text campaign context; an empty string is valid. |
|
||||
| `setting` | No | Nonempty domain setting label or identifier. |
|
||||
| `system` | No | Nonempty game-system label or identifier. |
|
||||
| `references` | No | Relationships to domain documents. |
|
||||
| `references.party` | No | Nonempty locator for a party document. |
|
||||
| `references.glossaries` | No | List of nonempty locators for glossary documents; may be empty. |
|
||||
|
||||
Optional fields accept omission, not null. An empty `references` object is
|
||||
valid. Objects allow additional fields. IDs, labels, and locator strings are
|
||||
preserved without normalization. The issuer supplies the identity's namespace;
|
||||
this contract does not require globally unique campaign IDs.
|
||||
|
||||
References are locator strings, including URI references and relative file
|
||||
references. Consumers select supported locator forms and resolve relative
|
||||
references against the domain document's location (or a base
|
||||
provided with an in-memory document). Resolving authored configuration paths
|
||||
before this boundary remains the composing application's responsibility.
|
||||
References express relationships; the harness neither fetches them nor requires
|
||||
local installation. List order does not prescribe merge order, precedence, or
|
||||
execution. Those belong to the consuming application.
|
||||
|
||||
This document records shared context. Narratio's `campaign.yml` remains
|
||||
application configuration with its own operational fields. Session templates,
|
||||
speaker-file choices, execution paths, provider policy, and credentials are
|
||||
outside the defined shared campaign fields. Additional fields gain no execution
|
||||
or credential semantics through schema conformance.
|
||||
57
docs/compatibility.md
Normal file
57
docs/compatibility.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Compatibility
|
||||
|
||||
The initial candidate is the `v1.0.0` schema set. Publication status is established
|
||||
by the immutable upstream tag, not by this candidate's `VERSION` file. Contracts
|
||||
jointly comprise their JSON Schemas and semantic documents.
|
||||
|
||||
## Version identities
|
||||
|
||||
Schema-set releases use Semantic Versioning and ship together. Contract markers
|
||||
`maximumdirect.party.v1`, `maximumdirect.campaign.v1`, and
|
||||
`maximumdirect.glossary.v1` identify major domain contracts. A compatible schema
|
||||
release does not require editing operator document headers.
|
||||
|
||||
- Major: incompatible structure, validation, or meaning.
|
||||
- Minor: compatible additions that preserve interpretation of existing data.
|
||||
- Patch: compatible corrections. A tighter validation rule that rejects previously
|
||||
valid documents is not automatically a patch fix.
|
||||
|
||||
Each release pins absolute `$id` values to its immutable raw tag URLs. These are
|
||||
schema resource identities, distinct from the operator's contract marker.
|
||||
Vocabulary, schema-set, and consumer application versions evolve independently.
|
||||
|
||||
## Both directions matter
|
||||
|
||||
A new consumer should accept old documents within its claimed major contract.
|
||||
An older consumer can accept and preserve new optional extension fields without
|
||||
claiming their meaning. Additional fields are compatible only when ignoring
|
||||
them preserves interpretation of the known data. A field changing that
|
||||
interpretation needs a new major contract or an explicitly selected extension
|
||||
contract with its own documented semantics.
|
||||
|
||||
Consumers forwarding or republishing shared documents should preserve extensions;
|
||||
task-specific projections may omit them. Extensions cannot redefine a standard
|
||||
field. Consumers can require additional data for a task without claiming that
|
||||
every shared document must contain it.
|
||||
|
||||
Contract changes include a compatibility assessment, updated schema and semantics,
|
||||
examples and focused fixtures, and migration guidance for incompatible changes.
|
||||
Retain representative valid documents from supported releases in `tests/valid/`
|
||||
as compatibility evidence. A schema diff alone does not detect changed meanings.
|
||||
The initial release has no earlier shared-schema releases to compare against.
|
||||
|
||||
## Existing consumers
|
||||
|
||||
No existing application is declared compatible by this repository's initial
|
||||
release. Adoption requires explicit implementation and verification.
|
||||
|
||||
| Consumer | Current gap / later adoption responsibility |
|
||||
| --- | --- |
|
||||
| Narratio | Uses `narratio.party.v1`, stricter roster requirements, and the wrapperless glossary schema. Separate shared domain documents from operational campaign configuration and adopt the shared marker, alias spelling, and extension semantics. |
|
||||
| Audita v4.2.0 | Runtime glossary input is wrapperless and can contain task instructions. Adopt the shared envelope and obtain instructions through application configuration. |
|
||||
| Notarius v0.9.0 | Spell recognition consumes a strict JSON overlay with separate catalog and ruleset semantics. Reconcile its embedded catalog, merges, and ambiguity rules with shared spell entries and provenance; recognize names and aliases without asking operators to duplicate the source vocabulary. |
|
||||
| Scriptorium prompts | Adopt shared party and glossary structures in the prompt input contracts that need them; no generic application compatibility is implied. |
|
||||
| Reference catalog | Retains a wrapperless glossary and partial authoring format. Adopt shared completed envelopes while leaving composition to ConfigKit and vocabulary distribution independent. |
|
||||
|
||||
The [inventory](inventory.md) identifies source baselines and the deliberate
|
||||
differences. Consumer release order and conversion code belong to later work.
|
||||
46
docs/development.md
Normal file
46
docs/development.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Development
|
||||
|
||||
Start with the [README](../README.md), [agent guidance](../AGENTS.md), and the
|
||||
affected contract's schema and semantic document. [Inventory](inventory.md)
|
||||
records the initial scope decisions; [compatibility](compatibility.md) owns
|
||||
change classification and current consumer gaps.
|
||||
|
||||
Go 1.27.0 is the harness minimum. Maintained checks use the official Go 1.27.4
|
||||
toolchain. Prepare the pinned dependencies with `go mod download`, then run:
|
||||
|
||||
```sh
|
||||
go test ./...
|
||||
go vet ./...
|
||||
```
|
||||
|
||||
`go test ./...` compiles and meta-validates all schemas, validates all examples
|
||||
and fixtures, checks semantic uniqueness and YAML/JSON equivalence, exercises
|
||||
decoding and CLI failures, and checks that distribution content and local
|
||||
documentation links are present. Tests are offline and use synthetic data.
|
||||
|
||||
`sh scripts/check.sh` runs those checks and verifies an unpacked `git archive`
|
||||
of the committed candidate. Use it after committing when preparing a release.
|
||||
CI uses the same command. It tests the source archive independently of the
|
||||
original checkout so missing files and accidental outside references are caught.
|
||||
|
||||
## Layout and changes
|
||||
|
||||
- `schemas/`: language-neutral Draft 2020-12 contracts.
|
||||
- `docs/{party,campaign,glossary}.md`: field meanings and semantic rules.
|
||||
- `examples/`: complete authoring examples, including equivalent YAML and JSON.
|
||||
- `tests/valid/`: valid compatibility fixtures.
|
||||
- `tests/invalid/`: focused invalid documents; prefixes identify failure phase.
|
||||
- `internal/validation/`: local YAML profile, schema registration, semantic check.
|
||||
- `cmd/validate/`: developer CLI; no application SDK or configuration loader.
|
||||
|
||||
Implement a contract change in its schema, semantics, and relevant examples and
|
||||
fixtures together. Test observable acceptance and rejection, extension retention,
|
||||
and semantic boundaries. Avoid duplicating the upstream libraries' own suites.
|
||||
New standard fields need a compatibility assessment. Routine editing does not
|
||||
publish a release or upgrade any consumer.
|
||||
|
||||
Keep one canonical owner for each definition. Link to upstream library guides
|
||||
for their features. Use original synthetic examples. Before incorporating source
|
||||
material, record its origin, revision, applicable license, and modifications in
|
||||
[attribution](oss/attribution.md); the repository's CC0 choice does not change
|
||||
third-party terms. New code and prose here are dedicated under [CC0](../COPYRIGHT).
|
||||
67
docs/glossary.md
Normal file
67
docs/glossary.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Glossary contract
|
||||
|
||||
Contract: `maximumdirect.glossary.v1`. [Schema](../schemas/glossary.schema.json).
|
||||
The [validation profile](validation.md) and [compatibility rules](compatibility.md)
|
||||
apply. Start with [campaign vocabulary](../examples/glossary.yml),
|
||||
[weather](../examples/weather.yml), or [sports](../examples/sports.yml).
|
||||
|
||||
| Field | Required | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `schema_version` | Yes | Exactly `maximumdirect.glossary.v1`. |
|
||||
| `collections` | Yes | Mapping of nonempty collection names to collections; may be empty. |
|
||||
| `collections.<name>.entries` | Yes | List of entries; may be empty. |
|
||||
| `entries[].id` | Yes | Stable, nonempty identity unique within this collection. |
|
||||
| `entries[].name` | Yes | Nonempty canonical display name. |
|
||||
| `entries[].category` | Yes | Nonempty domain-defined category. |
|
||||
| `entries[].description` | No | Description; an empty string is valid. |
|
||||
| `entries[].aliases` | No | Alternative names for the same entity. May be null, empty, or a list of nonempty strings. |
|
||||
| `entries[].plural` | No | Nonempty plural display form, or null. |
|
||||
| `collections.<name>.provenance` | No | Source metadata object, possibly empty. Optional `id`, `ruleset`, and `title` are nonempty strings; optional `version`, `url`, and `license` are strings that may be empty. |
|
||||
|
||||
All objects permit extensions. Optional fields accept omission; only `aliases`
|
||||
and `plural` additionally accept null. Values are preserved without trimming,
|
||||
case folding, coercion, or defaults. IDs and names compare exactly. Distinct
|
||||
collections can reuse an ID. Display names, aliases, and categories need not be
|
||||
unique. Lists retain their authored order but establish no precedence or execution
|
||||
order. Collection names and categories are strings chosen by the domain, not a
|
||||
fixed set of D&D labels.
|
||||
|
||||
For example, `spells` entries contain names, aliases, and optionally extended
|
||||
domain information such as `casting_time`. Their collection's provenance can
|
||||
identify a catalog and ruleset. Provenance describes origin and applicability;
|
||||
it is not transcript evidence or a spell rule. If different source contexts
|
||||
matter, use separately named collections with their own provenance. A consumer
|
||||
can derive its recognition input from these entries instead of requiring a second
|
||||
operator-maintained spell list. Embedded vocabulary, source precedence,
|
||||
normalization, inference, and conflicts remain consumer policy.
|
||||
|
||||
Entry-ID uniqueness is a semantic rule checked separately from JSON Schema.
|
||||
The [validator](validation.md) performs both checks. No cross-document identity or
|
||||
reference-resolution check is part of this initial contract.
|
||||
|
||||
## Extensions and task instructions
|
||||
|
||||
Extensions describe domain information. Consumers forwarding a shared document
|
||||
should retain them; task-specific projections may intentionally omit them.
|
||||
Acceptance and preservation do not claim interpretation. Defined fields retain
|
||||
their schema constraints in an extended document.
|
||||
|
||||
Task instructions belong to consumer configuration. `instruction` is not a
|
||||
defined field in this contract. Like other unknown fields, it can be retained
|
||||
without acquiring instruction semantics. Maintained examples contain domain
|
||||
data only.
|
||||
|
||||
## Authoring contributions
|
||||
|
||||
`#/$defs/partialCollection` is an editor-assistance definition with optional
|
||||
`entries`. `#/$defs/entry` and `#/$defs/collection` assist entry and complete
|
||||
collection editing. A partial contribution is not a standalone valid domain
|
||||
document. ConfigKit owns imports, inheritance, and composition before validation
|
||||
of the complete envelope.
|
||||
|
||||
## Differences from the reference catalog and Audita v4.2
|
||||
|
||||
The old format maps collection names directly at the root. The shared format
|
||||
requires `schema_version` and `collections`. It removes defined collection
|
||||
instructions, permits structural extensions, and adds defined provenance.
|
||||
Existing consumers must explicitly adopt this envelope and its semantics.
|
||||
23
docs/inventory.md
Normal file
23
docs/inventory.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Initial field and ownership inventory
|
||||
|
||||
This inventory precedes and explains the initial contracts. It is design history;
|
||||
the linked contract documents own current semantics.
|
||||
|
||||
| Source and baseline | Shared domain information | Consumer-owned information | Initial disposition |
|
||||
| --- | --- | --- | --- |
|
||||
| Narratio [`party.md`](https://forge.maximumdirect.net/eric/narratio/src/commit/782bcceb1c59bc71d782c7113ed440b47c608d51/docs/integrations/party.md) | Character IDs, names, aliases, player relationships, class names and levels | Artifact-key grammar, roster iteration order, generated players projection | [Party](party.md) retains the nested character/player shape; classes and player are optional, aliases use the common plural spelling, and mapping order has no meaning. |
|
||||
| Narratio [`config.md`](https://forge.maximumdirect.net/eric/narratio/src/commit/782bcceb1c59bc71d782c7113ed440b47c608d51/docs/config.md) | Campaign identity, setting/system labels, relationships to party and glossary resources | Session templates, input staging, provider settings, paths used by execution, secrets | [Campaign](campaign.md) defines a small domain document independent of Narratio configuration. |
|
||||
| CC0 reference catalog `FORMAT.md` and [schema snapshot](origins/reference-catalog-glossary-v1.schema.json) at `a1a87edafd59a1de545a1c0b4efe5feeb80348e0` | Named collections, entry IDs, names, categories, descriptions, aliases, plural forms, extensions | Collection instruction and native composition controls | [Glossary](glossary.md) adds an explicit envelope, permits structural extensions, and removes task instructions from the defined fields. |
|
||||
| Audita v4.2.0 [glossary input](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/transcript-glossary-files.md) | Canonical names, aliases, optional null aliases/plural, rich entries | Pipeline selection, correction instructions, replacement rules | Preserve the shared field shapes; the new envelope requires later Audita adoption. |
|
||||
| Notarius v0.9.0 [spell overlay](https://forge.maximumdirect.net/eric/notarius/src/tag/v0.9.0/docs/integrations/dnd-spell-catalog-overlays.md) | Spell names and aliases, catalog/ruleset provenance | Embedded base catalog, recognition and collision policy, merge order | Spell entries use the general glossary. Catalog/ruleset context is collection provenance; later consumer adoption defines its interpretation. |
|
||||
|
||||
The party and campaign schemas and their documentation are new, independently
|
||||
written specifications informed by the interfaces above; no Narratio or Audita
|
||||
implementation or prose is copied. The glossary schema is adapted from the CC0
|
||||
reference catalog; [attribution](oss/attribution.md) records that source.
|
||||
|
||||
No cross-document relationship is enforced by the initial harness. Campaign
|
||||
references are locators, not assertions that resources exist or are installed.
|
||||
The semantic check beyond JSON Schema is glossary entry-ID uniqueness within
|
||||
each collection. Duplicate mapping keys are decoding failures, including
|
||||
duplicate party IDs. Consumers can add operational requirements at adoption.
|
||||
17
docs/origins/README.md
Normal file
17
docs/origins/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Incorporated schema origin
|
||||
|
||||
The [original glossary schema](reference-catalog-glossary-v1.schema.json) is an
|
||||
unmodified snapshot of `schemas/glossary-v1.schema.json` from the local
|
||||
`narratio-reference-catalog` repository at commit
|
||||
`a1a87edafd59a1de545a1c0b4efe5feeb80348e0`.
|
||||
|
||||
That repository's README dedicates its original vocabulary, schema, examples,
|
||||
and documentation to CC0 1.0. Its LICENSE contains the CC0 1.0 text also supplied
|
||||
in this distribution's [LICENSE](../../LICENSE). The selected revision is not
|
||||
publicly available at the forge during this adoption. This snapshot makes the
|
||||
incorporated source independently inspectable in the distribution.
|
||||
|
||||
The active [shared glossary schema](../../schemas/glossary.schema.json) adapts
|
||||
that source with an envelope, changed defined fields, structural extensions,
|
||||
and provenance. The snapshot records origin; it is not a supported contract
|
||||
or an additional schema that consumers need to register.
|
||||
85
docs/origins/reference-catalog-glossary-v1.schema.json
Normal file
85
docs/origins/reference-catalog-glossary-v1.schema.json
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://forge.maximumdirect.net/eric/narratio-reference-catalog/schemas/glossary-v1.schema.json",
|
||||
"title": "Glossary named collections v1",
|
||||
"$ref": "#/$defs/document",
|
||||
"$defs": {
|
||||
"entry": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"category"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"category": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"aliases": {
|
||||
"type": ["array", "null"],
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"plural": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"partialCollection": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"instruction": {
|
||||
"type": "string"
|
||||
},
|
||||
"entries": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/entry"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"collection": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/$defs/partialCollection"
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"entries"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"document": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/$defs/collection"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
docs/oss/attribution.md
Normal file
52
docs/oss/attribution.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# Open Source Attribution Notices
|
||||
|
||||
## Narratio reference catalog
|
||||
|
||||
Material: `schemas/glossary.schema.json`, adapted from the catalog's glossary-v1
|
||||
schema at `a1a87edafd59a1de545a1c0b4efe5feeb80348e0`. The unmodified source is
|
||||
retained in `docs/origins/reference-catalog-glossary-v1.schema.json`. The shared
|
||||
envelope, defined fields, provenance, and structural extension behavior were changed.
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
License and notices: [CC0 1.0](../../LICENSE).
|
||||
|
||||
[Source](../origins/reference-catalog-glossary-v1.schema.json).
|
||||
|
||||
## go-yaml
|
||||
|
||||
Selected module: `go.yaml.in/yaml/v4` at `v4.0.0`.
|
||||
|
||||
Copyright 2006-2010 Kirill Simonov
|
||||
|
||||
Copyright 2011-2019 Canonical Ltd
|
||||
|
||||
Copyright 2025 The go-yaml Project Contributors
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 AND MIT
|
||||
|
||||
License and notices: [Apache 2.0](licenses/Apache-2.0.txt) | [MIT](licenses/MIT.txt) | [LICENSE](https://github.com/yaml/go-yaml/blob/f2f9563503f11b7a60da0c532175dcc693ce8d5a/LICENSE) | [NOTICE](https://github.com/yaml/go-yaml/blob/f2f9563503f11b7a60da0c532175dcc693ce8d5a/NOTICE).
|
||||
|
||||
[Source](https://github.com/yaml/go-yaml/tree/f2f9563503f11b7a60da0c532175dcc693ce8d5a).
|
||||
|
||||
## jsonschema
|
||||
|
||||
Selected module: `github.com/santhosh-tekuri/jsonschema/v6` at `v6.0.3`.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
License and notices: [Apache 2.0](licenses/Apache-2.0.txt) | [LICENSE](https://github.com/santhosh-tekuri/jsonschema/blob/b0fc661f4939578bc429f408c18202573dbafcc4/LICENSE).
|
||||
|
||||
[Source](https://github.com/santhosh-tekuri/jsonschema/tree/b0fc661f4939578bc429f408c18202573dbafcc4).
|
||||
|
||||
## Go text
|
||||
|
||||
Selected module: `golang.org/x/text` at `v0.14.0` (transitive dependency).
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause.txt) | [LICENSE](https://go.googlesource.com/text/+/6c97a165dd661335ff7bce6104a008558123c353/LICENSE) | [PATENTS](https://go.googlesource.com/text/+/6c97a165dd661335ff7bce6104a008558123c353/PATENTS).
|
||||
|
||||
[Source](https://go.googlesource.com/text/+/6c97a165dd661335ff7bce6104a008558123c353).
|
||||
202
docs/oss/licenses/Apache-2.0.txt
Normal file
202
docs/oss/licenses/Apache-2.0.txt
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
27
docs/oss/licenses/BSD-3-Clause.txt
Normal file
27
docs/oss/licenses/BSD-3-Clause.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
18
docs/oss/licenses/MIT.txt
Normal file
18
docs/oss/licenses/MIT.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
39
docs/party.md
Normal file
39
docs/party.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Party contract
|
||||
|
||||
Contract: `maximumdirect.party.v1`. [Schema](../schemas/party.schema.json).
|
||||
The [validation profile](validation.md) and [compatibility rules](compatibility.md)
|
||||
apply. See the [example](../examples/party.yml).
|
||||
|
||||
| Field | Required | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `schema_version` | Yes | Exactly `maximumdirect.party.v1`. |
|
||||
| `characters` | Yes | Mapping from stable character IDs to roster entries; an empty mapping is valid. |
|
||||
| `characters.<id>.character` | Yes | Character information. |
|
||||
| `character.name` | Yes | Nonempty canonical display name. |
|
||||
| `character.aliases` | No | Alternative names for the same character; omission, null, an empty list, or a list of nonempty strings. |
|
||||
| `character.classes` | No | List of class objects, possibly empty. Each has a nonempty `name` and optional positive integer `level`. |
|
||||
| `characters.<id>.player` | No | Player relationship. When present, an object with a required nonempty `name`. Multiple characters may have the same player. |
|
||||
|
||||
IDs are nonempty strings scoped to this party, independent of display names and
|
||||
application artifact names. They remain stable when a display name changes.
|
||||
Player names are display labels, not globally unique player identifiers.
|
||||
Equal character names and aliases do not establish identity; consumers decide
|
||||
how to handle ambiguity in a particular task. Strings are preserved as authored.
|
||||
|
||||
Every object permits additional fields. Classes are optional domain information
|
||||
for campaigns that use them. Other character attributes may be extensions.
|
||||
Known fields have the documented type even when other fields are present.
|
||||
Optional objects and `classes` accept omission, not null. List order carries no
|
||||
additional contract meaning; mapping order never establishes character order.
|
||||
|
||||
A consumer can derive a party glossary from this roster. It uses character IDs
|
||||
as entry IDs, canonical names and aliases, and its selected domain category.
|
||||
Operators need not maintain a duplicate party vocabulary document.
|
||||
|
||||
## Differences from Narratio's existing party input
|
||||
|
||||
This contract uses a shared marker and `aliases` rather than `alias`. Player and
|
||||
class information is optional. IDs follow domain identity rather than artifact
|
||||
key syntax. Name uniqueness, class requirements, and mapping iteration order are
|
||||
consumer decisions. Narratio's existing `narratio.party.v1` format remains a
|
||||
separate released interface until adoption is implemented.
|
||||
85
docs/release.md
Normal file
85
docs/release.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Release procedure
|
||||
|
||||
This is a source-only schema distribution. The authoritative remote is `origin`
|
||||
at `ssh://git@forge.maximumdirect.net:22222/eric/schemas.git`, branch `main`.
|
||||
Publication requires an explicit release request. Implementing the repository
|
||||
does not publish the initial candidate.
|
||||
|
||||
## Prepare the candidate
|
||||
|
||||
1. Select a fresh Semantic Versioning tag under the [compatibility rules](compatibility.md).
|
||||
2. Update `VERSION`, each schema's raw-tag `$id`, release-specific README examples,
|
||||
and references between schemas to that version. Contract markers change only
|
||||
when their major domain contract changes.
|
||||
3. Write `docs/releases/<version>.md` with the changes, compatibility assessment,
|
||||
and migration instructions where needed. Include links to COPYRIGHT, LICENSE,
|
||||
and ATTRIBUTION at the intended immutable tag. The initial candidate note is
|
||||
[v1.0.0](releases/v1.0.0.md).
|
||||
4. Prepare Go 1.27.4 and `go mod download`. Commit the intended source with a
|
||||
short descriptive message. Review the diff for unintended data or credentials.
|
||||
|
||||
Run `sh scripts/check.sh` on that committed candidate. It performs the same checks
|
||||
as CI, including offline compilation and validation from the unpacked tagged-source
|
||||
archive format. Validation dependencies are prepared separately; tests need no
|
||||
network, consumer applications, provider credentials, or LLM calls.
|
||||
|
||||
## Distribution
|
||||
|
||||
The forge's immutable tagged source archive is the distribution:
|
||||
|
||||
```text
|
||||
https://forge.maximumdirect.net/eric/schemas/archive/v1.0.0.tar.gz
|
||||
```
|
||||
|
||||
It contains the complete schema directory, semantic documentation, examples,
|
||||
license and attribution, release note, and pinned optional Go harness and fixtures.
|
||||
A consumer can bundle the schemas and semantic documents, register each `$id`
|
||||
against its local file, and resolve all references offline. The harness is not a
|
||||
runtime dependency. No binaries or separate registry are published.
|
||||
|
||||
To inspect the candidate distribution locally before publication:
|
||||
|
||||
```sh
|
||||
mkdir -p dist
|
||||
git archive --format=tar.gz --prefix=schemas-v1.0.0/ \
|
||||
--output=dist/schemas-v1.0.0.tar.gz HEAD
|
||||
```
|
||||
|
||||
Individual schema/editor URLs use the raw tag route, for example:
|
||||
|
||||
```text
|
||||
https://forge.maximumdirect.net/eric/schemas/raw/tag/v1.0.0/schemas/glossary.schema.json
|
||||
```
|
||||
|
||||
The forge's raw-commit route was checked against the initial repository revision;
|
||||
the public raw-tag JSON route was checked against a released sibling JSON document.
|
||||
The exact URLs above become available only after this tag is published. Optional
|
||||
post-publication inspection can use `curl --fail` on them and decode the response
|
||||
as JSON, not an HTML forge page. It does not delay source-release completion.
|
||||
|
||||
## Publish when requested
|
||||
|
||||
Start from a clean `main` whose HEAD is the validated candidate. Fetch `origin`
|
||||
and verify that advancing `origin/main` to HEAD is fast-forward. Check that the
|
||||
selected tag is absent locally and on `origin`. Publish only the intended branch
|
||||
and fresh annotated tag. For the initial candidate:
|
||||
|
||||
```sh
|
||||
git fetch origin main --tags
|
||||
git merge-base --is-ancestor origin/main HEAD
|
||||
git status --short
|
||||
git tag --list v1.0.0
|
||||
git ls-remote --tags origin refs/tags/v1.0.0
|
||||
git tag -a v1.0.0 -F docs/releases/v1.0.0.md
|
||||
git push --atomic origin HEAD:refs/heads/main refs/tags/v1.0.0
|
||||
```
|
||||
|
||||
The status and tag checks must be empty before creating the tag. Stop if the
|
||||
branch is not `main`, the candidate changed, the worktree is dirty, the version
|
||||
is already used, or validation failed. Publication completes when the push
|
||||
succeeds; do not wait for CI. The forge supplies the tagged source archive.
|
||||
|
||||
Published tags and contents are immutable. A defect is corrected in a new
|
||||
version. On an ambiguous push result, inspect the exact upstream branch and tag
|
||||
before reporting success or retrying. Preserve already-published tags. Routine
|
||||
releases do not require installed-consumer checks or a new external approval gate.
|
||||
18
docs/releases/v1.0.0.md
Normal file
18
docs/releases/v1.0.0.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Maximum Direct shared schemas v1.0.0
|
||||
|
||||
Initial shared party, campaign, and general glossary contracts, identified by
|
||||
`maximumdirect.party.v1`, `maximumdirect.campaign.v1`, and
|
||||
`maximumdirect.glossary.v1`.
|
||||
|
||||
The distribution includes Draft 2020-12 schemas, semantic documentation,
|
||||
synthetic YAML/JSON examples, compatibility rules, and an optional offline Go
|
||||
validation harness. Objects support extensions; semantic validation checks
|
||||
glossary entry IDs within collections. Glossaries use a versioned envelope and
|
||||
keep task instructions in consumer configuration.
|
||||
|
||||
This is a new independent contract set. Existing Narratio, Audita, Notarius,
|
||||
Scriptorium prompt, and reference catalog formats require separately planned
|
||||
adoption. See [compatibility](../compatibility.md#existing-consumers) for the
|
||||
initial differences. There is no earlier shared release to migrate.
|
||||
|
||||
[COPYRIGHT](https://forge.maximumdirect.net/eric/schemas/src/tag/v1.0.0/COPYRIGHT) | [LICENSE](https://forge.maximumdirect.net/eric/schemas/src/tag/v1.0.0/LICENSE) | [ATTRIBUTION](https://forge.maximumdirect.net/eric/schemas/src/tag/v1.0.0/docs/oss/attribution.md)
|
||||
102
docs/validation.md
Normal file
102
docs/validation.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# 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.
|
||||
|
||||
## Command
|
||||
|
||||
With Go 1.27 or later, run from the selected schema-set checkout or unpacked
|
||||
source archive:
|
||||
|
||||
```sh
|
||||
go mod download
|
||||
go run ./cmd/validate examples/party.yml examples/campaign.yml examples/glossary.yml
|
||||
```
|
||||
|
||||
Dependencies are pinned in `go.mod` and `go.sum`. Once prepared, validation is
|
||||
offline. A built tool can select another unpacked distribution:
|
||||
|
||||
```sh
|
||||
go build -o /tmp/schemas-validate ./cmd/validate
|
||||
/tmp/schemas-validate -root /path/to/schemas-v1.0.0 /path/to/completed-glossary.yml
|
||||
```
|
||||
|
||||
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 or an unusable schema set. 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.
|
||||
|
||||
The harness uses [go-yaml v4](https://github.com/yaml/go-yaml/tree/v4.0.0) for
|
||||
parsing and [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.
|
||||
|
||||
## YAML decoding profile
|
||||
|
||||
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.
|
||||
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
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.
|
||||
|
||||
## Structural and semantic boundaries
|
||||
|
||||
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 immutable release `$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.
|
||||
Keep the complete schema directory from one release together. Configure editors
|
||||
externally to associate document paths with a local schema or its immutable raw
|
||||
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.
|
||||
9
examples/campaign.yml
Normal file
9
examples/campaign.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
schema_version: maximumdirect.campaign.v1
|
||||
id: lantern-coast
|
||||
name: Lantern Coast Expedition
|
||||
description: A synthetic coastal exploration campaign.
|
||||
setting: Lantern Coast
|
||||
system: Sample Fantasy
|
||||
references:
|
||||
party: party.yml
|
||||
glossaries: [glossary.yml]
|
||||
22
examples/glossary.yml
Normal file
22
examples/glossary.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
campaign:
|
||||
entries:
|
||||
- id: lighthouse
|
||||
name: Glass Lantern
|
||||
category: place
|
||||
aliases: [The Lantern]
|
||||
description: A fictional lighthouse at the entrance to the bay.
|
||||
spells:
|
||||
provenance:
|
||||
id: lantern-coast-original
|
||||
ruleset: sample-fantasy
|
||||
title: Synthetic campaign spells
|
||||
version: "1"
|
||||
license: CC0-1.0
|
||||
entries:
|
||||
- id: ember-veil
|
||||
name: Ember Veil
|
||||
category: spell
|
||||
aliases: [Veil of Embers]
|
||||
casting_time: one action
|
||||
15
examples/party.yml
Normal file
15
examples/party.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
schema_version: maximumdirect.party.v1
|
||||
characters:
|
||||
mira:
|
||||
player:
|
||||
name: Rowan
|
||||
character:
|
||||
name: Mira Vale
|
||||
aliases: [Mira, The Lantern]
|
||||
classes:
|
||||
- name: ranger
|
||||
level: 3
|
||||
homeland: Lantern Coast
|
||||
guide-npc:
|
||||
character:
|
||||
name: Tavi
|
||||
16
examples/sports.yml
Normal file
16
examples/sports.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
clubs:
|
||||
sport: association football
|
||||
entries:
|
||||
- id: harbour
|
||||
name: Harbour Wanderers
|
||||
category: club
|
||||
aliases: []
|
||||
plural: null
|
||||
home_ground: Lantern Park
|
||||
venues:
|
||||
entries:
|
||||
- id: harbour
|
||||
name: Lantern Park
|
||||
category: venue
|
||||
12
examples/weather.json
Normal file
12
examples/weather.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"schema_version": "maximumdirect.glossary.v1",
|
||||
"collections": {
|
||||
"measurements": {
|
||||
"unit_system": "metric",
|
||||
"entries": [
|
||||
{"id": "temperature", "name": "Air temperature", "category": "measurement", "aliases": ["Temperature"], "unit": "degree Celsius"},
|
||||
{"id": "precipitation", "name": "Precipitation", "category": "measurement", "aliases": null, "unit": "millimetre"}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
15
examples/weather.yml
Normal file
15
examples/weather.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
measurements:
|
||||
unit_system: metric
|
||||
entries:
|
||||
- id: temperature
|
||||
name: Air temperature
|
||||
category: measurement
|
||||
aliases: [Temperature]
|
||||
unit: degree Celsius
|
||||
- id: precipitation
|
||||
name: Precipitation
|
||||
category: measurement
|
||||
aliases: null
|
||||
unit: millimetre
|
||||
10
go.mod
Normal file
10
go.mod
Normal file
@@ -0,0 +1,10 @@
|
||||
module forge.maximumdirect.net/eric/schemas
|
||||
|
||||
go 1.27.0
|
||||
|
||||
require (
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3
|
||||
go.yaml.in/yaml/v4 v4.0.0
|
||||
)
|
||||
|
||||
require golang.org/x/text v0.14.0 // indirect
|
||||
8
go.sum
Normal file
8
go.sum
Normal file
@@ -0,0 +1,8 @@
|
||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28=
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
||||
go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
|
||||
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
195
internal/validation/decode.go
Normal file
195
internal/validation/decode.go
Normal file
@@ -0,0 +1,195 @@
|
||||
// Package validation supports this repository's contract checks. It is not a
|
||||
// consumer SDK: consumers may use their own conforming YAML and schema tools.
|
||||
package validation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
// Decode uses go-yaml's parser and scalar resolution, adapting its node graph to
|
||||
// the documented JSON data model. Numbers retain their precision as json.Number.
|
||||
func Decode(data []byte) (any, error) {
|
||||
var document yaml.Node
|
||||
if err := yaml.Load(data, &document, yaml.WithUniqueKeys()); err != nil {
|
||||
return nil, fmt.Errorf("decode: %w", err)
|
||||
}
|
||||
d := decoder{active: make(map[*yaml.Node]bool), values: make(map[*yaml.Node]any)}
|
||||
value, err := d.value(&document, "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode: %w", err)
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
type decoder struct {
|
||||
active map[*yaml.Node]bool
|
||||
values map[*yaml.Node]any
|
||||
}
|
||||
|
||||
func (d *decoder) value(n *yaml.Node, path string) (any, error) {
|
||||
if n == nil {
|
||||
return nil, fmt.Errorf("%s: unresolved alias", pointer(path))
|
||||
}
|
||||
if d.active[n] {
|
||||
return nil, nodeError(n, path, "cyclic alias")
|
||||
}
|
||||
if value, found := d.values[n]; found {
|
||||
return value, nil
|
||||
}
|
||||
d.active[n] = true
|
||||
defer delete(d.active, n)
|
||||
var value any
|
||||
var err error
|
||||
switch n.Kind {
|
||||
case yaml.DocumentNode:
|
||||
if len(n.Content) != 1 {
|
||||
return nil, nodeError(n, path, "expected one document")
|
||||
}
|
||||
value, err = d.value(n.Content[0], path)
|
||||
case yaml.AliasNode:
|
||||
value, err = d.value(n.Alias, path)
|
||||
case yaml.MappingNode:
|
||||
if n.ShortTag() != "!!map" {
|
||||
return nil, nodeError(n, path, "unsupported mapping tag %q", n.Tag)
|
||||
}
|
||||
mapping := make(map[string]any, len(n.Content)/2)
|
||||
for i := 0; i < len(n.Content); i += 2 {
|
||||
keyValue, keyErr := d.value(n.Content[i], path)
|
||||
if keyErr != nil {
|
||||
return nil, keyErr
|
||||
}
|
||||
key, ok := keyValue.(string)
|
||||
if !ok {
|
||||
return nil, nodeError(n.Content[i], path, "mapping key must be a string")
|
||||
}
|
||||
childPath := path + "/" + escape(key)
|
||||
if _, exists := mapping[key]; exists {
|
||||
return nil, nodeError(n.Content[i], childPath, "duplicate mapping key %q", key)
|
||||
}
|
||||
mapping[key], err = d.value(n.Content[i+1], childPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
value = mapping
|
||||
case yaml.SequenceNode:
|
||||
if n.ShortTag() != "!!seq" {
|
||||
return nil, nodeError(n, path, "unsupported sequence tag %q", n.Tag)
|
||||
}
|
||||
sequence := make([]any, len(n.Content))
|
||||
for i, child := range n.Content {
|
||||
sequence[i], err = d.value(child, fmt.Sprintf("%s/%d", path, i))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
value = sequence
|
||||
case yaml.ScalarNode:
|
||||
value, err = scalar(n)
|
||||
if err != nil {
|
||||
return nil, nodeError(n, path, "%v", err)
|
||||
}
|
||||
default:
|
||||
return nil, nodeError(n, path, "expected a document value")
|
||||
}
|
||||
if err == nil {
|
||||
d.values[n] = value
|
||||
}
|
||||
return value, err
|
||||
}
|
||||
|
||||
func scalar(n *yaml.Node) (any, error) {
|
||||
switch n.ShortTag() {
|
||||
case "!!str":
|
||||
// go-yaml resolves decimal numbers outside machine-float range as
|
||||
// strings. Plain JSON numbers still retain numeric meaning in this
|
||||
// profile, including when the source serialization is JSON.
|
||||
if n.Style == 0 {
|
||||
if number, ok := jsonNumber(n.Value); ok {
|
||||
return number, nil
|
||||
}
|
||||
}
|
||||
return n.Value, nil
|
||||
case "!!timestamp":
|
||||
// Date-like scalars are text in the shared data model, not time.Time.
|
||||
return n.Value, nil
|
||||
case "!!bool", "!!null":
|
||||
var value any
|
||||
err := n.Decode(&value)
|
||||
return value, err
|
||||
case "!!int":
|
||||
text := strings.ReplaceAll(n.Value, "_", "")
|
||||
integer, ok := new(big.Int).SetString(text, 0)
|
||||
if !ok {
|
||||
integer, ok = new(big.Int).SetString(text, 10)
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid integer %q", n.Value)
|
||||
}
|
||||
return json.Number(integer.String()), nil
|
||||
case "!!float":
|
||||
// Normalize YAML's leading '+', '.5', and '5.' spellings, retaining the
|
||||
// decimal digits instead of converting through float64.
|
||||
text := strings.TrimPrefix(strings.ReplaceAll(n.Value, "_", ""), "+")
|
||||
mantissa, exponent, hasExponent := strings.Cut(strings.ToLower(text), "e")
|
||||
sign := ""
|
||||
if strings.HasPrefix(mantissa, "-") {
|
||||
sign, mantissa = "-", strings.TrimPrefix(mantissa, "-")
|
||||
}
|
||||
whole, fraction, hasPoint := strings.Cut(mantissa, ".")
|
||||
whole = strings.TrimLeft(whole, "0")
|
||||
if whole == "" {
|
||||
whole = "0"
|
||||
}
|
||||
text = sign + whole
|
||||
if hasPoint {
|
||||
if fraction == "" {
|
||||
fraction = "0"
|
||||
}
|
||||
text += "." + fraction
|
||||
}
|
||||
if hasExponent {
|
||||
text += "e" + exponent
|
||||
}
|
||||
if number, ok := jsonNumber(text); ok {
|
||||
return number, nil
|
||||
}
|
||||
return nil, fmt.Errorf("number %q is not a finite JSON number", n.Value)
|
||||
default:
|
||||
return nil, fmt.Errorf("tag %q has no shared JSON representation", n.Tag)
|
||||
}
|
||||
}
|
||||
|
||||
func jsonNumber(text string) (json.Number, bool) {
|
||||
if !json.Valid([]byte(text)) {
|
||||
return "", false
|
||||
}
|
||||
var value any
|
||||
decoder := json.NewDecoder(strings.NewReader(text))
|
||||
decoder.UseNumber()
|
||||
if err := decoder.Decode(&value); err != nil {
|
||||
return "", false
|
||||
}
|
||||
number, ok := value.(json.Number)
|
||||
return number, ok
|
||||
}
|
||||
|
||||
func nodeError(n *yaml.Node, path, format string, args ...any) error {
|
||||
return fmt.Errorf("%s (line %d, column %d): %s", pointer(path), n.Line, n.Column, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func pointer(path string) string {
|
||||
if path == "" {
|
||||
return "/"
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func escape(value string) string {
|
||||
return strings.ReplaceAll(strings.ReplaceAll(value, "~", "~0"), "/", "~1")
|
||||
}
|
||||
67
internal/validation/documentation_test.go
Normal file
67
internal/validation/documentation_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// This deliberately checks local Markdown destinations, not external services.
|
||||
// It also runs unchanged from an unpacked source archive.
|
||||
func TestDistributionDocuments(t *testing.T) {
|
||||
root := os.DirFS("../..")
|
||||
for _, required := range []string{
|
||||
"README.md", "AGENTS.md", "LICENSE", "COPYRIGHT", "VERSION", "go.mod", "go.sum",
|
||||
"docs/party.md", "docs/campaign.md", "docs/glossary.md", "docs/validation.md",
|
||||
"docs/compatibility.md", "docs/development.md", "docs/release.md", "docs/inventory.md",
|
||||
"docs/oss/attribution.md", "scripts/check.sh", ".woodpecker.yml",
|
||||
} {
|
||||
if _, err := fs.Stat(root, required); err != nil {
|
||||
t.Errorf("required distribution content %s: %v", required, err)
|
||||
}
|
||||
}
|
||||
version, err := fs.ReadFile(root, "VERSION")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := fs.Stat(root, "docs/releases/"+strings.TrimSpace(string(version))+".md"); err != nil {
|
||||
t.Errorf("version-matched release note: %v", err)
|
||||
}
|
||||
link := regexp.MustCompile(`\[[^\]]*\]\(([^)]+)\)`)
|
||||
err = fs.WalkDir(root, ".", func(file string, entry fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if entry.IsDir() {
|
||||
if entry.Name() == ".git" || entry.Name() == "dist" {
|
||||
return fs.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if filepath.Ext(file) != ".md" {
|
||||
return nil
|
||||
}
|
||||
data, err := fs.ReadFile(root, file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, match := range link.FindAllSubmatch(data, -1) {
|
||||
destination := string(match[1])
|
||||
if strings.Contains(destination, "://") || strings.HasPrefix(destination, "#") {
|
||||
continue
|
||||
}
|
||||
destination, _, _ = strings.Cut(destination, "#")
|
||||
if _, err := fs.Stat(root, path.Join(path.Dir(file), destination)); err != nil {
|
||||
t.Errorf("%s links to missing %s: %v", file, destination, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
118
internal/validation/validate.go
Normal file
118
internal/validation/validate.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/santhosh-tekuri/jsonschema/v6"
|
||||
)
|
||||
|
||||
const schemaBase = "https://forge.maximumdirect.net/eric/schemas/raw/tag/"
|
||||
|
||||
var contractNames = []string{"campaign", "glossary", "party"}
|
||||
|
||||
// Set is a compiled, offline schema set loaded from an unpacked distribution.
|
||||
type Set struct {
|
||||
schemas map[string]*jsonschema.Schema
|
||||
}
|
||||
|
||||
// Load compiles every contract, including meta-schema validation, using only
|
||||
// locally registered resources and the library's built-in dialect definitions.
|
||||
func Load(root fs.FS) (*Set, error) {
|
||||
version, err := fs.ReadFile(root, "VERSION")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read VERSION: %w", err)
|
||||
}
|
||||
compiler := jsonschema.NewCompiler()
|
||||
compiler.DefaultDraft(jsonschema.Draft2020)
|
||||
compiler.UseLoader(offlineLoader{})
|
||||
ids := make(map[string]string)
|
||||
for _, name := range contractNames {
|
||||
file := "schemas/" + name + ".schema.json"
|
||||
data, err := fs.ReadFile(root, file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", file, err)
|
||||
}
|
||||
if !json.Valid(data) {
|
||||
return nil, fmt.Errorf("%s: expected JSON syntax", file)
|
||||
}
|
||||
value, err := Decode(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", file, err)
|
||||
}
|
||||
doc, ok := value.(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%s: expected a schema object", file)
|
||||
}
|
||||
id := schemaBase + strings.TrimSpace(string(version)) + "/" + file
|
||||
if doc["$schema"] != "https://json-schema.org/draft/2020-12/schema" || doc["$id"] != id {
|
||||
return nil, fmt.Errorf("%s: expected Draft 2020-12 and $id %q", file, id)
|
||||
}
|
||||
if err := compiler.AddResource(id, value); err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", file, err)
|
||||
}
|
||||
ids[name] = id
|
||||
}
|
||||
set := &Set{schemas: make(map[string]*jsonschema.Schema)}
|
||||
for _, name := range contractNames {
|
||||
schema, err := compiler.Compile(ids[name])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("compile %s: %w", name, err)
|
||||
}
|
||||
set.schemas["maximumdirect."+name+".v1"] = schema
|
||||
}
|
||||
return set, nil
|
||||
}
|
||||
|
||||
type offlineLoader struct{}
|
||||
|
||||
func (offlineLoader) Load(url string) (any, error) {
|
||||
return nil, fmt.Errorf("schema resource %q is absent from the local distribution; network loading is disabled", url)
|
||||
}
|
||||
|
||||
// Validate checks structure, then the selected semantic rules. It does not
|
||||
// resolve imports or references, populate defaults, or mutate the input.
|
||||
func (s *Set) Validate(value any) error {
|
||||
doc, ok := value.(map[string]any)
|
||||
if !ok {
|
||||
return fmt.Errorf("structure: /: expected a document object")
|
||||
}
|
||||
version, ok := doc["schema_version"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("structure: /schema_version: expected a contract identifier string")
|
||||
}
|
||||
schema := s.schemas[version]
|
||||
if schema == nil {
|
||||
return fmt.Errorf("structure: /schema_version: unsupported contract %q", version)
|
||||
}
|
||||
if err := schema.Validate(value); err != nil {
|
||||
return fmt.Errorf("structure: %w", err)
|
||||
}
|
||||
if version == "maximumdirect.glossary.v1" {
|
||||
return uniqueGlossaryIDs(doc["collections"].(map[string]any))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func uniqueGlossaryIDs(collections map[string]any) error {
|
||||
names := make([]string, 0, len(collections))
|
||||
for name := range collections {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
entries := collections[name].(map[string]any)["entries"].([]any)
|
||||
seen := make(map[string]int, len(entries))
|
||||
for i, entry := range entries {
|
||||
id := entry.(map[string]any)["id"].(string)
|
||||
if previous, exists := seen[id]; exists {
|
||||
return fmt.Errorf("semantic: /collections/%s/entries/%d/id: duplicate ID %q (first at entry %d)", escape(name), i, id, previous)
|
||||
}
|
||||
seen[id] = i
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
283
internal/validation/validation_test.go
Normal file
283
internal/validation/validation_test.go
Normal file
@@ -0,0 +1,283 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
)
|
||||
|
||||
func loadSet(t *testing.T) *Set {
|
||||
t.Helper()
|
||||
set, err := Load(os.DirFS("../.."))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
func TestDocuments(t *testing.T) {
|
||||
set := loadSet(t)
|
||||
for _, directory := range []string{"examples", "tests/valid", "tests/invalid"} {
|
||||
err := filepath.WalkDir(filepath.Join("../..", directory), func(path string, entry fs.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
return walkErr
|
||||
}
|
||||
if entry.IsDir() {
|
||||
return nil
|
||||
}
|
||||
t.Run(filepath.ToSlash(path), func(t *testing.T) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
value, err := Decode(data)
|
||||
var before []byte
|
||||
if err == nil {
|
||||
before, err = json.Marshal(value)
|
||||
}
|
||||
if err == nil {
|
||||
err = set.Validate(value)
|
||||
}
|
||||
if directory == "tests/invalid" {
|
||||
phase, _, _ := strings.Cut(entry.Name(), "-")
|
||||
if err == nil || !strings.HasPrefix(err.Error(), phase+":") {
|
||||
t.Fatalf("want %s failure, got %v", phase, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
after, err := json.Marshal(value)
|
||||
if err != nil || string(before) != string(after) {
|
||||
t.Fatalf("validation mutated value: %s -> %s, %v", before, after, err)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefinedFieldShapes(t *testing.T) {
|
||||
set := loadSet(t)
|
||||
tests := []struct {
|
||||
name string
|
||||
body string
|
||||
valid bool
|
||||
}{
|
||||
{"collection null", `collections: {weather: null}`, false},
|
||||
{"entries omitted", `collections: {weather: {description: context}}`, false},
|
||||
{"entries null", `collections: {weather: {entries: null}}`, false},
|
||||
{"entries empty", `collections: {weather: {entries: []}}`, true},
|
||||
{"aliases omitted", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed}]}}`, true},
|
||||
{"aliases null", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, aliases: null}]}}`, true},
|
||||
{"aliases empty", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, aliases: []}]}}`, true},
|
||||
{"aliases populated", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, aliases: [Breeze]}]}}`, true},
|
||||
{"aliases invalid item", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, aliases: [1]}]}}`, false},
|
||||
{"empty ID", `collections: {weather: {entries: [{id: "", name: Wind, category: speed}]}}`, false},
|
||||
{"category required", `collections: {weather: {entries: [{id: wind, name: Wind}]}}`, false},
|
||||
{"empty collection name", `collections: {"": {entries: []}}`, false},
|
||||
{"provenance empty", `collections: {weather: {entries: [], provenance: {}}}`, true},
|
||||
{"provenance absent metadata", `collections: {weather: {entries: [], provenance: {version: "", url: "", license: ""}}}`, true},
|
||||
{"provenance extension", `collections: {weather: {entries: [], provenance: {title: Sample, source_id: 2}}}`, true},
|
||||
{"provenance wrong known field", `collections: {weather: {entries: [], provenance: {ruleset: []}}}`, false},
|
||||
{"unknown fields have no instruction semantics", `collections: {weather: {entries: [], instruction: {arbitrary: data}}}`, true},
|
||||
{"null plural", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, plural: null}]}}`, true},
|
||||
{"empty plural", `collections: {weather: {entries: [{id: wind, name: Wind, category: speed, plural: ""}]}}`, false},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
value, err := Decode([]byte("schema_version: maximumdirect.glossary.v1\n" + test.body))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := set.Validate(value); (err == nil) != test.valid {
|
||||
t.Fatalf("valid=%v, error=%v", test.valid, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, test := range []struct {
|
||||
body string
|
||||
valid bool
|
||||
}{
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: null", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {}}}", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {name: Mira}, player: {}}}", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {name: Mira, classes: null}}}", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {name: Mira, classes: [{name: scout, level: 0}]}}}", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {name: Mira, classes: [{name: scout, level: 1.5}]}}}", false},
|
||||
{"schema_version: maximumdirect.party.v1\ncharacters: {mira: {character: {name: Mira, classes: [{name: scout, level: 1.0000000000000000000001}]}}}", false},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: example\nreferences: {}", true},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: example\nreferences: {glossaries: []}", true},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: example\nreferences: {party: null}", false},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: example\nreferences: {glossaries: [false]}", false},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: example\nreferences: null", false},
|
||||
{"schema_version: maximumdirect.campaign.v1\nid: null", false},
|
||||
{"schema_version: maximumdirect.campaign.v1\nname: Example", false},
|
||||
} {
|
||||
t.Run(test.body, func(t *testing.T) {
|
||||
value, err := Decode([]byte(test.body))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := set.Validate(value); (err == nil) != test.valid {
|
||||
t.Fatalf("valid=%v, error=%v", test.valid, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeProfile(t *testing.T) {
|
||||
for _, input := range []string{
|
||||
"a: 1\na: 2", "a: {b: 1, b: 2}", `{"a":1,"a":2}`,
|
||||
"---\na: 1\n---\na: 2", "1: value", "true: value", "? [a, b]\n: value",
|
||||
"a: !custom value", "a: !!binary Zm9v", "a: !!set {x: null}", "a: !!omap [{x: 1}]",
|
||||
"a: &cycle [*cycle]", "a: *unknown", "a: .inf", "a: -.Inf", "a: .NaN",
|
||||
"a: !!float true", "a: !!int false", "a: [broken", "a: &x {b: 1}\nc: {<<: *x}",
|
||||
} {
|
||||
t.Run(input, func(t *testing.T) {
|
||||
if _, err := Decode([]byte(input)); err == nil || !strings.HasPrefix(err.Error(), "decode:") {
|
||||
t.Fatalf("expected decoding failure, got %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
value, err := Decode([]byte(`
|
||||
date: 2026-11-28
|
||||
timestamp: 2026-11-28T12:30:00Z
|
||||
affirmative: yes
|
||||
switch: on
|
||||
enabled: true
|
||||
missing: ~
|
||||
quoted: "true"
|
||||
quoted_number: "1e500"
|
||||
tagged_string: !!str 1e500
|
||||
"<<": literal extension
|
||||
original: &items [one, two]
|
||||
copy: *items
|
||||
`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := map[string]any{
|
||||
"date": "2026-11-28", "timestamp": "2026-11-28T12:30:00Z",
|
||||
"affirmative": "yes", "switch": "on", "enabled": true, "missing": nil, "quoted": "true",
|
||||
"quoted_number": "1e500", "tagged_string": "1e500",
|
||||
"<<": "literal extension", "original": []any{"one", "two"}, "copy": []any{"one", "two"},
|
||||
}
|
||||
if !reflect.DeepEqual(value, want) {
|
||||
t.Fatalf("got %#v, want %#v", value, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNumericPrecision(t *testing.T) {
|
||||
for input, want := range map[string]string{
|
||||
"1234567890123456789012345678901234567890": "1234567890123456789012345678901234567890",
|
||||
"0.123456789012345678901234567890": "0.123456789012345678901234567890",
|
||||
".5": "0.5", "5.": "5.0", "+.5": "0.5", "-0.5": "-0.5", "1e500": "1e500",
|
||||
"0x10": "16", "0o10": "8", "0b10": "2", "010": "8", "1_000": "1000",
|
||||
} {
|
||||
t.Run(input, func(t *testing.T) {
|
||||
value, err := Decode([]byte("measurement: " + input))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
number, ok := value.(map[string]any)["measurement"].(json.Number)
|
||||
if !ok || number.String() != want {
|
||||
t.Fatalf("want exact JSON number %q, got %#v", want, value)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestYAMLJSONEquivalence(t *testing.T) {
|
||||
yamlBytes, err := os.ReadFile("../../examples/weather.yml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
jsonBytes, err := os.ReadFile("../../examples/weather.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
yamlValue, err := Decode(yamlBytes)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
jsonValue, err := Decode(jsonBytes)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(yamlValue, jsonValue) {
|
||||
t.Fatal("YAML and JSON represent different domain data")
|
||||
}
|
||||
data, err := json.Marshal(yamlValue)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
roundTrip, err := Decode(data)
|
||||
if err != nil || !reflect.DeepEqual(yamlValue, roundTrip) {
|
||||
t.Fatalf("JSON conversion changed data: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistributionAndOfflineResolution(t *testing.T) {
|
||||
// Only the distributed schemas and version are needed; no checkout or HTTP
|
||||
// resource loader is available through this in-memory filesystem.
|
||||
files := fstest.MapFS{}
|
||||
for _, file := range []string{"VERSION", "schemas/campaign.schema.json", "schemas/glossary.schema.json", "schemas/party.schema.json"} {
|
||||
data, err := os.ReadFile(filepath.Join("../..", file))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
files[file] = &fstest.MapFile{Data: data}
|
||||
}
|
||||
set, err := Load(files)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
value, err := Decode([]byte("schema_version: maximumdirect.campaign.v1\nid: offline"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := set.Validate(value); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
original := files["schemas/party.schema.json"].Data
|
||||
t.Run("shared reference in the same release", func(t *testing.T) {
|
||||
version := strings.TrimSpace(string(files["VERSION"].Data))
|
||||
reference := `"name": {"$ref": "` + schemaBase + version + `/schemas/glossary.schema.json#/$defs/text"}`
|
||||
files["schemas/party.schema.json"] = &fstest.MapFile{Data: []byte(strings.Replace(string(original), `"name": {"$ref": "#/$defs/text"}`, reference, 1))}
|
||||
if _, err := Load(files); err != nil {
|
||||
t.Fatalf("bundled cross-schema reference failed offline: %v", err)
|
||||
}
|
||||
})
|
||||
for name, replacement := range map[string]string{
|
||||
"missing reference": `"name": {"$ref": "https://example.invalid/missing.json"}`,
|
||||
"bad schema keyword": `"name": {"type": 123}`,
|
||||
"mixed release": `"name": {"$ref": "https://forge.maximumdirect.net/eric/schemas/raw/tag/v0.0.0/schemas/glossary.schema.json"}`,
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
files["schemas/party.schema.json"] = &fstest.MapFile{Data: []byte(strings.Replace(string(original), `"name": {"$ref": "#/$defs/text"}`, replacement, 1))}
|
||||
if _, err := Load(files); err == nil {
|
||||
t.Fatal("incomplete or malformed distribution compiled")
|
||||
}
|
||||
})
|
||||
}
|
||||
files["schemas/party.schema.json"] = &fstest.MapFile{Data: original}
|
||||
files["schemas/party.schema.json"] = &fstest.MapFile{Data: []byte("title: not JSON")}
|
||||
if _, err := Load(files); err == nil {
|
||||
t.Fatal("a schema file accepted non-JSON syntax")
|
||||
}
|
||||
files["schemas/party.schema.json"] = &fstest.MapFile{Data: original}
|
||||
files["VERSION"] = &fstest.MapFile{Data: []byte("v9.0.0\n")}
|
||||
if _, err := Load(files); err == nil {
|
||||
t.Fatal("schema IDs did not match the distribution's version")
|
||||
}
|
||||
}
|
||||
23
schemas/campaign.schema.json
Normal file
23
schemas/campaign.schema.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://forge.maximumdirect.net/eric/schemas/raw/tag/v1.0.0/schemas/campaign.schema.json",
|
||||
"title": "Maximum Direct campaign v1",
|
||||
"type": "object",
|
||||
"required": ["schema_version", "id"],
|
||||
"properties": {
|
||||
"schema_version": {"const": "maximumdirect.campaign.v1"},
|
||||
"id": {"$ref": "#/$defs/text"},
|
||||
"name": {"$ref": "#/$defs/text"},
|
||||
"description": {"type": "string"},
|
||||
"setting": {"$ref": "#/$defs/text"},
|
||||
"system": {"$ref": "#/$defs/text"},
|
||||
"references": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"party": {"$ref": "#/$defs/text"},
|
||||
"glossaries": {"type": "array", "items": {"$ref": "#/$defs/text"}}
|
||||
}
|
||||
}
|
||||
},
|
||||
"$defs": {"text": {"type": "string", "minLength": 1}}
|
||||
}
|
||||
53
schemas/glossary.schema.json
Normal file
53
schemas/glossary.schema.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://forge.maximumdirect.net/eric/schemas/raw/tag/v1.0.0/schemas/glossary.schema.json",
|
||||
"$comment": "Adapted from narratio-reference-catalog a1a87edafd59a1de545a1c0b4efe5feeb80348e0 under CC0-1.0; envelope, extensions, provenance, and defined fields changed.",
|
||||
"title": "Maximum Direct glossary v1",
|
||||
"type": "object",
|
||||
"required": ["schema_version", "collections"],
|
||||
"properties": {
|
||||
"schema_version": {"const": "maximumdirect.glossary.v1"},
|
||||
"collections": {
|
||||
"type": "object",
|
||||
"propertyNames": {"minLength": 1},
|
||||
"additionalProperties": {"$ref": "#/$defs/collection"}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"text": {"type": "string", "minLength": 1},
|
||||
"aliases": {"type": ["array", "null"], "items": {"$ref": "#/$defs/text"}},
|
||||
"entry": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "category"],
|
||||
"properties": {
|
||||
"id": {"$ref": "#/$defs/text"},
|
||||
"name": {"$ref": "#/$defs/text"},
|
||||
"category": {"$ref": "#/$defs/text"},
|
||||
"description": {"type": "string"},
|
||||
"aliases": {"$ref": "#/$defs/aliases"},
|
||||
"plural": {"type": ["string", "null"], "minLength": 1}
|
||||
}
|
||||
},
|
||||
"provenance": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {"$ref": "#/$defs/text"},
|
||||
"ruleset": {"$ref": "#/$defs/text"},
|
||||
"title": {"$ref": "#/$defs/text"},
|
||||
"version": {"type": "string"},
|
||||
"url": {"type": "string"},
|
||||
"license": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"partialCollection": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entries": {"type": "array", "items": {"$ref": "#/$defs/entry"}},
|
||||
"provenance": {"$ref": "#/$defs/provenance"}
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"allOf": [{"$ref": "#/$defs/partialCollection"}, {"required": ["entries"]}]
|
||||
}
|
||||
}
|
||||
}
|
||||
51
schemas/party.schema.json
Normal file
51
schemas/party.schema.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://forge.maximumdirect.net/eric/schemas/raw/tag/v1.0.0/schemas/party.schema.json",
|
||||
"title": "Maximum Direct party v1",
|
||||
"type": "object",
|
||||
"required": ["schema_version", "characters"],
|
||||
"properties": {
|
||||
"schema_version": {"const": "maximumdirect.party.v1"},
|
||||
"characters": {
|
||||
"type": "object",
|
||||
"propertyNames": {"minLength": 1},
|
||||
"additionalProperties": {"$ref": "#/$defs/rosterEntry"}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"text": {"type": "string", "minLength": 1},
|
||||
"rosterEntry": {
|
||||
"type": "object",
|
||||
"required": ["character"],
|
||||
"properties": {
|
||||
"player": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {"name": {"$ref": "#/$defs/text"}}
|
||||
},
|
||||
"character": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {"$ref": "#/$defs/text"},
|
||||
"aliases": {
|
||||
"type": ["array", "null"],
|
||||
"items": {"$ref": "#/$defs/text"}
|
||||
},
|
||||
"classes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["name"],
|
||||
"properties": {
|
||||
"name": {"$ref": "#/$defs/text"},
|
||||
"level": {"type": "integer", "minimum": 1}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
scripts/check.sh
Normal file
14
scripts/check.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
go test ./...
|
||||
go vet ./...
|
||||
|
||||
# Inspect the actual committed source archive, independent of the checkout.
|
||||
release_dir=$(mktemp -d)
|
||||
trap 'rm -r -- "$release_dir"' EXIT HUP INT TERM
|
||||
git archive --format=tar --output="$release_dir/source.tar" HEAD
|
||||
mkdir "$release_dir/source"
|
||||
tar -xf "$release_dir/source.tar" -C "$release_dir/source"
|
||||
cd "$release_dir/source"
|
||||
go test ./...
|
||||
5
tests/invalid/decode-complex-key.yml
Normal file
5
tests/invalid/decode-complex-key.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
schema_version: maximumdirect.campaign.v1
|
||||
id: example
|
||||
context:
|
||||
? [one, two]
|
||||
: value
|
||||
4
tests/invalid/decode-cycle.yml
Normal file
4
tests/invalid/decode-cycle.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
schema_version: maximumdirect.campaign.v1
|
||||
id: example
|
||||
context: &context
|
||||
recurse: *context
|
||||
4
tests/invalid/decode-duplicate-key.yml
Normal file
4
tests/invalid/decode-duplicate-key.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
schema_version: maximumdirect.party.v1
|
||||
characters:
|
||||
mira: {character: {name: Mira}}
|
||||
mira: {character: {name: Another Mira}}
|
||||
3
tests/invalid/decode-nonfinite.yml
Normal file
3
tests/invalid/decode-nonfinite.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
schema_version: maximumdirect.campaign.v1
|
||||
id: example
|
||||
measurement: .inf
|
||||
6
tests/invalid/semantic-duplicate-id.yml
Normal file
6
tests/invalid/semantic-duplicate-id.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
weather:
|
||||
entries:
|
||||
- {id: wind, name: Wind, category: speed}
|
||||
- {id: wind, name: Another wind, category: speed}
|
||||
5
tests/invalid/structure-invalid-known-field.yml
Normal file
5
tests/invalid/structure-invalid-known-field.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
weather:
|
||||
unit: metric
|
||||
entries: [{id: wind, name: Wind, category: speed, aliases: 2}]
|
||||
2
tests/invalid/structure-legacy-envelope.yml
Normal file
2
tests/invalid/structure-legacy-envelope.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
weather:
|
||||
entries: [{id: wind, name: Wind, category: speed}]
|
||||
4
tests/invalid/structure-missing-name.yml
Normal file
4
tests/invalid/structure-missing-name.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
weather:
|
||||
entries: [{id: wind, category: measurement, unit: metre per second}]
|
||||
4
tests/invalid/structure-null-description.yml
Normal file
4
tests/invalid/structure-null-description.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections:
|
||||
weather:
|
||||
entries: [{id: wind, name: Wind, category: speed, description: null}]
|
||||
2
tests/invalid/structure-wrong-marker.yml
Normal file
2
tests/invalid/structure-wrong-marker.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
schema_version: maximumdirect.glossary.v2
|
||||
collections: {}
|
||||
30
tests/valid/v1-extensions.yml
Normal file
30
tests/valid/v1-extensions.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
recorded_at: 2026-11-28
|
||||
source_context: &context
|
||||
synthetic: true
|
||||
stations: [North, South]
|
||||
calibration: 0.0000000000000000000000000000001
|
||||
context_copy: *context
|
||||
collections:
|
||||
measurements:
|
||||
metadata: {note: An extension on a collection}
|
||||
entries:
|
||||
- id: wind
|
||||
name: Wind speed
|
||||
category: speed
|
||||
aliases: null
|
||||
plural: null
|
||||
unit: metre per second
|
||||
- id: gust
|
||||
name: Gust speed
|
||||
category: speed
|
||||
aliases: []
|
||||
description: ""
|
||||
- id: direction
|
||||
name: Wind direction
|
||||
category: bearing
|
||||
another_collection:
|
||||
entries:
|
||||
- id: wind
|
||||
name: Wind
|
||||
category: phenomenon
|
||||
2
tests/valid/v1-minimal-campaign.yml
Normal file
2
tests/valid/v1-minimal-campaign.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
schema_version: maximumdirect.campaign.v1
|
||||
id: sample
|
||||
2
tests/valid/v1-minimal-glossary.yml
Normal file
2
tests/valid/v1-minimal-glossary.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
schema_version: maximumdirect.glossary.v1
|
||||
collections: {}
|
||||
2
tests/valid/v1-minimal-party.yml
Normal file
2
tests/valid/v1-minimal-party.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
schema_version: maximumdirect.party.v1
|
||||
characters: {}
|
||||
14
tests/valid/v1-party-extensions.yml
Normal file
14
tests/valid/v1-party-extensions.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
schema_version: maximumdirect.party.v1
|
||||
description: A party without universal class requirements.
|
||||
characters:
|
||||
"character:one":
|
||||
player: {name: Rowan, pronouns: they/them}
|
||||
character:
|
||||
name: Mira
|
||||
aliases: null
|
||||
classes: []
|
||||
species: human
|
||||
role: scout
|
||||
"character:two":
|
||||
player: {name: Rowan}
|
||||
character: {name: Mira, aliases: []}
|
||||
Reference in New Issue
Block a user