fix(runtime): fail closed on offline artifact misses

This commit is contained in:
DCCONSTRUCTIONS
2026-07-30 22:19:01 +03:00
parent 81d7ad1a77
commit 8c91d40e2e
12 changed files with 510 additions and 29 deletions
+23 -1
View File
@@ -16,7 +16,7 @@ from collections.abc import Iterator, Mapping, Sequence
from contextlib import contextmanager, suppress
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Final
from typing import Any, Final, Literal
from uuid import uuid4
from k1link.artifacts import utc_now_iso
@@ -98,6 +98,12 @@ class ArtifactCacheStatus:
free_space_reserve_bytes: int
@dataclass(frozen=True, slots=True)
class ArtifactGatewayStatus:
central_status: Literal["ready", "unavailable", "invalid"]
cache: ArtifactCacheStatus
class CentralArtifactStore:
"""Immutable SHA-256 objects/manifests plus atomically replaceable named refs."""
@@ -617,6 +623,22 @@ class ArtifactGateway:
self.store = store
self.cache = cache
def status(self) -> ArtifactGatewayStatus:
"""Return a lightweight readiness snapshot without resolving an artifact."""
try:
self.store._require_root()
except ArtifactStoreUnavailable:
central_status: Literal["ready", "unavailable", "invalid"] = "unavailable"
except ArtifactIntegrityError:
central_status = "invalid"
else:
central_status = "ready"
return ArtifactGatewayStatus(
central_status=central_status,
cache=self.cache.status(),
)
def publish(
self,
*,