Files
Nexus/docs/reports/2026-06-13-session-features-patrol.md
T
Nexus Agent 821cf12ade fix(terminal,alerts): quick-cmd enter on send and offline Telegram channel
Append CR when executing quick commands (fixes trim stripping saved \r) and
allow optional dedicated Telegram bot for server offline alerts only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 01:45:55 +08:00

109 lines
4.0 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.
# 巡检 — 快捷命令回车 + 离线 Telegram 分流 + Layer3 巡检
**日期**2026-06-13
**范围**:本会话两项功能 + 部署门控 + Layer3 宿主机巡检状态
**生产**https://api.synaglobal.vip(本机外网 curl 不可达,见下)
## 进度条
| 步骤 | 状态 |
|------|------|
| 实现 | ✅ 工作区完成 |
| 本地 L2b | ✅ 26/26 + ruff |
| 功能单测 | ✅ 10/10offline 4 + quick-cmd 1 + offline_monitor 5 |
| Layer3 单测 | ✅ `test_ops_patrol_sync.py` 7/7 |
| 前端 build | ✅(此前已构建) |
| 门控 7/7 | ❌ **5/7**Gate 2/7 审计路径、Gate 7 无审计文件) |
| 生产健康 | ⚠️ 外网 `curl` 连接重置;SSH `nexus` 主机名不可解析 |
| 本地 API | ✅ `GET /health``ok` |
| 浏览器终验 | ❌ 待部署 |
---
## 1. 功能变更巡检
### 1.1 终端快捷命令回车
| 检查项 | 结果 |
|--------|------|
| `formatQuickCmdForSend` 发送时补 `\r` | ✅ |
| 设置页不再 `trim``\r` 后入库 | ✅ |
| 内置命令 DB 带 `\r` 幂等 | ✅ 单测逻辑 |
| `pytest test_terminal_quick_commands` | ✅ 1 passed |
### 1.2 子机离线告警独立 Telegram
| 检查项 | 结果 |
|--------|------|
| `resolve_offline_telegram_credentials` 专用优先 / 半配回退 | ✅ 3 case |
| `send_telegram_offline_alert` 传入专用 token/chat | ✅ mock 单测 |
| 资源告警仍走默认 Bot | ✅ 未改 `send_telegram_alert` |
| 设置页离线 Bot UI + 3 API | ✅ 代码 + 构建产物 |
| Layer3 `health_monitor.sh` 使用离线 Bot | ✅ **否**(设计:仅默认 `NEXUS_TELEGRAM_*` |
| `ops_patrol_sync` 同步离线 Token | ✅ **否**(符合设计) |
---
## 2. Layer 3 宿主机巡检
| 项 | 本地状态 |
|----|----------|
| `deploy/health_monitor.sh` 语法 | ✅ `bash -n` 通过 |
| `test_ops_patrol_sync.py` | ✅ 7/7 |
| `.env``NEXUS_TELEGRAM_*` | ❌ 未写入(`env_synced: false` |
| DB `TELEGRAM_BOT_TOKEN/CHAT_ID` | ❌ 本地未配置 |
| 离线专用 `TELEGRAM_OFFLINE_*` | ❌ 未配置(预期:不影响 L3) |
| 生产 cron / `nexus_health.log` | ⚠️ 无法 SSH 核查(`nexus` 主机名不可解析) |
**说明**Layer3 巡检 Telegram 依赖设置页保存后「同步巡检 Telegram」或 `health_monitor.sh` 的 DB 回退;与本次**离线专用 Bot**无关。
---
## 3. 部署门控 `pre_deploy_check.sh`
| Gate | 结果 |
|------|------|
| 1 Changelog | ✅ `2026-06-13-offline-alert-telegram-split.md` |
| 2 Audit | ❌ 缺少 `docs/audit/2026-06-13-*.md`(审计写在 `docs/reports/` |
| 3 Test | ✅ |
| 4 Lint | ✅ |
| 5 Import | ✅ |
| 6 Security | ✅ bandit 0 HIGH |
| 7 Review | ❌ 无 audit 文件对照 diff |
**部署结论****BLOCKED**,需将门控格式审计写入 `docs/audit/2026-06-13-*.md`(含 Step 3 / Closure / DoD 段落)后方可 `deploy-production.sh`
---
## 4. 生产可达性(本环境)
```
curl https://api.synaglobal.vip/health → Recv failure: 连接被对方重置
ssh nexus → Could not resolve hostname
curl http://127.0.0.1:8600/health → ok
```
外网/SSH 失败可能为本机网络或 DNS 限制,**不能据此判定生产宕机**;请在可访问生产的环境复验。
---
## 5. 风险与待办
| 优先级 | 项 | 建议 |
|--------|-----|------|
| P0 部署 | 门控审计路径 | 补 `docs/audit/2026-06-13-offline-quick-cmd-telegram.md` |
| P1 上线 | 前端 `web/app/` | `vite build` 后部署 |
| P1 上线 | 后端重启 | 新 `telegram/offline/*` 端点 |
| P2 运维 | 离线专用 Bot | 设置页配置 + 测试离线通道 |
| P2 运维 | Layer3 | 保存默认 Telegram 后点「同步巡检 Telegram」 |
| P3 | 审计 P3 项 | 见 `docs/reports/2026-06-13-session-features-audit.md` |
---
## 6. 建议部署后终验清单
1. 设置 → 离线专用 Bot → **测试离线通道**
2. 终端 → 自定义快捷命令 → 点击执行有回车
3. 设置 → Layer3 状态芯片「巡检 Telegram 就绪」+ `.env 已同步`(若使用 L3
4. `https://api.synaglobal.vip/health``ok`