Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(#6834): keep a page import slugged __managed_sync_checkpoint__ a page failure; move the new revival and doctor logic into sibling modules
garrytan528b5f63a785
diff --git a/src/commands/doctor/checks/extraction-sync.ts b/src/commands/doctor/checks/extraction-sync.tsindex e1972eea2e..9917e019de 100644--- a/src/commands/doctor/checks/extraction-sync.ts+++ b/src/commands/doctor/checks/extraction-sync.ts@@ -34,9 +34,8 @@ import { isOwnedContentSchemaMissing, ownedContentFreshness } from '../../../corimport { readOnlyCatalogPackSourceIds } from '../../../core/shared-skills/adopted-packs.ts';import { connectorAuthorities } from '../../../core/persistence/connector-authority.ts';import { parseSourceConfig } from '../../../core/sources-load.ts';-import { agentFix, checkError } from '../check-fix.ts';-import { classifyManagedSyncOrphans } from '../../../core/persistence/managed-sync-orphans.ts';-import { firstSyncRunning, noSuccessfulSync, stoppedConnectorIssues, type SyncOutcomeEntry } from '../sync-outcome.ts';+import { checkError } from '../check-fix.ts';+import { checkpointMovedFix, firstSyncRunning, noSuccessfulSync, stoppedConnectorIssues, type SyncOutcomeEntry } from '../sync-outcome.ts';import { haltReasonsWithUnknown, readRecordedHaltReasons7d, topHaltReason } from '../../../core/extract/rollup-writer.ts';/** Local aliases; the shared warn-once memo lives in core so it can't fork per module. */@@ -1491,27 +1490,13 @@ export async function checkSyncFreshness(+ (read_only_pack_count ? `. ${read_only_pack_count} read-only skill-pack source(s): no commits to sync` : '') + (catalogPacks.note ? `. ${catalogPacks.note}` : '');const remedy = issues.length > outcomes.length;- // #6834: a stale managed source whose unfinished cursor no sync can publish (its checkpoint moved elsewhere) is retired, not re-synced.- const moved = managed && localOnly && staleIds.length ? (await classifyManagedSyncOrphans(engine, staleIds).catch(() => ({ orphans: [] }))).orphans- .filter(orphan => orphan.reason === 'checkpoint_moved') : [];- const movedFix = moved.length ? agentFix(['gbrain', 'repair', 'managed-sync-orphans', ...(new Set(moved.map(o => o.source_id)).size === 1 ? ['--source', moved[0]!.source_id] : [])],- `The unfinished sync of ${[...new Set(moved.map(o => o.source_id))].join(', ')} can never checkpoint (its source's last_commit moved outside the run), so a plain sync stays blocked. The preview lists the cursor and prints the apply command with its hash; writes nothing.`,- 'sync_freshness', { docs: 'docs/guides/repair.md#managed-sync-orphans' }) : undefined;- const outcomeFix = outcomes.find(o => o.code === 'sync_no_successful_sync')?.fix ?? outcomes[0]?.fix ?? movedFix;- const movedNote = movedFix ? `. ${movedFix.why} Run \`${movedFix.argv!.join(' ')}\`` : '';- if (hasFailures) {+ const moved = managed && localOnly && staleIds.length ? await checkpointMovedFix(engine, staleIds) : null;+ const outcomeFix = outcomes.find(o => o.code === 'sync_no_successful_sync')?.fix ?? outcomes[0]?.fix ?? moved?.fix;+ if (hasFailures || hasWarnings) {return {name: 'sync_freshness',- status: 'fail',- message: `${issues.join('; ')}${remedy ? `. Run \`gbrain sync --source <id>${managed ? ' --no-pull' : ''}\` for each stale source` : ''}${movedNote}${inProgressNote}`,- details, ...(outcomeFix ? { fix: outcomeFix } : {}),- };- }- if (hasWarnings) {- return {- name: 'sync_freshness',- status: 'warn',- message: `${issues.join('; ')}${remedy ? `. Run \`gbrain sync --source <id>${managed ? ' --no-pull' : ''}\` to refresh` : ''}${movedNote}${inProgressNote}`,+ status: hasFailures ? 'fail' : 'warn',+ message: `${issues.join('; ')}${remedy ? `. Run \`gbrain sync --source <id>${managed ? ' --no-pull' : ''}\` ${hasFailures ? 'for each stale source' : 'to refresh'}` : ''}${moved?.note ?? ''}${inProgressNote}`,details, ...(outcomeFix ? { fix: outcomeFix } : {}),};}diff --git a/src/commands/doctor/sync-outcome.ts b/src/commands/doctor/sync-outcome.tsindex 4d238e4ad2..90e486f2d6 100644--- a/src/commands/doctor/sync-outcome.ts+++ b/src/commands/doctor/sync-outcome.ts@@ -8,7 +8,8 @@import type { Action } from '../../core/agent-output.ts';import type { BrainEngine } from '../../core/engine.ts';import { readLastSyncAttempt, type SyncAttemptState } from '../../core/sync-attempt.ts';-import { doctorVerify } from './check-fix.ts';+import { classifyManagedSyncOrphans } from '../../core/persistence/managed-sync-orphans.ts';+import { agentFix, doctorVerify } from './check-fix.ts';export interface SyncOutcomeEntry {source_id: string;@@ -81,3 +82,18 @@ export async function stoppedConnectorIssues(engine: BrainEngine, sources: Array}return issues;}++/**+ * #6834: the fix for stale managed sources whose unfinished cursor no sync can publish (its checkpoint lost to a+ * `last_commit` that moved outside the run): `gbrain repair managed-sync-orphans` retires it, so the remedy is the+ * preview, not another sync. Null when none of them has a `checkpoint_moved` cursor or the read fails.+ */+export async function checkpointMovedFix(engine: BrainEngine, staleIds: string[]): Promise<{ fix: Action; note: string } | null> {+ const moved = (await classifyManagedSyncOrphans(engine, staleIds).catch(() => ({ orphans: [] }))).orphans.filter(orphan => orphan.reason === 'checkpoint_moved');+ if (!moved.length) return null;+ const ids = [...new Set(moved.map(orphan => orphan.source_id))];+ const fix = agentFix(['gbrain', 'repair', 'managed-sync-orphans', ...(ids.length === 1 ? ['--source', ids[0]!] : [])],+ `The unfinished sync of ${ids.join(', ')} can never checkpoint (its source's last_commit moved outside the run), so a plain sync stays blocked. The preview lists the cursor and prints the apply command with its hash; writes nothing.`,+ 'sync_freshness', { docs: 'docs/guides/repair.md#managed-sync-orphans' });+ return { fix, note: `. ${fix.why} Run \`${fix.argv!.join(' ')}\`` };+}diff --git a/src/core/persistence/sync-run.ts b/src/core/persistence/sync-run.tsindex b1dc2c185f..401d2f0a7a 100644--- a/src/core/persistence/sync-run.ts+++ b/src/core/persistence/sync-run.ts@@ -15,7 +15,7 @@ import { preparationConfigView } from './config-snapshot.ts';import { isWriteCapacityWait, retryWriteAdmission } from './admission-retry.ts';import { assertPersistenceAccepting, awaitWrite, foregroundWriteCompletions, startPersistenceConsumer } from './service.ts';import { assertSyncEntryOrigin, discoverManagedSync, resolveManagedSyncContext, readSyncFile, syncGit, type ManagedSyncContext, type SyncDiscovery } from './sync-discovery.ts';-import { checkpointMovedToTarget, slugModeCheckpointRevivable } from './sync-slug-mode.ts';+import { checkpointRevival } from './sync-slug-mode.ts';import { managedCursorKey, resolveManagedCursor } from './sync-cursor-key.ts';import { isImageFilePath, isMultimodalEnabled } from '../sync.ts';import { assertSyncPageOrigin, sameSyncOrigin, syncOriginScope } from './sync-origin.ts';@@ -799,17 +799,14 @@ const revivableCheckpointRefusal = (done: Pick<WriteRequest, 'state' | 'error_co* knock-on, a receipt at an index the cursor settled), a fresh checkpoint request replaces it by cursor swap, and its* publication validates everything again. The completed manifest and the old receipt stay as they are. Null when it* still blocks, or after `CHECKPOINT_REVIVAL_LIMIT` revivals in this invocation (the next invocation re-assesses).- * #6694: a checkpoint refused for its slug-root mode is revived the same way once the source admits it (sync-slug-mode.ts).- * #6834: a checkpoint refused because `last_commit` moved to exactly this run's target is revived marked overtaken.+ * #6694/#6834: a slug-mode refusal the source now admits, or a moved checkpoint at this run's target, revives too (sync-slug-mode.ts).*/async function reviveCheckpoint(engine: BrainEngine, input: SettleInput): Promise<Cursor | null> {const { cursor, key, pending, done } = input;- const checkpoint = pending.intent.kind === 'managed_sync_checkpoint';- const atTarget = checkpoint && await checkpointMovedToTarget(engine, cursor, pending.intent, done);- const refused = revivableCheckpointRefusal(done) || atTarget || (checkpoint && await slugModeCheckpointRevivable(engine, cursor, pending.intent, done));+ const refused = revivableCheckpointRefusal(done) || (pending.intent.kind === 'managed_sync_checkpoint' && await checkpointRevival(engine, cursor, pending.intent, done));const revivals = checkpointRevivalsByRun.get(input.run) ?? 0;- if (!checkpoint || !refused || done.recovery || cursor.index !== cursor.entries.length || revivals >= CHECKPOINT_REVIVAL_LIMIT) return null;- const base: Cursor = { ...withoutPending(cursor), ...(atTarget ? { overtaken: true as const } : {}) };+ if (pending.intent.kind !== 'managed_sync_checkpoint' || !refused || done.recovery || cursor.index !== cursor.entries.length || revivals >= CHECKPOINT_REVIVAL_LIMIT) return null;+ const base: Cursor = { ...withoutPending(cursor), ...(refused === 'overtaken' ? { overtaken: true as const } : {}) };const fresh = await freezeEntry(engine, base, key, input.assertActive, input.run);if (!('requestId' in fresh)) return null;const blocker = await findIncompleteSyncReceipt(engine, cursor.binding.worktree_id, cursor.runId, fresh.intent.supersededRequests ?? [], fresh.intent.settled ?? null);diff --git a/src/core/persistence/sync-slug-mode.ts b/src/core/persistence/sync-slug-mode.tsindex ba4c4bf0f0..c85791a2c1 100644--- a/src/core/persistence/sync-slug-mode.ts+++ b/src/core/persistence/sync-slug-mode.ts@@ -51,6 +51,19 @@ export async function checkpointMovedToTarget(engine: Pick<BrainEngine, 'executereturn !!row && row.last_commit === intent.target && row.last_commit !== intent.from;}+/**+ * Why a refused checkpoint can be revived: `'overtaken'` when `last_commit` moved to exactly the run's target+ * (`checkpointMovedToTarget`; the fresh checkpoint is marked overtaken), `'slug_mode'` when the source now admits its slug+ * mode (`slugModeCheckpointRevivable`), false when it still blocks.+ */+export async function checkpointRevival(engine: Pick<BrainEngine, 'executeRaw'>,+ cursor: { sourceId: string; incarnation: string; root: string; gitRoot: string },+ intent: { slugMode: SlugRootMode; from: string | null; target: string; slice?: { done?: boolean } },+ done: Pick<WriteRequest, 'state' | 'error_code' | 'error_message' | 'recovery'>): Promise<'overtaken' | 'slug_mode' | false> {+ if (await checkpointMovedToTarget(engine, cursor, intent, done)) return 'overtaken';+ return await slugModeCheckpointRevivable(engine, cursor, intent, done) ? 'slug_mode' : false;+}+/*** Whether a failed checkpoint was refused for its slug mode and the source now admits it: its `last_commit` is still* where the run started, and the pin is unset, equal to the run's mode, or the scope is empty. A legacydiff --git a/src/core/persistence/terminal-classify.ts b/src/core/persistence/terminal-classify.tsindex 8438ddd2de..5ee3864488 100644--- a/src/core/persistence/terminal-classify.ts+++ b/src/core/persistence/terminal-classify.ts@@ -319,7 +319,8 @@ export const PAGE_REMOVAL_OPERATIONS: readonly string[] = ['delete_page', 'purge* failed request `r` (both `persistence_requests` aliases): the same intent committed, failed or still pending; a later* page removal committed or pending; for a `put_page`, any later write committed or pending, or a later caller* `put_page` that failed (the newer content); #6834: for a refused sync checkpoint, any later committed checkpoint of the- * source. Literal strings only; NULL-safe for a compacted `c` (no intent).+ * source (both read by kind; a compacted row, which keeps no kind, by its operation). `r` must expose `id`.+ * Literal strings only; NULL-safe for a compacted `c` (no intent).*/export function supersessionSql(r: string, c: string): string {const removals = PAGE_REMOVAL_OPERATIONS.map(op => `'${op}'`).join(',');@@ -327,6 +328,7 @@ export function supersessionSql(r: string, c: string): string {(${c}.digest=${r}.digest AND ${c}.state IN ('committed','failed','queued','running','recovering'))OR (${c}.state IN ('committed','queued','running','recovering') AND (${c}.operation IN (${removals}) OR ${r}.operation='put_page'))OR (${r}.slug='__managed_sync_checkpoint__' AND ${r}.operation='submit_job' AND ${c}.state='committed' AND ${c}.operation='submit_job'+ AND COALESCE((SELECT k.intent->>'kind' FROM persistence_requests k WHERE k.id=${r}.id),'managed_sync_checkpoint')='managed_sync_checkpoint'AND COALESCE(${c}.intent->>'kind','managed_sync_checkpoint')='managed_sync_checkpoint')OR (${r}.operation='put_page' AND ${c}.state='failed' AND ${c}.operation='put_page' AND COALESCE(NOT (${c}.intent ? 'kind'), false))))`;}diff --git a/src/core/persistence/terminal-failures.ts b/src/core/persistence/terminal-failures.tsindex 44577879e4..96426df129 100644--- a/src/core/persistence/terminal-failures.ts+++ b/src/core/persistence/terminal-failures.ts@@ -81,7 +81,7 @@ const TERMINAL = (r: string) => `${r}.state IN ('failed','conflict','cancelled')/** A request holding a publication recovery record outside an in-flight claim: it blocks its root. `recovering` is the durable parked state (a blocked restore). */const RECOVERY = (r: string) => `(${r}.recovery IS NOT NULL AND ${r}.state IN ('committed','recovering','failed','conflict','cancelled'))`;-interface KeyColumns { source_id: string; state: string; error_code: string | null; origin: string | null; reason: string | null; cause: string | null; operation: string;+interface KeyColumns { source_id: string; state: string; error_code: string | null; origin: string | null; reason: string | null; cause: string | null; operation: string; intent_kind?: string | null;has_recovery: boolean; blocked_reason: string | null; compacted: boolean; knock_on: boolean; routed_message: string | null; build: string | null }function verdictOf(row: KeyColumns & { request_id?: string; slug?: string; error_detail?: Record<string, unknown> | null }): TerminalVerdict {@@ -89,7 +89,7 @@ function verdictOf(row: KeyColumns & { request_id?: string; slug?: string; error...(row.cause ? { cause: row.cause } : {}) } : null);return classifyTerminal({ request_id: row.request_id, source_id: row.source_id, slug: row.slug ?? '<slug>', operation: row.operation, state: row.state, error_code: row.error_code,error_detail: detail, recovery: row.has_recovery || null, blocked_reason: row.blocked_reason, compacted: row.compacted, knock_on: row.knock_on,- error_message: row.routed_message, build: row.build })!;+ error_message: row.routed_message, build: row.build, intent_kind: row.intent_kind ?? null })!;}async function bounded<T>(engine: BrainEngine, sql: string, params: unknown[]): Promise<T[] | 'unknown'> {@@ -129,7 +129,7 @@ export async function readTerminalFailureSummary(engine: BrainEngine, opts: { soconst rows = await bounded<KeyColumns & { set: number; resolved: boolean | null; rows: number; in_window: number; n_24h: number; oldest: string | null; oldest_age: number | null;distinct_slugs: number; distinct_intents: number; recovery_ids: string[] | null; recovery_slugs: string[] | null } & Record<string, number>>(engine,`WITH base AS (- SELECT r.id, r.request_id::text AS request_id, r.source_id, r.slug, r.digest, r.sequence, r.operation, r.state, r.error_code,+ SELECT r.id, r.request_id::text AS request_id, r.source_id, r.slug, r.digest, r.sequence, r.operation, r.intent->>'kind' AS intent_kind, r.state, r.error_code,r.error_detail->>'origin' AS origin, r.error_detail->>'reason' AS reason, r.error_detail->>'cause' AS cause,r.recovery IS NOT NULL AS has_recovery, r.blocked_reason, r.compacted, ${terminalKnockOnSql('r')} AS knock_on,${ROUTED_MESSAGE('r')} AS routed_message, ${BUILD('r')} AS build, ${ENDED('r')} AS ended_at@@ -142,7 +142,7 @@ export async function readTerminalFailureSummary(engine: BrainEngine, opts: { soSELECT b.*, (x.id IS NOT NULL) AS resolved, (b.has_recovery OR b.ended_at > now()-($3::int*interval '1 day')) AS in_window, ${HISTORICAL_BY_BUILD('b')} AS historical_buildFROM base b LEFT JOIN resolved x ON x.id=b.id)- SELECT GROUPING(state) AS set, source_id, state, error_code, origin, reason, cause, operation, has_recovery, blocked_reason, compacted, knock_on, routed_message, build, resolved,+ SELECT GROUPING(state) AS set, source_id, state, error_code, origin, reason, cause, operation, intent_kind, has_recovery, blocked_reason, compacted, knock_on, routed_message, build, resolved,count(*) FILTER (WHERE in_window)::int AS rows, count(*) FILTER (WHERE in_window)::int AS in_window,count(*) FILTER (WHERE state IN ('failed','conflict','cancelled') AND ended_at > now()-interval '1 day')::int AS n_24h,${days},@@ -153,7 +153,7 @@ export async function readTerminalFailureSummary(engine: BrainEngine, opts: { so(array_agg(request_id ORDER BY sequence) FILTER (WHERE has_recovery))[1:20] AS recovery_ids,(array_agg(slug ORDER BY sequence) FILTER (WHERE has_recovery))[1:20] AS recovery_slugsFROM tagged- GROUP BY GROUPING SETS ((source_id, state, error_code, origin, reason, cause, operation, has_recovery, blocked_reason, compacted, knock_on, routed_message, build, resolved), (source_id))+ GROUP BY GROUPING SETS ((source_id, state, error_code, origin, reason, cause, operation, intent_kind, has_recovery, blocked_reason, compacted, knock_on, routed_message, build, resolved), (source_id))ORDER BY source_id`, [span, opts.sourceIds ?? null, t.windowDays]);if (rows === 'unknown') return { status: 'unknown', window_days: t.windowDays, reason: `the aggregate did not finish within ${TERMINAL_STATEMENT_MS} ms (or no connection within ${TERMINAL_ACQUIRE_MS} ms)` };const bySource = new Map<string, TerminalSourceSummary>();@@ -294,7 +294,7 @@ export async function readTerminalFailures(engine: BrainEngine, q: TerminalFailuconst want = q.groupBy ? MAX_SCAN : limit + 1;while (out.length < want && scanned < MAX_SCAN && !exhausted) {const batch = await bounded<KeyColumns & { request_id: string; sequence: string; slug: string; error_detail: Record<string, unknown> | null; ended_at: string; later_state: string | null; same_intent: boolean | null }>(engine,- `SELECT r.request_id::text AS request_id, r.sequence::text AS sequence, r.source_id, r.slug, r.operation, r.state, r.error_code, r.error_detail,+ `SELECT r.request_id::text AS request_id, r.sequence::text AS sequence, r.source_id, r.slug, r.operation, r.intent->>'kind' AS intent_kind, r.state, r.error_code, r.error_detail,r.error_detail->>'origin' AS origin, r.error_detail->>'reason' AS reason, r.error_detail->>'cause' AS cause,r.recovery IS NOT NULL AS has_recovery, r.blocked_reason, r.compacted, ${terminalKnockOnSql('r')} AS knock_on, ${ROUTED_MESSAGE('r')} AS routed_message, ${BUILD('r')} AS build,to_char(${ENDED('r')} AT TIME ZONE 'UTC','YYYY-MM-DD"T"HH24:MI:SS"Z"') AS ended_at, later.state AS later_state, later.same_intentdiff --git a/test/sync-checkpoint-moved-6834.test.ts b/test/sync-checkpoint-moved-6834.test.tsindex 8a20666827..24b6f6ea84 100644--- a/test/sync-checkpoint-moved-6834.test.ts+++ b/test/sync-checkpoint-moved-6834.test.ts@@ -37,6 +37,7 @@ import { readManagedSyncFailures } from '../src/core/persistence/sync-failures.timport { classifyManagedSyncOrphans } from '../src/core/persistence/managed-sync-orphans.ts';import { readSyncStatus } from '../src/core/persistence/sync-status.ts';import { classifyTerminal, supersessionSql } from '../src/core/persistence/terminal-classify.ts';+import { readTerminalFailures, readTerminalFailureSummary } from '../src/core/persistence/terminal-failures.ts';import { writeFailureDiagnostic } from '../src/core/persistence/verb-errors.ts';import { checkSyncFailures } from '../src/commands/doctor/checks/sync-failures.ts';import { checkSyncFreshness } from '../src/commands/doctor/checks/extraction-sync.ts';@@ -306,11 +307,11 @@ describe('#6834 a managed-sync checkpoint whose source checkpoint moved', () =>action: { argv: ['gbrain', 'get', '--source', 'example-source', '--', '__managed_sync_checkpoint__'] } });}const later = async (r: { operation: string }, c: { operation: string; kind: string | null }) => (await engine.executeRaw<{ hit: boolean }>(- `SELECT EXISTS(SELECT 1 FROM (VALUES ('example-source','__managed_sync_checkpoint__',1::bigint,'d1',$1::text,'conflict'))- r(source_id,slug,sequence,digest,operation,state),+ `SELECT EXISTS(SELECT 1 FROM (VALUES ($4::uuid,'example-source','__managed_sync_checkpoint__',1::bigint,'d1',$1::text,'conflict'))+ r(id,source_id,slug,sequence,digest,operation,state),(VALUES ('example-source','__managed_sync_checkpoint__',2::bigint,'d2',$2::text,$3::text::jsonb,'committed')) c(source_id,slug,sequence,digest,operation,intent,state)WHERE ${supersessionSql('r', 'c')}) AS hit`,- [r.operation, c.operation, c.kind ? JSON.stringify({ kind: c.kind }) : null]))[0]!.hit;+ [r.operation, c.operation, c.kind ? JSON.stringify({ kind: c.kind }) : null, randomUUID()]))[0]!.hit;expect(await later({ operation: 'submit_job' }, { operation: 'submit_job', kind: 'managed_sync_checkpoint' })).toBe(true);expect(await later({ operation: 'submit_job' }, { operation: 'submit_job', kind: null })).toBe(true);expect(await later({ operation: 'remember' }, { operation: 'submit_job', kind: 'managed_sync_checkpoint' })).toBe(false);@@ -323,4 +324,29 @@ describe('#6834 a managed-sync checkpoint whose source checkpoint moved', () =>expect((await classifyManagedSyncOrphans(engine, [f.id])).orphans).toEqual([]);expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('synced');}), 180_000);++ test('a failed import of a page slugged __managed_sync_checkpoint__ stays a page failure after a later checkpoint commits', () => each(async engine => {+ const f = await fixture(engine, 'entries');+ const receipt = async (kind: string) => {+ const requestId = randomUUID();+ await engine.executeRaw(`INSERT INTO persistence_requests(principal_kind,principal_id,request_id,operation,source_id,source_incarnation,slug,digest,authority,intent_bytes,terminal_reservation,+ state,error_code,error_message,intent,completed_at,updated_at,admitter_version)+ VALUES('local_cli','fixture',$1::uuid,'submit_job',$2,(SELECT incarnation FROM sources WHERE id=$2),'__managed_sync_checkpoint__',$3,'{}'::jsonb,0,0,+ 'conflict','revision_conflict',$4,$5::text::jsonb,now()-interval '1 hour',now()-interval '1 hour',$6)`,+ [requestId, f.id, randomUUID(), kind === 'managed_sync_checkpoint' ? MOVED : 'The page changed during sync preparation.', JSON.stringify({ kind }), '0.60.262.0']);+ return (await engine.executeRaw<{ id: string }>('SELECT id::text AS id FROM persistence_requests WHERE request_id=$1::uuid', [requestId]))[0]!;+ };+ const page = await receipt('managed_sync_import');+ const checkpoint = await receipt('managed_sync_checkpoint');+ expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('synced');+ expect(await superseded(engine, checkpoint.id)).toBe(true);+ expect(await superseded(engine, page.id)).toBe(false);+ const listing = await readTerminalFailures(engine, { sourceId: f.id });+ expect(listing.status).toBe('ok');+ const rows = 'rows' in listing ? listing.rows ?? [] : [];+ expect(rows.filter(row => row.slug === '__managed_sync_checkpoint__')).toEqual([expect.objectContaining({ class: 'page', category: 'caller_conflict',+ fix: expect.objectContaining({ argv: ['gbrain', 'get', '--source', f.id, '--', '__managed_sync_checkpoint__'] }) })]);+ const summary = await readTerminalFailureSummary(engine, { sourceIds: [f.id] });+ expect(summary.status === 'ok' ? summary.sources.find(s => s.source_id === f.id)?.unresolved.rows : null).toBe(1);+ }), 180_000);});