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

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
GbyAI
GbyAI
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
C
Check Point Blog
H
Help Net Security
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
Y
Y Combinator Blog
U
Unit 42
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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(plugin-state): evict current namespace on plugin row ...
keshavbotage · 2026-05-28 · via Recent Commits to openclaw:main

@@ -19,7 +19,11 @@ import { canonicalizeMainSessionAlias } from "../config/sessions/main-session.js

1919

import type { SessionScope } from "../config/sessions/types.js";

2020

import type { OpenClawConfig } from "../config/types.openclaw.js";

2121

import { createSubsystemLogger } from "../logging/subsystem.js";

22-

import { createPluginStateKeyedStore } from "../plugin-state/plugin-state-store.js";

22+

import {

23+

countPluginStateLiveEntries,

24+

createPluginStateKeyedStore,

25+

MAX_PLUGIN_STATE_ENTRIES_PER_PLUGIN,

26+

} from "../plugin-state/plugin-state-store.js";

2327

import {

2428

buildAgentMainSessionKey,

2529

DEFAULT_AGENT_ID,

@@ -127,6 +131,15 @@ function resolvePluginStateImportTargetKey(scopeKey: string, key: string): strin

127131

return scopeKey ? `${scopeKey}:${key}` : key;

128132

}

129133134+

function findMissingKey(expected: Set<string>, actual: Set<string>): string | undefined {

135+

for (const key of expected) {

136+

if (!actual.has(key)) {

137+

return key;

138+

}

139+

}

140+

return undefined;

141+

}

142+130143

async function withPluginStateImportEnv<T>(

131144

plan: Extract<ChannelLegacyStateMigrationPlan, { kind: "plugin-state-import" }>,

132145

run: () => Promise<T>,

@@ -155,23 +168,41 @@ async function runLegacyMigrationPlans(

155168

for (const plan of plans) {

156169

if (plan.kind === "plugin-state-import") {

157170

await withPluginStateImportEnv(plan, async () => {

158-

let storeEntries: Array<{ key: string }> = [];

171+

let storeEntries: Array<{ key: string; value: unknown }> = [];

172+

let pluginEntryCount = 0;

159173

const store = createPluginStateKeyedStore<unknown>(plan.pluginId, {

160174

namespace: plan.namespace,

161175

maxEntries: plan.maxEntries,

162176

});

163177

try {

164178

storeEntries = await store.entries();

179+

pluginEntryCount = countPluginStateLiveEntries(plan.pluginId);

165180

} catch (err) {

166181

warnings.push(

167182

`Failed reading ${plan.label} plugin state before migration: ${String(err)}`,

168183

);

169184

return;

170185

}

171186

const existingKeys = new Set(storeEntries.map(({ key }) => key));

187+

const existingValuesByKey = new Map(storeEntries.map(({ key, value }) => [key, value]));

188+

const expectedKeys = new Set(existingKeys);

172189

let remainingCapacity = Math.max(0, plan.maxEntries - storeEntries.length);

173190

const entries = await plan.readEntries();

191+

const missingEntries = entries.filter(

192+

({ key }) => !existingKeys.has(resolvePluginStateImportTargetKey(plan.scopeKey, key)),

193+

);

194+

const pluginRemainingCapacity = Math.max(

195+

0,

196+

MAX_PLUGIN_STATE_ENTRIES_PER_PLUGIN - pluginEntryCount,

197+

);

198+

if (missingEntries.length > pluginRemainingCapacity) {

199+

warnings.push(

200+

`Skipped migrating ${plan.label} because plugin state has room for ${pluginRemainingCapacity} of ${missingEntries.length} missing entries; left legacy source in place`,

201+

);

202+

return;

203+

}

174204

let imported = 0;

205+

const importedKeys: string[] = [];

175206

for (const entry of entries) {

176207

const targetKey = resolvePluginStateImportTargetKey(plan.scopeKey, entry.key);

177208

if (existingKeys.has(targetKey)) {

@@ -182,7 +213,26 @@ async function runLegacyMigrationPlans(

182213

}

183214

try {

184215

await store.register(targetKey, entry.value);

216+

const nextExpectedKeys = new Set(expectedKeys);

217+

nextExpectedKeys.add(targetKey);

218+

const liveKeys = new Set((await store.entries()).map(({ key }) => key));

219+

const missingKey = findMissingKey(nextExpectedKeys, liveKeys);

220+

if (missingKey) {

221+

for (const importedKey of importedKeys.toReversed()) {

222+

await store.delete(importedKey);

223+

}

224+

await store.delete(targetKey);

225+

if (existingValuesByKey.has(missingKey)) {

226+

await store.register(missingKey, existingValuesByKey.get(missingKey));

227+

}

228+

warnings.push(

229+

`Stopped migrating ${plan.label} because plugin state cap evicted ${missingKey}; left legacy source in place`,

230+

);

231+

return;

232+

}

233+

expectedKeys.add(targetKey);

185234

existingKeys.add(targetKey);

235+

importedKeys.push(targetKey);

186236

remainingCapacity--;

187237

imported++;

188238

} catch (err) {

@@ -194,10 +244,14 @@ async function runLegacyMigrationPlans(

194244

`Migrated ${imported} ${plan.label} ${imported === 1 ? "entry" : "entries"} → plugin state`,

195245

);

196246

}

247+

let cleanupKeys = existingKeys;

248+

if (plan.cleanupSource === "rename") {

249+

cleanupKeys = expectedKeys;

250+

}

197251

const allEntriesCovered =

198252

entries.length > 0 &&

199253

entries.every(({ key }) =>

200-

existingKeys.has(resolvePluginStateImportTargetKey(plan.scopeKey, key)),

254+

cleanupKeys.has(resolvePluginStateImportTargetKey(plan.scopeKey, key)),

201255

);

202256

if (allEntriesCovered && plan.cleanupSource === "rename" && fileExists(plan.sourcePath)) {

203257

const archivedPath = `${plan.sourcePath}.migrated`;