Skip to main content

expand_reduction

Function expand_reduction 

Source
pub fn expand_reduction(
    log: &ReductionLog,
    minted_view: &[ChatMessage],
    recorded: Option<&[ChatMessage]>,
    id: &str,
    byte_range: Option<(usize, usize)>,
) -> Result<ExpandOutcome, ReductionError>
Expand description

Resolve the expand_reduction(reduction_id, byte_range?) agent intrinsic (SPEC.md TR-1 dev/01): the exact original bytes behind reduction id in log, resolved against minted_view (hash-verified) with recorded preferred for cap-diverged content — see the module doc comment for the two-source contract. With byte_range = Some((start, end)), just that [start, end) slice (end clamped to total_bytes, char-boundary-safe).

Errors, all model-recoverable:

  • unknown id → names every currently-valid id (mirrors C4’s /expand error style);
  • reversed range (start > end) or start beyond the original’s total bytes → names the expected [start, end) form and the true total_bytes, rather than ever silently returning empty or full content the caller didn’t ask for.