Skip to main content

compose_for_prompt_with

Function compose_for_prompt_with 

Source
pub fn compose_for_prompt_with<'a, I, S>(
    frames: I,
    global_budget: u32,
    strategy: &S,
) -> ComposedPrompt
where I: IntoIterator<Item = (&'a str, &'a ContextFrame)>, S: RankingStrategy + ?Sized,
Expand description

compose_for_prompt under an explicit cross-provider ranking policy (SPEC.md §6.6, F10).

The strategy orders the de-duplicated survivors, and that order is what the budget packer walks — so it decides which frames reach the prompt, not only where they sit in it. That is the half that matters: under a tight budget, ranking the union by raw score can spend the whole budget on the provider whose retriever reports the largest numbers and cite nothing from anyone else. ranking::RoundRobinByRank and ranking::PerProviderQuota are two policies that do not, and neither needs configuring.

A strategy cannot break the budget bound or the audit: it ranks, and the packer still includes a frame only while its canonical token cost fits, excluding the rest with a recorded reason.

Checks no attestations; see compose_for_prompt_attested.