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

推荐订阅源

小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
博客园 - 【当耐特】
博客园_首页
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
V
Visual Studio Blog
F
Fortinet All Blogs
Martin Fowler
Martin Fowler

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
Doctor: expose session lock findings (#84366) · openclaw/...
giodl73-repo · 2026-06-24 · via Recent Commits to openclaw:main

@@ -13,7 +13,12 @@ vi.mock("../../packages/terminal-core/src/note.js", () => ({

1313

note,

1414

}));

151516-

import { noteSessionLockHealth } from "./doctor-session-locks.js";

16+

import {

17+

detectStaleSessionLocks,

18+

noteSessionLockHealth,

19+

sessionLockToHealthFinding,

20+

sessionLockToRepairEffect,

21+

} from "./doctor-session-locks.js";

17221823

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

1924

try {

@@ -105,6 +110,154 @@ describe("noteSessionLockHealth", () => {

105110

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

106111

});

107112113+

it("detects stale locks without removing them for structured lint", async () => {

114+

const sessionsDir = state.sessionsDir();

115+

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

116+117+

const staleLock = path.join(sessionsDir, "stale.jsonl.lock");

118+

const freshLock = path.join(sessionsDir, "fresh.jsonl.lock");

119+120+

await fs.writeFile(

121+

staleLock,

122+

JSON.stringify({ pid: -1, createdAt: new Date(Date.now() - 120_000).toISOString() }),

123+

"utf8",

124+

);

125+

await fs.writeFile(

126+

freshLock,

127+

JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() }),

128+

"utf8",

129+

);

130+131+

const locks = await detectStaleSessionLocks({

132+

staleMs: 30_000,

133+

readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],

134+

});

135+136+

expect(locks).toHaveLength(1);

137+

expect(locks[0]?.lockPath).toBe(staleLock);

138+

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

139+

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

140+

});

141+142+

it("maps stale locks to structured findings and dry-run effects", async () => {

143+

const sessionsDir = state.sessionsDir();

144+

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

145+

const lockPath = path.join(sessionsDir, "stale.jsonl.lock");

146+

await fs.writeFile(

147+

lockPath,

148+

JSON.stringify({ pid: -1, createdAt: new Date(Date.now() - 120_000).toISOString() }),

149+

"utf8",

150+

);

151+152+

const [lock] = await detectStaleSessionLocks({

153+

staleMs: 30_000,

154+

readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],

155+

});

156+

if (!lock) {

157+

throw new Error("expected stale session lock");

158+

}

159+160+

expect(sessionLockToHealthFinding(lock)).toEqual(

161+

expect.objectContaining({

162+

checkId: "core/doctor/session-locks",

163+

severity: "warning",

164+

path: lockPath,

165+

}),

166+

);

167+

expect(sessionLockToRepairEffect(lock)).toEqual({

168+

kind: "state",

169+

action: "would-remove-stale-session-lock",

170+

target: lockPath,

171+

dryRunSafe: false,

172+

});

173+

});

174+175+

it("preserves fresh malformed stale locks in dry-run repair effects", async () => {

176+

const sessionsDir = state.sessionsDir();

177+

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

178+179+

const malformedLock = path.join(sessionsDir, "malformed.jsonl.lock");

180+

await fs.writeFile(malformedLock, "{}", "utf8");

181+182+

const [lock] = await detectStaleSessionLocks({

183+

staleMs: 30_000,

184+

readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],

185+

});

186+

if (!lock) {

187+

throw new Error("expected stale session lock");

188+

}

189+190+

expect(lock.staleReasons).toEqual(["missing-pid", "invalid-createdAt"]);

191+

expect(lock.removable).toBe(false);

192+

expect(sessionLockToHealthFinding(lock).fixHint).toContain("after the cleanup grace period");

193+

expect(sessionLockToRepairEffect(lock)).toEqual({

194+

kind: "state",

195+

action: "would-preserve-mtime-gated-stale-session-lock",

196+

target: malformedLock,

197+

dryRunSafe: false,

198+

});

199+

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

200+

});

201+202+

it("uses the supplied env to choose the structured lint state dir", async () => {

203+

const other = await createOpenClawTestState({

204+

layout: "state-only",

205+

prefix: "openclaw-doctor-locks-other-",

206+

applyEnv: false,

207+

});

208+

try {

209+

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

210+

const lockPath = path.join(other.sessionsDir(), "other-stale.jsonl.lock");

211+

await fs.writeFile(

212+

lockPath,

213+

JSON.stringify({ pid: -1, createdAt: new Date(Date.now() - 120_000).toISOString() }),

214+

"utf8",

215+

);

216+217+

const locks = await detectStaleSessionLocks({

218+

env: other.env,

219+

staleMs: 30_000,

220+

readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],

221+

});

222+223+

expect(locks.map((lock) => lock.lockPath)).toEqual([lockPath]);

224+

} finally {

225+

await other.cleanup();

226+

}

227+

});

228+229+

it("preserves report-only live OpenClaw locks in dry-run repair effects", async () => {

230+

const sessionsDir = state.sessionsDir();

231+

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

232+233+

const reportOnlyLock = path.join(sessionsDir, "report-only.jsonl.lock");

234+

await fs.writeFile(

235+

reportOnlyLock,

236+

JSON.stringify({ pid: process.pid, createdAt: new Date(Date.now() - 45_000).toISOString() }),

237+

"utf8",

238+

);

239+240+

const [lock] = await detectStaleSessionLocks({

241+

staleMs: 30_000,

242+

readOwnerProcessArgs: () => ["node", "/opt/openclaw/openclaw.mjs", "doctor"],

243+

});

244+

if (!lock) {

245+

throw new Error("expected stale session lock");

246+

}

247+248+

expect(lock.staleReasons).toEqual(["too-old"]);

249+

expect(sessionLockToHealthFinding(lock).fixHint).toBe(

250+

"OpenClaw is preserving this live owned lock; inspect the owning process if it appears stuck.",

251+

);

252+

expect(sessionLockToRepairEffect(lock)).toEqual({

253+

kind: "state",

254+

action: "would-preserve-report-only-stale-session-lock",

255+

target: reportOnlyLock,

256+

dryRunSafe: false,

257+

});

258+

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

259+

});

260+108261

it("uses configured stale threshold without removing live OpenClaw lock files", async () => {

109262

const sessionsDir = state.sessionsDir();

110263

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