



























@@ -87,6 +87,10 @@ describe("short-term promotion", () => {
8787return candidate.promotedAt;
8888}
898990+async function expectEnoent(promise: Promise<unknown>): Promise<void> {
91+await expect(promise).rejects.toHaveProperty("code", "ENOENT");
92+}
93+9094it("detects short-term daily memory paths", () => {
9195expect(isShortTermMemoryPath("memory/2026-04-03.md")).toBe(true);
9296expect(isShortTermMemoryPath("2026-04-03.md")).toBe(true);
@@ -190,11 +194,7 @@ describe("short-term promotion", () => {
190194],
191195});
192196193-await expect(
194-fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"),
195-).rejects.toMatchObject({
196-code: "ENOENT",
197-});
197+await expectEnoent(fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"));
198198});
199199});
200200@@ -215,11 +215,7 @@ describe("short-term promotion", () => {
215215],
216216});
217217218-await expect(
219-fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"),
220-).rejects.toMatchObject({
221-code: "ENOENT",
222-});
218+await expectEnoent(fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"));
223219});
224220});
225221@@ -241,12 +237,11 @@ describe("short-term promotion", () => {
241237],
242238});
243239244-expect(
245-JSON.parse(await fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8")),
246-).toMatchObject({
247-version: 1,
248-entries: {},
249-});
240+const store = JSON.parse(
241+await fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"),
242+) as { version?: number; entries?: unknown };
243+expect(store.version).toBe(1);
244+expect(store.entries).toEqual({});
250245});
251246});
252247@@ -273,12 +268,11 @@ describe("short-term promotion", () => {
273268],
274269});
275270276-expect(
277-JSON.parse(await fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8")),
278-).toMatchObject({
279-version: 1,
280-entries: {},
281-});
271+const store = JSON.parse(
272+await fs.readFile(resolveShortTermRecallStorePath(workspaceDir), "utf-8"),
273+) as { version?: number; entries?: unknown };
274+expect(store.version).toBe(1);
275+expect(store.entries).toEqual({});
282276});
283277});
284278@@ -490,11 +484,9 @@ describe("short-term promotion", () => {
490484});
491485492486expect(ranked).toHaveLength(1);
493-expect(ranked[0]).toMatchObject({
494-recallCount: 0,
495-dailyCount: 3,
496-uniqueQueries: 3,
497-});
487+expect(ranked[0]?.recallCount).toBe(0);
488+expect(ranked[0]?.dailyCount).toBe(3);
489+expect(ranked[0]?.uniqueQueries).toBe(3);
498490expect(ranked[0]?.recallDays).toEqual(queryDays);
499491expect(ranked[0]?.score).toBeGreaterThanOrEqual(0.75);
500492});
@@ -803,10 +795,8 @@ describe("short-term promotion", () => {
803795const phaseStore = JSON.parse(await fs.readFile(phaseStorePath, "utf-8")) as {
804796entries: Record<string, { lightHits: number; remHits: number }>;
805797};
806-expect(phaseStore.entries[boostedKey]).toMatchObject({
807-lightHits: 1,
808-remHits: 1,
809-});
798+expect(phaseStore.entries[boostedKey]?.lightHits).toBe(1);
799+expect(phaseStore.entries[boostedKey]?.remHits).toBe(1);
810800});
811801});
812802@@ -1167,11 +1157,7 @@ describe("short-term promotion", () => {
11671157});
1168115811691159expect(applied.applied).toBe(0);
1170-await expect(
1171-fs.readFile(path.join(workspaceDir, "MEMORY.md"), "utf-8"),
1172-).rejects.toMatchObject({
1173-code: "ENOENT",
1174-});
1160+await expectEnoent(fs.readFile(path.join(workspaceDir, "MEMORY.md"), "utf-8"));
11751161});
11761162});
11771163@@ -1214,11 +1200,7 @@ describe("short-term promotion", () => {
12141200});
1215120112161202expect(applied.applied).toBe(0);
1217-await expect(
1218-fs.readFile(path.join(workspaceDir, "MEMORY.md"), "utf-8"),
1219-).rejects.toMatchObject({
1220-code: "ENOENT",
1221-});
1203+await expectEnoent(fs.readFile(path.join(workspaceDir, "MEMORY.md"), "utf-8"));
12221204});
12231205});
12241206@@ -1526,9 +1508,7 @@ describe("short-term promotion", () => {
15261508});
1527150915281510expect(applied.applied).toBe(0);
1529-await expect(fs.access(path.join(workspaceDir, "MEMORY.md"))).rejects.toMatchObject({
1530-code: "ENOENT",
1531-});
1511+await expectEnoent(fs.access(path.join(workspaceDir, "MEMORY.md")));
15321512});
15331513});
15341514@@ -1651,10 +1631,12 @@ describe("short-term promotion", () => {
1651163116521632expect(repair.changed).toBe(true);
16531633expect(repair.rewroteStore).toBe(true);
1654-expect(JSON.parse(await fs.readFile(storePath, "utf-8"))).toMatchObject({
1655-version: 1,
1656-entries: {},
1657-});
1634+const store = JSON.parse(await fs.readFile(storePath, "utf-8")) as {
1635+version?: number;
1636+entries?: unknown;
1637+};
1638+expect(store.version).toBe(1);
1639+expect(store.entries).toEqual({});
16581640});
16591641});
16601642此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。