"""Behavioral SSDL tests for src.code_path_audit_ssdl.compute_effective_codepaths. Locks down the headline 4.01e22 effective codepaths math against a small synthetic fixture so future refactors cannot silently change the formula. CONVENTION: 1-space indentation. NO COMMENTS. """ from __future__ import annotations import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts" / "code_path_audit")) from code_path_audit import ( AggregateProfile, CrossAuditFindings, DecompositionCost, FunctionRef, Frequency, FrequencyEvidence, ResultCoverage, TypeAliasCoverage, ) from code_path_audit_ssdl import compute_effective_codepaths FIXTURE_FILE = "sample_module.py" FIXTURE_SRC_DIR = "tests/fixtures/synthetic_ssdl" FIXTURE_FUNC_NAMES = ( "func_one", "func_two", "func_three", "func_four", "func_five", ) def _make_synthetic_profile() -> AggregateProfile: consumers = tuple( FunctionRef( fqname=f"tests.fixtures.synthetic_ssdl.sample_module.{name}", file=FIXTURE_FILE, line=1, role="consumer", ) for name in FIXTURE_FUNC_NAMES ) return AggregateProfile( name="synthetic", aggregate_kind="typealias", memory_dim="control", producers=(), consumers=consumers, access_pattern="whole_struct", access_pattern_evidence=(), frequency="per_turn", frequency_evidence=(), result_coverage=ResultCoverage(0, 0, 0, 0, ""), type_alias_coverage=TypeAliasCoverage(0, 0, 0, ""), cross_audit_findings=CrossAuditFindings((), (), (), (), ()), decomposition_cost=DecompositionCost(0, 0, 0, "hold", "no data", None, 0, False), optimization_candidates=(), is_candidate=False, ) def _make_candidate_profile() -> AggregateProfile: f = FunctionRef( fqname="tests.fixtures.synthetic_ssdl.sample_module.func_one", file=FIXTURE_FILE, line=1, role="consumer", ) return AggregateProfile( name="synthetic_candidate", aggregate_kind="typealias", memory_dim="control", producers=(), consumers=(f,), access_pattern="whole_struct", access_pattern_evidence=(), frequency="per_turn", frequency_evidence=(), result_coverage=ResultCoverage(0, 0, 0, 0, ""), type_alias_coverage=TypeAliasCoverage(0, 0, 0, ""), cross_audit_findings=CrossAuditFindings((), (), (), (), ()), decomposition_cost=DecompositionCost(0, 0, 0, "hold", "no data", None, 0, False), optimization_candidates=(), is_candidate=True, ) def test_effective_codepaths_synthetic() -> None: profile = _make_synthetic_profile() result = compute_effective_codepaths(profile, src_dir=FIXTURE_SRC_DIR) assert result == 40 def test_effective_codepaths_candidate_returns_zero() -> None: profile = _make_candidate_profile() result = compute_effective_codepaths(profile, src_dir=FIXTURE_SRC_DIR) assert result == 0