solvi.core.deciders.state¶
The input a decider reads: a text, or a state serialized by state_text.
Part of solvi.core.deciders, which re-exports every name; import from there.
The input a decider reads: a text, or a state serialized by state_text (paths / tree / json). (Part of solvi.core.deciders, which re-exports every name.)
state_text ¶
The input a decider reads: a text as it is; any other value (a dict, a list, a pydantic model, a dataclass) first as
JSON data (see jsonable), then serialized — by default "paths", one line per leaf with its full key path:
customer.name: Anna
items[0].sku: A-1
items[0].qty: 2
note: two lines of text
Keys in their order (a pydantic model: field order); a key that is not [A-Za-z0-9_-]+ is written ["key"] (a JSON
string); strings without quotes (a new line becomes a space); null / true / false; floats rounded to 6 decimals without
trailing zeros; empty {} and [] kept; a scalar at the top is ".: value". "tree" is the YAML-like indented form, "json"
is json.dumps with ", " / ": " separators. These are exactly the typed decider's training serializations
(serialize of its training code); docs/decide_format.md has the rules.
jsonable ¶
A Python value → JSON data, deterministically: a pydantic model → its model_dump(), a dataclass → its fields, dates and times → ISO 8601, an Enum → its value, Decimal / UUID / other objects → str, bytes → UTF-8 text, tuples → lists, sets → lists sorted by their JSON text, numpy → Python numbers.