Files
Nexus/docs/reports/2026-06-12-watch-bug-patrol.md
T
Nexus Agent 32a1885f0d feat(watch): 监测槽开关、8h/24h、到期暂停与探针修复
支持随时暂停/恢复实时监测并保留槽位;TTL 到期自动暂停不占删槽;修复到期竞态导致空槽与唯一约束冲突;探针 parse_error 与中文错误;移除失败 snackbar。
2026-06-12 03:47:56 +08:00

41 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 归零场景。