cadrumo.core.models module

Shared pydantic model configuration constants.

Provides the canonical STRICT_FROZEN_CONFIG used across domain, application, and adapter pydantic models that require strict-mode, frozen, no-extra-fields configuration. It is a pydantic.ConfigDict value shared by records that need immutable boundary contracts, including domain.calculations.registry.schema_base.RegistryModel, core.optional_extras.OptionalExtra, and encrypted-storage envelope records.

The constant is intentionally only a config value, not a base class or a validation policy. Domain modules still own field validators, serializers, model rebuilds, and any richer invariants on their own records; this module only centralises the common strict=True, frozen=True, extra="forbid" and validate_default=True baseline.

validate_default=True belongs here rather than on each embedding module. Without it a default value is trusted unread, so a default that its own field would reject is accepted silently and only surfaces where something else happens to re-validate it. Declaring it once at the shared constant means a field’s constraint governs its default everywhere the constant is used; adding it per module as the gap resurfaces is how one omission becomes hundreds of files of drift.

Modules with intentionally divergent ConfigDict values (e.g. arbitrary_types_allowed=True in storage adapter models, or validate_assignment=True in JSON contract models) must keep their own module-local config constant and must NOT import STRICT_FROZEN_CONFIG from here. The CLI JSON contract is such an exception: core.json_contract.OutputSchema and core.json_contract.SchemaEnvelope add assignment validation for machine-output conformance.

STRICT_FROZEN_CONFIG: ConfigDict

Canonical pydantic ConfigDict for strict-mode, frozen, no-extra-fields models.

Modules that require a different config (e.g. arbitrary_types_allowed=True for ORM-mapped types, or validate_assignment=True for mutable contract types) must declare a module-local constant instead. This constant deliberately does not set validate_assignment; it is the default for frozen value objects, not for settings models, mutable accumulators, or the CLI JSON schema registry. Schema construction is deferred to first use so importing a module of value objects does not pay for validators the process never runs.

STRICT_FROZEN_HIDDEN_INPUT_CONFIG: ConfigDict

Canonical strict, frozen, no-extra-fields configuration that also prevents Pydantic from echoing rejected input in validation errors. Use it for models whose values can contain opaque or sensitive source identifiers.