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(wiki): basis-aware Stage-2 curation bar, inferred markers, enrichment routing
Personal Jarvis Maintainerbc5fe57f9adc
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.pyindex 493a527b8e..bf7bbf8cf4 100644--- a/jarvis/memory/wiki/consolidator.py+++ b/jarvis/memory/wiki/consolidator.py@@ -75,6 +75,9 @@ _GRAPH_TARGET_DIR_BY_KIND = {"place": "entities","organization": "entities","project": "projects",+ # A recurring sport/hobby the user practices is a standing theme of+ # their life — graph-visible under concepts/ (for example golf).+ "activity": "concepts",}# Numeric claims are a small but damaging hallucination class: a page about an@@ -800,13 +803,20 @@ class Consolidator:session_id = str(row.session_id or "").strip()if not turn_id:return body+ # Non-explicit provenance is part of the citation: a reader (and a+ # later upgrade pass) can see the fact was inferred from behaviour,+ # not asserted verbatim.+ basis = str(getattr(row, "basis", "") or "").strip().lower()+ basis_suffix = (+ f" (basis: {basis})" if basis and basis != "explicit" else ""+ )if session_id:marker = (f"- Realtime transcript: session `{session_id}`, "- f"turn `{turn_id}`."+ f"turn `{turn_id}`{basis_suffix}.")else:- marker = f"- Conversation transcript: turn `{turn_id}`."+ marker = f"- Conversation transcript: turn `{turn_id}`{basis_suffix}."if marker in body:return body@@ -1338,6 +1348,12 @@ class Consolidator:continueif closing >= 0 and index <= closing:continue+ if normalised.endswith("*(inferred)*"):+ # Behavioral/inferred lines are upgradeable by design: a+ # later explicit assertion may rewrite them (dropping the+ # marker) or an explicit contradiction may remove them.+ # Everything else keeps byte-level protection.+ continuerequired.add(normalised)return requireddiff --git a/jarvis/memory/wiki/prompt.py b/jarvis/memory/wiki/prompt.pyindex a49d2bb390..d81e791606 100644--- a/jarvis/memory/wiki/prompt.py+++ b/jarvis/memory/wiki/prompt.py@@ -76,13 +76,16 @@ any update.blockers.- Relationships: who-knows-whom, family, employer, collaborator.-The user must explicitly assert or confirm their durable relationship to a-topic. "I own a yacht." and "I plan to attend Monaco." are worth saving. If a-question also contains self-disclosure, retain only the disclosed fact and do-not infer why the user asked. When in doubt after direct self-disclosure is-established: write the note. Forgetting a grounded fact is a strictly worse-failure than adding a slightly-too-eager one (the user can always edit or-archive a wiki page; they cannot un-forget).+The user must assert or confirm their durable relationship to a topic —+either explicitly ("I own a yacht.", "I plan to attend Monaco.") or through a+first-person lived-experience report ("I love being out on golf courses with+my buddies" grounds that the user plays and enjoys golf). Topic choice alone+never qualifies. If a question also contains self-disclosure, retain only the+disclosed fact and do not infer why the user asked. Quality bar: this is a+curated map of the user's life, not a transcript archive. For facts the user+asserted about themselves, their people, possessions, health, habits, and+projects, forgetting is the worse failure. For everything else, writing junk+is the worse failure — when in doubt with no strong personal anchor, skip it.## Output Contract (binding)@@ -444,7 +447,7 @@ excerpt does not directly support the fact, or evidence is unavailable, choose"noop" with an unsupported-evidence reason. Existing pages help decide wheresupported knowledge belongs, but cannot make an unsupported candidate true.For a claimed user interest, preference, habit, plan, intent, identity, or-ownership, the evidence must explicitly assert or confirm that relationship.+ownership, the evidence must assert or confirm that relationship.A topic mention, one-off question, search, or information request is not directsupport. "What are the benefits of Vitamin D?" does not establish a supplementinterest or plan. "Tell me about Monaco." does not establish interest, travel@@ -453,6 +456,24 @@ By contrast, "I own a yacht." and "I plan to attend Monaco." are explicitself-disclosures that may be stored. If a question contains a self-disclosure,judge only the disclosed clause and never invent a reason for the question.+Evidence bases: each candidate carries basis=explicit|behavioral|inferred and+salience=1-5 (how central the fact is to the user's own life).+- basis=explicit: the user literally asserted the fact.+- basis=behavioral: the user described first-person lived experience — doing,+ practicing, or enjoying something — without naming it as a preference. Store+ it phrased from the evidence (for example "Plays golf with friends;+ describes it with enthusiasm") and end that page bullet with the exact+ marker *(inferred)*. When a later candidate provides an explicit assertion+ for the same fact, upgrade the line: rewrite it and drop the marker. An+ explicit contradiction may remove an *(inferred)* line outright (the only+ permitted line deletion) or use "invalidate" for a whole superseded page.+- Topic questions and one-off mentions still require "noop" regardless of the+ claimed basis; a basis label never overrides the evidence rules above.+- Curation bar by salience: candidates with salience 1-2 (world knowledge,+ trivia) prefer "noop" — junk on the map is the worse failure there. For+ asserted personal facts (salience 3-5), prefer "add"/"update" — the user+ cannot recover a fact the wiki never stored.+Explicit persistence requests are binding across all supported conversationlanguages (English, German, and Spanish):- When the user asks Jarvis to remember, note, save, record, or add something@@ -502,10 +523,12 @@ Decision semantics:organization, place) that only appears as a line on ANOTHER page — forexample the user's profile — is NOT already known; "add" its own entitypage and cross-link it instead of choosing "noop".- For an evidence-supported durable fact, prefer "add" or "update" over- "noop": the user can edit or archive an over-eager page, but cannot- recover a fact the wiki never stored. You are the binding cleanliness- gate for durability and evidence, not a brake on wiki growth.+ You are the curation gate of a person-centric wiki, asymmetric by design:+ for an evidence-supported fact about the user's identity, people,+ possessions, health, habits, or projects, prefer "add"/"update" over+ "noop" — the user cannot recover a fact the wiki never stored. For world+ knowledge, one-off topics, and salience 1-2 candidates, prefer "noop" —+ junk on the map is the worse failure there.Provide only "candidate_id", "decision", "reason".- "invalidate": the fact CONTRADICTS a shown page so that page (orstatement) is now outdated. Provide "target" (the superseded page) and@@ -527,6 +550,13 @@ batch and cross-link it with the profile in both directions. Do not createtopic pages for one-off mentions, smalltalk themes, or unsupported guesses— the evidence rules above still apply.+Enrichment routing (binding): when a candidate's subjects name a topic that+already has its own page (the user's car, a sport, a person), the primary+"update" targets THAT topic page — new detail about the topic belongs there.+The user profile keeps at most a one-line [[wikilink]] bullet to the topic;+profile bullets must not accumulate detail that belongs on a linked topic+page.+A grounded residence is always graph-visible: use kind `place`, require thecandidate subjects to contain both the exact user slug and the named placeslug, create `entities/<place-slug>.md` when missing, and cross-link the place@@ -611,8 +641,11 @@ def build_consolidator_prompt(subjects = ", ".join(getattr(row, "subjects", ()) or ()) or "-"evidence_turn_id = str(getattr(row, "evidence_turn_id", "") or "")evidence_excerpt = str(getattr(row, "evidence_excerpt", "") or "")+ basis = str(getattr(row, "basis", "") or "explicit")+ salience = int(getattr(row, "salience", 3) or 3)parts.append(- f"candidate_id={row.id} kind={row.kind} subjects=[{subjects}]\n"+ f"candidate_id={row.id} kind={row.kind} subjects=[{subjects}] "+ f"basis={basis} salience={salience}\n"f" proposed_fact={json.dumps(str(row.fact), ensure_ascii=False)}\n"f" user_evidence_turn_id={json.dumps(evidence_turn_id)}\n"" user_evidence_excerpt="diff --git a/tests/unit/memory/wiki/test_consolidator.py b/tests/unit/memory/wiki/test_consolidator.pyindex b02d4d5784..16607cc044 100644--- a/tests/unit/memory/wiki/test_consolidator.py+++ b/tests/unit/memory/wiki/test_consolidator.py@@ -2287,3 +2287,243 @@ async def test_empty_journal_is_a_cheap_noop(stack) -> None:label = await consolidator.run_once()assert label == "journal-empty"assert brain.received_requests == []+++# ---------------------------------------------------------------------------+# Evidence-tiered curation: *(inferred)* markers, basis provenance, activity+# ---------------------------------------------------------------------------++RUBEN_WITH_INFERRED_GOLF = RUBEN_FULL_BODY.replace(+ "- Enjoys great coffee.\n",+ "- Enjoys great coffee.\n- Plays golf with friends *(inferred)*\n",+)+++def _golf_concept_body() -> str:+ today = dt.date.today().isoformat()+ return (+ "---\n"+ "type: concept\n"+ "slug: golf\n"+ "aliases: [Golf]\n"+ f"created: {today}\n"+ f"updated: {today}\n"+ "---\n\n"+ "# Golf\n\n"+ "## Summary\n\n"+ "A sport the user plays actively with friends.\n\n"+ "## Definition\n\n"+ "Recurring outdoor activity of the user.\n\n"+ "## Examples\n\n"+ "- Weekend rounds with friends.\n\n"+ "## Related\n\n"+ "- [[entities/ruben|The user]]\n\n"+ "## Sources\n\n"+ "- conversation\n"+ )+++async def test_inferred_marker_line_may_be_rewritten_on_explicit_upgrade(+ stack,+) -> None:+ """An *(inferred)* bullet is upgradeable: a later explicit assertion may+ rewrite it (dropping the marker) without tripping the preservation guard."""+ vault_root, _curator, journal = stack+ page = vault_root / "entities" / "ruben.md"+ _write_aged(page, RUBEN_WITH_INFERRED_GOLF)+ journal.append(+ [CandidateFact(+ fact="Golf is the user's favourite sport.",+ kind="preference", subjects=("ruben",),+ evidence_turn_id="golf-upgrade",+ evidence_excerpt=(+ "Evidence user turn [golf-upgrade]: "+ "Golf is genuinely my favourite sport."+ ),+ )],+ source_label="realtime:golf-upgrade", turn_hash="golf-upgrade",+ )+ cid = journal.pending()[0].id++ upgraded = RUBEN_WITH_INFERRED_GOLF.replace(+ "- Plays golf with friends *(inferred)*\n",+ "- Golf is the user's favourite sport.\n",+ )+ brain = FakeBrain([_judge_json([{+ "candidate_id": cid,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": upgraded,+ "reason": "explicit assertion upgrades the inferred line",+ }])])++ label = await _consolidator(+ stack, brain, config=_config(user_entity_slug="ruben"),+ ).run_once()++ assert label == "journal-batch:1"+ content = page.read_text(encoding="utf-8")+ assert "- Golf is the user's favourite sport." in content+ assert "*(inferred)*" not in content+ assert "- Enjoys great coffee." in content # unmarked content survived+ assert journal.pending() == []+++async def test_unmarked_line_deletion_is_still_rejected_beside_marker_lines(+ stack,+) -> None:+ """The guard exemption is bounded to the literal *(inferred)* marker: a+ judge dropping an unmarked fact still falls back to a grounded provider."""+ vault_root, _curator, journal = stack+ page = vault_root / "entities" / "ruben.md"+ _write_aged(page, RUBEN_WITH_INFERRED_GOLF)+ journal.append(+ [CandidateFact(+ fact="Golf is the user's favourite sport.",+ kind="preference", subjects=("ruben",),+ )],+ source_label="realtime:golf-destructive", turn_hash="golf-destructive",+ )+ cid = journal.pending()[0].id++ destructive = RUBEN_WITH_INFERRED_GOLF.replace(+ "- Enjoys great coffee.\n- Plays golf with friends *(inferred)*\n",+ "- Golf is the user's favourite sport.\n",+ )+ preserved = RUBEN_WITH_INFERRED_GOLF.replace(+ "- Plays golf with friends *(inferred)*\n",+ "- Golf is the user's favourite sport.\n",+ )+ registry = ScriptedProviderRegistry(+ {+ "gemini": _judge_json([{+ "candidate_id": cid,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": destructive,+ }]),+ "openrouter": _judge_json([{+ "candidate_id": cid,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": preserved,+ }]),+ }+ )++ label = await _consolidator(+ stack,+ FakeBrain([]),+ registry=registry,+ config=_config(user_entity_slug="ruben"),+ ).run_once()++ assert label == "journal-batch:1"+ assert registry.tried == ["gemini", "openrouter"]+ content = page.read_text(encoding="utf-8")+ assert "- Enjoys great coffee." in content+ assert "- Golf is the user's favourite sport." in content+++async def test_source_marker_carries_behavioral_basis(stack) -> None:+ vault_root, _curator, journal = stack+ journal.append(+ [CandidateFact(+ fact="The user plays golf actively with friends.",+ kind="activity", subjects=("ruben", "golf"),+ evidence_turn_id="golf-turn",+ evidence_excerpt=(+ "Evidence user turn [golf-turn]: I love being out on golf "+ "courses with my buddies, playing this sport actively."+ ),+ basis="behavioral", salience=4,+ )],+ source_label="realtime:golf-behavioral", turn_hash="golf-behavioral",+ )+ cid = journal.pending()[0].id++ brain = FakeBrain([_judge_json([{+ "candidate_id": cid,+ "decision": "add",+ "target": "concepts/golf.md",+ "new_body": _golf_concept_body(),+ "reason": "recurring activity page",+ }])])++ label = await _consolidator(+ stack, brain, config=_config(user_entity_slug="ruben"),+ ).run_once()++ assert label == "journal-batch:1"+ content = (vault_root / "concepts" / "golf.md").read_text(encoding="utf-8")+ assert "turn `golf-turn` (basis: behavioral)." in content+ # The judge saw the basis/salience metadata on the candidate line.+ user_prompt = brain.received_requests[0].messages[0].content+ assert "basis=behavioral salience=4" in user_prompt+++async def test_activity_candidate_requires_companion_concept_page(stack) -> None:+ """A profile-only decision for a named recurring activity is invalid: the+ graph-companion invariant demands concepts/<topic>.md in the same batch."""+ vault_root, _curator, journal = stack+ _write_aged(vault_root / "entities" / "ruben.md", RUBEN_FULL_BODY)+ journal.append(+ [CandidateFact(+ fact="The user plays golf actively with friends.",+ kind="activity", subjects=("ruben", "golf"),+ basis="behavioral", salience=4,+ )],+ source_label="realtime:golf-companion", turn_hash="golf-companion",+ )+ cid = journal.pending()[0].id++ profile_only = RUBEN_FULL_BODY.replace(+ "- Enjoys great coffee.\n",+ "- Enjoys great coffee.\n"+ "- Plays golf actively with friends *(inferred)*\n",+ )+ with_companion = _judge_json([+ {+ "candidate_id": cid,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": profile_only,+ "reason": "profile note",+ },+ {+ "candidate_id": cid,+ "decision": "add",+ "target": "concepts/golf.md",+ "new_body": _golf_concept_body(),+ "reason": "companion activity page (graph visibility)",+ },+ ])+ registry = ScriptedProviderRegistry(+ {+ "gemini": _judge_json([{+ "candidate_id": cid,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": profile_only,+ "reason": "profile note without companion",+ }]),+ "openrouter": with_companion,+ }+ )++ label = await _consolidator(+ stack,+ FakeBrain([]),+ registry=registry,+ config=_config(user_entity_slug="ruben"),+ ).run_once()++ assert label == "journal-batch:1"+ assert registry.tried == ["gemini", "openrouter"]+ assert (vault_root / "concepts" / "golf.md").is_file()+ profile = (vault_root / "entities" / "ruben.md").read_text(encoding="utf-8")+ assert "- Plays golf actively with friends *(inferred)*" in profilediff --git a/tests/unit/memory/wiki/test_prompt.py b/tests/unit/memory/wiki/test_prompt.pyindex a2b9c87b19..f93eccd774 100644--- a/tests/unit/memory/wiki/test_prompt.py+++ b/tests/unit/memory/wiki/test_prompt.py@@ -332,14 +332,15 @@ def test_system_prompt_demands_empty_array_for_smalltalk() -> None:)-def test_system_prompt_tells_curator_to_prefer_writing_when_in_doubt() -> None:- """Forgetting a fact is the worse failure mode -- prompt must say so."""+def test_system_prompt_carries_the_asymmetric_curation_bar() -> None:+ """Recall-protected for personal facts, precision-biased elsewhere."""- prompt = build_system_prompt("schema body", vault_summary=None).lower()- # Anchor phrase; if the wording shifts in future revisions, update- # this assertion together with the prompt.- assert "when in doubt" in prompt- assert "forgetting" in prompt or "un-forget" in prompt+ prompt = " ".join(build_system_prompt("schema body", vault_summary=None).split())+ # Anchor phrases; if the wording shifts in future revisions, update+ # these assertions together with the prompt.+ assert "forgetting is the worse failure" in prompt+ assert "writing junk is the worse failure" in prompt+ assert "when in doubt with no strong personal anchor, skip it" in promptdef test_system_prompt_requires_self_disclosure_for_topic_memory() -> None:@@ -349,8 +350,10 @@ def test_system_prompt_requires_self_disclosure_for_topic_memory() -> None:assert '"What are the benefits of Vitamin D?"' in promptassert '"Tell me about Monaco."' in promptassert "both require `[]`" in prompt- assert '"I own a yacht." and "I plan to attend Monaco."' in prompt- assert "after direct self-disclosure is established" in prompt+ assert '"I own a yacht."' in prompt+ assert '"I plan to attend Monaco."' in prompt+ assert "Topic choice alone never qualifies" in prompt+ assert "first-person lived-experience report" in promptdef test_system_prompt_has_no_maintainer_specific_user_target() -> None:@@ -423,12 +426,14 @@ def test_consolidator_prompt_rechecks_question_derived_user_claims() -> None:system, user = build_consolidator_prompt([candidate], {})- assert "evidence must explicitly assert or confirm that relationship" in system+ assert "evidence must assert or confirm that relationship" in systemassert '"What are the benefits of Vitamin D?"' in systemassert '"Tell me about Monaco."' in systemassert 'both examples require "noop"' in systemassert '"I own a yacht." and "I plan to attend Monaco."' in systemassert "What are the benefits of Vitamin D?" in user+ # Rows without basis metadata render the explicit/3 defaults.+ assert "basis=explicit salience=3" in userdef test_consolidator_prompt_carries_the_graph_visibility_rule() -> None: