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

推荐订阅源

T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Register - Security
The Register - Security
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
N
Netflix TechBlog - Medium
量子位
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
H
Help Net Security
D
Docker
D
DataBreaches.Net
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
B
Blog
博客园 - 聂微东
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
The Cloudflare Blog
F
Full Disclosure
GbyAI
GbyAI
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
有赞技术团队
有赞技术团队
博客园 - 叶小钗
小众软件
小众软件
V
Visual Studio Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
J
Java Code Geeks
雷峰网
雷峰网
P
Privacy & Cybersecurity Law Blog
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Webroot Blog
Webroot Blog
美团技术团队
N
News | PayPal Newsroom
G
Google Developers Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园_首页
V
Vulnerabilities – Threatpost

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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
Merge branch 'main' of https://github.com/openclaw/openclaw · openclaw/openclaw@a53be2d
vincentkoc · 2026-05-03 · via Recent Commits to openclaw:main

@@ -0,0 +1,288 @@

1+

import { afterEach, describe, expect, it, vi } from "vitest";

2+

import type { OpenClawConfig } from "../config/config.js";

3+

import { startHeartbeatRunner } from "./heartbeat-runner.js";

4+

import { computeNextHeartbeatPhaseDueMs, resolveHeartbeatPhaseMs } from "./heartbeat-schedule.js";

5+

import { resetHeartbeatWakeStateForTests } from "./heartbeat-wake.js";

6+7+

/** Verifies that the scheduler seeks to in-window phase slots (#75487). */

8+

