Skip to content

🎯 Session quotas: Limit.reset_after #597

Description

@sodre

What

Today a quota resets on a calendar edge β€” midnight, the first of the month β€” at the same instant for everyone (ADR-138). Session quotas add the other shape: a window measured from when you first used it.

10,000 tokens, and your window resets 5 hours after you first used it.

Spelled Limit.reset_after, taking a datetime.timedelta, as an alternative to reset_schedule. Under ADR-137 a limit drips or resets, never both, so the two are mutually exclusive spellings of the reset half rather than two mechanisms that compose.

Settled semantics

  • Idle-restarting, not tiling. The window is anchored by use, not by a repeating grid. A window ends at 14:00, the entity goes quiet, and a call at 20:00 starts a fresh window at 20:00 rather than landing inside one that has already elapsed. An entity can therefore restart its window by going idle.
  • Rollover anchors; exhaustion does not. Crossing a boundary anchors the next window. Running out of tokens inside the current window leaves the anchor where it is, so an entity cannot restart its own window by spending it out.
  • Parent and child anchor independently. A cascading child's window and its parent's window are separate state, consistent with how cascade already treats limits, shards and disabled as per-entity state.

Prerequisite

Builds on the v0.14.0 quota machinery. A duration window is a quota under ADR-137 (refill_amount = 0), so it inherits that release's reset handling β€” in particular #587's reclaim-then-grant shard creation, which is what stops a shard split handing out net-new allowance mid-window.

Design and plan

Not restated here; the plan is the source of truth.

Sub-issues for the individual tasks can be cut when someone picks the work up β€” the plan carries them until then.

Refs #222

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions