Files
awoooi/apps/api/src/services/snapshot_paths.py
Your Name 1d4b3df5e4
Some checks failed
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / tests (push) Successful in 1m44s
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Successful in 5m14s
CD Pipeline / post-deploy-checks (push) Successful in 1m39s
feat(iwooos): add runtime security readback board
2026-06-26 17:51:08 +08:00

43 lines
1.3 KiB
Python

"""
Snapshot path helpers.
Resolve committed documentation snapshot paths across local repo checkouts and
production API images. In containers, service modules live under
``/app/src/services`` instead of ``apps/api/src/services``.
"""
from __future__ import annotations
from pathlib import Path
def resolve_repo_root(anchor: Path) -> Path:
"""Resolve the repository root that contains committed docs snapshots."""
resolved = anchor.resolve()
start = resolved if resolved.is_dir() else resolved.parent
for candidate in (start, *start.parents):
if (candidate / "docs").is_dir():
return candidate
container_root = Path("/app")
if (container_root / "docs").is_dir():
return container_root
parents = list(start.parents)
return parents[2] if len(parents) > 2 else start
def default_evaluations_dir(anchor: Path) -> Path:
"""Resolve the default committed evaluations snapshot directory."""
return resolve_repo_root(anchor) / "docs" / "evaluations"
def default_operations_dir(anchor: Path) -> Path:
"""Resolve the default committed operations snapshot directory."""
return resolve_repo_root(anchor) / "docs" / "operations"
def default_security_dir(anchor: Path) -> Path:
"""Resolve the default committed security snapshot directory."""
return resolve_repo_root(anchor) / "docs" / "security"