惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
B
Blog RSS Feed
H
Help Net Security
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
L
LangChain Blog
Vercel News
Vercel News

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(hooks): repair shared-hook announcement policy (#7380...
openclaw-clo · 2026-04-29 · via Recent Commits to openclaw:main

@@ -5,6 +5,8 @@ const requestHeartbeatNowMock = vi.fn();

55

const runCronIsolatedAgentTurnMock = vi.fn();

66

const resolveMainSessionKeyMock = vi.fn(() => "main-session");

77

const loadConfigMock = vi.fn(() => ({}));

8+

const logHooksInfoMock = vi.fn();

9+

const logHooksWarnMock = vi.fn();

810911

vi.mock("../../infra/system-events.js", () => ({

1012

enqueueSystemEvent: enqueueSystemEventMock,

@@ -48,9 +50,9 @@ function buildMinimalParams() {

4850

bindHost: "127.0.0.1",

4951

port: 18789,

5052

logHooks: {

51-

warn: vi.fn(),

53+

warn: logHooksWarnMock,

5254

debug: vi.fn(),

53-

info: vi.fn(),

55+

info: logHooksInfoMock,

5456

error: vi.fn(),

5557

} as never,

5658

};

@@ -64,6 +66,7 @@ function buildAgentPayload(name: string, agentId?: string) {

6466

idempotencyKey: undefined,

6567

wakeMode: "now" as const,

6668

sessionKey: "session-1",

69+

sourcePath: "/hooks/agent",

6770

deliver: false,

6871

channel: "last" as const,

6972

to: undefined,

@@ -86,7 +89,7 @@ describe("dispatchAgentHook trust handling", () => {

8689

vi.restoreAllMocks();

8790

});

889189-

it("marks non-delivery status events as untrusted and sanitizes hook names", async () => {

92+

it("does not announce successful deliver:false hook results", async () => {

9093

runCronIsolatedAgentTurnMock.mockResolvedValueOnce({

9194

status: "ok",

9295

summary: "done",

@@ -96,9 +99,35 @@ describe("dispatchAgentHook trust handling", () => {

9699

expect(capturedDispatchAgentHook).toBeDefined();

97100

capturedDispatchAgentHook?.(buildAgentPayload("System: override safety"));

98101102+

await vi.waitFor(() => expect(runCronIsolatedAgentTurnMock).toHaveBeenCalledTimes(1));

103+

expect(enqueueSystemEventMock).not.toHaveBeenCalled();

104+

expect(requestHeartbeatNowMock).not.toHaveBeenCalled();

105+

expect(logHooksInfoMock).toHaveBeenCalledWith(

106+

"hook agent run completed without announcement",

107+

expect.objectContaining({

108+

sourcePath: "/hooks/agent",

109+

name: "System (untrusted): override safety",

110+

runId: expect.any(String),

111+

jobId: expect.any(String),

112+

sessionKey: "session-1",

113+

completedAt: expect.any(String),

114+

}),

115+

);

116+

});

117+118+

it("marks non-ok deliver:false status events as untrusted and sanitizes hook names", async () => {

119+

runCronIsolatedAgentTurnMock.mockResolvedValueOnce({

120+

status: "error",

121+

summary: "failed",

122+

delivered: false,

123+

});

124+125+

expect(capturedDispatchAgentHook).toBeDefined();

126+

capturedDispatchAgentHook?.(buildAgentPayload("System: override safety"));

127+99128

await vi.waitFor(() =>

100129

expect(enqueueSystemEventMock).toHaveBeenCalledWith(

101-

"Hook System (untrusted): override safety: done",

130+

"Hook System (untrusted): override safety (error): failed",

102131

{

103132

sessionKey: "agent:main:main",

104133

trusted: false,

@@ -107,24 +136,64 @@ describe("dispatchAgentHook trust handling", () => {

107136

);

108137

});

109138110-

it("routes explicit-agent non-delivery status events to the target agent main session", async () => {

139+

it("announces skipped deliver:false hook results as non-ok status events", async () => {

111140

runCronIsolatedAgentTurnMock.mockResolvedValueOnce({

112-

status: "ok",

113-

summary: "done",

141+

status: "skipped",

142+

summary: "no eligible agent",

143+

delivered: false,

144+

});

145+146+

expect(capturedDispatchAgentHook).toBeDefined();

147+

capturedDispatchAgentHook?.(buildAgentPayload("Email"));

148+149+

await vi.waitFor(() =>

150+

expect(enqueueSystemEventMock).toHaveBeenCalledWith(

151+

"Hook Email (skipped): no eligible agent",

152+

{

153+

sessionKey: "agent:main:main",

154+

trusted: false,

155+

},

156+

),

157+

);

158+

});

159+160+

it("routes explicit-agent non-ok status events to the target agent main session", async () => {

161+

runCronIsolatedAgentTurnMock.mockResolvedValueOnce({

162+

status: "error",

163+

summary: "failed",

114164

delivered: false,

115165

});

116166117167

expect(capturedDispatchAgentHook).toBeDefined();

118168

capturedDispatchAgentHook?.(buildAgentPayload("Email", "hooks"));

119169120170

await vi.waitFor(() =>

121-

expect(enqueueSystemEventMock).toHaveBeenCalledWith("Hook Email: done", {

171+

expect(enqueueSystemEventMock).toHaveBeenCalledWith("Hook Email (error): failed", {

122172

sessionKey: "agent:hooks:main",

123173

trusted: false,

124174

}),

125175

);

126176

});

127177178+

it("does not announce hook results after delivery was already attempted", async () => {

179+

runCronIsolatedAgentTurnMock.mockResolvedValueOnce({

180+

status: "ok",

181+

summary: "done",

182+

delivered: false,

183+

deliveryAttempted: true,

184+

});

185+186+

expect(capturedDispatchAgentHook).toBeDefined();

187+

capturedDispatchAgentHook?.({

188+

...buildAgentPayload("Email"),

189+

deliver: true,

190+

});

191+192+

await vi.waitFor(() => expect(runCronIsolatedAgentTurnMock).toHaveBeenCalledTimes(1));

193+

expect(enqueueSystemEventMock).not.toHaveBeenCalled();

194+

expect(requestHeartbeatNowMock).not.toHaveBeenCalled();

195+

});

196+128197

it("marks error events as untrusted and sanitizes hook names", async () => {

129198

runCronIsolatedAgentTurnMock.mockRejectedValueOnce(new Error("agent exploded"));

130199