pub struct CompressionEvent {
pub ts: String,
pub session_id: Option<String>,
pub surface: String,
pub surface_detail: String,
pub tokens_before: usize,
pub tokens_after: usize,
pub ratio: f64,
pub working_context_pct_after: Option<u8>,
pub overhead_pct_after: Option<u8>,
pub compaction_event: bool,
pub duration_ms: u64,
pub rounds: usize,
}Expand description
One JSONL line: a single compression/summarization event (issue #3867).
Why: a flat, all-primitive shape keeps the log trivially grep-able and
loadable into jq/pandas/DuckDB for Slice C’s report, and lets every field
be asserted individually in tests without a custom deserializer.
What: field names and semantics match issue #3867’s schema exactly — see
the issue body for the authoritative field-by-field spec. ratio is
tokens_after / tokens_before, 0.0 when tokens_before == 0 (never a
divide-by-zero or NaN, mirroring tm compress’s log_compression_stats
guard). working_context_pct_after/overhead_pct_after are None for
surfaces with no CadenceOutcome to derive them from (agents-ws-summary
per the issue; this crate never emits that surface).
Test: tests::compression_event_serializes_expected_schema,
tests::ratio_guards_divide_by_zero.
Fields§
§ts: String§session_id: Option<String>§surface: String§surface_detail: String§tokens_before: usize§tokens_after: usize§ratio: f64§working_context_pct_after: Option<u8>§overhead_pct_after: Option<u8>§compaction_event: bool§duration_ms: u64§rounds: usizeImplementations§
Source§impl CompressionEvent
impl CompressionEvent
Sourcepub fn new(
session_id: Option<String>,
surface: &str,
surface_detail: &str,
tokens_before: usize,
tokens_after: usize,
working_context_pct_after: Option<u8>,
overhead_pct_after: Option<u8>,
compaction_event: bool,
duration_ms: u64,
rounds: usize,
) -> Self
pub fn new( session_id: Option<String>, surface: &str, surface_detail: &str, tokens_before: usize, tokens_after: usize, working_context_pct_after: Option<u8>, overhead_pct_after: Option<u8>, compaction_event: bool, duration_ms: u64, rounds: usize, ) -> Self
Build a record with ts set to “now” (RFC3339 UTC, matching
trusty-agents::usage::UsageRecord.ts’s convention) and ratio
derived via compute_ratio.
Trait Implementations§
Source§impl Clone for CompressionEvent
impl Clone for CompressionEvent
Source§impl Debug for CompressionEvent
impl Debug for CompressionEvent
Source§impl<'de> Deserialize<'de> for CompressionEvent
impl<'de> Deserialize<'de> for CompressionEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CompressionEvent
impl PartialEq for CompressionEvent
Source§impl Serialize for CompressionEvent
impl Serialize for CompressionEvent
impl StructuralPartialEq for CompressionEvent
Auto Trait Implementations§
impl Freeze for CompressionEvent
impl RefUnwindSafe for CompressionEvent
impl Send for CompressionEvent
impl Sync for CompressionEvent
impl Unpin for CompressionEvent
impl UnsafeUnpin for CompressionEvent
impl UnwindSafe for CompressionEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more