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
feat(brain): route explicit "merk dir …" facts to wiki-ingest in the say-do guard
Ruben Lütke1f8a9110ea7e
diff --git a/jarvis/brain/contact_intent.py b/jarvis/brain/contact_intent.pyindex 1aabd06d53..05fad28375 100644--- a/jarvis/brain/contact_intent.py+++ b/jarvis/brain/contact_intent.py@@ -113,4 +113,71 @@ def detect_contact_write_intent(utterance: str) -> bool:return False-__all__ = ["detect_contact_write_intent", "CONTACT_WRITE_DIRECTIVE"]+# Minimum substance for a wiki note (mirrors wiki_ingest._MIN_INGEST_CHARS) —+# below this the curator's salience filter would drop it anyway.+_MIN_MEMORY_CHARS: int = 12++# An EXPLICIT "write this into my long-term memory" cue. Deliberately narrow:+# "speichere" alone is excluded (it also means save a file / a config), so a+# general memory note needs a clear remember-phrasing.+_MEMORY_VERB_RE = re.compile(+ r"\b("+ r"merk(e|t)?\s+(es\s+)?dir" # merk dir / merke dir / merk es dir+ r"|notier\w*\s+dir" # notier dir / notiere dir+ r"|behalt\w*" # behalte (im Hinterkopf/Kopf)+ r"|halt\w*\b[^?]{0,30}\bfest\b" # halt … fest+ r"|schreib\w*\b[^?]{0,30}\bauf\b" # schreib … auf+ r"|vermerk\w*" # vermerke+ r"|remember\s+(that|this|to)|note\s+(that|down)|keep\s+in\s+mind"+ r"|recuerda\w*|apunta\w*|anota\w*" # ES recordar/apuntar/anotar+ r")"+)++# Per-turn directive for a general wiki memory note (English — LLM-facing).+WIKI_INGEST_DIRECTIVE = (+ "MANDATORY THIS TURN: the user explicitly asked you to remember a fact "+ "about a person or their life. You MUST call the `wiki-ingest` tool to "+ "actually write it to their long-term wiki — pass the fact as one "+ "self-contained sentence in the `text` argument — instead of only "+ "acknowledging it in words. Never tell the user you noted or saved "+ "something unless the `wiki-ingest` tool actually ran this turn."+)+++def detect_memory_save_intent(utterance: str) -> bool:+ """True when the user explicitly asks to REMEMBER a general fact (no contact+ field) — routed to the direct wiki write path (``wiki-ingest``).++ Requires an explicit remember cue ("merk dir", "notier dir", "remember+ that", "behalte im Hinterkopf") AND enough substance to be worth a page, so+ a bare "merk dir" or a plain question never fires.+ """+ t = _normalize(utterance or "")+ if len(t.strip()) < _MIN_MEMORY_CHARS:+ return False+ return bool(_MEMORY_VERB_RE.search(t))+++def resolve_save_mandate(utterance: str) -> tuple[str, str] | None:+ """Map a save/remember turn to ``(tool_name, per-turn directive)``, or None.++ Contact-data writes (an email/phone/address, or "save X as a contact") take+ priority over a general wiki memory note, so a dictated phone number lands in+ the address book rather than as free prose in the wiki. This is the single+ routing point the manager consumes — both the contact and the wiki say-do+ guards flow through here.+ """+ if detect_contact_write_intent(utterance):+ return ("contact-upsert", CONTACT_WRITE_DIRECTIVE)+ if detect_memory_save_intent(utterance):+ return ("wiki-ingest", WIKI_INGEST_DIRECTIVE)+ return None+++__all__ = [+ "detect_contact_write_intent",+ "detect_memory_save_intent",+ "resolve_save_mandate",+ "CONTACT_WRITE_DIRECTIVE",+ "WIKI_INGEST_DIRECTIVE",+]diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex ad52346959..8341432570 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -1158,6 +1158,19 @@ _ACTION_UNFULFILLED_PHRASES: dict[str, dict[str, str]] = {"añado."),},+ "wiki-ingest": {+ "de": (+ "Ich hab das noch nicht in deinem Wiki vermerkt — sag's noch mal, " # i18n-allow: German TTS+ "dann schreib ich's rein." # i18n-allow: German TTS+ ),+ "en": (+ "I haven't actually noted that in your wiki yet — say it once more "+ "and I'll write it down."+ ),+ "es": (+ "Todavía no lo he anotado en tu wiki — dímelo otra vez y lo escribo."+ ),+ },}# A write tool with no bespoke table reuses the contact wording's shape._ACTION_UNFULFILLED_DEFAULT = _ACTION_UNFULFILLED_PHRASES["contact-upsert"]@@ -6009,34 +6022,32 @@ class BrainManager:self._evidence_directive = verdict.directiveself._evidence_required_tool = verdict.tool_name- # Say-do honesty guard for WRITES (contacts). The read evidence gate- # above never fires on a "save this person" turn (it is not a lookup),- # so a confirmed offer ("ja, leg die an … die Mail ist …") used to be- # answered with a chatty "Okay, sehr gut" and NO contact-upsert call —- # the address book stayed empty (live session 2026-06-30). Mandate the- # real tool this turn, reusing the evidence machinery: the prompt- # directive, the smalltalk tool-widening (_evidence_required_tool stays- # visible), and the unverified-answer backstop that catches a fake- # confirmation. Only when the read gate did not already mandate a tool,- # and only if contact-upsert is actually registered (a deployment- # without contacts degrades to no mandate — never a mandate for a- # missing tool, §3 open-source).- if (- not self._evidence_required_tool- and "contact-upsert" in (getattr(self, "_tools", None) or {})- ):- from jarvis.brain.contact_intent import (- CONTACT_WRITE_DIRECTIVE,- detect_contact_write_intent,- )-- if detect_contact_write_intent(user_text):- self._evidence_directive = CONTACT_WRITE_DIRECTIVE- self._evidence_required_tool = "contact-upsert"+ # Say-do honesty guard for WRITES. The read evidence gate above never+ # fires on a "save this" turn (it is not a lookup), so a confirmed offer+ # ("ja, leg die an … die Mail ist …") or an explicit "merk dir, dass …"+ # used to be answered with a chatty "Okay, sehr gut" and NO write call —+ # nothing persisted (live session 2026-06-30). Mandate the right write+ # tool this turn, reusing the evidence machinery: the prompt directive,+ # the smalltalk tool-widening (_evidence_required_tool stays visible),+ # and the unverified-answer backstop that catches a fake confirmation.+ # resolve_save_mandate routes contact data → contact-upsert and a+ # general fact → wiki-ingest. Only when the read gate did not already+ # mandate a tool, and only if the target tool is actually registered (a+ # deployment without contacts/wiki degrades to no mandate — never a+ # mandate for a missing tool, §3 open-source).+ if not self._evidence_required_tool:+ from jarvis.brain.contact_intent import resolve_save_mandate++ _save_mandate = resolve_save_mandate(user_text)+ if _save_mandate is not None and _save_mandate[0] in (+ getattr(self, "_tools", None) or {}+ ):+ self._evidence_directive = _save_mandate[1]+ self._evidence_required_tool = _save_mandate[0]self._evidence_required_is_write = Truelog.info(- "Say-do guard: contact-write intent — mandating "- "contact-upsert this turn"+ "Say-do guard: save intent — mandating %s this turn",+ _save_mandate[0],)# Phase 5 / ADR-0006: pre-call budget gate. Block rather than requestdiff --git a/tests/unit/brain/test_action_say_do_guard.py b/tests/unit/brain/test_action_say_do_guard.pyindex 266fa5923e..5fe023070d 100644--- a/tests/unit/brain/test_action_say_do_guard.py+++ b/tests/unit/brain/test_action_say_do_guard.py@@ -33,6 +33,15 @@ def test_action_unfulfilled_answer_unknown_language_is_safe():assert _action_unfulfilled_answer("contact-upsert", lang="fr").strip()+def test_action_unfulfilled_answer_wiki_ingest_is_distinct_and_honest():+ de = _action_unfulfilled_answer("wiki-ingest", lang="de")+ en = _action_unfulfilled_answer("wiki-ingest", lang="en")+ assert de.strip() and en.strip()+ # Wiki wording, not the contact line.+ assert "kontakt" not in de.lower()+ assert any(w in de.lower() for w in ("wiki", "vermerkt", "notiert", "gemerkt"))++# --- the replacement decision (pure) -----------------------------------------diff --git a/tests/unit/brain/test_contact_intent.py b/tests/unit/brain/test_contact_intent.pyindex 66ff5fc8c5..8686d4a529 100644--- a/tests/unit/brain/test_contact_intent.py+++ b/tests/unit/brain/test_contact_intent.py@@ -10,7 +10,10 @@ backstop can catch a fake confirmation. Pure regex, no LLM (AP-9/AP-11).from jarvis.brain.contact_intent import (CONTACT_WRITE_DIRECTIVE,+ WIKI_INGEST_DIRECTIVE,detect_contact_write_intent,+ detect_memory_save_intent,+ resolve_save_mandate,)# --- positive: the turn really asks to save a person ------------------------@@ -83,3 +86,65 @@ def test_directive_forces_the_real_tool_and_clarifies_bad_fields():assert "@" in d# Must forbid claiming a save that did not run.assert "never" in d.lower() or "not" in d.lower()+++# --- general "merk dir …" facts → wiki-ingest (the wiki document path) --------+++def test_memory_save_intent_fires_on_explicit_remember():+ assert detect_memory_save_intent("Merk dir, dass Harald gerne Fußball schaut.") is True+ assert detect_memory_save_intent("Notier dir, dass Joy am 14. August Geburtstag hat.") is True+ assert detect_memory_save_intent("Remember that Tom prefers tea over coffee.") is True+ assert (+ detect_memory_save_intent("Behalte im Hinterkopf, dass ich allergisch gegen Nüsse bin.")+ is True+ )+++def test_memory_save_intent_needs_a_remember_cue_and_substance():+ assert detect_memory_save_intent("Was geht ab?") is False+ assert detect_memory_save_intent("Wie ist das Wetter?") is False+ # "speichere die Datei" is file/config, not a personal memory note.+ assert detect_memory_save_intent("Speichere die Datei.") is False+ assert detect_memory_save_intent("Merk.") is False # no real content+++# --- routing: contact data vs general fact -----------------------------------+++def test_resolve_save_mandate_routes_contact_data_to_contact_upsert():+ mandate = resolve_save_mandate(+ "Ähm, ja, legt die mal an. Also die Mailadresse von Harald ist harald.10.de."+ )+ assert mandate is not None+ tool, directive = mandate+ assert tool == "contact-upsert"+ assert directive == CONTACT_WRITE_DIRECTIVE+++def test_resolve_save_mandate_routes_general_fact_to_wiki_ingest():+ mandate = resolve_save_mandate("Merk dir, dass Harald gerne Fußball schaut.")+ assert mandate is not None+ tool, directive = mandate+ assert tool == "wiki-ingest"+ assert directive == WIKI_INGEST_DIRECTIVE+++def test_resolve_save_mandate_prefers_contact_when_both_match():+ # "merk dir … Nummer ist …" is BOTH a remember cue AND contact data — the+ # address-book path wins so the number lands where it belongs.+ mandate = resolve_save_mandate("Merk dir, Christophs Nummer ist 0171 1234567.")+ assert mandate is not None+ assert mandate[0] == "contact-upsert"+++def test_resolve_save_mandate_none_on_plain_turn():+ assert resolve_save_mandate("Was geht ab?") is None+ assert resolve_save_mandate("Wie ist das Wetter?") is None+++def test_wiki_ingest_directive_forces_the_real_tool():+ d = WIKI_INGEST_DIRECTIVE+ assert "wiki-ingest" in d+ assert "MANDATORY" in d+ assert "never" in d.lower() or "not" in d.lower()