fix(code-review): 修复走查发现的 13 High + Medium 安全/可靠性问题 #2

Closed
fischer wants to merge 0 commits from test/calendar-ui-manual-testing into main
Owner

概述

应用 ce-debug skill 修复 open-code-review 走查发现的 13 High + Medium 问题(8 High 代码 + 5 High 文档 + 17 Medium)。

代码修复(8 High + 9 Medium)

  • portal.py — C1 IDOR 文档 / C2 类型修复 / C3 WS 连接上限 16 / C4 ws_user_id 早初始化 / M silent swallow 日志化
  • auth/middleware.py — C5 WS sid 补齐
  • calendar_tool.py — C6 偏移量 ±43200 双向校验 + reminder_channels 类型/白名单校验
  • sqlite_conversation_store.py — C7 DELETE 事务回滚
  • chat.ts (Pinia) — C8 deleteConversation 清理 pending 缓存
  • app.py — M except: pass → logger.debug(exc_info=True)
  • Scene6Error.vue — M onUnmounted 清理 setTimeout
  • DocumentsTab.vue — M Invalid Date 守卫
  • ChatSidebar/RightPanel/TopNav.vue — M aria-label 无障碍标签
  • SystemMonitorPanel.vue — M v-else 兜底 + active 边框色 + tablist 键盘导航
  • CalendarDrawer.vue — M overflow-y: auto
  • CalendarGrid.vue — M ResizeObserver 反馈循环防护
  • SkillsTab.vue — M onMounted 始终 fetchSkills

文档修复(5 High + 6 Medium)

  • portal-platform-security-reliability-fixes.md — D2 测试路径 / D3 Root Cause+Impact 章节 / D4 severity: mixed / 标题中文化 / 12 处绝对路径转相对 / P2 #12 数字口径
  • AGENTS.md — D5 路由表 22→28 / 专家模板 5→15 / LiteLLM U15 迁移 / 配置查找 fallback
  • README.md — 8 处端口 8000→8001

新增测试

tests/unit/calendar/test_calendar_tool.py — ponytail 自检断言(偏移量边界 / 渠道白名单 / 渠道类型)

验证

  • ruff check (5 文件) — All checks passed
  • vue-tsc --noEmit — exit 0, 无 TypeScript 错误
  • Ponytail 自检断言通过
  • git stash baseline 验证 — portal 17 个 401 失败为预存在问题

已知限制(预存在,非本 PR 引入)

  1. 17 个 portal 测试 401 失败tests/unit/server/test_portal_routes.py 假设无 JWT 即可访问 /api/v1/portal/*,但路由实际要求认证。已通过 baseline 验证确认与本次修复无关
  2. README.md 7 处 CostAwareRouter 引用过时 — AGENTS.md 已替换为 RequestPreprocessor,README 仍保留旧名,建议另起文档同步任务

后续建议

  • 短期:另起 ce-debug 会话调查 portal 路由认证策略
  • 中期:README.md 中 CostAwareRouter → RequestPreprocessor 文档同步
  • 长期:将 portal WS _MAX_CONNECTIONS_PER_USER = 16 下沉到 AuthMiddleware 统一连接管理器
## 概述 应用 ce-debug skill 修复 open-code-review 走查发现的 13 High + Medium 问题(8 High 代码 + 5 High 文档 + 17 Medium)。 ## 代码修复(8 High + 9 Medium) - **portal.py** — C1 IDOR 文档 / C2 类型修复 / C3 WS 连接上限 16 / C4 ws_user_id 早初始化 / M silent swallow 日志化 - **auth/middleware.py** — C5 WS sid 补齐 - **calendar_tool.py** — C6 偏移量 ±43200 双向校验 + reminder_channels 类型/白名单校验 - **sqlite_conversation_store.py** — C7 DELETE 事务回滚 - **chat.ts (Pinia)** — C8 deleteConversation 清理 pending 缓存 - **app.py** — M except: pass → logger.debug(exc_info=True) - **Scene6Error.vue** — M onUnmounted 清理 setTimeout - **DocumentsTab.vue** — M Invalid Date 守卫 - **ChatSidebar/RightPanel/TopNav.vue** — M aria-label 无障碍标签 - **SystemMonitorPanel.vue** — M v-else 兜底 + active 边框色 + tablist 键盘导航 - **CalendarDrawer.vue** — M overflow-y: auto - **CalendarGrid.vue** — M ResizeObserver 反馈循环防护 - **SkillsTab.vue** — M onMounted 始终 fetchSkills ## 文档修复(5 High + 6 Medium) - **portal-platform-security-reliability-fixes.md** — D2 测试路径 / D3 Root Cause+Impact 章节 / D4 severity: mixed / 标题中文化 / 12 处绝对路径转相对 / P2 #12 数字口径 - **AGENTS.md** — D5 路由表 22→28 / 专家模板 5→15 / LiteLLM U15 迁移 / 配置查找 fallback - **README.md** — 8 处端口 8000→8001 ## 新增测试 `tests/unit/calendar/test_calendar_tool.py` — ponytail 自检断言(偏移量边界 / 渠道白名单 / 渠道类型) ## 验证 - ✅ `ruff check` (5 文件) — All checks passed - ✅ `vue-tsc --noEmit` — exit 0, 无 TypeScript 错误 - ✅ Ponytail 自检断言通过 - ✅ `git stash` baseline 验证 — portal 17 个 401 失败为预存在问题 ## 已知限制(预存在,非本 PR 引入) 1. **17 个 portal 测试 401 失败** — `tests/unit/server/test_portal_routes.py` 假设无 JWT 即可访问 `/api/v1/portal/*`,但路由实际要求认证。已通过 baseline 验证确认与本次修复无关 2. **README.md 7 处 CostAwareRouter 引用过时** — AGENTS.md 已替换为 RequestPreprocessor,README 仍保留旧名,建议另起文档同步任务 ## 后续建议 - 短期:另起 ce-debug 会话调查 portal 路由认证策略 - 中期:README.md 中 CostAwareRouter → RequestPreprocessor 文档同步 - 长期:将 portal WS `_MAX_CONNECTIONS_PER_USER = 16` 下沉到 AuthMiddleware 统一连接管理器
fischer added 3 commits 2026-06-28 15:10:01 +08:00
43e9025c6d fix(calendar): 日历能力缺失修复 + UI 布局优化 + 会话404处理
P0: calendar_tool reminder_rules 未传入 create_event,提醒功能完全失效。P1: chat.ts deleteConversation 未清理 pending + 404 递归保护。P2: app.py 系统提示重复段落 + gui_mode F821 + SystemMonitorPanel flex 布局。P3: portal send_json 快照 + WS connected 清除 is_local + 移除死代码。验证: ruff+pytest 98passed+typecheck 通过。
c9ce15fa4b fix(code-review): 修复走查发现的 13 High + Medium 安全/可靠性问题
代码修复(8 High + 9 Medium):
- portal.py — C1 IDOR 文档 / C2 类型修复 / C3 WS 连接上限 16 / C4 ws_user_id 早初始化 / M silent swallow 日志化
- auth/middleware.py — C5 WS sid 补齐
- calendar_tool.py — C6 偏移量 ±43200 双向校验 + reminder_channels 类型/白名单校验
- sqlite_conversation_store.py — C7 DELETE 事务回滚
- chat.ts (Pinia) — C8 deleteConversation 清理 pending 缓存
- app.py — M except: pass → logger.debug(exc_info=True)
- Scene6Error.vue — M onUnmounted 清理 setTimeout
- DocumentsTab.vue — M Invalid Date 守卫
- ChatSidebar/RightPanel/TopNav.vue — M aria-label 无障碍标签
- SystemMonitorPanel.vue — M v-else 兜底 + active 边框色 + tablist 键盘导航
- CalendarDrawer.vue — M overflow-y: auto
- CalendarGrid.vue — M ResizeObserver 反馈循环防护
- SkillsTab.vue — M onMounted 始终 fetchSkills

文档修复(5 High + 6 Medium):
- portal-platform-security-reliability-fixes.md — D2 测试路径 / D3 Root Cause+Impact 章节 / D4 severity: mixed / 标题中文化 / 12 处绝对路径转相对 / P2 #12 数字口径
- AGENTS.md — D5 路由表 22→28 / 专家模板 5→15 / LiteLLM U15 迁移 / 配置查找 fallback
- README.md — 8 处端口 8000→8001

新增测试:
- tests/unit/calendar/test_calendar_tool.py — ponytail 自检断言

验证:
- ruff check (5 文件) — All checks passed
- vue-tsc --noEmit — exit 0
- git stash baseline 验证 — portal 17 个 401 失败为预存在问题

已知限制(预存在):
- 17 个 portal 测试 401 失败 — 需另起 ce-debug 调查
- README.md 7 处 CostAwareRouter 引用过时 — 文档同步另起任务
fischer added 1 commit 2026-06-28 15:26:55 +08:00
d27681a93c fix(portal-auth): 修复 dev mode JWT 验证误激活 + README 文档同步
## Portal 401 根因修复

问题:AGENTKIT_JWT_SECRET 未设置时,jwt_utils 生成 ephemeral 非空 secret,
该 secret 被传给 AuthMiddleware 后 _is_dev_mode() 返回 False(not "" = False),
导致无 JWT/API key 的请求被拒为 401(17 个 portal 测试失败)。

修复:分离 explicit_jwt_secret 与 jwt_secret —
- explicit_jwt_secret = get_jwt_secret()  # None when env unset
- jwt_secret = explicit_jwt_secret or get_or_create_jwt_secret()  # for signing
- AuthMiddleware(jwt_secret=explicit_jwt_secret or "")  # only explicit activates JWT verify

ephemeral secret 仅供 token 签名 routes,不激活 middleware 的 JWT 验证。
生产环境(AGENTKIT_JWT_SECRET 已设置)行为不变。

验证:
- _is_dev_mode(): False → True
- GET /api/v1/portal/conversations: 401 → 200
- 27 个 portal 测试全部通过(之前 17 失败)
- 232 个测试通过 (portal + auth + calendar),0 失败

## README 文档同步

代码中 CostAwareRouter / RegexRules / HeuristicClassifier / SemanticRouter / LLMClassifier
类已完全删除,仅 RequestPreprocessor 存在。README.md 6 处过时引用同步:

- 第 4 节"意图路由"改为引用 RequestPreprocessor(详见第 7 节)
- 第 7 节重写为"请求预处理(RequestPreprocessor)",按 AGENTS.md 架构描述
- 第 8 节"语义路由"删除(合并入第 7 节历史说明)
- 架构图 CostAwareRouter → RequestPreprocessor,22→28 路由模块
- 模块详解 chat/skill_routing + chat/semantic_router 合并为 chat/request_preprocessor
- 模块详解 router/intent 描述更新为"未接入 chat 流程"
- 目录注释 CostAwareRouter → RequestPreprocessor
- 章节重新编号 1-16 连续(原 1-17 跳过 9)
fischer closed this pull request 2026-06-29 09:27:57 +08:00
Some checks failed
Test / backend-test (pull_request) Has been cancelled
Test / frontend-unit (pull_request) Has been cancelled
Test / api-e2e (pull_request) Has been cancelled
Test / frontend-e2e (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fischer/fischer-agentkit#2
No description provided.