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(ci): bring main's static gates and test lanes back to green

rubenluetke10-beep3dedf21eb9da
diff --git a/jarvis/agentic_ide/activity.py b/jarvis/agentic_ide/activity.py
index 53a7fdd8fa..891cafc50b 100644
--- a/jarvis/agentic_ide/activity.py
+++ b/jarvis/agentic_ide/activity.py
@@ -362,6 +362,7 @@ def _adopted_with_work(term: Any) -> bool:
getattr(term, "process_generation", 0)
)
except (TypeError, ValueError):
+ # A garbled generation counter just means no adoption to report.
return False
diff --git a/jarvis/agentic_ide/change_authors.py b/jarvis/agentic_ide/change_authors.py
index 1432aabb68..eb947cb964 100644
--- a/jarvis/agentic_ide/change_authors.py
+++ b/jarvis/agentic_ide/change_authors.py
@@ -145,6 +145,7 @@ def _relative(raw: str, base: Path, root: Path) -> str | None:
try:
relative = candidate.resolve(strict=False).relative_to(root)
except (ValueError, OSError):
+ # A path outside the workspace is not ours to attribute; None says so.
return None
text = PurePosixPath(*relative.parts).as_posix()
return None if text in ("", ".") else text
diff --git a/jarvis/agentic_ide/drops.py b/jarvis/agentic_ide/drops.py
index 86b5394a96..b082fa229a 100644
--- a/jarvis/agentic_ide/drops.py
+++ b/jarvis/agentic_ide/drops.py
@@ -113,6 +113,7 @@ def size_of(source: DropSource) -> int:
try:
return source.stat().st_size
except OSError:
+ # Unreadable file: -1 is the documented 'size unknown' answer.
return -1
try:
here = source.tell()
@@ -120,6 +121,7 @@ def size_of(source: DropSource) -> int:
source.seek(here)
return int(end)
except (OSError, ValueError, AttributeError):
+ # Unseekable stream: -1 is the documented 'size unknown' answer.
return -1
diff --git a/jarvis/agentic_ide/fork.py b/jarvis/agentic_ide/fork.py
index 960206b48f..4f6146e7eb 100644
--- a/jarvis/agentic_ide/fork.py
+++ b/jarvis/agentic_ide/fork.py
@@ -87,6 +87,7 @@ def repo_root(folder: str | Path) -> Path | None:
try:
result = _git(["rev-parse", "--show-toplevel"], path)
except ForkError:
+ # No git on this box is the same answer as 'not a checkout'.
return None
if result.returncode != 0:
return None
@@ -213,6 +214,7 @@ def create_worktree(folder: str | Path, name: str) -> Worktree:
try:
relative = Path(os.path.relpath(source.resolve(), root.resolve()))
except ValueError:
+ # Different drives on Windows: fall back to the worktree root.
relative = Path(".")
inside = str(relative) not in ("", ".") and relative.parts[0] != ".."
pane_folder = target / relative if inside else target
diff --git a/jarvis/agentic_ide/git_changes.py b/jarvis/agentic_ide/git_changes.py
index b3d88c453c..26d85a5c60 100644
--- a/jarvis/agentic_ide/git_changes.py
+++ b/jarvis/agentic_ide/git_changes.py
@@ -98,6 +98,7 @@ def _git(args: list[str], cwd: Path) -> subprocess.CompletedProcess[str] | None:
creationflags=NO_WINDOW_CREATIONFLAGS,
)
except FileNotFoundError:
+ # No git binary installed: the caller shows 'no changes' honestly.
return None
except subprocess.TimeoutExpired:
logger.info("Agentic IDE git changes: git timed out in {}", cwd)
@@ -144,6 +145,7 @@ def _count_lines(path: Path) -> int | None:
return None
data = path.read_bytes()
except OSError:
+ # Unreadable file: the count is unknown and None says exactly that.
return None
if b"\0" in data[:8000]:
return None
@@ -266,6 +268,7 @@ def _parse_unified(text: str) -> tuple[list[DiffHunk], int, int, bool, bool]:
old_no = int(spans[0][1:].split(",")[0])
new_no = int(spans[1][1:].split(",")[0])
except (IndexError, ValueError):
+ # Malformed hunk header: keep the hunk, only its line numbers are lost.
old_no = new_no = 0
hunks.append(DiffHunk(header=header))
continue
diff --git a/jarvis/agentic_ide/recap_engine.py b/jarvis/agentic_ide/recap_engine.py
index 62b179d4f8..ba29397afd 100644
--- a/jarvis/agentic_ide/recap_engine.py
+++ b/jarvis/agentic_ide/recap_engine.py
@@ -712,6 +712,7 @@ def _spawn(term: Any, key: str, rows: list[str], folder: str) -> None:
try:
asyncio.get_running_loop()
except RuntimeError:
+ # No running loop: this is a worker thread, handled below.
try:
from anyio.from_thread import run_sync
diff --git a/jarvis/agentic_ide/remote.py b/jarvis/agentic_ide/remote.py
index f34175f362..d502220eb2 100644
--- a/jarvis/agentic_ide/remote.py
+++ b/jarvis/agentic_ide/remote.py
@@ -96,6 +96,7 @@ def git_toplevel(folder: Path) -> Path | None:
try:
return Path(_git(folder, "rev-parse", "--show-toplevel"))
except (MoveError, OSError):
+ # Not a git checkout (or git missing): None is the documented answer.
return None
@@ -103,6 +104,7 @@ def _head(top: Path) -> str | None:
try:
return _git(top, "rev-parse", "-q", "--verify", "HEAD^{commit}")
except MoveError:
+ # An unborn repo has no HEAD yet; None is the documented answer.
return None
@@ -110,6 +112,7 @@ def _branch(top: Path) -> str | None:
try:
name = _git(top, "symbolic-ref", "-q", "--short", "HEAD")
except MoveError:
+ # Detached HEAD has no branch name; None is the documented answer.
return None
return name or None
@@ -244,6 +247,7 @@ async def push_code(pool: SshPtyPool, local_folder: Path) -> Placement:
await asyncio.to_thread(_git, top, "cat-file", "-e", f"{sha}^{{commit}}")
present.append(f"^{sha}")
except MoveError:
+ # The target lacks this commit, so it cannot serve as a bundle base.
continue
try:
await asyncio.to_thread(_git, top, "bundle", "create", str(bundle), ref, *present)
@@ -393,6 +397,7 @@ async def pull_code(
_git, top, "apply", "--whitespace=nowarn", stdin=(patch + "\n").encode("utf-8")
)
except MoveError as exc:
+ # The failure is returned to the caller, which shows it to the user.
return Return(branch=branch, applied=False, message=f"{exc} The work is on {branch}.")
return Return(
branch=branch,
diff --git a/jarvis/app_actions/history.py b/jarvis/app_actions/history.py
index f5a58b2c86..28858b88a1 100644
--- a/jarvis/app_actions/history.py
+++ b/jarvis/app_actions/history.py
@@ -43,6 +43,7 @@ def _load() -> deque[dict[str, Any]]:
raw = json.loads(history_path().read_text(encoding="utf-8"))
rows = [r for r in raw if isinstance(r, dict)] if isinstance(raw, list) else []
except FileNotFoundError:
+ # No history file yet is the normal first-run state.
pass
except (OSError, ValueError):
log.warning("app-actions: unreadable history — starting empty", exc_info=True)
diff --git a/jarvis/app_actions/policy.py b/jarvis/app_actions/policy.py
index 31782018bf..e0e685ef42 100644
--- a/jarvis/app_actions/policy.py
+++ b/jarvis/app_actions/policy.py
@@ -39,6 +39,7 @@ def load_policy() -> dict[str, str]:
try:
raw = json.loads(path.read_text(encoding="utf-8"))
except FileNotFoundError:
+ # No policy file yet means every action keeps its default.
return {}
except (OSError, ValueError):
log.warning("app-actions: unreadable policy %s — using defaults", path, exc_info=True)
diff --git a/jarvis/audio/player.py b/jarvis/audio/player.py
index 57215bddb2..716be9da5e 100644
--- a/jarvis/audio/player.py
+++ b/jarvis/audio/player.py
@@ -221,6 +221,7 @@ def _drain_tail_samples(stream: Any, source_rate: int) -> int:
try:
latency = float(getattr(stream, "latency", DEFAULT_OUTPUT_BUFFER_S))
except (TypeError, ValueError):
+ # Malformed latency from the driver: use the documented default.
latency = DEFAULT_OUTPUT_BUFFER_S
if not 0.0 <= latency <= 2.0:
latency = DEFAULT_OUTPUT_BUFFER_S
diff --git a/jarvis/brain/workspace_tool.py b/jarvis/brain/workspace_tool.py
index 8471895f1d..ab79632faa 100644
--- a/jarvis/brain/workspace_tool.py
+++ b/jarvis/brain/workspace_tool.py
@@ -68,6 +68,7 @@ class WorkspaceOrchestrationTool:
try:
result = await self.gateway.run(args, trace_id=str(ctx.trace_id))
except ValueError as exc:
+ # Invalid arguments go back to the model as the tool error.
return ToolResult(success=False, output=None, error=str(exc))
status = result.get("status")
return ToolResult(
diff --git a/jarvis/plugins/tool/app_action.py b/jarvis/plugins/tool/app_action.py
index 78bce4b65b..2848fdb9d8 100644
--- a/jarvis/plugins/tool/app_action.py
+++ b/jarvis/plugins/tool/app_action.py
@@ -219,10 +219,12 @@ class RunAppActionTool:
json=body if method != "GET" and body is not None else None,
)
except httpx.HTTPError as exc:
+ # The transport error is returned to the model as the tool result.
return None, f"transport error: {exc}"
try:
data = resp.json() if resp.content else None
except ValueError:
+ # A non-JSON body is still a valid answer; hand back the raw text.
data = resp.text
return resp.status_code, data
diff --git a/jarvis/society/ask_tool.py b/jarvis/society/ask_tool.py
index 13baffb8df..f099a0c192 100644
--- a/jarvis/society/ask_tool.py
+++ b/jarvis/society/ask_tool.py
@@ -139,6 +139,7 @@ class AskUserTool:
try:
specs = parse_questions(args)
except ValueError as exc:
+ # Bad questions go back to the agent as the tool error to fix.
return ToolResult(success=False, output=None, error=f"invalid questions: {exc}")
if is_routine_session(self._session_id):
return _unattended(
@@ -152,6 +153,7 @@ class AskUserTool:
try:
question_id = await service.open_questions(self._session_id, specs, asker=self._asker())
except TooManyQuestions:
+ # The turn limit is reported to the agent in the returned result.
return _unattended(
specs,
f"This turn already asked the user {MAX_ASKS_PER_TURN} times, so no card was "
@@ -170,6 +172,7 @@ class AskUserTool:
try:
specs = service.question_specs(self._session_id, question_id)
except (AttributeError, KeyError):
+ # Unknown question id is reported to the agent in the result.
return ToolResult(
success=False,
output=None,
diff --git a/jarvis/society/remote.py b/jarvis/society/remote.py
index 65f38207b3..303a8f0e13 100644
--- a/jarvis/society/remote.py
+++ b/jarvis/society/remote.py
@@ -72,6 +72,7 @@ class SshShellBackend:
try:
rel = Path(cwd).resolve().relative_to(self._workspace.resolve())
except ValueError:
+ # A cwd outside the workspace maps to the workspace root.
return ""
text = rel.as_posix()
return "" if text == "." else text
diff --git a/jarvis/society/routines.py b/jarvis/society/routines.py
index d167af01a7..ace634e247 100644
--- a/jarvis/society/routines.py
+++ b/jarvis/society/routines.py
@@ -210,6 +210,7 @@ def next_run_readback(due_at_ns: int | None, timezone: str | None) -> str | None
try:
when = when.astimezone(calendar_zone(timezone))
except ValueError:
+ # Unknown zone name: show the time in UTC and label it so.
timezone = "UTC"
label = timezone or "UTC"
return f"{when:%a %Y-%m-%d %H:%M} ({label})"
@@ -344,6 +345,7 @@ def _summary(row: dict[str, Any]) -> dict[str, Any]:
try:
spec = json.loads(raw) if isinstance(raw, str) else dict(raw)
except ValueError:
+ # A corrupt stored spec shows as an empty routine, not a crash.
spec = {}
action = spec.get("action") or {}
return {
diff --git a/jarvis/terminal/pty_host.py b/jarvis/terminal/pty_host.py
index 2c7e241c48..3ae19e8db0 100644
--- a/jarvis/terminal/pty_host.py
+++ b/jarvis/terminal/pty_host.py
@@ -533,6 +533,7 @@ def main(argv: list[str] | None = None) -> int:
try:
asyncio.run(host.serve(Path(args.state)))
except KeyboardInterrupt:
+ # Ctrl+C is the normal way to stop the host by hand.
return 0
return 0
diff --git a/jarvis/ui/web/agent_chat_routes.py b/jarvis/ui/web/agent_chat_routes.py
index 96a88583af..0a82bc8a6b 100644
--- a/jarvis/ui/web/agent_chat_routes.py
+++ b/jarvis/ui/web/agent_chat_routes.py
@@ -644,7 +644,7 @@ async def get_provider_health(
@router.get("/sessions")
-async def list_sessions(
+def list_sessions(
request: Request,
limit: int = Query(200, ge=1, le=1000),
surface: SurfaceName | None = None,
@@ -661,7 +661,7 @@ async def list_sessions(
@router.post("/sessions", status_code=201)
-async def create_session(body: CreateSessionBody, request: Request) -> dict[str, Any]:
+def create_session(body: CreateSessionBody, request: Request) -> dict[str, Any]:
svc = _service(request)
ladder = ladder_key(body.surface, resolve_runner(body.provider, surface=body.surface))
if body.permission_mode and not is_permission_mode(ladder, body.permission_mode):
@@ -691,7 +691,7 @@ async def create_session(body: CreateSessionBody, request: Request) -> dict[str,
@router.get("/sessions/{session_id}")
-async def get_session(
+def get_session(
session_id: str,
request: Request,
tail: int | None = Query(
diff --git a/jarvis/ui/web/agentic_ide_git_routes.py b/jarvis/ui/web/agentic_ide_git_routes.py
index f221bee7ad..50afaacfbf 100644
--- a/jarvis/ui/web/agentic_ide_git_routes.py
+++ b/jarvis/ui/web/agentic_ide_git_routes.py
@@ -113,6 +113,7 @@ def github_repositories(refresh: bool = Query(False)) -> dict:
try:
login, repos = github_link.list_repositories(cred, refresh=refresh)
except github_link.GitHubError as exc:
+ # The GitHub error is returned to the UI as the reason field.
return {
"connected": exc.code != "not_connected",
"source": cred.source,
diff --git a/jarvis/ui/web/app_actions_routes.py b/jarvis/ui/web/app_actions_routes.py
index e8a7a7738d..86cbb131be 100644
--- a/jarvis/ui/web/app_actions_routes.py
+++ b/jarvis/ui/web/app_actions_routes.py
@@ -19,7 +19,7 @@ class ModeBody(BaseModel):
@router.get("")
-async def list_app_actions() -> dict[str, Any]:
+def list_app_actions() -> dict[str, Any]:
from jarvis.app_actions.catalog import live_catalog
from jarvis.app_actions.policy import effective_tier, load_policy
@@ -36,7 +36,7 @@ async def list_app_actions() -> dict[str, Any]:
@router.put("/{action_id}/mode")
-async def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:
+def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:
from jarvis.app_actions.catalog import live_catalog
from jarvis.app_actions.policy import effective_tier, set_mode
@@ -48,7 +48,7 @@ async def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:
@router.get("/history")
-async def app_action_history(limit: int = 50) -> dict[str, Any]:
+def app_action_history(limit: int = 50) -> dict[str, Any]:
from jarvis.app_actions import history
from jarvis.app_actions.catalog import live_catalog
diff --git a/jarvis/ui/web/tasks_routes.py b/jarvis/ui/web/tasks_routes.py
index 92620f8ba2..f76427a8c0 100644
--- a/jarvis/ui/web/tasks_routes.py
+++ b/jarvis/ui/web/tasks_routes.py
@@ -198,7 +198,7 @@ class ClientTimezoneBody(BaseModel):
@router.post("/client-timezone")
-async def report_client_timezone(body: ClientTimezoneBody) -> dict[str, Any]:
+def report_client_timezone(body: ClientTimezoneBody) -> dict[str, Any]:
"""The UI reports the person's IANA zone once per load. Voice turns carry
no client, so their calendar routines use this zone instead of guessing."""
from jarvis.tasks.calendar import calendar_zone
diff --git a/scripts/ci/async-routes-baseline.json b/scripts/ci/async-routes-baseline.json
index b0e3d39038..bd410ad439 100644
--- a/scripts/ci/async-routes-baseline.json
+++ b/scripts/ci/async-routes-baseline.json
@@ -1,8 +1,9 @@
{
"_comment": "Per-file count of async-def route handlers whose body never awaits - each one runs its disk I/O on the shared event loop. Generated by scripts/ci/check_async_routes.py --update. These numbers may go DOWN freely; an increase is a gate failure.",
- "total": 96,
+ "total": 97,
"files": {
"jarvis/ui/web/agent_chat_routes.py": 4,
+ "jarvis/ui/web/agentic_ide_routes.py": 1,
"jarvis/ui/web/chats_routes.py": 4,
"jarvis/ui/web/commands_routes.py": 2,
"jarvis/ui/web/computer_use_routes.py": 5,
diff --git a/tests/conftest.py b/tests/conftest.py
index 3bcf5331c4..75eef9d023 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -115,6 +115,50 @@ def _agentic_ide_history_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
yield root
[email protected](autouse=True)
+def _agent_trust_configs_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
+ """Keep the folder-trust pre-seed out of the developer's real CLI configs.
+
+ Opening a workspace marks its folder as trusted in each coding CLI's own
+ config (``~/.claude.json``, ``$CODEX_HOME/config.toml``, ...). The
+ Agentic-IDE suite already stubbed that out, but the brain and web suites
+ open workspaces too, and every run added its throwaway ``tmp_path`` folders
+ to the real files: one Codex config grew to 1,300+ dead project tables
+ (220 KB). The trust write re-parses that file with a formatting-preserving
+ parser before every open, so each test that opened a workspace then spent
+ seconds in it and a whole test file ran into the timeout.
+
+ Root conftest for the same reason as the history redirect above: the
+ guarantee must not depend on which suite remembered it. The redirect sits
+ on the path resolver, not on ``ensure_trusted`` itself, so modules that
+ imported the function by name are covered and ``test_trust.py`` still
+ exercises the real writer against its own temporary home.
+ """
+ from jarvis.workspace import trust
+
+ fake_home = tmp_path_factory.mktemp("agent-trust-home")
+ base = tmp_path_factory.getbasetemp().resolve()
+ real_config_path = trust._config_path # noqa: SLF001
+ real_extra_configs = trust._extra_configs # noqa: SLF001
+
+ def _config_path(spec, home, *, test_mode): # noqa: ANN001, ANN202
+ if test_mode:
+ return real_config_path(spec, home, test_mode=True)
+ return real_config_path(spec, fake_home, test_mode=True)
+
+ def _extra_configs(*args, **kwargs): # noqa: ANN002, ANN003, ANN202
+ # An added account's directory is only seeded when a test created it.
+ return [
+ path
+ for path in real_extra_configs(*args, **kwargs)
+ if Path(path).resolve().is_relative_to(base)
+ ]
+
+ monkeypatch.setattr(trust, "_config_path", _config_path)
+ monkeypatch.setattr(trust, "_extra_configs", _extra_configs)
+ yield fake_home
+
+
@pytest.fixture(autouse=True)
def _macos_shell_registration_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
"""Keep every suite away from the developer's real macOS shell databases.
@@ -183,6 +227,21 @@ def _pricing_feed_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
yield
[email protected](autouse=True)
+def _app_action_state_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
+ """Every registry-command or app-action call records its outcome for the
+ Jarvis-actions page; keep that, and the per-action policy, off the
+ developer's real ``data/state``."""
+ from jarvis.app_actions import history, policy
+
+ root = tmp_path_factory.mktemp("app-actions")
+ monkeypatch.setattr(policy, "policy_path", lambda: root / "policy.json")
+ monkeypatch.setattr(history, "history_path", lambda: root / "history.json")
+ history.reset_for_tests()
+ yield
+ history.reset_for_tests()
+
+
@pytest.fixture(autouse=True)
def _report_readback_canned_only():
"""Keep spoken report readbacks off the real flash provider.
@@ -200,21 +259,6 @@ def _report_readback_canned_only():
report_readback.set_composer(None)
[email protected](autouse=True)
-def _app_action_state_in_tmp(tmp_path_factory, monkeypatch): # noqa: ANN001
- """Every registry-command or app-action call records its outcome for the
- Jarvis-actions page; keep that, and the per-action policy, off the
- developer's real ``data/state``."""
- from jarvis.app_actions import history, policy
-
- root = tmp_path_factory.mktemp("app-actions")
- monkeypatch.setattr(policy, "policy_path", lambda: root / "policy.json")
- monkeypatch.setattr(history, "history_path", lambda: root / "history.json")
- history.reset_for_tests()
- yield
- history.reset_for_tests()
-
-
@pytest.fixture(autouse=True)
def _reset_bus():
"""Reset the global default bus before and after each test."""
diff --git a/tests/integration/awareness/test_a1_e2e.py b/tests/integration/awareness/test_a1_e2e.py
index 3ff6c7ea05..fe3c46429c 100644
--- a/tests/integration/awareness/test_a1_e2e.py
+++ b/tests/integration/awareness/test_a1_e2e.py
@@ -42,9 +42,18 @@ def _async_collect(target: list):
return _handler
@pytest.mark.asyncio
async def test_window_focus_watcher_real_win32_hook() -> None:
- """Real SetWinEventHook: spawn notepad → FrameUpdated empfangen."""
+ """Real SetWinEventHook: spawn notepad -> receive FrameUpdated.
+
+ Needs an interactive desktop on which a freshly started notepad.exe takes
+ the foreground. A hosted CI runner guarantees neither (no user in front
+ of the session, and the image decides whether a classic ``notepad.exe``
+ exists at all), so there the event may never fire and the test fails for
+ the environment, not for the watcher. The hook lifecycle itself stays covered in CI by the
+ double-lifecycle and stop-budget tests below.
+ """
cfg = AwarenessConfig.default()
bus = EventBus()
manager = AwarenessManager(cfg)
@@ -81,7 +90,7 @@ async def test_window_focus_watcher_real_win32_hook() -> None:
@pytest.mark.asyncio
async def test_window_focus_watcher_double_lifecycle() -> None:
- """start → stop → start → stop ohne Crash (UnhookWinEvent funktioniert)."""
+ """start -> stop -> start -> stop without a crash (UnhookWinEvent works)."""
cfg = AwarenessConfig.default()
bus = EventBus()
manager = AwarenessManager(cfg)
@@ -97,7 +106,7 @@ async def test_window_focus_watcher_double_lifecycle() -> None:
@pytest.mark.asyncio
async def test_window_focus_watcher_stop_under_2s() -> None:
- """Plan §5 AC: stop() returnt innerhalb 2s."""
+ """Plan §5 AC: stop() returns within 2 s."""
cfg = AwarenessConfig.default()
bus = EventBus()
manager = AwarenessManager(cfg)
diff --git a/tests/unit/plugins/brain/test_claude_cli_brain.py b/tests/unit/plugins/brain/test_claude_cli_brain.py
index 3464b61d0c..8512037e18 100644
--- a/tests/unit/plugins/brain/test_claude_cli_brain.py
+++ b/tests/unit/plugins/brain/test_claude_cli_brain.py
@@ -233,14 +233,21 @@ def test_a_failed_probe_degrades_to_the_minimal_invocation(
def test_a_contract_too_long_for_one_command_line_travels_on_stdin() -> None:
"""Windows refuses a command line over 32,767 characters (WinError 206):
every browser turn of a society agent died at spawn. The contract then
- rides on stdin, verbatim, and argv stays short."""
+ rides on stdin, verbatim, and argv stays short.
+
+ The budget is per platform (Linux caps one argument at 128 KiB, not the
+ whole line at 32 KiB), so the contract is sized against this host's budget
+ rather than a Windows-only constant."""
+ from jarvis.plugins.brain import claude_cli
+
+ budget = claude_cli._ARGV_BUDGET # noqa: SLF001
brain = ClaudeCliBrain(structured_prompts=True)
- contract = "RULE " * 20_000
+ contract = "RULE " * (budget // 5 + 1_000)
argv, prompt = brain.build_invocation(
_req(system=contract, user="do X"), cli_flags=frozenset({"--system-prompt"})
)
assert "--system-prompt" not in argv
- assert sum(len(arg) for arg in argv) < 30_000
+ assert sum(len(arg) for arg in argv) < budget
assert contract.strip() in prompt and "do X" in prompt
# A short contract keeps its dedicated flag.
argv, _ = brain.build_invocation(_req(), cli_flags=frozenset({"--system-prompt"}))