Skip to main content

InferenceBudget

Struct InferenceBudget 

Source
pub struct InferenceBudget {
    pub extract_latency_budget_ms: u32,
    pub max_inference_ms_per_commit: u32,
    pub max_phrases_embedded: u32,
    pub max_types: u32,
    pub author_rate_limit_per_commit: u32,
}
Expand description

Shared primitive: wall-clock and volume caps for the inference stage of a single commit.

All fields are floor-c tunables (solution.md R6 §Constant classification table) or corpus-derived. No magic numbers.

Fields§

§extract_latency_budget_ms: u32

Rolling wall-clock budget for the extract-and-embed phase of inference, derived from 3 * rolling.p50_ingest_phrase_embed_ms (fallback 500ms). Class a (rolling telemetry).

§max_inference_ms_per_commit: u32

Hard wall-clock ceiling per commit. Class c (reference standard): 250ms = 50% of max_cooccurrence_ms = 500.

§max_phrases_embedded: u32

Hard ceiling on bridging-phrase embeddings per commit. Class a (corpus-derived): min(50_000, sqrt(N_phrases) * 100).

§max_types: u32

Max inferred relation types emitted per commit. Class a (corpus-derived): ceil(log2(corpus_size)).

§author_rate_limit_per_commit: u32

Per-author bridging-phrase cap per commit. Class a (corpus-derived): max(200, 0.01 * mean_phrases_per_author).

Implementations§

Source§

impl InferenceBudget

Source

pub const MAX_INFERENCE_MS_PER_COMMIT: u32 = 250

Floor-c reference standard for the per-commit hard wall.

250ms. See solution.md R6 §Floor-c apparatus.

Source

pub const FALLBACK_EXTRACT_LATENCY_MS: u32 = 500

Fallback for extract_latency_budget_ms when rolling p50 telemetry is unavailable. See shared/inference-budget.md §API sketch.

Source

pub const fn conservative() -> Self

Conservative defaults for CI / proptest / initial runs.

Real deployments derive via a stats-aware constructor in the ingest crate; this keeps mnem-extract free of clock or telemetry dependencies.

Source

pub const fn effective_ms(&self) -> u32

Effective runtime budget = min(extract_latency_budget_ms, max_inference_ms_per_commit).

The hard wall is always the ceiling, even when rolling telemetry computes a higher extract budget.

Source

pub fn effective_ms_gauge(&self) -> (&'static str, f64)

Sample for gauge mnem_inference_budget_effective_ms.

Caller is responsible for emission; this module does not link a metrics backend. Returning (name, value) lets the caller use either metrics::gauge! or a custom registry.

Source

pub fn validate(&self) -> Result<(), &'static str>

Validate that the budget is internally consistent.

Returns Err with a static reason when:

  1. max_inference_ms_per_commit is zero.
  2. extract_latency_budget_ms is zero.
  3. max_phrases_embedded is zero.

Zero-valued caps are always a programming error: they would make the entire inference pass a no-op and silently hide bugs.

Trait Implementations§

Source§

impl Clone for InferenceBudget

Source§

fn clone(&self) -> InferenceBudget

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 InferenceBudget

Source§

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

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

impl Default for InferenceBudget

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for InferenceBudget

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 PartialEq for InferenceBudget

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for InferenceBudget

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 Copy for InferenceBudget

Source§

impl Eq for InferenceBudget

Source§

impl StructuralPartialEq for InferenceBudget

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,