Skip to main content

invert_messages

Function invert_messages 

Source
pub fn invert_messages(
    reduced: &[ChatMessage],
    log: &ReductionLog,
    sidecar_messages: &[ChatMessage],
) -> Result<Vec<ChatMessage>, ReductionError>
Expand description

Reconstruct the full view: every placeholder in reduced replaced by the original content resolved from sidecar_session (the ONE canonical model — a canonical message slice reconstructed from its sidecar), hash-verified against SidecarPtr::content_hash before ever substituting it in.

Fails loudly (Err) rather than silently partial: on any reduced message whose sc.reduction id has no matching entry in log (an unresolvable pointer — e.g. the log entry was deleted), on any pointer that no longer resolves in the sidecar, or on any hash mismatch (a stale/foreign/tampered sidecar).

Strips the sc.reduction bookkeeping key from every message’s metadata — it never survives inversion.