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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
chore: auto-save WIP via Claude stop-hook safety net (2026-07-07 20:21)
Ruben Lütke5c86d9132ae7
diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex 688fdf1e95..d5aaf9812f 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -909,7 +909,11 @@ class SchedulerConfig(BaseModel):# Wave-2 journal pressure: once this many candidate facts sit pending# in the Stage-1 journal, a JOURNAL trigger asks the consolidator to# drain a batch (still subject to cooldown + lock).- consolidate_after_candidates: int = 8+ consolidate_after_candidates: int = 3+ # Age-based flush (spec A4): even below the count threshold, pending+ # candidates older than this become a JOURNAL trigger so a quiet fresh+ # install still produces visible pages. 0 disables the age flush.+ flush_pending_max_age_minutes: int = 10class VoiceBridgeConfig(BaseModel):diff --git a/jarvis/memory/wiki/integration.py b/jarvis/memory/wiki/integration.pyindex ccf41f068e..1302641a7f 100644--- a/jarvis/memory/wiki/integration.py+++ b/jarvis/memory/wiki/integration.py@@ -35,6 +35,7 @@ from __future__ import annotationsimport asyncioimport logging+import timefrom collections.abc import Awaitable, Callablefrom dataclasses import dataclass, fieldfrom pathlib import Path@@ -99,6 +100,10 @@ class WikiIntegrationHandle:_worker_stop: Callable[[], Awaitable[None]] | None_task: "asyncio.Task[Any] | None" = field(default=None)_telemetry_task: "asyncio.Task[Any] | None" = field(default=None)+ # Spec A4: age-based journal flush loop. Same fire-and-forget+ # conventions as the hourly telemetry loop (started off the boot+ # critical path per AP-26, cancelled here on teardown).+ _journal_age_flush_task: "asyncio.Task[Any] | None" = field(default=None)# The VoiceFactBridge attached during bootstrap. Declared as a field (not# monkey-patched) so shutdown() can stop it — otherwise its TranscriptFinal# / ResponseGenerated subscriptions leak on every teardown.@@ -189,6 +194,15 @@ class WikiIntegrationHandle:passself._telemetry_task = None+ # Cancel the age-based journal flush loop if started (spec A4).+ if self._journal_age_flush_task is not None and not self._journal_age_flush_task.done():+ self._journal_age_flush_task.cancel()+ try:+ await self._journal_age_flush_task+ except (asyncio.CancelledError, Exception): # noqa: BLE001+ pass+ self._journal_age_flush_task = None+# Clear the running-curator registry so a fresh bootstrap (e.g. in a# test that tears down and re-creates) does not see the stale one._set_running_curator(None)@@ -489,6 +503,17 @@ async def bootstrap_wiki_integration(# leftovers (< pressure threshold) consolidate without waiting# for new conversation.kick_journal_backlog(journal, scheduler)++ # Spec A4: below-threshold backlogs on a quiet install would+ # otherwise sit pending forever (not enough NEW conversation+ # ever arrives to cross consolidate_after_candidates). Start a+ # background age-check loop, same fire-and-forget conventions+ # as the hourly telemetry loop started below (AP-9/AP-26).+ handle._journal_age_flush_task = asyncio.create_task( # noqa: SLF001+ _journal_age_flush_loop(journal, scheduler, root_cfg.wiki_scheduler),+ name="wiki-journal-age-flush",+ )+ log.info("wiki_integration: age-based journal flush loop started")except Exception as exc: # noqa: BLE001log.warning("wiki_integration: Stage-2 consolidator unavailable (%s) — "diff --git a/jarvis/memory/wiki/journal.py b/jarvis/memory/wiki/journal.pyindex c738afc39e..65cb4f0f48 100644--- a/jarvis/memory/wiki/journal.py+++ b/jarvis/memory/wiki/journal.py@@ -230,6 +230,20 @@ class CandidateJournal:).fetchone()return int(row[0])+ def oldest_pending_ms(self) -> int | None:+ """``created_ms`` of the oldest pending row, or ``None`` when none+ pending (spec A4 — drives the age-based flush so a quiet fresh+ install still produces pages below the count threshold)."""+ with self._lock:+ conn = self._connection()+ if conn is None:+ return None+ row = conn.execute(+ "SELECT MIN(created_ms) FROM wiki_candidate_journal "+ "WHERE status = 'pending'"+ ).fetchone()+ return int(row[0]) if row and row[0] is not None else None+def seen_turn(self, turn_hash: str) -> bool:"""True when a turn with this hash was already journaled (dedupe)."""with self._lock:diff --git a/tests/unit/memory/wiki/test_journal_age_flush.py b/tests/unit/memory/wiki/test_journal_age_flush.pynew file mode 100644index 0000000000..8019048a87--- /dev/null+++ b/tests/unit/memory/wiki/test_journal_age_flush.py@@ -0,0 +1,67 @@+"""Pending ambient candidates must become visible by age, not only count+(spec A4) — a fresh machine with 2 candidates used to sit at zero .md+files forever (threshold was 8).+"""+from __future__ import annotations++from pathlib import Path++from jarvis.memory.wiki.journal import CandidateFact, CandidateJournal+++def _mk_journal(tmp_path: Path, now_ms: list[int]) -> CandidateJournal:+ return CandidateJournal(tmp_path / "journal.db", clock=lambda: now_ms[0] / 1000)+++def test_oldest_pending_ms_none_when_empty(tmp_path: Path) -> None:+ j = _mk_journal(tmp_path, [1_000_000])+ assert j.oldest_pending_ms() is None+++def test_oldest_pending_ms_returns_first_pending(tmp_path: Path) -> None:+ now = [1_000_000]+ j = _mk_journal(tmp_path, now)+ j.append(+ [CandidateFact(fact="Fact one about Joy.", kind="fact", subjects=("joy",))],+ source_label="test",+ turn_hash="h1",+ )+ now[0] += 60_000+ j.append(+ [CandidateFact(fact="Fact two about Rome.", kind="fact", subjects=("rome",))],+ source_label="test",+ turn_hash="h2",+ )+ oldest = j.oldest_pending_ms()+ assert oldest is not None+ assert oldest <= 1_000_000+++def test_oldest_pending_ms_ignores_consolidated_rows(tmp_path: Path) -> None:+ now = [1_000_000]+ j = _mk_journal(tmp_path, now)+ j.append(+ [CandidateFact(fact="Fact one about Joy.", kind="fact", subjects=("joy",))],+ source_label="test",+ turn_hash="h1",+ )+ now[0] += 60_000+ j.append(+ [CandidateFact(fact="Fact two about Rome.", kind="fact", subjects=("rome",))],+ source_label="test",+ turn_hash="h2",+ )+ rows = j.pending()+ j.mark([rows[0].id], status="consolidated", decision="add", target_path="entities/joy.md")++ oldest = j.oldest_pending_ms()+ assert oldest is not None+ assert oldest >= 1_060_000+++def test_default_consolidation_threshold_is_three() -> None:+ from jarvis.core.config import SchedulerConfig++ cfg = SchedulerConfig()+ assert cfg.consolidate_after_candidates == 3+ assert cfg.flush_pending_max_age_minutes == 10