
























@@ -30,6 +30,24 @@ describe("compileMemoryWikiVault", () => {
3030await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
3131}
323233+function expectDigestPage<T extends { path: string }>(pages: T[], pagePath: string): T {
34+const page = pages.find((candidate) => candidate.path === pagePath);
35+expect(page).toBeDefined();
36+if (!page) {
37+throw new Error(`Expected digest page ${pagePath}`);
38+}
39+return page;
40+}
41+42+function expectDigestCluster<T extends { key: string }>(clusters: T[], key: string): T {
43+const cluster = clusters.find((candidate) => candidate.key === key);
44+expect(cluster).toBeDefined();
45+if (!cluster) {
46+throw new Error(`Expected digest contradiction cluster ${key}`);
47+}
48+return cluster;
49+}
50+3351it("writes root and directory indexes for native markdown", async () => {
3452const { rootDir, config } = await createVault({
3553rootDir: nextCaseRoot(),
@@ -77,13 +95,11 @@ describe("compileMemoryWikiVault", () => {
7795pages: Array<{ path: string; claimCount: number; topClaims: Array<{ text: string }> }>;
7896};
7997expect(agentDigest.claimCount).toBe(1);
80-expect(agentDigest.pages).toContainEqual(
81-expect.objectContaining({
82-path: "sources/alpha.md",
83-claimCount: 1,
84-topClaims: [expect.objectContaining({ text: "Alpha is the canonical source page." })],
85-}),
86-);
98+const alphaPage = expectDigestPage(agentDigest.pages, "sources/alpha.md");
99+expect(alphaPage.claimCount).toBe(1);
100+expect(alphaPage.topClaims.map((claim) => claim.text)).toEqual([
101+"Alpha is the canonical source page.",
102+]);
87103await expect(
88104fs.readFile(path.join(rootDir, ".openclaw-wiki", "cache", "claims.jsonl"), "utf8"),
89105).resolves.toContain('"text":"Alpha is the canonical source page."');
@@ -341,8 +357,8 @@ describe("compileMemoryWikiVault", () => {
341357};
342358expect(agentDigest.claimHealth.missingEvidence).toBeGreaterThanOrEqual(1);
343359expect(agentDigest.claimHealth.freshness.unknown).toBeGreaterThanOrEqual(1);
344-expect(agentDigest.contradictionClusters).toContainEqual(
345-expect.objectContaining({ key: "claim.alpha.db" }),
360+expect(expectDigestCluster(agentDigest.contradictionClusters, "claim.alpha.db").key).toBe(
361+"claim.alpha.db",
346362);
347363});
348364@@ -456,15 +472,11 @@ describe("compileMemoryWikiVault", () => {
456472relationshipCount?: number;
457473}>;
458474};
459-expect(agentDigest.pages).toContainEqual(
460-expect.objectContaining({
461-path: "entities/brad.md",
462-canonicalId: "maintainer.brad-groux",
463-aliases: ["brad"],
464-personCard: expect.objectContaining({ lane: "Microsoft Teams" }),
465-relationshipCount: 1,
466-}),
467-);
475+const bradPage = expectDigestPage(agentDigest.pages, "entities/brad.md");
476+expect(bradPage.canonicalId).toBe("maintainer.brad-groux");
477+expect(bradPage.aliases).toEqual(["brad"]);
478+expect(bradPage.personCard?.lane).toBe("Microsoft Teams");
479+expect(bradPage.relationshipCount).toBe(1);
468480await expect(
469481fs.readFile(path.join(rootDir, ".openclaw-wiki", "cache", "claims.jsonl"), "utf8"),
470482).resolves.toContain('"evidenceKinds":["maintainer-whois"]');
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。