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(missions): credit the worktree diff as Critic evidence for prose/CLI workers
Ruben Lütke4339d9fdf7c6
diff --git a/jarvis/missions/critic/runner.py b/jarvis/missions/critic/runner.pyindex bbf5cfdb65..c7d6105fc9 100644--- a/jarvis/missions/critic/runner.py+++ b/jarvis/missions/critic/runner.py@@ -34,6 +34,7 @@ from pydantic import ValidationErrorfrom ..stream_evidence import (capability_refusal_answer,+ diff_has_action_evidence,informational_file_answer,is_informational_request,readonly_answer,@@ -206,6 +207,42 @@ def _resolve_capability_requires_evidence(user_request: str) -> tuple[bool, strreturn (False, None)+# --- Messaging-action discriminator (for the diff-as-evidence gate) ---+#+# A real worktree diff proves the worker DID file work — valid ground truth for+# an artefact task (HTML/report/code), so it satisfies the honesty gate for a+# prose-only CLI worker (agy/gemini) that writes files but emits no tool_use+# frame. It is NOT valid for a real SEND action: writing draft.txt does not+# prove an email/SMS/chat message was sent, so those must still show a real+# messaging/MCP tool call. We require BOTH a send-verb AND a messaging noun so+# an artefact task that merely mentions the topic ("write an HTML report ABOUT+# my emails") is NOT misclassified as a send — only "send an email", "tweet+# this", "reply to the message" are.+_SEND_VERB_RE = re.compile(+ r"\b(send|sende|sendest|schick|schicke|verschick|verschicke|post|poste|"+ r"tweet|reply|antworte|antworten|message|nachricht|dm)\b",+ re.I,+)+_MESSAGING_NOUN_RE = re.compile(+ r"\b(e-?mails?|mails?|sms|whatsapp|telegram|discord|slack|tweets?|"+ r"nachrichten?|message|messages|dm|dms)\b",+ re.I,+)+++def _request_is_messaging_action(user_request: str) -> bool:+ """True when the request is to SEND a message (email/SMS/chat/tweet).++ Such an action can never be satisfied by a file write, so the diff-as-+ evidence credit must NOT apply to it — the honesty gate keeps requiring a+ real messaging tool call. Requires a send-verb AND a messaging noun so an+ artefact task that only mentions the topic keeps its diff credit.+ """+ return bool(_SEND_VERB_RE.search(user_request)) and bool(+ _MESSAGING_NOUN_RE.search(user_request)+ )++# --- Main gate function ---_CAPABILITY_NOT_EXECUTED_SUMMARY_DE: Final[str] = (@@ -220,6 +257,7 @@ def enforce_capability_honesty(user_request: str,verdict: CriticVerdict,worker_output: str,+ worker_diff: str = "",) -> CapabilityHonestyCheck:"""Apply the capability-honesty gate to a CriticVerdict.@@ -237,6 +275,12 @@ def enforce_capability_honesty(verdict: CriticVerdict returned by the LLM critic.worker_output: Raw worker log / stream.jsonl content used forevidence extraction.+ worker_diff: The worker's git diff (in-worktree hunks + Kontrollierer+ augmentations). A real diff is ground-truth evidence of an executed+ action for CLI subscription workers (Antigravity ``agy``, Gemini+ ``--yolo``) that DO the work but emit only prose / plain text and so+ carry no machine-readable tool_use frame. Defaults to "" so existing+ callers and the prose-only anti-hallucination contract are unchanged.Returns:A ``CapabilityHonestyCheck`` wrapping the (possibly overridden) verdict.@@ -244,7 +288,22 @@ def enforce_capability_honesty(evidence = _extract_tool_call_evidence(worker_output)requires_ev, cap_id = _resolve_capability_requires_evidence(user_request)- if requires_ev and not evidence:+ # A real worktree diff is ground-truth evidence of an executed file/action —+ # the canonical artefact the gate demands. agy/gemini write real files but+ # narrate over a PTY/pipe (no tool_use frame), so frame-based extraction is+ # always empty for them; crediting the diff is what lets a genuinely+ # completed CLI mission pass instead of looping 3× to exhaustion (live+ # mission 019eefda, 2026-06-22). It is NOT a weakening of the honesty gate:+ # a prose-only claim with an EMPTY diff still has no evidence and is still+ # overridden (see test_gate_still_blocks_prose_only_email_claim). The one+ # exception is a real SEND action (email/SMS/chat) — a file write does not+ # prove a message was sent, so those still require a real messaging tool+ # call even when a diff exists.+ fs_evidence = diff_has_action_evidence(worker_diff) and not (+ _request_is_messaging_action(user_request)+ )++ if requires_ev and not evidence and not fs_evidence:# Override: LLM approved but no real tool-call evidence found.logger.warning("enforce_capability_honesty: requires_evidence=True but no tool-call "@@ -285,9 +344,15 @@ def enforce_capability_honesty(honesty_overridden=True,)+ # When no tool_use frame was found but the worktree diff proves a real+ # action, surface that as the evidence so telemetry / downstream readers+ # see the mission produced ground-truth work (not "no evidence").+ effective_evidence = evidence or (+ ("filesystem-change",) if fs_evidence else ()+ )return CapabilityHonestyCheck(verdict=verdict,- tool_call_evidence=evidence,+ tool_call_evidence=effective_evidence,capability_id=cap_id,honesty_overridden=False,)@@ -810,6 +875,7 @@ class CriticRunner:user_request=mission_prompt,verdict=verdict,worker_output=worker_log,+ worker_diff=worker_diff,)if honesty.honesty_overridden:logger.info(diff --git a/jarvis/missions/stream_evidence.py b/jarvis/missions/stream_evidence.pyindex 8c81eb2baf..f4f788f8c7 100644--- a/jarvis/missions/stream_evidence.py+++ b/jarvis/missions/stream_evidence.py@@ -627,6 +627,44 @@ def _has_inworktree_hunk(diff_text: str) -> bool:return any(ln.startswith("diff --git ") for ln in diff_text.splitlines())+# Every diff-block prefix the pipeline uses to record a real, ground-truth+# worker action: an in-worktree file change (``diff --git``), an out-of-worktree+# deliverable (``diff --external-target``, Kontrollierer-augmented), a verified+# state-changing git/gh command (``diff --command-evidence``), or a verified+# desktop launch (``diff --desktop-action-evidence``). Each one is observable+# ground truth that the worker DID something — the same standard the empty-diff+# GROUND-TRUTH-RULE applies.+_DIFF_ACTION_PREFIXES: tuple[str, ...] = (+ "diff --git ",+ "diff --external-target",+ "diff --command-evidence",+ "diff --desktop-action-evidence",+)+++def diff_has_action_evidence(diff_text: str) -> bool:+ """True if the diff proves a real worker action (file change or augmented op).++ This is the ground-truth counterpart to :func:`_extract_tool_call_evidence`+ for workers that perform real work but emit NO machine-readable tool_use+ frame: the Antigravity ``agy`` CLI (PTY prose) and the Gemini CLI+ (``--yolo`` plain text) genuinely write files into the worktree, yet their+ transcript is narrative ("I will create index.html…"), so the frame-based+ extractor finds nothing. The git diff is where those writes ARE observable,+ so it must count as evidence — otherwise the capability-honesty gate+ overrides every such mission to failure (live mission 019eefda, 2026-06-22:+ agy wrote an 80 KB index.html, the gate still said "made no tool call" and+ burned all three critic loops). Crediting the diff is consistent with the+ GROUND-TRUTH-RULE, not a weakening of it: a prose-only claim with an EMPTY+ diff still yields False, so the anti-hallucination contract is intact.+ """+ if not diff_text or not diff_text.strip():+ return False+ return any(+ ln.startswith(_DIFF_ACTION_PREFIXES) for ln in diff_text.splitlines()+ )++# --- informational / question request detection ----------------------------## A pure question ("which city would you recommend for Australia?", "explain@@ -1062,6 +1100,7 @@ def summarize_answers(answers: list[str], *, cap: int = 600) -> str:__all__ = ["StreamEvidence","clean_request_body",+ "diff_has_action_evidence","extract_stream_evidence","extract_verified_commands","extract_verified_desktop_actions",diff --git a/tests/missions/critic/test_capability_honesty.py b/tests/missions/critic/test_capability_honesty.pyindex bb7bdee79d..a16e48c210 100644--- a/tests/missions/critic/test_capability_honesty.py+++ b/tests/missions/critic/test_capability_honesty.py@@ -30,6 +30,8 @@ from jarvis.missions.critic.verdict import (CriticAxis,CriticVerdict,)+from jarvis.missions.critic.runner import _request_is_messaging_action+from jarvis.missions.stream_evidence import diff_has_action_evidencefrom tests.missions.critic.test_runner_claude_direct import (_patch_direct,_valid_verdict_json,@@ -201,6 +203,124 @@ def test_gate_still_blocks_prose_only_email_claim() -> None:assert check.verdict.verdict == "revise"+# --- prose/CLI workers (agy/Antigravity, gemini --yolo): the git diff is evidence ---+#+# Live mission 019eefda-7e5f (2026-06-22): the user picked Antigravity as the+# subagent provider; agy REALLY wrote an 80 KB index.html into the worktree, but+# it emits only narrative PROSE over its PTY ("I will create index.html…"), never+# a machine-readable tool_use frame. `_extract_tool_call_evidence` is therefore+# always empty for agy/gemini, so the honesty gate overrode every iteration to+# "made no tool call" -> 3x revise -> 13-20 min -> the user gave up ("Ewigkeiten").+# A real worktree diff is the GROUND-TRUTH-RULE's own source of truth, so it must+# satisfy the gate exactly as a tool_use frame does.++_AGY_PROSE = (+ "I will analyze the workspace directory to understand its layout.\n"+ "I will create index.html with a polished market dashboard.\n"+ "I have created the file and the task is complete."+)++_REAL_GIT_DIFF = (+ "diff --git a/index.html b/index.html\n"+ "new file mode 100644\n"+ "--- /dev/null\n"+ "+++ b/index.html\n"+ "@@ -0,0 +1,2 @@\n"+ "+<!DOCTYPE html>\n"+ "+<html><body><h1>Market Dashboard</h1></body></html>\n"+)+++def test_diff_has_action_evidence_recognises_real_markers() -> None:+ assert diff_has_action_evidence(_REAL_GIT_DIFF) is True+ assert diff_has_action_evidence("diff --external-target b/out/x.html\n+<html>") is True+ assert diff_has_action_evidence("diff --command-evidence b/<ops>\n+main -> main") is True+ assert (+ diff_has_action_evidence("diff --desktop-action-evidence b/<launch>\n+ok") is True+ )+++def test_diff_has_action_evidence_rejects_empty_or_prose() -> None:+ assert diff_has_action_evidence("") is False+ assert diff_has_action_evidence(" \n \n") is False+ # prose that merely mentions a diff is not a diff+ assert diff_has_action_evidence("I produced a diff for index.html") is False+++def test_request_is_messaging_action() -> None:+ # real send actions: verb + messaging noun+ assert _request_is_messaging_action("Sende eine E-Mail an Max") is True+ assert _request_is_messaging_action("Schick eine WhatsApp an Lisa") is True+ assert _request_is_messaging_action("Tweet this update") is True+ assert _request_is_messaging_action("reply to the message from Tom") is True+ # artefact tasks that only MENTION the topic must NOT be misclassified+ assert _request_is_messaging_action(+ "Erstelle einen HTML-Report über meine E-Mails"+ ) is False+ assert _request_is_messaging_action("Mach eine HTML-Datei zum Aktienmarkt") is False+++def _force_requires_evidence(monkeypatch: pytest.MonkeyPatch) -> None:+ """Pin requires_evidence=True so the test exercises the diff-evidence branch+ regardless of the (empty in unit tests) capability registry."""+ monkeypatch.setattr(+ "jarvis.missions.critic.runner._resolve_capability_requires_evidence",+ lambda _req: (True, "test.write-artefact"),+ )+++def test_gate_credits_worktree_diff_for_prose_worker(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """agy/gemini write real files but emit only prose — the git diff is the+ ground-truth artefact and must satisfy the honesty gate (regression for+ live mission 019eefda, 2026-06-22: agy wrote an 80 KB index.html, the gate+ still said 'made no tool call' and burned all three critic loops)."""+ _force_requires_evidence(monkeypatch)+ check = enforce_capability_honesty(+ user_request="Mach eine visuell ansprechende HTML-Datei zum Aktienmarkt",+ verdict=_approval_verdict(),+ worker_output=_AGY_PROSE, # NO tool_use frames at all+ worker_diff=_REAL_GIT_DIFF,+ )+ assert check.honesty_overridden is False+ assert check.verdict.verdict == "approve"+ assert check.tool_call_evidence # the filesystem change is credited+++def test_gate_still_blocks_prose_worker_with_empty_diff(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Anti-hallucination contract intact: a prose claim with NO diff AND NO+ tool frame still fails, even for a CLI worker."""+ _force_requires_evidence(monkeypatch)+ check = enforce_capability_honesty(+ user_request="Mach eine visuell ansprechende HTML-Datei zum Aktienmarkt",+ verdict=_approval_verdict(),+ worker_output=_AGY_PROSE,+ worker_diff="", # nothing written+ )+ assert check.honesty_overridden is True+ assert check.verdict.verdict == "revise"+++def test_gate_messaging_action_ignores_file_diff(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A file write does NOT prove a message was sent: a real send action keeps+ requiring a messaging tool call even when a diff exists (the diff-evidence+ credit must not re-open the 'I have sent the email' hallucination)."""+ _force_requires_evidence(monkeypatch)+ check = enforce_capability_honesty(+ user_request="Sende eine E-Mail an Max mit der Zusammenfassung",+ verdict=_approval_verdict(),+ worker_output=_AGY_PROSE,+ worker_diff=_REAL_GIT_DIFF, # wrote a file, but that's not a sent email+ )+ assert check.honesty_overridden is True+ assert check.verdict.verdict == "revise"++# --- empty-diff pre-gate: codex actions must defer to the LLM critic ---