From 6694f65465ebb29dc00fa277b220468536c4efc0 Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Mon, 14 Sep 2026 16:08:29 +0530 Subject: [PATCH] Add regression test for unscoped callers with no allowlist Confirms recovery never runs when allowed_source_files is omitted: a genuinely bogus path is skipped exactly as before this fix, and a normal well formed path in the same batch still saves and loads back. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh (cherry picked from commit 12999a80f6e288b2c780f6c34f0a4f797c0e6753) --- .../test_semantic_cache_basename_recovery.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_semantic_cache_basename_recovery.py b/tests/test_semantic_cache_basename_recovery.py index f498e095d..62fea2236 100644 --- a/tests/test_semantic_cache_basename_recovery.py +++ b/tests/test_semantic_cache_basename_recovery.py @@ -44,3 +44,23 @@ def test_ambiguous_basename_stays_skipped(tmp_path): assert saved == 0 assert load_cached(a, root=tmp_path, kind="semantic") is None assert load_cached(b, root=tmp_path, kind="semantic") is None + + +def test_unscoped_call_with_no_allowlist_is_unaffected(tmp_path): + # No allowed_source_files at all: recovery must never run, so a + # genuinely bogus path is skipped exactly as before this fix, and a + # normal well formed path still resolves and saves. + real = tmp_path / "sub" / "weird_named_file.py" + real.parent.mkdir(parents=True) + real.write_text("def f(): pass\n") + + nodes = [ + {"id": "n1", "label": "f", "source_file": "sub/weird_named_file.py"}, + {"id": "n2", "label": "g", "source_file": "totally/does/not/exist.py"}, + ] + saved = save_semantic_cache(nodes, [], root=tmp_path) + assert saved == 1 + + cached = load_cached(real, root=tmp_path, kind="semantic") + assert cached is not None + assert {n["id"] for n in cached["nodes"]} == {"n1"}