diff --git a/mempalace/entity_detector.py b/mempalace/entity_detector.py index 85b54e8fec..16e438aa94 100644 --- a/mempalace/entity_detector.py +++ b/mempalace/entity_detector.py @@ -235,6 +235,13 @@ def _get_stopwords(languages: tuple) -> frozenset: ".rb", ".go", ".rs", + # C / C++ + ".c", + ".h", + ".cpp", + ".hpp", + ".cc", + ".hh", } SKIP_DIRS = { diff --git a/mempalace/miner.py b/mempalace/miner.py index dda0c0e109..7f11cf6ea3 100644 --- a/mempalace/miner.py +++ b/mempalace/miner.py @@ -125,6 +125,13 @@ def _read_text_no_follow(filepath: Path, root: Path) -> Optional[str]: ".java", ".go", ".rs", + # C / C++ + ".c", + ".h", + ".cpp", + ".hpp", + ".cc", + ".hh", ".swift", ".kt", ".kts", diff --git a/tests/test_miner_c_cpp_visibility.py b/tests/test_miner_c_cpp_visibility.py new file mode 100644 index 0000000000..9ceda2c4bb --- /dev/null +++ b/tests/test_miner_c_cpp_visibility.py @@ -0,0 +1,34 @@ +"""C/C++ sources must not be silently skipped by the project miner. + +Same failure class as test_miner_jsonl_visibility.py: scan_project keeps +only files whose suffix is in READABLE_EXTENSIONS. The whitelist grew +per-stack (C#, PHP, Swift/Kotlin, LaTeX) but never gained C or C++, so +mining any C project silently drops every .c/.h file — no warning, no +log line. +""" + +import tempfile +from pathlib import Path + +from mempalace.miner import READABLE_EXTENSIONS, scan_project + +C_CPP_EXTENSIONS = {".c", ".h", ".cpp", ".hpp", ".cc", ".hh"} + + +class TestCAndCppNotSilentlySkipped: + def test_c_cpp_in_readable_extensions(self): + missing = C_CPP_EXTENSIONS - READABLE_EXTENSIONS + assert not missing, ( + f"READABLE_EXTENSIONS is missing C/C++ suffixes {sorted(missing)}; " + "every such file in a mined project is silently skipped." + ) + + def test_scan_project_picks_up_c_file(self): + with tempfile.TemporaryDirectory() as tmp: + tmpdir = Path(tmp) + c_path = tmpdir / "probe.c" + c_path.write_text( + '#include \nint main(void) { printf("hello\\n"); return 0; }\n' + ) + found = [p.name for p in scan_project(str(tmpdir))] + assert "probe.c" in found, f"scan_project silently dropped probe.c. Returned: {found}"