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

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
爱范儿
爱范儿
月光博客
月光博客
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
T
Tailwind CSS Blog
美团技术团队
D
Docker
V
Visual Studio Blog
Martin Fowler
Martin Fowler
博客园 - 聂微东
The Cloudflare Blog

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(matrix): guard startup verification timestamps · open...
steipete · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,7 +1,7 @@

11

import fs from "node:fs";

22

import os from "node:os";

33

import path from "node:path";

4-

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

4+

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

55

import { ensureMatrixStartupVerification } from "./startup-verification.js";

66
77

function createTempStateDir(): string {

@@ -80,6 +80,10 @@ function createHarness(params?: {

8080

}

8181
8282

describe("ensureMatrixStartupVerification", () => {

83+

afterEach(() => {

84+

vi.restoreAllMocks();

85+

});

86+
8387

it("skips automatic requests when the device is already verified", async () => {

8488

const tempHome = createTempStateDir();

8589

const harness = createHarness({ verified: true });

@@ -203,6 +207,27 @@ describe("ensureMatrixStartupVerification", () => {

203207

expect(fs.existsSync(createStateFilePath(tempHome))).toBe(true);

204208

});

205209
210+

it("falls back when startup verification nowMs is outside Date range", async () => {

211+

vi.spyOn(Date, "now").mockReturnValue(Date.parse("2026-05-30T12:00:00.000Z"));

212+

const tempHome = createTempStateDir();

213+

const stateFilePath = createStateFilePath(tempHome);

214+

const harness = createHarness();

215+
216+

const result = await ensureMatrixStartupVerification({

217+

client: harness.client as never,

218+

auth: createAuth(),

219+

accountConfig: {},

220+

stateFilePath,

221+

nowMs: 8_640_000_000_000_001,

222+

});

223+
224+

expect(result.kind).toBe("requested");

225+

const state = JSON.parse(fs.readFileSync(stateFilePath, "utf-8")) as {

226+

attemptedAt?: string;

227+

};

228+

expect(state.attemptedAt).toBe("2026-05-30T12:00:00.000Z");

229+

});

230+
206231

it("keeps startup verification failures non-fatal", async () => {

207232

const tempHome = createTempStateDir();

208233

const harness = createHarness({

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import fs from "node:fs/promises";

22

import path from "node:path";

33

import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";

4+

import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";

45

import type { MatrixConfig } from "../../types.js";

56

import { resolveMatrixStoragePaths } from "../client/storage.js";

67

import type { MatrixAuth } from "../client/types.js";

@@ -95,6 +96,14 @@ function resolveRetryAfterMs(params: {

9596

return remaining > 0 ? remaining : undefined;

9697

}

9798
99+

function resolveStartupVerificationTimestamp(nowMs: unknown): string {

100+

return (

101+

timestampMsToIsoString(nowMs) ??

102+

timestampMsToIsoString(Date.now()) ??

103+

"1970-01-01T00:00:00.000Z"

104+

);

105+

}

106+
98107

function shouldHonorCooldown(params: {

99108

state: MatrixStartupVerificationState | null;

100109

verification: MatrixOwnDeviceVerificationStatus;

@@ -189,6 +198,7 @@ export async function ensureMatrixStartupVerification(params: {

189198

);

190199

const cooldownMs = cooldownHours * 60 * 60 * 1000;

191200

const nowMs = params.nowMs ?? Date.now();

201+

const attemptedAt = resolveStartupVerificationTimestamp(nowMs);

192202

const state = await readStartupVerificationState(statePath);

193203

const stateCooldownMs = resolveStateCooldownMs(state, cooldownMs);

194204

if (shouldHonorCooldown({ state, verification, stateCooldownMs, nowMs })) {

@@ -208,7 +218,7 @@ export async function ensureMatrixStartupVerification(params: {

208218

await writeJsonFileAtomically(statePath, {

209219

userId: verification.userId,

210220

deviceId: verification.deviceId,

211-

attemptedAt: new Date(nowMs).toISOString(),

221+

attemptedAt,

212222

outcome: "requested",

213223

requestId: request.id,

214224

transactionId: request.transactionId,

@@ -224,7 +234,7 @@ export async function ensureMatrixStartupVerification(params: {

224234

await writeJsonFileAtomically(statePath, {

225235

userId: verification.userId,

226236

deviceId: verification.deviceId,

227-

attemptedAt: new Date(nowMs).toISOString(),

237+

attemptedAt,

228238

outcome: "failed",

229239

error,

230240

} satisfies MatrixStartupVerificationState).catch(() => {});