Capture the current unreleased K1 connection, recovery, lifecycle, viewer, and test work as a single known-bad baseline for subsequent fixes.
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def test_lazy_app_import_in_child_keeps_mutable_k1_state_out_of_repository() -> None:
|
|
repository_root = Path(__file__).resolve().parents[1]
|
|
data_root = Path(os.environ["MISSIONCORE_DATA_DIR"]).resolve()
|
|
evidence_root = Path(os.environ["MISSIONCORE_EVIDENCE_DIR"]).resolve()
|
|
legacy_root = Path(os.environ["MISSIONCORE_LEGACY_SESSIONS_DIR"]).resolve()
|
|
assert data_root != repository_root / ".runtime" / "mission-core"
|
|
assert evidence_root != repository_root / ".runtime" / "mission-core" / "evidence"
|
|
assert legacy_root != repository_root / "sessions"
|
|
|
|
script = """
|
|
import importlib
|
|
import json
|
|
|
|
module = importlib.import_module("k1link.web.app")
|
|
contribution = module.plugin_environment._contributions[0]
|
|
runtime = contribution.runtime
|
|
service = runtime._adapter.service
|
|
print(json.dumps({
|
|
"session_data": str(module.session_store.data_dir),
|
|
"service_evidence": str(service.evidence_root),
|
|
"shadow_token": str(service.live_perception_token_path),
|
|
"archive_roots": [str(item.root) for item in module.plugin_environment.observation_archives],
|
|
}))
|
|
module.plugin_environment.close()
|
|
"""
|
|
completed = subprocess.run(
|
|
[sys.executable, "-c", script],
|
|
cwd=repository_root,
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
)
|
|
document = json.loads(completed.stdout.strip().splitlines()[-1])
|
|
|
|
assert Path(document["session_data"]).resolve() == data_root
|
|
assert Path(document["service_evidence"]).resolve() == evidence_root
|
|
assert Path(document["shadow_token"]).resolve().is_relative_to(data_root)
|
|
assert {Path(item).resolve() for item in document["archive_roots"]} == {
|
|
legacy_root,
|
|
evidence_root,
|
|
}
|