Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix: timestamp UltraWiki syncs after reconciliation

Ruben Lütke0d1bd72cb17f
diff --git a/jarvis/ultrawiki/service.py b/jarvis/ultrawiki/service.py
index 9ee735d737..d64ac394dc 100644
--- a/jarvis/ultrawiki/service.py
+++ b/jarvis/ultrawiki/service.py
@@ -1704,7 +1704,6 @@ class UltraWikiService:
max_cursor = await self._flush_chunk(
job, source_id, buffer, max_cursor
)
- now = _iso_now()
if job.mode == "backfill":
deletes_capable = bool(
getattr(getattr(connector, "capabilities", None), "deletes", False)
@@ -1714,6 +1713,13 @@ class UltraWikiService:
job.tombstoned += await store.reconcile_deletes(
source_id, yielded_ids
)
+ # Stamp completion only after delete reconciliation finishes. A
+ # large vector-backed cleanup can take minutes; using a timestamp
+ # captured before it made the source immediately look stale again
+ # and let the freshness scheduler overwrite the useful full-run
+ # outcome with a no-op incremental run.
+ now = _iso_now()
+ if job.mode == "backfill":
# Clearing the checkpoint is what makes the NEXT backfill a full
# one. Left behind, it points at the LAST item of a completed
# walk, so a connector that cannot run incrementally
diff --git a/tests/unit/ultrawiki/test_service.py b/tests/unit/ultrawiki/test_service.py
index e145ebc125..3077252eaf 100644
--- a/tests/unit/ultrawiki/test_service.py
+++ b/tests/unit/ultrawiki/test_service.py
@@ -19,6 +19,7 @@ from typing import Any
import pytest
import jarvis.ultrawiki.connectors as connectors_mod
+import jarvis.ultrawiki.service as service_mod
from jarvis.ultrawiki.service import (
JOB_TERMINAL_STATUSES,
SyncAlreadyRunningError,
@@ -499,6 +500,47 @@ async def test_full_refresh_resets_the_cursor_and_reconciles_deletes(
assert sync_state["backfill_checkpoint"] is None
+async def test_full_refresh_records_completion_after_delete_reconciliation(
+ service, monkeypatch
+):
+ items = make_items(1)
+ connector = FakeConnector(items, [])
+ patch_connectors(monkeypatch, {"fake-conn": lambda: connector})
+
+ source = await service.add_source("fake-conn", "Fake Source")
+ await service.approve_source(source["id"], auto_sync=False)
+ await wait_for_job(service, await service.start_sync(source["id"]))
+
+ store = service._require_store()
+ original_reconcile = store.reconcile_deletes
+ order: list[str] = []
+
+ async def traced_reconcile(source_id: str, yielded_ids: set[str]) -> int:
+ order.append("reconcile")
+ return await original_reconcile(source_id, yielded_ids)
+
+ completed_at = "2026-07-30T16:33:34Z"
+
+ def completion_clock() -> str:
+ order.append("clock")
+ return completed_at
+
+ monkeypatch.setattr(store, "reconcile_deletes", traced_reconcile)
+ monkeypatch.setattr(service_mod, "_iso_now", completion_clock)
+ connector._items = []
+
+ full = await wait_for_job(
+ service, await service.start_sync(source["id"], full=True)
+ )
+
+ assert full["status"] == "done"
+ assert full["tombstoned"] == 1
+ assert order == ["reconcile", "clock"]
+ sync_state = await store.get_sync_state(source["id"])
+ assert sync_state["backfill_complete_at"] == completed_at
+ assert sync_state["last_success_at"] == completed_at
+
+
# ---------------------------------------------------------------------------
# One sync per source at a time
# ---------------------------------------------------------------------------