Commit Graph
32 Commits
Author SHA1 Message Date
张胜宇 c5adf01603 test: 补端点编号守卫与权限判定的 HTTP 层用例
补两道守卫,覆盖 2026-09-12 那次合并评审暴露出来的两个盲区。

一、`docs/05` §19 端点编号唯一性(新增 `tools/check_docs_endpoint_ids.py`)
- 背景:`tools/check_authoritative_docs.py` 只校验 `docs/` 的**文件名编号**,不校验
  §19 的**端点编号**。两条线各自新增端点时都占了 `A034`/`A035`,合并后 §19 同时
  存在两个 `A034` 与两个 `A035`,而文档守卫照样通过 —— 编号复用会静默遗留。
- 口径要点:**不枚举前缀白名单**,前缀从数据里归纳后连同数量一起输出。同一件事上
  还踩过一次"扫描正则写成 `[AMKCS]`,漏掉 `O`/`R` 两段,把 62 个端点报成 55 个"——
  漏掉的号段一旦被复用,脚本仍会报"重复 0"。所以覆盖报告会打印
   `62 个端点编号 / 6 个号段(A×40、C×7、K×4、M×4、O×3、R×4)`,让漏扫本身可见。
- 只读、不依赖任何环境变量(纯解析文档),可在裸检出环境直接跑。

二、端点权限判定的 HTTP 层用例(新增 `tests/unit/api/test_permission_enforcement.py`)
- 背景:既有用例都通过 `build_request_context` 覆写注入**已经带好权限**的上下文,
  只覆盖"有权限能通",覆盖不到"缺权限必须被拒"。而"权限码在库里根本不存在"这类
  环境数据问题(本次三个新权限码)恰恰只会在这一层暴露:权限判定发生在身份解析之后,
  服务层测试自己构造 `RequestContext`,权限字段由测试塞入,所以全绿也照样漏。
- 覆盖客服二期三个权限码对应的 5 个端点:
  `handover:read`(工单列表/详情)、`memory:candidate:review`(候选列表/审核)、
  `memory:candidate:confirm`(用户确认)。
- 正反双向断言:缺权限 → 必须 403 且错误码为 `AGENT_PERMISSION_DENIED`;
  带权限 → **不能**再是 403(这一条把端点要求的权限码钉住,改动即红)。
- 只替换两处边界:`build_request_context`(跳过 JWT 与身份库)与
  `AuthorizationService` 的审计落库(内存替身);真实路由、真实权限判定与真实 403 信封。
- 已做反向验证:给一个不存在的权限码时,5 个端点全部被拒(403),确认正向断言非空过。

验证(隔离 worktree,基线 `origin/qyqy_develop` = 4d8edb4):
pytest tests/unit tests/contract -> 1294 passed, 2 skipped, 0 failed;
ruff check app tests tools alembic 全通过;mypy app 244 源文件 0 错;
check_authoritative_docs(50 份文档无撞号)与本脚本均通过。
2026-09-12 12:57:16 +08:00
张胜宇 f68b052a69 fix: 端点编号去重与 milvus-lite 降为可选依赖
按 qyqy 在 PR #7 评审中的要求处理两项:

- docs/05-接口文档.md §19:客服画像候选的两个端点由 A034/A035 改为 A039/A040。
  原编号与 qyqy 侧登录 / RBAC 只读接口(A034-A038)重复;docs 守卫脚本只校验
  文档文件名编号、不校验 §19 端点编号,因此该重复会静默遗留。改后全表 55 个
  端点编号唯一。
- pyproject.toml / requirements.txt:milvus-lite 由主 dependencies 挪到
  [project.optional-dependencies] dev;requirements.txt 只保留说明性注释,
  不再作为生效依赖。理由:它仅用于本地开发(Docker Milvus 未运行时的本地
  持久化向量库),进主依赖会让生产环境多背一个包。

验证:pytest tests/unit tests/contract -> 1275 passed, 2 skipped, 0 failed;
ruff check app tests tools alembic 通过;mypy app 通过(244 个源文件)。
2026-09-12 11:53:35 +08:00
张胜宇 9aaacc242f chore: 清理违反底座规则的死代码并修正接口文档编号
- 删除生产死代码 app/service/knowledge_tool_service.py 与
  app/infrastructure/milvus_knowledge_adapter.py:后者硬编码 Milvus 字段名,
  违反 AGENTS.md §E,且仅被前者引用;生产检索链路实际走
  knowledge_search_tool -> KnowledgeSearchService -> knowledge_schema 运行时探测。
- 删除上述两模块的单测,以及依赖 legacy 位置参数构造的
  tests/unit/service/test_knowledge_retrieval.py。
- app/service/knowledge_retrieval_service.py 整文件回退底座版本,
  移除 legacy 双构造与重复检索实现。
