MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / test_openkb_files_tree_is_hardlinked

Function test_openkb_files_tree_is_hardlinked

tests/test_mutation.py:263–286  ·  view source on GitHub ↗

The PageIndex blob store (.openkb/files) is append-only across docs — each add creates new {doc_id} blobs and never modifies existing ones — so it is hardlink-safe and must be snapshotted via hardlinks, not copied.

(tmp_path)

Source from the content-addressed store, hash-verified

261
262
263def test_openkb_files_tree_is_hardlinked(tmp_path):
264 """The PageIndex blob store (.openkb/files) is append-only across docs —
265 each add creates new {doc_id} blobs and never modifies existing ones — so
266 it is hardlink-safe and must be snapshotted via hardlinks, not copied.
267 """
268 kb_dir = tmp_path
269 blobs = kb_dir / ".openkb" / "files" / "col"
270 blobs.mkdir(parents=True)
271 existing = blobs / "an-existing-doc.pdf"
272 existing.write_bytes(b"existing-blob")
273 live_inode = existing.stat().st_ino
274
275 snapshot = snapshot_paths(
276 kb_dir,
277 [kb_dir / ".openkb" / "files"],
278 operation="add",
279 details={},
280 hardlink_dirs={kb_dir / ".openkb" / "files"},
281 )
282 try:
283 backup = snapshot.backup_dir / ".openkb" / "files" / "col" / "an-existing-doc.pdf"
284 assert backup.stat().st_ino == live_inode
285 finally:
286 snapshot.discard_best_effort()
287
288
289def test_concept_writer_is_atomic_so_hardlink_rollback_restores(tmp_path):

Callers

nothing calls this directly

Calls 2

snapshot_pathsFunction · 0.90
discard_best_effortMethod · 0.80

Tested by

no test coverage detected