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

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
美团技术团队
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
A
About on SuperTechFans
Recent Announcements
Recent Announcements
D
Docker
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
腾讯CDC
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
fix(memory): key index sources by path and source · openc...
jalehman · 2026-06-19 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -140,8 +140,8 @@ describe("memory manager database publication", () => {

140140
141141

concurrentDb = new DatabaseSync(targetPath);

142142

concurrentDb

143-

.prepare("UPDATE memory_index_sources SET hash = ? WHERE path = ?")

144-

.run("newer", "memory.md");

143+

.prepare("UPDATE memory_index_sources SET hash = ? WHERE path = ? AND source = ?")

144+

.run("newer", "memory.md", "memory");

145145

concurrentDb.close();

146146

concurrentDb = undefined;

147147

@@ -154,7 +154,9 @@ describe("memory manager database publication", () => {

154154

}),

155155

).rejects.toThrow(/changed while full reindex was building/);

156156

expect(

157-

targetDb.prepare("SELECT hash FROM memory_index_sources WHERE path = ?").get("memory.md"),

157+

targetDb

158+

.prepare("SELECT hash FROM memory_index_sources WHERE path = ? AND source = ?")

159+

.get("memory.md", "memory"),

158160

).toEqual({ hash: "newer" });

159161

} finally {

160162

try {

Original file line numberDiff line numberDiff line change

@@ -719,8 +719,7 @@ export abstract class MemoryManagerEmbeddingOps extends MemoryManagerSyncOps {

719719

this.db

720720

.prepare(

721721

`INSERT INTO memory_index_sources (path, source, hash, mtime, size) VALUES (?, ?, ?, ?, ?)

722-

ON CONFLICT(path) DO UPDATE SET

723-

source=excluded.source,

722+

ON CONFLICT(path, source) DO UPDATE SET

724723

hash=excluded.hash,

725724

mtime=excluded.mtime,

726725

size=excluded.size`,

Original file line numberDiff line numberDiff line change

@@ -118,11 +118,12 @@ describe("memory manager self-heal missing identity with FTS-only chunks", () =>

118118

updated_at INTEGER NOT NULL

119119

);

120120

CREATE TABLE IF NOT EXISTS memory_index_sources (

121-

path TEXT PRIMARY KEY,

121+

path TEXT NOT NULL,

122122

source TEXT NOT NULL DEFAULT 'memory',

123123

hash TEXT NOT NULL,

124124

mtime INTEGER NOT NULL,

125-

size INTEGER NOT NULL

125+

size INTEGER NOT NULL,

126+

PRIMARY KEY (path, source)

126127

);

127128

INSERT INTO memory_index_chunks (id, path, source, start_line, end_line, hash, model, text, embedding, updated_at)

128129

VALUES ('chunk-1', 'MEMORY.md', 'memory', 1, 3, 'hash-1', '${model}', 'Alpha topic keep note', '[]', ${Date.now()});

Original file line numberDiff line numberDiff line change

@@ -84,6 +84,33 @@ describe("memory index schema", () => {

8484

}

8585

});

8686
87+

it("stores source records with the same path in separate sources", () => {

88+

const db = new DatabaseSync(":memory:");

89+

try {

90+

ensureMemoryIndexSchema({

91+

db,

92+

cacheEnabled: false,

93+

ftsEnabled: false,

94+

});

95+
96+

db.prepare(

97+

"INSERT INTO memory_index_sources (path, source, hash, mtime, size) VALUES (?, ?, ?, ?, ?)",

98+

).run("shared.md", "memory", "memory-hash", 10, 20);

99+

db.prepare(

100+

"INSERT INTO memory_index_sources (path, source, hash, mtime, size) VALUES (?, ?, ?, ?, ?)",

101+

).run("shared.md", "sessions", "session-hash", 30, 40);

102+
103+

expect(

104+

db.prepare("SELECT path, source, hash FROM memory_index_sources ORDER BY source").all(),

105+

).toEqual([

106+

{ path: "shared.md", source: "memory", hash: "memory-hash" },

107+

{ path: "shared.md", source: "sessions", hash: "session-hash" },

108+

]);

109+

} finally {

110+

db.close();

111+

}

112+

});

113+
87114

it("leaves unrelated generic tables untouched", () => {

88115

const db = new DatabaseSync(":memory:");

89116

try {

Original file line numberDiff line numberDiff line change

@@ -194,11 +194,12 @@ export function ensureMemoryIndexSchema(params: {

194194

value TEXT NOT NULL

195195

);

196196

CREATE TABLE IF NOT EXISTS ${MEMORY_INDEX_SOURCES_TABLE} (

197-

path TEXT PRIMARY KEY,

197+

path TEXT NOT NULL,

198198

source TEXT NOT NULL DEFAULT 'memory',

199199

hash TEXT NOT NULL,

200200

mtime INTEGER NOT NULL,

201-

size INTEGER NOT NULL

201+

size INTEGER NOT NULL,

202+

PRIMARY KEY (path, source)

202203

);

203204

CREATE TABLE IF NOT EXISTS ${MEMORY_INDEX_CHUNKS_TABLE} (

204205

id TEXT PRIMARY KEY,

@@ -250,6 +251,10 @@ export function ensureMemoryIndexSchema(params: {

250251

UPDATE ${MEMORY_INDEX_STATE_TABLE} SET revision = revision + 1 WHERE id = 1;

251252

END;

252253
254+

CREATE INDEX IF NOT EXISTS idx_memory_index_sources_source

255+

ON ${MEMORY_INDEX_SOURCES_TABLE}(source);

256+

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path_source

257+

ON ${MEMORY_INDEX_CHUNKS_TABLE}(path, source);

253258

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path

254259

ON ${MEMORY_INDEX_CHUNKS_TABLE}(path);

255260

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_source

Original file line numberDiff line numberDiff line change

@@ -62,7 +62,7 @@ export interface MemoryIndexMeta {

6262

export interface MemoryIndexSources {

6363

hash: string;

6464

mtime: number;

65-

path: string | null;

65+

path: string;

6666

size: number;

6767

source: Generated<string>;

6868

}

Original file line numberDiff line numberDiff line change

@@ -48,11 +48,12 @@ CREATE TABLE IF NOT EXISTS memory_index_meta (

4848

);

4949
5050

CREATE TABLE IF NOT EXISTS memory_index_sources (

51-

path TEXT PRIMARY KEY,

51+

path TEXT NOT NULL,

5252

source TEXT NOT NULL DEFAULT 'memory',

5353

hash TEXT NOT NULL,

5454

mtime INTEGER NOT NULL,

55-

size INTEGER NOT NULL

55+

size INTEGER NOT NULL,

56+

PRIMARY KEY (path, source)

5657

);

5758
5859

CREATE TABLE IF NOT EXISTS memory_index_chunks (

@@ -125,6 +126,12 @@ END;

125126

CREATE INDEX IF NOT EXISTS idx_memory_embedding_cache_updated_at

126127

ON memory_embedding_cache(updated_at);

127128
129+

CREATE INDEX IF NOT EXISTS idx_memory_index_sources_source

130+

ON memory_index_sources(source);

131+
132+

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path_source

133+

ON memory_index_chunks(path, source);

134+
128135

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path

129136

ON memory_index_chunks(path);

130137
Original file line numberDiff line numberDiff line change

@@ -43,11 +43,12 @@ CREATE TABLE IF NOT EXISTS memory_index_meta (

4343

);

4444
4545

CREATE TABLE IF NOT EXISTS memory_index_sources (

46-

path TEXT PRIMARY KEY,

46+

path TEXT NOT NULL,

4747

source TEXT NOT NULL DEFAULT 'memory',

4848

hash TEXT NOT NULL,

4949

mtime INTEGER NOT NULL,

50-

size INTEGER NOT NULL

50+

size INTEGER NOT NULL,

51+

PRIMARY KEY (path, source)

5152

);

5253
5354

CREATE TABLE IF NOT EXISTS memory_index_chunks (

@@ -120,6 +121,12 @@ END;

120121

CREATE INDEX IF NOT EXISTS idx_memory_embedding_cache_updated_at

121122

ON memory_embedding_cache(updated_at);

122123
124+

CREATE INDEX IF NOT EXISTS idx_memory_index_sources_source

125+

ON memory_index_sources(source);

126+
127+

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path_source

128+

ON memory_index_chunks(path, source);

129+
123130

CREATE INDEX IF NOT EXISTS idx_memory_index_chunks_path

124131

ON memory_index_chunks(path);

125132