From 49c576bc4fb01835092823568b3597c44226ded1 Mon Sep 17 00:00:00 2001 From: OoO Date: Wed, 13 May 2026 11:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=99=E5=AE=9A=20PG=20sync=20=E7=82=BA=20op?= =?UTF-8?q?t-in=20=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../claude_inventory_validation_20260513.md | 1 + tests/test_pg_sync_contract.py | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/test_pg_sync_contract.py diff --git a/docs/memory/claude_inventory_validation_20260513.md b/docs/memory/claude_inventory_validation_20260513.md index 211ec6b..06ec7a9 100644 --- a/docs/memory/claude_inventory_validation_20260513.md +++ b/docs/memory/claude_inventory_validation_20260513.md @@ -48,6 +48,7 @@ - `paramiko` 已確認沒有 runtime import;ADR-013 現行實作改以 `utils/ssh_helper.py` 組 CLI `ssh`,因此已從 `requirements.txt` 移除並補測試防止依賴殘影回來。 - `pgvector` Python package 與 `matplotlib-inline` 已確認不是 runtime 依賴:pgvector 走 PostgreSQL extension + 本地 SQLAlchemy `Vector` type,Jupyter inline backend 不屬 production path;兩者已從 `requirements.txt` 移除並補測試。 - `tests/test_pg_sync.py` 已改為 opt-in integration test:預設不再連 localhost PostgreSQL 或建立/刪除測試表,需 `RUN_PG_SYNC_INTEGRATION=1` 且提供 `POSTGRES_PASSWORD` 才執行。 +- `services/pg_sync_service.py` 是顯式 opt-in legacy CLI,不是生產自動同步路徑;`tests/test_pg_sync_contract.py` 已守住預設 OFF 與 runtime paths 不自動 import。 - `qwen3:14b` 不是未使用 Ollama 模型:OpenClaw QA、NemoTron dispatch 與 LLM model router 仍有現役路徑;`tests/test_qwen3_runtime_usage.py` 已守住,不能只因體積大就三主機移除。 - Telegram `momo:eig:` callback 已在 `routes/openclaw_bot_routes.py` 與 `services/telegram_bot_service.py` 實作並有 webhook 測試覆蓋,不是未實作缺口。 - Telegram `date_*` / `goal_*` 不是死 callback handler:按鈕先送 `await:*` 進入輸入等待狀態,使用者下一則文字才由 pending action 消費;`tests/test_openclaw_bot_menu_keyboards.py` 與 `tests/test_openclaw_bot_routes_webhook.py` 已覆蓋。 diff --git a/tests/test_pg_sync_contract.py b/tests/test_pg_sync_contract.py new file mode 100644 index 0000000..ac5f624 --- /dev/null +++ b/tests/test_pg_sync_contract.py @@ -0,0 +1,36 @@ +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] + + +def test_pg_sync_service_remains_explicit_opt_in_legacy_tool(): + source = (ROOT / "services" / "pg_sync_service.py").read_text(encoding="utf-8") + + assert "PG_SYNC_ENABLED', 'false'" in source + assert "python services/pg_sync_service.py --full" in source + assert "python services/pg_sync_service.py --verify" in source + assert "python services/pg_sync_service.py --daemon" in source + + +def test_runtime_paths_do_not_auto_wire_pg_sync_service(): + active_paths = [ + ROOT / "app.py", + ROOT / "scheduler.py", + ROOT / "run_scheduler.py", + ROOT / "routes", + ROOT / "services", + ] + forbidden = "services.pg_sync_service" + offenders = [] + + for active_path in active_paths: + paths = active_path.rglob("*.py") if active_path.is_dir() else [active_path] + for path in paths: + if path.name == "pg_sync_service.py" or "__pycache__" in path.parts: + continue + source = path.read_text(encoding="utf-8") + if forbidden in source: + offenders.append(str(path.relative_to(ROOT))) + + assert offenders == []