cadrumo.application.inventory.ports module

Application-owned capabilities for bucket-scoped inventory operations.

The inventory service coordinates ledger persistence and bucket-event emission, but it does not know which encrypted repositories implement either capability. An executable composition root supplies this complete bundle for each bucket.

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

Bases: Protocol

Complete ledger capability required by InventoryService.

load()[source]

Load the bucket’s inventory document.

Return type:

InventoryLedgerDocument

save(document)[source]

Persist a validated inventory document.

Return type:

None

Parameters:

document (InventoryLedgerDocument)

create(ledger)[source]

Atomically create one activity/year ledger.

Return type:

InventoryLedgerDocument

Parameters:

ledger (InventoryLedger)

record_closing_authority(actividad_id, authority_record, *, year)[source]

Atomically record one closing-authority record.

Return type:

InventoryLedger

Parameters:
remove(actividad_id, *, year)[source]

Atomically remove one activity/year ledger.

Return type:

InventoryLedger

Parameters:
  • actividad_id (str)

  • year (int)

class InventoryServicePorts(inventory_repository_factory, bucket_event_repository)[source]

Bases: object

Required persisted authorities for one inventory service instance.

Parameters:
inventory_repository_factory: Callable[[str], InventoryLedgerServiceRepositoryProtocol]
bucket_event_repository: BucketEventHistoryRepositoryProtocol
class InventoryServicePortsFactory(*args, **kwargs)[source]

Bases: Protocol

Construct the complete inventory capability bundle for one bucket.