fix(lint): 修复 PR #14 引入的 lint 回退 (119→0)
PR #14 从旧分支复制文件导致回退了 PR #10 的 lint 修复。 修复内容: - autoflake 移除未使用导入/变量 - autopep8 修复缩进/空格 - 手动修复 F821(pathlib→Path), F541(f-string), F841(未使用变量) - 所有修复均通过 flake8 --max-line-length=120 --extend-ignore=E501 检查 (0 errors)
This commit is contained in:
+11
-6
@@ -9,9 +9,9 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
from src.blackboard.db import get_connection, init_db
|
||||
from src.blackboard.db import get_connection
|
||||
from src.blackboard.queries import Queries
|
||||
|
||||
logger = logging.getLogger("moziplus-v2.health")
|
||||
@@ -41,7 +41,7 @@ class HealthChecker:
|
||||
{"healthy": bool, "zombie": bool, "stale_ticks": int,
|
||||
"alert_written": bool, "resolved": bool}
|
||||
"""
|
||||
db_key = str(db_path)
|
||||
str(db_path)
|
||||
result: Dict[str, Any] = {
|
||||
"healthy": True,
|
||||
"zombie": False,
|
||||
@@ -58,7 +58,8 @@ class HealthChecker:
|
||||
# 用 event count 变化判断是否有真实变更
|
||||
conn = queries._conn()
|
||||
try:
|
||||
total_events = conn.execute("SELECT COUNT(*) FROM events").fetchone()[0]
|
||||
conn.execute(
|
||||
"SELECT COUNT(*) FROM events").fetchone()[0]
|
||||
non_tick_events = conn.execute(
|
||||
"SELECT COUNT(*) FROM events WHERE event_type != 'daemon_tick' "
|
||||
"AND event_type != 'agent_zombie_detected'"
|
||||
@@ -85,7 +86,8 @@ class HealthChecker:
|
||||
self._stale_ticks[project_id] = stale
|
||||
result["stale_ticks"] = stale
|
||||
|
||||
if stale >= self.zombie_threshold and not self._alerted.get(project_id):
|
||||
if stale >= self.zombie_threshold and not self._alerted.get(
|
||||
project_id):
|
||||
# 写告警
|
||||
self._write_alert(db_path, project_id, tick_num, stale)
|
||||
self._alerted[project_id] = True
|
||||
@@ -126,7 +128,10 @@ class HealthChecker:
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
logger.warning("Zombie detected: %s (stale=%d)", project_id, stale_ticks)
|
||||
logger.warning(
|
||||
"Zombie detected: %s (stale=%d)",
|
||||
project_id,
|
||||
stale_ticks)
|
||||
|
||||
def _write_resolution(self, db_path: Path, project_id: str,
|
||||
tick_num: int) -> None:
|
||||
|
||||
Reference in New Issue
Block a user