aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_indexer.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-26 00:40:25 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-26 00:40:25 +0200
commit704cfe37506fc5316c997b025004fbc9c4d2a47b (patch)
treebb51f6dc2ae395f56afc05e6a048a23d5b409fdf /packages/meshbay-node/tests/test_indexer.py
parent2af320ba4da49547176ef7e4c081956c33841958 (diff)
parent37d8d9c15c982f2da17b2fad4ea1a90613b560a6 (diff)
downloadmeshbay-704cfe37506fc5316c997b025004fbc9c4d2a47b.tar.gz
Merge branch 'feat/cross-group-file-cache'
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013XSohfUQQiaE77qyFLgSv3
Diffstat (limited to 'packages/meshbay-node/tests/test_indexer.py')
-rw-r--r--packages/meshbay-node/tests/test_indexer.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_indexer.py b/packages/meshbay-node/tests/test_indexer.py
index 9aa9fb9..729dade 100644
--- a/packages/meshbay-node/tests/test_indexer.py
+++ b/packages/meshbay-node/tests/test_indexer.py
@@ -284,6 +284,44 @@ async def test_second_scan_with_same_cache_hashes_nothing(
@pytest.mark.asyncio
+async def test_second_group_sharing_the_same_folder_hashes_nothing(
+ shared_dir, sk_node, gek, index_cache):
+ """
+ The scenario the cache was made node-wide for (2026-08-25): an operator
+ shares the same physical folder into a second group. `IndexCache` is
+ keyed purely by absolute path, with no notion of group_id at all — a
+ *different* group_id scanning the same folder through the same shared
+ cache instance must hit exactly as hard as a same-group restart does
+ (the test right above this one). Before this cache was shared node-wide,
+ each group got its own on-disk cache file and this scan would have
+ rehashed every byte again.
+ """
+ first = DirectoryIndexer(roots=one_root(shared_dir), group_id="group-a",
+ sk_node=sk_node, gek=gek, cache=index_cache)
+ await first.initial_scan()
+ assert first.index.count == 4
+
+ calls = []
+ real_scan_file = indexer_mod._scan_file
+
+ def spy(root, path):
+ calls.append(path)
+ return real_scan_file(root, path)
+
+ indexer_mod._scan_file = spy
+ try:
+ second = DirectoryIndexer(roots=one_root(shared_dir), group_id="group-b",
+ sk_node=sk_node, gek=gek, cache=index_cache)
+ await second.initial_scan()
+ finally:
+ indexer_mod._scan_file = real_scan_file
+
+ assert calls == [], (
+ f"a second group scanning the same folder must not rehash it, got {calls}")
+ assert {e.id for e in second.index.entries} == {e.id for e in first.index.entries}
+
+
+@pytest.mark.asyncio
async def test_modified_file_is_rehashed(tmp_path, sk_node, gek, index_cache):
d = tmp_path / "shared"
d.mkdir()