pub struct EncoderTrace {Show 18 fields
pub term_substitutions: u32,
pub if_prefix: u32,
pub success: u32,
pub failure: u32,
pub arrow: u32,
pub vs: u32,
pub and: u32,
pub filler_removed: u32,
pub ansi_stripped: u32,
pub trailing_ws: u32,
pub blank_lines: u32,
pub json_minified: u32,
pub json_records_table: u32,
pub numeric_range_lines: u32,
pub repeated_chunk_dict: u32,
pub repeated_lines: u32,
pub tool_schema_semantic_table: u32,
pub bytes_saved: [u64; 17],
}Expand description
Per-rule fire counts emitted alongside an encode pass.
Each field counts how many match instances the rule produced on
this input. A non-firing rule reports 0; rules with no semantic
effect on a given input are useful exactly because they cost
nothing to evaluate. Use EncoderTrace::any_fired to gate
telemetry on whether the encoder did real work.
Fields§
§term_substitutions: u32Total term-substitution match count across the 35-pair table.
if_prefix: u32Number of if prefix removals.
success: u32Success-glyph (\u{2713}) substitutions.
failure: u32Failure-glyph (\u{2717}) substitutions.
arrow: u32Arrow-glyph (\u{2192}) substitutions.
vs: u32vs substitutions.
and: u32+ substitutions for and/plus.
filler_removed: u32Number of filler words removed.
ansi_stripped: u32Number of ANSI-escape sequences stripped from tool_result
content blocks. Applied shim-side before the encoder runs to
claw back tokens burned on terminal-color bytes the LLM never
needs to see. Lossless for model consumption.
trailing_ws: u32Number of lines where trailing [ \t]+ was removed from
tool_result content. Pure-waste whitespace that tokenizes
into real input-billed tokens; LLMs ignore trailing spaces
semantically. Lossless for model consumption.
blank_lines: u32Number of excess blank lines collapsed in tool_result
content. Runs of 3+ consecutive \n are squeezed to exactly
two (one blank line preserved as a paragraph break). Preserves
semantic section separation while dropping layout-only padding.
json_minified: u32Number of JSON string payloads minified inside tool_result
content. Lossless for valid JSON: only insignificant whitespace
is removed.
json_records_table: u32Number of homogeneous JSON record arrays rendered as compact
TOON-like tables inside tool_result content. This preserves
field names and scalar values but is no longer JSON syntax, so
it is canary-only by default.
numeric_range_lines: u32Number of numeric line ranges compacted in tool_result
content. This is deterministic for lines that differ only by
an incrementing number.
repeated_chunk_dict: u32Number of repeated chunk dictionaries emitted in tool_result
content. Repeated log lines/sentences are represented once plus
an explicit sequence, preserving reconstruction information.
repeated_lines: u32Number of consecutive repeated-line runs collapsed in
tool_result content. Repetition count is preserved as xN,
so log volume is compacted without hiding that repetition
occurred.
tool_schema_semantic_table: u32Number of simple tool-schema payloads rendered as compact semantic tables. Preserves tool name, description, required parameters, and property schemas for the supported simple schema subset; canary-only by default.
bytes_saved: [u64; 17]Per-rule byte-savings attribution, indexed identically to the
pairs returned by as_pairs (alphabetical by rule name).
PLAN_2026-04-24.md Step 9 substrate. Each entry is the UTF-8 byte count a rule removed from the payload on THIS encoder pass — pre-rule body length minus post-rule body length. A non-firing rule contributes 0. Rules that never fire on a given input contribute 0, so zero-valued entries are signal, not noise.
Default is an all-zero array (matches the default-non-firing
trace). The actual per-rule measurement hooks inside
encode_symbolic_traced_with will land in a follow-up commit
so this schema can deploy without the rule-pass refactor. Until
then, callers SHOULD treat any bytes_saved they read as “may
be zero because the rule did not run OR because the measurement
hook is not yet wired” — any_fired() on the same trace is the
disambiguator.
Implementations§
Source§impl EncoderTrace
impl EncoderTrace
Sourcepub const IDX_AND: usize = 0
pub const IDX_AND: usize = 0
Positional index of each rule in bytes_saved / as_pairs.
Alphabetically ordered, so adding a new rule between existing
ones shifts subsequent indices — readers MUST use these
constants instead of hardcoded integers. Step-9 scaffold.
pub const IDX_ANSI_STRIPPED: usize = 1
pub const IDX_ARROW: usize = 2
pub const IDX_BLANK_LINES: usize = 3
pub const IDX_FAILURE: usize = 4
pub const IDX_FILLER_REMOVED: usize = 5
pub const IDX_IF_PREFIX: usize = 6
pub const IDX_JSON_MINIFIED: usize = 7
pub const IDX_JSON_RECORDS_TABLE: usize = 8
pub const IDX_NUMERIC_RANGE_LINES: usize = 9
pub const IDX_REPEATED_CHUNK_DICT: usize = 10
pub const IDX_REPEATED_LINES: usize = 11
pub const IDX_SUCCESS: usize = 12
pub const IDX_TERM_SUBSTITUTIONS: usize = 13
pub const IDX_TOOL_SCHEMA_SEMANTIC_TABLE: usize = 14
pub const IDX_TRAILING_WS: usize = 15
pub const IDX_VS: usize = 16
Sourcepub fn any_fired(&self) -> bool
pub fn any_fired(&self) -> bool
True if any rule produced at least one substitution or removal.
Sourcepub fn bytes_saved_pairs(&self) -> [(&'static str, u64); 17]
pub fn bytes_saved_pairs(&self) -> [(&'static str, u64); 17]
Render byte-savings attribution as a stable, sorted list of
(rule_name, bytes_saved) pairs. Positional order matches
as_pairs; non-firing rules contribute 0. Added with Step 9.
Pairs with as_pairs for post-hoc analysis: counts tell you
HOW OFTEN each rule fired, bytes_saved tells you WHICH BYTES
each rule removed. Combined they let the bandit attribute
savings to specific rules without re-running the encoder.
Sourcepub fn as_pairs(&self) -> [(&'static str, u32); 17]
pub fn as_pairs(&self) -> [(&'static str, u32); 17]
Render as a stable, sorted list of (rule_name, count) pairs.
Used by pithy-cli analyze and the audit ledger so a
future rule rename does not break replay.
Sourcepub fn merge(&mut self, other: EncoderTrace)
pub fn merge(&mut self, other: EncoderTrace)
Sum-merge fire counts from other into self. Used by the
structural encoder to aggregate traces across compressed
paragraph segments.
Trait Implementations§
Source§impl Clone for EncoderTrace
impl Clone for EncoderTrace
Source§fn clone(&self) -> EncoderTrace
fn clone(&self) -> EncoderTrace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EncoderTrace
impl Debug for EncoderTrace
Source§impl Default for EncoderTrace
impl Default for EncoderTrace
Source§fn default() -> EncoderTrace
fn default() -> EncoderTrace
Source§impl PartialEq for EncoderTrace
impl PartialEq for EncoderTrace
impl Eq for EncoderTrace
impl StructuralPartialEq for EncoderTrace
Auto Trait Implementations§
impl Freeze for EncoderTrace
impl RefUnwindSafe for EncoderTrace
impl Send for EncoderTrace
impl Sync for EncoderTrace
impl Unpin for EncoderTrace
impl UnsafeUnpin for EncoderTrace
impl UnwindSafe for EncoderTrace
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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