Files
semantica/tests/context
cxzg007andSameer Kadam c111277a1f fix(context): make auto_generate_id a real InitVar in decision models (#1153)
The six decision-model dataclasses (Decision, DecisionContext, Policy,
PolicyException, Precedent, ApprovalChain) accepted `auto_generate_id`
only as a plain `__post_init__` parameter. Since it was neither a field
nor an InitVar, the generated `__init__` never forwarded it, so the
parameter was always its `True` default and the `auto_generate_id=False`
validation branch was unreachable dead code.

Declare `auto_generate_id: InitVar[bool] = True` on each dataclass so the
generated `__init__` forwards it to `__post_init__`, restoring the
required-id contract. Serialization is unaffected because InitVar is not
a real field. Add regression tests covering the auto-generate path, the
required-id error path, and the explicit-id path.

Fixes #1152

Co-authored-by: Sameer Kadam <sskadam6305@gmail.com>
2026-08-31 15:50:40 +05:30
..