Module context_pool

Module context_pool 

Source
Expand description

The context pool: per-kind bounded, lazily-filled sets the differential drivers draw from so contexts recur across flushes.

Every driver invocation is a fresh process; without coordination each would mint its own contexts and the space would grow without bound and never recur. The pool holds one shared set per kind behind a hard per-kind cap: it mints a new context of a sampled kind while that kind is under its cap, then draws an existing one of that kind at random. Once a kind’s cumulative requests exceed its cap the set is exhausted and its contexts recur across flushes, which is what gives the differential oracle multi-point curves to align.

The caps are read from context_source.yaml on the first Pool::serve call. The intake starts before first_sample_config samples that file, but the first /contexts request only ever comes from a driver, which runs after first_sample_config — so the config is present by then.

A kind serves an existing context for one of two reasons and the pool tells them apart. Reaching the cap is the configured end state. Spending every mint try on a duplicate is a crowded alphabet, which is counted per kind and reported so a cap that fills slowly is visible. It is never latched: one unlucky streak must not pin a kind below its cap for the rest of the run. A budget too small to hold a kind’s smallest identity is neither of those, and errors.

One pull in NON_UTF8_PULL_RATE leads with a context carrying an invalid UTF-8 byte. A driver pulls once per invocation and leads every datagram it sends with that context, so a carrying pull puts the byte in all of its datagrams and any other pull in none. How many datagrams an invocation sends is sampled independently of what its pull holds, so across a run the fraction of datagrams carrying the byte is the fraction of pulls that do. Deciding it here rather than in the driver is what makes the rate independent of how many contexts a timeline sampled: a driver holding one context gets the same 1% as one holding a thousand. Such a context is a pool member like any other, minted against the same budget, deduplicated, and counted against its kind’s cap, so bounded cardinality is unaffected.

Structs§

Pool
A per-kind bounded, lazily-filled pool of contexts.