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

推荐订阅源

J
Java Code Geeks
Jina AI
Jina AI
小众软件
小众软件
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
美团技术团队
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 聂微东
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
博客园 - 司徒正美
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
月光博客
月光博客
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
博客园 - Franky

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(scripts): bound plugin install index artifacts · open...
vincentkoc · 2026-06-16 · via Recent Commits to openclaw:main
1+

// Plugin Index SQLite tests cover shared E2E install-index readers.

2+

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";

3+

import { tmpdir } from "node:os";

4+

import path from "node:path";

5+

import { DatabaseSync } from "node:sqlite";

6+

import { pathToFileURL } from "node:url";

7+

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

8+9+

const MODULE_URL = pathToFileURL(path.resolve("scripts/e2e/lib/plugin-index-sqlite.mjs")).href;

10+

let importCounter = 0;

11+12+

async function loadPluginIndex(env: Record<string, string> = {}) {

13+

const previous = new Map(Object.keys(env).map((key) => [key, process.env[key]]));

14+

Object.assign(process.env, env);

15+

try {

16+

return await import(`${MODULE_URL}?case=${importCounter++}`);

17+

} finally {

18+

for (const [key, value] of previous) {

19+

if (value === undefined) {

20+

delete process.env[key];

21+

} else {

22+

process.env[key] = value;

23+

}

24+

}

25+

}

26+

}

27+28+

function writeLegacyIndex(root: string, text: string) {

29+

const file = path.join(root, "plugins", "installs.json");

30+

mkdirSync(path.dirname(file), { recursive: true });

31+

writeFileSync(file, text, "utf8");

32+

}

33+34+

function configPath(root: string) {

35+

return path.join(root, "openclaw.json");

36+

}

37+38+

function writeSqliteIndex(root: string, installRecordsJson: string) {

39+

const dbPath = path.join(root, "state", "openclaw.sqlite");

40+

mkdirSync(path.dirname(dbPath), { recursive: true });

41+

const db = new DatabaseSync(dbPath);

42+

try {

43+

db.exec(`

44+

CREATE TABLE installed_plugin_index (

45+

index_key TEXT NOT NULL PRIMARY KEY,

46+

version INTEGER NOT NULL,

47+

host_contract_version TEXT NOT NULL,

48+

compat_registry_version TEXT NOT NULL,

49+

migration_version INTEGER NOT NULL,

50+

policy_hash TEXT NOT NULL,

51+

generated_at_ms INTEGER NOT NULL,

52+

refresh_reason TEXT,

53+

install_records_json TEXT NOT NULL,

54+

plugins_json TEXT NOT NULL,

55+

diagnostics_json TEXT NOT NULL,

56+

warning TEXT,

57+

updated_at_ms INTEGER NOT NULL

58+

);

59+

`);

60+

db.prepare(

61+

`

62+

INSERT INTO installed_plugin_index (

63+

index_key, version, host_contract_version, compat_registry_version,

64+

migration_version, policy_hash, generated_at_ms, refresh_reason,

65+

install_records_json, plugins_json, diagnostics_json, warning, updated_at_ms

66+

)

67+

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

68+

`,

69+

).run(

70+

"installed-plugin-index",

71+

1,

72+

"1",

73+

"1",

74+

1,

75+

"hash",

76+

Date.now(),

77+

null,

78+

installRecordsJson,

79+

"{}",

80+

"{}",

81+

null,

82+

Date.now(),

83+

);

84+

} finally {

85+

db.close();

86+

}

87+

}

88+89+

describe("plugin index SQLite E2E helpers", () => {

90+

it("reads legacy install records when SQLite index state is absent", async () => {

91+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-plugin-index-"));

92+

try {

93+

writeLegacyIndex(

94+

root,

95+

JSON.stringify({ records: { demo: { installPath: "/tmp/demo", source: "npm" } } }),

96+

);

97+98+

const { readPluginInstallRecords } = await loadPluginIndex();

99+100+

expect(readPluginInstallRecords({ stateDir: root, configPath: configPath(root) })).toEqual({

101+

demo: { installPath: "/tmp/demo", source: "npm" },

102+

});

103+

} finally {

104+

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

105+

}

106+

});

107+108+

it("keeps malformed legacy install JSON as an empty fallback", async () => {

109+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-plugin-index-"));

110+

try {

111+

writeLegacyIndex(root, "{not-json");

112+113+

const { readPluginInstallRecords } = await loadPluginIndex();

114+115+

expect(readPluginInstallRecords({ stateDir: root, configPath: configPath(root) })).toEqual(

116+

{},

117+

);

118+

} finally {

119+

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

120+

}

121+

});

122+123+

it("rejects oversized legacy install JSON before parsing it", async () => {

124+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-plugin-index-"));

125+

try {

126+

writeLegacyIndex(root, JSON.stringify({ records: {}, filler: "x".repeat(128) }));

127+128+

const { readPluginInstallRecords } = await loadPluginIndex({

129+

OPENCLAW_PLUGIN_INDEX_JSON_MAX_BYTES: "64",

130+

});

131+132+

expect(() =>

133+

readPluginInstallRecords({ stateDir: root, configPath: configPath(root) }),

134+

).toThrow("plugin index JSON artifact exceeded 64 bytes");

135+

} finally {

136+

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

137+

}

138+

});

139+140+

it("rejects oversized SQLite install index JSON before parsing it", async () => {

141+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-plugin-index-"));

142+

try {

143+

writeSqliteIndex(root, JSON.stringify({ filler: "x".repeat(128) }));

144+145+

const { readPluginInstallIndex } = await loadPluginIndex({

146+

OPENCLAW_PLUGIN_INDEX_JSON_MAX_BYTES: "64",

147+

});

148+149+

expect(() =>

150+

readPluginInstallIndex({ stateDir: root, configPath: configPath(root) }),

151+

).toThrow("plugin index install_records_json exceeded 64 bytes");

152+

} finally {

153+

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

154+

}

155+

});

156+

});