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 (
fold_to_edges) — deal 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.
Ranking across providers by raw score is a host policy choice, not a
protocol guarantee (SPEC.md §6.6, F10) — see order_by_value. Use
compose_for_prompt_with to pick a different one.
This entry point checks no attestations, so every entry’s
attestation is
AttestationState::NotChecked. Use compose_for_prompt_attested — or
FanOut::compose_for_prompt, which
passes the fan-out’s own ledger — to record what the host found.