Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(synthesize): a terminal or unmatchable postprocess request is a per-output conflict, and one output error no longer stops the pass (GBRA-130 A-4)
garrytanbb610490a038
diff --git a/src/core/cycle/synthesize-postprocess.ts b/src/core/cycle/synthesize-postprocess.tsindex 05f20f2c6a..9c8689b82d 100644--- a/src/core/cycle/synthesize-postprocess.ts+++ b/src/core/cycle/synthesize-postprocess.ts@@ -4,6 +4,7 @@ import { throwIfAborted } from '../abort-check.ts';import { parseMarkdown, serializePageToMarkdown } from '../markdown.ts';import type { Action } from '../agent-output.ts';import { opError } from '../ops/contract.ts';+import { ItemRun } from '../item-failure.ts';import { readFix } from '../ops/op-fix.ts';import { publicationHold } from '../persistence/accepted-pending.ts';import { authorizeStoredRequest } from '../persistence/authority.ts';@@ -12,7 +13,6 @@ import { getWriteRequest } from '../persistence/journal.ts';import { parseWriteRequestId } from '../persistence/preconditions.ts';import type { WriteRequest } from '../persistence/model.ts';import { maintenancePreflight, publishMaintenancePage, type MaintenanceAuthority } from '../persistence/prepared-maintenance.ts';-import { writeResponse } from '../persistence/service.ts';import type { PhaseResult } from '../cycle.ts';import type { DiscoveredTranscript } from './transcript-discovery.ts';import { transcriptDerivation } from './dream-taint.ts';@@ -26,8 +26,12 @@ import { DEFERRED_READ_LABEL, isPostprocessReadTimeout, pendingOutputsFor, readPinterface OutputRef { slug: string; source_id: string; raw_source?: string; seat?: string; first_write_at?: Date; }export interface RetainedOutput { job_id: number | bigint; job_key: string; input_slug: string; request: WriteRequest; }-/** #6360: a retained output a later non-maintenance write moved; it is left alone and reported once. */-export interface PostprocessConflict { slug: string; source_id: string; request_id: string; message: string; fix: Action; }+/**+ * An output postprocessing leaves alone for good and reports once (GBRA-130 A-4): a later non-maintenance write+ * moved its page (#6360, revision_conflict), its postprocess request ended without committing (the request's+ * error_code), or its retained request or carried provenance cannot be finished (recovery_required).+ */+export interface PostprocessConflict { slug: string; source_id: string; request_id: string; code: string; message: string; fix: Action; }export const POSTPROCESS_CONFLICTS_KEY = 'dream.synthesize.postprocess_conflicts';const CONFLICT_MEMORY_MS = 30 * 86_400_000;@@ -50,6 +54,8 @@ async function laterRequests(engine: BrainEngine, output: WriteRequest): Promiseconst localMaintenance = (r: WriteRequest) => r.operation === 'submit_job' && r.intent?.kind === 'managed_maintenance_page' && r.authority?.remote === false;const writerStatusFix = (sourceId: string, why: string): Action => readFix(why, { argv: ['gbrain', 'sources', 'writer', 'status', '--source', sourceId, '--json'] });+const receiptFix = (requestId: string): Action => readFix(`Reads postprocess request ${requestId}'s durable receipt: its state, recorded error and retained intent, read-only.`,+ { argv: ['gbrain', 'write-request', '--', requestId] });/** The slug submitPageMutation journals for a client slug: it lowercases it (page-mutations.ts). */export const journaledPageSlug = (slug: string): string => slug.toLowerCase();@@ -206,7 +212,7 @@ export async function postprocessManagedSynthesis(if (transcript === undefined) { carry.push(p); pending++; continue; }if (!output || !transcript) {settled.push(p.request_id);- if (!reported.has(p.request_id)) conflicts.push({ slug: p.slug, source_id: sourceId, request_id: p.request_id,+ if (!reported.has(p.request_id)) conflicts.push({ slug: p.slug, source_id: sourceId, request_id: p.request_id, code: 'recovery_required',message: `Deferred synthesis output ${p.slug} in source ${sourceId} ${output ? `lost its transcript ${p.raw_source}` : `has no committed journal row for child request ${p.request_id}`}, so postprocessing left it alone and did not verify or stamp it. Review the page; this output is not retried.`,fix: writerStatusFix(sourceId, `Shows source ${sourceId}'s committed and pending maintenance requests, read-only.`) });continue;@@ -227,8 +233,9 @@ export async function postprocessManagedSynthesis(}};let grounded: GroundedSource | undefined;- for (const [index, { ref, output, path, transcript, hash }] of items.entries()) {- throwIfAborted(opts.signal, '[dream] synthesis postprocessing');+ const run = new ItemRun('synthesize.postprocess');+ let itemError: unknown;+ const postprocessOne = async (index: number, { ref, output, path, transcript, hash }: Item): Promise<'stop' | void> => {if (ref.source_id !== authority.writer.sourceId) {throw opError('source_changed', 'The synthesis output source changed.',`Synthesis output ${ref.slug} belongs to source ${ref.source_id}, not ${authority.writer.sourceId} that this dream cycle writes, so it was not postprocessed. Check source ${authority.writer.sourceId}'s writer status, then run gbrain dream --phase synthesize --source ${authority.writer.sourceId} again.`,@@ -251,7 +258,7 @@ export async function postprocessManagedSynthesis(let base = revision;let requestId = postprocessId(base);let prior = await readPrior(index, requestId);- if (prior === undefined) break;+ if (prior === undefined) return 'stop';let snapshot: Awaited<ReturnType<BrainEngine['readPageSnapshot']>> = null;if (!prior) {snapshot = await engine.readPageSnapshot(ref.slug, { sourceId: ref.source_id });@@ -263,31 +270,40 @@ export async function postprocessManagedSynthesis(base = ours.intent!.expected_revision as string;requestId = ours.request_id;prior = await readPrior(index, requestId);- if (prior === undefined) break;+ if (prior === undefined) return 'stop';} else if (snapshot && later.filter(r => r.state === 'committed').every(localMaintenance) && sameBody(output.request.intent?.content, snapshot.page, ref.slug)) {base = snapshot.revision;requestId = postprocessId(base);} else {settled.push(outputRequestId);- if (!reported.has(requestId)) conflicts.push({ slug: ref.slug, source_id: ref.source_id, request_id: requestId,+ if (!reported.has(requestId)) conflicts.push({ slug: ref.slug, source_id: ref.source_id, request_id: requestId, code: 'revision_conflict',message: `Page ${ref.slug} in source ${ref.source_id} changed after the synthesis child committed revision ${revision}, so postprocessing left it alone and did not verify or stamp it. Review the page; this output is not retried.`,fix: readFix(`Shows page ${ref.slug} as it is now, read-only.`, { argv: ['gbrain', 'get', '--source', ref.source_id, '--', ref.slug] }) });- continue;+ return;}}}if (prior) {await authorizeStoredRequest(engine, prior);- if (prior.state === 'committed') { settled.push(outputRequestId); finalizedRefs.push(finalizedRef); continue; }- if (['conflict', 'failed', 'cancelled'].includes(prior.state)) writeResponse(prior);+ if (prior.state === 'committed') { settled.push(outputRequestId); finalizedRefs.push(finalizedRef); return; }+ if (['conflict', 'failed', 'cancelled'].includes(prior.state)) {+ settled.push(outputRequestId);+ const code = prior.error_code ?? prior.state;+ if (!reported.has(prior.request_id)) conflicts.push({ slug: ref.slug, source_id: ref.source_id, request_id: prior.request_id, code,+ message: `Postprocess request ${prior.request_id} for page ${ref.slug} in source ${ref.source_id} ended ${prior.state} (${code}) without committing, so postprocessing left the page alone and did not verify or stamp it. Read the request's receipt for the cause; this output is not retried.`,+ fix: receiptFix(prior.request_id) });+ return;+ }}await authorizeStoredRequest(engine, output.request);let content: string;if (prior) {if (prior.intent?.kind !== 'managed_maintenance_page' || prior.intent.expected_revision !== base || typeof prior.intent.content !== 'string') {- throw opError('recovery_required', 'The retained synthesis postprocessing intent is unavailable.',- `Postprocess request ${prior.request_id} for ${ref.slug} in source ${ref.source_id} exists, but its retained intent does not match revision ${base}. Inspect it in writer status; do not resubmit under a new request.`,- { fix: writerStatusFix(ref.source_id, `Shows request ${prior.request_id} and any recovery it holds, read-only.`) });+ settled.push(outputRequestId);+ if (!reported.has(prior.request_id)) conflicts.push({ slug: ref.slug, source_id: ref.source_id, request_id: prior.request_id, code: 'recovery_required',+ message: `Postprocess request ${prior.request_id} for page ${ref.slug} in source ${ref.source_id} exists, but its retained intent does not match revision ${base}, so postprocessing left the page alone and did not verify or stamp it. Read the request's receipt; do not resubmit it under a new request. This output is not retried.`,+ fix: receiptFix(prior.request_id) });+ return;}content = prior.intent.content;} else {@@ -322,16 +338,28 @@ export async function postprocessManagedSynthesis(// #6757: carried too, so the same request finishes even after the transcript grows or the child's rows are pruned.carry.push(...pendingOf(items[index]!));pending++;- continue;+ return;}settled.push(outputRequestId);writtenRefs.push(finalizedRef);finalizedRefs.push(finalizedRef);await new Promise(resolve => setTimeout(resolve, 0));+ };+ for (const [index, item] of items.entries()) {+ throwIfAborted(opts.signal, '[dream] synthesis postprocessing');+ try {+ if (await postprocessOne(index, item) === 'stop') break;+ run.succeed();+ } catch (error) {+ throwIfAborted(opts.signal, '[dream] synthesis postprocessing');+ run.fail(item.ref.slug, error);+ itemError ??= error;+ }}if (deferred?.read === 'postprocess_request') pending += items.length - readsFrom;if (conflicts.length) await rememberConflicts(engine, reported, conflicts);const deferral = await recordPostprocessPass(engine, sourceId, sourceIncarnation, { settled, carry, deferred });+ if (itemError) throw itemError;return { writtenRefs, finalizedRefs, stats, pending, conflicts, deferral };}@@ -350,14 +378,14 @@ async function rememberConflicts(engine: BrainEngine, reported: Map<string, stri}/**- * #6360: outputs a later non-maintenance write moved are terminal (retrying- * cannot help), so the phase warns once per output instead of failing every- * cycle, and the cooldown still stamps.+ * #6360, GBRA-130 A-4: postprocess conflicts are terminal (retrying cannot+ * help), so the phase warns once per output, naming each page and its code,+ * instead of failing every cycle, and the cooldown still stamps.*/export function withPostprocessConflicts(conflicts: PostprocessConflict[], result: PhaseResult): PhaseResult {if (!conflicts.length) return result;return { ...result, status: result.status === 'fail' ? 'fail' : 'warn',- summary: `${result.summary}; ${conflicts.length} output page(s) changed after the child committed and were left alone`,+ summary: `${result.summary}; ${conflicts.length} output page(s) left alone, not verified or stamped: ${conflicts.map(c => `${c.slug} (${c.code})`).join(', ')}`,details: { ...result.details, postprocess_conflicts: conflicts } };}diff --git a/test/pathological/a4-synthesize-postprocess.test.ts b/test/pathological/a4-synthesize-postprocess.test.tsnew file mode 100644index 0000000000..46387a8e62--- /dev/null+++ b/test/pathological/a4-synthesize-postprocess.test.ts@@ -0,0 +1,213 @@+/**+ * GBRA-130 A-4: a managed synthesis output whose postprocess publish was deferred (#5854/#6757) is carried in+ * `dream.synthesize.postprocess_pending`; when its request later ends without committing (a user edit before the+ * coordinator publishes ends it `revision_conflict`), or its retained intent no longer matches, the output is a+ * per-output conflict that is reported once and dropped, and every other output still finishes in the same pass.+ *+ * Authoring gate:+ * 1. Protects: a terminal postprocess request never fails the synthesize phase on every pass (which withholds the+ * global-maintenance stamp); one output's error never stops the outputs after it; run-scoped errors still stop.+ * 2. Regression: rethrowing the terminal receipt (`writeResponse(prior)`), throwing `recovery_required` for a+ * mismatched intent, or letting one output's error leave the loop before `recordPostprocessPass`.+ * 3. test/managed-synthesis-postprocess.test.ts covers a page moved after the child commit (#6360), not a request+ * that was carried and then ended terminal, and never two outputs in one pass with one failing.+ * 4. No production seam: the bad states are journal rows edited directly; other errors are injected by spying the+ * journal read the loop already makes.+ */+import { afterAll, beforeAll, describe, expect, spyOn, test } from 'bun:test';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import type { BrainEngine } from '../../src/core/engine.ts';+import type { PhaseResult } from '../../src/core/cycle.ts';+import { PGLiteEngine } from '../../src/core/pglite-engine.ts';+import { runPhaseSynthesize } from '../../src/core/cycle/synthesize.ts';+import { POSTPROCESS_CONFLICTS_KEY } from '../../src/core/cycle/synthesize-postprocess.ts';+import { POSTPROCESS_PENDING_KEY } from '../../src/core/cycle/synthesize-postprocess-deferral.ts';+import * as journal from '../../src/core/persistence/journal.ts';+import { __setMaintenanceWriteWaitForTests } from '../../src/core/persistence/maintenance-wait.ts';+import { acquireWorktree, getWorktreeBinding } from '../../src/core/persistence/ownership.ts';+import { disposePersistenceConsumer } from '../../src/core/persistence/service.ts';+import { configureGateway, resetGateway } from '../../src/core/ai/gateway.ts';+import { childCommittedOrdinaryCycle, managedSynthesisFixture, type SynthesisFixture } from '../helpers/managed-synthesis-fixture.ts';+import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';+import { editRequest } from '../helpers/persistence-request-fixture.ts';+import { expectItemFailure, expectOthersUnchanged, expectUnitNotAborted, pathologicalArms, runScopedErrors, snapshotItems } from './harness.ts';++type Ordinary = Parameters<typeof runPhaseSynthesize>[1];+interface OutputRequest { id: string; request_id: string; slug: string }++const outputRequests = (engine: BrainEngine, sourceId: string) => engine.executeRaw<OutputRequest>(+ "SELECT id::text, request_id::text, slug FROM persistence_requests WHERE source_id=$1 AND intent->>'kind'='managed_maintenance_page' ORDER BY slug", [sourceId]);+const pendingEntry = async (engine: BrainEngine, sourceId: string) =>+ (JSON.parse(await engine.getConfig(POSTPROCESS_PENDING_KEY) ?? '{}') as Record<string, { pending: Array<{ slug: string }> } | undefined>)[sourceId];+const outputSlugs = async (engine: BrainEngine, sourceId: string) => (await engine.executeRaw<{ slug: string }>(+ "SELECT slug FROM pages WHERE source_id=$1 AND slug LIKE 'wiki/personal/reflections/session%' ORDER BY slug", [sourceId])).map(r => r.slug);+const summaries = (snapshot: Map<string, unknown>) => [...snapshot.keys()].filter(slug => slug.startsWith('dream-cycle-summaries/'));++/** Runs one pass while the source's worktree is held, so every postprocess publish waits 300 ms and is carried. */+async function underHeldWorktree(engine: BrainEngine, sourceId: string, run: () => Promise<PhaseResult>): Promise<PhaseResult> {+ const lock = (await acquireWorktree((await getWorktreeBinding(engine, sourceId))!, 1000))!;+ __setMaintenanceWriteWaitForTests(300);+ try { return await run(); }+ finally { __setMaintenanceWriteWaitForTests(null); await disposePersistenceConsumer(engine); await lock.release(); }+}++/** Two child outputs committed; their postprocess publishes are deferred and carried. */+async function carriedOutputs(f: SynthesisFixture): Promise<{ ordinary: Ordinary; requests: OutputRequest[] }> {+ const { engine, sourceId } = f;+ const { ordinary } = await childCommittedOrdinaryCycle(f);+ const deferred = await underHeldWorktree(engine, sourceId, () => runPhaseSynthesize(engine, ordinary));+ expect(deferred.status, deferred.summary).toBe('warn');+ expect(deferred.details.publish_pending).toBe(2);+ const requests = await outputRequests(engine, sourceId);+ expect(requests.length).toBe(2);+ expect((await pendingEntry(engine, sourceId))?.pending.map(p => p.slug).sort()).toEqual(requests.map(r => r.slug));+ return { ordinary, requests };+}++/** The coordinator ended the output's postprocess request without committing it, as a user edit before publication does. */+const endInConflict = (engine: BrainEngine, request: OutputRequest) => editRequest(engine, request.id,+ "state='conflict',error_code='revision_conflict',error_message='The target changed since it was read.',execution_token=NULL,claim_expires_at=NULL,completed_at=now()");++for (const arm of pathologicalArms()) {+ describe(`A-4 synthesize postprocess (${arm.backend})`, () => {+ let engine: BrainEngine;+ let close: () => Promise<void>;+ beforeAll(async () => {+ configureGateway({ embedding_model: 'openai:text-embedding-3-large', embedding_dimensions: 1536, env: {} });+ if (arm.backend === 'pglite') {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-a4-'));+ const pglite = new PGLiteEngine();+ await pglite.connect({ database_path: dir });+ await pglite.initSchema();+ engine = pglite;+ close = async () => { await pglite.disconnect(); rmSync(dir, { recursive: true, force: true }); };+ } else {+ const pg = await isolatedPersistencePostgres(arm.databaseUrl!);+ engine = pg.engine;+ close = pg.close;+ }+ }, 120_000);+ afterAll(async () => { await disposePersistenceConsumer(engine); await close(); resetGateway(); });+ const fixture = (run: (f: SynthesisFixture) => Promise<void>, outputs = 2) => managedSynthesisFixture([engine], run, outputs);++ test('A-4 item: a carried output whose postprocess request ended revision_conflict is reported and dropped while the other carried output lands', async () => {+ await fixture(async f => {+ const { sourceId, calls } = f;+ const { ordinary, requests: [bad, healthy] } = await carriedOutputs(f);+ await endInConflict(engine, bad!);+ const spent = calls();+ const before = await snapshotItems(engine, sourceId);+ const result = await expectUnitNotAborted(() => runPhaseSynthesize(engine, ordinary));+ expect(result.status, result.summary).toBe('warn');+ expect(result.summary).toContain(bad!.slug);+ const conflicts = (result.details.postprocess_conflicts ?? []) as Array<{ slug: string; code: string; fix: { argv: string[] } }>;+ expect(conflicts.length).toBe(1);+ expectItemFailure({ key: conflicts[0]!.slug, code: conflicts[0]!.code, fix: conflicts[0]!.fix.argv.join(' ') },+ { key: bad!.slug, code: 'revision_conflict', fix: new RegExp(`^gbrain write-request -- ${bad!.request_id}$`) });+ const after = await snapshotItems(engine, sourceId);+ expectOthersUnchanged(before, after, { changed: summaries(after), expectProgress: [healthy!.slug] });+ expect(result.details.written_slugs).toEqual([healthy!.slug]);+ expect(await pendingEntry(engine, sourceId)).toBeUndefined();+ expect(calls()).toBe(spent);+ const again = await runPhaseSynthesize(engine, ordinary);+ expect(again.status, again.summary).toBe('ok');+ expect(again.details.postprocess_conflicts).toBeUndefined();+ });+ }, 180_000);++ test('A-4 item: a carried output whose retained postprocess intent no longer matches is reported recovery_required and dropped', async () => {+ await fixture(async f => {+ const { sourceId } = f;+ const { ordinary, requests: [bad, healthy] } = await carriedOutputs(f);+ await editRequest(engine, bad!.id, "intent=jsonb_set(intent,'{expected_revision}',to_jsonb('mismatched-revision'::text))");+ const before = await snapshotItems(engine, sourceId);+ const result = await expectUnitNotAborted(() => underHeldWorktree(engine, sourceId, () => runPhaseSynthesize(engine, ordinary)));+ expect(result.status, result.summary).toBe('warn');+ const conflicts = (result.details.postprocess_conflicts ?? []) as Array<{ slug: string; code: string; fix: { argv: string[] } }>;+ expectItemFailure(conflicts[0] && { key: conflicts[0].slug, code: conflicts[0].code, fix: conflicts[0].fix.argv.join(' ') },+ { key: bad!.slug, code: 'recovery_required', fix: new RegExp(`^gbrain write-request -- ${bad!.request_id}$`) });+ expect(result.details.publish_pending).toBe(1);+ expect((await pendingEntry(engine, sourceId))?.pending.map(p => p.slug)).toEqual([healthy!.slug]);+ const after = await snapshotItems(engine, sourceId);+ expectOthersUnchanged(before, after, { changed: summaries(after) });+ });+ }, 180_000);++ test('A-4 run: a run-scoped error while reading a carried output stops the pass and records nothing', async () => {+ await fixture(async f => {+ const { sourceId } = f;+ const { ordinary, requests } = await carriedOutputs(f);+ await endInConflict(engine, requests[0]!);+ const pendingBefore = await engine.getConfig(POSTPROCESS_PENDING_KEY);+ const conflictsBefore = await engine.getConfig(POSTPROCESS_CONFLICTS_KEY);+ const before = await snapshotItems(engine, sourceId);+ const read = journal.getWriteRequest;+ for (const { name, error } of runScopedErrors()) {+ let injected = 0;+ const spy = spyOn(journal, 'getWriteRequest').mockImplementation(async (...args) => {+ if (!injected++) throw error();+ return read(...args);+ });+ let outcome: { status?: string; thrown?: string };+ try {+ const result = await runPhaseSynthesize(engine, ordinary);+ outcome = { status: result.status };+ } catch (e) { outcome = { thrown: e instanceof Error ? e.name : String(e) }; }+ finally { spy.mockRestore(); await disposePersistenceConsumer(engine); }+ expect({ name, injected: injected > 0, stopped: outcome.thrown !== undefined || outcome.status === 'fail' }).toEqual({ name, injected: true, stopped: true });+ expect({ name, pending: await engine.getConfig(POSTPROCESS_PENDING_KEY) }).toEqual({ name, pending: pendingBefore });+ expect({ name, conflicts: await engine.getConfig(POSTPROCESS_CONFLICTS_KEY) }).toEqual({ name, conflicts: conflictsBefore });+ expectOthersUnchanged(before, await snapshotItems(engine, sourceId));+ }+ });+ }, 240_000);++ test('A-4 breaker: when every output fails the pass stops item_failures_systemic and carries or reports nothing', async () => {+ await fixture(async f => {+ const { sourceId } = f;+ const { ordinary } = await childCommittedOrdinaryCycle(f);+ const before = await snapshotItems(engine, sourceId);+ const conflictsBefore = await engine.getConfig(POSTPROCESS_CONFLICTS_KEY);+ const spy = spyOn(journal, 'getWriteRequest').mockImplementation(async () => { throw new TypeError('synthetic postprocess read failure'); });+ let result: PhaseResult;+ try { result = await runPhaseSynthesize(engine, ordinary); } finally { spy.mockRestore(); await disposePersistenceConsumer(engine); }+ expect(result.status).toBe('fail');+ expect(result.details.error_code).toBe('item_failures_systemic');+ expect(await pendingEntry(engine, sourceId)).toBeUndefined();+ expect(await engine.getConfig(POSTPROCESS_CONFLICTS_KEY)).toBe(conflictsBefore);+ expectOthersUnchanged(before, await snapshotItems(engine, sourceId));+ }, 5);+ }, 240_000);++ test('A-4 recovery: an output whose postprocess failed transiently does not stop the next output, and the next pass retries it and it lands', async () => {+ await fixture(async f => {+ const { sourceId, calls } = f;+ const { ordinary } = await childCommittedOrdinaryCycle(f);+ const [first, second] = await outputSlugs(engine, sourceId);+ const spent = calls();+ const before = await snapshotItems(engine, sourceId);+ const read = journal.getWriteRequest;+ let hits = 0;+ const spy = spyOn(journal, 'getWriteRequest').mockImplementation(async (...args) => {+ if (!hits++) throw new TypeError('synthetic postprocess read failure');+ return read(...args);+ });+ let failed: PhaseResult;+ try { failed = await runPhaseSynthesize(engine, ordinary); } finally { spy.mockRestore(); await disposePersistenceConsumer(engine); }+ expect(failed.status).toBe('fail');+ expect(failed.error?.message).toContain('synthetic postprocess read failure');+ const mid = await snapshotItems(engine, sourceId);+ expect(mid.get(first!)).toEqual(before.get(first!));+ expectOthersUnchanged(before, mid, { changed: summaries(mid), expectProgress: [second!] });+ const next = await runPhaseSynthesize(engine, ordinary);+ expect(next.status, next.summary).toBe('ok');+ expect(next.details.written_slugs).toEqual([first]);+ const after = await snapshotItems(engine, sourceId);+ expectOthersUnchanged(mid, after, { changed: summaries(after), expectProgress: [first!] });+ expect(calls()).toBe(spent);+ });+ }, 240_000);+ });+}