docs(modularization): 建立模組化治理守門
All checks were successful
CD Pipeline / deploy (push) Successful in 1m36s
All checks were successful
CD Pipeline / deploy (push) Successful in 1m36s
This commit is contained in:
44
tests/test_modularization_governance.py
Normal file
44
tests/test_modularization_governance.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
INVENTORY = ROOT / "docs/memory/code_modularization_inventory_20260430.md"
|
||||
GUIDE = ROOT / "docs/guides/modularization_governance.md"
|
||||
|
||||
|
||||
def _python_line_counts():
|
||||
ignored_parts = {".git", "venv", "__pycache__", ".pytest_cache"}
|
||||
for path in ROOT.rglob("*.py"):
|
||||
if any(part in ignored_parts for part in path.relative_to(ROOT).parts):
|
||||
continue
|
||||
with path.open(encoding="utf-8", errors="ignore") as handle:
|
||||
yield path.relative_to(ROOT).as_posix(), sum(1 for _ in handle)
|
||||
|
||||
|
||||
def test_large_python_modules_are_tracked_in_modularization_inventory():
|
||||
inventory = INVENTORY.read_text(encoding="utf-8")
|
||||
large_modules = {
|
||||
path: lines
|
||||
for path, lines in _python_line_counts()
|
||||
if lines >= 800
|
||||
}
|
||||
|
||||
assert large_modules, "盤點應至少包含目前既有大檔"
|
||||
missing = [
|
||||
f"{path} ({lines} lines)"
|
||||
for path, lines in sorted(large_modules.items())
|
||||
if f"`{path}`" not in inventory
|
||||
]
|
||||
assert missing == []
|
||||
|
||||
|
||||
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")
|
||||
memory_index = (ROOT / "docs/memory/README.md").read_text(encoding="utf-8")
|
||||
|
||||
assert "docs/guides/modularization_governance.md" in agents
|
||||
assert "docs/guides/modularization_governance.md" in constitution
|
||||
assert "code_modularization_inventory_20260430.md" in agents
|
||||
assert "code_modularization_inventory_20260430.md" in memory_index
|
||||
assert GUIDE.exists()
|
||||
Reference in New Issue
Block a user