Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
196 lines
7.3 KiB
TypeScript
196 lines
7.3 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { ingestMemoryWikiSource } from "./ingest.js";
|
|
import { createMemoryWikiTestHarness } from "./test-helpers.js";
|
|
|
|
const { createTempDir, createVault } = createMemoryWikiTestHarness();
|
|
|
|
describe("ingestMemoryWikiSource human notes", () => {
|
|
it("preserves user notes when the same source is re-ingested", async () => {
|
|
const rootDir = await createTempDir("memory-wiki-reingest-");
|
|
const inputPath = path.join(rootDir, "roadmap.txt");
|
|
const { config } = await createVault({ rootDir: path.join(rootDir, "vault") });
|
|
|
|
await fs.writeFile(inputPath, "v1 content\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 5, 12, 0, 0),
|
|
});
|
|
|
|
const pagePath = path.join(config.vault.path, "sources", "roadmap.md");
|
|
const userNote = "KEY INSIGHT: covers $1 of the Q2 roadmap";
|
|
const edited = (await fs.readFile(pagePath, "utf8")).replace(
|
|
"<!-- openclaw:human:start -->\n<!-- openclaw:human:end -->",
|
|
`<!-- openclaw:human:start -->\n${userNote}\n<!-- openclaw:human:end -->`,
|
|
);
|
|
await fs.writeFile(pagePath, edited, "utf8");
|
|
|
|
await fs.writeFile(inputPath, "v2 content updated\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 6, 12, 0, 0),
|
|
});
|
|
|
|
const after = await fs.readFile(pagePath, "utf8");
|
|
expect(after).toContain("v2 content updated");
|
|
expect(after).toContain(userNote);
|
|
});
|
|
|
|
it("preserves notes without corrupting source content that contains human markers", async () => {
|
|
const rootDir = await createTempDir("memory-wiki-markers-");
|
|
const inputPath = path.join(rootDir, "notes.txt");
|
|
const { config } = await createVault({ rootDir: path.join(rootDir, "vault") });
|
|
|
|
await fs.writeFile(inputPath, "first body\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 5, 12, 0, 0),
|
|
});
|
|
|
|
const pagePath = path.join(config.vault.path, "sources", "notes.md");
|
|
const userNote = "MY PRIVATE NOTE";
|
|
const edited = (await fs.readFile(pagePath, "utf8")).replace(
|
|
"<!-- openclaw:human:start -->\n<!-- openclaw:human:end -->",
|
|
`<!-- openclaw:human:start -->\n${userNote}\n<!-- openclaw:human:end -->`,
|
|
);
|
|
await fs.writeFile(pagePath, edited, "utf8");
|
|
|
|
const sourceWithMarkers = [
|
|
"second body",
|
|
"<!-- openclaw:human:start -->",
|
|
"INJECTED FROM SOURCE",
|
|
"<!-- openclaw:human:end -->",
|
|
"",
|
|
].join("\n");
|
|
await fs.writeFile(inputPath, sourceWithMarkers, "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 6, 12, 0, 0),
|
|
});
|
|
|
|
const after = await fs.readFile(pagePath, "utf8");
|
|
const notesBlock = after.slice(after.indexOf("## Notes"));
|
|
expect(after).toContain("INJECTED FROM SOURCE");
|
|
expect(notesBlock).toContain(userNote);
|
|
expect(notesBlock).not.toContain("INJECTED FROM SOURCE");
|
|
});
|
|
|
|
it("preserves CRLF notes without copying marker comments from existing source content", async () => {
|
|
const rootDir = await createTempDir("memory-wiki-crlf-markers-");
|
|
const inputPath = path.join(rootDir, "windows-notes.txt");
|
|
const { config } = await createVault({ rootDir: path.join(rootDir, "vault") });
|
|
|
|
const sourceWithMarkers = [
|
|
"first body",
|
|
"<!-- openclaw:human:start -->",
|
|
"OLD SOURCE MARKER PAYLOAD",
|
|
"<!-- openclaw:human:end -->",
|
|
"",
|
|
].join("\n");
|
|
await fs.writeFile(inputPath, sourceWithMarkers, "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 5, 12, 0, 0),
|
|
});
|
|
|
|
const pagePath = path.join(config.vault.path, "sources", "windows-notes.md");
|
|
const userNote = "CRLF USER NOTE";
|
|
const edited = (await fs.readFile(pagePath, "utf8")).replace(
|
|
"<!-- openclaw:human:start -->\n<!-- openclaw:human:end -->",
|
|
`<!-- openclaw:human:start -->\n${userNote}\n<!-- openclaw:human:end -->`,
|
|
);
|
|
await fs.writeFile(pagePath, edited.replace(/\n/g, "\r\n"), "utf8");
|
|
|
|
await fs.writeFile(inputPath, "second body without marker comments\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 6, 12, 0, 0),
|
|
});
|
|
|
|
const after = await fs.readFile(pagePath, "utf8");
|
|
const notesBlock = after.slice(after.indexOf("## Notes"));
|
|
expect(after).toContain("second body without marker comments");
|
|
expect(notesBlock).toContain(userNote);
|
|
expect(notesBlock).not.toContain("OLD SOURCE MARKER PAYLOAD");
|
|
});
|
|
|
|
it("preserves the whole note when the note text itself contains a marker comment", async () => {
|
|
const rootDir = await createTempDir("memory-wiki-innermarker-");
|
|
const inputPath = path.join(rootDir, "diary.txt");
|
|
const { config } = await createVault({ rootDir: path.join(rootDir, "vault") });
|
|
|
|
await fs.writeFile(inputPath, "first body\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 5, 12, 0, 0),
|
|
});
|
|
|
|
const pagePath = path.join(config.vault.path, "sources", "diary.md");
|
|
const noteWithMarker = [
|
|
"EARLY NOTE before any quoted marker",
|
|
"<!-- openclaw:human:start -->",
|
|
"LATE NOTE after a pasted marker",
|
|
].join("\n");
|
|
const edited = (await fs.readFile(pagePath, "utf8")).replace(
|
|
"<!-- openclaw:human:start -->\n<!-- openclaw:human:end -->",
|
|
`<!-- openclaw:human:start -->\n${noteWithMarker}\n<!-- openclaw:human:end -->`,
|
|
);
|
|
await fs.writeFile(pagePath, edited, "utf8");
|
|
|
|
await fs.writeFile(inputPath, "second body\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 6, 12, 0, 0),
|
|
});
|
|
|
|
const after = await fs.readFile(pagePath, "utf8");
|
|
expect(after).toContain("second body");
|
|
expect(after).toContain("EARLY NOTE before any quoted marker");
|
|
expect(after).toContain("LATE NOTE after a pasted marker");
|
|
});
|
|
|
|
it("preserves the note when the note text contains a Markdown heading", async () => {
|
|
const rootDir = await createTempDir("memory-wiki-heading-");
|
|
const inputPath = path.join(rootDir, "log.txt");
|
|
const { config } = await createVault({ rootDir: path.join(rootDir, "vault") });
|
|
|
|
await fs.writeFile(inputPath, "first body\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 5, 12, 0, 0),
|
|
});
|
|
|
|
const pagePath = path.join(config.vault.path, "sources", "log.md");
|
|
const noteWithHeading = ["NOTE TOP", "## Notes", "NOTE BOTTOM under a pasted heading"].join(
|
|
"\n",
|
|
);
|
|
const edited = (await fs.readFile(pagePath, "utf8")).replace(
|
|
"<!-- openclaw:human:start -->\n<!-- openclaw:human:end -->",
|
|
`<!-- openclaw:human:start -->\n${noteWithHeading}\n<!-- openclaw:human:end -->`,
|
|
);
|
|
await fs.writeFile(pagePath, edited, "utf8");
|
|
|
|
await fs.writeFile(inputPath, "second body\n", "utf8");
|
|
await ingestMemoryWikiSource({
|
|
config,
|
|
inputPath,
|
|
nowMs: Date.UTC(2026, 3, 6, 12, 0, 0),
|
|
});
|
|
|
|
const after = await fs.readFile(pagePath, "utf8");
|
|
expect(after).toContain("second body");
|
|
expect(after).toContain("NOTE TOP");
|
|
expect(after).toContain("NOTE BOTTOM under a pasted heading");
|
|
});
|
|
});
|