`bynk.agents.non_zeroable_state_field`
[bynk.agents.non_zeroable_state_field] agent `Gauge` store cell `level` has nodefined zero value, so a fresh key cannot be initialisedWhat it means
Section titled “What it means”An agent’s store field has a type with no zero value. Bynk initialises a
never-seen key’s state automatically, so every field needs a well-defined
starting value. Types that have one include Int (0), Bool (false),
String (""), Option[T] (None), and records of zeroable fields. Types that
do not include opaque types, sum types (other than Option), and refined
types that exclude their zero.
agent Gauge { key id: String store level: Cell[Int where Positive] -- Positive excludes 0 — no zero value}-
Add an initialiser. Give the field an explicit starting value with
= <value>; any type becomes admissible, including sums (a state machine’s initial state) and refined types:store level: Cell[Int where Positive] = 1The initialiser must be a compile-time value; see
bynk.agents.bad_state_initialiser. -
Use
Optionfor “not set yet”.Noneis a valid zero and means “never set” (store level: Cell[Option[Int]]). -
Relax the refinement so the zero is admitted (e.g.
NonNegativeinstead ofPositive, since0satisfiesNonNegative).
Related
Section titled “Related”- Build a stateful agent
- Reference: agents
- Explanation: The agent model