Files
notarius/docs/roadmap/shared-domain-schemas.md

367 lines
22 KiB
Markdown

# Shared Domain Schema Adoption
## Purpose
Adopt the Maximum Direct shared domain contracts for D&D reference inputs so
operators can maintain one roster and one set of glossary documents across
Narratio, Notarius, Audita, and relevant Scriptorium prompts. In particular, the
same authored spell glossary should support transcript correction and Notarius
spell recognition without an independently maintained Notarius overlay.
This is Notarius's feature roadmap responding to the
[Narratio feature request](narratio-shared-schemas-feature-request.md). It defines
the target state and required work; a subsequent implementation plan will divide
that work into execution stages. Collection selection belongs on reference
bindings; the text-input decision at the end remains pending review.
## Current Baseline
Reviewed against Notarius commit
`bff0fb44e86e024f1cb5f0987b2ba583c225a53b`.
- The [reference interface](../config.md#references-and-ordered-handoffs) supports
configured external files, CLI overrides, and ordered generated artifacts.
External bindings currently select a path, not a glossary collection.
- D&D shared prompt inputs treat `party`, `players`, and `glossary` as text.
Some modules also accept the existing `roster` alias. These inputs do not
currently establish conformance to the proposed shared contracts.
- [Spell-catalog overlays](../integrations/dnd-spell-catalog-overlays.md) use the
private `notarius.dnd.spell-catalog-overlay.v1` JSON format. The reader rejects
unknown fields, requires catalog/ruleset/source information, and rejects null
aliases. That reader cannot consume a shared glossary unchanged.
- `internal/modules/dnd/spells/catalog` constructs effective vocabulary from
the embedded D&D 5e 2014 SRD catalog and an optional overlay. Extraction,
normalization, and catalog validation use that resolver. Constructors already
surface determinable spell-catalog problems during pipeline preparation.
- Explicit [preflight](../cli.md#preflight) and run share reference
materialization and module construction through
`internal/cli/pipeline_invocation.go`. Preflight also parses the supplied
source and checks destinations and native provider readiness; it does not run
the extraction pipeline.
- The maintained [complete example](../../examples/dnd-complete/config.yml)
supplies text party/glossary references and a separately authored spell overlay.
The [D&D subprocess guide](../consumers/dnd-pipeline.md) reflects those inputs.
- The repository already imports `go.yaml.in/yaml/v4` and
`github.com/santhosh-tekuri/jsonschema/v6`. No new parser or schema-engine
dependency is expected solely for this adoption.
## Selected Upstream Baseline
Use the shared schemas source distribution
[`2026.11.0`](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0),
whose published remote tag resolves to commit
`1b8430bdcbf04eb98c8d45c98a1cb986a9e6d477`. Its
[catalog](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0/catalog.json)
contains the following independently versioned contracts:
| Contract | Version | Document identifier | Adoption scope |
| --- | --- | --- | --- |
| General glossary | `0.1.0` | `maximumdirect.glossary.v1` | Structured vocabulary and spell recognition. |
| RPG party | `0.1.0` | `maximumdirect.rpg.party.v1` | Structured character roster and player relationships. |
| RPG campaign | `0.1.0` | `maximumdirect.rpg.campaign.v1` | Reviewed; no new structured consumer in this work set. |
Adopt the glossary and party schemas together with their adjacent semantics and
the selected distribution's
[validation profile](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0/docs/validation.md)
and
[compatibility guidance](https://forge.maximumdirect.net/eric/schemas/src/tag/2026.11.0/docs/compatibility.md).
Repository CalVer, individual schema SemVer, document generation markers, and
canonical schema IDs remain distinct. Record exact selected versions and source
revision; do not discover support from mutable `main` or live URL availability.
## Target End State
### Operator And Caller Workflow
Operators can supply completed shared glossary and party documents as YAML or
equivalent JSON through the established reference interface. A glossary file may
contain several collections; each consuming task uses a documented selection.
Narratio may serialize a shared document or save a selected shared view, but
does not translate entries into a Notarius-specific spell format.
The same glossary file can supply spell recognition and general campaign
vocabulary through separate bindings when useful. Repeating a file binding is
not a requirement to author duplicate data. A spell-only document is sufficient
for a spell-only use; `party`, `campaign`, `setting`, and `spells` are useful
Narratio conventions, not a mandatory collection inventory or schema enumeration.
A shared roster supplies canonical character names, aliases, player
relationships, and relevant optional attributes. The maintained complete
pipeline needs no second operator-maintained player list or party glossary to
repeat those facts. Optional supplemental context remains separate from a
requirement to duplicate roster data.
Retain existing pipeline, lane, and stage reference scopes, configuration-origin
path handling, CLI working-directory path handling, and generated handoffs.
Preflight and run resolve the same bindings and collection selections.
### Binding Roles And Collection Selection
Retain the existing `spell_catalog`, `glossary`, and `party` slot roles. The first
two consume the same shared glossary format for different tasks. Collection
selection belongs on an external reference binding, not in module options;
`collections` is the intended configuration field. A binding selects the input
view, while the consuming domain code owns its interpretation.
When bound without an explicit selection, `spell_catalog` selects `spells`;
`glossary` selects available `campaign` and `setting` collections. Explicit
selections permit other collection names, including `party`. A missing explicitly
selected collection is an error. A missing default `spells` collection is a
spell-task suitability error; absence of default general-context collections
contributes no context. Neither glossary binding is required merely because the
other is supplied.
Selection travels with the binding through pipeline, lane, and stage scopes.
Existing `--reference slot=path` overrides replace the path and retain configured
collection selection; an otherwise unconfigured CLI binding uses the slot's
defaults. Ordinary Narratio invocations need no new CLI syntax. The same file may
be bound to both roles, with its complete content retained for shared validation.
The framework carries selection metadata without interpreting glossary content.
Extraction, normalization, and validators consume their resolved bindings using
the same selection rules, avoiding repeated collection options on individual
modules. Internal transport details belong in the subsequent implementation plan.
### Shared Conformance And Task Suitability
Provide one reusable decoding/validation boundary for adopted shared documents,
with small task-specific projections. Ordinary validation is offline, using
bundled exact-version schemas registered under their canonical IDs. Bundle the
adopted schema directories and semantics without importing the schema
repository's internal Go validation harness or creating a runtime catalog client.
Match the selected upstream validation profile for JSON/YAML decoding, including
one completed document, duplicate-key rejection, supported YAML aliases and
scalar handling, and preservation of numeric precision. In particular, extension
values must not be silently altered by a lossy generic decode. Reuse existing
libraries where they provide the required behavior; add only the adapter logic
needed to bridge the adopted profile.
Validate the complete shared document before projecting selected collections.
Enforce the upstream semantic rule that glossary entry IDs are unique within
each collection using exact comparison. Reuse of an ID in another collection is
valid. Do not require globally unique names, aliases, player names, or IDs, or
introduce cross-document referential-integrity checks.
Honor omission, null, empty values, and optional fields exactly where the
selected contract permits them. In particular, omitted/null/empty aliases are
supported, while null is not interchangeable with omission for every optional
field. Shared authored-input schemas are not private LLM response schemas and
do not inherit provider-specific restrictions on optional response properties.
Accept permitted extensions and preserve them when forwarding a shared document.
Task-specific projections may intentionally omit irrelevant fields. An extension
named `instruction` has no instruction or configuration semantics. Supported
domain interpretation must be deliberate rather than inferred from field names.
Keep shared conformance separate from task suitability. A valid document may
still lack a selected collection or contain spell-recognition ambiguities.
Report those as task requirements with reference/collection/field context where
practical, rather than redefining the upstream schema. A selected empty spell
collection adds no vocabulary to the embedded catalog; it is not malformed.
ConfigKit retains ownership of configuration loading and composition. Shared
reference readers consume completed domain documents; they do not add imports,
overlays, or another authoring merge language. Roster, glossary, and provenance
content remain auxiliary context. The current transcript remains the sole source
of event evidence and durable source ranges.
### Spell Recognition
Replace the operator-facing private overlay reader with a shared-glossary reader.
Remove the old envelope parser and legacy overlay fixtures when the cutover
lands; provide migration instructions rather than conversion shims.
Project selected entries into canonical names and aliases for the existing
effective catalog. Keep stable shared entry IDs and optional provenance available
for internal attribution and useful diagnostics, without asking models to copy
those IDs. Spell recognition does not need new required category values or
catalog metadata merely to consume a selected spell collection.
Retain the existing recognition policy unless a separately reviewed change is
needed:
- Start with the embedded D&D 5e 2014 SRD vocabulary.
- Add new canonical spell names and augment known canonical spells with aliases,
retaining the established embedded display spelling for a known spell.
- Apply the existing case, whitespace, and apostrophe lookup normalization to the
task view, without rewriting the authored shared document.
- Accept repeated aliases identifying the same spell; report normalized
canonical/alias collisions identifying different spells. These are recognition
conflicts, not shared-schema failures.
- Use the same resolver and selection semantics for extraction, normalization,
and catalog validation. Deterministic presentation and conflict outcomes must
not depend on YAML mapping order or upstream list order implying precedence.
The existing spell family determines the embedded ruleset. Do not require an
overlay-style `ruleset` or provenance title on the shared glossary, infer a
ruleset from Narratio selectors, or add a ruleset extension solely for parity
with the retired format. A future multi-ruleset workflow can establish its own
explicit selection if needed.
Keep the prompt projection focused on recognition vocabulary. Descriptions and
provenance do not become spell effects, rules, or transcript evidence. No new
spell extraction fields or output schema changes are part of this adoption.
### Party And General Context
Use a deterministic, contextual party projection for the chunker and extraction
families that already accept party context. It can include character names,
aliases, player relationships, and relevant optional attributes without exposing
opaque character IDs for model selection. Missing players or classes remain
valid; the application does not invent them. Equal display names do not merge
distinct roster entries merely because they compare equally.
Project selected general-glossary collections into useful reference vocabulary.
Selection is explicit task policy, not an attempt to parse all unknown domain
extensions or execute collection content. Party-derived vocabulary may be
consumed where useful but is not required alongside a roster containing the same
facts. The treatment of existing text inputs remains an open decision below.
Do not add a required campaign file, a typed campaign reference slot, or campaign
locator traversal without a demonstrated task. The shared RPG campaign contract
is reviewed context for this work, not a commitment to interpret it. Existing
ordinary text contexts outside the selected cutover do not need typed interfaces
solely because a campaign schema exists.
### Preparation And Readiness
Resolve and validate the selected external structured references during shared
local pipeline preparation, before chunking or other domain inference. Existing
module construction receives materialized references and already validates spell
catalogs; extend that path for the new shared readers and context projections.
Keep schema/domain interpretation in its owning integration code, not hardcoded
into the CLI or generic pipeline. Reuse prepared data where appropriate rather
than parsing the same roster or glossary for every chunk.
Explicit preflight must catch determinable malformed documents, incompatible
markers, semantic duplicate IDs, unavailable explicitly selected collections,
and spell-recognition conflicts using the same rules as execution. Run checks
its actual supplied documents even when a caller previously ran preflight.
Preserve the existing boundary between offline `pipeline validate` and explicit
preflight: ordinary offline pipeline validation does not start reading reference
bytes. Ordinary execution does not acquire preflight's destination probes or
provider smoke checks. A synthetic transcript establishes readiness only for that
input and its supplied references, not for a future transcript.
Use existing native outcomes/readiness reports and actionable diagnostics. No
new result protocol or warning system is needed. Invalid operator references
are input/preparation errors, not model-quality failures to repair with retries.
## Required Work Areas
| Area | Work needed |
| --- | --- |
| Shared contract assets | Bundle exact adopted schemas and adjacent semantics, source/version identification, and applicable license material in the content-only asset tree. Keep validation logic outside `assets`. |
| Shared input integration | Implement reusable offline decoding, schema validation, and glossary semantic checks. Preserve full documents separately from task projections. |
| Reference binding | Add binding-level `collections` selection and carry it through normal configuration/CLI override resolution without implementing a new composition system. Update reference declarations and accepted media types for affected consumers. |
| Spell family | Replace private overlay parsing in `internal/modules/dnd/spells/catalog`; adapt effective-catalog composition, prompt projection, and useful input diagnostics. Exercise extraction, normalization, and catalog-validator constructors together. |
| D&D context consumers | Update `internal/modules/dnd/shared`, applicable chunk/extract constructors, shared reference prompt content, and any direct reference presentations bypassing those helpers. Derive player context from the roster without requiring duplicate authored data. |
| Shared preparation and preflight | Ensure all selected external typed references receive domain validation during the existing preparation path, for both run and explicit preflight. Cover stage-scoped overrides as well as pipeline defaults. |
| Examples and documentation | Replace private overlay examples; supply synthetic shared party/glossary documents; update configuration, integration, D&D subprocess, and relevant internal documentation with the implemented bindings and cutover. |
This work does not require a general parsed-reference registry, a new public
schema API, or a repository-wide package reorganization. Choose concrete helper
placement and transport changes for the selected binding design during
implementation planning.
## Documentation, Migration, And Ownership
Create a focused integration document for Notarius's shared-input support. It
owns exact supported versions, accepted serializations, consumer roles,
collection selection, recognition adaptations, and task suitability. Link to
the selected upstream semantics and validation documentation for the shared
formats rather than maintaining a competing format specification.
Replace or retire `docs/integrations/dnd-spell-catalog-overlays.md` when its reader
is removed, updating inbound links. Update `docs/config.md` for binding fields and
defaults, `docs/consumers/dnd-pipeline.md` for first-class subprocess usage, and
focused internal docs for implemented ownership. Put complete copyable examples
under `examples/dnd-complete/`; leave the minimal configuration minimal.
Document the direct cutover in the release carrying the feature and its migration
guidance. Explain how old names/aliases map to shared entries, which old metadata
is optional provenance or unnecessary, and how replaced text references move
under the approved input design. No legacy overlay reader, automatic conversion,
or dual authoring workflow is required. Do not choose a release number or tag
as part of this planning pass.
Record incorporated schema material under the repository's
[OSS policy](../policy/oss.md), using the selected source revision and its actual
CC0-1.0 grant and notices. Keep `assets` a content-only leaf. This adoption fits
existing architecture; no new ADR is necessary unless resolving the open
decisions changes an architectural ownership boundary.
## Acceptance And Verification
The implemented feature should demonstrate:
1. A single synthetic shared spell document supplies canonical names and aliases
to Notarius without a private overlay. Validate it against the pinned upstream
contract. Cross-application execution is an interoperability check when the
other consumer has adopted that contract, not a claim about current Audita
compatibility or a dependency of Notarius's offline test suite.
2. A multi-collection file reaches only its selected task views. Unrelated
collections need not exist, explicit missing selections have useful errors,
and empty valid collections remain usable according to their task role.
3. One shared roster supplies character aliases and player relationships to the
maintained pipeline without duplicate player/party-vocabulary authoring.
Optional attributes and duplicate display labels follow the shared contract.
4. Equivalent YAML and JSON inputs produce equivalent task material. Focused
decoding tests cover duplicate keys, unsupported YAML forms, precision-sensitive
extension values, and representative allowed aliases/scalars from the upstream
profile. Structural and semantic tests cover omission/null/empty behavior,
extensions, per-collection ID uniqueness, and incompatible markers.
5. Recognition tests preserve embedded vocabulary, canonical display, same-spell
alias augmentation, and deterministic collision handling. General glossary
validity is tested separately from recognition suitability.
6. Preflight and run reject the same determinable bad structured references
before domain inference. Fake provider boundaries prove valid projections
reach their intended tasks and reference-only entries do not create events.
7. Bundled schema validation requires no network, schema-repository installation,
or credentials. Full-document forwarding retains extensions; model-facing
projections omit opaque IDs and do not promote extensions to instructions.
8. Existing output artifact contracts, generated handoffs, input-based session
identity, native report shape, and cache policy remain intact. Updated prompt
material participates in existing native cache identity; add no separate
schema/provenance cache-key dimension or automatic cache migration.
Use focused package tests for the readers, spell family, shared projections,
reference resolution, and representative CLI preflight/run behavior. Reuse
upstream fixtures selectively for meaningful contract risks rather than copying
the upstream test harness. Avoid prompt prose snapshots and redundant tests of
the same parser behavior in every extractor.
For the implementation, run `go test ./...`, `go vet ./...`, and
`go build ./cmd/notarius`, validate the maintained examples, and check affected
links and stale private-overlay references. Paid/provider tests and coordinated
Narratio/Audita deployment runs are optional follow-up evidence, not default
offline correctness gates.
## Open Decisions
### Existing Text Party And Glossary References
**Recommendation:** Reuse `party` for the shared party contract and `glossary`
for the shared glossary contract, making a documented direct cutover for those
slots alongside the spell-overlay replacement. Existing `roster` aliases, where
already accepted, can retain their current slot-alias behavior while consuming
the same new party contract; do not retain a second text roster parser. Keep
`players` as optional supplemental text context, while deriving the ordinary
character/player relationships from the roster so the maintained workflow does
not need that separate file.
This gives established slot names one clear meaning and avoids parallel typed
and untyped roster/vocabulary paths. It also changes public text-input behavior,
so approval and explicit migration guidance are appropriate. It does not require
adding a new typed campaign input or removing unrelated text interfaces.
**Viable alternative:** Add distinctly named structured party/glossary slots and
leave current text slots unchanged. This preserves ordinary free-form context
without format detection or legacy converters, and may suit independent users
of those text interfaces. It introduces parallel context sources, requires
documented combination/precedence behavior, and makes it easier to continue
duplicating the same roster facts. Choose it if retaining those text workflows
outweighs the benefit of a simpler cutover.