Private
Public Access
0
0
Files
manual_slop/tests/test_code_path_audit_ssdl_behavioral.py
T
ed 5ac0618a33 refactor(scripts): move 7 code_path_audit files from src/ to scripts/code_path_audit/
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
2026-06-25 09:29:24 -04:00

101 lines
2.7 KiB
Python

"""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