Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/system-specs/modules/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1419,9 +1419,10 @@ Resolution order:

A reader that parses the files itself rather than loading the config merges them in
the same order: the MCP broker's read limit (`mcp_gateway.read_buffer_limit_bytes`)
and spill threshold (`mcp_gateway.response_spill_threshold_bytes`) merge
`config.local.json` over `config.json`, so a value pinned in the overlay is the
one they use.
and spill threshold (`mcp_gateway.response_spill_threshold_bytes`), the
unattended-turn cap (`dashboard.max_background_turns`) and the xdist worker cap
(`resource_limits.xdist_auto_cap`) merge `config.local.json` over `config.json`,
so a value pinned in the overlay is the one they use.

### CLI Usage

Expand Down
15 changes: 12 additions & 3 deletions src/kiro_crew/dashboard/state_parts/dashboard_services.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The services ``DashboardState`` hosts, and the coordinators it reaches them through.

The lazy coordinator accessors (``_approvals_for`` .. ``_registry_for``) a
Expand Down Expand Up @@ -29,7 +29,13 @@
from typing import TYPE_CHECKING, Any, Callable

from kiro_crew.atomic_write import atomic_write
from kiro_crew.config.loader import _raw_config, config_dir
from kiro_crew.config.loader import (
_raw_config,
config_dir,
config_local_path,
read_merged_config_files,
)
from kiro_crew.config.resolution import _deep_merge
from kiro_crew.dashboard.crew_api_app_turn import grant_of
from kiro_crew.dashboard.dashboard_persistence import DashboardPersistenceCoordinator
from kiro_crew.dashboard.interaction_coordinator import ApprovalCoordinator, QuestionCoordinator
Expand Down Expand Up @@ -294,15 +300,18 @@
def effective_max_background_turns(self: DashboardState) -> int:
"""Configured cap on concurrent unattended turns.

Reads ``config.json → dashboard.max_background_turns`` (same
Reads ``dashboard.max_background_turns`` from ``config.json`` with
``config.local.json`` merged over it (same
``_raw_config`` route ``sandbox.py`` and ``mcp_gateway/pool.py`` use for
their tunables) and clamps to ``[1, MAX_BACKGROUND_TURNS_CEIL]`` so an
operator can widen the fleet without editing code but can never remove
the bound. Unreadable/garbage config falls back to the default rather
than failing a turn.
"""
try:
raw = (_raw_config().get("dashboard") or {}).get(
# config.local.json merged over config.json, as the loader reads them.
merged = _deep_merge(_raw_config(), read_merged_config_files(config_local_path()))
raw = (merged.get("dashboard") or {}).get(
"max_background_turns", self.MAX_BACKGROUND_TURNS
)
val = int(raw)
Expand Down
12 changes: 10 additions & 2 deletions src/kiro_crew/resource_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,17 @@ def _xdist_cap_config() -> int:
the config loader.
"""
try:
from kiro_crew.config.loader import ResourceLimitsConfig, _raw_config
from kiro_crew.config.loader import (
ResourceLimitsConfig,
_raw_config,
config_local_path,
read_merged_config_files,
)
from kiro_crew.config.resolution import _deep_merge

rl = ResourceLimitsConfig.from_raw(_raw_config().get("resource_limits"))
# config.local.json merged over config.json, as the loader reads them.
merged = _deep_merge(_raw_config(), read_merged_config_files(config_local_path()))
rl = ResourceLimitsConfig.from_raw(merged.get("resource_limits"))
if rl.xdist_auto_cap is not None:
return rl.xdist_auto_cap
except Exception: # pragma: no cover - defensive; config must never break a spawn
Expand Down
49 changes: 49 additions & 0 deletions test/test_config_overlay_raw_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,52 @@ def test_the_voice_fallback_reads_the_overlay(tmp_path: Path, monkeypatch) -> No
handler_mod.load_voice_reply_config(None)

assert handler_mod._vc.auto_speak is True


@pytest.mark.parametrize(
("base", "local", "expected"),
[
pytest.param(None, 7, 7, id="overlay-only"),
pytest.param(5, 7, 7, id="overlay-wins"),
pytest.param(5, None, 5, id="base-only"),
pytest.param(None, None, 3, id="default"),
],
)
def test_the_background_turn_cap_reads_the_overlay(
tmp_path: Path, monkeypatch, base, local, expected
) -> None:
from kiro_crew.dashboard.state_parts import dashboard_services

monkeypatch.setenv("KIROCREW_HOME", str(tmp_path))
for name, value in (("config.json", base), ("config.local.json", local)):
if value is not None:
_write(tmp_path / name, {"dashboard": {"max_background_turns": value}})

class _State:
MAX_BACKGROUND_TURNS = 3
MAX_BACKGROUND_TURNS_CEIL = 16
_log = __import__("logging").getLogger("test")

assert dashboard_services.effective_max_background_turns(_State()) == expected


@pytest.mark.parametrize(
("base", "local", "expected"),
[
pytest.param(None, 2, 2, id="overlay-only"),
pytest.param(4, 2, 2, id="overlay-wins"),
pytest.param(4, None, 4, id="base-only"),
pytest.param(None, None, -1, id="default"),
],
)
def test_the_xdist_auto_cap_reads_the_overlay(
tmp_path: Path, monkeypatch, base, local, expected
) -> None:
from kiro_crew import resource_status

monkeypatch.setenv("KIROCREW_HOME", str(tmp_path))
for name, value in (("config.json", base), ("config.local.json", local)):
if value is not None:
_write(tmp_path / name, {"resource_limits": {"xdist_auto_cap": value}})

assert resource_status._xdist_cap_config() == expected
Loading