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
+38 -2
View File
@@ -15,6 +15,7 @@ import pytest
import k1link.sessions.recording as recording_module
from k1link.artifact_gateway import (
ArtifactGateway,
ArtifactStoreUnavailable,
CentralArtifactStore,
LocalArtifactCache,
)
@@ -184,7 +185,7 @@ def test_materializer_restores_exact_central_recording_without_export(
assert exporter.calls == 0
def test_default_recording_cache_has_no_application_byte_quota(
def test_default_recording_cache_has_a_bounded_application_quota(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
@@ -195,7 +196,42 @@ def test_default_recording_cache_has_no_application_byte_quota(
exporter=FakeExporter(),
)
assert materializer.cache_max_bytes is None
assert materializer.cache_max_bytes == 8 * 1024 * 1024 * 1024
def test_materializer_does_not_rebuild_when_central_store_is_offline(
tmp_path: Path,
) -> None:
command = _command(tmp_path / "source")
exporter = FakeExporter()
class OfflineGateway:
def resolve_role(
self,
namespace: str,
key: str,
role: str,
) -> object:
assert (namespace, key, role) == (
"sessions",
command.session_id,
"base-rrd",
)
raise ArtifactStoreUnavailable("offline cache miss")
materializer = SessionRecordingMaterializer(
tmp_path / "private",
exporter=exporter,
artifact_gateway=OfflineGateway(), # type: ignore[arg-type]
)
with pytest.raises(
RecordingMaterializationError,
match="not present in the local artifact cache",
):
materializer.materialize(command)
assert exporter.calls == 0
def test_delete_cached_refuses_a_live_lease_then_removes_the_exact_cache(