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(brain): evidence gate must never overrule a matched plugin-skill turn

Ruben Lütke230b99bad13e
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index 2cceeb7441..b1a43d5032 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -4094,6 +4094,24 @@ class BrainManager:
"""
from jarvis.brain.evidence_gate import EvidenceVerdict, check_evidence_domain
+ # AD-S3 (a matched skill IS the capability): a deterministically
+ # skill-matched turn already proves an installed integration owns this
+ # request — the gate must never overrule it. Live 2026-07-18 (voice
+ # session 18:31): the paired-capability sync had not reached this
+ # process' CapabilityRegistry, so a CONNECTED Google Calendar plugin
+ # turn — freshly matched to plugin-google_calendar — still got the
+ # deterministic "Ich habe aktuell keinen Kalenderzugriff" refusal # i18n-allow: quoted live refusal under discussion
+ # plus a CLI-setup detour. With the skill match as evidence the turn
+ # proceeds; a genuinely dead plugin still fails honestly through its
+ # tool's own "not connected" result.
+ if getattr(self, "_skill_turn_match", None) is not None:
+ log.info(
+ "Evidence gate stood down: turn is owned by matched skill %s "
+ "(AD-S3: a matched skill IS the capability)",
+ getattr(self._skill_turn_match, "name", "?"),
+ )
+ return EvidenceVerdict(kind="pass")
+
try:
cfg = self._config.brain.evidence_domains
if not cfg.enabled:
@@ -7538,7 +7556,9 @@ class BrainManager:
# from the model's head. Either a connected CLI covers the domain
# (mandatory-tool directive for this turn) or the answer is a
# deterministic honest refusal. Pure regex + registry lookup, no LLM
- # (AP-11). Skill turns already returned above; non-CLI capabilities
+ # (AP-11). Only MISSION skill turns returned above — an inline
+ # plugin-skill turn reaches this point, so _run_evidence_gate itself
+ # stands down on a matched skill (AD-S3); non-CLI capabilities
# (paired skills, router tools, MCP) make the gate stand down (PASS).
verdict = self._run_evidence_gate(user_text)
if verdict.kind == "honest_refusal":
diff --git a/jarvis/brain/tool_use_loop.py b/jarvis/brain/tool_use_loop.py
index 93334ebf6f..5de3b49727 100644
--- a/jarvis/brain/tool_use_loop.py
+++ b/jarvis/brain/tool_use_loop.py
@@ -358,15 +358,17 @@ _ARG_MAXLEN: dict[str, tuple[str, int]] = {
def _canonical_tool_name(name: str) -> str:
- """Hyphen/underscore- and case-insensitive canonical form of a tool name.
+ """Separator- and case-insensitive canonical form of a tool name.
The registered tool surface mixes naming conventions (``wiki-recall`` vs
``run_shell``), so models cross-normalize and invent the OTHER spelling of a
- real tool (live incident 2026-07-05: gemini called ``run-shell``). Both
- spellings collapse to one canonical key so an unambiguous variant still
- resolves to the registered tool instead of the missing-tool refusal.
+ real tool (live incident 2026-07-05: gemini called ``run-shell``). Dots are
+ folded too: the system prompt advertises CapabilityRegistry ids like
+ ``cli.gcloud`` whose registered tool is ``cli_gcloud``. All spellings
+ collapse to one canonical key so an unambiguous variant still resolves to
+ the registered tool instead of the missing-tool refusal.
"""
- return (name or "").strip().lower().replace("-", "_")
+ return (name or "").strip().lower().replace("-", "_").replace(".", "_")
def _is_stt_hallucinated(tool_name: str, args: Any) -> tuple[bool, str]:
@@ -459,6 +461,31 @@ class ToolUseLoop:
return tool, requested
alias = self._alias_map.get(_canonical_tool_name(requested))
if alias is None:
+ # Capability ids are NOT tool names, but the system prompt renders
+ # them verbatim (``skill.paired.<plugin>`` from the paired-skill
+ # coupling) and a model occasionally calls one as a tool (live
+ # 2026-07-18 18:15: 'skill.paired.google_calendar' hit the
+ # anti-silence fallback although the real ``google_calendar`` tool
+ # was registered). A paired capability id's tail IS the native
+ # tool / plugin id, so strip the namespace and resolve the rest.
+ try:
+ from jarvis.skills.plugin_coupling import PAIRED_CAP_PREFIX
+ except Exception: # noqa: BLE001 — resolution aid must never break the loop
+ PAIRED_CAP_PREFIX = "skill.paired."
+ if requested.startswith(PAIRED_CAP_PREFIX):
+ stripped = requested[len(PAIRED_CAP_PREFIX):]
+ tool = self._tools.get(stripped)
+ if tool is None:
+ inner = self._alias_map.get(_canonical_tool_name(stripped))
+ if inner is not None:
+ tool = self._tools.get(inner)
+ stripped = inner if tool is not None else stripped
+ if tool is not None:
+ log.info(
+ "tool_use_loop: model called capability id %r — "
+ "resolved to registered tool %r", requested, stripped,
+ )
+ return tool, stripped
return None, requested
tool = self._tools.get(alias)
if tool is None:
diff --git a/jarvis/skills/registry.py b/jarvis/skills/registry.py
index 39c30ced02..98072ebf70 100644
--- a/jarvis/skills/registry.py
+++ b/jarvis/skills/registry.py
@@ -326,7 +326,11 @@ class SkillRegistry:
sync_paired_capabilities(get_registry(), self.list())
except Exception: # noqa: BLE001
- log.debug("paired-capability sync failed", exc_info=True)
+ # WARNING, not debug: a silently missing sync leaves the evidence
+ # gate blind to every connected plugin domain for the whole
+ # process lifetime ("no calendar access" on a connected calendar,
+ # live 2026-07-17 and 2026-07-18) — that must be visible in logs.
+ log.warning("paired-capability sync failed", exc_info=True)
def _emit_reloaded(self) -> None:
if self.bus is None:
diff --git a/tests/unit/brain/test_evidence_gate_wiring.py b/tests/unit/brain/test_evidence_gate_wiring.py
index ddf0357df9..da2af8403b 100644
--- a/tests/unit/brain/test_evidence_gate_wiring.py
+++ b/tests/unit/brain/test_evidence_gate_wiring.py
@@ -54,6 +54,33 @@ def test_run_evidence_gate_refuses_without_any_integration(monkeypatch):
assert verdict.kind == "honest_refusal"
+def test_run_evidence_gate_stands_down_on_matched_skill_turn(monkeypatch):
+ """AD-S3: a deterministically matched skill IS the capability — the gate
+ must never overrule it. Live 2026-07-18 (voice 18:31): the paired-
+ capability sync had not reached the serving process' CapabilityRegistry,
+ so a CONNECTED Google Calendar plugin turn — freshly matched to
+ plugin-google_calendar — was answered with the deterministic
+ "no calendar access" refusal plus a CLI-setup detour."""
+ import jarvis.clis.shared as shared
+ import jarvis.core.capabilities as cap_mod
+
+ m = _bare_manager()
+ m._config = SimpleNamespace(
+ brain=SimpleNamespace(
+ evidence_domains=SimpleNamespace(
+ enabled=True,
+ domains={"calendar": ["kalender", "steht heute"]},
+ )
+ )
+ )
+ monkeypatch.setattr(shared, "get_active_registry", lambda: None)
+ # Empty capability registry — exactly the live failure state:
+ monkeypatch.setattr(cap_mod, "get_registry", lambda: cap_mod.CapabilityRegistry())
+ m._skill_turn_match = SimpleNamespace(name="plugin-google_calendar")
+ verdict = m._run_evidence_gate("Kannst du mal meinen Kalender vorlesen?")
+ assert verdict.kind == "pass"
+
+
def test_run_evidence_gate_disabled_passes():
m = _bare_manager()
m._config = SimpleNamespace(
diff --git a/tests/unit/brain/test_tool_use_loop.py b/tests/unit/brain/test_tool_use_loop.py
index d314ffeb3c..90d5cc303b 100644
--- a/tests/unit/brain/test_tool_use_loop.py
+++ b/tests/unit/brain/test_tool_use_loop.py
@@ -481,6 +481,57 @@ async def test_underscore_alias_resolves_to_hyphenated_tool() -> None:
assert "wiki-recall" in result.executed_tool_names
+async def test_paired_capability_id_resolves_to_native_tool() -> None:
+ """A ``skill.paired.<plugin>`` capability id called as a tool must execute
+ the registered native tool (live 2026-07-18 18:15: gemini called
+ 'skill.paired.google_calendar' — advertised verbatim by the capability
+ prompt block — and the turn fell into the anti-silence fallback although
+ the real ``google_calendar`` tool sat registered)."""
+
+ class _CalendarTool:
+ name = "google_calendar"
+ schema: dict[str, Any] = {}
+
+ brain = _AliasCallingBrain("skill.paired.google_calendar")
+ executor = _ExecOK()
+ loop = ToolUseLoop(
+ brain,
+ {"google_calendar": _CalendarTool(), "run_shell": _RunShellTool()},
+ executor, # type: ignore[arg-type]
+ )
+
+ result = await loop.run([], user_utterance="lies meinen Kalender vor") # i18n-allow: German utterance fixture under test
+
+ assert executor.calls, "the capability id must resolve to the native tool"
+ assert executor.calls[0][0].name == "google_calendar"
+ assert "google_calendar" in result.executed_tool_names
+
+
+async def test_dotted_cli_capability_id_resolves_to_cli_tool() -> None:
+ """``cli.<name>`` (the CLI capability id) must resolve to the registered
+ ``cli_<name>`` tool via the dot-folding canonical alias."""
+
+ class _GcloudTool:
+ name = "cli_gcloud"
+ schema: dict[str, Any] = {}
+
+ brain = _AliasCallingBrain("cli.gcloud")
+ executor = _ExecOK()
+ loop = ToolUseLoop(
+ brain,
+ {"cli_gcloud": _GcloudTool()},
+ executor, # type: ignore[arg-type]
+ )
+
+ result = await loop.run([], user_utterance="list my gcloud projects")
+
+ assert executor.calls, "'cli.gcloud' must resolve to the registered 'cli_gcloud'"
+ assert executor.calls[0][0].name == "cli_gcloud"
+ assert "cli_gcloud" in result.executed_tool_names
+
+
class _ExecWithDeniedLog(_ExecOK):
"""Executor fake that records guard-denied publications (Task-3 contract)."""