pub fn compose_for_prompt<'a, I>(
frames: I,
global_budget: u32,
) -> ComposedPromptExpand description
Compose an accepted frame set into a prompt-ready block: the R3 preamble,
the value-ordered fenced frames, a citation map, and a CompositionAudit
that explains every included and excluded frame (issue #15). This is the
reference answer to “the host has honest frames — now what?”, layered on
compose_context’s [render_frame] so the fencing and escaping are
identical to the determinism floor.
The pipeline, in order:
- Dedup (
dedup_cross_provider) — collapse the same evidence from two providers, keeping the higher-scored copy; the losers are excluded withExclusionReason::Duplicate. - Budget-pack — walk the survivors highest-value first and include each
whose canonical token cost still fits
global_budget; the rest are excluded withExclusionReason::OverBudget. This is what makestokens_used <= global_budgeta guarantee rather than a hope. - Place (
order_by_value) — order the included frames so the highest-value ones sit at the top/bottom edges (Lost in the Middle). - Render — the preamble, then each frame through [
render_frame], so a content-embedded</frame>still cannot break out of its fence.
The audit is a total partition of the input: every offered frame appears once, included-with-verification-state or excluded-with-reason.