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
feat(brain): deterministic run_shell mandate for natural file/system requests
rubenluetke10-beepa59467824e43
diff --git a/jarvis/brain/local_outcome_gate.py b/jarvis/brain/local_outcome_gate.pynew file mode 100644index 0000000000..6ba61fece1--- /dev/null+++ b/jarvis/brain/local_outcome_gate.py@@ -0,0 +1,171 @@+"""Local-outcome gate — say-do guard for local file/folder/system actions.++Why this exists+---------------+Maintainer report (2026-08-08): "Erstell einen neuen Ordner auf meinem+Desktop" was answered with the dictated capability refusal ("mir fehlt das+passende Werkzeug") although ``run_shell`` was registered AND visible in the+turn's tool surface. Root cause: the ``tool.run-shell`` capability vocabulary+only matched users who NAME the vehicle (shell/terminal/befehl), and no+deterministic mandate backed natural outcome phrasings — whether the model+mapped "create a folder" onto a shell command was model whim (a timer request+worked one day, a folder request was refused the next).++This module mirrors ``contact_intent.resolve_save_mandate`` (the say-do write+guard) and ``evidence_gate.py`` (the read guard): it spots, deterministically,+that a turn wants a LOCAL file/folder/system outcome, so the manager can+mandate ``run_shell`` for the turn — the prompt directive makes the call+non-optional, and the existing unverified-answer backstop replaces a fake+"done" with an honest line when the tool never ran. Pure regex + the shared+normalizer — NO LLM, NO IO (AP-9/AP-11).++The German phrases quoted above and in the vocabulary below are speech-input+matching data / forensic quotes of the failing voice requests (i18n-allow+rationale identical to ``local_action_gate.py``).++Matching contract+-----------------+A mandate needs BOTH an outcome verb ("erstell", "loesch", "rename", …) AND a+file-system object ("ordner", "datei", "folder", "desktop", …) — the noun is+what separates "erstell einen Ordner" (shell) from "erstell einen+Kalendereintrag" (plugin/calendar flow, untouched).++Stand-downs (each defers to the flow that owns the turn):+ - external-integration dispatch ("schick die Datei per Mail") — the+ capability/plugin machinery owns it;+ - cloud storage nouns (Drive/Dropbox/OneDrive/…) — not a local disk;+ - how-to / definition questions ("wie erstelle ich einen Ordner") — an+ inline answer, never an action;+ - explicit GUI vehicle ("klick auf den Ordner") — computer-use owns the+ screen when the user asks for it;+ - explicit heavy vehicle ("spawn"/"subagent") or a named skill — AD-S9:+ a user-named vehicle always wins.+"""++from __future__ import annotations++import re++from jarvis.brain.local_action_gate import requires_external_integration+from jarvis.core.capabilities import _normalize++# Outcome verbs (already umlaut-normalised — matched on ``_normalize`` output).+# ``\w*`` suffixes cover the German conjugations; the stems are chosen so the+# common imperative/infinitive forms all start with them.+_FS_VERB_RE = re.compile(+ r"\b(?:"+ r"erstell\w*|anleg\w*|create|mkdir|" # i18n-allow+ r"loesch\w*|entfern\w*|delete|remove|" # i18n-allow+ r"umbenenn\w*|benenn\w*|rename|" # i18n-allow+ r"verschieb\w*|schieb\w*|move|" # i18n-allow+ r"kopier\w*|copy|dupliz\w*|duplicate|" # i18n-allow+ r"entpack\w*|unzip|zipp\w*|zip|komprimier\w*|extract|pack\w*|" # i18n-allow+ r"liste\w*|list|zeig\w*|show|" # i18n-allow+ r"oeffn\w*|open|aufmach\w*|" # i18n-allow+ r"lies|lese|liest|read|vorles\w*|" # i18n-allow+ r"leg\w*|mach\w*|make|" # i18n-allow+ r"fuehr\w*|ausfuehr\w*|run|execute|start\w*" # i18n-allow+ r")\b"+)++# File-system / shell objects. Includes the legacy vehicle nouns (shell,+# terminal, skript, …) so "fuehr das Skript aus" mandates exactly like the+# outcome phrasings do. Deliberately NOT included: bilder/pictures/musik+# ("zeig mir Bilder von Katzen" is a search, not a directory listing) and+# domain nouns owned by other flows (termin, kontakt, mail, wiki).+_FS_OBJECT_RE = re.compile(+ r"\b(?:"+ r"ordner|unterordner|verzeichnis\w*|datei(?:en)?|" # i18n-allow+ r"folders?|director(?:y|ies)|files?|"+ r"desktop|downloads?|papierkorb|recycle\s+bin|" # i18n-allow+ r"archiv\w*|archive|zip|" # i18n-allow+ r"skript\w*|scripts?|befehl\w*|kommando\w*|commands?|" # i18n-allow+ r"terminal|shell|powershell|bash|cmd"+ r")\b"+)++# How-to / definition questions are answered inline, never acted on. Matched+# unanchored so a greeting prefix ("Hey Jarvis, wie erstelle ich …") cannot+# defeat the guard (mirrors the greeting-prefix lesson in _is_smalltalk).+_HOWTO_DEFINITION_RE = re.compile(+ r"\b(?:"+ r"wie\s+\w+\s+(?:ich|man)\b|" # i18n-allow+ r"how\s+(?:do|can|could|should|would)\s+(?:i|you|one)\b|how\s+to\b|"+ r"was\s+(?:ist|sind|bedeutet|heisst)\s+(?:ein|eine|der|die|das)\b|" # i18n-allow+ r"what\s+(?:is|are|does)\s+an?\b"+ r")"+)++# The user explicitly asks for the SCREEN to be operated — computer-use owns+# that vehicle (AD-S9: a named vehicle wins). "desktop" alone is NOT a GUI+# marker here: "auf meinem Desktop" names a folder location, not the screen.+_GUI_VEHICLE_RE = re.compile(+ r"\b(?:klick\w*|click\w*|maus|mouse|cursor|scroll\w*|per\s+hand)\b" # i18n-allow+)++# The user explicitly names a heavy-work or skill vehicle — those flows own+# the turn (AD-S9), the mandate must never fight them.+_OTHER_VEHICLE_RE = re.compile(+ r"\b(?:subagent\w*|sub-agents?|spawn\w*|worker|skills?|deep\s*dive)\b"+)++# Cloud storage is not the local disk — the plugin/CLI machinery owns it.+_CLOUD_STORAGE_RE = re.compile(+ r"\b(?:google\s*drive|gdrive|dropbox|onedrive|one\s*drive|icloud|"+ r"sharepoint|nextcloud|cloud)\b"+)++# Per-turn directive injected into the system prompt when the mandate fires+# (English — LLM-facing, mirrors CONTACT_WRITE_DIRECTIVE / the read gate).+RUN_SHELL_OUTCOME_DIRECTIVE = (+ "MANDATORY THIS TURN: the user asks for a local file/folder/system action "+ "on THIS computer (create/delete/rename/move/copy/list/read/open or "+ "similar). You MUST accomplish it NOW by calling the `run_shell` tool "+ "with a fitting command — write the command for the shell named in the "+ "tool description and quote paths that contain spaces. The user never "+ "needs to say 'terminal' or dictate a command; translating the outcome "+ "into a command is YOUR job. NEVER claim you lack a tool for this — "+ "`run_shell` IS the tool, and clicking through the GUI via computer_use "+ "is the wrong vehicle unless the user explicitly asked for the screen. "+ "Afterwards report what the tool result actually says: confirm on "+ "success, state the concrete error on failure. Only for an irreversible "+ "bulk delete/overwrite whose target is ambiguous, ask ONE short "+ "clarifying question instead of guessing."+)+++def resolve_local_outcome_mandate(utterance: str) -> tuple[str, str] | None:+ """Map a local file/folder/system request to ``(tool_name, directive)``.++ Returns ``("run_shell", RUN_SHELL_OUTCOME_DIRECTIVE)`` when the turn+ deterministically asks for a local outcome a shell command can achieve,+ ``None`` otherwise. Single consumption point: ``BrainManager.generate()``+ (exactly like ``resolve_save_mandate``).+ """+ raw = (utterance or "").strip()+ # Mirrors the force-spawn minimum-length gate: shorter fragments are+ # Whisper artefacts, not commands.+ if len(raw) < 6:+ return None+ t = _normalize(raw)+ if _HOWTO_DEFINITION_RE.search(t):+ return None+ if _GUI_VEHICLE_RE.search(t) or _OTHER_VEHICLE_RE.search(t):+ return None+ if _CLOUD_STORAGE_RE.search(t):+ return None+ # External dispatch ("schick … per Mail") — checked on the RAW text,+ # the detector does its own normalisation.+ if requires_external_integration(raw):+ return None+ if not _FS_OBJECT_RE.search(t):+ return None+ if not _FS_VERB_RE.search(t):+ return None+ return ("run_shell", RUN_SHELL_OUTCOME_DIRECTIVE)+++__all__ = [+ "RUN_SHELL_OUTCOME_DIRECTIVE",+ "resolve_local_outcome_mandate",+]diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 9ec881631f..be1d1e77da 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -1602,6 +1602,22 @@ _ACTION_UNFULFILLED_PHRASES: dict[str, dict[str, str]] = {"Todavía no lo he anotado en tu wiki — dímelo otra vez y lo escribo."),},+ # Local-outcome mandate (shell-consistency rework 2026-08-08): a mandated+ # run_shell that never ran must not degrade to the contact wording.+ "run_shell": {+ "de": (+ "Das hab ich noch nicht ausgeführt — der Befehl ist nicht " # i18n-allow: German TTS+ "gelaufen. Sag's noch mal, dann mache ich es direkt." # i18n-allow: German TTS+ ),+ "en": (+ "I haven't actually done that yet — the command never ran. "+ "Say it once more and I'll do it right away."+ ),+ "es": (+ "Todavía no lo he hecho — el comando no llegó a ejecutarse. "+ "Dímelo otra vez y lo hago directamente."+ ),+ },}# A write tool with no bespoke table reuses the contact wording's shape._ACTION_UNFULFILLED_DEFAULT = _ACTION_UNFULFILLED_PHRASES["contact-upsert"]@@ -9852,6 +9868,34 @@ class BrainManager:_save_mandate[0],)+ # Say-do guard for LOCAL OUTCOMES (shell-consistency rework 2026-08-08).+ # A natural file/folder/system request ("erstell einen Ordner auf dem+ # Desktop") used to reach the LLM with run_shell merely OPTIONAL:+ # whether the model mapped the outcome onto a shell command was model+ # whim, and the capability block's "never invent tools" rule biased it+ # towards the dictated refusal ("mir fehlt das passende Werkzeug")+ # although the tool was registered and visible (maintainer report+ # 2026-08-08 — a timer request worked, a folder request refused).+ # Mirror the save mandate above: deterministically mandate run_shell so+ # the directive + honest write backstop turn "sometimes works" into+ # "always works or fails honestly". Never overrides an earlier mandate+ # (read evidence / save — those are more specific), and degrades to no+ # mandate when run_shell is not registered (§3 open-source).+ if not self._evidence_required_tool:+ from jarvis.brain.local_outcome_gate import resolve_local_outcome_mandate++ _local_mandate = resolve_local_outcome_mandate(user_text)+ if _local_mandate is not None and _local_mandate[0] in (+ getattr(self, "_tools", None) or {}+ ):+ self._evidence_directive = _local_mandate[1]+ self._evidence_required_tool = _local_mandate[0]+ self._evidence_required_is_write = True+ log.info(+ "Local-outcome guard: file/system intent — mandating %s this turn",+ _local_mandate[0],+ )+# Phase 5 / ADR-0006: pre-call budget gate. Block rather than request# when cooldown is active or the task/daily budget is exhausted.trace_uuid = turn_trace_id@@ -10794,6 +10838,18 @@ class BrainManager:if injected:return injected+ # A turn under a WRITE mandate is an ACTION turn, not a vision turn+ # (shell-consistency rework 2026-08-08): an attached image zeroes the+ # tool surface downstream (screen_context.has_image → tools={}), which+ # would blind the very tool the mandate requires. "erstell einen Ordner+ # hier auf dem Desktop" carries the visual marker "hier auf" yet wants+ # a shell action, not a screen answer — same for a mandated contact/+ # wiki write. Read mandates are untouched (they never attach anyway:+ # their data comes from the mandated tool, not the screen).+ if getattr(self, "_evidence_required_is_write", False):+ log.info("Vision-Inject skipped: write-mandate action turn")+ return ()+vision = getattr(self, "_vision_provider", None)vision_none = vision is Nonepaused = (diff --git a/jarvis/brain/router.py b/jarvis/brain/router.pyindex 00b85a9a7c..db92ba804c 100644--- a/jarvis/brain/router.py+++ b/jarvis/brain/router.py@@ -336,7 +336,15 @@ Du sortierst jede Ruben-Nachricht in genau eine von drei Kategorien:computer_use only when Ruben explicitly wants the screen, an app, orthe browser OPERATED ("oeffne...", "klick...", "geh im Browserauf..."). A deterministic gate enforces this and will reject the call.- - Shell-Kommando: "ls im Desktop", "starte notepad" (run_shell)+ - Shell-Kommando (run_shell): JEDES lokale Datei-/Ordner-/System-Ergebnis,+ auch wenn Ruben NIE "Terminal" sagt — "erstell einen Ordner auf dem+ Desktop", "benenn die Datei um", "loesch die Zip im Downloads-Ordner",+ "ls im Desktop", "starte notepad", "setz einen Timer". Du uebersetzt+ das gewuenschte ERGEBNIS selbst in ein Kommando; Ruben diktiert keine+ Befehle. NIEMALS "mir fehlt das Werkzeug" fuer lokale Datei-/System-+ Aufgaben antworten — run_shell IST das Werkzeug dafuer. Explorer-+ Klickerei via computer_use nur, wenn Ruben AUSDRUECKLICH den Bildschirm+ bedient haben will.- Bildschirm beschreiben: "was siehst du auf meinem Screen" (screenshot)- "merk dir X": KEIN Tool — beginne deine Antwort mit demBestaetigungswort in deiner Antwortsprache ("Notiert"/"Noted"/"Anotado",diff --git a/jarvis/core/capabilities.py b/jarvis/core/capabilities.pyindex 8ace09ccd2..0b988fd5d7 100644--- a/jarvis/core/capabilities.py+++ b/jarvis/core/capabilities.py@@ -88,6 +88,13 @@ _UNIVERSAL_ACTION_VERBS: frozenset[str] = frozenset({# "stop"/"stoppe" (also matches "stopp"/"stoppen") and "anhalt"/"anhalte"."anhalt", "anhalte", "halte", "stop", "stoppe","loesch", "loesche", "loescht", "delete", "remove",+ # Outcome verbs for local file/folder actions (shell-consistency rework+ # 2026-08-08): "erstell einen Ordner" carried no action verb at all, so+ # has_action_intent returned False and the turn was treated as signalless.+ "erstell", "erstelle", "anleg", "anlege", "create",+ "umbenenn", "umbenenne", "benenn", "benenne", "rename",+ "kopier", "kopiere", "copy", "verschieb", "verschiebe", "move",+ "entpack", "entpacke", "unzip","speichere", "speicher", "speichert", "save","frag", "frage", "fragt", "ask","antwort", "antworte", "antwortet", "reply", "respond",diff --git a/jarvis/core/capabilities_seed.py b/jarvis/core/capabilities_seed.pyindex 98dc3b42d3..4997404e2a 100644--- a/jarvis/core/capabilities_seed.py+++ b/jarvis/core/capabilities_seed.py@@ -81,9 +81,33 @@ _SEED_CAPABILITIES: list[Capability] = [Capability(id="tool.run-shell",source="router_tool",- verbs=_ACTION_VERBS + ("fuehre", "fuehr", "fuehren"),- objects=_SHELL_OBJECTS,- description="Run arbitrary shell commands (PowerShell / bash) on the host.",+ verbs=_ACTION_VERBS + (+ "fuehre", "fuehr", "fuehren",+ # Outcome verbs (shell-consistency rework 2026-08-08): users name+ # the OUTCOME ("erstell einen Ordner"), not the vehicle ("shell").+ # Without these the capability only resolved for users who talk+ # like developers, and natural file requests fell through to the+ # dictated "no tool" refusal (maintainer report 2026-08-08).+ "erstell", "erstelle", "anleg", "anlege", "anlegen", # i18n-allow+ "loesch", "loesche", "entfern", "entferne", # i18n-allow+ "umbenenn", "umbenenne", "benenn", "benenne", # i18n-allow+ "verschieb", "verschiebe", "kopier", "kopiere", # i18n-allow+ "entpack", "entpacke", "komprimier", "komprimiere", # i18n-allow+ "create", "delete", "remove", "rename", "move", "copy",+ "unzip", "zip", "extract", "list", "liste", # i18n-allow+ ),+ objects=_SHELL_OBJECTS + (+ # Outcome objects: the file-system nouns natural requests name.+ "ordner", "unterordner", "verzeichnis", "verzeichnisse", # i18n-allow+ "datei", "dateien", "folder", "folders", "directory", # i18n-allow+ "directories", "file", "files", "desktop", "download",+ "downloads", "papierkorb", "archiv", "zip", # i18n-allow+ ),+ description=(+ "Run shell commands for local computer tasks: create/delete/"+ "rename/move files and folders, list directories, start "+ "programs, timers, system queries."+ ),risk_tier="ask",requires_evidence=True,),diff --git a/scripts/ci/german-allowlist.txt b/scripts/ci/german-allowlist.txtindex 8280905ed3..849b38a987 100644--- a/scripts/ci/german-allowlist.txt+++ b/scripts/ci/german-allowlist.txt@@ -127,6 +127,15 @@ docs/qa/*# untranslated artifact ---tests/unit/brain/test_local_action_gate.py+# --- Local-outcome gate (shell-consistency rework 2026-08-08): the classifier+# must contain the German outcome verbs/nouns LITERALLY (reason 3, same+# rationale as local_action_gate.py), and its docstring quotes the German+# voice request under repair (inline i18n-allow impossible in docstrings,+# same rationale as rolling_whisper_wake.py). Its tests are German voice+# fixtures — content under test ---+jarvis/brain/local_outcome_gate.py+tests/unit/brain/test_local_outcome_gate.py+# --- DIRECT-path acknowledgement language test: proves the German open_app# launch ack is localized for English/Spanish turns and preserved for German# turns — the German fixtures are the content under test ---diff --git a/tests/unit/brain/test_local_outcome_gate.py b/tests/unit/brain/test_local_outcome_gate.pynew file mode 100644index 0000000000..832134c80d--- /dev/null+++ b/tests/unit/brain/test_local_outcome_gate.py@@ -0,0 +1,84 @@+"""Local-outcome gate: natural file/folder/system requests must mandate+``run_shell`` (shell-consistency rework 2026-08-08) — and conversational /+how-to / external-integration turns must NOT.++The German utterances below are simulated voice inputs, i.e. the speech+input the gate classifies — content under test (same rationale as+``test_local_action_gate.py``; registered in scripts/ci/german-allowlist.txt).+"""++from __future__ import annotations++import pytest++from jarvis.brain.local_outcome_gate import (+ RUN_SHELL_OUTCOME_DIRECTIVE,+ resolve_local_outcome_mandate,+)++# The maintainer's canonical failing request (2026-08-08) leads the list.+MANDATE_UTTERANCES = [+ "Erstell einen neuen Ordner namens Personal Jarvis auf meinem Desktop",+ "Kannst du bitte einen neuen Ordner auf dem Desktop erstellen?",+ "Hey Jarvis, leg mal ein Verzeichnis für Rechnungen an",+ "Lösch die Datei alt.txt aus dem Downloads-Ordner",+ "Benenn die Datei Bericht.docx in Final.docx um",+ "Verschieb die Zip auf den Desktop",+ "Kopier die Datei bitte nach D:",+ "Entpack das Archiv im Downloads-Ordner",+ "Zeig mir, was in meinem Downloads-Ordner liegt",+ "Lies mir die Datei notes.txt vor",+ "Führ das Skript build.ps1 aus",+ "create a folder called projects on my desktop",+ "delete the old files in the downloads folder",+ "rename the file notes.txt to todo.txt",+ "unzip the archive on my desktop",+ "run the cleanup script",+]++NO_MANDATE_UTTERANCES = [+ # Smalltalk / conversation — no verb+object pair.+ "Hallo, wie geht's dir heute?",+ "Danke dir, das war super",+ # Definition / how-to — answered inline, never acted on.+ "Was ist eine Datei?",+ "Wie erstelle ich einen Ordner in Windows?",+ "How do I create a folder on Windows?",+ # External dispatch — the integration machinery owns it.+ "Schick die Datei bitte per Mail an Harald",+ # Cloud storage — not the local disk.+ "Lad die Datei in mein Google Drive hoch",+ # Explicit GUI vehicle — computer-use owns the screen.+ "Klick auf den Ordner auf dem Desktop",+ # Explicit heavy vehicle — AD-S9, spawn owns it.+ "Spawn einen Subagenten, der den Ordner aufräumt",+ # Other domains: verb matches, but no file-system object.+ "Lösch den Termin am Freitag",+ "Erstell einen Kalendereintrag für Montag",+ # Below the minimum command length / empty.+ "ordne",+ "",+]++[email protected]("utterance", MANDATE_UTTERANCES)+def test_local_outcome_mandates_run_shell(utterance: str) -> None:+ mandate = resolve_local_outcome_mandate(utterance)+ assert mandate is not None, f"expected a run_shell mandate for: {utterance!r}"+ tool, directive = mandate+ assert tool == "run_shell"+ assert directive == RUN_SHELL_OUTCOME_DIRECTIVE++[email protected]("utterance", NO_MANDATE_UTTERANCES)+def test_conversational_and_foreign_turns_do_not_mandate(utterance: str) -> None:+ assert resolve_local_outcome_mandate(utterance) is None, (+ f"expected NO mandate for: {utterance!r}"+ )+++def test_directive_names_the_tool_and_forbids_the_refusal() -> None:+ # The directive is the LLM-facing contract: it must name run_shell and+ # explicitly outlaw the "no tool" refusal the live bug produced.+ assert "run_shell" in RUN_SHELL_OUTCOME_DIRECTIVE+ assert "NEVER claim you lack a tool" in RUN_SHELL_OUTCOME_DIRECTIVEdiff --git a/tests/unit/core/test_resolve_intent_skill_precision.py b/tests/unit/core/test_resolve_intent_skill_precision.pyindex e11d7d1380..5aa071b0b0 100644--- a/tests/unit/core/test_resolve_intent_skill_precision.py+++ b/tests/unit/core/test_resolve_intent_skill_precision.py@@ -52,6 +52,18 @@ def test_generic_verb_without_gmail_noun_does_not_hijack():def test_seed_harness_caps_unchanged_by_skill_rules():+ reg = _reg_with_gmail()+ # A screen-operation request still resolves to the computer-use harness —+ # skill registration must not alter seed harness resolutions.+ cap = reg.resolve_intent("Klick auf das Fenster am Bildschirm") # i18n-allow+ assert cap is not None and cap.source == "harness", f"-> {cap}"+++def test_file_read_resolves_to_run_shell():+ # Shell-consistency rework (2026-08-08): natural file phrasings resolve to+ # tool.run-shell now — reading a file is a shell command (cat/Get-Content),+ # not a python-script harness job. This deliberately supersedes the old+ # "Lies die Datei" -> harness expectation. # i18n-allowreg = _reg_with_gmail()cap = reg.resolve_intent("Lies die Datei foo.txt") # i18n-allow- assert cap is not None and cap.source == "harness"+ assert cap is not None and cap.id == "tool.run-shell", f"-> {cap}"