cadrumo.application.modelo.workspace_producers module

Stamped producer contracts and atomic capture ports for Modelo Workspace V1.

Core types: CalculationRevision, RegistrySnapshot.

class RegistryAuthorityCapturePort(*args, **kwargs)[source]

Bases: Protocol

Narrow authority surface required by the atomic workspace registry port.

capture_law_selected_projection(modelo_id, *, filing_year, period, on=None, grade=None)[source]
Return type:

RegistryAuthorityCapture

Parameters:
read_current_coordinate()[source]
Return type:

RegistryAuthorityCurrentCoordinate

class ModeloWorkspaceContributorKindV1(*values)[source]

Bases: StrEnum

The closed contributor denominator for one successful Workspace V1 read.

REGISTRY
WORK
BOUNDED_REVIEW
CALCULATION
READINESS
LOCALE_CATALOGUE
FIELD_MANIFEST
class ModeloWorkspaceEpochKindV1(*values)[source]

Bases: StrEnum

The accepted owner-scoped invalidation mechanism for Workspace contributors.

MONOTONIC_GENERATION
modelo_workspace_projection_schema_fingerprint(projection_type)[source]

Derive one deterministic fingerprint over the contract a consumer actually receives.

A port projects outward: the caller reads the SERIALIZATION shape, never the validation shape, so the serialization schema alone is the contract the fingerprint has to identify. Fingerprinting BOTH schemas and demanding they coincide was standing in for a round-trip guarantee it never tested and does not need: a bare Decimal field validates as anyOf[number, string] but serializes as string alone, which is a faithful, round-trippable representation (model_validate_json parses the dumped string straight back to Decimal), not a broken contract. Refuse it here and every Decimal-bearing domain model – the registry snapshot, the work review, the calculation revision – becomes unregisterable for a shape difference that never breaks a round trip.

Return type:

TypeAliasType

Parameters:

projection_type (type[BaseModel])

class ModeloWorkspaceProducerContractV1(**data)[source]

Bases: _WorkspaceProducerModel

Frozen declaration of one owner contribution to a successful Workspace result.

Parameters:
contract_version: Literal[1]
contributor_kind: ModeloWorkspaceContributorKindV1
contributor: ModeloWorkspaceContributorIdentityV1
projection_discriminator: _ProducerCode
projection_contract_version: Annotated[int, Field(ge=1)]
projection_schema_fingerprint: ContentDigest
epoch_kind: ModeloWorkspaceEpochKindV1
epoch_schema_version: Literal[2]
atomic_read_operation: Literal['capture_projection_with_epoch']
contract_digest: ContentDigest
classmethod declare(*, contributor_kind, contributor, projection_discriminator, projection_contract_version, projection_type, epoch_schema_version=2)[source]

Declare a contract from the exact public projection schema it returns.

Return type:

Self

Parameters:
class ModeloWorkspaceProducerStampV1(**data)[source]

Bases: _WorkspaceProducerModel

The captured declaration identity that binds one value to its producer contract.

Parameters:

data (Any)

stamp_version: Literal[1]
contributor_kind: ModeloWorkspaceContributorKindV1
contributor: ModeloWorkspaceContributorIdentityV1
contract_digest: ContentDigest
projection_discriminator: _ProducerCode
projection_contract_version: Annotated[int, Field(ge=1)]
projection_schema_fingerprint: ContentDigest
classmethod from_contract(contract)[source]

Mint the one stamp that exactly represents contract.

Return type:

Self

Parameters:

contract (ModeloWorkspaceProducerContractV1)

require_contract(contract)[source]

Refuse a capture whose stamp differs from the declared current contract.

Return type:

Self

Parameters:

contract (ModeloWorkspaceProducerContractV1)

class ModeloWorkspaceEpochV1(**data)[source]

Bases: _WorkspaceProducerModel

Owner generation that exposes every ABA transition within one process incarnation.

Parameters:

data (Any)

owner: _ProducerCode
kind: ModeloWorkspaceEpochKindV1
schema_version: Literal[2]
comparison_domain: ContentDigest
generation: Annotated[int, Field(ge=1)]
require_current(current)[source]

Require this epoch to remain current within its exact comparison domain.

