feat(shared-root): S3 — configurable shared-root resolver with load-bearing override test

One call-time resolver (env PORTFOLIO_SHARED_ROOT, default the in-repo
shared/) consumed by both MAF-side readers of the shared core:
persona._example_path() (the _EXAMPLE_PATH monkeypatch seam is kept) and
simulation._default_bundle_dir() (replaces the _BUNDLE_DIR module global).
De-risks the S4 extraction: re-pointing the commons becomes an env var,
not a code change. Override test proves the marker follows a tmp copy of
the whole shared tree; both detach points proven RED. Suite 155->157.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaQCFnfsh3tfq1VfzdJpoi
This commit is contained in:
Kjell Tore Guttormsen 2026-07-03 01:10:05 +02:00
commit cebba7d954
4 changed files with 110 additions and 15 deletions

View file

@ -0,0 +1,23 @@
"""Resolver for the location of the shared framework-neutral core (S3, R1-forberedelse).
``shared/`` is today an in-repo directory, but is slated for extraction into its own commons repo
(R1/S4). Every MAF-side consumer resolves its location through this ONE seam so the extraction is
a re-point (env var), not a code change. Pure stdlib the shared core itself stays framework-free.
"""
from __future__ import annotations
import os
from pathlib import Path
ENV_VAR = "PORTFOLIO_SHARED_ROOT"
_DEFAULT = Path(__file__).resolve().parents[2] / "shared"
def shared_root() -> Path:
"""Resolve the shared-core root at CALL time: ``PORTFOLIO_SHARED_ROOT`` if set (non-empty),
else the in-repo default. The call-time read is what keeps the override testable and the S4
extraction re-pointable without touching consumers."""
override = os.environ.get(ENV_VAR)
return Path(override) if override else _DEFAULT