aeat.domain.calculations.registry._loader_cache module¶
Registry loader cache predicates.
This module centralizes the small policy decisions that keep registry loading fast without hiding live TOML edits. Bundled registry roots receive a short fingerprint TTL, mutable authoring roots keep the stricter window, and under pytest the cross-process disk pickle is shared only for the immutable bundled root – a mutable/synthetic root always keeps it disabled so xdist workers cannot share a stale compiled registry from a tree the run itself can edit.
See also
_loaderRegistry TOML loader that consumes these TTL and disk-cache predicates.
bundled_path()Resource boundary used to identify the package-bundled registry root.
test_registry_disk_cache_disabled_under_pytest()Real-behavior gate for the pytest disk-cache refusal path.
test_is_bundled_registry_root_rejects_a_mutable_authoring_tree()Coverage for bundled-root versus mutable-authoring-tree separation.
test_bundled_tree_fingerprint_cache_survives_past_the_mutable_tree_ttl()Coverage for the longer bundled-root fingerprint TTL window.
_isolate_registry_caches()Session fixture that clears registry caches around pytest runs.
- Governing vault records
2026-05-20-registry-authority-flow-adrand2026-06-02-registry-loader-boundary-auditgovern the authority boundary and loader-extraction cache invalidation behavior.
- REGISTRY_DISK_CACHE_DIR_ENV_VAR¶
Environment variable backing
aeat_registry_disk_cache_dir.
- is_bundled_registry_root(resolved)[source]¶
Whether
resolvedis the package-bundled registry tree.The bundled tree is shipped inside the installed wheel (or, under an editable install, force-included from the in-tree
registry/aeatdirectory) rather than passed explicitly as a mutable authoring tree (e.g. a test’stmp_pathfixture building a synthetic registry). Comparing the resolved path against the bundled root lets the fingerprint cache applyBUNDLED_REGISTRY_FINGERPRINT_TTL_SECONDSto the bundled tree alone without weakening invalidation for any mutable tree, which always keeps the strictMUTABLE_REGISTRY_FINGERPRINT_TTL_SECONDSwindow.
- registry_disk_cache_enabled(*, is_bundled=False)[source]¶
Whether the cross-process
/tmpregistry pickle is read/written.Production (no pytest markers present at all) always keeps the disk cache: it loads the registry once at startup with no concurrent edits.
Under pytest, including collection before
PYTEST_CURRENT_TESTis set, the cache is enabled ONLY foris_bundled=True– the package-bundled, read-only registry tree (is_bundled_registry_root()). That tree is never mutated during a test run, so every pytest-xdist worker and every subprocess-spawning test may safely share ONE compiled pickle keyed by a content fingerprint of that tree, collapsing what would otherwise be an independent multi-second cold compile per worker/subprocess into a single shared compile the rest read.A mutable or synthetic root (e.g. a test’s
tmp_pathregistry, or any path that is not the resolved bundled root) always keeps the cache disabled under pytest – this is the #44 isolation fix: such a root CAN be edited mid-run by the very test that built it, and the pickle is keyed by file mtime, so sharing it across workers could serve a stale or transiently-inconsistent compiled registry (the M303-2009 flake #44 diagnosed). Only the always-immutable bundled tree is exempt from that race.
- registry_disk_cache_dir()[source]¶
Return the directory the cross-process registry disk pickle lives in.
Reads
aeat_registry_disk_cache_dir(theAEAT_REGISTRY_DISK_CACHE_DIRenv var) before falling back totempfile.gettempdir(), so a test can redirect the disk-cache pickle to a test-owned directory. Production and the ordinary bundled-root sharing path never set this field and always use the real OS temp directory; only a test that needs to assert EXCLUSIVE state on the pickle (e.g. “exactly one file exists”, “the mtime is unchanged”) – which the real OS temp directory cannot guarantee once sibling pytest-xdist workers are also touching the shared bundled-root pickle – sets this var to isolate its own assertions from that sibling traffic, while still exercising the real filesystem and the real pickle read/write path (no mock of the loader’s own behavior). It rides the env var (rather than a plain monkeypatched function) because it also needs to propagate to a subprocess a test spawns viaenv=, so a cross-process sharing proof can isolate BOTH ends of the process pair onto the same test-owned directory.- Return type:
Path