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): bisect judge-rejected batches and unteach the two-update prompt rule
Ruben Lütke4afd03499fb5
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.pyindex f1ed536f9a..fc094ff4c3 100644--- a/jarvis/memory/wiki/consolidator.py+++ b/jarvis/memory/wiki/consolidator.py@@ -130,6 +130,7 @@ class _BatchOutcome:transient: int = 0unavailable: bool = Falsetruncated: bool = False+ rejected: int = 0def merge(self, other: _BatchOutcome) -> _BatchOutcome:return _BatchOutcome(@@ -138,6 +139,7 @@ class _BatchOutcome:transient=self.transient + other.transient,unavailable=self.unavailable or other.unavailable,truncated=self.truncated or other.truncated,+ rejected=self.rejected + other.rejected,)@@ -225,6 +227,8 @@ class Consolidator:return "judge-truncated"if outcome.unavailable:return "judge-unavailable"+ if outcome.rejected and not outcome.processed:+ return f"judge-rejected:{outcome.rejected}"if outcome.transient:return f"journal-transient:{outcome.transient}"if outcome.deferred:@@ -243,10 +247,13 @@ class Consolidator:# Provider timeout/unavailability is not a content verdict. Keep# every candidate pending for the next bounded trigger.return _BatchOutcome(unavailable=True)- if decisions == "truncated":+ if decisions in ("truncated", "rejected"):if len(rows) == 1:- # A single overlong result remains observable and retryable;- # never convert an output cap into terminal data loss.+ # A single overlong or judge-rejected result remains+ # observable and retryable; never convert it into terminal+ # data loss.+ if decisions == "rejected":+ return _BatchOutcome(rejected=1)return _BatchOutcome(truncated=True)midpoint = len(rows) // 2left = await self._process_rows(rows[:midpoint])@@ -341,7 +348,12 @@ class Consolidator:async def _judge(self, rows: list[JournalRow], neighbours: dict[str, str],) -> list[dict[str, Any]] | str | None:- """One batched LLM call. Returns decisions, "truncated", or None."""+ """One batched LLM call.++ Returns the decision list, ``"truncated"`` (output-cap hit),+ ``"rejected"`` (every provider answered but failed validation),+ or ``None`` (no provider reachable).+ """user_slug = resolve_user_entity_slug(getattr(self._root_cfg.memory.wiki.session_rollup,@@ -420,6 +432,14 @@ class Consolidator:)telemetry.inc("wiki_writes_blocked_truncated")return "truncated"+ if rejection_reasons:+ # At least one provider answered but every answer failed+ # validation. Retrying the identical batch would burn the+ # chain on the same verdict forever; bisecting isolates a+ # poison candidate to a single-row batch while the rest of+ # the queue keeps draining.+ telemetry.inc("wiki_writes_blocked_rejected")+ return "rejected"return Noneagg, self._resolved_provider = result@@ -928,7 +948,11 @@ class Consolidator:decision not in ("invalidate", "add")and not required_place_update):- return "candidate has more than one primary decision"+ return (+ f"candidate {cid} has more than one primary decision "+ f"(primary={primary_decisions[cid]}, "+ f"extra={decision} -> {item.get('target', '')!r})"+ )else:primary_seen.add(cid)primary_decisions[cid] = decisiondiff --git a/jarvis/memory/wiki/prompt.py b/jarvis/memory/wiki/prompt.pyindex c63b2b4b3c..a49d2bb390 100644--- a/jarvis/memory/wiki/prompt.py+++ b/jarvis/memory/wiki/prompt.py@@ -549,8 +549,11 @@ Page-type templates (frontmatter keys are mandatory):Linking rules:- Cross-link related pages with [[wikilinks]] in their Relationships /- Related sections — when a fact connects two pages, update BOTH if both- are shown to you.+ Related sections. A candidate carries at most ONE "update": when a fact+ connects two EXISTING pages, place the link inside that single updated+ page and do NOT emit a second "update" for the other page — the only+ two-update exception is the residence-link repair above. A secondary+ "add" page may of course link back to the page you update.- Only link pages that exist or that you create in THIS batch; anythingelse write as plain text.- The user's profile page (the user entity) is the preferred "update"diff --git a/tests/unit/memory/wiki/test_consolidator.py b/tests/unit/memory/wiki/test_consolidator.pyindex 35f50889b4..626861c938 100644--- a/tests/unit/memory/wiki/test_consolidator.py+++ b/tests/unit/memory/wiki/test_consolidator.py@@ -832,13 +832,68 @@ async def test_secondary_update_is_still_rejected(stack) -> None:label = await consolidator.run_once()- assert label == "judge-unavailable" # rejected response, chain exhausted+ assert label == "judge-rejected:1" # rejected response, chain exhaustedassert (vault_root / "entities" / "lena.md").read_text(encoding="utf-8") == LENA_BODYassert journal.pending() != [] # candidate stays visible for the next pass+async def test_rejected_batch_bisects_so_one_poison_candidate_cannot_wedge_the_queue(+ stack,+) -> None:+ """When EVERY provider fails validation on a multi-row batch, the batch+ is bisected like a truncated one: healthy candidates drain in their own+ single-row batches instead of being held hostage forever."""+ vault_root, _curator, journal = stack+ _write_aged(vault_root / "entities" / "ruben.md", RUBEN_FULL_BODY)+ _write_aged(vault_root / "entities" / "lena.md", LENA_BODY)+ journal.append(+ [+ CandidateFact(fact="Lena lives in Hamburg.", kind="person", subjects=("lena",)),+ CandidateFact(fact="The user enjoys great coffee.", subjects=("ruben",)),+ ],+ source_label="voice:poison-batch",+ turn_hash="poison-batch",+ )+ first, second = [row.id for row in journal.pending()]++ # Call 1 (full batch): illegal double-update -> rejected by validation.+ # Calls 2+3 (bisected halves): legal noops.+ brain = FakeBrain([+ _judge_json([+ {+ "candidate_id": first,+ "decision": "update",+ "target": "entities/lena.md",+ "new_body": LENA_BODY,+ "reason": "profile note",+ },+ {+ "candidate_id": first,+ "decision": "update",+ "target": "entities/ruben.md",+ "new_body": RUBEN_FULL_BODY,+ "reason": "illegal second update",+ },+ {"candidate_id": second, "decision": "noop", "reason": "known"},+ ]),+ _judge_json([+ {"candidate_id": first, "decision": "noop", "reason": "known"},+ ]),+ _judge_json([+ {"candidate_id": second, "decision": "noop", "reason": "known"},+ ]),+ ])+ consolidator = _consolidator(stack, brain)++ label = await consolidator.run_once()++ assert label == "journal-batch:2"+ assert journal.pending() == []++@pytest.mark.asyncioasync def test_partial_decision_array_crosses_to_complete_provider(stack) -> None:_vault_root, _curator, journal = stack@@ -1708,7 +1763,7 @@ async def test_unsafe_superseded_by_cannot_inject_frontmatter(stack) -> None:label = await _consolidator(stack, brain).run_once()- assert label == "judge-unavailable"+ assert label == "judge-rejected:1"assert old_page.read_text(encoding="utf-8") == LENA_BODYassert [row.id for row in journal.pending()] == [cid]