spectral-budget
A budget primitive for bounded sequential domains: token windows, time horizons, request counts — anything where you need to refuse work that would exceed a principled ceiling, and surface a structured reason when you do.
use SpectralBudget;
// 200 000-token context window; admit up to 3 ring-down periods.
let budget = SpectralBudget ;
assert!;
assert!;
Why this shape
The framing comes from the Faber–Krahn inequality on the principal
eigenvalue of a bounded Laplacian: a closed domain of diameter d with
propagation speed c has a slowest mode with period T_1 ≈ 2·d/c.
Capping aggregate diameter at k · T_1 (default k = 3) keeps becoming
finite. The same arithmetic applies whether d is photon path-length,
an LLM token window, an audio duration, or an agent reasoning depth.
In practice this means:
principal_periodis your domain's natural period: context-window size for LLM calls, total path-length horizon for a renderer, max audio bar length for an audio bed.ring_down_factoris how many of those periods you'll tolerate before refusing.3.0is the well-tempered default — three rings of the slowest mode.try_admitreturns a structuredBudgetError::Exceededcarrying the diameter, the bound,T_1, and the factor — diagnosable at the call site without inspecting internals.
License
Dual MIT / Apache-2.0. © 3BSN LLC.