From 847dfd4535e38b5441244b1a2603d5c93b170ce6 Mon Sep 17 00:00:00 2001 From: ogt Date: Sat, 11 Jul 2026 09:59:39 +0800 Subject: [PATCH] fix(governance): align inventory with runtime image --- .../code_modularization_inventory_20260430.md | 2 +- ...debase_modularization_performance_service.py | 17 +++++++++++++++-- ...debase_modularization_performance_service.py | 10 ++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/memory/code_modularization_inventory_20260430.md b/docs/memory/code_modularization_inventory_20260430.md index a2df64d..716d144 100644 --- a/docs/memory/code_modularization_inventory_20260430.md +++ b/docs/memory/code_modularization_inventory_20260430.md @@ -196,5 +196,5 @@ - `python3 scripts/ops/report_codebase_modularization_performance.py` 會為 Python 與前端大型資產建立穩定 work item ID、P0/P1、`in_progress/not_started` 狀態與拆分方向。 - `momo-scheduler` 每日 04:15 執行同一盤點,原子寫入 `data/ai_automation/codebase_inventory/latest.json`;失敗只記 degraded receipt,不得阻斷其他排程。 -- 本次基線:447 個 production Python modules、260,059 行、48 個大於等於 800 行模組、33 個大型前端資產、23 個 P0、6/6 runtime controls 通過;program completion 69.1%,runtime closure 仍為 partial。 +- 本次基線以 production image build context 為準;`.dockerignore` 排除的 `.claude`、data/logs、docs 與 infra sources 不計入 runtime coverage。V10.777 同版 scanner 為 443 個 production Python modules、259,764 行;48 個大模組、33 個大型前端資產、23 個 P0、6/6 runtime controls、program completion 69.1%、runtime closure partial。禁止手動沿用舊的 447-module 基線。 - `services/openclaw_learning_service.py` 已降至 789 行;embedding worker 的唯一 runtime owner 已移到 `momo-scheduler`,因此不再列入大檔債務,但仍需由 production worker/readback 驗證。 diff --git a/services/codebase_modularization_performance_service.py b/services/codebase_modularization_performance_service.py index fe2cd7c..a7ef9d1 100644 --- a/services/codebase_modularization_performance_service.py +++ b/services/codebase_modularization_performance_service.py @@ -21,11 +21,26 @@ IN_PROGRESS_PYTHON_PATHS = { "run_scheduler.py", } IGNORED_PARTS = { + ".claude", + ".docker", ".git", + ".gitea", + ".github", ".pytest_cache", ".venv", "__pycache__", + "aiops-core", "backups", + "data", + "docs", + "k8s", + "logs", + "memory", + "n8n-workflows", + "node_modules", + "runtime_artifacts", + "secrets", + "ssl", "tests", "venv", } @@ -36,8 +51,6 @@ def _iter_python_files(root: Path) -> Iterable[Path]: relative = path.relative_to(root) if any(part in IGNORED_PARTS for part in relative.parts): continue - if relative.parts[:2] in {("docs", "design"), ("docs", "design_audit_frontend")}: - continue yield path diff --git a/tests/test_codebase_modularization_performance_service.py b/tests/test_codebase_modularization_performance_service.py index 28bca33..9ecbd9b 100644 --- a/tests/test_codebase_modularization_performance_service.py +++ b/tests/test_codebase_modularization_performance_service.py @@ -3,6 +3,8 @@ from datetime import datetime, timezone from pathlib import Path from services.codebase_modularization_performance_service import ( + ROOT, + _iter_python_files, build_codebase_inventory, write_codebase_inventory_receipt, ) @@ -44,6 +46,14 @@ def test_inventory_receipt_write_is_atomic_and_readable(tmp_path): assert not target.with_suffix(".json.tmp").exists() +def test_production_inventory_excludes_docker_build_ignored_sources(): + paths = {path.relative_to(ROOT).as_posix() for path in _iter_python_files(ROOT)} + + assert "data/__init__.py" not in paths + assert "logs/__init__.py" not in paths + assert not any(path.startswith(".claude/") for path in paths) + + def test_scheduler_owns_daily_inventory_runtime(): source = (Path(__file__).resolve().parents[1] / "run_scheduler.py").read_text(encoding="utf-8")