Complete D&D NPC interaction integration
This commit is contained in:
@@ -98,7 +98,7 @@ D&D prompt content. `internal/framework/promptfs` provides the domain-neutral
|
||||
filesystem composition helper used to combine module-owned files with shared
|
||||
domain prompt fragments.
|
||||
|
||||
The D&D scene chunker and spell, NPC, and combat-turn extractors each declare an
|
||||
The D&D scene chunker and spell, NPC, combat-turn, and NPC-interaction extractors each declare an
|
||||
ordered prompt asset manifest. The manifest lists the package-owned YAML and
|
||||
Markdown files, then the exact shared fragments rendered by that prompt; the
|
||||
same ordered list drives both filesystem mounting and the prompt fingerprint.
|
||||
@@ -126,17 +126,18 @@ per-chunk transcript changes. Cache reuse requires the preceding message
|
||||
sequence and content to be exactly identical; semantic similarity is not
|
||||
sufficient. Cache boundaries belong at the ends of reusable stable tiers,
|
||||
subject to the provider's cache-boundary limit. The shared identity and
|
||||
campaign-reference messages form the first two extraction boundaries. Spell
|
||||
and combat prompts add a boundary at the shared NPC registry. Each extraction
|
||||
campaign-reference messages form the first two extraction boundaries. Spell,
|
||||
combat, and interaction prompts add a boundary at the shared NPC registry. Each extraction
|
||||
prompt places its final boundary on its lane-specific instructions, immediately
|
||||
before the transcript. The transcript does not carry cache control because no
|
||||
reusable content follows it.
|
||||
|
||||
Accordingly, the common prefix of all three extraction prompts is system,
|
||||
Accordingly, the common prefix of all four extraction prompts is system,
|
||||
extraction evidence, identity, and campaign references. The NPC prompt then
|
||||
renders task, instructions, and transcript. Spell renders the NPC registry,
|
||||
catalog, task, instructions, and transcript. Combat renders the NPC registry,
|
||||
task, instructions, and transcript. The
|
||||
task, instructions, and transcript. NPC interaction renders the names-only NPC
|
||||
registry, task, instructions, and transcript. The
|
||||
scene chunker is not an extraction lane: it retains its separate system,
|
||||
transcript, campaign-reference, task, and instruction order and marks its
|
||||
transcript and campaign-reference messages ephemeral.
|
||||
@@ -154,7 +155,7 @@ return defensive copies, and expose a diagnostics map that omits schema bytes.
|
||||
The small framework registry contains only generic test schemas; production
|
||||
schemas remain package-owned.
|
||||
|
||||
The spell, NPC, and combat extractors' package-owned prompts declare their
|
||||
The spell, NPC, combat, and NPC-interaction extractors' package-owned prompts declare their
|
||||
structured JSON inputs and private response schemas. Each private response
|
||||
schema remains separate from its durable artifact codec schema; this work does
|
||||
not use shared schema fragments or schema generation. Those private schemas own
|
||||
@@ -167,14 +168,14 @@ numbers. The spell extractor's prompt declares a required
|
||||
the catalog input from its prepared
|
||||
effective catalog as `{"spell_names":[...]}` using sorted canonical names only.
|
||||
The shared D&D prompt assets include a generic NPC grounding fragment directly
|
||||
after the campaign reference message for spell and combat prompts. When an NPC
|
||||
after the campaign reference message for spell, combat, and interaction prompts. When an NPC
|
||||
registry is bound, the
|
||||
domain registry boundary strictly decodes and identity-validates one durable
|
||||
artifact, re-encodes canonical JSON for provenance, and separately generates a
|
||||
names-only prompt projection. The unbound projection is exactly `{"npcs":[]}`.
|
||||
Prompt input and component-local checkpoint digests cover the projected bytes;
|
||||
manifests retain the optional full registry digest/count rather than names,
|
||||
overlay bytes, registry paths, or source metadata. Combat prompt,
|
||||
overlay bytes, registry paths, or source metadata. Combat and interaction prompt,
|
||||
response-schema, mapping, normalization, identity, and registry-projection
|
||||
fingerprints remain separate semantic inputs to checkpoint identity.
|
||||
|
||||
|
||||
@@ -17,16 +17,16 @@ validator registry. Package-family registrars compose those leaf registrations
|
||||
into the production catalog and own family-level policy such as default
|
||||
validator chains and prompt asset collection.
|
||||
|
||||
Production input, chunk, output, and D&D spell- and combat-extract packages
|
||||
Production input, chunk, output, and D&D spell-, combat-, and interaction-extract packages
|
||||
register strict option decoders and run-local builders. Preparation decodes their options into
|
||||
implementation-owned values and injects dependencies plus the materialized
|
||||
reference set for the selected target. Each builder receives an isolated clone
|
||||
of that set; input and output builders receive no references. The spell and
|
||||
combat extractors are typed over the canonical D&D model. D&D validators, merge,
|
||||
of that set; input and output builders receive no references. The spell,
|
||||
combat, and interaction extractors are typed over the canonical D&D model. D&D validators, merge,
|
||||
and normalize use typed variants; JSON representation validators use serialized
|
||||
requests; and unconditional validators expose separate chunk and typed
|
||||
variants. The D&D production registrar registers the canonical typed spell,
|
||||
NPC, and combat implementations, including their kind-specific merge and
|
||||
NPC, combat, and interaction implementations, including their kind-specific merge and
|
||||
normalize behavior.
|
||||
|
||||
For D&D artifact defaults, generic JSON syntax validation runs first. Rejecting
|
||||
@@ -54,7 +54,7 @@ package-local embedded assets. Shared filesystem composition belongs in
|
||||
`internal/framework/promptfs`; reusable D&D prompt fragments, reference
|
||||
declarations, prompt-input assembly, and source-unit/citation helpers belong in
|
||||
`internal/modules/dnd/shared`, which also owns bounded D&D diagnostics. The
|
||||
D&D scene chunker and spell, NPC, and combat-turn extractors use ordered
|
||||
D&D scene chunker and spell, NPC, combat-turn, and NPC-interaction extractors use ordered
|
||||
package-local prompt manifests for both rendering and prompt fingerprinting, so
|
||||
only the shared fragments each prompt actually renders participate in either
|
||||
operation. Extraction prompts place stable shared and lane-specific context
|
||||
@@ -65,7 +65,7 @@ contracts expose only Notarius structured-completion types, not Scriptorium
|
||||
public types.
|
||||
|
||||
The shared `ChunkPromptMaterial` helper owns common transcript material
|
||||
preparation for the spell, NPC, and combat-turn extractors. It clones supplied
|
||||
preparation for the spell, NPC, combat-turn, and NPC-interaction extractors. It clones supplied
|
||||
source metadata, falls back to the materialized chunk when content is absent,
|
||||
checks that content remains chunk-identical, and fills only the common default
|
||||
fields. Extractors retain their request validation and wrap helper errors with
|
||||
@@ -122,6 +122,12 @@ The `internal/modules/dnd/codec/combatturns` package owns the durable
|
||||
is registered by the production D&D family registrar for the selectable combat
|
||||
lane.
|
||||
|
||||
The `internal/modules/dnd/codec/npcinteractions` package owns the durable
|
||||
`dnd/npc-interaction-list` schema and candidate versus approved JSON boundary.
|
||||
It is registered by the production D&D family registrar for the selectable
|
||||
interaction lane. Its external contract is documented in the
|
||||
[D&D NPC interaction artifact contract](../integrations/dnd-npc-interaction-artifacts.md).
|
||||
|
||||
## Input Adapter
|
||||
|
||||
### `internal/modules/seriatim/input/transcript`
|
||||
@@ -284,6 +290,19 @@ The combat normalizer accepts only the optional structured NPC registry.
|
||||
Campaign references remain extractor-only LLM context and are not materialized
|
||||
for deterministic normalization.
|
||||
|
||||
### `internal/modules/dnd/extract/npcinteractions`
|
||||
|
||||
The NPC interaction extractor requires the structured `npcs` registry slot. It
|
||||
uses the registry's names-only prompt projection with shared extraction
|
||||
evidence, identity, and transcript material, then maps private model records to
|
||||
`dnd.NPCInteractionList` with the current source identity. Registry source
|
||||
references are never reused as interaction evidence. The private response
|
||||
schema carries only name, bounded interaction kind, and source-unit ranges;
|
||||
deterministic validators own registry membership, source validity, and
|
||||
relatedness. Prompt, schema, mapping, and the names-only registry projection
|
||||
participate in checkpoint identity, while generated producer identity remains
|
||||
framework provenance.
|
||||
|
||||
### `internal/modules/dnd/normalize/npcs`
|
||||
|
||||
The NPC normalizer performs deterministic identity-aware consolidation in
|
||||
@@ -344,6 +363,16 @@ digest/count metadata; generated identity is retained in framework provenance
|
||||
and dependency fingerprints. The normalizer is included in the production D&D
|
||||
registrar with the default combat normalization chain.
|
||||
|
||||
### `internal/modules/dnd/normalize/npcinteractions`
|
||||
|
||||
The interaction normalizer requires the same immutable NPC registry. It
|
||||
canonicalizes exact registry-name matches, orders and de-duplicates source
|
||||
references, stable-sorts occurrences by source-document position, and collapses
|
||||
only exact interaction identities with valid evidence. It does not infer,
|
||||
merge, or summarize distinct occurrences. Its metadata and fingerprints expose
|
||||
the normalization and NPC identity policies; generated registry identity stays
|
||||
in framework provenance and checkpoint dependencies.
|
||||
|
||||
## Output Encoder
|
||||
|
||||
### `internal/modules/generic/output/json`
|
||||
@@ -428,6 +457,18 @@ expose local policy fingerprints. In the registered defaults, JSON syntax runs
|
||||
first; combat shape, normalized invariants when applicable, and source-reference
|
||||
validation precede JSON Schema validation; warning-only relatedness runs last.
|
||||
|
||||
## D&D NPC Interaction Validators
|
||||
|
||||
Interaction shape validation owns the required list, registry name, supported
|
||||
kind, and non-empty source-reference collection. Registry validation checks
|
||||
exact membership in the required immutable NPC registry. Source-reference and
|
||||
relatedness validation use the current transcript only; malformed candidates
|
||||
are deferred by later validators and produce no relatedness warning. The
|
||||
normalized-invariants validator owns canonical registry names, source-reference
|
||||
order, chronology, and exact duplicate identity. The production chains run
|
||||
shape, registry, and source-reference checks before JSON Schema validation;
|
||||
relatedness remains warning-only and last.
|
||||
|
||||
## Production Registration
|
||||
|
||||
Production composition occurs through family registrars. The CLI allocates one
|
||||
@@ -436,7 +477,7 @@ complete framework registry set and one LLM asset registry. It invokes
|
||||
`internal/modules/seriatim/register`, and `internal/modules/dnd/register` in
|
||||
that order, then exposes the matching catalog for resolution. The generic and
|
||||
Seriatim registrars own their production leaf registrations. The D&D registrar
|
||||
owns D&D leaf registrations, typed spell, NPC, and combat default-validator
|
||||
owns D&D leaf registrations, typed spell, NPC, combat, and interaction default-validator
|
||||
chains, typed append-order specializations, and D&D prompt/schema asset
|
||||
collection. Its registration helpers group module, validator, prompt-asset, and
|
||||
chain composition while retaining artifact-specific merge and clone behavior in
|
||||
|
||||
@@ -67,8 +67,9 @@ run-local construction closures. Preparation injects shared dependencies and
|
||||
constructs input, chunk, validators, ordered lanes, and output before source
|
||||
parsing. Production modules use strict construction-time option decoding, and
|
||||
LLM-backed modules retain the injected shared client. The D&D family registers
|
||||
the canonical `dnd/spell-list`, `dnd/npc-list`, and `dnd/combat-turn-list`
|
||||
codecs, typed spell, NPC, and combat extractors and normalizers, validators,
|
||||
the canonical `dnd/spell-list`, `dnd/npc-list`, `dnd/combat-turn-list`, and
|
||||
`dnd/npc-interaction-list` codecs, typed spell, NPC, combat, and interaction
|
||||
extractors and normalizers, validators,
|
||||
plus kind-specific generic merge strategies; generic JSON validators use the
|
||||
serialized-validation contract. The runner executes lanes through
|
||||
private exact-type-checked closures, coordinates extract results independently
|
||||
@@ -87,15 +88,19 @@ Configuration. The implemented module packages are:
|
||||
| `internal/modules/seriatim/input/transcript` | Parses the supported Seriatim transcript format into the generic source model. |
|
||||
| `internal/modules/generic/chunk/units` | Splits ordered source units by unit count and overlap. |
|
||||
| `internal/modules/dnd/chunk/scenes` | Produces contiguous D&D scene chunks from structured model output. |
|
||||
| `internal/modules/dnd` | Owns the canonical D&D spell-list, spell-cast, NPC-list, NPC, combat-turn-list, and combat-turn artifact types. |
|
||||
| `internal/modules/dnd` | Owns the canonical D&D spell-list, spell-cast, NPC-list, NPC, combat-turn-list, combat-turn, NPC-interaction-list, and NPC-interaction artifact types. |
|
||||
| `internal/modules/dnd/codec/spells` | Strictly decodes and stably encodes the durable D&D spell-list representation. |
|
||||
| `internal/modules/dnd/codec/npcs` | Strictly decodes and stably encodes the durable D&D NPC-list representation. |
|
||||
| `internal/modules/dnd/codec/combatturns` | Strictly decodes and stably encodes the durable D&D combat-turn-list representation. |
|
||||
| `internal/modules/dnd/codec/npcinteractions` | Strictly decodes and stably encodes the durable D&D NPC-interaction-list representation. |
|
||||
| `internal/modules/dnd/extract/spells` | Maps private structured model output to canonical source-grounded D&D spell lists. |
|
||||
| `internal/modules/dnd/extract/npcs` | Maps private structured model output to canonical source-grounded D&D NPC lists. |
|
||||
| `internal/modules/dnd/extract/combatturns` | Maps private structured model output to source-grounded D&D combat-turn candidates and preserves chronology and invalid candidate values for validators. |
|
||||
| `internal/modules/dnd/extract/npcinteractions` | Maps private structured model output to current-source NPC interaction candidates grounded by a required registry. |
|
||||
| `internal/modules/dnd/normalize/combatturns` | Canonicalizes and orders merged combat turns, applies exact NPC identity matches, and collapses only exact valid-evidence duplicates. |
|
||||
| `internal/modules/dnd/normalize/npcinteractions` | Canonicalizes required-registry names, orders interaction occurrences, and collapses only exact valid-evidence duplicates. |
|
||||
| `internal/modules/dnd/validate/combatturns` | Provides deterministic shape, source-reference, source-relatedness, and normalized-invariant validation for the production combat chains. |
|
||||
| `internal/modules/dnd/validate/npcinteractions` | Provides deterministic shape, registry, source-reference, source-relatedness, and normalized-invariant validation for interaction chains. |
|
||||
| `internal/modules/dnd/npcs/registry` | Resolves validated normalized NPC references into immutable grounding data and exact identity lookup. |
|
||||
| `internal/modules/dnd/npcs/identity` | Owns Unicode-aware NPC identity, ID derivation, and registry collision validation. |
|
||||
| `internal/modules/dnd/spells/catalog` | Embeds and validates the versioned D&D 5e 2014 SRD catalog, composes optional overlays, and provides immutable effective lookup. |
|
||||
@@ -116,14 +121,16 @@ The `dnd/npcs/registry` package owns the optional `npcs` registry boundary.
|
||||
External references are strictly decoded and identity-validated during
|
||||
preparation; generated references are decoded and identity-validated at the
|
||||
ordered step handoff. Both paths retain canonical registry JSON for provenance
|
||||
and emit a names-only projection to operation-time spell and combat prompts.
|
||||
Combat normalization uses the canonical registry for exact actor lookup. The
|
||||
and emit a names-only projection to operation-time spell, combat, and
|
||||
interaction prompts. Combat and interaction normalization use the canonical
|
||||
registry for exact name lookup. The
|
||||
framework records generated identity and bounded producer provenance, while
|
||||
the raw external reference remains independently tracked by pipeline
|
||||
provenance. An absent registry is represented only by the empty prompt value
|
||||
`{"npcs":[]}`. Spell
|
||||
and combat consumers use this shared boundary without changing their public
|
||||
module contracts.
|
||||
module contracts. Interaction consumers require it and retain only current
|
||||
transcript references as durable evidence.
|
||||
|
||||
Generic validators under `internal/modules/generic/validate` provide
|
||||
unconditional test decisions, JSON syntax validation, and JSON Schema
|
||||
|
||||
Reference in New Issue
Block a user