Skip to content

symfonic.services.cost.tracker_adapter

tracker_adapter

The shipped TokenBudgetTracker behind the row-5 ports.

Nothing about the tracker changes โ€” BUD-5 keeps accounting where it is, and V4 forbids a behaviour change during the program. What changes is who the platform talks to: a narrow protocol instead of a concrete class reached through a module-level get_budget_tracker() singleton.

The tracker is addressed structurally rather than imported, so this adapter works against any object with the same three coroutines โ€” which is what lets a deployment bind a different ledger without the admission decision noticing.

TrackerBudgetCheck

TrackerBudgetCheck(tracker: _TrackerLike)

BudgetCheck over TokenBudgetTracker.

The ledger is keyed by tenant id and stays that way: inventing a sub-tenant-granular key here would silently give every sub-tenant its own ceiling, which is a pricing change wearing a refactor's clothes. The subject's tenant segment is what the tracker sees, and that is recorded rather than assumed.

Source code in src/symfonic/services/cost/tracker_adapter.py
def __init__(self, tracker: _TrackerLike) -> None:
    self._tracker = tracker

TrackerCostReadModel

TrackerCostReadModel(tracker: Any)

CostReadModel over the tracker's usage aggregates (BUD-6).

Source code in src/symfonic/services/cost/tracker_adapter.py
def __init__(self, tracker: Any) -> None:
    self._tracker = tracker