Implement infospace scaffold and service baseline

This commit is contained in:
tegwick 2026-05-23 03:12:02 +02:00
parent df6238c7e0
commit 9883a99f78
43 changed files with 35986 additions and 28 deletions

View file

@ -0,0 +1,65 @@
from __future__ import annotations
import importlib.util
import sys
import types
from pathlib import Path
from types import ModuleType
from typing import Any
BENCH_PACKAGE = "_info_tech_canon_infospace_bench"
BENCH_SOURCE_ROOT = (
Path(__file__).resolve().parents[3] / "infospace-bench" / "src" / "infospace_bench"
)
def _ensure_package() -> ModuleType:
existing = sys.modules.get(BENCH_PACKAGE)
if existing is not None:
return existing
package = types.ModuleType(BENCH_PACKAGE)
package.__path__ = [str(BENCH_SOURCE_ROOT)] # type: ignore[attr-defined]
sys.modules[BENCH_PACKAGE] = package
return package
def _load_module(name: str) -> ModuleType:
_ensure_package()
module_name = f"{BENCH_PACKAGE}.{name}"
existing = sys.modules.get(module_name)
if existing is not None:
return existing
path = BENCH_SOURCE_ROOT / f"{name}.py"
if not path.is_file():
raise RuntimeError(f"Missing infospace-bench module: {path}")
spec = importlib.util.spec_from_file_location(module_name, path)
if spec is None or spec.loader is None:
raise RuntimeError(f"Unable to load infospace-bench module: {path}")
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
return module
errors = _load_module("errors")
models = _load_module("models")
lifecycle = _load_module("lifecycle")
checks = _load_module("checks")
inspection = _load_module("inspection")
Infospace = models.Infospace
KnowledgeArtifact = models.KnowledgeArtifact
load_infospace = lifecycle.load_infospace
run_collection_checks = checks.run_collection_checks
relationship_summary = inspection.relationship_summary
export_mermaid = inspection.export_mermaid
__all__ = [
"Infospace",
"KnowledgeArtifact",
"export_mermaid",
"load_infospace",
"relationship_summary",
"run_collection_checks",
]