Pure, conservative accounting for Mandate resource limits.
Every operation consumes a typed Meter.Account and preserves:
ceiling = available + reserved + suspended + spent + delegatedQuantities move between buckets; they are never inferred or created. A parent's delegated quantity becomes a child's ceiling, so delegation is subtractive rather than a second issuance of authority.
suspended is never released by time or restart. It moves only through an
explicit Duty disposition or definitive late Outcome.
Summary
Functions
Returns whether quantity can currently be reserved.
Transfers quantity subtractively from a parent to a child allocation.
Returns all currently free child quantity to its parent.
Returns only free child quantity to its parent.
Validates a canonical reservation request against current balances.
Conservatively takes back released quantities that remain available.
Returns reserved quantity only after definitive no-effect Evidence.
Moves quantity from available to reserved.
Plans and applies several reservations as one pure transition.
Resolves suspended quantity under an explicit durable disposition.
Moves a definitive effected quantity from reserved to spent.
Moves an ambiguous reservation from reserved to suspended.
Validates a typed account and its conservation equation.
Types
@type accounts() :: %{optional(String.t()) => Spectre.GAM.Kernel.Meter.Account.t()}
@type reason() :: term()
Functions
@spec available?(Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer()) :: boolean()
Returns whether quantity can currently be reserved.
@spec delegate( Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer() ) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Transfers quantity subtractively from a parent to a child allocation.
Both accounts must represent the same Meter. The parent moves
available -> delegated; the child's ceiling and available grow by the
same quantity.
@spec devolve( Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t() ) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Returns all currently free child quantity to its parent.
@spec devolve( Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer() ) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t(), Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Returns only free child quantity to its parent.
Reserved and suspended quantities remain bound to their Attempt or Duty, and
spent remains historical. Only available can therefore be devolved.
@spec plan_reservations(Spectre.GAM.Kernel.Meter.Amounts.t(), accounts()) :: {:ok, Spectre.GAM.Kernel.Meter.Amounts.t()} | {:error, reason()}
Validates a canonical reservation request against current balances.
@spec recontain_many(Spectre.GAM.Kernel.Meter.Amounts.t(), accounts()) :: {:ok, accounts(), Spectre.GAM.Kernel.Meter.Amounts.t(), Spectre.GAM.Kernel.Meter.Amounts.t()} | {:error, reason()}
Conservatively takes back released quantities that remain available.
The returned maps partition every request into recontained and deficits.
A deficit is reported without inventing quantity or violating conservation.
@spec release(Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer()) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Returns reserved quantity only after definitive no-effect Evidence.
@spec reserve(Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer()) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Moves quantity from available to reserved.
@spec reserve_many(Spectre.GAM.Kernel.Meter.Amounts.t(), accounts()) :: {:ok, accounts(), Spectre.GAM.Kernel.Meter.Amounts.t()} | {:error, reason()}
Plans and applies several reservations as one pure transition.
@spec resolve_suspended( Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer(), :settle | :release ) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Resolves suspended quantity under an explicit durable disposition.
:settle acknowledges it as spent; :release makes it available again.
@spec settle(Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer()) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Moves a definitive effected quantity from reserved to spent.
@spec suspend(Spectre.GAM.Kernel.Meter.Account.t(), non_neg_integer()) :: {:ok, Spectre.GAM.Kernel.Meter.Account.t()} | {:error, reason()}
Moves an ambiguous reservation from reserved to suspended.
@spec validate(Spectre.GAM.Kernel.Meter.Account.t()) :: :ok | {:error, reason()}
Validates a typed account and its conservation equation.