Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): #6712 PR 4b drain.remaining is null for a pass that stopped reading its level
garrytane96383c4e19d
diff --git a/src/core/persistence/sync-drain.ts b/src/core/persistence/sync-drain.tsindex d98ce31989..edbc366250 100644--- a/src/core/persistence/sync-drain.ts+++ b/src/core/persistence/sync-drain.ts@@ -510,7 +510,8 @@ export async function runDrain(input: DrainInput): Promise<SyncResult> {};const finish = (result: SyncResult, outcome: DrainOutcome, stopReason?: DrainStopReason, extra?: Partial<DrainReport>): SyncResult => {if (result.managedCursor) { index = result.managedCursor.index; total = result.managedCursor.total; }- const left = outcome === 'synced' ? 0 : result.pass ? result.pass.remaining : remaining();+ // A pass that stopped reading its level (reconcile_read_incomplete) has no candidate set, so its remaining is unknown.+ const left = outcome === 'synced' ? 0 : result.pass ? (result.reason === 'reconcile_read_incomplete' ? null : result.pass.remaining) : remaining();if (stopReason === 'deadline' && continues(result)) result = { ...result, reason: 'timeout' };if (carried) result = { ...result, added: result.added + carried.added, modified: result.modified + carried.modified, deleted: result.deleted + carried.deleted,renamed: result.renamed + carried.renamed, chunksCreated: result.chunksCreated + carried.chunksCreated };diff --git a/test/fixtures/goldens/sync/pass-outcomes.json b/test/fixtures/goldens/sync/pass-outcomes.jsonindex 4581686ef5..efd4e01322 100644--- a/test/fixtures/goldens/sync/pass-outcomes.json+++ b/test/fixtures/goldens/sync/pass-outcomes.json@@ -9,7 +9,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "admission_paused","waived": 0,"written": 0@@ -61,7 +61,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "admission_paused","waived": 0,"written": 0@@ -116,7 +116,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "grant_scope","waived": 0,"written": 0@@ -168,7 +168,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "grant_scope","waived": 0,"written": 0@@ -223,7 +223,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "not_converged","waived": 0,"written": 0@@ -274,7 +274,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "not_converged","waived": 0,"written": 0@@ -328,7 +328,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "not_converged","waived": 0,"written": 0@@ -371,7 +371,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "not_converged","waived": 0,"written": 0@@ -417,7 +417,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "reconcile_host_required","waived": 0,"written": 0@@ -469,7 +469,7 @@"passes": 1,"processed": 0,"rate_pages_per_min": null,- "remaining": null,+ "remaining": 1,"stop_reason": "reconcile_host_required","waived": 0,"written": 0