cadrumo.application.user_profile.custody_repository module

Application repository and lock ports for profile custody transactions.

class ProfileCustodyTransactionRepository(*, root=None, adapters=None)[source]

Bases: object

Persist strict current-format transaction journals and owner receipts.

Parameters:
journal_path(transaction_id)[source]

Return the durable path for a transaction journal.

Return type:

Path

Parameters:

transaction_id (UUID)

receipt_path(transaction_id)[source]

Return the durable path for an application-local receipt.

Return type:

Path

Parameters:

transaction_id (UUID)

owner_receipt_path(transaction_id, owner)[source]

Return the durable path for an owner-specific receipt.

Return type:

Path

Parameters:
  • transaction_id (UUID)

  • owner (Literal[CustodyReceiptOwner.PROCESS_SECRET_REVOCATION, CustodyReceiptOwner.LOCAL_SESSION_ACCELERATION])

create_journal(journal)[source]

Create a transaction journal with exclusive publication.

Return type:

None

Parameters:

journal (ProfileCustodyTransactionJournal)

load_journal(transaction_id)[source]

Load and validate a transaction journal.

Return type:

ProfileCustodyTransactionJournal

Parameters:

transaction_id (UUID)

save_journal(journal)[source]

Replace an existing transaction journal with canonical bytes.

Return type:

None

Parameters:

journal (ProfileCustodyTransactionJournal)

write_receipt(receipt)[source]

Write or confirm an application-local receipt.

Return type:

ProfileCustodyTransactionReceipt

Parameters:

receipt (ProfileCustodyTransactionReceipt)

load_receipt(transaction_id)[source]

Load and validate an application-local receipt, if present.

Return type:

ProfileCustodyTransactionReceipt | None

Parameters:

transaction_id (UUID)

write_owner_receipt(receipt)[source]

Write or confirm an owner-specific receipt.

Return type:

ProfileCustodyOwnerReceipt

Parameters:

receipt (ProfileCustodyOwnerReceipt)

load_owner_receipt(transaction_id, owner)[source]

Load and validate an owner-specific receipt, if present.

Return type:

ProfileCustodyOwnerReceipt | None

Parameters:
  • transaction_id (UUID)

  • owner (Literal[CustodyReceiptOwner.PROCESS_SECRET_REVOCATION, CustodyReceiptOwner.LOCAL_SESSION_ACCELERATION])

profile_custody_transaction_lock(root, profile_id)[source]

Acquire root then profile lock, the only accepted custody lock order.

Custody transactions are GLOBALLY serialised, not per profile. The root lock is taken first and held for the whole span, so two transactions for DIFFERENT profiles exclude each other exactly as two for the same profile do; a long transaction on one profile blocks every other.

The profile lock therefore never contends under the current call graph – it is only ever acquired inside this function, with the root lock already held. Removing it fails the lock-order gate and nothing else, which is stated here because “there is a per-profile lock” otherwise reads as a promise of per-profile concurrency that the root lock does not deliver. It stays because the ORDER is the deadlock-safety rule: a future path that takes both must take them this way round.

Return type:

Generator[None]

Parameters: