Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): bind checkpoint_moved retirement to the previewed run, clear slice records, keep page diagnoses on bookkeeping-like slugs (#6834)
garrytan222c61addd53
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 75fc57a6ab..8c29b71ca9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,10 +39,11 @@ On v0.60.255.0 through v0.60.262.0 (one cursor per source): `gbrain sync --sourc### Itemized changes- **Checkpoint at its target (#6834).** A managed-sync checkpoint refused "The source checkpoint changed during this sync." whose source now records exactly the run's target is revived marked overtaken (the #5522 rule the publication already applies), within the existing per-invocation revival bound. A checkpoint moved to any other commit stays refused: publishing it would move the source's commit backwards or past work nobody imported.-- **`checkpoint_moved` orphans (#6834).** `classifyManagedSyncOrphans` lists an unfinished cursor whose checkpoint is that refusal, whose pages all committed, whose source records a commit other than the run's start and target, and with no open or recovering request under its key. `retireManagedSyncOrphan` re-checks the same rule in the delete, so a cursor whose source reached its target after the preview is kept (`no_longer_orphaned`) and the next sync finishes it. Bookkeeping rows only (`op_checkpoints`); no page or file changes, nothing at upgrade.+- **`checkpoint_moved` orphans (#6834).** `classifyManagedSyncOrphans` lists an unfinished cursor whose checkpoint is that refusal, whose pages all committed, whose source records a commit other than the run's start and target, and with no open or recovering request under its key; for a path slice short of its target's end (#6349), any commit other than the run's start qualifies, since that checkpoint never moves `last_commit`. `retireManagedSyncOrphan` re-checks the same rule in the delete and binds it to the previewed run and checkpoint request, so a cursor whose source reached its target after the preview, or a run that replaced the previewed one under the same key, is kept (`no_longer_orphaned`). Retiring a path slice clears its slice record too, so the next discovery starts from the recorded commit instead of resuming that slice against it. Bookkeeping rows only (`op_checkpoints`); no page or file changes, nothing at upgrade.- **Doctor (#6834).** `sync_failures` sets `fix` to `gbrain repair managed-sync-orphans [--source <id>]` whenever it lists orphans. `sync_freshness` sets the same `fix` (and names it in the message) for a stale managed source with a `checkpoint_moved` cursor, instead of a plain sync that would block again.-- **Diagnostics (#6834).** `writeFailureDiagnostic` gives the moved-checkpoint and incomplete-fact-batch refusals their own reasons and suggestions. `classifyTerminal` keeps both in `caller_conflict` but with class `systemic` and an action that reads sync status (checkpoint) or the receipt (fact batch), never `gbrain get` on a bookkeeping slug. The supersession rule counts a later committed checkpoint of the source as superseding a refused one. Ordinary page conflicts are unchanged.-- Tests: `test/sync-checkpoint-moved-6834.test.ts` (PGLite and Postgres) builds the race with two older cursor keys, a brain that already carries the refused receipt and failure row, and a checkpoint moved elsewhere; it fails on v0.60.262.0 (every plain sync blocked, no orphan listed, the page fix printed) and passes here.+- **Diagnostics (#6834).** `writeFailureDiagnostic` gives the moved-checkpoint and incomplete-fact-batch refusals their own reasons and suggestions. `classifyTerminal` keeps both in `caller_conflict` but with class `systemic` and an action that reads sync status (checkpoint) or the receipt (fact batch), never `gbrain get` on a bookkeeping slug. The supersession rule counts a later committed checkpoint of the source as superseding a refused one. A page whose slug merely looks like a bookkeeping slug keeps the page diagnosis: the request's own kind (or, once compacted, its operation) decides. Ordinary page conflicts are unchanged.+- `test/persistence-sync-failures.serial.test.ts` produced its checkpoint failure by moving `last_commit` to the run's own target, which now finishes; it moves it to a commit outside the run instead.+- Tests: `test/sync-checkpoint-moved-6834.test.ts` (PGLite and Postgres) builds the race with two older cursor keys, a brain that already carries the refused receipt and failure row, a checkpoint moved elsewhere, a path slice, and a run replaced between preview and apply; it fails on v0.60.262.0 (every plain sync blocked, no orphan listed, the page fix printed) and passes here.- No schema change.## [0.60.262.0] - 2026-10-16diff --git a/src/core/persistence/managed-sync-orphans.ts b/src/core/persistence/managed-sync-orphans.tsindex c4f1a73ad0..810759e4e1 100644--- a/src/core/persistence/managed-sync-orphans.ts+++ b/src/core/persistence/managed-sync-orphans.ts@@ -43,6 +43,8 @@ import type { BrainEngine } from '../engine.ts';import type { SqlEngine } from './model.ts';import { clearManagedSyncFailure, loadSyncFailures } from '../sync-failure-ledger.ts';import { CHECKPOINT_MOVED_MESSAGE } from './sync-slug-mode.ts';+import { clearSyncSlice } from './sync-slices.ts';+import type { SyncCursorOptions } from './sync-prepare.ts';/** `superseded_by_adoption` (#6712 PR 1): an unfinished cursor of the incarnation that the drain's fan-in did not adopt (sync-cursor-key.ts). */export type ManagedSyncOrphanReason = 'no_cursor' | 'principal_unadoptable' | 'superseded' | 'incarnation_retired' | 'mirror_only' | 'superseded_by_adoption' | 'checkpoint_moved';@@ -80,13 +82,15 @@ interface CursorRow {/*** #6834: the cursor `c` (of source `s`) stands at its checkpoint, which ended refused because `last_commit` moved, and the- * source now records a commit that is neither the cursor's start nor its target. A company-brain cursor records its- * approval and is never one. Shared by the classification and the- * retirement's re-check, so both read the same rule. `$msg` is the moved-checkpoint message parameter.+ * source now records a commit other than the cursor's start and other than where the checkpoint would put it: the+ * target, or, for a path slice short of its target's end (#6349), the start again. A company-brain cursor records its+ * approval and is never one. Shared by the classification and the retirement's re-check, so both read the same rule.+ * `$msg` is the moved-checkpoint message parameter.*/const checkpointMovedSql = (msg: string) => `(c.completed_keys->0->'pending'->'intent'->>'kind'='managed_sync_checkpoint' AND c.completed_keys->0->>'companyReceiptId' IS NULLAND (c.completed_keys->0->>'index')::int>=(c.completed_keys->0->>'total')::int- AND s.last_commit IS DISTINCT FROM c.completed_keys->0->>'from' AND s.last_commit IS DISTINCT FROM c.completed_keys->0->>'target'+ AND s.last_commit IS DISTINCT FROM c.completed_keys->0->>'from'+ AND (c.completed_keys->0->'pending'->'intent'->'slice'->>'done'='false' OR s.last_commit IS DISTINCT FROM c.completed_keys->0->>'target')AND EXISTS(SELECT 1 FROM persistence_requests m WHERE m.source_id=s.id AND m.request_id=(c.completed_keys->0->'pending'->>'requestId')::uuidAND m.state IN ('failed','conflict') AND m.recovery IS NULL AND m.error_code='revision_conflict' AND m.error_message=${msg})AND NOT EXISTS(SELECT 1 FROM persistence_requests o WHERE o.source_id=s.id AND o.intent->>'cursorKey'=c.fingerprint@@ -231,9 +235,11 @@ export async function pruneMirrorOnlyManagedFailures(engine: SqlEngine, sourceId** #6834: a `checkpoint_moved` cursor is deleted only while the classification's rule still holds (`checkpointMovedSql`):* its checkpoint is still the refused one, the source still records a commit other than its start and target, and no- * request under its key is open or carries recovery.+ * request under its key is open or carries recovery. It is bound to the previewed run and checkpoint request, so a run+ * that replaced the cursor under the same key since the preview is kept, and a path slice's record is cleared with it.*/-export async function retireManagedSyncOrphan(engine: BrainEngine, orphan: Pick<ManagedSyncOrphan, 'kind' | 'cursor_key' | 'run_id' | 'source_id' | 'source_incarnation' | 'reason'>,+export async function retireManagedSyncOrphan(engine: BrainEngine, orphan: Pick<ManagedSyncOrphan, 'kind' | 'cursor_key' | 'run_id' | 'source_id' | 'source_incarnation' | 'reason'>+ & { pending_request_id?: string | null },inTx?: (tx: BrainEngine) => Promise<void>): Promise<{ cursor: boolean; failure: boolean; manifest: boolean; mirror: boolean }> {const retired = orphan.reason === 'incarnation_retired';const mode = retired ? 'retired' : orphan.reason === 'superseded_by_adoption' ? 'adoption' : orphan.reason === 'checkpoint_moved' ? 'checkpoint_moved' : 'orphan';@@ -256,14 +262,20 @@ export async function retireManagedSyncOrphan(engine: BrainEngine, orphan: Pick<AND ($4::text='retired' AND EXISTS(SELECT 1 FROM sources s WHERE s.id=$2 AND NOT COALESCE(s.archived,false) AND s.incarnation::text<>$3)OR $4::text='adoption' AND NOT EXISTS(SELECT 1 FROM persistence_requests r WHERE r.source_id=$2 AND r.intent->>'cursorKey'=$1AND (r.state IN ('queued','running','recovering') OR r.recovery IS NOT NULL))- OR $4::text='checkpoint_moved' AND EXISTS(SELECT 1 FROM sources s WHERE s.id=$2 AND s.incarnation::text=$3 AND NOT COALESCE(s.archived,false) AND ${checkpointMovedSql('$5')})+ OR $4::text='checkpoint_moved' AND c.completed_keys->0->>'runId' IS NOT DISTINCT FROM $6::text+ AND c.completed_keys->0->'pending'->>'requestId' IS NOT DISTINCT FROM $7::text+ AND EXISTS(SELECT 1 FROM sources s WHERE s.id=$2 AND s.incarnation::text=$3 AND NOT COALESCE(s.archived,false) AND ${checkpointMovedSql('$5')})OR $4::text='orphan' AND NOT EXISTS(SELECT 1 FROM persistence_local_writers w WHERE w.revoked_at IS NULLAND w.id::text=c.completed_keys->0->'authority'->'writer'->'principal'->>'id'AND c.completed_keys->0->'authority'->'writer'->'principal'->>'kind' IN ('local_cli','local_stdio')AND (c.completed_keys->0 ? 'syncOptions')))- RETURNING fingerprint`, [orphan.cursor_key, orphan.source_id, orphan.source_incarnation, mode, CHECKPOINT_MOVED_MESSAGE]);+ RETURNING fingerprint,c.completed_keys->0->'pending'->'intent' AS intent`,+ [orphan.cursor_key, orphan.source_id, orphan.source_incarnation, mode, CHECKPOINT_MOVED_MESSAGE, orphan.run_id, orphan.pending_request_id ?? null]);cursor = rows.length > 0;if (!cursor) return { cursor: false, failure: false, manifest: false, mirror: false };+ // #6834: a retired path slice's record goes with it, so the next discovery starts from the recorded commit instead of resuming that slice.+ const intent = (rows[0] as { intent?: { slice?: { target?: string }; syncOptions?: SyncCursorOptions } | null }).intent;+ if (mode === 'checkpoint_moved' && intent?.slice?.target && intent.syncOptions) await clearSyncSlice(tx, orphan.source_id, orphan.source_incarnation!, intent.syncOptions, intent.slice.target);}const failure = (await tx.executeRaw(`DELETE FROM op_checkpoints f WHERE f.op='managed-sync-failure' AND f.fingerprint=$1AND NOT EXISTS(SELECT 1 FROM op_checkpoints c WHERE c.op='managed-sync' AND c.fingerprint=$1diff --git a/src/core/persistence/sync-slices.ts b/src/core/persistence/sync-slices.tsindex c10c4ada84..9b7ebe66ad 100644--- a/src/core/persistence/sync-slices.ts+++ b/src/core/persistence/sync-slices.ts@@ -41,8 +41,10 @@ export async function writeSyncSlice(tx: Exec, sourceId: string, incarnation: stON CONFLICT(op,fingerprint) DO UPDATE SET completed_keys=EXCLUDED.completed_keys,updated_at=now()`,[SYNC_SLICE_OP, sliceFingerprint(sourceId, incarnation, options), JSON.stringify([{ ...slice, recorded_at: new Date().toISOString() }])]);}-export async function clearSyncSlice(tx: Exec, sourceId: string, incarnation: string, options: SyncCursorOptions): Promise<void> {- await tx.executeRaw('DELETE FROM op_checkpoints WHERE op=$1 AND fingerprint=$2', [SYNC_SLICE_OP, sliceFingerprint(sourceId, incarnation, options)]);+/** `target` (#6834) clears the record only while it still names that target. */+export async function clearSyncSlice(tx: Exec, sourceId: string, incarnation: string, options: SyncCursorOptions, target?: string): Promise<void> {+ await tx.executeRaw("DELETE FROM op_checkpoints WHERE op=$1 AND fingerprint=$2 AND ($3::text IS NULL OR completed_keys->0->>'target'=$3)",+ [SYNC_SLICE_OP, sliceFingerprint(sourceId, incarnation, options), target ?? null]);}/** Code-unit order: the cursor's `after` must compare the same way on every host, which `localeCompare` does not promise. */diff --git a/src/core/persistence/terminal-classify.ts b/src/core/persistence/terminal-classify.tsindex 42df787d04..8438ddd2de 100644--- a/src/core/persistence/terminal-classify.ts+++ b/src/core/persistence/terminal-classify.ts@@ -249,13 +249,15 @@ function route(input: TerminalInput): Partial_ {return fromTable('sync_fault', code, origin ?? known, syncRetry(source, `The file changed under the write (${known}); a sync imports the current bytes.`), known === 'pinned_git_worktree_conflict' ? known : 'source_changed');}// #6834: a checkpoint or fact-batch completion receipt names a bookkeeping slug, never a page; reading it finds nothing.- if (code === 'revision_conflict' && input.slug === '__managed_sync_checkpoint__') {+ // A compacted receipt keeps no intent kind; its operation and slug still identify the bookkeeping request.+ const bookkeeping = (kind: string, operation: string, slug: string) => input.slug === slug && (input.intent_kind ? input.intent_kind === kind : input.operation === operation);+ if (code === 'revision_conflict' && bookkeeping('managed_sync_checkpoint', 'submit_job', '__managed_sync_checkpoint__')) {return { category: 'caller_conflict', code, origin, class: 'systemic', safe_actions: ['retry'], needs_human: false, escalate: escalateOf(code),action: { argv: ['gbrain', 'sync', 'status', '--source', source, '--json'], consent: [], actor: 'agent', requires_exclusive: false,why: 'A sync checkpoint was refused (__managed_sync_checkpoint__ is bookkeeping, not a page). Sync status names the step that finishes or retires its run, read-only; a later checkpoint of the source supersedes this receipt.',verify: { argv: failuresArgv(source) }, docs: 'docs/guides/repair.md#managed-sync-orphans' } };}- if (code === 'revision_conflict' && input.slug === '__managed_facts_complete__') {+ if (code === 'revision_conflict' && bookkeeping('managed_facts_complete', 'extract_facts', '__managed_facts_complete__')) {return { category: 'caller_conflict', code, origin, class: 'systemic', safe_actions: ['none'], needs_human: false, escalate: 'never: the batch\'s committed facts stay',action: { argv: terminalInspectArgv(input.request_id ?? '<request_id>'), consent: [], actor: 'agent', requires_exclusive: false,why: 'A fact-extraction batch was not recorded complete because some of its per-entity requests did not commit (__managed_facts_complete__ is bookkeeping, not a page). The receipt is read-only history; run the extraction again only if facts are still missing.',@@ -324,7 +326,8 @@ export function supersessionSql(r: string, c: string): string {return `(${c}.source_id=${r}.source_id AND ${c}.slug=${r}.slug AND ${c}.sequence>${r}.sequence AND ((${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 ${c}.state='committed')+ OR (${r}.slug='__managed_sync_checkpoint__' AND ${r}.operation='submit_job' AND ${c}.state='committed' AND ${c}.operation='submit_job'+ 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/test/sync-checkpoint-moved-6834.test.ts b/test/sync-checkpoint-moved-6834.test.tsindex b57f542b2c..8a20666827 100644--- a/test/sync-checkpoint-moved-6834.test.ts+++ b/test/sync-checkpoint-moved-6834.test.ts@@ -29,6 +29,9 @@ import { PGLiteEngine } from '../src/core/pglite-engine.ts';import { claimWorktree } from '../src/core/persistence/ownership.ts';import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';import { performManagedSync } from '../src/core/persistence/sync-run.ts';+import { drainManagedSync } from '../src/core/persistence/sync-drain.ts';+import { _setCursorBoundForTest } from '../src/core/persistence/sync-discovery.ts';+import { SYNC_SLICE_OP } from '../src/core/persistence/sync-slices.ts';import { __setManagedCursorKeyForTests } from '../src/core/persistence/sync-cursor-key.ts';import { readManagedSyncFailures } from '../src/core/persistence/sync-failures.ts';import { classifyManagedSyncOrphans } from '../src/core/persistence/managed-sync-orphans.ts';@@ -226,6 +229,69 @@ describe('#6834 a managed-sync checkpoint whose source checkpoint moved', () =>expect(await unfinished(engine, f)).toBe(0);}), 180_000);+ test.each([['the run\'s own target'], ['a newer commit']] as const)('a path slice short of its target whose checkpoint moved to %s is listed, and retiring it clears its slice record', moved => each(async engine => {+ _setCursorBoundForTest();+ await disposePersistenceConsumer(engine);+ await engine.executeRaw('UPDATE persistence_brain SET enabled=false WHERE singleton=1');+ const id = `sliced-${randomUUID().slice(0, 12)}`, root = join(home, id);+ mkdirSync(join(root, 'notes'), { recursive: true }); git(root, 'init', '-q');+ const names = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];+ for (const name of names) writeFileSync(join(root, 'notes', `${name}.md`), note(name));+ const target = commit(root, 'seven at once');+ await engine.executeRaw('INSERT INTO sources(id,name,local_path,config) VALUES($1,$1,$2,$3::text::jsonb)', [id, root, '{}']);+ await claimWorktree(engine, id, root);+ await engine.executeRaw('UPDATE persistence_brain SET enabled=true WHERE singleton=1');+ const f = { id, repo: root, root, seed: target, side: target, target, opts: { sourceId: id, noPull: true, noEmbed: true, noExtract: true } };+ const slices = async () => Number((await engine.executeRaw<{ n: string }>("SELECT COUNT(*)::text AS n FROM op_checkpoints WHERE op=$1 AND fingerprint LIKE $2", [SYNC_SLICE_OP, `${id}:%`]))[0]!.n);+ try {+ _setCursorBoundForTest({ entries: 3, bytes: 1024 ** 2 });+ expect((await drainManagedSync(engine, f.opts, false)).staged?.slice).toMatchObject({ phase: 'import', after: 'notes/c.md' });+ expect(await slices()).toBe(1);+ // The second slice commits its pages and stops before its checkpoint.+ const abort = new AbortController();+ expect((await outcome(performManagedSync(engine, { ...f.opts, signal: abort.signal, onProgress: p => { if (p.total && p.bankedFiles === p.total) abort.abort(); } }))).status).toBe('partial');+ writeFileSync(join(root, 'notes', 'x.md'), note('x'));+ const newer = commit(root, 'one more');+ await moveCheckpoint(engine, f, moved === 'a newer commit' ? newer : target);+ expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('blocked_by_failures');+ expect((await classifyManagedSyncOrphans(engine, [id])).orphans.map(orphan => orphan.reason)).toEqual(['checkpoint_moved']);+ const preview = await repair(engine, f);+ expect((await repair(engine, f, preview.preview_hash)).applied).toBe(1);+ expect(await slices()).toBe(0);+ _setCursorBoundForTest();+ const next = await outcome(performManagedSync(engine, f.opts));+ expect(next.status).not.toBe('blocked_by_failures');+ expect(next.deleted ?? 0).toBe(0);+ // The source never moves back to the slice's target, and nothing the newer commit has is deleted.+ expect(await lastCommit(engine, f)).toBe(newer);+ } finally { _setCursorBoundForTest(); }+ }), 180_000);++ test('an apply keeps a cursor whose run replaced the previewed one under the same key', () => each(async engine => {+ const f = await fixture(engine, 'entries');+ await beforeCheckpoint(engine, f, 'entries');+ await moveCheckpoint(engine, f, f.side);+ expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('blocked_by_failures');+ const preview = await repair(engine, f);+ const previewed = (await classifyManagedSyncOrphans(engine, [f.id])).orphans[0]!;+ // --retry-failed replaces the run under the same key; the replacement stops before its checkpoint, which moves too.+ writeFileSync(join(f.root, 'notes', 'beta.md'), note('beta', 'A revised observation'));+ const head = commit(f.repo, 'beta');+ const abort = new AbortController();+ expect((await outcome(performManagedSync(engine, { ...f.opts, retryFailed: true, signal: abort.signal, onProgress: p => { if (p.total && p.bankedFiles === p.total) abort.abort(); } }))).status).toBe('partial');+ await moveCheckpoint(engine, f, f.seed);+ expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('blocked_by_failures');+ const current = (await classifyManagedSyncOrphans(engine, [f.id])).orphans[0]!;+ expect(current.run_id).not.toBe(previewed.run_id);+ expect((await repair(engine, f, preview.preview_hash)).applied).toBe(0);+ expect(await unfinished(engine, f)).toBe(1);+ // A fresh preview binds to the replacement run and retires it.+ const again = await repair(engine, f);+ expect((await repair(engine, f, again.preview_hash)).applied).toBe(1);+ expect((await outcome(performManagedSync(engine, f.opts))).status).toBe('synced');+ expect(await lastCommit(engine, f)).toBe(head);+ }), 180_000);+test('ordinary page revision conflicts keep their diagnosis and action', () => each(async engine => {const page = writeFailureDiagnostic('revision_conflict', 'The page changed during sync preparation.');expect(page).toMatchObject({ reason: 'revision_conflict', suggestion: 'Read the current page and review the intended change before submitting a corrected write.' });@@ -234,6 +300,21 @@ describe('#6834 a managed-sync checkpoint whose source checkpoint moved', () =>const base = { source_id: 'example-source', operation: 'submit_job', state: 'conflict', error_code: 'revision_conflict', recovery: null, blocked_reason: null, compacted: false, request_id: randomUUID() };expect(classifyTerminal({ ...base, slug: 'notes/alpha' })).toMatchObject({ category: 'caller_conflict', class: 'page',action: { argv: ['gbrain', 'get', '--source', 'example-source', '--', 'notes/alpha'] } });+ // A user page may carry a bookkeeping-like slug; only the bookkeeping request's own kind (or, compacted, its operation) is reclassified.+ for (const page of [{ operation: 'put_page', intent_kind: null }, { operation: 'submit_job', intent_kind: 'managed_sync_import' }]) {+ expect(classifyTerminal({ ...base, ...page, slug: '__managed_sync_checkpoint__' })).toMatchObject({ class: 'page',+ 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),+ (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;+ 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);+ expect(await later({ operation: 'submit_job' }, { operation: 'submit_job', kind: 'managed_sync_import' })).toBe(false);expect(classifyTerminal({ ...base, slug: '__managed_facts_complete__', operation: 'extract_facts' })).toMatchObject({ class: 'systemic', safe_actions: ['none'],action: { argv: ['gbrain', 'write-request', base.request_id, '--json'] } });// An unfinished run whose checkpoint has not published is the run's to finish, never an orphan.