Skip to content

10.4 Thresholds and Overage

Sprint: Sprint 10 - Usage Metering
Feature ID: 10.4
Subtasks: 10.4.1, 10.4.2, 10.4.3

Objective

Deliver "Thresholds and Overage" within Sprint 10 - Usage Metering.

Dependencies

Aggregated from the subtasks below (prerequisite task IDs and enablers):

  • 10.3.2
  • 10.4.1
  • 10.4.2

Subtasks

10.4.1 Threshold detection (80% / 100%)

  • ID: 10.4.1
  • Title: Emit quota.threshold-reached.v1 and quota.exceeded.v1
  • Description: After each decrement, evaluate consumption against totals; emit quota.threshold-reached.v1 once when crossing 80% and quota.exceeded.v1 once when reaching 100%, guarding against duplicate emission per period/threshold (FR-19).
  • Business Purpose: Notify subscribers and trigger overage at thresholds (FR-19, AC-03).
  • Inputs: FR-19, event-catalog quota events, AC-03.
  • Outputs: Threshold evaluation + events.
  • Acceptance Criteria:
  • Crossing 80% emits exactly one quota.threshold-reached.v1; reaching 100% emits exactly one quota.exceeded.v1; re-crossing within the same period does not re-emit.
  • Dependencies: 10.3.2
  • Complexity: M

10.4.2 Overage capture post-exhaustion

  • ID: 10.4.2
  • Title: Flag and aggregate post-exhaustion usage as overage
  • Description: After a quota is exhausted, mark further usage_records as overage and accumulate overage quantities per subscription/period for billing (FR-20).
  • Business Purpose: Bill usage beyond the included allowance (FR-20, AC-03).
  • Inputs: FR-20, AC-03.
  • Outputs: Overage flagging + aggregation.
  • Acceptance Criteria:
  • Usage after exhaustion is flagged overage and accumulated; pre-exhaustion usage is not.
  • Dependencies: 10.4.1
  • Complexity: M

10.4.3 Usage aggregation for billing

  • ID: 10.4.3
  • Title: Emit usage.aggregated.v1 for the billing period
  • Description: Aggregate the period's usage and overage per subscription and emit usage.aggregated.v1 (consumed by billing) on bill-cycle close or on demand (FR-20).
  • Business Purpose: Hand period usage to billing (FR-20, AC-02 dependency).
  • Inputs: FR-20, event-catalog usage.aggregated.v1.
  • Outputs: Aggregation job + event.
  • Acceptance Criteria:
  • Aggregation produces usage.aggregated.v1 with per-subscription totals including overage for the requested period.
  • Dependencies: 10.4.2
  • Complexity: M

Acceptance Criteria

Each subtask above carries its own objective, testable acceptance criteria. This feature is complete when every subtask's acceptance criteria are met.

Deliverables

  • Threshold evaluation + events.
  • Overage flagging + aggregation.
  • Aggregation job + event.

Definition of Done

  • All subtasks (10.4.1, 10.4.2, 10.4.3) completed and their acceptance criteria verified.
  • All listed dependencies satisfied.
  • Build and tests green per the global conventions in ../README.md (Section 3).