Return type:

Self

Parameters:

current (ModeloWorkspaceEpochV1)

class ModeloWorkspaceContributingProjectionV1(**data)[source]

Bases: _WorkspaceProducerModel, Generic

One projection, stamp, and incarnation-scoped ABA-safe epoch from one atomic read.

Parameters:
projection: ProjectionT
stamp: ModeloWorkspaceProducerStampV1
epoch: ModeloWorkspaceEpochV1
require_contract(contract)[source]

Validate the captured projection against its declared contract without a live reread.

Return type:

Self

Parameters:

contract (ModeloWorkspaceProducerContractV1)

class ModeloWorkspaceRegistryProjectionV1(**data)[source]

Bases: _WorkspaceProducerModel

Exactly one of the two registry admission shapes, never both.

Parameters:
inspection: RegistryRevisionInspection | None
snapshot: RegistrySnapshot | None
property revision_id: RevisionId

Return the one law-selected revision id, whichever admission shape carries it.

property review_status: RevisionReviewStatus

Return the revision’s own governance stamp, whichever admission shape carries it.

class ModeloWorkspaceReadinessProjectionV1(**data)[source]

Bases: _WorkspaceProducerModel

The complete readiness report set, exactly as the sole producer built it.

Parameters:

reports (tuple[ProjectionModeloReadiness, ...])

reports: tuple[ProjectionModeloReadiness, ...]
class ModeloWorkspaceLocaleCatalogueProjectionV1(**data)[source]

Bases: _WorkspaceProducerModel

One captured catalogue entry, exactly as the sole catalogue reader returned it.

Parameters:
locale: str
translation_key: str
present: bool
value: str | None
catalogue_digest: ContentDigest
class ModeloWorkspaceRegistryPortV1(*, authority, modelo_id, filing_year, period, on=None, grade=None)[source]

Bases: object

Application-owned port realization delegating to the registry authority.

Parameters:
property producer_contract: ModeloWorkspaceProducerContractV1

Return the frozen REGISTRY contributor contract.

capture_projection_with_epoch()[source]

Atomically capture one law-selected registry projection and stamp it with its epoch.

Return type:

ModeloWorkspaceContributingProjectionV1[ModeloWorkspaceRegistryProjectionV1]

class ModeloWorkspaceWorkPortV1(*, request, catalogue_repository, mode=ModeloWorkSelectionMode.VISIBLE_OR_EXACT)[source]

Bases: object

Application-owned port realization delegating to the sole WORK capture.

Parameters:
property producer_contract: ModeloWorkspaceProducerContractV1

Return the frozen WORK contributor contract.

capture_projection_with_epoch()[source]

Atomically capture one work resolution and stamp it with its epoch.

Return type:

ModeloWorkspaceContributingProjectionV1[ModeloWorkResolution]

class ModeloWorkspaceLocaleCataloguePortV1(*, translation_key, locale)[source]

Bases: object

Application-owned port realization delegating to the sole LOCALE_CATALOGUE capture.

Parameters:
  • translation_key (str)

  • locale (str)

property producer_contract: ModeloWorkspaceProducerContractV1

Return the frozen LOCALE_CATALOGUE contributor contract.

capture_projection_with_epoch()[source]

Atomically capture one catalogue entry and stamp it with its epoch.

Return type:

ModeloWorkspaceContributingProjectionV1[ModeloWorkspaceLocaleCatalogueProjectionV1]

class ModeloWorkspaceFieldManifestPortV1(*, authority)[source]

Bases: object

Application-owned port realization delegating to the sole FIELD_MANIFEST capture.

A static inspection and a graded snapshot make different authority claims and generate over different type universes – this port accepts either admission’s own authority object and dispatches to the matching generator, never filtering one universe’s manifest down for the other.

Parameters:

authority (RegistrySnapshot | RegistryRevisionInspection)

property producer_contract: ModeloWorkspaceProducerContractV1

Return the frozen FIELD_MANIFEST contributor contract.

capture_projection_with_epoch()[source]

Atomically capture the field manifest and stamp it with its epoch.

Return type:

ModeloWorkspaceContributingProjectionV1[ModeloWorkspaceFieldManifestV1]