Skip to main content

dedup_cross_provider

Function dedup_cross_provider 

Source
pub fn dedup_cross_provider<'a, I>(frames: I) -> Deduped
where I: IntoIterator<Item = (&'a str, &'a ContextFrame)>,
Expand description

Collapse the same evidence arriving from more than one provider into a single frame, keeping the higher-scored copy and merging provenance — the cross-provider dedup compose_context’s identity-only dedup cannot do (issue #15). Wire this in before compose_context: frame id is provider-scoped, so two providers returning the same file region under different ids survive the identity dedup as two blocks.

Two frames are the same evidence when:

  1. they carry the same content_digest (both present and equal) — the provider-declared hash of the exact bytes; or, failing that,
  2. their provenance overlaps: they name a file region at the same uri and the same range (both absent counts as the whole resource).

The survivor is the higher-scored frame, ties broken by canonical FrameId so the result is a pure function of the input set — independent of arrival order, which is what keeps the downstream composition byte-stable. The survivor’s provenance becomes the de-duplicated union of the group’s provenance, so a citation still points at every source that vouched for the evidence.