Lmml.Narrative.Resolver (Lmml v0.1.0)

View Source

Resolves every embed a bundle's narrative mentions against the bundle itself, producing a fully-resolved intermediate structure that pairs each Lmml.Embed with its actual bytes -- trivially for an inline embed (its bytes are already its own content) and by zip-entry lookup for an external reference (Lmml.Bundle.embed/2).

This is deliberately the only place bundle access happens on the way to an LLM-ready payload: Lmml.Narrative.Renderer consumes a t/0 produced here and needs no further knowledge of Lmml.Bundle at all.

Summary

Types

One embed paired with its actually-resolved bytes.

t()

Functions

Resolves every embed bundle's narrative mentions (each distinct name once, in first-occurrence order -- see Lmml.Document.embed_names/1).

Same as resolve/1, but raises on failure.

Types

resolved_embed()

@type resolved_embed() :: %{embed: Lmml.Embed.t(), content: binary()}

One embed paired with its actually-resolved bytes.

t()

@type t() :: %Lmml.Narrative.Resolver{embeds: [resolved_embed()], narrative: binary()}

Functions

resolve(bundle)

@spec resolve(Lmml.Bundle.t()) :: {:ok, t()} | {:error, term()}

Resolves every embed bundle's narrative mentions (each distinct name once, in first-occurrence order -- see Lmml.Document.embed_names/1).

Fails on the first embed that cannot be resolved (a dangling @name.ext reference, or one pointing outside the bundle) rather than silently dropping it or returning a partial result: a narrative meant for an LLM call should either be fully resolved or not sent at all.

resolve!(bundle)

@spec resolve!(Lmml.Bundle.t()) :: t()

Same as resolve/1, but raises on failure.