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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
H
Help Net Security
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
V
V2EX
M
MIT News - Artificial intelligence
Vercel News
Vercel News
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
D
Docker
V
Visual Studio Blog
博客园 - 叶小钗
美团技术团队
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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(qa-matrix): read sqlite inbound dedupe state · opencl...
steipete · 2026-06-01 · via Recent Commits to openclaw:main
1+

import { createHash } from "node:crypto";

12

import { mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";

23

import os from "node:os";

34

import path from "node:path";

@@ -60,6 +61,69 @@ const MATRIX_SUBAGENT_MISSING_HOOK_ERROR =

6061

"thread=true is unavailable because no channel plugin registered subagent_spawning hooks.";

6162

const MATRIX_QA_HOT_RELOAD_RESTART_DELAY_MS = 300_000;

626364+

function matrixInboundDedupePluginStateKey(params: {

65+

accountId: string;

66+

eventId: string;

67+

roomId: string;

68+

}): string {

69+

const accountId = params.accountId.trim() || "sut";

70+

const digest = createHash("sha256")

71+

.update(accountId)

72+

.update("\0")

73+

.update(params.roomId.trim())

74+

.update("\0")

75+

.update(params.eventId.trim())

76+

.digest("hex");

77+

return `${accountId}:${digest}`;

78+

}

79+80+

async function writeMatrixInboundDedupePluginStateEntry(params: {

81+

accountId: string;

82+

eventId: string;

83+

roomId: string;

84+

stateRoot: string;

85+

}) {

86+

const sqlite = await import("node:sqlite");

87+

const databasePath = path.join(params.stateRoot, "state", "openclaw.sqlite");

88+

await mkdir(path.dirname(databasePath), { recursive: true });

89+

const db = new sqlite.DatabaseSync(databasePath);

90+

try {

91+

db.exec(`

92+

CREATE TABLE IF NOT EXISTS plugin_state_entries (

93+

plugin_id TEXT NOT NULL,

94+

namespace TEXT NOT NULL,

95+

entry_key TEXT NOT NULL,

96+

value_json TEXT NOT NULL,

97+

created_at INTEGER NOT NULL,

98+

expires_at INTEGER,

99+

PRIMARY KEY (plugin_id, namespace, entry_key)

100+

);

101+

`);

102+

db.prepare(`

103+

INSERT INTO plugin_state_entries (

104+

plugin_id, namespace, entry_key, value_json, created_at, expires_at

105+

) VALUES (?, ?, ?, ?, ?, ?)

106+

ON CONFLICT(plugin_id, namespace, entry_key) DO UPDATE SET

107+

value_json = excluded.value_json,

108+

created_at = excluded.created_at,

109+

expires_at = excluded.expires_at

110+

`).run(

111+

"matrix",

112+

"inbound-dedupe",

113+

matrixInboundDedupePluginStateKey(params),

114+

JSON.stringify({

115+

roomId: params.roomId,

116+

eventId: params.eventId,

117+

ts: Date.now(),

118+

}),

119+

Date.now(),

120+

null,

121+

);

122+

} finally {

123+

db.close();

124+

}

125+

}

126+63127

function requireMatrixQaScenario(id: string): (typeof MATRIX_QA_SCENARIOS)[number] {

64128

const scenario = MATRIX_QA_SCENARIOS.find((entry) => entry.id === id);

65129

if (!scenario) {

@@ -1958,7 +2022,6 @@ describe("matrix live qa scenarios", () => {

19582022

const accountDir = path.join(stateRoot, "matrix", "accounts", "sut", "server", "token");

19592023

const staleSyncRoomId = "!stale-sync:matrix-qa.test";

19602024

const syncStorePath = path.join(accountDir, "bot-storage.json");

1961-

const dedupeStorePath = path.join(accountDir, "inbound-dedupe.json");

19622025

await mkdir(accountDir, { recursive: true });

19632026

await writeTestJsonFile(path.join(accountDir, "storage-meta.json"), {

19642027

accountId: "sut",

@@ -1983,14 +2046,11 @@ describe("matrix live qa scenarios", () => {

19832046

const kind = token.includes("STALE_SYNC_DEDUPE_FRESH") ? "fresh" : "first";

19842047

callOrder.push(`wait:${kind}`);

19852048

if (kind === "first") {

1986-

await writeTestJsonFile(dedupeStorePath, {

1987-

version: 1,

1988-

entries: [

1989-

{

1990-

key: `${staleSyncRoomId}|$first-trigger`,

1991-

ts: Date.now(),

1992-

},

1993-

],

2049+

await writeMatrixInboundDedupePluginStateEntry({

2050+

accountId: "sut",

2051+

eventId: "$first-trigger",

2052+

roomId: staleSyncRoomId,

2053+

stateRoot,

19942054

});

19952055

}

19962056

return {