5ac0618a33
The 7 code_path_audit*.py files (2604 lines total) are pure static analysis tools. They do AST traversal of src/, no intrusive profiling, no runtime markers. They were inlaid with src/ but only import: - src.result_types (the Result[T] convention type) - each other (the 6 siblings) After the move: - src/ is now pure application code; line-count audit metrics are clean - scripts/code_path_audit/ is a new namespace-isolated subdir per AGENTS.md 'scripts are namespace-isolated by directory' rule TIER-3 READ AGENTS.md + conductor/workflow.md + conductor/edit_workflow.md + conductor/code_styleguides/code_path_audit.md + the 7 files before this commit. Changes: - 7 files moved: src/code_path_audit*.py -> scripts/code_path_audit/ - 7 files updated: internal imports rom src.code_path_audit_X -> rom code_path_audit_X (siblings in same subdir) - 7 files updated: add sys.path.insert(0, str(Path(__file__).resolve().parents[2] / 'src')) to find src.result_types when run standalone - 5 test files updated: rom src.code_path_audit -> rom code_path_audit + sys.path setup to find the new subdir - 6 throwaway scripts in scripts/tier2/artifacts/ updated: import path + sys.path setup (parents[3] / 'src' + parents[3] / 'scripts' / 'code_path_audit') - 2 styleguide/spec references updated: conductor/code_styleguides/code_path_audit.md + conductor/tracks/code_path_audit_20260607/spec_v2.md - 1 meta-audit docstring updated: scripts/audit_code_path_audit_coverage.py - 1 type registry entry deleted: docs/type_registry/src_code_path_audit.md (the type is no longer in src/) - 1 type registry index updated: docs/type_registry/index.md (22 files, was 23) Verification: - 7/7 audit gates pass --strict (weak_types 102<=112, type_registry 22 files, main_thread_imports OK, no_models_config_io OK, code_path_audit_coverage 0 violations, exception_handling 0 violations, optional_in_3_files 0 violations) - 6/6 test files pass: test_code_path_audit, test_code_path_audit_integration, test_code_path_audit_phase78, test_code_path_audit_phase89, test_code_path_audit_ssdl_behavioral, test_metadata_nil_sentinel - src/ line count: 29997 lines (down from 32621 = -2624 lines) - scripts/code_path_audit/ line count: 2620 lines
111 lines
3.8 KiB
Python
111 lines
3.8 KiB
Python
"""Integration tests for src.code_path_audit v2."""
|
|
from __future__ import annotations
|
|
import sys
|
|
from pathlib import Path
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts" / "code_path_audit"))
|
|
import tempfile
|
|
from code_path_audit import (
|
|
run_audit,
|
|
render_rollups,
|
|
)
|
|
|
|
FIXTURE_SRC = "tests/fixtures/synthetic_src"
|
|
FIXTURE_INPUTS = "tests/fixtures/audit_inputs"
|
|
|
|
def test_integration_synthetic_src_produces_3_real_aggregates() -> None:
|
|
"""The full run_audit against the synthetic src/ produces 10 real + 3 candidate profiles."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
real_profiles = [p for p in result.data.aggregate_profiles if not p.is_candidate]
|
|
candidate_profiles = [p for p in result.data.aggregate_profiles if p.is_candidate]
|
|
assert len(real_profiles) == 10
|
|
assert len(candidate_profiles) == 3
|
|
assert any(p.name == "Metadata" for p in real_profiles)
|
|
assert any(p.name == "FileItems" for p in real_profiles)
|
|
assert any(p.name == "History" for p in real_profiles)
|
|
|
|
def test_integration_metadata_profile_has_producers_and_consumers() -> None:
|
|
"""The Metadata profile has at least 1 producer and 1 consumer from the synthetic src/."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
metadata = next(p for p in result.data.aggregate_profiles if p.name == "Metadata")
|
|
assert len(metadata.producers) >= 1
|
|
|
|
def test_integration_metadata_memory_dim_is_discussion() -> None:
|
|
"""The Metadata profile's memory_dim is 'discussion' (canonical mapping)."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
metadata = next(p for p in result.data.aggregate_profiles if p.name == "Metadata")
|
|
assert metadata.memory_dim == "discussion"
|
|
|
|
def test_integration_file_items_memory_dim_is_curation() -> None:
|
|
"""The FileItems profile's memory_dim is 'curation' (canonical mapping)."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
file_items = next(p for p in result.data.aggregate_profiles if p.name == "FileItems")
|
|
assert file_items.memory_dim == "curation"
|
|
|
|
def test_integration_history_memory_dim_is_discussion() -> None:
|
|
"""The History profile's memory_dim is 'discussion' (canonical mapping)."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
history = next(p for p in result.data.aggregate_profiles if p.name == "History")
|
|
assert history.memory_dim == "discussion"
|
|
|
|
def test_integration_missing_audit_inputs_tolerated() -> None:
|
|
"""run_audit tolerates missing audit inputs."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
inputs_dir = str(Path(tmp) / "nonexistent")
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=inputs_dir,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
assert len(result.data.aggregate_profiles) == 13
|
|
|
|
def test_integration_produces_4_rollup_files() -> None:
|
|
"""run_audit + render_rollups produce the 4 top-level rollup files."""
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
result = run_audit(
|
|
src_dir=FIXTURE_SRC,
|
|
audit_inputs_dir=FIXTURE_INPUTS,
|
|
output_dir=tmp,
|
|
date="2026-06-22",
|
|
)
|
|
assert result.ok
|
|
rollup_paths = render_rollups(result.data, Path(tmp) / "2026-06-22")
|
|
for name, path in rollup_paths.items():
|
|
assert Path(path).exists()
|
|
assert Path(path).stat().st_size > 0 |