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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
博客园_首页
Scott Helme
Scott Helme
V
Vulnerabilities – Threatpost
C
Cisco Blogs
B
Blog
Y
Y Combinator Blog
Simon Willison's Weblog
Simon Willison's Weblog
F
Fortinet All Blogs
D
DataBreaches.Net
IT之家
IT之家
C
Check Point Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tenable Blog
P
Privacy International News Feed
O
OpenAI News
H
Hacker News: Front Page
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
小众软件
小众软件
Security Latest
Security Latest
Google DeepMind News
Google DeepMind News
S
Security @ Cisco Blogs
有赞技术团队
有赞技术团队
The Hacker News
The Hacker News
T
Tor Project blog
D
Docker
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
T
Threatpost
人人都是产品经理
人人都是产品经理
The Last Watchdog
The Last Watchdog
G
GRAHAM CLULEY
H
Heimdal Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
量子位
Webroot Blog
Webroot Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Palo Alto Networks Blog
W
WeLiveSecurity

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… fix: restrict HTML timeout short-circuit to transient statuses 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 Extensions/lmstudio: back off inference preload after consecutive fai… TUI/streaming: add watchdog that resets the activity indicator after … Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write fix: classify HTML provider error pages correctly (#67642) (thanks @s… 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… 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… fix: align host tilde paths with OS home (#62804) (thanks @stainlu) 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
fix(memory): clean stale reindex temp files (#92891) · openclaw/openclaw@a42bda5
ZengWen-DT · 2026-06-15 · via Recent Commits to openclaw:main
1+

import fsSync from "node:fs";

12

import fs from "node:fs/promises";

23

import os from "node:os";

34

import path from "node:path";

45

import { DatabaseSync } from "node:sqlite";

5-

import { afterAll, beforeAll, describe, expect, it } from "vitest";

6-

import { openMemoryDatabaseAtPath } from "./manager-db.js";

6+

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

7+

import {

8+

cleanupAgedMemoryReindexTempFiles,

9+

openMemoryDatabaseAtPath,

10+

openMemoryReindexTempDatabaseAtPath,

11+

} from "./manager-db.js";

12+

import {

13+

acquireMemoryReindexLock,

14+

resolveMemoryReindexLockPath,

15+

tryAcquireMemoryReindexLock,

16+

} from "./manager-reindex-lock.js";

17+18+

async function expectPathMissing(targetPath: string): Promise<void> {

19+

await expect(fs.access(targetPath)).rejects.toThrow("ENOENT");

20+

}

721822

describe("openMemoryDatabaseAtPath readOnly probe", () => {

923

let fixtureRoot = "";

@@ -17,6 +31,10 @@ describe("openMemoryDatabaseAtPath readOnly probe", () => {

1731

await fs.rm(fixtureRoot, { recursive: true, force: true });

1832

});

193334+

afterEach(() => {

35+

vi.restoreAllMocks();

36+

});

37+2038

it("allows opening when the database file exists", async () => {

2139

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

2240

const dir = path.dirname(dbPath);

@@ -41,6 +59,21 @@ describe("openMemoryDatabaseAtPath readOnly probe", () => {

4159

expect(stat.size).toBeGreaterThan(0);

4260

});

436162+

it("refuses to create a missing live database while a safe reindex holds the lock", async () => {

63+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

64+

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

65+

const reindexLock = acquireMemoryReindexLock(dbPath);

66+67+

expect(() => openMemoryDatabaseAtPath(dbPath, false, true)).toThrow(

68+

/another reindex is active/,

69+

);

70+

await expectPathMissing(dbPath);

71+72+

reindexLock.release();

73+

const db = openMemoryDatabaseAtPath(dbPath, false, true);

74+

db.close();

75+

});

76+4477

it("refuses to auto-create an empty database when allowCreate is false", async () => {

4578

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "absent-index.sqlite");

4679

@@ -54,12 +87,132 @@ describe("openMemoryDatabaseAtPath readOnly probe", () => {

5487

it("allows open with allowCreate=true for temp database creation", async () => {

5588

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "temp-index.sqlite");

568957-

const db = openMemoryDatabaseAtPath(dbPath, false, true);

90+

const db = openMemoryReindexTempDatabaseAtPath(dbPath, false);

5891

db.exec("CREATE TABLE IF NOT EXISTS meta(key TEXT PRIMARY KEY, value TEXT)");

5992

db.close();

93+

await expectPathMissing(resolveMemoryReindexLockPath(dbPath));

60946195

const reopen = openMemoryDatabaseAtPath(dbPath, false, false);

6296

expect(reopen).toBeDefined();

6397

reopen.close();

6498

});

65-

});

99+100+

it("removes aged orphan reindex temp files before opening the live database", async () => {

101+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

102+

const dir = path.dirname(dbPath);

103+

await fs.mkdir(dir, { recursive: true });

104+

const seed = new DatabaseSync(dbPath);

105+

seed.exec("CREATE TABLE IF NOT EXISTS meta(key TEXT PRIMARY KEY, value TEXT)");

106+

seed.close();

107+108+

const orphanBase = `${dbPath}.tmp-11111111-2222-3333-4444-555555555555`;

109+

for (const suffix of ["", "-wal", "-shm"]) {

110+

const filePath = `${orphanBase}${suffix}`;

111+

await fs.writeFile(filePath, "orphan");

112+

const old = new Date(Date.now() - 48 * 60 * 60_000);

113+

await fs.utimes(filePath, old, old);

114+

}

115+116+

const db = openMemoryDatabaseAtPath(dbPath, false);

117+

db.close();

118+119+

await expectPathMissing(orphanBase);

120+

await expectPathMissing(`${orphanBase}-wal`);

121+

await expectPathMissing(`${orphanBase}-shm`);

122+

});

123+124+

it("keeps young reindex temp files during live database startup", async () => {

125+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

126+

const dir = path.dirname(dbPath);

127+

await fs.mkdir(dir, { recursive: true });

128+

const seed = new DatabaseSync(dbPath);

129+

seed.exec("CREATE TABLE IF NOT EXISTS meta(key TEXT PRIMARY KEY, value TEXT)");

130+

seed.close();

131+132+

const activeBase = `${dbPath}.tmp-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee`;

133+

for (const suffix of ["", "-wal", "-shm"]) {

134+

await fs.writeFile(`${activeBase}${suffix}`, "active");

135+

}

136+137+

const db = openMemoryDatabaseAtPath(dbPath, false);

138+

db.close();

139+140+

await expect(fs.access(activeBase)).resolves.toBeUndefined();

141+

await expect(fs.access(`${activeBase}-wal`)).resolves.toBeUndefined();

142+

await expect(fs.access(`${activeBase}-shm`)).resolves.toBeUndefined();

143+

});

144+145+

it("keeps aged reindex temp files while another process holds the reindex lock", async () => {

146+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

147+

const dir = path.dirname(dbPath);

148+

await fs.mkdir(dir, { recursive: true });

149+

const seed = new DatabaseSync(dbPath);

150+

seed.exec("CREATE TABLE IF NOT EXISTS meta(key TEXT PRIMARY KEY, value TEXT)");

151+

seed.close();

152+153+

const activeBase = `${dbPath}.tmp-99999999-aaaa-bbbb-cccc-dddddddddddd`;

154+

for (const suffix of ["", "-wal", "-shm"]) {

155+

const filePath = `${activeBase}${suffix}`;

156+

await fs.writeFile(filePath, "active");

157+

const old = new Date(Date.now() - 48 * 60 * 60_000);

158+

await fs.utimes(filePath, old, old);

159+

}

160+

const reindexLock = acquireMemoryReindexLock(dbPath);

161+162+

cleanupAgedMemoryReindexTempFiles(dbPath);

163+

const db = openMemoryDatabaseAtPath(dbPath, false);

164+

db.close();

165+166+

await expect(fs.access(activeBase)).resolves.toBeUndefined();

167+

await expect(fs.access(`${activeBase}-wal`)).resolves.toBeUndefined();

168+

await expect(fs.access(`${activeBase}-shm`)).resolves.toBeUndefined();

169+

reindexLock.release();

170+

cleanupAgedMemoryReindexTempFiles(dbPath);

171+

await expectPathMissing(activeBase);

172+

await expectPathMissing(`${activeBase}-wal`);

173+

await expectPathMissing(`${activeBase}-shm`);

174+

});

175+176+

it("keeps aged reindex temp files while the live database is absent", async () => {

177+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

178+

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

179+

const orphanBase = `${dbPath}.tmp-abcdef12-aaaa-bbbb-cccc-123456789abc`;

180+

await fs.writeFile(orphanBase, "recovery candidate");

181+

const old = new Date(Date.now() - 48 * 60 * 60_000);

182+

await fs.utimes(orphanBase, old, old);

183+184+

const db = openMemoryDatabaseAtPath(dbPath, false, true);

185+

db.close();

186+187+

await expect(fs.access(orphanBase)).resolves.toBeUndefined();

188+

});

189+190+

it("serializes safe reindexes and releases the lock for the next owner", async () => {

191+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

192+

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

193+194+

const first = acquireMemoryReindexLock(dbPath);

195+

expect(tryAcquireMemoryReindexLock(dbPath)).toBeUndefined();

196+

expect(() => acquireMemoryReindexLock(dbPath)).toThrow(/another reindex is active/);

197+198+

first.release();

199+

const second = tryAcquireMemoryReindexLock(dbPath);

200+

expect(second).toBeDefined();

201+

second?.release();

202+203+

await expect(fs.access(resolveMemoryReindexLockPath(dbPath))).resolves.toBeUndefined();

204+

});

205+206+

it("does not block database startup when orphan discovery fails", async () => {

207+

const dbPath = path.join(fixtureRoot, `case-${caseId++}`, "index.sqlite");

208+

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

209+

const seed = new DatabaseSync(dbPath);

210+

seed.close();

211+

vi.spyOn(fsSync, "readdirSync").mockImplementationOnce(() => {

212+

throw Object.assign(new Error("scan failed"), { code: "EACCES" });

213+

});

214+215+

const db = openMemoryDatabaseAtPath(dbPath, false);

216+

db.close();

217+

});

218+

});