pub struct SamplerIdentity { /* private fields */ }Expand description
SESSION-RESUME SAMPLER IDENTITY (lane/session-resume-sampler-predicate-20260820; receipts
research/spec-cache-20260818/SESSION-RESUME-PREDICATE.md).
The canonical form of a request’s sampler, for exactly one question: may this request resume
a parked whole session that some OTHER request’s sampler shaped? The spec pool’s resume probe
compared prompts and never samplers — that omission is how a filtered request inherited a draft
graph captured unfiltered (memra-engine SampledGraphKey, lane/graph-s-key-exactness-
20260819). Keying the graph closed the exactness hole; it did not make cross-sampler resume
SOUND, and the house posture in that situation is refuse-on-ambiguity with the refusal naming
itself. This type is that predicate.
CANONICALIZATION, and why each rule is safe. Two encodings that name the same program must compare equal, or the predicate refuses resumes that cost nothing to allow:
temperature <= 0.0is GREEDY —-1.0and0.0are one program, sotemp_bitsis pinned to0.0in that regime andgreedycarries the distinction. The greedy/sampled flip is itself a refusal: the two arms consume a parkednext_pred/pending_tokdifferently and engage different captured draft graphs.top_k == 0,top_p >= 1.0,min_p <= 0.0are each the OFF sentinel (matchingis_spec_samplingandSampledGraphKey::pure_temp), canonicalized sotop_p 1.5andtop_p 1.0do not look like a change.- Penalties are OFF as a group iff
penalty_last_n == 0or all three coefficients are neutral — the samepen_onpredicatespec.rscomputes. Off canonicalizes to the whole disabled tuple, sopenalty_last_n 64with neutral coefficients equals penalties absent.
Float fields compare by BITS after canonicalization (no NaN/-0.0 surprise), the same
discipline SampledGraphKey uses.
seed IS carried and DELIBERATELY NOT COMPARED — see SamplerIdentity::mismatch.
Implementations§
Source§impl SamplerIdentity
impl SamplerIdentity
Sourcepub fn of(cfg: &SamplerConfig) -> Self
pub fn of(cfg: &SamplerConfig) -> Self
Canonical identity of a sampler configuration.
Sourcepub fn seed(&self) -> u64
pub fn seed(&self) -> u64
The seed this identity was built from (logging/receipts only — never compared).
Sourcepub fn mismatch(&self, parked: &Self) -> Option<&'static str>
pub fn mismatch(&self, parked: &Self) -> Option<&'static str>
The FIRST field on which self (an incoming request) differs from parked (the sampler
that shaped a parked session), as a stable name for the refusal line — None when the two
samplers are equivalent and the resume is legal. A refusal that does not say why is
indistinguishable from an unwired mechanism, so the name is the deliverable, not a nicety.
Order is fixed and coarsest-first (regime before the field that only exists inside one
regime), so the reported name is the most informative one rather than an artifact of struct
layout.
seed IS NOT COMPARED, deliberately. It is the one sampler field a resume may change,
for two reasons that are both mechanical:
- The only parked state that BAKES the seed is the sampled draft graph, and
SampledGraphKeyalready carriesseed: a seed change drops the parked graph and recaptures. (memra-enginespec.rs; pinned byseed_alone_still_rekeys_the_draft_graphin that crate’ssampled_graph_keytests.) - The session’s persisted Philox counters (
SpecSession::sctr/uctr) are counter-based:philox(seed', ctr)continued from another seed’s counter position is an independent stream, not a repeated one. Reproducibility is already scoped per(seed, session)rather than per seed (memra-serverworker.rs, the spec-burst sampling note), so a changed seed costs nothing that same-seed resume was not already costing.
Comparing it would refuse essentially ALL sampled traffic: omitting seed on a serve
request draws fresh per-request entropy, so every turn of every seed-omitting conversation
would carry a “changed” seed. That is a cost with no soundness gain, which is exactly the
trade this predicate exists to make explicitly rather than by accident.
Sourcepub fn legacy_admits(&self, _parked: &Self) -> bool
pub fn legacy_admits(&self, _parked: &Self) -> bool
THE PRE-LANE PREDICATE, RESTATED (teeth, not production). The spec pool-resume probe
applied no sampler test at all — it compared prompts and nothing else — so every sampler
pair was admitted. Restating it here keeps the refusal tests DECISIVE instead of
tautological: the same pair that mismatch names must be admitted by this, or the test is
asserting against a mechanism that never existed.
It is also what MEMRA_SPEC_RESUME_SAMPLER=0 selects at runtime (the rollback door and the
A/B arm the cost measurement needs), so this function is the single definition of “legacy”
for both the tests and the server.
Trait Implementations§
Source§impl Clone for SamplerIdentity
impl Clone for SamplerIdentity
Source§fn clone(&self) -> SamplerIdentity
fn clone(&self) -> SamplerIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more