Skip to main content

EncoderTrace

Struct EncoderTrace 

Source
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: u32

Total term-substitution match count across the 35-pair table.

§if_prefix: u32

Number of if prefix removals.

§success: u32

Success-glyph (\u{2713}) substitutions.

§failure: u32

Failure-glyph (\u{2717}) substitutions.

§arrow: u32

Arrow-glyph (\u{2192}) substitutions.

§vs: u32

vs substitutions.

§and: u32

+ substitutions for and/plus.

§filler_removed: u32

Number of filler words removed.

§ansi_stripped: u32

Number 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: u32

Number 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: u32

Number 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: u32

Number of JSON string payloads minified inside tool_result content. Lossless for valid JSON: only insignificant whitespace is removed.

§json_records_table: u32

Number 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: u32

Number of numeric line ranges compacted in tool_result content. This is deterministic for lines that differ only by an incrementing number.

§repeated_chunk_dict: u32

Number 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: u32

Number 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: u32

Number 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

Source

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.

Source

pub const IDX_ANSI_STRIPPED: usize = 1

Source

pub const IDX_ARROW: usize = 2

Source

pub const IDX_BLANK_LINES: usize = 3

Source

pub const IDX_FAILURE: usize = 4

Source

pub const IDX_FILLER_REMOVED: usize = 5

Source

pub const IDX_IF_PREFIX: usize = 6

Source

pub const IDX_JSON_MINIFIED: usize = 7

Source

pub const IDX_JSON_RECORDS_TABLE: usize = 8

Source

pub const IDX_NUMERIC_RANGE_LINES: usize = 9

Source

pub const IDX_REPEATED_CHUNK_DICT: usize = 10

Source

pub const IDX_REPEATED_LINES: usize = 11

Source

pub const IDX_SUCCESS: usize = 12

Source

pub const IDX_TERM_SUBSTITUTIONS: usize = 13

Source

pub const IDX_TOOL_SCHEMA_SEMANTIC_TABLE: usize = 14

Source

pub const IDX_TRAILING_WS: usize = 15

Source

pub const IDX_VS: usize = 16

Source

pub fn any_fired(&self) -> bool

True if any rule produced at least one substitution or removal.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> EncoderTrace

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncoderTrace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EncoderTrace

Source§

fn default() -> EncoderTrace

Returns the “default value” for a type. Read more
Source§

impl PartialEq for EncoderTrace

Source§

fn eq(&self, other: &EncoderTrace) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for EncoderTrace

Source§

impl StructuralPartialEq for EncoderTrace

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V