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

推荐订阅源

WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
博客园_首页
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
小众软件
小众软件
博客园 - 司徒正美
雷峰网
雷峰网
T
Tailwind CSS Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
罗磊的独立博客
量子位
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - 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(plugins): shorten runtime mirror lock hold · openclaw...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

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

11

import fs from "node:fs";

22

import os from "node:os";

33

import path from "node:path";

4-

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

4+

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

55

import { resolveBundledRuntimeDependencyInstallRoot } from "./bundled-runtime-deps.js";

66

import { prepareBundledPluginRuntimeRoot } from "./bundled-runtime-root.js";

77

@@ -14,6 +14,7 @@ function makeTempRoot(): string {

1414

}

15151616

afterEach(() => {

17+

vi.restoreAllMocks();

1718

for (const root of tempRoots.splice(0)) {

1819

fs.rmSync(root, { recursive: true, force: true });

1920

}

@@ -23,6 +24,17 @@ async function waitForFilesystemTimestampTick(): Promise<void> {

2324

await new Promise((resolve) => setTimeout(resolve, 50));

2425

}

252627+

function isPathInsideRoot(candidate: string, root: string): boolean {

28+

const relative = path.relative(root, candidate);

29+

return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));

30+

}

31+32+

function isBigIntStatOptions(options: unknown): boolean {

33+

return Boolean(

34+

options && typeof options === "object" && "bigint" in options && options.bigint === true,

35+

);

36+

}

37+2638

describe("prepareBundledPluginRuntimeRoot", () => {

2739

it("materializes root JavaScript chunks in external mirrors", () => {

2840

const packageRoot = makeTempRoot();

@@ -265,6 +277,84 @@ describe("prepareBundledPluginRuntimeRoot", () => {

265277

).toContain("onboard-abc123");

266278

});

267279280+

it("fingerprints runtime mirror source roots before taking the mirror lock", () => {

281+

const packageRoot = makeTempRoot();

282+

const stageDir = makeTempRoot();

283+

const canonicalPluginRoot = path.join(packageRoot, "dist", "extensions", "qqbot");

284+

const runtimePluginRoot = path.join(packageRoot, "dist-runtime", "extensions", "qqbot");

285+

const env = { ...process.env, OPENCLAW_PLUGIN_STAGE_DIR: stageDir };

286+

fs.mkdirSync(canonicalPluginRoot, { recursive: true });

287+

fs.mkdirSync(runtimePluginRoot, { recursive: true });

288+

fs.writeFileSync(

289+

path.join(packageRoot, "package.json"),

290+

JSON.stringify({ name: "openclaw", version: "2026.4.27", type: "module" }),

291+

"utf8",

292+

);

293+

fs.writeFileSync(

294+

path.join(canonicalPluginRoot, "index.js"),

295+

"export default { id: 'qqbot' };\n",

296+

"utf8",

297+

);

298+

fs.writeFileSync(

299+

path.join(canonicalPluginRoot, "package.json"),

300+

JSON.stringify({ name: "@openclaw/qqbot", version: "1.0.0", type: "module" }, null, 2),

301+

"utf8",

302+

);

303+

fs.writeFileSync(

304+

path.join(runtimePluginRoot, "index.js"),

305+

`export { default } from ${JSON.stringify("../../../dist/extensions/qqbot/index.js")};\n`,

306+

"utf8",

307+

);

308+

fs.writeFileSync(

309+

path.join(runtimePluginRoot, "package.json"),

310+

JSON.stringify(

311+

{

312+

name: "@openclaw/qqbot",

313+

version: "1.0.0",

314+

type: "module",

315+

dependencies: { "qqbot-runtime": "1.0.0" },

316+

openclaw: { extensions: ["./index.js"] },

317+

},

318+

null,

319+

2,

320+

),

321+

"utf8",

322+

);

323+

const installRoot = resolveBundledRuntimeDependencyInstallRoot(runtimePluginRoot, { env });

324+

fs.mkdirSync(path.join(installRoot, "node_modules", "qqbot-runtime"), { recursive: true });

325+

fs.writeFileSync(

326+

path.join(installRoot, "node_modules", "qqbot-runtime", "package.json"),

327+

JSON.stringify({ name: "qqbot-runtime", version: "1.0.0", type: "module" }),

328+

"utf8",

329+

);

330+331+

const lockPath = path.join(installRoot, ".openclaw-runtime-mirror.lock");

332+

const fingerprintLockStates: Array<{ source: "runtime" | "canonical"; locked: boolean }> = [];

333+

const realLstatSync = fs.lstatSync.bind(fs) as typeof fs.lstatSync;

334+

vi.spyOn(fs, "lstatSync").mockImplementation(((target, options) => {

335+

const targetPath = target.toString();

336+

if (isBigIntStatOptions(options)) {

337+

if (isPathInsideRoot(targetPath, runtimePluginRoot)) {

338+

fingerprintLockStates.push({ source: "runtime", locked: fs.existsSync(lockPath) });

339+

} else if (isPathInsideRoot(targetPath, canonicalPluginRoot)) {

340+

fingerprintLockStates.push({ source: "canonical", locked: fs.existsSync(lockPath) });

341+

}

342+

}

343+

return realLstatSync(target, options as never);

344+

}) as typeof fs.lstatSync);

345+346+

prepareBundledPluginRuntimeRoot({

347+

pluginId: "qqbot",

348+

pluginRoot: runtimePluginRoot,

349+

modulePath: path.join(runtimePluginRoot, "index.js"),

350+

env,

351+

});

352+353+

expect(fingerprintLockStates.some((entry) => entry.source === "runtime")).toBe(true);

354+

expect(fingerprintLockStates.some((entry) => entry.source === "canonical")).toBe(true);

355+

expect(fingerprintLockStates.filter((entry) => entry.locked)).toEqual([]);

356+

});

357+268358

it("reuses unchanged external runtime mirrors from the original plugin root", async () => {

269359

const packageRoot = makeTempRoot();

270360

const stageDir = makeTempRoot();