- docs/05-接口文档.md:客服画像候选改登记为 §8.5,恢复 §8.2 解析知识引用;
  既有 §8.1-§8.4 编号全部保持,修复此前出现两个 8.3 的问题。
- app/model/profile.py:current_customer_id 改为普通可空列映射,与
  alembic/baseline_generated.sql 及真实库一致;原 Computed 声明会让 ORM 把该列
  从 INSERT 中排除,与「必须显式写入」的实际 schema 不符。
- 新增 docs/客服Agent接入底座扩展说明_v1.md,供集成分支评审逐项确认。

验证:pytest tests/unit tests/contract -> 1275 passed, 2 skipped, 0 failed;
ruff check app tests tools alembic 通过;mypy app 通过(244 个源文件)。
2026-09-12 11:15:24 +08:00
张胜宇 e85989b344 merge: integrate latest qyqy_develop (auth login + RBAC read) into ZSY branch
Incremental merge on top of ef701c8, which already integrated the earlier qyqy base bbf623a. qyqy_develop only added commits on top of bbf623a, so this merge is conflict-free. Incoming: account/password login (POST /api/v1/auth/tokens), RBAC read-only query API, rate limit dependency, login test console and user management tools. Additive changes in app/main.py, requirements.txt and pyproject.toml from both sides are all preserved. ZSY side capabilities (visitor tokens, customer service agent, knowledge retrieval, profile projection) are unchanged.
2026-09-12 10:37:53 +08:00
张胜宇 ef701c844c merge: integrate ZSY customer service and profile capabilities 2026-09-11 22:31:51 +08:00
张胜宇 cbcf7c7444 feat: add milvus profile projection 2026-09-11 20:45:50 +08:00
张胜宇 50a611274a feat: target memory sync event replay 2026-09-11 20:26:05 +08:00
张胜宇 5e848f5690 feat: wire neo4j projection into worker 2026-09-11 20:19:34 +08:00
张胜宇 6c605ec3c1 feat: add memory sync outbox worker 2026-09-11 20:07:55 +08:00
张胜宇 f167390a8a feat: add neo4j profile projection adapter 2026-09-11 19:54:46 +08:00
张胜宇 5777f0f86e feat: include memory sources in profile sync events 2026-09-11 19:37:18 +08:00
张胜宇 2de1735673 docs: define profile projection protocol 2026-09-11 19:24:57 +08:00
张胜宇 1eb04f28b1 test: fix mysql profile snapshot cleanup 2026-09-11 18:09:36 +08:00
张胜宇 27174b9ce2 feat: generate approved profile snapshots 2026-09-11 17:58:46 +08:00
张胜宇 a769130658 feat: add profile candidate review workflow 2026-09-11 17:47:06 +08:00
张胜宇 3a21afa847 feat: add customer profile candidate flow 2026-09-11 17:16:43 +08:00
张胜宇 ef098e6a4b feat: complete customer service safety and handover flow 2026-09-11 16:11:30 +08:00
张胜宇 0059701509 fix: persist visitor handover tickets anonymously 2026-09-11 11:57:48 +08:00
张胜宇 9220b7b47c feat: integrate customer service agent into ZSY develop
# Conflicts:
#	app/core/config.py
#	app/main.py
#	app/service/agent/bootstrap.py
2026-09-11 10:46:56 +08:00
张胜宇 a229ec276e docs: add phase one integration gate 2026-09-11 10:27:29 +08:00
张胜宇 c76b763101 feat: configure local customer service knowledge runtime 2026-09-11 10:13:48 +08:00
张胜宇 bc2f521c2e feat: add guarded knowledge publication tool 2026-09-10 22:08:15 +08:00
张胜宇 24f75636a0 feat: add knowledge import preflight 2026-09-10 20:22:53 +08:00
张胜宇 e9b3d272f0 feat: add governed customer service agent 2026-09-10 19:51:08 +08:00
张胜宇 511a8ca18f feat: add governed public knowledge retrieval 2026-09-10 18:42:44 +08:00
张胜宇 ba22a2220f feat: preserve isolated visitor agent runtime 2026-09-10 17:36:39 +08:00
张胜宇 8e36a9941d merge: preserve existing business features on new foundation 2026-09-10 17:26:52 +08:00
张胜宇 a789872c79 test: record pre-migration workspace evidence 2026-09-10 17:11:52 +08:00
张胜宇 d0793355fc docs: add foundation migration implementation plan 2026-09-10 16:59:53 +08:00
张胜宇 5ebed374c4 docs: add safe foundation migration design 2026-09-10 16:36:36 +08:00
张胜宇 ad7172367a feat: add limited visitor tokens 2026-09-10 13:56:08 +08:00
张胜宇 c6be99078e chore: ignore local worktrees 2026-09-10 13:33:59 +08:00