@@ -1046,7 +1046,7 @@ describe("memory index", () => {
|
1046 | 1046 | } |
1047 | 1047 | }); |
1048 | 1048 | |
1049 | | -it("rebuilds missing metadata with existing chunks on gateway sync", async () => { |
| 1049 | +it("rebuilds missing metadata with existing chunks before search", async () => { |
1050 | 1050 | const cfg = createCfg({ |
1051 | 1051 | hybrid: { enabled: true, vectorWeight: 0.5, textWeight: 0.5 }, |
1052 | 1052 | }); |
@@ -1070,24 +1070,10 @@ describe("memory index", () => {
|
1070 | 1070 | |
1071 | 1071 | const results = await nextManager.search("alpha"); |
1072 | 1072 | |
1073 | | -expect(results).toStrictEqual([]); |
1074 | | -expect(nextManager.status().dirty).toBe(true); |
1075 | | -expect(nextManager.status().custom?.indexIdentity).toEqual({ |
1076 | | -status: "missing", |
1077 | | -reason: "index metadata is missing", |
1078 | | -}); |
1079 | | - |
1080 | | -await nextManager.sync({ reason: "test" }); |
1081 | | - |
1082 | 1073 | expect(nextManager.status().dirty).toBe(false); |
1083 | 1074 | expect(nextManager.status().custom?.indexIdentity).toEqual({ status: "valid" }); |
1084 | | -const repairedAlphaResults = await nextManager.search("alpha"); |
1085 | | -expect( |
1086 | | -repairedAlphaResults.some((result) => result.path.endsWith("memory/2026-01-12.md")), |
1087 | | -).toBe(false); |
1088 | | -const repairedResults = await nextManager.search("beta"); |
1089 | | -expect(repairedResults.length).toBeGreaterThan(0); |
1090 | | -expect(repairedResults[0]?.path).toContain("memory/2026-01-13.md"); |
| 1075 | +expect(results.some((result) => result.path.endsWith("memory/2026-01-12.md"))).toBe(false); |
| 1076 | +expect(results.some((result) => result.path.endsWith("memory/2026-01-13.md"))).toBe(true); |
1091 | 1077 | } finally { |
1092 | 1078 | await nextManager.close?.(); |
1093 | 1079 | } |
|