Skip to main content

RecallQueryShape

Struct RecallQueryShape 

Source
pub struct RecallQueryShape {
    pub original_tokens: usize,
    pub sent_tokens: usize,
    pub sent_tokens_max: usize,
    pub budget_tokens: usize,
    pub envelope_stripped: bool,
    pub units_dropped: usize,
}
Expand description

What shaping did to the recall query before it was embedded (#4972).

Why: the query used to go to the embedder whole and come back cut at the 512-token window with “no warning, no metric, and no signal to the caller” — the defect as filed. This struct is the metric. It rides the enriched- prompt log line, which is the same corpus the 52%-over-window rate was measured from, so the rate after the fix is two jq filters away: select(.recall_query.units_dropped > 0) for queries this module reduced, and select(.recall_query.sent_tokens_max > .recall_query.budget_tokens) for sends whose fit inside the window could not be proven. What: token estimates before and after shaping, the ceiling on what was sent, the budget in force, and what was removed. Absent from the JSON when no palace was resolved and no recall was attempted. Test: single_event_roundtrip covers serialisation; prompt_context::tests::over_window_query_is_reduced_to_whole_units covers the values.

Fields§

§original_tokens: usize

Estimated tokens in the raw prompt, before any shaping.

§sent_tokens: usize

Estimated tokens actually sent to /recall.

§sent_tokens_max: usize

Upper bound on the true tokens sent (#4972).

Why: sent_tokens charges ASCII-letter runs by a calibrated divisor, which no divisor above 1 token per character can make a bound. Without this field a shape reporting sent_tokens: 490, units_dropped: 0 asserts a clean pass on a query the embedder may have cut — the metric reading healthy while the loss happens. What: prompt_context::query::max_tokens of the sent text. #[serde(default)] so log lines written before this field parse back.

§budget_tokens: usize

Token budget in force for this firing.

§envelope_stripped: bool

Whether a task-notification envelope was reduced to its payload.

§units_dropped: usize

Whole units (lines, or words) dropped to fit the budget. On the last-resort character path the unit is the character.

Implementations§

Source§

impl RecallQueryShape

Source

pub fn reshaped(&self) -> bool

True when shaping changed the query the embedder saw.

Why: the pass-through case is the common one and must stay quiet — a warn on every firing is a warn nobody reads. What: envelope_stripped || units_dropped > 0. Test: prompt_context::tests::short_query_passes_through_untouched.

Source

pub fn may_exceed_window(&self) -> bool

True when the sent query is not provably inside the embedder window.

Why (#4972, round-3 review): sent_tokens <= budget_tokens is an estimate clearing a budget, not a proof, and treating it as one is what let a reshaped query still overrun the window while the log reported the reduction as a success. This is the honest complement — false means the send fits, full stop; true means it may have been cut and the shape declines to claim otherwise. What: sent_tokens_max > budget_tokens. Test: prompt_context::tests::shape_flags_a_send_it_cannot_prove_fits.

Trait Implementations§

Source§

impl Clone for RecallQueryShape

Source§

fn clone(&self) -> RecallQueryShape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RecallQueryShape

Source§

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

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

impl Default for RecallQueryShape

Source§

fn default() -> RecallQueryShape

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

impl<'de> Deserialize<'de> for RecallQueryShape

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for RecallQueryShape

Source§

impl PartialEq for RecallQueryShape

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for RecallQueryShape

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RecallQueryShape

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more