api/internal/frequency/frequency_policy library

Typed frequency-capping policy + state models.

Dart port of the cross-platform frequency core (Android FrequencyEvaluator.kt / FrequencyManager.kt, RN, iOS). The wire format is camelCase — maxTotal, maxPerWindow { count, window }, stopOn — and a campaign carries it under a top-level frequency object. Old snake_case payloads have no recognised keys and parse to a no-constraint (uncapped) policy.

Classes

FrequencyEvalResult
The result of evaluating a policy against a state. Mirrors Android's FrequencyEvalResult.
FrequencyPolicy
A campaign's server-configured frequency policy. Any field may be absent; hasConstraint is false when none are set, in which case the campaign is never capped.
FrequencyState
Persisted per-campaign capping state. total (lifetime) and windowCount (current window) are tracked independently so a per-window cap never double-counts against FrequencyPolicy.maxTotal. Mirrors Android's FrequencyState.
FrequencyWindow
{ count, window } — at most count shows within one window. window is one of session / day / week / month (kept as the raw wire string so the golden matrix matches the other platforms exactly).

Enums

FrequencySkipReason
Why an evaluation blocked a campaign (null when allowed).