Refresh native configuration, CLI, and LLM internal guides
This commit is contained in:
@@ -1,363 +1,186 @@
|
||||
# LLM Runtime Internals
|
||||
# Native LLM Integration Internals
|
||||
|
||||
`internal/framework/llm` is Notarius’s provider-independent structured
|
||||
completion boundary. It adapts framework requests to PromptKit, bounds
|
||||
provider calls, assembles registered prompt and schema assets, records selected
|
||||
profiles, and redacts provider errors. The architectural boundary is defined in
|
||||
[Architecture](../policy/architecture.md#llm-boundary); profile sources,
|
||||
credentials, and concurrency settings belong in
|
||||
[Configuration](../config.md#promptkit-profiles) and
|
||||
[Configuration](../config.md#concurrency-output-cache-and-debug).
|
||||
Model-executing code uses native PromptKit types directly. This guide explains
|
||||
Notarius's integration points, not a private completion service or a copied
|
||||
library manual. [Architecture](../policy/architecture.md#native-execution-boundary)
|
||||
defines the boundary; [Configuration](../config.md#promptkit-profiles) owns
|
||||
resources/settings; [CLI Reference](../cli.md#run-wide-llm-overrides) owns request
|
||||
controls; [Operations](../operations.md) owns state and handling.
|
||||
|
||||
## Structured Completion Boundary
|
||||
## Construction And Ownership
|
||||
|
||||
Modules and LLM-backed validators depend only on
|
||||
`contracts.StructuredLLMClient`. A completion request supplies a prompt ID and
|
||||
version, optional profile and session IDs, named input material, variables, and
|
||||
a caller-owned decode target. The successful response returns the validated raw
|
||||
structured bytes together with non-secret provider, model, profile, and token
|
||||
metadata.
|
||||
The [CLI loader](../../internal/cli/configkit_load.go) hands the original completed
|
||||
ConfigKit application result to `promptkit.NewFromConfig`. One invocation shares
|
||||
the resulting engine across initial producers, corrections, normalization, and
|
||||
LLM validators. Runtime-only HTTP/client settings and an injected native
|
||||
`promptkit.LLMClient` remain construction options, not application YAML.
|
||||
There is no provider-neutral completion conversion or second engine per role.
|
||||
|
||||
The caller owns the domain behavior: it chooses the prompt, prepares inputs,
|
||||
selects the private response schema, and interprets the decoded result. The
|
||||
adapter does not own source evidence, artifact conversion, normalization, or
|
||||
durable schemas. Those responsibilities remain with the module and its
|
||||
[integration contract](../integrations/).
|
||||
[Configuration Internals](configuration.md) owns native definition/source assembly
|
||||
and invocation selection reuse. PromptKit owns captured resources, request
|
||||
preparation, native validation/repair, provider transport, conversation state,
|
||||
and backend admission. See the [upstream Go consumer contract][consumer] for those
|
||||
APIs rather than reproducing their mechanics here.
|
||||
|
||||
The calling module also resolves contextual entity selections and attaches any
|
||||
application identity; PromptKit and this adapter do not own entity identity.
|
||||
Application contracts remain typed production, candidate assessment, supported
|
||||
fallback, and artifact encoding. Pure domain models, codecs, source resolution,
|
||||
and deterministic transforms do not need PromptKit merely because a surrounding
|
||||
operation invokes a model.
|
||||
|
||||
`PromptKitClient` validates the request target and prompt identity, maps each
|
||||
named material to a PromptKit inline artifact while preserving its origin URI,
|
||||
passes the supplied request session through to PromptKit's direct per-run
|
||||
session field, retains the same value as the `session_id` prompt variable for
|
||||
maintained prompt compatibility, and forwards profile selection. It does not
|
||||
derive or replace session values; the CLI owns that policy. It then creates one
|
||||
frozen prepared execution, captures its caller-owned credential-redacted
|
||||
details for debug material, and executes that exact snapshot through
|
||||
PromptKit's prepared-execution boundary. The direct field
|
||||
is authoritative for provider session behavior. A session ID is a stable,
|
||||
non-secret correlation identifier and may be exposed to providers and provider
|
||||
observability. The adapter returns PromptKit’s validated raw bytes rather than
|
||||
re-encoding the decoded target. An empty optional material is represented as
|
||||
one space so its named input is retained by PromptKit.
|
||||
## Requests And Fixed Operation Inputs
|
||||
|
||||
When a request includes semantic correction material, the adapter validates and
|
||||
defensively copies it before preparation, then appends exactly two messages
|
||||
after the ordinarily rendered prompt: the prior response as an assistant
|
||||
message and the correction guidance as a user message. Requests without a
|
||||
correction do not add messages or introduce caller roles. Ordinary request
|
||||
summaries record correction byte counts and digests only; complete messages are
|
||||
available solely in an explicitly requested debug trace.
|
||||
Model modules receive the shared engine during typed preparation. A module
|
||||
prepares transcript, references, contextual identity projections, and any
|
||||
normalization candidate mapping once. It constructs a `promptkit.RunRequest`
|
||||
with its selected prompt, profile/session, native artifact inputs, and variables.
|
||||
Response interpretation consumes `*promptkit.RunResult` and produces the
|
||||
application's typed candidate.
|
||||
|
||||
The adapter leaves the ordinary rendered message prefix, named inputs,
|
||||
variables, session, profile, execution overrides, prepared-execution path, and
|
||||
PromptKit repair policy unchanged for a corrected request. It never imports a
|
||||
PromptKit message type into a module or pipeline contract. PromptKit reports
|
||||
actual structural repair count and cumulative token usage per completion; the
|
||||
pipeline's safe terminal debug record projects those values without copying
|
||||
message content.
|
||||
[Spell extraction](../../internal/modules/dnd/extract/spells/extractor.go) is a
|
||||
representative path: fixed transcript/catalog/NPC projections feed an initial
|
||||
request; native output is decoded and canonically mapped into its durable type.
|
||||
The correction builder selects a paired prompt and supplies current guidance,
|
||||
not another copy of original source/reference material.
|
||||
|
||||
Client construction may also receive a run-wide reasoning-effort override from
|
||||
the CLI factory boundary. The adapter copies the caller-owned pointer and
|
||||
creates a fresh PromptKit execution override for each request: a nil pointer
|
||||
inherits the selected profile, a non-empty value replaces it, and an empty
|
||||
value clears inherited reasoning. The CLI's mutually exclusive
|
||||
`--reasoning-effort` and `--clear-reasoning-effort` controls select those
|
||||
states. With neither flag, profile behavior remains unchanged. Because
|
||||
production constructs one shared client, the selected state applies uniformly
|
||||
to module calls, retries, and LLM-backed validators for the whole run.
|
||||
Domain identity stays deterministic. Contextual selectors and request-local
|
||||
normalization handles resolve against fixed supplied records; models do not
|
||||
acquire authority over durable IDs, citation meaning, or typed artifact shape.
|
||||
[Module Internals](modules.md) and [D&D Internals](dnd.md) own extension/domain
|
||||
recipes.
|
||||
|
||||
An empty request profile lets the prompt select its configured default. Before a
|
||||
run begins, the CLI asks the adapter to inspect every explicit profile on the
|
||||
resolved selected LLM-backed bindings and validators, including inherited
|
||||
pipeline profiles. Inspection resolves the profile and its selected backend and
|
||||
target without preparing a request, reading credentials, admitting capacity, or
|
||||
contacting a provider. Engine construction validates effective prompt definitions
|
||||
and captures message files and static templates. A missing or invalid profile fails before
|
||||
stage execution while a valid `api_key_env` may remain unset. Calls record the
|
||||
profile actually selected by PromptKit. The recorder trims and deduplicates
|
||||
non-secret profile identity, provider, model, selected backend ID, and
|
||||
effective reasoning values for manifest use. Entries that differ in backend or
|
||||
reasoning remain distinct and deterministically ordered. Endpoint-only profiles
|
||||
retain an empty backend ID, which the published JSON omits. Successful
|
||||
completion responses and recorded profile manifests identify the adapter
|
||||
provider as `promptkit`.
|
||||
Native request overrides preserve supplied values without rewriting configured
|
||||
profiles. The producer helper's request composition preserves operation-owned
|
||||
prompt/input/capture fields and existing callbacks; validators pass native
|
||||
execution options explicitly on their own requests.
|
||||
|
||||
The CLI's profile-inspection engine and production adapter use the same source
|
||||
assembly: PromptKit catalogs, one application group containing registered
|
||||
prompts and fallback profiles, the selected operator file or directory, and
|
||||
the optional final `local` backend registration. Execution, preflight, and
|
||||
inspection therefore capture the same effective definitions. PromptKit and
|
||||
ConfigKit compose recursively across groups while retaining each input's file
|
||||
context; inputs within a group compose strictly. Operator imports are enabled
|
||||
for the selected operator input, and imports retain their declaring file's
|
||||
relative resource roots. PromptKit validates final effective definitions at
|
||||
engine construction. It does not run a separate audit that rejects a malformed
|
||||
definition superseded by a later overlay. The D&D registrar contributes its
|
||||
`dnd-extraction` fallback, and maintained D&D prompts select that logical ID
|
||||
by default. A profile selecting `backend: local` can use an operator
|
||||
`backends.local` declaration or the optional Notarius registration; see
|
||||
[native source rules](../config.md#native-promptkit-sources-and-migration).
|
||||
## Native Production And Application Assessment
|
||||
|
||||
This PromptKit integration uses the old-path ConfigKit v0.5.0 types exposed by
|
||||
PromptKit v0.12.0. Application configuration uses the distinct new-path
|
||||
ConfigKit package; those named types do not cross the adapter boundary.
|
||||
[RunProducer](../../internal/framework/pipeline/producer.go) connects ordinary
|
||||
module interpretation/correction/fallback functions to the pipeline assessor.
|
||||
It uses native `Run`, or retained prepared execution on the cache path, then
|
||||
checks errors and public validation status before interpretation. Failed native
|
||||
validation can accompany nil Go error and is not a usable semantic candidate.
|
||||
|
||||
Each engine captures its definitions at construction. A later source-file edit
|
||||
does not mutate an existing engine; constructing a new engine captures the
|
||||
updated view. Before execution, the adapter computes one immutable,
|
||||
versioned `promptkit_configuration` checkpoint identity from public captured
|
||||
inspection APIs. The private digest covers captured effective configuration,
|
||||
all effective profile targets and credential-policy metadata (including
|
||||
provider parameters), and every effective prompt ID/version and captured
|
||||
content hash. The identity also includes PromptKit and the selected OpenRouter
|
||||
and Rakestrawhome catalog versions. Local-backend concurrency settings remain
|
||||
excluded because they affect scheduling; its endpoint is represented only in
|
||||
the private digest, never as checkpoint metadata. Neither the private digest
|
||||
payload, raw sources, paths, endpoints, provider parameters, nor prompt bodies
|
||||
are published. An existing engine retains its identity after files change; a
|
||||
new engine gets the identity of its newly captured definitions. This replaces
|
||||
the former live-file profile and local-endpoint fingerprints. Run manifests
|
||||
remain independent and list only profile choices actually observed during LLM
|
||||
calls.
|
||||
Every usable initial/revised candidate receives the full applicable configured
|
||||
assessment chain once, including unchanged candidates and the final permitted
|
||||
response. Native coordination owns history and additional-turn iteration.
|
||||
Its initial callback uses already collected findings instead of reassessing the
|
||||
initial result. Module templates own correction assignments; detecting modules/
|
||||
validators own actionable guidance, separately from diagnostics.
|
||||
|
||||
## Shared Provider-Call Limit
|
||||
Native execution success is not domain acceptance. Stopped/exhausted outcomes
|
||||
are control facts. Result-less failed continuation does not recover an earlier
|
||||
candidate, and an undelivered response is not assessed or accepted. Caller
|
||||
cancellation stops without fallback. Native timeout/provider/capacity failures
|
||||
remain distinguishable through context state and typed causes.
|
||||
|
||||
Production construction creates one PromptKit client and wraps it in one
|
||||
scheduled client. The scheduler has a fixed, positive permit limit, serves
|
||||
queued calls in FIFO order, and removes a queued call when its context is
|
||||
cancelled. It rechecks the caller context after admission and before dispatch.
|
||||
A granted permit is released exactly once on every completion path.
|
||||
Resolved producer mode chooses terminal handling. A supported permissive fallback
|
||||
must preserve intrinsic/source/downstream invariants without repeating ordinary
|
||||
assessment or claiming semantic approval. Preparation/capture/encoding failures
|
||||
are not reasons to extend model budgets. Detailed assessment/disposition and
|
||||
handoff eligibility belong in [Pipeline Internals](pipeline.md).
|
||||
|
||||
The scheduled wrapper surrounds every `CompleteStructured` call, so concurrent
|
||||
lanes, pipeline retries, and LLM-backed validators share the same provider-call
|
||||
ceiling. This ceiling is independent of pipeline worker concurrency; changing
|
||||
worker counts cannot exceed the configured LLM limit. The configuration field
|
||||
and its effective default are owned by
|
||||
[Configuration](../config.md#concurrency-output-cache-and-debug).
|
||||
## LLM Validators
|
||||
|
||||
PromptKit applies a second, independent admission limit when the selected
|
||||
profile names a limited backend. It sits beneath the Notarius scheduled client,
|
||||
so it may narrow but cannot expand the application-wide limit. Built-in
|
||||
OpenRouter profiles select PromptKit's reserved backend and its upstream
|
||||
capacity policy. A positive configured local-backend limit bounds active local
|
||||
generations inside PromptKit; zero leaves that backend unlimited there.
|
||||
Endpoint-only profiles do not select a PromptKit backend and remain limited
|
||||
only by the Notarius scheduler.
|
||||
The [combat-semantics validator](../../internal/modules/dnd/validate/scenedescriptions/combat_semantics/validator.go)
|
||||
builds one native request with its own profile and scene-local input. It uses
|
||||
the same engine and run-wide native execution/session selections, then checks
|
||||
the native error/status before decoding.
|
||||
|
||||
Successful interpretation returns a domain judgment and actionable rejection
|
||||
guidance where appropriate. Execution or interpretation failure is unavailable
|
||||
assessment with retained causes, not a semantic defect or invented instructions.
|
||||
Cancellation delivers no judgment. Validators do not coordinate another semantic
|
||||
conversation or rerun themselves to extend structural repair.
|
||||
|
||||
A completed producer/continuation releases native admission before assessment,
|
||||
so a nested validator can use that same limited backend. Application workers
|
||||
and native admission remain independent; there is no second scheduler or queue.
|
||||
Capacity handling follows producer mode, not an additional application retry.
|
||||
|
||||
## Prompt And Schema Assets
|
||||
|
||||
An `AssetRegistry` collects prompt, schema, and optional fallback-profile
|
||||
filesystems from production module families. It retains each registered root's
|
||||
filesystem context when constructing PromptKit's application source group.
|
||||
Schema files are supplied separately through the engine's schema filesystem;
|
||||
PromptKit reads and validates a selected schema while preparing that request,
|
||||
not while constructing the configuration snapshot. Prompt and fallback
|
||||
definitions are validated after native source composition, and referenced
|
||||
prompt content is captured with the engine. Checkpoint identity uses captured
|
||||
prompt content hashes rather than rescanning live files or hashing only
|
||||
content-file paths. Raw paths and bytes are never included. The framework’s
|
||||
`promptfs` helper combines
|
||||
module-selected prompt files with reusable domain fragments without making the
|
||||
framework depend on D&D content.
|
||||
[assets/notarius.yml](../../assets/notarius.yml) imports ordinary embedded
|
||||
initial/correction/validator resources with retained filesystem contexts.
|
||||
The assets package remains a content-only leaf. Prompt declarations own default
|
||||
output format, validation, and schema selections; modules own prompt meaning
|
||||
and small static resource-ID dependencies, not behavioral asset registration.
|
||||
|
||||
LLM-facing content is embedded once by the root `assets` package. Each consumer
|
||||
uses only its scoped subtree, while the module retains ownership of its prompt
|
||||
declaration, ordered manifest, private response-schema identity, and
|
||||
registration. Shared D&D fragments are selected by D&D's shared implementation;
|
||||
the detailed convention is in [D&D Module Internals](dnd.md). This physical
|
||||
arrangement and its data-only boundary are defined by
|
||||
[Architecture](../policy/architecture.md) and
|
||||
[ADR-0011](../adr/0011-centralize-llm-assets.md), rather than by this runtime
|
||||
guide.
|
||||
Each producer pair requests a complete replacement response using its shared
|
||||
schema. Enduring principles live in initial system context; the follow-up
|
||||
supplies current findings and its domain assignment. Normalization applies
|
||||
each complete proposal afresh to fixed originals, not a union of prior groups.
|
||||
|
||||
The generic registrar is the sole production registration owner for the
|
||||
semantic-reconciliation default prompt and private response schema. The
|
||||
domain-neutral reconciliation package also exposes only its mandatory protocol
|
||||
and candidate/transcript presentation files for domain prompt manifests. D&D
|
||||
registry normalizers mount those files while retaining ownership and hashing
|
||||
of their D&D system message, semantic instructions, and complete prompt
|
||||
declaration. The response schema is therefore registered once even though
|
||||
several typed normalizers select it.
|
||||
Native preparation loads selected inline/file/root schemas. Intrinsic durable
|
||||
artifact schemas remain application-owned codec contracts and are not removed
|
||||
with duplicate model-response schema machinery. Full source/root/presence rules
|
||||
belong in [Configuration](../config.md#prompt-output-contracts-and-schemas) and
|
||||
[PromptKit formats][formats].
|
||||
|
||||
Mounted prompt assets determine a module's fingerprint. The fingerprint hashes
|
||||
only the module and shared files explicitly selected by its manifest, so an
|
||||
unrelated asset does not invalidate a checkpoint. Schema loaders validate JSON,
|
||||
attach identity and digest metadata, make defensive copies, and expose
|
||||
diagnostics without raw schema bytes.
|
||||
Native structural repair and transient retries remain upstream-owned. Notarius
|
||||
does not pin omitted counts or wrap them in blanket producer/validator retries.
|
||||
Application semantic allowance is a separate resolved control, not another
|
||||
counter around native coordination.
|
||||
|
||||
Semantic-reconciliation normalizers extend this identity with the shared
|
||||
response-schema digest, framework policy version, and complete limit-policy
|
||||
digest. Their manifest metadata records the same content-free prompt, schema,
|
||||
policy, and limit identities together with domain identity and normalization
|
||||
policies. Request-local handles, source material, proposal content, and raw
|
||||
asset bytes are not checkpoint metadata.
|
||||
## Prepared Execution And Reuse
|
||||
|
||||
Private response schemas validate a model transport envelope. They are not the
|
||||
durable artifact schema and should not be documented as an external wire
|
||||
contract. Durable formats and compatibility rules remain in the
|
||||
[integration contracts](../integrations/).
|
||||
For eligible cacheable producers, the helper prepares the initial request once,
|
||||
retains its details and opaque message-content hash, and either discards the
|
||||
handle on a usable hit or executes that same handle with `RunPrepared`.
|
||||
Unused handles are discarded on exits. Continuation retains the initial key.
|
||||
|
||||
## Prompt Maintenance And Backend Caching
|
||||
Hits decode the accepted application artifact/plan without semantic reassessment,
|
||||
exchange restoration, native execution, or historical usage. Normalizers cache
|
||||
applied artifacts, not proposals. Provider-side prompt-cache hints remain native
|
||||
request metadata, distinct from accepted-result identity. State layout and
|
||||
eligibility mechanics belong in [Run State Internals](state.md), not another
|
||||
LLM cache abstraction. The [prepared execution contract][prepared] owns native
|
||||
handle lifetime and admission behavior.
|
||||
|
||||
Prompt message order and shared asset bytes are runtime behavior. Backend cache
|
||||
reuse depends on identical preceding roles, rendered bytes, and cache-control
|
||||
metadata—not merely equivalent meaning. Keep reusable shared assets
|
||||
byte-identical and preserve each prompt’s declared ordering and cache controls
|
||||
when editing it.
|
||||
## Native Evidence And Sensitive Data
|
||||
|
||||
For sibling prompts that can reuse the same source material, order universal
|
||||
shared context first, request source material next, and module-specific
|
||||
suffixes last. Put a cache boundary at a reusable prefix that is useful to the
|
||||
backend. Redundant intermediate cache boundaries do not extend that reusable
|
||||
prefix and add no value.
|
||||
The runner supplies one invocation execution group. Actual initial, continuation,
|
||||
and nested validator executions enroll once; group observations preserve native
|
||||
identity, terminal coverage, and unknown usage without copied totals or a
|
||||
durable profile inventory.
|
||||
|
||||
Prompt-family owners may choose a different sequence when their inputs and
|
||||
reuse pattern differ. The D&D family’s extraction, scene-chunking, and NPC
|
||||
normalization policies are maintained in [D&D Module Internals](dnd.md#prompt-construction).
|
||||
Do not add tests that enforce prompt prose; prompt tests should verify the
|
||||
meaningful input placement and cache controls of the prompt being changed.
|
||||
[Native capture](../../internal/framework/pipeline/native_capture.go) composes
|
||||
observers/preparation callbacks rather than replacing them. Retain prepared
|
||||
details cheaply during callbacks, then write at normal boundaries. Cache paths
|
||||
reuse existing details; debug never triggers a second preparation or model call.
|
||||
Shared callback state is synchronized. Available result-less failure facts and
|
||||
unassessed undelivered responses remain distinguishable.
|
||||
|
||||
## Validation, Repair, And Retries
|
||||
|
||||
PromptKit performs prompt rendering, provider execution, and the prompt’s
|
||||
structured-output validation. The adapter reports an empty result, validation
|
||||
failure, empty structured body, or decode failure as
|
||||
`ErrInvalidStructuredOutput`, while retaining the returned raw bytes and debug
|
||||
material when they exist. Provider failures remain operational errors rather
|
||||
than output-validation failures. Apart from documented context, capacity, and
|
||||
invalid-output categories, provider error values and types do not cross the
|
||||
adapter error chain; callers receive only a credential-redacted diagnostic.
|
||||
|
||||
`LLMGenerationError` preserves the provider-neutral failure kind (`transport`,
|
||||
`provider_status`, `malformed_response`, or generic `generation`) and any HTTP
|
||||
status. When PromptKit exhausts an eligible transient-status retry budget, it
|
||||
also records that exhaustion and the attempts in that generation. Those fields
|
||||
do not include repair generations, and zero attempts means unavailable rather
|
||||
than proof that no request was sent.
|
||||
|
||||
Every execution that reaches PromptKit returns an optional request-local
|
||||
`execution` summary. It contains only terminal aggregate attempts, retry and
|
||||
repair counts, durations, outcome and failure classification, status, and
|
||||
presence-aware token usage. Preparation failures have no summary; later local
|
||||
decode failures retain the upstream terminal summary without changing it.
|
||||
|
||||
When PromptKit rejects backend admission before generation, the adapter maps
|
||||
`promptkit.ErrCapacityExceeded` to
|
||||
`contracts.ErrLLMCapacityExceeded`, retaining prompt context and a redacted
|
||||
upstream diagnostic without exposing the PromptKit sentinel or capacity-error
|
||||
type as a framework contract. When supplied, the normalized selected backend
|
||||
ID appears only in that safe application-owned diagnostic context. A canceled
|
||||
caller context takes precedence. The adapter does not retry capacity failures;
|
||||
the pipeline's existing binding attempt policy sees the operational error and
|
||||
decides whether to rerun the complete operation.
|
||||
|
||||
PromptKit executes structural repair within its structured-output flow. The
|
||||
maintained production prompt manifests declare one additional repair attempt.
|
||||
When a resolved binding supplies a repair value, the adapter inspects the
|
||||
prompt, copies its complete output contract, changes only the repair limit, and
|
||||
passes that complete replacement contract to PromptKit. This preserves the
|
||||
prompt's output format, validation mode, schema, and provider structured-output
|
||||
settings.
|
||||
|
||||
A successful repair is an ordinary successful completion, not a warning. The
|
||||
adapter reports PromptKit's actual repair count and its cumulative usage
|
||||
directly, without adding the initial and corrective counts again. Debug prompt
|
||||
material records the configured complete contract; debug response material
|
||||
records the repaired response and actual validation result. If the repair
|
||||
budget is exhausted, the adapter retains the final raw bytes and debug material
|
||||
and reports `ErrInvalidStructuredOutput`. Generation failures during an initial
|
||||
or corrective call remain provider-neutral operational errors with the same
|
||||
redaction boundary.
|
||||
|
||||
Structural repair does not replace pipeline retry behavior: a binding's
|
||||
configured retry count reruns its complete stage attempt after an operational
|
||||
or structural error, module-requested retry, or actionable semantic rejection.
|
||||
An actionable module-requested retry and a validator rejection both use the
|
||||
same correction payload when the producer exposes an exact latest response;
|
||||
feedback-free module retries reconstruct the ordinary request without appended
|
||||
messages. The pipeline owns attempt lifecycle, validation chains, and retry
|
||||
diagnostics; see
|
||||
[Pipeline Internals](pipeline.md#validation-retries-and-output) and the
|
||||
[binding reference](../config.md#module-bindings-and-validators).
|
||||
|
||||
## Timeout Ownership
|
||||
|
||||
The caller context remains the outer cancellation authority. PromptKit applies
|
||||
a positive effective generation timeout as an inner request deadline for each
|
||||
built-in generation attempt; an explicit zero disables only that generation
|
||||
deadline. The HTTP client timeout is a separate transport-wide cap. Notarius
|
||||
forwards the caller context and does not install another timeout wrapper around
|
||||
PromptKit.
|
||||
|
||||
The selected PromptKit profile owns generation settings. The resolved global
|
||||
`promptkit.transient_retries` configuration is passed to the shared PromptKit
|
||||
engine and controls additional built-in attempts for eligible transient HTTP
|
||||
failures in one generation. It defaults to two; explicit zero disables those
|
||||
attempts. Notarius binding retries remain outside the adapter and repeat the
|
||||
complete module operation and validation chain.
|
||||
Operator-facing behavior is summarized in
|
||||
[Operations](../operations.md#operational-limits), and the pinned upstream
|
||||
contract is identified in
|
||||
[PromptKit Integration](../integrations/pkg-promptkit.md).
|
||||
|
||||
## Observability And Redaction
|
||||
|
||||
When debug recording is enabled, the pipeline decorates the shared client. The
|
||||
wrapper records prepared prompt and response material, timing, selected profile
|
||||
and backend, effective model parameters, and call identifiers in the run’s
|
||||
debug bundle, including material available from a failed structured completion.
|
||||
The profile-inspection CLI projects copied values into its Notarius-owned
|
||||
neutral JSON DTO; effective configuration and explanation remain PromptKit's
|
||||
redacted YAML and source-history views. Credential names and `APIKeyRequired`
|
||||
metadata are configuration metadata, not credential-availability checks.
|
||||
Effective parameters use PromptKit's stable lower-case JSON field names and may
|
||||
include `backend_id`. For a successful completion, a debug-write failure is
|
||||
surfaced; when the completion already failed, its call error remains the
|
||||
result. Debug-bundle location, retention, and handling are operational concerns
|
||||
documented in [Operations](../operations.md#debug-bundles).
|
||||
|
||||
The attempt-terminal summary is a separate safe trace record: it contains
|
||||
attempt kinds, validator outcome counts and reason codes, effective policy,
|
||||
terminal action, and repair/usage references. It excludes raw assistant
|
||||
responses and correction text. Those values can appear only in the explicitly
|
||||
requested detailed prompt and response artifacts, which require sensitive-data
|
||||
handling.
|
||||
|
||||
Run manifests receive selected profile summaries, including optional effective
|
||||
backend and reasoning provenance, and component identities—not prompt, schema,
|
||||
source, reference, or response content. The published field semantics belong
|
||||
to the [JSON output contract](../integrations/json-output.md#manifestjson).
|
||||
Provider error text is wrapped with prompt context and bearer credentials are
|
||||
redacted before it crosses the runtime boundary. Known-secret redaction is
|
||||
available to other runtime collaborators; it does not make prompt or response
|
||||
contents safe for general logging.
|
||||
|
||||
Generation failures expose an application-owned category and optional HTTP
|
||||
status. Provider code, type, and message remain debug-only, after redaction.
|
||||
|
||||
## Failure Boundaries
|
||||
|
||||
- Construction fails for missing asset registries, mutually exclusive profile
|
||||
sources, invalid asset registration, or a non-positive scheduler limit.
|
||||
- Preparation failures, unavailable explicit profiles, provider failures, and
|
||||
context cancellation propagate to the calling stage with context.
|
||||
- Backend admission exhaustion is a provider-neutral operational error and is
|
||||
not classified as invalid structured output or validator rejection.
|
||||
- Malformed or schema-invalid provider output is classified separately as
|
||||
invalid structured output so the module or pipeline can apply its own retry
|
||||
and rejection policy.
|
||||
- Domain semantic checks, evidence decisions, and deterministic normalization
|
||||
run outside the provider adapter.
|
||||
[Run capture](../../internal/cli/run_capture.go) uses secret-aware configuration
|
||||
views and exact marked-secret omissions, while native snapshots preserve credential
|
||||
omissions. Do not heuristically scrub arbitrary source/prompt/response strings.
|
||||
Selected full evidence can be sensitive; private debug representations are not
|
||||
a consumer serialization contract. Recording failures reach application boundaries
|
||||
without retrying model work. [Operations](../operations.md#debug-bundles) owns
|
||||
handling and [State Internals](state.md) owns recorder lifecycle.
|
||||
|
||||
## Focused Verification
|
||||
|
||||
Read the LLM adapter, scheduler, asset registry, schema loader, and redaction
|
||||
tests when changing this boundary. Prompt changes also require the owning
|
||||
module’s asset tests, and retry or debug changes require focused pipeline or
|
||||
CLI coverage. The focused runtime and D&D checks are:
|
||||
Use real kits with a fake native provider or local fake HTTP server, not a
|
||||
replacement completion interface. Relevant owners include:
|
||||
|
||||
~~~sh
|
||||
go test ./internal/framework/llm/... ./internal/modules/dnd/...
|
||||
~~~
|
||||
- [Native loading](../../internal/cli/native_load_test.go) and
|
||||
[schema overrides](../../internal/cli/native_schema_load_test.go).
|
||||
- [Producer/continuation tests](../../internal/framework/pipeline/producer_test.go),
|
||||
[ordered assessment](../../internal/framework/pipeline/candidate_assessment_test.go),
|
||||
and [nested native validation](../../internal/framework/pipeline/native_assessment_test.go).
|
||||
- [Accepted-result reuse](../../internal/framework/pipeline/producer_cache_test.go)
|
||||
and [native capture](../../internal/framework/pipeline/native_capture_test.go).
|
||||
- [Representative extraction](../../internal/modules/dnd/extract/spells/extractor_test.go)
|
||||
and [validator execution](../../internal/modules/dnd/validate/scenedescriptions/combat_semantics/native_execution_test.go).
|
||||
- [Assembled recovery](../../internal/cli/recovery_contract_test.go) and
|
||||
[real executable checks](../../internal/cli/native_process_test.go).
|
||||
|
||||
These verify native status/causes, complete assessment, fixed inputs/history,
|
||||
override propagation, cancellation/admission, reuse, and evidence. They do not
|
||||
claim production model quality. Wider checks belong in
|
||||
[Development](../development.md#validation).
|
||||
|
||||
[consumer]: https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.24.0/docs/consumers/pkg-promptkit.md
|
||||
[formats]: https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.24.0/docs/formats.md
|
||||
[prepared]: https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.24.0/docs/consumers/pkg-promptkit.md#prepare-now-and-execute-the-same-snapshot-later
|
||||
|
||||
Reference in New Issue
Block a user