

























@@ -328,7 +328,7 @@ describe("subagent registry persistence", () => {
328328expect(after.version).toBe(2);
329329});
330330331-it("reuses unchanged persisted registry snapshots without reparsing runs.json", async () => {
331+it("returns isolated clones for unchanged persisted registry snapshots", async () => {
332332const registryPath = await writePersistedRegistry(
333333{
334334version: 2,
@@ -349,8 +349,6 @@ describe("subagent registry persistence", () => {
349349},
350350{ seedChildSessions: false },
351351);
352-const readSpy = vi.spyOn(fsSync, "readFileSync");
353-354352const first = loadSubagentRegistryFromDisk();
355353first.clear();
356354const cachedEntry = loadSubagentRegistryFromDisk().get("run-cached");
@@ -373,9 +371,6 @@ describe("subagent registry persistence", () => {
373371});
374372expect(second.get("run-cached")?.endedAt).toBeUndefined();
375373expect(second.get("run-cached")?.cleanupHandled).toBeUndefined();
376-expect(
377-readSpy.mock.calls.filter(([pathname]) => String(pathname) === registryPath),
378-).toHaveLength(1);
379374380375await fs.writeFile(
381376registryPath,
@@ -398,24 +393,17 @@ describe("subagent registry persistence", () => {
398393);
399394400395expect(loadSubagentRegistryFromDisk().has("run-updated")).toBe(true);
401-expect(
402-readSpy.mock.calls.filter(([pathname]) => String(pathname) === registryPath),
403-).toHaveLength(2);
404396});
405397406-it("reuses unchanged invalid persisted registry snapshots as empty", async () => {
398+it("returns empty maps for unchanged invalid persisted registry snapshots", async () => {
407399tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-subagent-"));
408400process.env.OPENCLAW_STATE_DIR = tempStateDir;
409401const registryPath = path.join(tempStateDir, "subagents", "runs.json");
410402await fs.mkdir(path.dirname(registryPath), { recursive: true });
411403await fs.writeFile(registryPath, "{invalid", "utf8");
412-const readSpy = vi.spyOn(fsSync, "readFileSync");
413404414405expect(loadSubagentRegistryFromDisk()).toEqual(new Map());
415406expect(loadSubagentRegistryFromDisk()).toEqual(new Map());
416-expect(
417-readSpy.mock.calls.filter(([pathname]) => String(pathname) === registryPath),
418-).toHaveLength(1);
419407});
420408421409it("normalizes persisted and newly registered session keys to canonical trimmed values", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。