2026-07-26 13:30:36 +00:00
|
|
|
# Module Internals
|
|
|
|
|
|
2026-11-22 06:48:55 +00:00
|
|
|
This guide owns typed module construction, registration, and extension recipes.
|
|
|
|
|
[Configuration](../config.md#production-module-keys) owns selectable keys,
|
|
|
|
|
binding syntax, references, and default chains.
|
|
|
|
|
[Integration contracts](../integrations/json-output.md) own durable shapes;
|
|
|
|
|
[D&D Module Internals](dnd.md) owns that family's domain conventions.
|
|
|
|
|
|
|
|
|
|
## Typed Boundary And Registration
|
|
|
|
|
|
|
|
|
|
A module implements one fixed pipeline operation; an artifact family owns the
|
|
|
|
|
related domain types, codec, modules, validators, prompts, and reference
|
|
|
|
|
projections. Family ownership does not combine extraction/merge/normalization
|
|
|
|
|
or turn the pipeline into a workflow language.
|
|
|
|
|
|
|
|
|
|
[ModuleSpec](../../internal/framework/pipeline/module.go) declares the stable
|
|
|
|
|
key, operation, execution class, artifact kind, capabilities, reference slots,
|
|
|
|
|
and statically selected prompt IDs. Specs can be inspected without constructing
|
|
|
|
|
modules. The resolver applies model-profile selections only to model roles.
|
|
|
|
|
Static initial/correction dependencies use the same constants as request builders;
|
|
|
|
|
they are preflight declarations, not asset manifests or execution fingerprints.
|
|
|
|
|
|
2026-11-25 16:24:26 +00:00
|
|
|
[BuildRequest](../../internal/framework/pipeline/construction.go) supplies
|
|
|
|
|
dependencies, option values, and prepared references; one-shot validators may
|
|
|
|
|
use the shared native engine. Option-aware
|
2026-11-22 06:48:55 +00:00
|
|
|
modules provide a resolver validator and a builder using the same strict decoder.
|
|
|
|
|
They do not rediscover configuration or reopen reference files. Generated
|
|
|
|
|
references arrive through operation requests, not construction-time file reads.
|
|
|
|
|
|
|
|
|
|
Typed helpers retain the exact artifact type at registration:
|
|
|
|
|
|
|
|
|
|
- [RegisterExtractorBuilder](../../internal/framework/pipeline/extractor_registry.go),
|
|
|
|
|
[RegisterMergerBuilder](../../internal/framework/pipeline/merger_registry.go), and
|
|
|
|
|
[RegisterNormalizerBuilder](../../internal/framework/pipeline/normalizer_registry.go)
|
|
|
|
|
connect typed production to private framework erasure.
|
|
|
|
|
- [Typed validators](../../internal/framework/pipeline/validator_registry.go)
|
|
|
|
|
register compatible kind/type-specific assessment.
|
|
|
|
|
- [Artifact codecs](../../internal/framework/pipeline/artifact_codec_registry.go)
|
|
|
|
|
own durable encoding/decoding and intrinsic schema checks.
|
|
|
|
|
- Optional [evidence projectors](../../internal/framework/pipeline/artifact_evidence_registry.go)
|
|
|
|
|
copy direct generic source references using the codec's exact Go type.
|
|
|
|
|
|
|
|
|
|
Preparation rejects incompatible types/registrations before parsing source.
|
|
|
|
|
Projectors do not inspect arbitrary domain JSON or publish files; the
|
|
|
|
|
[evidence contract](../integrations/evidence-context.md) owns the excerpt.
|
|
|
|
|
|
2026-11-25 16:24:26 +00:00
|
|
|
## Preparing Operations
|
|
|
|
|
|
|
|
|
|
The [tested message-topic example](../../internal/framework/pipeline/author_example_test.go)
|
|
|
|
|
shows a domain-neutral input, codec, registrar, text chunk, contextual
|
|
|
|
|
interpretation, correction binding, and a deterministic branch. For production
|
|
|
|
|
adapters see [spell extraction](../../internal/modules/dnd/extract/spells/extractor.go)
|
|
|
|
|
and the [item registry normalizer](../../internal/modules/dnd/normalize/itemregistry/normalizer.go).
|
|
|
|
|
|
|
|
|
|
A typed stage implements its `PrepareExtraction`, `PrepareMerge`,
|
|
|
|
|
`PrepareNormalize`, or `PrepareChunk` method from
|
|
|
|
|
[preparation contracts](../../internal/framework/contracts/preparation.go).
|
|
|
|
|
Core invokes that method once with domain inputs, then executes the returned
|
|
|
|
|
operation. The stage does not receive or choose an assessor, engine, cache,
|
|
|
|
|
capture, or terminal mode. The runner binds those privately; direct callers can
|
|
|
|
|
supply a [core execution context](../../internal/framework/pipeline/operation.go)
|
|
|
|
|
and preparation function to the same executor.
|
|
|
|
|
|
|
|
|
|
- Return a deterministic operation with one candidate when no model is needed.
|
|
|
|
|
Core assesses it once; there is no native request or synthetic cache key.
|
|
|
|
|
- Return a native operation containing the selected `promptkit.RunRequest`,
|
|
|
|
|
an interpreter, and, when supported, a correction builder and fallback.
|
|
|
|
|
Interpret into an evaluation with a candidate and any ordered guidance.
|
|
|
|
|
A correctable selection can provide guidance without a candidate. A candidate
|
|
|
|
|
is not an approval: core still runs every configured validator.
|
|
|
|
|
- Return an ordinary Go error for preparation failures. Use the explicit
|
|
|
|
|
preparation-limit operation only for an existing supported limit, not as
|
|
|
|
|
generic error recovery. Core selects strict/permissive handling.
|
|
|
|
|
- Supply fallback only when the family supports intrinsically usable output.
|
|
|
|
|
It receives the final eligible evaluation, or nil when none remains. It must
|
|
|
|
|
preserve domain/source/downstream invariants; core does not re-run ordinary
|
|
|
|
|
validators or claim acceptance for fallback.
|
|
|
|
|
|
|
|
|
|
For the common correction form, `PromptCorrection` binds ordered guidance to
|
|
|
|
|
an integration-chosen prompt input; a specialized builder can instead construct
|
|
|
|
|
the assignment directly. Native coordination retains the initial profile/session,
|
|
|
|
|
resolved options, and conversation history. Modules do not replay source or
|
|
|
|
|
implement a continuation loop. See [Pipeline Internals](pipeline.md) for
|
|
|
|
|
assessment and terminal behavior and [LLM Integration](llm.md) for native ownership.
|
|
|
|
|
|
|
|
|
|
An evaluation and its candidate, diagnostics, guidance, and optional evidence
|
|
|
|
|
are one operation-local unit. Core replaces it on each delivered interpretation
|
|
|
|
|
and clears it before a selected correction; failed or unusable continuation
|
|
|
|
|
cannot restore a prior evaluation. Historical capture may retain prior evidence.
|
|
|
|
|
Preparation transfers returned values and callbacks to that operation; a shared
|
|
|
|
|
module must not store mutable operation state. Own mutable slices/maps that a
|
|
|
|
|
callback might modify and respect the existing detached input boundaries.
|
|
|
|
|
Optional evidence projections are lazy and only invoked when capture is enabled.
|
|
|
|
|
This does not promise thread safety for caller-supplied writers or observers.
|
2026-11-22 06:48:55 +00:00
|
|
|
|
|
|
|
|
## Validators And Deterministic Work
|
|
|
|
|
|
|
|
|
|
Validators receive native execution options and detached candidate/context views,
|
2026-11-25 16:24:26 +00:00
|
|
|
not an operation executor. Return approval or rejection with separately authored
|
|
|
|
|
actionable correction guidance; operator messages are not model feedback.
|
|
|
|
|
A model validator calls the shared engine once and checks native result usability
|
|
|
|
|
before interpretation. The [combat validator](../../internal/modules/dnd/validate/scenedescriptions/combat_semantics/validator.go)
|
|
|
|
|
is the one-shot example. It does not own a semantic correction loop or extend
|
|
|
|
|
native repair budgets.
|
|
|
|
|
|
|
|
|
|
Deterministic modules return prepared candidates through the same core path.
|
|
|
|
|
See the [noop normalizer](../../internal/modules/generic/normalize/noop/typed.go)
|
|
|
|
|
and the model-backed extractors with no-model branches.
|
2026-11-22 06:48:55 +00:00
|
|
|
|
|
|
|
|
## Prompt And Schema Ownership
|
|
|
|
|
|
|
|
|
|
[assets/notarius.yml](../../assets/notarius.yml) imports ordinary native prompt
|
|
|
|
|
declarations and profiles with their filesystem contexts. The content-only
|
|
|
|
|
assets package has no registration behavior. Declarations own ordered messages,
|
|
|
|
|
cache hints, default profiles, and output contracts/schema selection. Use real
|
|
|
|
|
relative content-file paths; no virtual mounts or Go prompt manifests.
|
|
|
|
|
|
|
|
|
|
A producer's initial/correction pair requests complete responses with matching
|
|
|
|
|
schema/profile defaults. Put enduring rules in initial system context and only
|
|
|
|
|
current guidance/new assignment in follow-ups. Native structural repair remains
|
|
|
|
|
upstream-owned. Private response envelopes are not durable artifact contracts.
|
|
|
|
|
See [schema selection](../config.md#prompt-output-contracts-and-schemas) and the
|
|
|
|
|
[D&D prompt recipe](dnd.md#prompt-construction) for concrete examples.
|
2026-07-26 13:30:36 +00:00
|
|
|
|
2026-08-09 17:05:17 +00:00
|
|
|
## Semantic Reconciliation
|
|
|
|
|
|
2026-11-25 16:24:26 +00:00
|
|
|
The [shared facility](../../internal/framework/semanticreconcile/operation.go)
|
|
|
|
|
prepares core operations and provides proposal assessment and typed application,
|
|
|
|
|
not a replacement execution service.
|
2026-11-22 06:48:55 +00:00
|
|
|
[Requests](../../internal/framework/semanticreconcile/requests.go) consume one
|
|
|
|
|
retained preparation. [Proposal safety](../../internal/framework/semanticreconcile/proposal.go)
|
|
|
|
|
resolves request-local handles; [application](../../internal/framework/semanticreconcile/application.go)
|
|
|
|
|
clones/preserves originals and applies domain policies.
|
|
|
|
|
|
|
|
|
|
The [item normalizer](../../internal/modules/dnd/normalize/itemregistry/normalizer.go)
|
2026-11-25 16:24:26 +00:00
|
|
|
preprocesses fixed originals once and prepares bounded windows/handles once.
|
|
|
|
|
Core executes its operation like extraction. Each complete proposal is assessed
|
2026-11-22 06:48:55 +00:00
|
|
|
and applied afresh to originals before pipeline assessment. Domain guards,
|
|
|
|
|
identity, evidence, diagnostics, and supported final-only fallback remain with
|
|
|
|
|
the artifact family. Do not union plans across turns, reuse prior mutated output,
|
|
|
|
|
or introduce module retry/repair protocols. [D&D reconciliation](dnd.md#semantic-registry-reconciliation)
|
|
|
|
|
explains the concrete policy differences.
|
|
|
|
|
|
|
|
|
|
## Production Composition And Change Checklist
|
|
|
|
|
|
|
|
|
|
The CLI invokes generic, Seriatim, and D&D registrars. They register typed modules,
|
|
|
|
|
codecs, evidence, and owned validator defaults, not prompts/schemas/profiles.
|
|
|
|
|
[Seriatim](../integrations/seriatim.md) retains input-format ownership; generic
|
|
|
|
|
operations remain domain-neutral; D&D does not compose process behavior.
|
|
|
|
|
|
|
|
|
|
For an extension, add the typed domain/codec boundary, strict options and spec,
|
|
|
|
|
native declarations/static dependencies where needed, stage implementation,
|
|
|
|
|
and owning registrar entry. Add default chains only where the family owns them.
|
|
|
|
|
Reference slots declare artifact/media/size requirements; generated handoffs
|
|
|
|
|
must retain prior-step compatibility. Preserve ownership of request maps/slices
|
|
|
|
|
and returned stored data. Modules receive no physical roots or CLI reporters.
|
|
|
|
|
|
|
|
|
|
Update canonical [keys/chains](../config.md#production-validator-keys-and-default-chains)
|
|
|
|
|
and durable contracts when their behavior changes; complete runnable configurations
|
|
|
|
|
belong in [examples](../../examples/). Test the actual leaf and registration path,
|
|
|
|
|
exact-type compatibility, domain invariants, fixed-input correction, unavailable/
|
|
|
|
|
failed outcomes, supported fallback, and cancellation where applicable.
|
|
|
|
|
[Spell tests](../../internal/modules/dnd/extract/spells/extractor_test.go),
|
|
|
|
|
[item normalization tests](../../internal/modules/dnd/normalize/itemregistry/normalizer_test.go),
|
|
|
|
|
and [registration dependencies](../../internal/modules/dnd/register/dependencies_test.go)
|
|
|
|
|
are concrete starting points. Use real kits with native provider fakes, not a
|
|
|
|
|
replacement completion mock or full prompt-prose snapshots.
|
|
|
|
|
[Development](../development.md#validation) owns wider checks.
|