Enum Class BudgetPolicy

java.lang.Object
java.lang.Enum<BudgetPolicy>
com.tnsai.quality.cost.BudgetPolicy
All Implemented Interfaces:
Serializable, Comparable<BudgetPolicy>, Constable

public enum BudgetPolicy extends Enum<BudgetPolicy>
What the framework should do when a CostBudget is exhausted (issue #82).

Sealed-style enum so the enforcement layer can pattern-match exhaustively. The enforcement layer itself (a Hook<PreAction> for LLM calls) is a separate follow-up — this enum is the data the hook will read off the budget definition.

Since:
0.5.0 (issue #82)
  • Enum Constant Details

    • SOFT_WARN

      public static final BudgetPolicy SOFT_WARN
      Emit a warning event + Prometheus alert; let the call through. Use when the budget is informational rather than enforcement (e.g. cost visibility for analytics, not throttling).
    • HARD_STOP

      public static final BudgetPolicy HARD_STOP
      Block any new LLM call that would push the period spend over budget. The enforcement hook returns a structured deny so the caller sees "budget exceeded" rather than a silent failure.
    • DEFER

      public static final BudgetPolicy DEFER
      Queue the call for the next period and notify the user via the OnNotification hook. Useful for non-interactive workloads that can wait — interactive chats should pick HARD_STOP instead.
  • Method Details

    • values

      public static BudgetPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BudgetPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null