aeat.core.resources._repository module

ResourceCacheRepository base for the resource-management API.

Every read-only bundled-data resource in the project is exposed through one ResourceRepository implementation. The repository owns its loader and its Identity Map cache; consumers go through ResourceRegistry instead of importing loader functions directly.

The base class implements the get(key) / clear_cache contract on top of an unbounded dict[K, T]. Subclasses override _load(key) -> T to perform the actual file read and Pydantic validation. The cache strategy is documented in the resource-management-api ADR: process-lifetime memoisation, no eviction, because the bundled data is immutable per install.

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

Bases: Protocol, Generic

Typed read-only resource repository protocol.

get(key)[source]

Return the resource identified by key.

Return type:

T

Parameters:

key (K)

all()[source]

Return every resource the repository can produce.

Return type:

Iterable[T]

clear_cache()[source]

Empty this repository’s Identity Map.

Return type:

None

class ResourceCacheRepository[source]

Bases: Generic

Default Repository implementation with an Identity Map cache.

Subclasses override _load() to read and validate one resource per key. The base class owns the cache behind the ResourceRepository protocol; subclasses never touch it directly.

get(key)[source]

Return the resource for key, loading on first access.

Return type:

T

Parameters:

key (K)

all()[source]

Return every resource the repository can produce.

The default implementation raises NotImplementedError because enumeration requires per-repository knowledge of the available keys. Subclasses with a finite key space (year-keyed catalogues, etc.) override.

Return type:

Iterable[T]

clear_cache()[source]

Empty the Identity Map.

Tests that override Settings or otherwise change the bundled-data location between cases call this to force a reload on the next get. Production code should not need to call this because the bundled data is immutable.

Return type:

None