Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: normalize retained titles and isolate sync fixture identity
garrytan850a2dea178d
diff --git a/src/core/facts/file-body-guard.ts b/src/core/facts/file-body-guard.tsindex 521953d373..beace058c4 100644--- a/src/core/facts/file-body-guard.ts+++ b/src/core/facts/file-body-guard.ts@@ -93,7 +93,7 @@ function fileHeldBy(fileBytes: string, slug: string, state: StoredState): booleaif (!fileBodyMatchesStored(fileBytes, slug, state)) return false;const parsed = parseMarkdown(fileBytes, `${slug}.md`);const declared = parseMarkdownHead(fileBytes).frontmatter;- if (declared.title !== undefined && parsed.title.trim() !== (state.title ?? '').trim()) return false;+ if (declared.title !== undefined && sanitizeText(parsed.title).trim() !== (state.title ?? '').trim()) return false;if (parsed.typeExplicit && parsed.type !== state.type) return false;const storedTags = Array.isArray(state.tags) ? state.tags.map(String) : [];if (JSON.stringify([...new Set(parsed.tags)].sort()) !== JSON.stringify([...new Set(storedTags)].sort())) return false;diff --git a/test/pathological/d15-sync-reexport-overwrite.test.ts b/test/pathological/d15-sync-reexport-overwrite.test.tsindex 1452e2e049..2d9761f29e 100644--- a/test/pathological/d15-sync-reexport-overwrite.test.ts+++ b/test/pathological/d15-sync-reexport-overwrite.test.ts@@ -41,6 +41,7 @@ async function withBrain(databaseUrl: string | undefined, run: (b: {const root = join(home, 'brain');mkdirSync(join(root, 'memories'), { recursive: true });gitExec('git init', root);+ gitExec('git config user.email [email protected] && git config user.name "Test Fixture"', root);writeFileSync(join(root, '.gitignore'), 'memories/\n');gitExec('git add .gitignore && git commit -m fixture', root);await engine.executeRaw("UPDATE sources SET local_path = $1 WHERE id = 'default'", [root]);diff --git a/test/pathological/d16-google-file-replacement.test.ts b/test/pathological/d16-google-file-replacement.test.tsindex 9ec573dd4f..6d1b540df9 100644--- a/test/pathological/d16-google-file-replacement.test.ts+++ b/test/pathological/d16-google-file-replacement.test.ts@@ -105,6 +105,25 @@ for (const { backend, databaseUrl } of pathologicalArms()) {});}, 180_000);+ test('a real title-only edit is held without replacing either copy', async () => {+ await withSource(databaseUrl, async b => {+ const file = b.file();+ const edited = file.replace('title: "Alice Example"', 'title: "Alice Updated Example"');+ expect(edited).not.toBe(file);+ writeFileSync(b.path, edited);+ const before = { body: await b.body(), title: (await b.engine.getPage(BAD, { sourceId: SOURCE }))!.title };+ for (let i = 0; i < 3; i++) {+ const result = await expectUnitNotAborted(() => b.sync());+ expect(result.failedFiles).toBe(1);+ expect({ file: b.file(), body: await b.body(), title: (await b.engine.getPage(BAD, { sourceId: SOURCE }))!.title })+ .toEqual({ file: edited, ...before });+ }+ const hold = readGoogleState(b.root).item_holds as { items: Record<string, { code: string; state: string }> };+ expect(hold.items['contact:people/c1']).toMatchObject({ code: 'file_database_drift', state: 'held' });+ expect(await b.body(GOOD)).toContain('Upstream 1');+ });+ }, 180_000);+test('late file edit: comparison preimage is checked again immediately before rename', async () => {await withSource(databaseUrl, async b => {const old = await b.body();