mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
feat(memory-wiki): lint imported provenance gaps
This commit is contained in:
@@ -36,18 +36,37 @@ describe("lintMemoryWikiVault", () => {
|
||||
});
|
||||
await fs.writeFile(path.join(rootDir, "entities", "alpha.md"), duplicate, "utf8");
|
||||
await fs.writeFile(path.join(rootDir, "concepts", "alpha.md"), duplicate, "utf8");
|
||||
await fs.writeFile(
|
||||
path.join(rootDir, "sources", "bridge-alpha.md"),
|
||||
renderWikiMarkdown({
|
||||
frontmatter: {
|
||||
pageType: "source",
|
||||
id: "source.bridge.alpha",
|
||||
title: "Bridge Alpha",
|
||||
sourceType: "memory-bridge",
|
||||
},
|
||||
body: "# Bridge Alpha\n",
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const result = await lintMemoryWikiVault(config);
|
||||
|
||||
expect(result.issueCount).toBeGreaterThan(0);
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("duplicate-id");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("missing-source-ids");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("missing-import-provenance");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("broken-wikilink");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("contradiction-present");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("open-question");
|
||||
expect(result.issues.map((issue) => issue.code)).toContain("low-confidence");
|
||||
expect(result.issuesByCategory.contradictions).toHaveLength(2);
|
||||
expect(result.issuesByCategory["open-questions"]).toHaveLength(2);
|
||||
expect(
|
||||
result.issuesByCategory.provenance.some(
|
||||
(issue) => issue.code === "missing-import-provenance",
|
||||
),
|
||||
).toBe(true);
|
||||
await expect(fs.readFile(result.reportPath, "utf8")).resolves.toContain("### Errors");
|
||||
await expect(fs.readFile(result.reportPath, "utf8")).resolves.toContain("### Contradictions");
|
||||
await expect(fs.readFile(result.reportPath, "utf8")).resolves.toContain("### Open Questions");
|
||||
|
||||
@@ -19,6 +19,7 @@ export type MemoryWikiLintIssue = {
|
||||
| "page-type-mismatch"
|
||||
| "missing-title"
|
||||
| "missing-source-ids"
|
||||
| "missing-import-provenance"
|
||||
| "broken-wikilink"
|
||||
| "contradiction-present"
|
||||
| "open-question"
|
||||
@@ -121,6 +122,34 @@ function collectPageIssues(pages: WikiPageSummary[]): MemoryWikiLintIssue[] {
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
(page.sourceType === "memory-bridge" || page.sourceType === "memory-bridge-events") &&
|
||||
(!page.sourcePath || !page.bridgeRelativePath || !page.bridgeWorkspaceDir)
|
||||
) {
|
||||
issues.push({
|
||||
severity: "warning",
|
||||
category: "provenance",
|
||||
code: "missing-import-provenance",
|
||||
path: page.relativePath,
|
||||
message:
|
||||
"Bridge-imported source page is missing `sourcePath`, `bridgeRelativePath`, or `bridgeWorkspaceDir` provenance.",
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
(page.provenanceMode === "unsafe-local" || page.sourceType === "memory-unsafe-local") &&
|
||||
(!page.sourcePath || !page.unsafeLocalConfiguredPath || !page.unsafeLocalRelativePath)
|
||||
) {
|
||||
issues.push({
|
||||
severity: "warning",
|
||||
category: "provenance",
|
||||
code: "missing-import-provenance",
|
||||
path: page.relativePath,
|
||||
message:
|
||||
"Unsafe-local source page is missing `sourcePath`, `unsafeLocalConfiguredPath`, or `unsafeLocalRelativePath` provenance.",
|
||||
});
|
||||
}
|
||||
|
||||
if (page.contradictions.length > 0) {
|
||||
issues.push({
|
||||
severity: "warning",
|
||||
|
||||
Reference in New Issue
Block a user