From daccc375197c86c3b9c00b2c34fc1ce3caa3d590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Mon, 12 Oct 2026 15:07:39 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=AE=A1=E5=88=92=E5=A4=8D=E5=AE=A1?= =?UTF-8?q?=E6=94=B6=E5=B0=BE=EF=BC=88anti=5Fkill=20=E6=AE=8B=E7=95=99?= =?UTF-8?q?=E6=B8=85=E9=99=A4/7=E4=B8=AA=E6=B5=8B=E8=AF=95=E6=96=87?= =?UTF-8?q?=E4=BB=B6/health=20=E6=96=AD=E8=A8=80/config=20=E6=B3=A8?= =?UTF-8?q?=E8=AE=B0/static=20=E6=8B=B7=E8=B4=9D=E5=8E=BB=20admin.html?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- ...26-10-12-phase1-engine-merge-tenantization.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/superpowers/plans/2026-10-12-phase1-engine-merge-tenantization.md b/docs/superpowers/plans/2026-10-12-phase1-engine-merge-tenantization.md index 7b000b4..582150a 100644 --- a/docs/superpowers/plans/2026-10-12-phase1-engine-merge-tenantization.md +++ b/docs/superpowers/plans/2026-10-12-phase1-engine-merge-tenantization.md @@ -85,7 +85,7 @@ jc/app/providers/ → app/engine/providers/ jc/app/api/routes/ → app/engine/routes/ (admin.py 本阶段不拷,Phase 2 重写) jc/app/models/database.py → app/engine/models.py jc/app/prompts/ → app/engine/prompts/ (4 个 md 原样) -jc/app/config.py → app/engine/config.py (暂留,Task 3 拆) +jc/app/config.py → app/engine/config.py (Phase 1 全程暂留作 .env 回退;Task 9 的 email 平台默认回退读它) jc/tests/ → tests/ (去掉 test_admin_*;Phase 2 恢复) jc/pytest.ini 的 testpaths 已在 Task 1 建 ``` @@ -96,7 +96,7 @@ jc/pytest.ini 的 testpaths 已在 Task 1 建 - [ ] **Step 3: 过渡版 app/main.py —— 照抄 jc main.py 全文(含模块级 engine/async_session/Base 与 lifespan),只改 import 路径与去掉 admin 路由** -⚠️ **不要写"最小 main"**:`chat.py`/`chat_rest.py`/`lead_push_service.py` 都 `from app.main import async_session`,jc 的 conftest 还 `from app.main import engine`——jc conftest 里文档化过 main→chat_rest 的循环导入次序坑。过渡期保留 jc main.py 的全局 engine/async_session 结构(Task 5 才由 Registry 接管),admin 路由 import 行删除。同时先把 `jc/static/` 整目录拷到 `static/`(Task 10 才改造,但 `StaticFiles(directory="static")` 需要目录先存在)。 +⚠️ **不要写"最小 main"**:`chat.py`/`chat_rest.py`/`lead_push_service.py` 都 `from app.main import async_session`,jc 的 conftest 还 `from app.main import engine`——jc conftest 里文档化过 main→chat_rest 的循环导入次序坑。过渡期保留 jc main.py 的全局 engine/async_session 结构(Task 5 才由 Registry 接管),admin 路由 import 行删除。同时先把 `jc/static/` 整目录拷到 `static/`(删掉 admin.html——旧单文件后台,Phase 2 重写;Task 10 才改造其余文件,但 `StaticFiles(directory="static")` 需要目录先存在)。 - [ ] **Step 4: 跑全量测试建立基线** @@ -237,7 +237,7 @@ git add app/platform tests/test_config_merge.py && git commit -m "feat: 出厂 ⚠️ **anti_kill 不设字段**:两个源项目的防误杀都不是独立常量,而是内嵌在正则断言里(如后顾放行、`(?!\s*(公里|km))` 排除)——没有可提取的"清单"。两租户防误杀差异由各自 price_patterns 自带断言体现,CompiledWall 不设 anti_kill。 -`seed_profiles/auto/wall.json`:同一结构,price_patterns 用上游 ai-kefu 的中英+$ 词表、anti_kill 换汽车清单(km/年款等)、deflections 去掉 es。 +`seed_profiles/auto/wall.json`:同一结构,price_patterns 用上游 ai-kefu 的中英+$ 词表(汽车防误杀断言如 km/年款内置于其 pattern)、deflections 去掉 es。 - [ ] **Step 2: 写编译器(先写失败测试)** @@ -278,9 +278,9 @@ class WallConfigError(ValueError): pass class CompiledWall: price_patterns: tuple deflections: dict + deflections_contact: dict no_contact: dict triggers: dict # 每值 tuple[re.Pattern] - anti_kill: tuple cc_templates: dict def compile_wall(cfg: dict) -> CompiledWall: @@ -485,9 +485,9 @@ git add -A && git commit -m "feat: PromptProvider 化 + $DEFLECTION_POOL 单一 from fastapi.testclient import TestClient # conftest 提供 build_app(seed_dir, data_dir) 工厂 -def test_known_host_routes_to_tenant(app_client): - r = app_client.get("/api/public/brand-not-exist-yet") # 先用 /health 或 404 路由验证不 500 - assert r.status_code in (200, 404) +def test_known_host_serves_health(app_client): + r = app_client.get("/health") + assert r.status_code == 200 def test_unknown_host_gets_404(app_client): app_client.headers = {"host": "nope.example.com"} @@ -665,7 +665,7 @@ def test_widget_keys_namespaced_by_slug(): - Modify: `static/widget.js`(placeholder 可配置——对齐 ai-kefu 的 input-placeholder 实现,读 brand.placeholder + data-placeholder 覆盖) - Test: 从 `D:\refactor\ai-kefu\tests\` 拷入 `test_channel_hygiene.py`、`test_chat_rest_ip.py`、`test_lead_push_cc.py`、`test_cc_integration.py`、`test_prompt_static.py`、`test_ip_service_region.py`、`test_placeholder_static.py` → 修 import 跑绿(行为以 jc 实现为准,断言不适处改断言不改实现) -- [ ] **Step 1: 拷 6 个测试文件、修 import、跑** +- [ ] **Step 1: 拷 7 个测试文件、修 import、跑** - [ ] **Step 2: 红→绿循环**:失败断言逐条判断是"上游测的旧行为"(改断言)还是"jc 缺的修复"(补实现,注明同步自上游) - [ ] **Step 3: 提交** `git commit -m "feat: 吸收上游测试断言与 placeholder 配置化"`