Add typed spell validation strategies
This commit is contained in:
@@ -21,10 +21,10 @@ Production input, chunk, output, and D&D spell-extract packages register strict
|
||||
option decoders and run-local builders. Preparation decodes their options into
|
||||
implementation-owned values and injects dependencies. The spell extractor is
|
||||
typed over the canonical D&D model; a temporary raw adapter preserves the
|
||||
current downstream production path. Production merge, normalize, and validator
|
||||
packages still use the explicit legacy raw registration APIs and temporary
|
||||
adapters around zero-argument constructors. Their raw option maps and LLM
|
||||
clients remain operation inputs while that part of the catalog migrates.
|
||||
current runner path. D&D validators, merge, and normalize use typed variants;
|
||||
JSON representation validators use serialized requests; and unconditional
|
||||
validators expose separate chunk and typed variants. Narrow legacy
|
||||
registrations preserve current raw execution until the runner migrates.
|
||||
|
||||
Specs expose capability and execution metadata without constructing an
|
||||
implementation. Registry entries separately expose option validation and
|
||||
@@ -123,16 +123,16 @@ The durable payload and manifest metadata shapes are defined in the
|
||||
|
||||
### `internal/modules/generic/merge/appendorder`
|
||||
|
||||
The merger preserves extract-result order. It passes through one JSON result,
|
||||
concatenates a common top-level array field across multiple JSON objects, and
|
||||
otherwise emits an array of the decoded values. It rejects invalid JSON and
|
||||
non-JSON media types, and it preserves compatible schema provenance.
|
||||
The typed merger passes values to an injected combine function in framework
|
||||
source-chunk order. The D&D registrar specializes it with a spell-list append
|
||||
function. Its temporary raw implementation retains the prior JSON merge
|
||||
behavior for the current runner.
|
||||
|
||||
### `internal/modules/generic/normalize/noop`
|
||||
|
||||
The normalizer defensively clones the accepted merge result, including payload
|
||||
bytes, metadata, warnings, and schema provenance, without changing its logical
|
||||
content.
|
||||
The typed normalizer returns the merged domain value unchanged and is reusable
|
||||
for any registered artifact type. Its temporary raw implementation defensively
|
||||
clones the accepted payload for the current runner.
|
||||
|
||||
## Output Encoder
|
||||
|
||||
@@ -152,26 +152,23 @@ paths and schemas.
|
||||
The generic validator implementations live under
|
||||
`internal/modules/generic/validate`.
|
||||
|
||||
The unconditional accept and reject validators provide deterministic production
|
||||
registrations used primarily for controlled composition and tests.
|
||||
The unconditional accept and reject validators provide explicit chunk and
|
||||
typed-artifact variants used primarily for controlled composition and tests.
|
||||
|
||||
The JSON syntax validator uses `encoding/json` to reject malformed payloads. The
|
||||
JSON Schema validator requires schema bytes on the validation request, parses
|
||||
the instance and schema with `jsonschema`, and distinguishes payload rejection
|
||||
from schema loading or compilation errors. Neither validator calls the LLM.
|
||||
The serialized JSON syntax validator uses `encoding/json` to reject malformed
|
||||
representation bytes. The serialized JSON Schema validator requires schema
|
||||
bytes, parses the instance and schema with `jsonschema`, and distinguishes
|
||||
payload rejection from schema loading or compilation errors. The framework
|
||||
serialized-validation request carries either canonical chunk bytes or artifact
|
||||
codec bytes according to its target context. Neither validator calls the LLM.
|
||||
|
||||
## D&D Spell Validators
|
||||
|
||||
`internal/modules/dnd/validate/spells/spellpayload` provides strict decoding,
|
||||
shape checks, source-reference candidates, and cited-text lookup shared by the
|
||||
three validators.
|
||||
|
||||
The shape validator rejects malformed JSON, unknown fields, missing or empty
|
||||
spell fields, and empty reference lists. The source-reference validator applies
|
||||
generic source-reference validation to every cited range. The relatedness
|
||||
validator approves structurally valid payloads but warns when a case-insensitive
|
||||
spell name is absent from all cited source text. It leaves malformed payloads to
|
||||
the earlier validators in the configured chain.
|
||||
All three validators receive `dnd.SpellList` directly. The shape validator
|
||||
rejects missing or empty spell fields and empty reference lists. The
|
||||
source-reference validator applies generic source-reference validation to every
|
||||
cited range. The relatedness validator warns when a case-insensitive spell name
|
||||
is absent from all cited source text.
|
||||
|
||||
These validators are deterministic. Their selectable keys and production order
|
||||
are defined in
|
||||
|
||||
@@ -64,10 +64,11 @@ parsing. Production input, chunk, and output modules use strict construction-tim
|
||||
option decoding, and the LLM-backed scene chunker retains the injected shared
|
||||
client. The D&D family registers the canonical `dnd/spell-list` codec and a
|
||||
typed spell extractor. A temporary raw adapter serializes that typed result for
|
||||
the still-raw production validators, merger, normalizer, and runner. Other
|
||||
artifact-lane modules and validators continue through explicitly named legacy
|
||||
raw registrations and temporary zero-argument constructor adapters. The current
|
||||
runner rejects a typed prepared lane instead of routing it through raw execution.
|
||||
the current runner. The D&D family also registers typed spell validators and
|
||||
kind-specific generic merge and normalize strategies; generic JSON validators
|
||||
use the serialized-validation contract. Narrow legacy registrations preserve
|
||||
the existing raw runner path until typed execution lands. The current runner
|
||||
rejects a typed prepared lane instead of routing it through raw execution.
|
||||
|
||||
## Production Extensions
|
||||
|
||||
@@ -96,8 +97,8 @@ helpers. Domain-neutral prompt filesystem composition lives in
|
||||
Generic validators under `internal/modules/generic/validate` provide
|
||||
unconditional test decisions, JSON syntax validation, and JSON Schema
|
||||
validation. D&D spell validators under `internal/modules/dnd/validate/spells`
|
||||
provide shape, source-reference, and source-relatedness decisions, with
|
||||
`spellpayload` holding their shared parser and lookup helpers.
|
||||
consume the canonical spell-list type directly to provide shape,
|
||||
source-reference, and source-relatedness decisions.
|
||||
|
||||
Production composition is grouped behind package-family registrars, and every
|
||||
implemented production extension uses its domain-first tree:
|
||||
|
||||
@@ -75,9 +75,11 @@ mismatches are rejected deterministically.
|
||||
|
||||
Production composition registers the D&D spell-list codec. The typed spell
|
||||
extractor also registers a temporary raw adapter, which resolution selects
|
||||
until its downstream production lane is typed. Other production artifact-lane
|
||||
modules use the explicitly named legacy raw registration APIs. A standalone raw
|
||||
registration cannot satisfy a typed lane.
|
||||
until runner execution is typed. The D&D family registers matching typed merge,
|
||||
normalize, and semantic-validator variants, while JSON validators register for
|
||||
serialized chunk and artifact targets. Narrow legacy registrations preserve the
|
||||
current raw runner path. A standalone raw registration cannot satisfy a typed
|
||||
lane.
|
||||
|
||||
A `ModuleSpec` declares its stage plus required and provided capabilities.
|
||||
Chunk, extract, merge, and normalize specs may also declare reference slots.
|
||||
|
||||
Reference in New Issue
Block a user