2.1 KiB
Prepared Report Internals
internal/app validates the report's generated-text catalog binding during
prompt inspection, before collection, and carries the resulting handler into
preparedReport construction after collection. This is the immutable boundary
shared by ordinary report generation and profile comparison; it is not a
durable artifact.
Preparation first establishes one PreparedIdentity for the report run, report
and prompt IDs, variant, generation time, units, timezone, valid period,
location, and source warnings. It passes that identity to the configured module
snapshot, curated prompt-input package, serialized YAML, generated-text render
context, and generated-text definition. Each boundary projects only the fields
it needs from that prepared authority.
Preparation deep-copies mutable facts, snapshots, identity, and data-package bytes before returning them. Consumers receive independent copies so one execution cannot change another's input or rendering context.
Before accepting generated JSON, the execution boundary reconciles the prepared report definition, inspected prompt hash and selected profile identity, the one preparation callback, and the completed Promptkit result. The callback and completion must agree on prompt, profile, backend, model, and rendered/input hashes; the callback output and completed validation must name the prepared report's JSON Schema. A mismatch produces no rendered Markdown and leaves results with only the inspected safe identity.
Single-report generation executes one prepared profile and publishes its Markdown. Comparison prepares once, gives every selected profile the same YAML bytes, and only then assembles the resulting logical bundle. The prompt-input shape is owned by prompt-input internals; profile execution semantics are owned by Promptkit integration.
Catalog incompatibility stops prompt inspection before weather collection or model work. Preparation failure has no publication side effects. Tests for this boundary cover catalog-preflight ordering, mutation isolation, byte equality, and reuse by both execution paths.