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
fix(wiki): ground negated habit claims via cessation assertions
Personal Jarvis Maintainere45397495fed
diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex a855e4617a..d05934035d 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -1133,7 +1133,9 @@ class ExtractorConfig(BaseModel):timeout_s: float = 30.0# Personal-salience floor (1-5): candidates the model scores below this# are dropped in Stage 1. 3 keeps peripheral personal facts and drops- # world-knowledge trivia; raise it for a leaner vault.+ # world-knowledge trivia; raise it for a leaner vault. The default equals+ # jarvis/memory/wiki/constants.py DEFAULT_SALIENCE (unscored candidates+ # sit exactly on the floor).min_salience: int = 3# Rollback switch to the pre-basis regime: when False, behavioral# (lived-experience) grounding is treated as ungrounded and onlydiff --git a/jarvis/memory/migrations/0009_wiki_candidate_basis.sql b/jarvis/memory/migrations/0009_wiki_candidate_basis.sqlindex 6f0791e089..0f60d3dbfe 100644--- a/jarvis/memory/migrations/0009_wiki_candidate_basis.sql+++ b/jarvis/memory/migrations/0009_wiki_candidate_basis.sql@@ -18,6 +18,7 @@ CREATE TABLE IF NOT EXISTS wiki_candidate_basis (REFERENCES wiki_candidate_journal(id) ON DELETE CASCADE,basis TEXT NOT NULL DEFAULT 'explicit'CHECK (basis IN ('explicit', 'behavioral', 'inferred')),+ -- DEFAULT mirrors jarvis/memory/wiki/constants.py DEFAULT_SALIENCE.salience INTEGER NOT NULL DEFAULT 3CHECK (salience BETWEEN 1 AND 5));diff --git a/jarvis/memory/wiki/cli.py b/jarvis/memory/wiki/cli.pyindex c03fd2bd79..29654bced8 100644--- a/jarvis/memory/wiki/cli.py+++ b/jarvis/memory/wiki/cli.py@@ -27,7 +27,6 @@ from __future__ import annotationsimport argparseimport asyncioimport logging-import osimport sysfrom pathlib import Path@@ -179,12 +178,6 @@ async def _run_recurate_profile(vault_root: Path, *, apply: bool) -> int:from .recurate import recurate_profile- # os.path instead of Path.is_dir: no blocking pathlib call in async code- # (ASYNC240) for the one line this subcommand adds.- if not os.path.isdir(vault_root):- print(f"ERROR: vault not found: {vault_root}", file=sys.stderr)- return 1-curator = _build_curator(vault_root)await curator._vault.scan(vault_root) # noqa: SLF001 — CLI wiringreport = await recurate_profile(@@ -399,8 +392,12 @@ def main(argv: list[str] | None = None) -> int:return _run_cleanup(args.vault.resolve(), apply=bool(args.apply))if args.command == "recurate-profile":+ vault_root = args.vault.resolve()+ if not vault_root.is_dir():+ print(f"ERROR: vault not found: {vault_root}", file=sys.stderr)+ return 1return asyncio.run(- _run_recurate_profile(args.vault.resolve(), apply=bool(args.apply))+ _run_recurate_profile(vault_root, apply=bool(args.apply)))if args.command == "ingest":diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.pyindex bf7bbf8cf4..4e01e8cc20 100644--- a/jarvis/memory/wiki/consolidator.py+++ b/jarvis/memory/wiki/consolidator.py@@ -39,7 +39,7 @@ from typing import TYPE_CHECKING, Anyfrom jarvis.brain.provider_registry import BrainProviderRegistryfrom jarvis.brain.streaming import aggregate, is_length_truncatedfrom jarvis.core.protocols import BrainMessage, BrainRequest-from jarvis.memory.wiki.constants import CURATOR_DECISIONS+from jarvis.memory.wiki.constants import CURATOR_DECISIONS, INFERRED_MARKERfrom jarvis.memory.wiki.curator_llm import (_extract_json_array,_resolve_provider_and_model,@@ -1348,7 +1348,7 @@ class Consolidator:continueif closing >= 0 and index <= closing:continue- if normalised.endswith("*(inferred)*"):+ if normalised.endswith(INFERRED_MARKER):# Behavioral/inferred lines are upgradeable by design: a# later explicit assertion may rewrite them (dropping the# marker) or an explicit contradiction may remove them.diff --git a/jarvis/memory/wiki/constants.py b/jarvis/memory/wiki/constants.pyindex 2fad367a25..a1288b5af3 100644--- a/jarvis/memory/wiki/constants.py+++ b/jarvis/memory/wiki/constants.py@@ -32,6 +32,16 @@ CuratorDecision = Literal["add", "update", "noop", "invalidate"]FACT_BASES: tuple[str, ...] = ("explicit", "behavioral", "inferred")FactBasis = Literal["explicit", "behavioral", "inferred"]+# Default personal-salience score for candidates without one. Mirrored by the+# SQL DEFAULT in 0009_wiki_candidate_basis.sql — keep both in sync.+DEFAULT_SALIENCE = 3++# The literal bullet suffix marking a behavioral/inferred page line. The+# consolidator prompt teaches it, the preservation guard exempts exactly it,+# and the recurate prompt preserves it — prompt.py/recurate.py assert their+# prompt text still carries this exact token (drift guard).+INFERRED_MARKER = "*(inferred)*"+# Runtime drift assertions (mirror the jarvis/memory/constants.py pattern):# importing this module with a drifted tuple/Literal pair fails immediately.assert set(CANDIDATE_STATUSES) == set(CandidateStatus.__args__) # type: ignore[attr-defined]@@ -41,7 +51,9 @@ assert set(FACT_BASES) == set(FactBasis.__args__) # type: ignore[attr-defined]__all__ = ["CANDIDATE_STATUSES","CURATOR_DECISIONS",+ "DEFAULT_SALIENCE","FACT_BASES",+ "INFERRED_MARKER","CandidateStatus","CuratorDecision","FactBasis",diff --git a/jarvis/memory/wiki/extractor.py b/jarvis/memory/wiki/extractor.pyindex adaea2649b..2bba9e0474 100644--- a/jarvis/memory/wiki/extractor.py+++ b/jarvis/memory/wiki/extractor.py@@ -34,6 +34,7 @@ from jarvis.brain.provider_registry import BrainProviderRegistryfrom jarvis.brain.streaming import aggregate, is_length_truncatedfrom jarvis.core.protocols import BrainMessage, BrainRequestfrom jarvis.core.redact import safe_preview+from jarvis.memory.wiki.constants import DEFAULT_SALIENCEfrom jarvis.memory.wiki.curator_llm import (_extract_json_array,_resolve_provider_and_model,@@ -76,15 +77,15 @@ _DURABLE_CUE_RE = re.compile(r"(?i)\b(?:my|our|i\s+(?:am|own|prefer|love|hate|work|live|decided|plan"r"|play|go|train|meet)"r"|every\s+(?:day|week|weekend|morning|evening)"- r"|mein(?:e|er|en|em|es)?|unser(?:e|er|en|em|es)?"- r"|ich\s+(?:bin|habe|besitze|mag|liebe|hasse|arbeite|wohne|plane"- r"|spiele|gehe|trainiere|treffe)|jede[nrs]?"+ r"|mein(?:e|er|en|em|es)?|unser(?:e|er|en|em|es)?" # i18n-allow: input vocab+ r"|ich\s+(?:bin|habe|besitze|mag|liebe|hasse|arbeite|wohne|plane" # i18n-allow: input vocab+ r"|spiele|gehe|trainiere|treffe)|jede[nrs]?" # i18n-allow: input vocabr"|mi|mis|nuestro|nuestra|soy|tengo|prefiero|trabajo|vivo"r"|juego|voy|entreno|cada"r"|friend|partner|wife|husband|boss|mother|father"- r"|freund|partnerin|ehefrau|ehemann|chef|mutter|vater"+ r"|freund|partnerin|ehefrau|ehemann|chef|mutter|vater" # i18n-allow: input vocabr"|amigo|amiga|pareja|esposa|esposo|jefe|madre|padre"- r"|project|projekt|proyecto)\b"+ r"|project|projekt|proyecto)\b" # i18n-allow: input vocab)# Valid candidate kinds. Anything else degrades to "other" (soft vocab —@@ -106,15 +107,20 @@ _KNOWN_KINDS = frozenset(})+# Kinds whose Stage-1 candidates are HARD-dropped without both the user slug+# and a topic slug. Deliberately place-only: a residence always names a place,+# but an activity can be generic ("The user exercises regularly" has no topic+# page) — for activities the companion-page invariant stays a Stage-2 soft+# rule that applies only when subjects DO name a topic._GRAPH_SUBJECT_KINDS = frozenset({"place"})def _candidate_salience(item: dict[str, Any]) -> int:- """Model-scored 1-5 personal salience, clamped; missing/garbage -> 3."""+ """Model-scored 1-5 personal salience, clamped; missing/garbage -> default."""try:- salience = int(item.get("salience", 3))+ salience = int(item.get("salience", DEFAULT_SALIENCE))except (TypeError, ValueError):- return 3+ return DEFAULT_SALIENCEreturn max(1, min(5, salience))diff --git a/jarvis/memory/wiki/grounding.py b/jarvis/memory/wiki/grounding.pyindex ed020a8359..56331c516d 100644--- a/jarvis/memory/wiki/grounding.py+++ b/jarvis/memory/wiki/grounding.py@@ -108,7 +108,25 @@ _NEGATIVE_CANDIDATE_RE = re.compile(r"\b(?:"r"not|never|no\s+longer"r")\s+(?:interested|curious|keen|a\s+fan|likes?|loves?|enjoys?|"- r"prefers?|follows?)\b|\b(?:dislikes?|hates?|avoids?)\b",+ r"prefers?|follows?|plays?|practi[cs]es?|trains?|does)\b"+ r"|\b(?:dislikes?|hates?|avoids?)\b"+ r"|\b(?:stopped|quit|gave\s+up)\b",+ re.IGNORECASE,+)++# Cessation assertions ground a NEGATIVE habit/attitude claim ("The user no+# longer plays golf.") the way a positive assertion grounds a positive one.+# Without this path such claims could never ground at all and a plainly+# stated "I quit playing golf" would be silently dropped.+_CESSATION_ASSERTION_RE = re.compile(+ r"(?:"+ r"\bi\s+(?:quit|stopped|gave\s+up)\b|"+ r"\bi\s+(?:don.?t|do\s+not)\s+[^.!?;,\n]{0,50}\banymore\b|"+ r"\bi\s+no\s+longer\b|"+ r"\bich\s+[^.!?;,\n]{0,60}\bnicht\s+mehr\b|" # i18n-allow: input vocab+ r"\bich\s+habe\s+[^.!?;,\n]{0,50}\baufgeh(?:oe|o)rt\b|" # i18n-allow: input vocab+ r"\bya\s+no\s+\w+|\bdej[eo]\s+de\b"+ r")",re.IGNORECASE,)@@ -150,7 +168,11 @@ _FIRST_PERSON_EXPERIENCE_RE = re.compile(# es folded: "juego/voy/entreno...", "cada sabado", "siempre/suelo"r"\b(?:yo\s+)?(?:juego|voy|entreno|corro|nado|cocino|paso|quedo|"r"asisto|visito|estuve|estaba)\b|"- r"\bcada\s+\w+|\bsiempre\b|\bsuelo\b"+ r"\bcada\s+\w+|\bsiempre\b|\bsuelo\b|"+ r"\b(?:una\s+vez|dos\s+veces)\s+(?:a|por)\s+(?:la\s+)?\w+|"+ # frequency phrases: "once/twice a week", "einmal pro Woche"+ r"\b(?:once|twice)\s+a\s+(?:day|week|month|year)\b|"+ r"\b(?:einmal|zweimal|mehrmals)\s+(?:pro|die|im)\s+\w+" # i18n-allow: input vocabr")",re.IGNORECASE,)@@ -189,19 +211,24 @@ def _asserted_interest_polarities(focus_text: str) -> set[bool]:return polarities-def _behavioral_experience_grounded(focus_text: str) -> bool:- """True when a declarative focus clause reports first-person experience."""+def _declarative_clause_matches(focus_text: str, pattern: re.Pattern[str]) -> bool:+ """True when a declarative (non-question) focus clause matches."""folded = _fold(focus_text)for match in _CLAUSE_RE.finditer(folded):clause = match.group(1).strip(" \t¿¡")terminal = match.group(2)if not clause or terminal == "?" or _QUESTION_PREFIX_RE.match(clause):continue- if _FIRST_PERSON_EXPERIENCE_RE.search(clause):+ if pattern.search(clause):return Truereturn False+def _behavioral_experience_grounded(focus_text: str) -> bool:+ """True when a declarative focus clause reports first-person experience."""+ return _declarative_clause_matches(focus_text, _FIRST_PERSON_EXPERIENCE_RE)++def classify_user_attitude_evidence(*,fact: str,@@ -249,8 +276,13 @@ def classify_user_attitude_evidence(focus = focus_user_evidence(evidence_excerpt)if expected_polarity in _asserted_interest_polarities(focus):return "explicit"- if expected_polarity and _behavioral_experience_grounded(focus):- return "behavioral"+ if expected_polarity:+ if _behavioral_experience_grounded(focus):+ return "behavioral"+ elif _declarative_clause_matches(focus, _CESSATION_ASSERTION_RE):+ # "I quit playing golf" / "I don't play golf anymore" is an explicit+ # first-person statement even though it names no interest verb.+ return "explicit"return Nonediff --git a/jarvis/memory/wiki/journal.py b/jarvis/memory/wiki/journal.pyindex 98789f1fd5..38af65fb0a 100644--- a/jarvis/memory/wiki/journal.py+++ b/jarvis/memory/wiki/journal.py@@ -35,7 +35,12 @@ from typing import Literalfrom jarvis.core.redact import safe_preview-from .constants import FACT_BASES, CandidateStatus, CuratorDecision+from .constants import (+ DEFAULT_SALIENCE,+ FACT_BASES,+ CandidateStatus,+ CuratorDecision,+)from .secret_guard import contains_secretlog = logging.getLogger(__name__)@@ -87,7 +92,7 @@ _KNOWN_ERROR_CODES = frozenset(_DEFAULT_BASIS = "explicit"-_DEFAULT_SALIENCE = 3+_DEFAULT_SALIENCE = DEFAULT_SALIENCE@dataclass(frozen=True, slots=True)diff --git a/jarvis/memory/wiki/prompt.py b/jarvis/memory/wiki/prompt.pyindex d81e791606..34aaa86147 100644--- a/jarvis/memory/wiki/prompt.py+++ b/jarvis/memory/wiki/prompt.py@@ -26,6 +26,7 @@ from collections.abc import Iterablefrom pathlib import Pathfrom typing import Any+from jarvis.memory.wiki.constants import INFERRED_MARKER as _INFERRED_MARKERfrom jarvis.memory.wiki.journal import normalise_subjects# Output-contract block appended to schema.md inside the system prompt.@@ -600,6 +601,12 @@ Linking rules:"""+# Drift guard: the preservation-guard exemption in consolidator.py matches+# exactly constants.INFERRED_MARKER — the prompt must teach the same literal+# token, or upgraded lines stop being exempt (fail-safe but broken UX).+assert _INFERRED_MARKER in _CONSOLIDATOR_SYSTEM++def build_consolidator_prompt(candidates: Iterable[Any],neighbours: dict[str, str],diff --git a/jarvis/memory/wiki/recurate.py b/jarvis/memory/wiki/recurate.pyindex 30eaee52f0..486ccf10c8 100644--- a/jarvis/memory/wiki/recurate.py+++ b/jarvis/memory/wiki/recurate.py@@ -32,6 +32,7 @@ from jarvis.brain.streaming import aggregate, is_length_truncatedfrom jarvis.core.protocols import BrainMessage, BrainRequestfrom .cleanup import _full_snapshot+from .constants import INFERRED_MARKERfrom .curator_llm import _extract_json_arrayfrom .journal import normalise_subjectsfrom .prompt import resolve_user_entity_slug@@ -75,6 +76,11 @@ Return ONLY a JSON array of update objects, no prose, no code fences:"""+# Drift guard: the recurate prompt must reference the same literal marker+# the preservation guard exempts (constants.INFERRED_MARKER).+assert INFERRED_MARKER in _RECURATE_SYSTEM++@dataclass(slots=True)class RecurateReport:"""Outcome of one re-curation run (dry or applied)."""diff --git a/tests/unit/memory/wiki/test_grounding.py b/tests/unit/memory/wiki/test_grounding.pyindex 29c2130c34..a70c876ba7 100644--- a/tests/unit/memory/wiki/test_grounding.py+++ b/tests/unit/memory/wiki/test_grounding.py@@ -121,3 +121,38 @@ def test_multilingual_topic_question_stays_blocked() -> None:"Erzaehl mir was ueber Monaco?", # i18n-allow: input vocabulary under testsubjects=(_USER, "monaco"),) is None+++def test_cessation_habit_claim_classifies_explicit() -> None:+ assert _classify(+ "The user no longer plays golf.",+ "I don't play golf anymore, I quit last year.",+ ) == "explicit"+ assert _classify(+ "The user stopped playing golf.",+ "I stopped playing golf.",+ ) == "explicit"+++ "evidence",+ [+ "Ich spiele nicht mehr Golf.", # i18n-allow: input vocabulary under test+ "Ich habe mit Golf aufgehoert.", # i18n-allow: input vocabulary under test+ "Ya no juego al golf.",+ ],+)+def test_multilingual_cessation_claims_classify_explicit(evidence: str) -> None:+ assert _classify(+ "The user no longer plays golf.",+ evidence,+ ) == "explicit"+++def test_ungrounded_cessation_claim_stays_blocked() -> None:+ # A negative habit claim with no cessation statement in the evidence+ # (e.g. inferred from a topic question) still grounds nothing.+ assert _classify(+ "The user no longer plays golf.",+ "Tell me about golf courses in Monaco.",+ ) is None