Skip to content

Commit 7fedfe8

Browse files
committed
lint(mem): scan all of src/ and internal/, exempt vendored/ by path segment
The memory-core linter scanned src/ and internal/cbm/. Widen it to src/ and every subtree under internal/, so a new tree added there is covered without anyone remembering to list it, and the count is for the whole project -- cli, mcp, daemon, store, pipeline, the extraction engine. Vendored code is now excluded wherever a vendored/ segment appears in the path rather than by one hardcoded prefix, so that exemption cannot drift either. internal/ holds only cbm today, so the regenerated baseline is byte-identical: 92 files, 4086 raw sites. Widening lost no coverage and vendored stays out (0 sites listed). The red/green proof still holds under the new scope, and the failure message now names the NEW site -- one appended malloc reports grew by 2 (83 -> 85) at the appended line, instead of listing six pre-existing ones. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent da3258f commit 7fedfe8

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎scripts/lint-memory-core.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
src/foundation/mem.c policy/measurement, probes with malloc
3030
src/foundation/mem_override_*.c the --wrap / override shims
3131
src/foundation/compat*.c libc replacement surface
32-
internal/cbm/vendored/** not ours
32+
internal/**/vendored/** not ours
3333
vendored/** not ours
3434
35+
SCOPE. Everything under src/ and internal/ -- cli, mcp, daemon, store,
36+
pipeline, the extraction engine -- so the count is for the whole project, not
37+
one subsystem, and a leak shows up wherever it is.
38+
3539
Usage:
3640
lint-memory-core.py check against the baseline (CI)
3741
lint-memory-core.py --strict also fail when a file is BELOW baseline
@@ -49,7 +53,7 @@
4953

5054
ROOT = pathlib.Path(__file__).resolve().parent.parent
5155
BASELINE = ROOT / "scripts" / "memory-core-baseline.txt"
52-
SCAN_ROOTS = ("src", "internal/cbm")
56+
SCAN_ROOTS = ("src", "internal")
5357
RAW = re.compile(r"(?<![A-Za-z0-9_])(malloc|calloc|realloc|free|strdup|strndup)\s*\(")
5458

5559
EXEMPT_EXACT = {
@@ -61,13 +65,17 @@
6165
EXEMPT_PREFIX = (
6266
"src/foundation/mem_override_",
6367
"src/foundation/compat",
64-
"internal/cbm/vendored/",
6568
"vendored/",
6669
)
6770

6871

72+
def is_vendored(rel: str) -> bool:
73+
"""Any vendored/ segment anywhere under internal/ is not ours."""
74+
return "/vendored/" in rel or rel.startswith("vendored/")
75+
76+
6977
def is_exempt(rel: str) -> bool:
70-
return rel in EXEMPT_EXACT or rel.startswith(EXEMPT_PREFIX)
78+
return rel in EXEMPT_EXACT or rel.startswith(EXEMPT_PREFIX) or is_vendored(rel)
7179

7280

7381
def strip_comments_and_strings(text: str) -> str:

0 commit comments

Comments
 (0)