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): bound the consolidator's judge-rejection loop — backoff, then park the poison row

Personal Jarvis Maintainer9df8fdfd9ead
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.py
index 20ff8e134a..744b053d6b 100644
--- a/jarvis/memory/wiki/consolidator.py
+++ b/jarvis/memory/wiki/consolidator.py
@@ -168,6 +168,17 @@ class _BatchOutcome:
class Consolidator:
"""Batched journal drain through the body-aware judge."""
+ # A candidate every reachable provider keeps answering for with an
+ # invalid decision is a poison row: retrying it forever burns a full
+ # provider chain (and its latency/cost) on every journal trigger — the
+ # live 2026-07-21 wedge re-judged three rows for ~16 hours. Bound it:
+ # back off between rounds, and park the row as ``skipped`` after this
+ # many judge-rejected rounds so the queue stays honest and cheap. A
+ # process restart grants a fresh set of rounds, so a code/prompt fix
+ # re-opens the row automatically.
+ _MAX_JUDGE_REJECTION_ROUNDS = 3
+ _JUDGE_REJECTION_BACKOFF_S = 600.0
+
def __init__(
self,
*,
@@ -201,6 +212,10 @@ class Consolidator:
self._on_run_complete = on_run_complete
self._brain: Any = None
self._resolved_provider: str | None = None
+ # Per-row judge-rejection history: id -> (rounds, last monotonic ts).
+ # In-memory by design: bounds the burn within one process life while
+ # a restart (usually carrying a fix) retries parked-adjacent rows.
+ self._judge_rejections: dict[int, tuple[int, float]] = {}
# ------------------------------------------------------------------
# public API
@@ -215,6 +230,17 @@ class Consolidator:
if not rows:
return "journal-empty"
+ cooling = [row for row in rows if self._in_rejection_backoff(row.id)]
+ if cooling:
+ rows = [row for row in rows if row not in cooling]
+ log.info(
+ "Consolidator: %d candidate(s) wait out the judge-rejection "
+ "backoff this round",
+ len(cooling),
+ )
+ if not rows:
+ return f"journal-rejection-backoff:{len(cooling)}"
+
# A captured row without persisted user evidence predates the grounded
# policy. It is unsafe to let Stage 2 guess, and a policy-v3 backfill can
# recreate it from the transcript. Direct/internal journal rows without
@@ -273,8 +299,10 @@ class Consolidator:
if len(rows) == 1:
# A single overlong or judge-rejected result remains
# observable and retryable; never convert it into terminal
- # data loss.
+ # data loss. Retryable is still bounded: repeat rejections
+ # back off, then park the row (see _note_judge_rejection).
if decisions == "rejected":
+ self._note_judge_rejection(rows[0])
return _BatchOutcome(rejected=1)
return _BatchOutcome(truncated=True)
midpoint = len(rows) // 2
@@ -282,6 +310,8 @@ class Consolidator:
right = await self._process_rows(rows[midpoint:])
return left.merge(right)
+ for row in rows:
+ self._judge_rejections.pop(row.id, None)
deferred, transient = await self._execute(
rows,
decisions,
@@ -294,6 +324,36 @@ class Consolidator:
transient=transient,
)
+ def _in_rejection_backoff(self, row_id: int) -> bool:
+ """True while a judge-rejected row waits out its escalating backoff."""
+ history = self._judge_rejections.get(row_id)
+ if history is None:
+ return False
+ rounds, last_ts = history
+ return (time.monotonic() - last_ts) < self._JUDGE_REJECTION_BACKOFF_S * rounds
+
+ def _note_judge_rejection(self, row: JournalRow) -> None:
+ """Record one all-provider judge rejection; park the row at the cap.
+
+ ``skipped`` (not ``rejected``) because the JUDGE never produced a
+ valid decision — the fact itself was not weighed and a backfill or
+ the next process life may still consolidate it.
+ """
+ rounds = self._judge_rejections.get(row.id, (0, 0.0))[0] + 1
+ if rounds >= self._MAX_JUDGE_REJECTION_ROUNDS:
+ self._judge_rejections.pop(row.id, None)
+ self._journal.mark([row.id], status="skipped")
+ telemetry.inc("wiki_consolidator_parked_judge_wedge")
+ log.warning(
+ "Consolidator: parking candidate %d as skipped after %d "
+ "judge-rejected rounds — every provider kept answering with "
+ "invalid decisions; a backfill can re-queue it",
+ row.id,
+ rounds,
+ )
+ return
+ self._judge_rejections[row.id] = (rounds, time.monotonic())
+
# ------------------------------------------------------------------
# retrieval
# ------------------------------------------------------------------
diff --git a/jarvis/memory/wiki/prompt.py b/jarvis/memory/wiki/prompt.py
index 34aaa86147..91793d0b5b 100644
--- a/jarvis/memory/wiki/prompt.py
+++ b/jarvis/memory/wiki/prompt.py
@@ -515,6 +515,13 @@ Decision semantics:
"target" and the page's complete "new_body" with the fact merged in.
MAKE THE SMALLEST CORRECT EDIT: every existing fact, section and link
of the shown body MUST survive unless the candidate directly corrects it.
+ Survival is checked LINE-FOR-LINE, not by meaning: copy every existing
+ line into "new_body" character-for-character and merge by ADDING new
+ lines. Never reword, merge, split, or reformat an existing line — even
+ when the new fact makes it look redundant. An overlapping old line plus
+ a new line is a valid page; a dropped or reworded old line rejects the
+ whole update. (Only a line the candidate directly contradicts may be
+ rewritten, and lines marked as inferred may be upgraded.)
- "noop": either the vault already knows this OR the candidate is not durable
enough to store (smalltalk, transient bodily/status chatter, weather,
assistant-only claims, commands with no separately asserted durable content,
diff --git a/tests/unit/memory/wiki/test_consolidator.py b/tests/unit/memory/wiki/test_consolidator.py
index 16607cc044..af27b08892 100644
--- a/tests/unit/memory/wiki/test_consolidator.py
+++ b/tests/unit/memory/wiki/test_consolidator.py
@@ -2527,3 +2527,89 @@ async def test_activity_candidate_requires_companion_concept_page(stack) -> None
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 profile
+
+
+# ---------------------------------------------------------------------------
+# Judge-rejection wedge: bounded retries instead of an endless provider burn
+# (live 2026-07-21: three poison rows re-judged the full chain for ~16 hours).
+# ---------------------------------------------------------------------------
+
+
+def _age_rejection(consolidator: Consolidator, cid: int) -> None:
+ """Move a recorded rejection outside its backoff window."""
+ rounds, _ts = consolidator._judge_rejections[cid]
+ consolidator._judge_rejections[cid] = (rounds, time.monotonic() - 1e9)
+
+
+async def test_judge_rejected_row_backs_off_before_the_next_round(stack) -> None:
+ _vault_root, _curator, journal = stack
+ journal.append(
+ [CandidateFact(fact="Lena moved to Hamburg.", kind="person", subjects=("lena",))],
+ source_label="voice-fact:1", turn_hash="h1",
+ )
+ brain = FakeBrain(["not json at all", "still not json"])
+ consolidator = _consolidator(stack, brain)
+
+ first = await consolidator.run_once()
+ second = await consolidator.run_once()
+
+ assert first.startswith("judge-rejected")
+ assert second == "journal-rejection-backoff:1"
+ # The backoff round never reached a provider.
+ assert len(brain.received_requests) == 1
+ assert journal.backlog_count() == 1 # still pending, only cooling down
+
+
+async def test_repeatedly_rejected_row_is_parked_as_skipped(stack) -> None:
+ _vault_root, _curator, journal = stack
+ journal.append(
+ [CandidateFact(fact="Lena moved to Hamburg.", kind="person", subjects=("lena",))],
+ source_label="voice-fact:1", turn_hash="h1",
+ )
+ cid = journal.pending()[0].id
+ brain = FakeBrain(["junk 1", "junk 2", "junk 3", "never reached"])
+ consolidator = _consolidator(stack, brain)
+
+ for _round in range(consolidator._MAX_JUDGE_REJECTION_ROUNDS - 1):
+ label = await consolidator.run_once()
+ assert label.startswith("judge-rejected")
+ _age_rejection(consolidator, cid)
+ final = await consolidator.run_once()
+
+ assert final.startswith("judge-rejected")
+ assert journal.backlog_count() == 0 # parked, no longer retried
+ assert journal.pending() == []
+ assert cid not in consolidator._judge_rejections
+ assert len(brain.received_requests) == consolidator._MAX_JUDGE_REJECTION_ROUNDS
+
+
+async def test_valid_verdict_clears_the_rejection_history(stack) -> None:
+ vault_root, _curator, journal = stack
+ journal.append(
+ [CandidateFact(fact="Lena moved to Hamburg.", kind="person", subjects=("lena",))],
+ source_label="voice-fact:1", turn_hash="h1",
+ )
+ cid = journal.pending()[0].id
+ brain = FakeBrain([
+ "garbled",
+ _judge_json([{
+ "candidate_id": cid,
+ "decision": "add",
+ "target": "entities/lena.md",
+ "new_body": LENA_BODY,
+ "reason": "new person",
+ }]),
+ ])
+ consolidator = _consolidator(stack, brain)
+
+ first = await consolidator.run_once()
+ _age_rejection(consolidator, cid)
+ second = await consolidator.run_once()
+
+ assert first.startswith("judge-rejected")
+ assert second == "journal-batch:1"
+ assert (vault_root / "entities" / "lena.md").is_file()
+ assert consolidator._judge_rejections == {}