From 71912809eb559410af34026470759dd36f747aa5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:00:48 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E4=BB=A3=E7=A0=81=E5=AE=A1?= =?UTF-8?q?=E6=9F=A5=E4=BF=AE=E5=A4=8D:=20Registry=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B5=B0=E6=A8=A1=E5=9D=97=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E6=96=B9=E6=B3=95+HLDP=E9=98=9F=E5=88=97=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E9=99=90=E5=88=B6+NOT=20EXISTS=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/e6744e69-7bd7-44fd-afcd-cc69135c95aa Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- server/age-os/agents/hldp-bus.js | 11 ++++++++++- server/age-os/agents/module-registry.js | 3 +-- server/age-os/agents/sy-scan.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/age-os/agents/hldp-bus.js b/server/age-os/agents/hldp-bus.js index abdca72d..1e8d9337 100644 --- a/server/age-os/agents/hldp-bus.js +++ b/server/age-os/agents/hldp-bus.js @@ -41,6 +41,7 @@ class HLDPBus { // ─── 消息队列(内存) ─── this._queues = new Map(); // moduleId → [messages] this._handlers = new Map(); // msgType → [handler] + this._maxQueueSize = 1000; // 每个模块最多1000条待处理消息 // ─── 广播订阅 ─── this._subscribers = new Map(); // topic → Set(moduleId) @@ -82,7 +83,15 @@ class HLDPBus { if (!this._queues.has(toModule)) { this._queues.set(toModule, []); } - this._queues.get(toModule).push(message); + const queue = this._queues.get(toModule); + + // 队列大小限制:丢弃最旧的消息 + if (queue.length >= this._maxQueueSize) { + queue.shift(); + this.stats.totalFailed++; + } + + queue.push(message); // 持久化 await this._persistMessage(message); diff --git a/server/age-os/agents/module-registry.js b/server/age-os/agents/module-registry.js index 6a76d6c6..8bcf3f84 100644 --- a/server/age-os/agents/module-registry.js +++ b/server/age-os/agents/module-registry.js @@ -193,9 +193,8 @@ class ModuleRegistry { const sinceLastHeart = now - module.lastHeartbeatAt.getTime(); if (sinceLastHeart > this._heartbeatTimeoutMs && module.status === 'alive') { console.warn(`[Registry] ${moduleId} 心跳超时 ${Math.round(sinceLastHeart / 1000)}秒`); - module.status = 'degraded'; - // 尝试触发自诊断 + // 通过模块自身的诊断方法更新状态 try { await module.selfDiagnose(); } catch (err) { diff --git a/server/age-os/agents/sy-scan.js b/server/age-os/agents/sy-scan.js index 109fa42c..1c7e0a67 100644 --- a/server/age-os/agents/sy-scan.js +++ b/server/age-os/agents/sy-scan.js @@ -98,7 +98,7 @@ class LivingSyScan extends LivingModule { // 尝试清理空目录 try { await db.query( - "UPDATE brain_nodes SET status = 'archived' WHERE node_type = 'folder' AND status = 'active' AND id NOT IN (SELECT DISTINCT parent_id FROM brain_nodes WHERE parent_id IS NOT NULL AND status = 'active')" + "UPDATE brain_nodes bn SET status = 'archived' WHERE bn.node_type = 'folder' AND bn.status = 'active' AND NOT EXISTS (SELECT 1 FROM brain_nodes child WHERE child.parent_id = bn.id AND child.status = 'active')" ); return { action: 'empty_folders_archived', success: true }; } catch (err) {