describe("heartbeat scheduler: activeHours-aware scheduling (#75487)", () => {

9+

type RunOnce = Parameters<typeof startHeartbeatRunner>[0]["runOnce"];

10+

const TEST_SCHEDULER_SEED = "heartbeat-ah-schedule-test-seed";

11+12+

function useFakeHeartbeatTime(startMs: number) {

13+

vi.useFakeTimers();

14+

vi.setSystemTime(new Date(startMs));

15+

}

16+17+

function heartbeatConfig(overrides?: {

18+

every?: string;

19+

activeHours?: { start: string; end: string; timezone?: string };

20+

userTimezone?: string;

21+

}): OpenClawConfig {

22+

return {

23+

agents: {

24+

defaults: {

25+

heartbeat: {

26+

every: overrides?.every ?? "4h",

27+

...(overrides?.activeHours ? { activeHours: overrides.activeHours } : {}),

28+

},

29+

...(overrides?.userTimezone ? { userTimezone: overrides.userTimezone } : {}),

30+

},

31+

},

32+

};

33+

}

34+35+

function resolveDueFromNow(nowMs: number, intervalMs: number, agentId: string) {

36+

return computeNextHeartbeatPhaseDueMs({

37+

nowMs,

38+

intervalMs,

39+

phaseMs: resolveHeartbeatPhaseMs({

40+

schedulerSeed: TEST_SCHEDULER_SEED,

41+

agentId,

42+

intervalMs,

43+

}),

44+

});

45+

}

46+47+

afterEach(() => {

48+

resetHeartbeatWakeStateForTests();

49+

vi.useRealTimers();

50+

vi.restoreAllMocks();

51+

});

52+53+

it("skips quiet-hours slots and fires at the first in-window phase slot", async () => {

54+

// 09:00–17:00 UTC, 4h interval. Start at 16:30 — raw due is after 17:00.

55+

const startMs = Date.parse("2026-06-15T16:30:00.000Z");

56+

useFakeHeartbeatTime(startMs);

57+58+

const intervalMs = 4 * 60 * 60_000;

59+

const callTimes: number[] = [];

60+

const runSpy: RunOnce = vi.fn().mockImplementation(async () => {

61+

callTimes.push(Date.now());

62+

return { status: "ran", durationMs: 1 };

63+

});

64+65+

const runner = startHeartbeatRunner({

66+

cfg: heartbeatConfig({

67+

every: "4h",

68+

activeHours: { start: "09:00", end: "17:00", timezone: "UTC" },

69+

}),

70+

runOnce: runSpy,

71+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

72+

});

73+74+

const rawDueMs = resolveDueFromNow(startMs, intervalMs, "main");

75+76+

// Advance past the raw due — should NOT fire (quiet hours).

77+

await vi.advanceTimersByTimeAsync(rawDueMs - startMs + 1);

78+79+

// Advance to end of next day's window — should fire within 09:00–17:00.

80+

const safeEndOfWindow = Date.parse("2026-06-16T17:00:00.000Z");

81+

await vi.advanceTimersByTimeAsync(safeEndOfWindow - Date.now());

82+83+

expect(runSpy).toHaveBeenCalled();

84+

const firstCallHourUTC = new Date(callTimes[0]).getUTCHours();

85+

expect(firstCallHourUTC).toBeGreaterThanOrEqual(9);

86+

expect(firstCallHourUTC).toBeLessThan(17);

87+88+

runner.stop();

89+

});

90+91+

it("fires immediately when the first phase slot is already within active hours", async () => {

92+

const startMs = Date.parse("2026-06-15T10:00:00.000Z");

93+

useFakeHeartbeatTime(startMs);

94+95+

const intervalMs = 4 * 60 * 60_000;

96+

const runSpy: RunOnce = vi.fn().mockResolvedValue({ status: "ran", durationMs: 1 });

97+98+

const runner = startHeartbeatRunner({

99+

cfg: heartbeatConfig({

100+

every: "4h",

101+

activeHours: { start: "08:00", end: "20:00", timezone: "UTC" },

102+

}),

103+

runOnce: runSpy,

104+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

105+

});

106+107+

const rawDueMs = resolveDueFromNow(startMs, intervalMs, "main");

108+

await vi.advanceTimersByTimeAsync(rawDueMs - startMs + 1);

109+110+

expect(runSpy).toHaveBeenCalledTimes(1);

111+

runner.stop();

112+

});

113+114+

it("seeks forward correctly with a non-UTC timezone (e.g. America/New_York)", async () => {

115+

// 09:00–17:00 ET (EDT = UTC-4 in June) → 13:00–21:00 UTC.

116+

// Start at 21:30 UTC (17:30 ET = outside window).

117+

const startMs = Date.parse("2026-06-15T21:30:00.000Z");

118+

useFakeHeartbeatTime(startMs);

119+120+

const callTimes: number[] = [];

121+

const runSpy: RunOnce = vi.fn().mockImplementation(async () => {

122+

callTimes.push(Date.now());

123+

return { status: "ran", durationMs: 1 };

124+

});

125+126+

const runner = startHeartbeatRunner({

127+

cfg: heartbeatConfig({

128+

every: "4h",

129+

activeHours: { start: "09:00", end: "17:00", timezone: "America/New_York" },

130+

}),

131+

runOnce: runSpy,

132+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

133+

});

134+135+

await vi.advanceTimersByTimeAsync(48 * 60 * 60_000);

136+137+

expect(runSpy).toHaveBeenCalled();

138+

const firstCallHourUTC = new Date(callTimes[0]).getUTCHours();

139+

expect(firstCallHourUTC).toBeGreaterThanOrEqual(13);

140+

expect(firstCallHourUTC).toBeLessThan(21);

141+142+

runner.stop();

143+

});

144+145+

it("advances to in-window slot after a quiet-hours skip during interval runs", async () => {

146+

// 09:00–17:00 UTC, 4h interval. Verify ALL fires over 48h stay in-window.

147+

const startMs = Date.parse("2026-06-15T09:00:00.000Z");

148+

useFakeHeartbeatTime(startMs);

149+150+

const callTimes: number[] = [];

151+

const runSpy: RunOnce = vi.fn().mockImplementation(async () => {

152+

callTimes.push(Date.now());

153+

return { status: "ran", durationMs: 1 };

154+

});

155+156+

const runner = startHeartbeatRunner({

157+

cfg: heartbeatConfig({

158+

every: "4h",

159+

activeHours: { start: "09:00", end: "17:00", timezone: "UTC" },

160+

}),

161+

runOnce: runSpy,

162+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

163+

});

164+165+

await vi.advanceTimersByTimeAsync(48 * 60 * 60_000);

166+167+

expect(callTimes.length).toBeGreaterThan(0);

168+

for (const t of callTimes) {

169+

const hour = new Date(t).getUTCHours();

170+

expect(

171+

hour,

172+

`fire at ${new Date(t).toISOString()} is outside active window`,

173+

).toBeGreaterThanOrEqual(9);

174+

expect(hour, `fire at ${new Date(t).toISOString()} is outside active window`).toBeLessThan(

175+

17,

176+

);

177+

}

178+179+

runner.stop();

180+

});

181+182+

it("does not loop indefinitely when activeHours window is zero-width", async () => {

183+

// start === end → never-active; seek falls back, runtime guard skips.

184+

const startMs = Date.parse("2026-06-15T10:00:00.000Z");

185+

useFakeHeartbeatTime(startMs);

186+187+

const runSpy: RunOnce = vi.fn().mockResolvedValue({ status: "skipped", reason: "quiet-hours" });

188+189+

const runner = startHeartbeatRunner({

190+

cfg: heartbeatConfig({

191+

every: "30m",

192+

activeHours: { start: "12:00", end: "12:00", timezone: "UTC" },

193+

}),

194+

runOnce: runSpy,

195+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

196+

});

197+198+

await vi.advanceTimersByTimeAsync(2 * 60 * 60_000);

199+200+

expect(runSpy).toHaveBeenCalled();

201+

runner.stop();

202+

});

203+204+

it("recomputes schedule when activeHours config changes via hot reload", async () => {

205+

// Narrow window pushes nextDueMs to tomorrow; widening via updateConfig

206+

// must recompute from `now` so the timer fires today.

207+

const startMs = Date.parse("2026-06-15T14:00:00.000Z");

208+

useFakeHeartbeatTime(startMs);

209+210+

const callTimes: number[] = [];

211+

const runSpy: RunOnce = vi.fn().mockImplementation(async () => {

212+

callTimes.push(Date.now());

213+

return { status: "ran", durationMs: 1 };

214+

});

215+216+

const runner = startHeartbeatRunner({

217+

cfg: heartbeatConfig({

218+

every: "4h",

219+

activeHours: { start: "09:00", end: "10:00", timezone: "UTC" },

220+

}),

221+

runOnce: runSpy,

222+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

223+

});

224+225+

await vi.advanceTimersByTimeAsync(60 * 60_000);

226+

expect(runSpy).not.toHaveBeenCalled();

227+228+

// Widen window — scheduler must recompute, not keep stale tomorrow slot.

229+

runner.updateConfig(

230+

heartbeatConfig({

231+

every: "4h",

232+

activeHours: { start: "08:00", end: "20:00", timezone: "UTC" },

233+

}),

234+

);

235+236+

await vi.advanceTimersByTimeAsync(8 * 60 * 60_000);

237+

expect(runSpy).toHaveBeenCalled();

238+

const firstCallHour = new Date(callTimes[0]).getUTCHours();

239+

expect(firstCallHour).toBeGreaterThanOrEqual(8);

240+

expect(firstCallHour).toBeLessThan(20);

241+

expect(new Date(callTimes[0]).getUTCDate()).toBe(15); // today, not tomorrow

242+243+

runner.stop();

244+

});

245+246+

it("recomputes schedule when activeHours effective timezone changes via hot reload", async () => {

247+

const startMs = Date.parse("2026-06-15T14:00:00.000Z");

248+

useFakeHeartbeatTime(startMs);

249+250+

const callTimes: number[] = [];

251+

const runSpy: RunOnce = vi.fn().mockImplementation(async () => {

252+

callTimes.push(Date.now());

253+

return { status: "ran", durationMs: 1 };

254+

});

255+256+

const activeHours = { start: "16:00", end: "17:00" };

257+

const runner = startHeartbeatRunner({

258+

cfg: heartbeatConfig({

259+

every: "4h",

260+

activeHours,

261+

userTimezone: "America/New_York",

262+

}),

263+

runOnce: runSpy,

264+

stableSchedulerSeed: TEST_SCHEDULER_SEED,

265+

});

266+267+

await vi.advanceTimersByTimeAsync(60 * 60_000);

268+

expect(runSpy).not.toHaveBeenCalled();

269+270+

runner.updateConfig(

271+

heartbeatConfig({

272+

every: "4h",

273+

activeHours,

274+

userTimezone: "UTC",

275+

}),

276+

);

277+278+

const endOfUtcWindow = Date.parse("2026-06-15T17:00:00.000Z");

279+

await vi.advanceTimersByTimeAsync(endOfUtcWindow - Date.now());

280+281+

expect(runSpy).toHaveBeenCalled();

282+

const firstCall = new Date(callTimes[0]);

283+

expect(firstCall.getUTCHours()).toBe(16);

284+

expect(firstCall.getUTCDate()).toBe(15);

285+286+

runner.stop();

287+

});

288+

});