1
0
Fork 0
Code Issues Pull requests Projects Releases 2 Packages Wiki Activity Actions Pages

Make project MCP workflows self-synchronizing

This commit is contained in:
Andraxion 2026-07-26 09:32:25 -04:00
parent a30f021a52
commit 73165c9f51
17 changed files with 1124 additions and 56 deletions

View file

@ -1,9 +1,11 @@
from __future__ import annotations
import hashlib
import sqlite3
import tempfile
import unittest
from collections.abc import Mapping
from contextlib import closing
from dataclasses import replace
from pathlib import Path
@ -350,6 +352,38 @@ class AdapterContractTests(unittest.TestCase):
index.get_node("guide.workflow")["node"]["source_path"],
)
def test_fast_incremental_reads_reverify_a_changed_index_file(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory).resolve()
loader = IncrementalLoader(root)
project = AdapterProject(loader, cache_root=root / ".cache" / "incremental")
index = ProjectIndex(project)
index.build()
index.synchronize()
self.assertTrue(index.attestation_path.is_file())
fresh = ProjectIndex(project)
self.assertEqual(
"current",
fresh.synchronize()["synchronization"]["action"],
)
with closing(sqlite3.connect(index.path)) as connection:
connection.execute(
"UPDATE nodes SET content = ? WHERE node_id = ?",
("tampered", "guide.foundation"),
)
connection.commit()
with self.assertRaisesRegex(DocForgeError, "rows do not match metadata"):
index.get_node("guide.foundation")
repaired = index.synchronize()
self.assertEqual("rebuilt", repaired["synchronization"]["action"])
self.assertEqual(
"Foundation content.",
index.get_node("guide.foundation")["node"]["content"],
)
def test_incremental_delete_failure_and_equivalence_are_safe(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory).resolve()