A byte budget shared across many models (M5 / design S3).

The federation invariant: budgets must be per browser, not per model, or opening N cross-referenced files re-introduces O(N) memory. This is the one accounting primitive that enforces it — every model's demand-geometry queue and window pool draws from a single SharedByteBudget, so the total resident footprint across all open models is bounded no matter how many are federated in.

It owns only the accounting (reserve / release / availability); the eviction policy that frees bytes when a reservation can't be met stays with each model's scheduler (M3's DemandGeometryQueue) — the budget just tells a caller how much it must evict first via overageFor.

Constructors

  • Parameters

    • totalBytes_: number

      The global ceiling shared across all models.

    Returns SharedByteBudget

Accessors

  • get available(): number
  • Returns number

    Bytes still reservable without eviction.

  • get total(): number
  • Returns number

    The global ceiling.

  • get used(): number
  • Returns number

    Bytes currently reserved across all models.

Methods

  • How many bytes a caller must evict (anywhere, across any model) before a reservation of bytes would fit. Zero when it already fits.

    Parameters

    • bytes: number

      The desired reservation.

    Returns number

    The bytes of eviction required (≥ 0).

  • Release previously reserved bytes back to the shared budget.

    Parameters

    • bytes: number

      The bytes to release (≥ 0). Clamped so used never goes negative — a double-release is a no-op past zero, not a corruption.

    Returns void

  • Try to reserve bytes against the shared ceiling. Succeeds (and charges the budget) only if it fits without exceeding the total; otherwise makes no change and returns false, leaving the caller to evict and retry.

    Parameters

    • bytes: number

      The bytes to reserve (≥ 0).

    Returns boolean

    True if reserved.