refactor(perception): isolate detector runtime

This commit is contained in:
DCCONSTRUCTIONS
2026-08-05 16:05:26 +03:00
parent 8e161a197f
commit 8bd632509e
14 changed files with 81 additions and 263 deletions
+30
View File
@@ -19,6 +19,20 @@ REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
PERCEPTION_ROOT = REPOSITORY_ROOT / "src" / "k1link" / "perception"
BASELINE_PATH = REPOSITORY_ROOT / "config" / "perception" / "m4-recorded-realtime-baseline-v1.json"
REUSE_PATH = REPOSITORY_ROOT / "config" / "perception" / "m4-reuse-inventory-v1.json"
DETECTOR_RUNTIME_MODULES = (
"__init__.py",
"baseline.py",
"contracts.py",
"detector.py",
"detector_replay.py",
"detector_replay_cli.py",
"detector_replay_contracts.py",
"detector_replay_result.py",
"detector_replay_validation.py",
"providers.py",
"recorded_source.py",
"yolox_object_detector.py",
)
def _imports(path: Path) -> set[str]:
@@ -151,6 +165,22 @@ def test_perception_contracts_import_no_compute_lab_graph_or_web_module() -> Non
assert forbidden == set()
def test_perception_package_initializer_is_side_effect_free() -> None:
assert _imports(PERCEPTION_ROOT / "__init__.py") == set()
def test_detector_runtime_closure_imports_no_legacy_compute_package() -> None:
violations = {
name: sorted(
module
for module in _imports(PERCEPTION_ROOT / name)
if module.startswith("k1link.compute")
)
for name in DETECTOR_RUNTIME_MODULES
}
assert {name: modules for name, modules in violations.items() if modules} == {}
def test_new_perception_boundary_has_no_experiment_specific_imports() -> None:
violations: dict[str, str] = {}
for path in PERCEPTION_ROOT.glob("*.py"):