Private
Public Access
0
0

fix(audit): path resolution in analyze_consumer_fields + analyze_producer_size

The previous code did Path(src_dir) / function_ref.file, which
double-prefixed (e.g. src/src/project_manager.py) and silently
returned empty. Fixed: if function_ref.file exists as
CWD-relative, use it directly. Only join if it doesn't exist.

Now 130 real field accesses detected across 35 Metadata consumers
in the 2026-06-22 audit output (was 0 before).
This commit is contained in:
2026-06-22 10:05:12 -04:00
parent 67ca680a05
commit 5405345c5a
13 changed files with 299 additions and 287 deletions
+14 -2
View File
@@ -80,7 +80,13 @@ def analyze_consumer_fields(
"""
type_registry = type_registry or {}
canonical_fields = _field_names_for_aggregate(aggregate, type_registry)
filepath = Path(src_dir) / function_ref.file
_p = Path(function_ref.file)
if _p.exists():
filepath = _p
elif _p.is_absolute():
filepath = _p
else:
filepath = Path(src_dir) / function_ref.file
if not filepath.exists():
return Counter(), [], False
try:
@@ -107,7 +113,13 @@ def analyze_producer_size(
Returns (field_count, field_names).
"""
filepath = Path(src_dir) / function_ref.file
_p2 = Path(function_ref.file)
if _p2.exists():
filepath = _p2
elif _p2.is_absolute():
filepath = _p2
else:
filepath = Path(src_dir) / function_ref.file
if not filepath.exists():
return 0, []
try: