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): a curation content verdict must not raise the provider chain-failure banner

Ruben Lütke11046188663d
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.py
index 744b053d6b..a86ea25730 100644
--- a/jarvis/memory/wiki/consolidator.py
+++ b/jarvis/memory/wiki/consolidator.py
@@ -476,6 +476,14 @@ class Consolidator:
),
)
rejection_reasons: list[str] = []
+ # Reasons where the model produced WELL-FORMED JSON but the judged
+ # decision merely violated a curation rule (companion page missing,
+ # update-removes-content, unsupported numeric). Truncated / unparseable
+ # output is NOT in here — that is provider-output damage. A content
+ # verdict means the provider is healthy, so the chain must neither cool
+ # it down nor raise a chain-failure banner for it (see
+ # ``complete_with_fallback(content_verdict=...)``).
+ content_verdict_reasons: set[str] = set()
def _validate_response(agg: Any) -> str | None:
if is_length_truncated(agg.finish_reason, agg.text):
@@ -494,6 +502,7 @@ class Consolidator:
reason = self._validate_decisions(parsed, rows, neighbours=neighbours)
if reason is not None:
rejection_reasons.append(reason)
+ content_verdict_reasons.add(reason)
return reason
return None
@@ -505,6 +514,7 @@ class Consolidator:
label="Consolidator",
aggregate=aggregate,
validate=_validate_response,
+ content_verdict=lambda reason: reason in content_verdict_reasons,
)
if result is None:
if any(reason.startswith("truncated") for reason in rejection_reasons):
diff --git a/jarvis/memory/wiki/provider_chain.py b/jarvis/memory/wiki/provider_chain.py
index ad49689625..86ca1ff9ed 100644
--- a/jarvis/memory/wiki/provider_chain.py
+++ b/jarvis/memory/wiki/provider_chain.py
@@ -232,6 +232,7 @@ async def complete_with_fallback(
validate: Callable[[Any], str | None] | None = None,
allow_last_rejection: Callable[[str], bool] | None = None,
allow_lone_rejection: Callable[[str], bool] | None = None,
+ content_verdict: Callable[[str], bool] | None = None,
) -> tuple[Any, str] | None:
"""Try each ``(provider, model)`` until one returns an aggregated response.
@@ -247,6 +248,19 @@ async def complete_with_fallback(
opinion available — is accepted as final; a reason outside it stays a
retryable failure, so one weak provider can never be terminal proof that
a transcript held no facts.
+
+ ``content_verdict`` classifies a ``validate`` rejection as a deterministic
+ CURATION verdict on WELL-FORMED output (e.g. "companion page missing",
+ "update removes existing content") as opposed to a broken RESPONSE
+ (truncated / unparseable JSON) or a transport failure. A provider hitting a
+ content verdict is HEALTHY — it answered; only the judged decision violated
+ a curation rule. Such a rejection therefore (1) does NOT cool the provider
+ down and (2) does NOT paint the red 'Chain failure' banner: a banner is a
+ PROVIDER-health signal, and one un-consolidatable candidate is not provider
+ damage. The caller's own bounded retry/park handles the candidate quietly.
+ Live 2026-07-23: a single mis-kinded 'cloudflare-plugin' activity candidate
+ demanded a companion page no provider produced, wedging the chain and
+ listing all 8 providers as broken on every journal trigger.
"""
from jarvis.memory.wiki.curator_llm import instantiate_curator_brain
@@ -255,6 +269,10 @@ async def complete_with_fallback(
# record (spec A5) so "openai 401; gemini 429" is visible, not just a
# generic "ALL N failed" count.
failure_summaries: list[str] = []
+ # Healthy providers whose WELL-FORMED answer only failed a curation rule.
+ # Kept out of ``failure_summaries`` so they never cool a provider down or
+ # reach the chain-failure banner (see ``content_verdict`` above).
+ content_rejections: list[str] = []
allowed_rejection_fallback: tuple[Any, str, str] | None = None
ordered, demoted = _order_by_cooldown(chain)
@@ -359,6 +377,31 @@ async def complete_with_fallback(
safe_rejection,
)
continue
+ if content_verdict is not None and content_verdict(rejection):
+ # Well-formed answer, curation rule violated: the
+ # provider is healthy. Record it for the log, but never
+ # cool it down or count it as chain damage — that is
+ # what wedged the chain and lit the banner for one
+ # un-consolidatable candidate.
+ content_rejections.append(
+ f"{provider} rejected content: {safe_rejection}"
+ )
+ log.info(
+ "%s: provider %s answered but its decision failed a "
+ "curation rule (%s) - trying next provider",
+ label,
+ provider,
+ safe_rejection,
+ )
+ try:
+ telemetry.inc("wiki_provider_output_rejected")
+ except Exception: # noqa: BLE001 - telemetry cannot break fallback
+ log.debug(
+ "%s: output-rejection telemetry failed",
+ label,
+ exc_info=True,
+ )
+ continue
log.warning(
"%s: provider %s returned unusable output (%s) - "
"trying next provider",
@@ -420,6 +463,29 @@ async def complete_with_fallback(
# chain ends as a retryable failure instead of terminal proof.
failure_summaries.append(f"{provider} unusable output: {safe_rejection}")
+ # A red 'Chain failure' banner is a PROVIDER-health signal ("the wiki
+ # pipeline could not reach a working model"). If ANY provider answered
+ # healthily and was rejected only on curation content, the pipeline is not
+ # bricked — a normal fact would have been written — so this is one
+ # un-consolidatable candidate, not provider damage. Suppress the banner
+ # (the caller's bounded park retires the candidate quietly) even when other
+ # rungs were genuinely dead: their 401/timeout is a separate, constant
+ # state surfaced on the API-keys health tab, not a reason to relabel a
+ # working chain as failed. Only a chain with NO healthy answer at all
+ # (below) is a real chain failure.
+ if content_rejections:
+ detail = "; ".join(content_rejections)
+ if failure_summaries:
+ detail += f" | dead rungs (not banner-worthy): {'; '.join(failure_summaries)}"
+ log.info(
+ "%s: chain wrote nothing, but at least one provider answered and was "
+ "rejected only on content (%s). Providers healthy — no chain-failure "
+ "recorded.",
+ label,
+ safe_preview(detail, max_chars=800),
+ )
+ return None
+
log.error(
"%s: ALL %d wiki provider(s) failed or returned unusable output — "
"nothing was written. Check provider health and structured-output logs.",
diff --git a/tests/unit/memory/wiki/test_consolidator.py b/tests/unit/memory/wiki/test_consolidator.py
index af27b08892..b7a0d16245 100644
--- a/tests/unit/memory/wiki/test_consolidator.py
+++ b/tests/unit/memory/wiki/test_consolidator.py
@@ -1718,6 +1718,62 @@ async def test_noop_on_graph_visible_fact_without_topic_page_is_accepted(stack)
assert not (vault_root / "entities" / "wiki-system.md").exists()
+async def test_companion_page_verdict_paints_no_chain_failure_banner(
+ stack, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """A mis-kinded graph-visible candidate whose companion page no provider
+ creates is a CONTENT problem, not provider damage. Every healthy provider
+ answering with the same companion-page verdict must NOT light the red
+ 'Chain failure' banner — the live 2026-07-23 'cloudflare-plugin' activity
+ wedge listed all 8 providers as broken on every journal trigger while the
+ providers were fine and only one fact was un-consolidatable."""
+ from jarvis.memory.wiki import health as health_module
+ from jarvis.memory.wiki import provider_chain as pc
+ from jarvis.memory.wiki.health import WikiHealth
+
+ pc.reset_provider_failure_memory()
+ isolated_health = WikiHealth()
+ monkeypatch.setattr(health_module, "health", isolated_health)
+
+ vault_root, _curator, journal = stack
+ journal.append(
+ [CandidateFact(
+ fact="The user actively uses a Cloudflare plugin.",
+ kind="activity", subjects=("user", "cloudflare-plugin"),
+ )],
+ source_label="realtime-session-sweep:cf", turn_hash="h-cf",
+ )
+ cid = journal.pending()[0].id
+ assert not (vault_root / "concepts" / "cloudflare-plugin.md").exists()
+
+ # Every provider answers WELL-FORMED JSON but routes the fact to a related
+ # page instead of creating the required concepts/cloudflare-plugin.md
+ # companion — so the graph-visibility rule rejects each one identically.
+ verdict_body = _judge_json([{
+ "candidate_id": cid,
+ "decision": "add",
+ "target": "concepts/cloudflare.md",
+ "new_body": (
+ "---\ntype: concept\nslug: cloudflare\n---\n\n"
+ "## Summary\n\nA content-delivery and security service.\n"
+ ),
+ "reason": "related concept",
+ }])
+ registry = ScriptedProviderRegistry(
+ {"gemini": verdict_body, "codex": verdict_body, "grok": verdict_body}
+ )
+ consolidator = _consolidator(stack, FakeBrain([]), registry=registry)
+
+ label = await consolidator.run_once()
+
+ # The candidate is judge-rejected (bounded park handles it), but the
+ # PROVIDER-health banner must stay clear: the providers are healthy.
+ assert label == "judge-rejected:1"
+ assert registry.tried == ["gemini", "codex", "grok"] # every provider asked
+ assert isolated_health.snapshot()["last_chain_failure"] is None
+
+
@pytest.mark.asyncio
async def test_topic_question_candidate_is_presented_to_stage2_as_noop(stack) -> None:
vault_root, _curator, journal = stack
diff --git a/tests/unit/memory/wiki/test_provider_chain.py b/tests/unit/memory/wiki/test_provider_chain.py
index 7024acf6f1..183d220b4b 100644
--- a/tests/unit/memory/wiki/test_provider_chain.py
+++ b/tests/unit/memory/wiki/test_provider_chain.py
@@ -466,6 +466,99 @@ async def test_chain_success_clears_the_sticky_health_failure(
assert isolated_health.snapshot()["last_chain_failure"] is None
+# --- content verdict != provider failure -------------------------------------
+
+
+async def test_content_verdict_from_healthy_provider_raises_no_chain_failure(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """A curation CONTENT verdict (companion page missing) on WELL-FORMED output
+ means the provider is HEALTHY — it answered, only the judged decision broke a
+ rule. It must neither cool the provider down nor paint the red 'Chain failure'
+ banner. Live 2026-07-23: a single mis-kinded 'cloudflare-plugin' activity
+ demanded a companion page no provider produced, wedging the chain and listing
+ all 8 providers as broken on every journal trigger."""
+ from jarvis.memory.wiki import health as health_module
+ from jarvis.memory.wiki import provider_chain as pc
+ from jarvis.memory.wiki.health import WikiHealth
+
+ pc.reset_provider_failure_memory()
+ isolated_health = WikiHealth()
+ monkeypatch.setattr(health_module, "health", isolated_health)
+
+ verdict = (
+ "graph-visible fact is missing its required companion page: "
+ "concepts/cloudflare-plugin.md"
+ )
+ reg = _ScriptedRegistry({"codex": "[]", "grok": "[]"})
+ result = await complete_with_fallback(
+ registry=reg,
+ chain=[("codex", None), ("grok", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="Consolidator",
+ aggregate=_aggregate,
+ validate=lambda _agg: verdict,
+ content_verdict=lambda reason: reason == verdict,
+ )
+ assert result is None # nothing consolidatable this round
+ assert reg.tried == ["codex", "grok"] # every provider still asked
+ # The banner is a PROVIDER-health signal; healthy providers stay off it.
+ assert isolated_health.snapshot()["last_chain_failure"] is None
+ assert not pc._in_cooldown("codex") # not demoted for the next 15 minutes
+ assert not pc._in_cooldown("grok")
+
+
+async def test_healthy_content_verdict_suppresses_banner_beside_dead_rungs(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The live screenshot mixed real failures (claude-api 401, openai 429,
+ timeouts) with content verdicts (codex/grok companion-page). As long as ONE
+ provider answered healthily, the pipeline is not bricked — a normal fact
+ would have been written — so no chain-failure banner, even beside genuinely
+ dead rungs (whose 401/timeout is a separate, constant state)."""
+ from jarvis.memory.wiki import health as health_module
+ from jarvis.memory.wiki import provider_chain as pc
+ from jarvis.memory.wiki.health import WikiHealth
+
+ pc.reset_provider_failure_memory()
+ isolated_health = WikiHealth()
+ monkeypatch.setattr(health_module, "health", isolated_health)
+
+ verdict = (
+ "graph-visible fact is missing its required companion page: "
+ "concepts/cloudflare-plugin.md"
+ )
+
+ class _MixedRegistry:
+ def __init__(self) -> None:
+ self.tried: list[str] = []
+
+ def instantiate(self, name: str, **_kwargs: Any) -> Any:
+ self.tried.append(name)
+ return _FakeBrain(fail=name == "openai") # openai is a dead rung
+
+ reg = _MixedRegistry()
+ result = await complete_with_fallback(
+ registry=reg,
+ chain=[("codex", None), ("openai", None), ("grok", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="Consolidator",
+ aggregate=_aggregate,
+ validate=lambda agg: verdict if agg.text == "chunk" else None,
+ content_verdict=lambda reason: reason == verdict,
+ )
+ assert result is None
+ assert reg.tried == ["codex", "openai", "grok"] # tried all three
+ assert isolated_health.snapshot()["last_chain_failure"] is None # no banner
+ assert not pc._in_cooldown("codex") # healthy providers uncooled
+ assert not pc._in_cooldown("grok")
+ assert pc._in_cooldown("openai") # the genuinely dead rung IS cooled
+
+
# --- failure cooldown: dead rungs stop taxing every call ---------------------