守住模組化盤點行數新鮮度

This commit is contained in:
OoO
2026-05-13 16:22:28 +08:00
parent f58c079e8b
commit 1bf2a6b146

View File

@@ -1,3 +1,4 @@
import re
from pathlib import Path
@@ -41,6 +42,34 @@ def test_large_python_modules_are_tracked_in_modularization_inventory():
assert missing == []
def test_modularization_inventory_line_counts_are_current_enough():
inventory = INVENTORY.read_text(encoding="utf-8")
inventory_counts = {
match.group("path"): int(match.group("lines"))
for match in re.finditer(
r"^\|\s*(?P<lines>\d+)\s*\|\s*`(?P<path>[^`]+)`\s*\|",
inventory,
re.MULTILINE,
)
}
large_modules = {
path: lines
for path, lines in _python_line_counts()
if lines >= 800
}
stale = []
for path, current_lines in sorted(large_modules.items()):
recorded_lines = inventory_counts.get(path)
if recorded_lines is None:
continue
allowed_drift = max(50, int(current_lines * 0.1))
if abs(recorded_lines - current_lines) > allowed_drift:
stale.append(f"{path}: recorded={recorded_lines}, current={current_lines}")
assert stale == []
def test_modularization_governance_is_indexed_for_codex_sessions():
agents = (ROOT / "AGENTS.md").read_text(encoding="utf-8")
constitution = (ROOT / "CONSTITUTION.md").read_text(encoding="utf-8")