@modusensus/dsh-mneme 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ // 版本自检(issue #174 后续,2026-09-15 拍板):独立插件不把「用户在用哪个
2
+ // 版本」托付给插件市场——市场收录有 ~26h 年龄闸门 + 30min 缓存,且安装时
3
+ // 精确指定过版本的 profile 会被 pnpm 钉子挡住(update 尊重既有 semver 范围,
4
+ // 永不跨 minor/major,#174 的报障者正是这样用着 0.7.32 的行为模型来报 bug)。
5
+ //
6
+ // 本模块只做三件事:
7
+ // 1. 向 npm registry 查 @modusensus/dsh-mneme 的 latest dist-tag(带 TTL
8
+ // 缓存 + 超时 + 全失败静默——离线/被墙/registry 异常都返回 null,调用方
9
+ // 据 null 渲染「未知」,前端不打扰);
10
+ // 2. 与运行版本做纯函数比对(classify);
11
+ // 3. 对外暴露 registry URL 白名单校验(validateRegistryUrl)——发请求前
12
+ // 强制 https + 精确 host,构造上排除本机与内网地址。
13
+ import { readFileSync } from "node:fs";
14
+
15
+ // 运行版本:src/ 与 lib/ 都在插件根下一层,相对 import.meta.url 解析一致;
16
+ // 读取失败(打包/受限环境)降级 "unknown",横幅随之静默。
17
+ const PACKAGE_VERSION = (() => {
18
+ try {
19
+ return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version ?? "unknown";
20
+ } catch {
21
+ return "unknown";
22
+ }
23
+ })();
24
+
25
+ // registry 查询地址是模块常量而非用户输入;validateRegistryUrl 仍作为发请求
26
+ // 前的强制闸(构造上即排除非 https 与非白名单 host,双保险且可单测)。
27
+ const REGISTRY_URL = "https://registry.npmjs.org/@modusensus%2Fdsh-mneme/latest";
28
+ const REGISTRY_HOST = "registry.npmjs.org";
29
+ // 市场收录本身有 ~1 天年龄闸门,1h 的 registry 缓存远低于该粒度,足够新鲜。
30
+ const CACHE_TTL_MS = 60 * 60 * 1000;
31
+ const FETCH_TIMEOUT_MS = 5000;
32
+
33
+ // 精确 host 白名单:协议必须 https,且 host 逐字等于 registry.npmjs.org。
34
+ // 这一条即构造性排除本机回环、私有网段与保留地址——不做任何
35
+ // 「看起来像公网」的宽松判断,将来换源必须显式改这里的常量。
36
+ export function validateRegistryUrl(candidate) {
37
+ let url;
38
+ try {
39
+ url = new URL(candidate);
40
+ } catch {
41
+ return false;
42
+ }
43
+ return url.protocol === "https:" && url.hostname === REGISTRY_HOST;
44
+ }
45
+
46
+ /** 解析 `x.y.z` / `x.y.z-后缀` 为可比较结构;解析失败返回 null。 */
47
+ function parseVersion(text) {
48
+ if (typeof text !== "string") return null;
49
+ const match = text.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);
50
+ if (!match) return null;
51
+ return {
52
+ major: Number(match[1]),
53
+ minor: Number(match[2]),
54
+ patch: Number(match[3]),
55
+ // 有 prerelease 后缀的同号版本视为更旧(0.9.0-rc.1 < 0.9.0)。
56
+ prerelease: match[4] !== undefined
57
+ };
58
+ }
59
+
60
+ /**
61
+ * 三元组语义化比较:a<b → -1,a>b → 1,无法比较 → null(调用方归入 unknown)。
62
+ * 仅比较数字部分;数字相等时,带 prerelease 的一方更旧(0.9.0-rc.1 < 0.9.0),
63
+ * 两侧都带则视为同版——横幅只关心「是否落后于 latest」,不追求完整 semver 序。
64
+ */
65
+ export function compareVersions(a, b) {
66
+ const va = parseVersion(a);
67
+ const vb = parseVersion(b);
68
+ if (!va || !vb) return null;
69
+ for (const key of ["major", "minor", "patch"]) {
70
+ if (va[key] !== vb[key]) return va[key] < vb[key] ? -1 : 1;
71
+ }
72
+ if (va.prerelease !== vb.prerelease) return va.prerelease ? -1 : 1;
73
+ return 0;
74
+ }
75
+
76
+ /**
77
+ * 运行版本 vs registry latest 的展示归类。latest 为 null(查询失败/离线)
78
+ * 或任一侧解析失败时归 unknown——前端对 unknown 完全静默。
79
+ */
80
+ export function classify(version, latest) {
81
+ const cmp = compareVersions(version, latest);
82
+ if (cmp === null) return "unknown";
83
+ if (cmp < 0) return "outdated";
84
+ if (cmp > 0) return "ahead";
85
+ return "up-to-date";
86
+ }
87
+
88
+ // 模块级缓存:面板可能多处/多次拉取,TTL 内一律复用,不重复打 registry。
89
+ // at 用 -Infinity 作「从未拉取」哨兵:任何时钟下 now-at 都是正无穷,首轮
90
+ // 必然真实请求(测试的假时钟从 0 起也不会被误判成新鲜缓存)。
91
+ let cache = { at: -Infinity, latest: null };
92
+
93
+ /**
94
+ * 查询 registry latest。TTL 内直接命中缓存;任何失败(网络/超时/非 2xx/
95
+ * 响应形状不对/URL 校验不过)都静默返回 null——版本提示是锦上添花,绝不
96
+ * 让它成为新的故障面。失败不写缓存:TTL 起点保持旧值,下次调用立刻重试。
97
+ */
98
+ export async function fetchLatestVersion({ fetchImpl = typeof fetch === "function" ? fetch : () => Promise.reject(new Error("no fetch")), now = Date.now } = {}) {
99
+ if (now() - cache.at < CACHE_TTL_MS) return cache.latest;
100
+ if (!validateRegistryUrl(REGISTRY_URL)) return null;
101
+ let manifest;
102
+ try {
103
+ const response = await fetchImpl(REGISTRY_URL, {
104
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
105
+ headers: { accept: "application/json" }
106
+ });
107
+ if (!response.ok) return null;
108
+ manifest = await response.json();
109
+ } catch {
110
+ return null;
111
+ }
112
+ const latest = typeof manifest?.version === "string" && manifest.version ? manifest.version : null;
113
+ cache = { at: now(), latest };
114
+ return latest;
115
+ }
116
+
117
+ /** 仅供测试:清空模块级缓存与时间戳。 */
118
+ export function resetCacheForTest() {
119
+ cache = { at: -Infinity, latest: null };
120
+ }
121
+
122
+ export { PACKAGE_VERSION, REGISTRY_URL, CACHE_TTL_MS };
@@ -111,13 +111,23 @@ test("store: countConflictPending 只统计未决行", () => {
111
111
  store.close();
112
112
  });
