core:kiln
Kiln stdlib entry point.
Import the user-facing Kiln types and the KilnHost effect via
use { ... } from "core:kiln". This facade re-exports the WIT-generated
submodules under lib/core/kiln/ and adds the Wado-only Request<T>
wrapper that generator authors write against.
See WEP 2026-04-12 (Kiln) §"The kiln world" and §"Protocol revision v0.3".
Effects
pub interface KilnHost
Host interface exposed to Kiln generators. Deliberately narrow:
no clocks, no random, no network, no filesystem beyond read-file.
See WEP 2026-04-12 (Kiln) §"The kiln world".
fn read_file(path: String) -> Result<String, HostError>
Read a file from the compiler's CompilerHost. Paths are resolved
relative to the invocation's declaration site (manifest directory
or the source file containing a use ... with). Every call is
recorded and contributes to the invocation cache key.
fn emit_diagnostic(diagnostic: Diagnostic)
Report a diagnostic that will be surfaced as a normal compile diagnostic. Multiple diagnostics may be reported; they are all printed even if the generator eventually returns a successful response.
Structs
pub struct NoOptions
The options type of a generator that takes no configuration. It is the
default type argument of Request, so a generator with no Options
struct writes fn generate(req: Request) and never mentions options.
Its CBOR wire form is the empty map, which decodes back into NoOptions.
pub struct Request<T = NoOptions>
The typed request a Kiln generator receives. Generator authors write
export fn generate(req: Request<Options>) -> Result<Response, Error>
(or Request for a no-options generator).
Request<T> is Wado-only sugar and never crosses the WIT boundary as a
single record: a generic cannot be expressed in a fixed WIT world (that is
why generators do not share one world). The compiler rewrites
fn generate(req: Request<T>) into flat, typed parameters
(primary: InputFile, inputs: List<InputFile>, options: T) in the
generator's own synthesized world, then rebinds them into a Request<T>
value so the author's body sees req unchanged. options crosses as a
typed WIT argument, not a serialized blob. The #[compiler_item("kiln_request")]
attribute is that rewrite's lookup anchor. T defaults to NoOptions, so
a generator that takes no options writes fn generate(req: Request).
See WEP 2026-04-12 §"Protocol revision v0.3".
primary: InputFile
inputs: List<InputFile>
options: T
pub struct SourceSpan
A span into any file the generator has read, or into a file the
generator knows about by other means. The compiler renders the
snippet by consulting CompilerHost.
path: String
byte_start: u32
byte_end: u32
pub struct Diagnostic
level: DiagnosticLevel
span: Option<SourceSpan>
message: String
pub struct InputFile
One schema file the compiler has pre-loaded for the generator. The file is always supplied by value so that the initial input set is fully determined by the invocation declaration.
path: String
content: String
pub struct OutputFile
One generated Wado file. path is relative to the invocation's
output directory (defaults to build/kiln/<invocation-name>/).
Exactly one output file must be the entry module; supplementary
files are referenced from the entry via ordinary Wado use.
