chore(storage): bound build retention, caches and test resources
Track build ownership, qualified pins and bounded cache/log lifecycles. Move Vite fixtures to a job-owned server helper and preserve private outputs outside Git.
This commit is contained in:
@@ -18,6 +18,7 @@ from typing import Any, cast
|
||||
import numpy as np
|
||||
import rerun as rr
|
||||
|
||||
from k1link.cache_budget import cache_publication, require_cache_room
|
||||
from k1link.laboratory.canonical_rerun_overlay import (
|
||||
APPLICATION_ID,
|
||||
CanonicalLabOverlayArtifact,
|
||||
@@ -198,6 +199,12 @@ class PortableReplayService:
|
||||
self.cache.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
if self.cache.is_symlink() or shutil.disk_usage(self.cache).free < 3 * 1024**3:
|
||||
raise PortableReplayError("replay cache has insufficient safe space")
|
||||
require_cache_room(
|
||||
self.cache,
|
||||
1024**3,
|
||||
kind="observatory-portable-replay-cache",
|
||||
error_type=PortableReplayError,
|
||||
)
|
||||
with tempfile.TemporaryDirectory(prefix=".pack-", dir=self.cache) as temporary:
|
||||
root = Path(temporary)
|
||||
proxy = self._video(epoch, root)
|
||||
@@ -231,10 +238,16 @@ class PortableReplayService:
|
||||
"sha256": artifact.sha256,
|
||||
"byte_length": artifact.byte_length,
|
||||
}
|
||||
staged = self.cache / f".{key}.json"
|
||||
staged.write_text(json.dumps(metadata, sort_keys=True), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, self.cache / f"{key}.json")
|
||||
with cache_publication(
|
||||
self.cache,
|
||||
65536,
|
||||
kind="observatory-portable-replay-cache",
|
||||
error_type=PortableReplayError,
|
||||
):
|
||||
staged = self.cache / f".{key}.json"
|
||||
staged.write_text(json.dumps(metadata, sort_keys=True), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, self.cache / f"{key}.json")
|
||||
return artifact
|
||||
|
||||
def _composition_key(
|
||||
@@ -381,6 +394,12 @@ class PortableReplayService:
|
||||
self.cache.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
if self.cache.is_symlink() or shutil.disk_usage(self.cache).free < 3 * 1024**3:
|
||||
raise PortableReplayError("replay cache has insufficient safe space")
|
||||
require_cache_room(
|
||||
self.cache,
|
||||
1024**3,
|
||||
kind="observatory-portable-replay-cache",
|
||||
error_type=PortableReplayError,
|
||||
)
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix=".pack-composition-", dir=self.cache
|
||||
) as temporary:
|
||||
@@ -416,10 +435,16 @@ class PortableReplayService:
|
||||
"sha256": artifact.sha256,
|
||||
"byte_length": artifact.byte_length,
|
||||
}
|
||||
staged = self.cache / f".{key}.json"
|
||||
staged.write_text(json.dumps(metadata, sort_keys=True), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, self.cache / f"{key}.json")
|
||||
with cache_publication(
|
||||
self.cache,
|
||||
65536,
|
||||
kind="observatory-portable-replay-cache",
|
||||
error_type=PortableReplayError,
|
||||
):
|
||||
staged = self.cache / f".{key}.json"
|
||||
staged.write_text(json.dumps(metadata, sort_keys=True), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, self.cache / f"{key}.json")
|
||||
return artifact
|
||||
|
||||
def _camera(self, session_id: str, bundle: dict[str, Any]) -> RecordedMediaEpoch:
|
||||
@@ -519,11 +544,17 @@ class PortableReplayService:
|
||||
digest = hashlib.file_digest(stream, "sha256").hexdigest()
|
||||
metadata = {"sha256": digest, "byte_length": proxy.stat().st_size}
|
||||
os.chmod(proxy, 0o600)
|
||||
os.replace(proxy, saved)
|
||||
staged = root / "camera.json"
|
||||
staged.write_text(json.dumps(metadata), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, saved_manifest)
|
||||
with cache_publication(
|
||||
self.cache,
|
||||
65536,
|
||||
kind="observatory-portable-replay-cache",
|
||||
error_type=PortableReplayError,
|
||||
):
|
||||
os.replace(proxy, saved)
|
||||
staged = root / "camera.json"
|
||||
staged.write_text(json.dumps(metadata), encoding="utf-8")
|
||||
os.chmod(staged, 0o600)
|
||||
os.replace(staged, saved_manifest)
|
||||
return saved
|
||||
|
||||
|
||||
|
||||
@@ -10,14 +10,10 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
from k1link.launchd_logs import launchd_log_path
|
||||
from k1link.launchd_logs import bounded_launchd_output, launchd_log_path
|
||||
|
||||
OBSERVATORY_WORKER_TUNNEL_LABEL: Final = (
|
||||
"com.nodedc.observatory-worker-tunnel.local"
|
||||
)
|
||||
OBSERVATORY_WORKER_TUNNEL_SCHEMA: Final = (
|
||||
"missioncore.observatory-worker-tunnel-plan/v1"
|
||||
)
|
||||
OBSERVATORY_WORKER_TUNNEL_LABEL: Final = "com.nodedc.observatory-worker-tunnel.local"
|
||||
OBSERVATORY_WORKER_TUNNEL_SCHEMA: Final = "missioncore.observatory-worker-tunnel-plan/v1"
|
||||
OBSERVATORY_WORKER_TUNNEL_PORT: Final = 18080
|
||||
|
||||
|
||||
@@ -97,6 +93,7 @@ def plan_observatory_worker_tunnel_launch_agent(
|
||||
"StandardOutPath": str(log_path),
|
||||
"StandardErrorPath": str(log_path),
|
||||
}
|
||||
desired = bounded_launchd_output(desired, Path(__file__).resolve().parents[3])
|
||||
payload = plistlib.dumps(desired, fmt=plistlib.FMT_XML, sort_keys=True)
|
||||
return ObservatoryWorkerTunnelLaunchAgentPlan(
|
||||
agent_path=target_path,
|
||||
|
||||
Reference in New Issue
Block a user