wip(k1): checkpoint connection recovery rewrite

Capture the current unreleased K1 connection, recovery, lifecycle, viewer, and test work as a single known-bad baseline for subsequent fixes.
This commit is contained in:
DCCONSTRUCTIONS
2026-08-14 14:57:50 +03:00
parent aff331082f
commit 0ca7316a24
157 changed files with 152962 additions and 4036 deletions
+22
View File
@@ -1,4 +1,6 @@
import json
import os
import stat
from pathlib import Path
from k1link.artifacts import write_json_atomic
@@ -9,3 +11,23 @@ def test_write_json_atomic(tmp_path: Path) -> None:
write_json_atomic(output, {"value": "тест"})
assert json.loads(output.read_text(encoding="utf-8")) == {"value": "тест"}
assert not list(output.parent.glob("*.tmp"))
def test_write_json_atomic_flushes_file_and_parent_directory(
tmp_path: Path,
monkeypatch,
) -> None:
output = tmp_path / "nested" / "artifact.json"
flushed_kinds: list[str] = []
real_fsync = os.fsync
def observing_fsync(descriptor: int) -> None:
mode = os.fstat(descriptor).st_mode
flushed_kinds.append("directory" if stat.S_ISDIR(mode) else "file")
real_fsync(descriptor)
monkeypatch.setattr(os, "fsync", observing_fsync)
write_json_atomic(output, {"durable": True})
assert flushed_kinds == ["file", "directory"]