cadrumo.domain.calculations.registry.authority_cache module

Bounded concurrent retention for immutable authority components.

retained_object_size(value)[source]

Estimate a decoded immutable graph without following types or callables.

Every reachable object is counted once by identity; the walk is iterative because a large revision component reaches millions of members.

Return type:

int

Parameters:

value (object)

exception AuthorityCacheCycleError(message=None, *, context=None, translated_message=None)[source]

Bases: CadrumoError

A component loader recursively requested a key already on its stack.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • translated_message (str | None)

Return type:

None

code
class RetainedAuthorityValue(value, exclusive_weight, shared_weights=())[source]

Bases: Generic

Loaded value and the retained bytes it contributes to the shared budget.

Parameters:
value: TypeVar(V)
exclusive_weight: int
shared_weights: tuple[tuple[Hashable, int], ...]
class AuthorityCacheTelemetry(budget, retained_weight, entries, in_flight)[source]

Bases: object

Accounted retention state, distinct from process RSS and active leases.

Parameters:
  • budget (int)

  • retained_weight (int)

  • entries (int)

  • in_flight (int)

budget: int
retained_weight: int
entries: int
in_flight: int
class AccountedAuthorityCache(budget=67108864)[source]

Bases: Generic

Coalesce loads and retain successful immutable values within one LRU budget.

Parameters:

budget (int)

get_or_load(key, loader)[source]

Return a retained value or share exactly one concurrent load for key.

Return type:

V

Parameters:
discard(key)[source]

Stop retaining a key without affecting values already held by callers.

Return type:

None

Parameters:

key (K)

clear()[source]

Drop retained cache ownership; active loads and caller values remain valid.

Return type:

None

telemetry()[source]

Return retained-accounting telemetry without claiming a process RSS bound.

Return type:

AuthorityCacheTelemetry