1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! The transcript serving boundary's envelope reconstruction.
//!
//! Provider response envelopes are persisted compacted: a turn's first frame in full, its later
//! frames as deltas against it (see `aion_integrations::envelope_delta` for why, and for the
//! measurements that motivated it). That is a **storage** representation. Every surface that
//! serves a transcript — the WebSocket stream, the REST fetch, the MCP transcript tool, the
//! live-describe projection — reconstructs the full envelopes here, so no consumer downstream of
//! this boundary can tell a compacted stream from an uncompacted one.
//!
//! Reconstructing in one place, at the edge, is deliberate. The alternative is every consumer
//! learning the delta format — the CLI, the ops console's TypeScript, the MCP tool, and anything
//! written later — which is four implementations of one format and four chances for them to drift.
//!
//! # Order matters, and it is the caller's job
//!
//! A delta resolves only against a base the decoder has already been shown. Feed a decoder the
//! records of ONE stream in ascending `store_seq`, which is the order every read path here already
//! produces, and resolve BEFORE windowing rather than after: a window that opens mid-turn would
//! otherwise discard the very base its first delta needs.
//!
//! # What cannot be reconstructed is said, never guessed
//!
//! A window that genuinely begins after its turn's base — because retention trimmed the base, or
//! because the caller resumed from a cursor inside a turn — yields a delta this boundary cannot
//! resolve. Those are returned to the caller, which logs them; the event is served with its delta
//! document intact, carrying every field that actually changed. Nothing is fabricated, and nothing
//! is dropped.
use ActivityEvent;
use ;
use ActivityRecord;
/// Reconstructs one event in place, returning the report when a delta could not be resolved.
///
/// For the streaming paths, which see one event at a time and must hold their own decoder for the
/// life of the socket so a live frame can resolve against a base delivered during replay.
pub
/// Reconstructs a whole read of one stream in place, returning every delta it could not resolve.
///
/// For the windowed paths, which read a range and then narrow it. Call this on the records as
/// read, before any narrowing.
pub
/// Records the deltas a read could not reconstruct.
///
/// A window opening inside a turn is ordinary and expected, so this is a debug-level note naming
/// the stream and each unresolvable base — enough to explain an operator's "why is this frame a
/// delta document?" without turning a routine window boundary into a warning.
pub