Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(concepts): a rehashed legacy concept keeps one Takes and Facts section
time-attack080c27869be8
diff --git a/src/core/cycle/synthesize-concepts.ts b/src/core/cycle/synthesize-concepts.tsindex 5664cb074e..e0d4df87cd 100644--- a/src/core/cycle/synthesize-concepts.ts+++ b/src/core/cycle/synthesize-concepts.ts@@ -358,7 +358,7 @@ export async function runPhaseSynthesizeConcepts(let synthesisMode: ConceptSynthesisMode;let fallbackWriter: string | undefined;if (grandfathered) {- narrative = existing!.compiled_truth;+ narrative = stripFenceSections(existing!.compiled_truth);synthesisMode = priorMode as ConceptSynthesisMode;rehashed.push(conceptSlug);} else if (group.tier === 'T1' || group.tier === 'T2') {diff --git a/test/cycle/synthesize-concepts-fences.test.ts b/test/cycle/synthesize-concepts-fences.test.tsindex 6c4bfdc8ae..3af76bcae5 100644--- a/test/cycle/synthesize-concepts-fences.test.ts+++ b/test/cycle/synthesize-concepts-fences.test.ts@@ -86,11 +86,11 @@ describe('pre-fix member hashes (D-N3 grandfathering)', () => {const legacyHash = (input: Atom[]) => createHash('sha256').update(JSON.stringify([MODEL, 'world', input.map((a) => [a.slug, a.title, a.body]).sort((x, y) => x[0].localeCompare(y[0]))])).digest('hex').slice(0, 16);- const seedLegacy = async (hash: string) => {+ const seedLegacy = async (hash: string, body = 'Legacy narrative.') => {await importFromContent(engine, 'concepts/flywheel', serializeMarkdown({tier: 'T2', synthesis_mode: 'llm', member_hash: hash, synthesized_at: '2026-01-01T00:00:00.000Z',synthesized_by: 'synthesize_concepts-v0.41', visibility: 'world',- }, 'Legacy narrative.', '', { type: 'concept', title: 'flywheel', tags: [] }), { noEmbed: true, sourceId: 'default' });+ }, body, '', { type: 'concept', title: 'flywheel', tags: [] }), { noEmbed: true, sourceId: 'default' });};test('unchanged inputs are rehashed without a model call and keep the narrative', async () => {@@ -107,6 +107,19 @@ describe('pre-fix member hashes (D-N3 grandfathering)', () => {expect(calls.n).toBe(0);}, 120000);+ test('a rehashed concept with a takes fence keeps one Takes section', async () => {+ const fenced = atoms().map((a, i) => (i === 0 ? { ...a, body: withTake(a.body) } : a));+ await seedLegacy(legacyHash(fenced), withTake('Legacy narrative.'));+ const calls = { n: 0 };+ const r = await run(fenced, calls);+ expect(calls.n).toBe(0);+ expect((r.details as Record<string, unknown>).rehashed).toEqual(['concepts/flywheel']);+ const page = await concept();+ expect(page!.compiled_truth.match(/^## Takes\s*$/gm)).toHaveLength(1);+ expect(parseTakesFence(page!.compiled_truth).takes.map((t) => t.claim)).toEqual(['Flywheels compound']);+ expect(page!.compiled_truth).toContain('Legacy narrative.');+ }, 120000);+test('changed inputs under a legacy hash re-synthesize', async () => {await seedLegacy(legacyHash(atoms()));const calls = { n: 0 };