# Host Restart Service

> 重启允许列表内的 systemd service（mutating，触发 reviewer 二审）

- Skill: `ongridio/host-restart-service` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ongridio/host-restart-service`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ongridio/host-restart-service/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ongridio (https://skillmd.com/u/ongridio)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ongridio/host-restart-service

---


[能力: host_restart_service]

本工具**重启**目标设备上的 systemd 服务。属于 **mutating** class，调用前自动经过 reviewer 二审：

## 调用规则

```
host_restart_service(device_id=<num>, service="nginx", reason="...")
```

- `device_id` 必填：与 @-mention chip 和 Prom `device_id` label 一致
- `service` 必填：systemd 短名（**不带** `.service` 后缀）
- `reason` 强烈建议填：写入审计行，事后复盘看得到为什么重启的

## 白名单

调用前自动检查 service ∈ 下列之一：

- `nginx` / `redis` / `prometheus` / `loki` / `tempo` / `grafana` / `mysql` / `ongrid`

其他 service 直接拒绝（不走 reviewer，省一次 LLM 调用）。

## 二审流程（HLD-003 SOP）

```
你 (coordinator) 发出 host_restart_service tool_call
      ↓
ReviewGate 装饰器拦截
      ↓ class="write"|"destructive"
      ↓ spawn reviewer worker (agents/reviewer.md)
      ↓ 等 reviewer 输出 "Decision: approve" 或 "Decision: reject"
      ↓
approve → 真正调用边端 systemctl restart
reject  → 返回 reject 理由给你，**不要重试，转告用户**
```

reviewer 自己会用 `get_edge_summary` / `query_logql` / `get_incident_detail` 看 SOP /
并行操作 / 上次 mutating 时间 / 关联告警再决议；你不需要重复这些查询。

## 不要做的事

- 不要在用户没明说"重启 X"时调用 — 主动建议重启是反模式
- 不要 reject 后立刻重试 — reviewer 已经给了理由，转告用户让他决定
- 不要试图绕过白名单 — 边端会再校验一次，绕不过
- 不要传 `reason=""` — 审计行会一片空白，post-mortem 会骂

## 一期实现 (PR-7)

- 边端 handler 是 **mock**（`Mocked: true`），不会真跑 `systemctl restart`
- 真实 shell-out 留 follow-up；本期目标是把 reviewer 二审端到端跑通

