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(wiki): accept the graph companion page from any candidate in the batch

Ruben Lütkef25dad54dfce
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.py
index d5b0d3353e..c63e46a9ee 100644
--- a/jarvis/memory/wiki/consolidator.py
+++ b/jarvis/memory/wiki/consolidator.py
@@ -1064,12 +1064,17 @@ class Consolidator:
if graph_target is None:
continue
graph_path = self._vault_root / graph_target
+ # Any candidate in the batch may carry the companion write: near-
+ # duplicate captures of one fact tempt the judge into putting the
+ # profile update under one candidate_id and the topic-page "add"
+ # under its twin — the batch as a whole still creates the page,
+ # and demanding a per-candidate copy would reject that correct
+ # answer (and force duplicate adds of the same target).
graph_item = next(
(
item
for item in parsed
- if item.get("candidate_id") == cid
- and item.get("decision") in ("add", "update")
+ if item.get("decision") in ("add", "update")
and self._safe_target(item.get("target")) == graph_target
),
None,
diff --git a/tests/unit/memory/wiki/test_consolidator.py b/tests/unit/memory/wiki/test_consolidator.py
index 04b8f30de9..6847f58df0 100644
--- a/tests/unit/memory/wiki/test_consolidator.py
+++ b/tests/unit/memory/wiki/test_consolidator.py
@@ -1573,6 +1573,73 @@ async def test_noop_marks_row_without_writing(stack) -> None:
assert (vault_root / "entities" / "lena.md").read_text(encoding="utf-8") == before
+async def test_companion_add_under_duplicate_candidate_satisfies_graph_check(
+ stack,
+) -> None:
+ """Near-duplicate captures of one fact may split the profile update and
+ the companion topic-page add across their two candidate_ids; the batch
+ still creates the required page and must validate."""
+ vault_root, _curator, journal = stack
+ _write_aged(vault_root / "entities" / "ruben.md", RUBEN_FULL_BODY)
+ journal.append(
+ [
+ CandidateFact(
+ fact="The user uses Safari as their web browser.",
+ kind="asset", subjects=("ruben", "safari"),
+ ),
+ CandidateFact(
+ fact="The user uses Safari as their web browser.",
+ kind="asset", subjects=("ruben", "safari"),
+ ),
+ ],
+ source_label="realtime-session-sweep:dupes", turn_hash="h-safari-dupes",
+ )
+ first, second = [row.id for row in journal.pending()]
+
+ updated_profile = RUBEN_FULL_BODY.replace(
+ "- Enjoys great coffee.\n",
+ "- Enjoys great coffee.\n- Uses Safari as the web browser.\n",
+ )
+ safari_body = (
+ "---\n"
+ "type: entity\n"
+ "entity_kind: tool\n"
+ "slug: safari\n"
+ "aliases: [Safari]\n"
+ f"created: {dt.date.today().isoformat()}\n"
+ f"updated: {dt.date.today().isoformat()}\n"
+ "---\n\n"
+ "# Safari\n\n## Summary\n\nThe user's web browser.\n\n"
+ "## Facts\n\n- Used as the primary web browser.\n\n"
+ "## Relationships\n\n- Used by [[entities/ruben|the user]].\n\n"
+ "## Sources\n\n- conversation\n"
+ )
+ brain = FakeBrain([_judge_json([
+ {
+ "candidate_id": first,
+ "decision": "update",
+ "target": "entities/ruben.md",
+ "new_body": updated_profile,
+ "reason": "profile note",
+ },
+ {
+ "candidate_id": second,
+ "decision": "add",
+ "target": "entities/safari.md",
+ "new_body": safari_body,
+ "reason": "topic page under the duplicate candidate",
+ },
+ ])])
+ consolidator = _consolidator(stack, brain)
+
+ label = await consolidator.run_once()
+
+ assert label == "journal-batch:2"
+ assert (vault_root / "entities" / "safari.md").is_file()
+ assert journal.pending() == []
+
+
@pytest.mark.asyncio
async def test_noop_on_graph_visible_fact_without_topic_page_is_accepted(stack) -> None:
"""A noop primary may not carry secondary writes, so the graph-visibility