# Bug 巡查 — 监测槽增强(2026-06-12) **范围**:工作区未提交的 watch 开关 / TTL / 探针修复 **方法**:代码走读 + 单测 + 竞态分析 ## 发现与处理 | # | 严重度 | 问题 | 状态 | |---|--------|------|------| | 1 | **P0** | TTL 到期后 ~5s 内槽位显示「空」,但 DB ghost pin 仍在;添加服务器 → 唯一约束冲突;点 X 移除 → 404「槽位为空」 | **已修** — API 读/写路径同步 `_finalize_due_pins` | | 2 | P2 | `onRemove` 无 try/catch,API 失败时未提示 | 未修(低概率,可跟进) | | 3 | P3 | 暂停态仍可通过 `get_processes` 拉取进程(数据可能过期) | 设计可接受 | | 4 | — | Gate 7 被并行 Agent 提示改动阻塞 | 非 watch bug | ## P0 根因 ``` expires_at 已过 → list 查询 or_(paused, expires_at>now) 排除该行 → UI empty=true → DB 仍有 monitoring_enabled=true 的行 → create_pin / pick 槽位 → IntegrityError ``` 探针循环每 5s 才跑 `expire_due_pins`,此前无 API 侧兜底。 ## 修复 `WatchService._finalize_due_pins()` 在 `list_slots` 及所有槽位变更 API 入口调用,与探针循环逻辑一致:暂停 pin、结束 session、无活跃监测时清 Redis。 ## 测试 ```text pytest tests/test_watch_pins.py → 7 passed pytest tests/test_watch_*.py → 21 passed ``` ## 未部署 生产仍为旧版本;修复需部署后浏览器终验 TTL 归零场景。