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.

test: stop the seed-boot brain build from leaking the global SkillContext into later tests

Personal Jarvis Maintainer1c1900a33ad9
diff --git a/tests/integration/test_capability_seed_boot.py b/tests/integration/test_capability_seed_boot.py
index d42e9774fd..423e704ce6 100644
--- a/tests/integration/test_capability_seed_boot.py
+++ b/tests/integration/test_capability_seed_boot.py
@@ -23,13 +23,29 @@ from jarvis.core.capabilities_seed import seed_registry
@pytest.fixture()
def empty_registry():
"""Reset the process-wide registry to the real (empty) boot state, then
- restore a seeded registry afterwards so later tests are not polluted."""
+ restore a seeded registry afterwards so later tests are not polluted.
+
+ The production brain build under test also installs the process-global
+ SkillContext (loaded with whatever skills the host machine carries).
+ Left in place, it made ``_should_force_spawn``'s installed-skill guard
+ stand down in UNRELATED later tests — the routing suite's
+ 'Wie viele PRs sind in jarvis-repo offen?' spawn # i18n-allow: quoted fixture utterance
+ params failed in every full run while staying green file-scoped. Restore
+ the pre-test context so the build's side effects end with this test.
+ """
+ from jarvis.skills.skill_context import (
+ set_skill_context,
+ try_get_skill_context,
+ )
+
reg = get_registry()
reg._caps.clear() # noqa: SLF001 — deliberately simulate fresh boot
+ prior_skill_ctx = try_get_skill_context()
try:
yield reg
finally:
seed_registry(reg) # leave a populated registry for downstream tests
+ set_skill_context(prior_skill_ctx)
def test_build_default_brain_seeds_capability_registry(empty_registry) -> None:
diff --git a/tests/unit/brain/test_routing.py b/tests/unit/brain/test_routing.py
index 2e2dccea4f..21338ed2ae 100644
--- a/tests/unit/brain/test_routing.py
+++ b/tests/unit/brain/test_routing.py
@@ -29,6 +29,37 @@ from jarvis.core.protocols import ToolResult
from jarvis.ui.web.mission_inject import MISSION_INJECT_SOURCE_LAYER
[email protected](autouse=True)
+def _hermetic_capability_registry():
+ """Snapshot/restore the process-global CapabilityRegistry per test.
+
+ ``_should_force_spawn`` consults ``get_registry().resolve_intent`` (the
+ connected-CLI/skill stand-down), so a capability another test file leaves
+ registered flips this module's routing verdicts — in the full suite the
+ 'Wie viele PRs sind in jarvis-repo offen?' spawn params # i18n-allow: quoted fixture utterance
+ failed while every file-scoped run stayed green. These tests pin the
+ heuristic on an UNSEEDED registry; tests that need a capability register
+ it themselves (see the snapshot pattern further down).
+ """
+ from jarvis.core.capabilities import get_registry
+ from jarvis.skills.skill_context import (
+ set_skill_context,
+ try_get_skill_context,
+ )
+
+ reg = get_registry()
+ snapshot = dict(reg._caps) # noqa: SLF001 — test fixture state restore
+ reg._caps.clear() # noqa: SLF001
+ prior_skill_ctx = try_get_skill_context()
+ set_skill_context(None)
+ try:
+ yield
+ finally:
+ reg._caps.clear() # noqa: SLF001
+ reg._caps.update(snapshot) # noqa: SLF001
+ set_skill_context(prior_skill_ctx)
+
+
class _FakeTool:
name = "spawn_worker"
schema: dict[str, Any] = {}