Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: stamp synthesize fixtures with their source and claim the solo brain's worktree (#7805)

garrytandf90a7e7d295
diff --git a/test/managed-maintenance.test.ts b/test/managed-maintenance.test.ts
index 75ca8f382c..735e6981c8 100644
--- a/test/managed-maintenance.test.ts
+++ b/test/managed-maintenance.test.ts
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
+import { ensureCorpusSpoolDir, sessionCorpusFileName } from '../src/core/context/corpus-segments.ts';
import type { BrainEngine } from '../src/core/engine.ts';
import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { runPhaseConsolidate } from '../src/core/cycle/phases/consolidate.ts';
@@ -438,7 +439,7 @@ for (const failure of ['commit', 'withdrawal'] as const) {
test('managed synthesis drives real children and publishes repaired provenance plus summary without repeated model calls', async () => {
await fixture(async (engine, sourceId, root) => {
await seed(engine, sourceId);
- const transcript = join(root, '2026-09-20-session.txt');
+ const transcript = join(ensureCorpusSpoolDir(root), sessionCorpusFileName('2026-09-20-session', sourceId));
const quote = 'we charge for durability because reliable memories should survive every tool';
writeFileSync(transcript, `User: ${quote}.\n${'Assistant: Discuss the long term roadmap.\n'.repeat(15)}`);
await engine.setConfig('dream.synthesize.enabled', 'true');
diff --git a/test/managed-phase-matrix.test.ts b/test/managed-phase-matrix.test.ts
index e086c3c45c..dfb18d7ed1 100644
--- a/test/managed-phase-matrix.test.ts
+++ b/test/managed-phase-matrix.test.ts
@@ -22,6 +22,7 @@ import { execFileSync } from 'node:child_process';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
+import { ensureCorpusSpoolDir, sessionCorpusFileName } from '../src/core/context/corpus-segments.ts';
import type { BrainEngine } from '../src/core/engine.ts';
import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { ALL_PHASES, runCycle, type CycleOpts, type CyclePhase, type PhaseResult } from '../src/core/cycle.ts';
@@ -179,7 +180,7 @@ const MATRIX: Record<CyclePhase, Entry> = {
synthesize: {
seed: async ({ engine, sourceId, root }) => {
await put(engine, sourceId, 'people/example', page('note', 'Example', 'Example evidence.'));
- writeFileSync(join(root, '2026-09-20-session.txt'), `User: we charge for durability because reliable memories should survive every tool.\n${'Assistant: Discuss the long term roadmap.\n'.repeat(15)}`);
+ writeFileSync(join(ensureCorpusSpoolDir(root), sessionCorpusFileName('2026-09-20-session', sourceId)), `User: we charge for durability because reliable memories should survive every tool.\n${'Assistant: Discuss the long term roadmap.\n'.repeat(15)}`);
},
config: { 'dream.synthesize.enabled': 'true', 'dream.synthesize.cooldown_hours': '0', 'dream.synthesize.min_chars': '100',
'dream.synthesize.link_manifest': 'false', 'dream.synthesize.mode': 'oneshot', 'models.dream.synthesize': 'anthropic:claude-sonnet-4-6',
diff --git a/test/pathological/g4-synthesis-resynthesis-7065.test.ts b/test/pathological/g4-synthesis-resynthesis-7065.test.ts
index 0fd3401011..53f330a69d 100644
--- a/test/pathological/g4-synthesis-resynthesis-7065.test.ts
+++ b/test/pathological/g4-synthesis-resynthesis-7065.test.ts
@@ -10,6 +10,7 @@ import { randomUUID } from 'node:crypto';
import { appendFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
+import { ensureCorpusSpoolDir, sessionCorpusFileName } from '../../src/core/context/corpus-segments.ts';
import type { BrainEngine } from '../../src/core/engine.ts';
import { PGLiteEngine } from '../../src/core/pglite-engine.ts';
import { runPhaseSynthesize } from '../../src/core/cycle/synthesize.ts';
@@ -66,8 +67,8 @@ async function fixture(managed: boolean, run: (f: Fixture) => Promise<void>) {
for (const engine of engines) {
const dir = mkdtempSync(join(tmpdir(), 'gbrain-g4-resynth-'));
const f: Fixture = { engine, sourceId: `resynth-${randomUUID().slice(0, 8)}`, root: join(dir, 'brain'), corpus: join(dir, 'corpus'), transcript: '', managed };
- f.transcript = join(f.corpus, 'sess-a.txt');
for (const path of [f.root, f.corpus]) mkdirSync(path);
+ f.transcript = join(ensureCorpusSpoolDir(f.corpus), sessionCorpusFileName('sess-a', f.sourceId));
writeFileSync(f.transcript, TRANSCRIPT);
try {
await withEnv({ GBRAIN_HOME: join(dir, 'home'), ANTHROPIC_API_KEY: 'sk-test-resynth' }, async () => {
diff --git a/test/pathological/g5-single-page-generations.test.ts b/test/pathological/g5-single-page-generations.test.ts
index a007f627ee..60315530db 100644
--- a/test/pathological/g5-single-page-generations.test.ts
+++ b/test/pathological/g5-single-page-generations.test.ts
@@ -9,6 +9,7 @@ import { randomUUID } from 'node:crypto';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
+import { ensureCorpusSpoolDir, sessionCorpusFileName } from '../../src/core/context/corpus-segments.ts';
import type { BrainEngine } from '../../src/core/engine.ts';
import { runThink, persistSynthesis, type ThinkLLMClient } from '../../src/core/think/index.ts';
import { runPhaseDrift } from '../../src/core/cycle/drift.ts';
@@ -91,7 +92,7 @@ async function synthesisRig(engine: BrainEngine, dir: string) {
'dream.synthesize.budget_usd': 'unlimited', 'models.dream.synthesize': 'anthropic:claude-sonnet-4-6', 'models.dream.triage': 'anthropic:claude-sonnet-4-6', 'agent.use_gateway_loop': 'true' })) await engine.setConfig(k, v);
const usage = { input_tokens: 1, output_tokens: 1, cache_read_tokens: 0, cache_creation_tokens: 0 };
const run = async (name: string, during?: () => Promise<void>) => {
- writeFileSync(join(corpus, `${name}.txt`), `[user]\nWe settled the storage plan for ${name}.\n\n${'[assistant]\nNoted.\n\n'.repeat(20)}`);
+ writeFileSync(join(ensureCorpusSpoolDir(corpus), sessionCorpusFileName(name, 'g5src')), `[user]\nWe settled the storage plan for ${name}.\n\n${'[assistant]\nNoted.\n\n'.repeat(20)}`);
__setChatTransportForTests(async opts => {
const mk = (text: string) => ({ text, blocks: [{ type: 'text', text }], stopReason: 'end', usage, model: opts.model!, providerId: 'anthropic' }) as never;
if ((opts.system ?? '').startsWith('You triage a conversation transcript')) return mk(JSON.stringify({ score: 0.9, content_type: 'reflection', segments: [], entities: [], reasons: ['durable'] }));
diff --git a/test/synthesize-session-source-7805.test.ts b/test/synthesize-session-source-7805.test.ts
index 4fe1d3cf0f..553ad63660 100644
--- a/test/synthesize-session-source-7805.test.ts
+++ b/test/synthesize-session-source-7805.test.ts
@@ -83,7 +83,7 @@ async function fixture(managed: boolean, run: (f: Fixture) => Promise<void>, sol
else await engine.executeRaw('INSERT INTO sources(id,name,local_path) VALUES($1,$1,$2)', [s.id, s.root]);
}
await engine.setConfig('sync.write_through', 'true');
- if (!solo) for (const s of sources) await claimWorktree(engine, s.id, s.root);
+ for (const s of sources) await claimWorktree(engine, s.id, s.root);
for (const [key, value] of Object.entries({
'dream.synthesize.enabled': 'true', 'dream.synthesize.cooldown_hours': '0',
'dream.synthesize.min_chars': '100', 'dream.synthesize.link_manifest': 'false',