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(ide): refuse mixed-runtime dispatch before creating agents

rubenluetke10-beep48816049f976
diff --git a/jarvis/agentic_ide/orchestration.py b/jarvis/agentic_ide/orchestration.py
index 75f3005538..06740f243f 100644
--- a/jarvis/agentic_ide/orchestration.py
+++ b/jarvis/agentic_ide/orchestration.py
@@ -9,6 +9,7 @@ from __future__ import annotations
import asyncio
import hashlib
+import inspect
import json
import re
import threading
@@ -210,6 +211,17 @@ class WorkspaceOrchestrator:
self.registry = registry
self.sessions = sessions
self.ledger = ledger
+ # A source update can leave the boot-loaded ledger older than this
+ # lazily imported controller. Check the contract before allocating a
+ # pane, recording a claim, or sending anything to an agent.
+ try:
+ inspect.signature(ledger.claim).bind(
+ "", "", "", {}, 0, deduplicate_unconfirmed=True,
+ )
+ self._ledger_compatible = callable(getattr(ledger, "operation", None))
+ except (TypeError, ValueError):
+ # Surface a restart requirement below instead of a partial dispatch.
+ self._ledger_compatible = False
# request_id -> (target IDs, issued at, prompt sent under it or "")
self._issued: dict[str, tuple[dict[str, str], float, str]] = {}
self._issued_lock = threading.Lock()
@@ -952,6 +964,14 @@ class WorkspaceOrchestrator:
self._issued[request_id] = (target, time.monotonic(), prompt)
async def run(self, args: dict[str, Any], *, trace_id: str = "") -> dict[str, Any]:
+ if not self._ledger_compatible:
+ return {
+ "status": "restart_required", "success": False, "executed": False,
+ "reason": "Workspace control and its receipt store are from different app "
+ "versions. Restart Personal Jarvis before retrying. This request "
+ "created no workspace or agent and sent no prompt. Do not retry, "
+ "reassign, or use another delivery tool before restarting.",
+ }
action = args.get("action")
from jarvis.core.image_references import get_store
diff --git a/tests/contract/test_workspace_runtime_compatibility.py b/tests/contract/test_workspace_runtime_compatibility.py
new file mode 100644
index 0000000000..ad8a6f7021
--- /dev/null
+++ b/tests/contract/test_workspace_runtime_compatibility.py
@@ -0,0 +1,65 @@
+"""A stale receipt store must refuse dispatch before creating or briefing panes."""
+
+from __future__ import annotations
+
+from uuid import uuid4
+
+import pytest
+
+from jarvis.agentic_ide.orchestration import WorkspaceOrchestrator
+from jarvis.brain.workspace_tool import WorkspaceOrchestrationTool
+from jarvis.core.protocols import ExecutionContext
+from tests.contract import test_workspace_orchestration as support
+
+rig = support.rig
+runnable = support.runnable
+
+
[email protected]("legacy_api", ["claim", "operation"])
[email protected]("action", ["send", "create", "open_workspace"])
+async def test_mixed_runtime_refuses_before_any_side_effect(
+ rig, runnable, monkeypatch, legacy_api, action,
+):
+ original, registry, sessions = rig
+ resolved = await support.target(rig, workspace="Personal Jarvis")
+ ledger = original.ledger
+ claim = ledger.claim
+ operation = ledger.operation
+ claims = []
+
+ def legacy_claim(session, call, tool, arguments, revision):
+ claims.append(call)
+ return claim(session, call, tool, arguments, revision)
+
+ if legacy_api == "claim":
+ monkeypatch.setattr(ledger, "claim", legacy_claim)
+ else:
+ monkeypatch.setattr(ledger, "operation", None)
+ orchestrator = WorkspaceOrchestrator(registry, sessions, ledger)
+ tool = WorkspaceOrchestrationTool(orchestrator)
+ before = [(w.id, [t.history_id for t in w.terminals]) for w in registry.sessions]
+ active = registry.active_id
+ request_id = uuid4().hex
+ args = {
+ "action": action,
+ **resolved,
+ "request_id": request_id,
+ "folder": registry.get(resolved["workspace_id"]).folder,
+ "name": "Runtime compatibility test",
+ "cli": "codex",
+ "prompt": "Check the output formatting",
+ }
+ ctx = ExecutionContext(uuid4(), "Check the output formatting", {}, None)
+ for _ in range(2):
+ result = await tool.execute(args, ctx)
+ assert result.success is False
+ assert result.output["status"] == "restart_required"
+ assert result.output["executed"] is False
+ assert "restart" in result.output["reason"].lower()
+ assert [(w.id, [t.history_id for t in w.terminals]) for w in registry.sessions] == before
+ assert registry.active_id == active
+ assert not sessions.calls
+ assert not claims
+ assert not orchestrator._issued
+ assert operation("workspace-create", request_id) is None
+ assert operation("workspace-orchestration", request_id) is None