113
113
 
114
- test("store: 已解决的同一对后续可再次 pending", () => {
114
+ test("store: 已解决的同一对在内容变化后才可再次 pending(issue #170 复核项 4)", async () => {
115
115
  const store = openStore();
116
- const p1 = store.saveConflictPending({ memory_a: "a", memory_b: "b", reason: "r" });
116
+ const a = store.save({ type: "project", title: "对A", content: "内容A" });
117
+ const b = store.save({ type: "project", title: "对B", content: "内容B" });
118
+ const p1 = store.saveConflictPending({ memory_a: a.id, memory_b: b.id, reason: "r" });
117
119
  store.resolveConflictPending(p1.id, { winner: "a" });
118
- // 去重只看未决行 —— 已解决后再现同一对应产生新 pending
119
- const p2 = store.saveConflictPending({ memory_a: "b", memory_b: "a", reason: "again" });
120
- assert.notEqual(p2.id, p1.id, "已解决行不参与去重");
120
+ // 内容未变 → 已裁决对不重新入队:「保留双方」是有效决定,不是待办。
121
+ const suppressed = store.saveConflictPending({ memory_a: b.id, memory_b: a.id, reason: "again" });
122
+ assert.equal(suppressed, undefined, "未变化的已裁决对被抑制");
123
+ assert.equal(store.countConflictPending(), 0);
124
+ // 任一侧被改过(updated_at 晚于 resolved_at)→ 重新入队产生新 pending。
125
+ // 留真实时间间隔:updated_at/resolved_at 毫秒精度,同毫秒算未变。
126
+ await new Promise((resolve) => setTimeout(resolve, 5));
127
+ store.update(a.id, { content: "内容A(改)" });
128
+ const p2 = store.saveConflictPending({ memory_a: b.id, memory_b: a.id, reason: "changed" });
129
+ assert.ok(p2, "内容变化后的对重新入队");
130
+ assert.notEqual(p2.id, p1.id, "新 pending 是新行");
121
131
  assert.equal(p2.resolved_at, undefined);
122
132
  assert.equal(store.countConflictPending(), 1);
123
133
  store.close();
@@ -0,0 +1,239 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { runSleep } from "../src/dream/sleep.js";
4
+ import { createDreamScheduler } from "../src/dream.js";
5
+ import { createStore } from "../src/store.js";
6
+ import { createService } from "../src/service.js";
7
+ import { createVectorIndex } from "../src/vector-index.js";
8
+
9
+ // v0.8.1(issue #170 第 2 步):sleep 冲突阶段的跨 scope 分流。
10
+ // 同一内容落在两个归属下(任一维标注键不等,含「一侧未标注=全局」)时,
11
+ // 不允许自动裁决(freeze 或 LLM)——归档败者可能销毁某归属下的唯一副本,
12
+ // 归属裁决是用户的决定。跨 scope 对一律停车到 conflict_pending(专属 reason),
13
+ // 同 scope 对维持既有路径。夹具为中性主题(构建笔记/编辑器主题)。
14
+
15
+ const embedder = {
16
+ embedSingle: async () => [1, 0, 0],
17
+ // 契约形状:按输入条数返回等长向量数组。update 会失效缓存并调度重嵌入,
18
+ // sleep 的回填走 embed()——返回单向量会让回填静默失败(no usable vectors)。
19
+ embed: async (texts) => (Array.isArray(texts) ? texts : [texts]).map(() => [1, 0, 0]),
20
+ schedule: () => {},
21
+ modelHash: "mock#1",
22
+ dimension: 3
23
+ };
24
+
25
+ function setup() {
26
+ const store = createStore(":memory:");
27
+ const service = createService({ store, mirror: null, config: {} });
28
+ const vectorIndex = createVectorIndex({ store });
29
+ service.setEmbedder(embedder);
30
+ service.setVectorIndex(vectorIndex);
31
+ return { store, service, vectorIndex };
32
+ }
33
+
34
+ function baseConfig(overrides = {}) {
35
+ return {
36
+ sleepModeEnabled: true,
37
+ sleepIdleMinutes: 5,
38
+ sleepMinIntervalHours: 8,
39
+ sleepConflictStrictness: "normal",
40
+ sleepArchiveDays: 30,
41
+ sleepCompressDays: 90,
42
+ sleepPatternMinMemories: 10,
43
+ sleepMaxPatternPerRun: 3,
44
+ ...overrides
45
+ };
46
+ }
47
+
48
+ function llmCtx(captured = [], selection = { provider: "mock", model: "sleep-model" }) {
49
+ return {
50
+ logger: { warn: () => {}, info: () => {} },
51
+ agentDefaultModel: { currentSelection: () => selection },
52
+ llm: {
53
+ async *stream(options) {
54
+ captured.push(options);
55
+ const userText = options.messages.find((m) => m.role === "user")?.content?.[0]?.text ?? "";
56
+ yield { type: "text-delta", index: 0, text: userText.startsWith("候选冲突") || userText.startsWith("Candidate conflicts") ? "[]" : "[]" };
57
+ yield { type: "finish", reason: { kind: "stop" } };
58
+ }
59
+ }
60
+ };
61
+ }
62
+
63
+ function noRouteCtx() {
64
+ return { logger: { warn: () => {}, info: () => {} } };
65
+ }
66
+
67
+ /** 保存一对高相似记忆并预填向量。返回 [新, 旧](updated_at DESC 序)。 */
68
+ function savePair(service, vectorIndex, titleA, titleB, scopeA, scopeB) {
69
+ const a = service.saveWithDedupe({
70
+ type: "project", title: titleA, content: `${titleA} 的正文`,
71
+ ...(scopeA?.agent ? { agent_scope: scopeA.agent } : {}),
72
+ ...(scopeA?.workspace ? { workspace_scope: scopeA.workspace } : {})
73
+ }).memory;
74
+ const b = service.saveWithDedupe({
75
+ type: "project", title: titleB, content: `${titleB} 的正文`,
76
+ ...(scopeB?.agent ? { agent_scope: scopeB.agent } : {}),
77
+ ...(scopeB?.workspace ? { workspace_scope: scopeB.workspace } : {})
78
+ }).memory;
79
+ vectorIndex.saveEmbedding(a.id, [1, 0, 0]);
80
+ vectorIndex.saveEmbedding(b.id, [1, 0, 0]);
81
+ return [a, b];
82
+ }
83
+
84
+ test("freeze mode: cross-scope pair parks with the scope-candidate reason; same-scope pair keeps the plain reason", async () => {
85
+ const { store, service, vectorIndex } = setup();
86
+ // updated_at DESC 序决定贪心配对:后保存的对先配。x 对=跨 scope,y 对=同 scope。
87
+ const [yNew, yOld] = savePair(service, vectorIndex, "构建笔记A", "构建笔记B", { agent: "coder" }, { agent: "coder" });
88
+ const [xNew, xOld] = savePair(service, vectorIndex, "编辑器主题A", "编辑器主题B", { agent: "coder" }, { agent: "writer" });
89
+
90
+ const result = await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
91
+ assert.equal(result.status, "ok");
92
+
93
+ const queue = store.listConflictPending();
94
+ assert.equal(queue.length, 2, "both pairs parked exactly once");
95
+ const crossRow = queue.find((q) => [q.memory_a, q.memory_b].includes(xNew.id));
96
+ const sameRow = queue.find((q) => [q.memory_a, q.memory_b].includes(yNew.id));
97
+ assert.ok(crossRow, "cross-scope pair must be parked");
98
+ assert.match(crossRow.reason, /跨作用域|cross-scope/, "cross pair carries the dedicated reason");
99
+ assert.ok(sameRow, "same-scope pair still parked in freeze mode");
100
+ assert.doesNotMatch(sameRow.reason, /跨作用域|cross-scope/, "same-scope pair keeps the plain similarity reason");
101
+
102
+ // 再跑一轮:同一对不去重不重复入队。
103
+ await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
104
+ assert.equal(store.countConflictPending(), 2, "pair-level dedupe survives reruns");
105
+ store.close();
106
+ });
107
+
108
+ test("NULL (unlabeled) vs labeled counts as a cross-scope pair", async () => {
109
+ const { store, service, vectorIndex } = setup();
110
+ savePair(service, vectorIndex, "部署清单A", "部署清单B", {}, { agent: "coder" });
111
+ const result = await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
112
+ assert.equal(result.status, "ok");
113
+ const queue = store.listConflictPending();
114
+ assert.equal(queue.length, 1);
115
+ assert.match(queue[0].reason, /跨作用域|cross-scope/, "global(unlabeled) copy vs scoped copy is an ownership decision");
116
+ store.close();
117
+ });
118
+
119
+ test("non-freeze without an LLM route: cross-scope pair still parks; nothing is auto-adjudicated", async () => {
120
+ const { store, service, vectorIndex } = setup();
121
+ const [newer, older] = savePair(service, vectorIndex, "发布流程A", "发布流程B", { agent: "coder" }, { agent: "writer" });
122
+ const result = await runSleep(noRouteCtx(), service, baseConfig(), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
123
+
124
+ const queue = store.listConflictPending();
125
+ assert.equal(queue.length, 1, "cross-scope pair parks even with no LLM route");
126
+ assert.match(queue[0].reason, /跨作用域|cross-scope/);
127
+ assert.equal(store.getById(newer.id).archived, false, "no side is auto-archived");
128
+ assert.equal(store.getById(older.id).archived, false);
129
+ assert.ok(queue[0].resolved_at === undefined);
130
+ store.close();
131
+ });
132
+
133
+ test("reviewed pair does not re-queue until one of its sides changes (review item 4)", async () => {
134
+ const { store, service, vectorIndex } = setup();
135
+ const [newer, older] = savePair(service, vectorIndex, "备份策略A", "备份策略B", { agent: "coder" }, { agent: "writer" });
136
+ await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
137
+ assert.equal(store.countConflictPending(), 1);
138
+
139
+ // 人工「保留双方」(winner=null)后,内容未变 → 下一轮不再入队。
140
+ const row = store.listConflictPending()[0];
141
+ store.resolveConflictPending(row.id, { winner: null });
142
+ assert.equal(store.countConflictPending(), 0);
143
+ const rerun = await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
144
+ assert.equal(store.countConflictPending(), 0, "unchanged reviewed pair must stay dismissed");
145
+ assert.equal(rerun.status, "noop", "suppressed parks count as noop");
146
+
147
+ // 任一侧被改过(updated_at 晚于裁决)→ 重新入队(新决策)。
148
+ // 留出真实时间间隔:updated_at/resolved_at 都是毫秒精度,同毫秒内
149
+ // 「裁决后立即修改」会算作未变(生产中人为修改不可能同毫秒)。
150
+ await new Promise((resolve) => setTimeout(resolve, 5));
151
+ service.update(newer.id, { content: "备份策略A 的正文(改)" });
152
+ await runSleep(llmCtx(), service, baseConfig({ conflictFreezeEnabled: true }), { warn: () => {}, info: () => {} }, { embedder, vectorIndex }, null);
153
+ assert.equal(store.countConflictPending(), 1, "changed pair is worth a fresh review");
154
+ store.close();
155
+ });
156
+
157
+ test("dream (non-freeze): cross-scope conflict parks for review instead of being adjudicated (review item 3)", async () => {
158
+ const { store, service } = setup();
159
+ const w = service.saveWithDedupe({ type: "decision", title: "发布时间", content: "8月20日", importance: 4, agent_scope: "coder", agent_scope_source: "explicit" }).memory;
160
+ const l = service.saveWithDedupe({ type: "decision", title: "发布时间旧", content: "8月15日", importance: 4, agent_scope: "writer", agent_scope_source: "explicit" }).memory;
161
+ const ctx = {
162
+ llm: { stream: async function* () {
163
+ yield { type: "text-delta", text: JSON.stringify([{ action: "conflict", winner: w.id, loser: l.id, reason: "日期更新" }]) };
164
+ yield { type: "finish", reason: { kind: "ok" } };
165
+ } },
166
+ logger: { warn: () => {}, info: () => {} }
167
+ };
168
+ const dream = createDreamScheduler({ thresholdCount: 1, thresholdChars: 0, delayMs: 0 });
169
+ const result = await dream.runDream(ctx, service, { dreamProvider: "mock", dreamModel: "mock-chat" });
170
+ assert.equal(result.ok, true);
171
+ assert.equal(result.applied, 0, "cross-scope conflict is NOT auto-adjudicated");
172
+ assert.equal(result.frozen, 1, "parked pair shows up in the run summary");
173
+ const pending = store.listConflictPending();
174
+ assert.equal(pending.length, 1);
175
+ assert.match(pending[0].reason, /跨作用域|cross-scope/, "dedicated reason");
176
+ assert.equal(store.getById(l.id).archived, false, "loser NOT archived");
177
+ assert.ok(!store.getById(w.id).content.includes("已否决旧信息"), "winner untouched");
178
+ store.close();
179
+ });
180
+
181
+ test("dream (non-freeze): same-scope conflict is still auto-adjudicated (regression)", async () => {
182
+ const { store, service } = setup();
183
+ const w = service.saveWithDedupe({ type: "decision", title: "发布时间", content: "8月20日", importance: 4, agent_scope: "coder", agent_scope_source: "explicit" }).memory;
184
+ const l = service.saveWithDedupe({ type: "decision", title: "发布时间旧", content: "8月15日", importance: 4, agent_scope: "coder", agent_scope_source: "explicit" }).memory;
185
+ const ctx = {
186
+ llm: { stream: async function* () {
187
+ yield { type: "text-delta", text: JSON.stringify([{ action: "conflict", winner: w.id, loser: l.id, reason: "日期更新" }]) };
188
+ yield { type: "finish", reason: { kind: "ok" } };
189
+ } },
190
+ logger: { warn: () => {}, info: () => {} }
191
+ };
192
+ const dream = createDreamScheduler({ thresholdCount: 1, thresholdChars: 0, delayMs: 0 });
193
+ const result = await dream.runDream(ctx, service, { dreamProvider: "mock", dreamModel: "mock-chat" });
194
+ assert.equal(result.ok, true);
195
+ assert.equal(result.applied, 1, "same-scope conflict adjudicated as before");
196
+ assert.equal(result.frozen, 0);
197
+ assert.equal(store.listConflictPending().length, 0);
198
+ assert.equal(store.getById(l.id).archived, true);
199
+ store.close();
200
+ });
201
+
202
+ test("non-freeze with an LLM: cross-scope pair bypasses adjudication; same-scope pair is adjudicated", async () => {
203
+ const { store, service, vectorIndex } = setup();
204
+ const [yNew, yOld] = savePair(service, vectorIndex, "缓存策略A", "缓存策略B", { agent: "coder" }, { agent: "coder" });
205
+ const [xNew, xOld] = savePair(service, vectorIndex, "编辑器主题A", "编辑器主题B", { agent: "coder" }, { agent: "writer" });
206
+
207
+ const captured = [];
208
+ const ctx = llmCtx(captured);
209
+ // 同 scope 对由 LLM 裁决:保留 yNew、归档 yOld。跨 scope 对绝不进 prompt。
210
+ ctx.llm.stream = async function* (options) {
211
+ captured.push(options);
212
+ const userText = options.messages.find((m) => m.role === "user")?.content?.[0]?.text ?? "";
213
+ const isConflictPass = userText.startsWith("候选冲突") || userText.startsWith("Candidate conflicts");
214
+ const text = isConflictPass
215
+ ? JSON.stringify([{ action: "conflict", winner: yNew.id, loser: yOld.id, reason: "同归属重复" }])
216
+ : "[]";
217
+ yield { type: "text-delta", index: 0, text };
218
+ yield { type: "finish", reason: { kind: "stop" } };
219
+ };
220
+
221
+ const result = await runSleep(ctx, service, baseConfig(), ctx.logger, { embedder, vectorIndex }, null);
222
+ assert.equal(result.status, "ok");
223
+
224
+ const conflictPassTexts = captured
225
+ .map((o) => o.messages.find((m) => m.role === "user")?.content?.[0]?.text ?? "")
226
+ .filter((t) => t.startsWith("候选冲突") || t.startsWith("Candidate conflicts"));
227
+ assert.ok(conflictPassTexts.length >= 1, "conflict pass ran for the same-scope pair");
228
+ for (const t of conflictPassTexts) {
229
+ assert.ok(!t.includes(xNew.id) && !t.includes(xOld.id), "cross-scope pair must never enter the LLM prompt");
230
+ assert.ok(t.includes(yNew.id) && t.includes(yOld.id), "same-scope pair is adjudicated");
231
+ }
232
+
233
+ const queue = store.listConflictPending();
234
+ assert.equal(queue.length, 1);
235
+ assert.match(queue[0].reason, /跨作用域|cross-scope/);
236
+ assert.equal(store.getById(xOld.id).archived, false, "cross-scope loser is NOT archived by the LLM");
237
+ assert.equal(store.getById(yOld.id).archived, true, "same-scope loser is adjudicated as usual");
238
+ store.close();
239
+ });