source_file may be written through a symlinked tmp directory (real macOS behaviour: /var/folders/... is a symlink to /private/var/folders/...). project_dirs goes through .resolve() which follows the symlink. Without matching .resolve() on the source side, _resolve_pro
(self, tmp_dir, palace_path)
| 902 | |
| 903 | @pytest.mark.skipif(os.name == "nt", reason="os.symlink needs admin on Windows") |
| 904 | def test_symlinked_project_root_resolves(self, tmp_dir, palace_path): |
| 905 | """source_file may be written through a symlinked tmp directory |
| 906 | (real macOS behaviour: /var/folders/... is a symlink to |
| 907 | /private/var/folders/...). project_dirs goes through .resolve() |
| 908 | which follows the symlink. Without matching .resolve() on the |
| 909 | source side, _resolve_project_root would mis-bucket every drawer |
| 910 | as out_of_scope. This test pins symmetric resolution. |
| 911 | """ |
| 912 | from mempalace.sync import sync_palace |
| 913 | |
| 914 | real_root = Path(tmp_dir) / "real" |
| 915 | (real_root / "build").mkdir(parents=True) |
| 916 | (real_root / ".gitignore").write_text("build/\n") |
| 917 | (real_root / "build" / "x.py").write_text("# ignored\n") |
| 918 | |
| 919 | link_root = Path(tmp_dir) / "link" |
| 920 | os.symlink(str(real_root), str(link_root)) |
| 921 | |
| 922 | client = chromadb.PersistentClient(path=palace_path) |
| 923 | col = client.get_or_create_collection( |
| 924 | "mempalace_drawers", metadata={"hnsw:space": "cosine"} |
| 925 | ) |
| 926 | col.add( |
| 927 | ids=["d_via_link"], |
| 928 | documents=["x"], |
| 929 | embeddings=[[1.0, 0.0, 0.0]], |
| 930 | metadatas=[ |
| 931 | { |
| 932 | "wing": "demo", |
| 933 | "room": "build", |
| 934 | "source_file": str(link_root / "build" / "x.py"), |
| 935 | "chunk_index": 0, |
| 936 | "added_by": "miner", |
| 937 | "filed_at": "2026-05-09T00:00:00", |
| 938 | } |
| 939 | ], |
| 940 | ) |
| 941 | del client |
| 942 | |
| 943 | report = sync_palace( |
| 944 | palace_path=palace_path, |
| 945 | project_dirs=[str(real_root)], |
| 946 | wing="demo", |
| 947 | dry_run=True, |
| 948 | ) |
| 949 | assert report["gitignored"] == 1, ( |
| 950 | f"symmetric resolve broken: drawer mis-bucketed; report={report}" |
| 951 | ) |
| 952 | assert report["out_of_scope"] == 0 |
| 953 | |
| 954 | def test_classification_cache_avoids_redundant_disk_hits( |
| 955 | self, tmp_dir, palace_path, monkeypatch |
nothing calls this directly
no test coverage detected