Initial commit

This commit is contained in:
2026-09-04 14:58:42 +08:00
commit 439cad87d9
4601 changed files with 29440 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Shared filesystem roots for the static compilation pipeline."""
from __future__ import annotations
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[2]
PROFILE_RESULTS_ROOT = PROJECT_ROOT / "results" / "static-opimization" / "profiles"
MODEL_PREFERENCE_PROFILE_ROOT = PROFILE_RESULTS_ROOT / "model-preference"
FINAL_PROFILE_ROOT = PROFILE_RESULTS_ROOT / "models"
def model_path_parts(model_identifier: str) -> tuple[str, ...]:
"""Validate a provider-qualified model identifier for filesystem use."""
parts = tuple(model_identifier.strip().strip("/").split("/"))
if len(parts) < 2 or any(part in {"", ".", ".."} for part in parts):
raise ValueError(
"model must use provider/model-id format without empty or relative segments"
)
return parts
def model_directory(root: Path, model_identifier: str) -> Path:
return root.joinpath(*model_path_parts(model_identifier))
def model_profile_path(root: Path, model_identifier: str) -> Path:
canonical = model_directory(root, model_identifier) / "profile.json"
legacy = root / model_identifier.strip().strip("/").replace("/", "_") / "profile.json"
return legacy if legacy.is_file() and not canonical.is_file() else canonical