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.

build(rename): prepare the tree for the package move (#622)

Ruben Lütkef3b2ac4b2dae
diff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.md
index bb38c6179d..8f3cdbdc2f 100644
--- a/docs/ci-pipeline.md
+++ b/docs/ci-pipeline.md
@@ -316,6 +316,34 @@ merge train always runs main's copy and needs no such step.
`classify_changes.py` reads a changed path under either name of the package
directory as the same path, so the move turns no lane off.
+The tree is kept ready for the move, so that the move commit needs no hand
+edits: `--dry-run` reports no undecided hit on main. Three conventions keep it
+that way.
+
+- A test that forbids or blocks imports of the package takes the import names
+ from `tests/package_names.py` instead of spelling one out. After the move it
+ guards the new name and the earlier one, which still resolves to the same
+ modules.
+- A line that carries the old name for another reason (a model id, a folder in
+ somebody's vault, a plugin group written out) ends in a `rename-keep`
+ comment. Where a comment would show up in a document, the file and the name
+ are listed in `UNRESOLVED_PATHS_KEPT` in the script instead.
+- Stored plugin configuration is not rewritten. The marketplace seed catalog
+ and the agent-plugin manifests next to it move as they are (`FROZEN_FILES`):
+ their entries start the bundled servers by module name, an existing install
+ keeps its own copy of that command, and the browser evidence of a plugin is
+ bound to it. Code that has to recognise such a command asks
+ `jarvis/marketplace/bundled_servers.py`, which accepts the module under every
+ name in `LEGACY_PACKAGE_NAMES` (`jarvis/core/branding.py`) and under the name
+ the package is imported as; the push-time privacy scan restates the same
+ names.
+
+The move also rewrites `install/update-contract.json`, which is how the
+release before it finds the moved package (`docs/desktop-installers.md`). A
+release from before that file existed reads the version in the compatibility
+package instead, finds one no release has, and stops before it changes
+anything.
+
## 3. Releases, installers and updates
A release happens **only** when the maintainer asks for one.
diff --git a/docs/local-live-voice-rebuild.md b/docs/local-live-voice-rebuild.md
index 260c9e2948..8b34a5ab67 100644
--- a/docs/local-live-voice-rebuild.md
+++ b/docs/local-live-voice-rebuild.md
@@ -260,8 +260,8 @@ Per session: `listening -> user_speaking -> turn_pending -> responding
### 4.4 The seam: adapter contract and `jarvis/live` fixes
-Adapter `jarvis/plugins/realtime/local_voice.py` (entry point
-`jarvis.realtime`, no `jarvis.*` import at module import):
+Adapter `jarvis/plugins/realtime/local_voice.py` (registered in the
+`jarvis.realtime` entry-point group; the module loads nothing from `jarvis.*`):
- Class attributes: `supports_realtime=True`, `native_tool_orchestration=True`,
`browser_audio=True`, `implicit_usage_fallback_allowed=False`,
diff --git a/jarvis/core/branding.py b/jarvis/core/branding.py
index 57644160db..5ae997cc0a 100644
--- a/jarvis/core/branding.py
+++ b/jarvis/core/branding.py
@@ -175,6 +175,14 @@ LEGACY_MCP_TOOLS_SERVER_NAMES = ("jarvis",)
MCP_AGENTS_SERVER_NAME = "dodaios-agents"
LEGACY_MCP_AGENTS_SERVER_NAMES = ("jarvis-agents",)
+# --- Import names --------------------------------------------------------------
+# Every import name the Python package has been published under. A stored
+# command such as ``python -m <name>.plugins.tool.connected_server`` names its
+# module by one of them and is configuration on somebody's disk, so each name
+# stays recognised for good. The name the package is imported as right now is
+# never restated: code reads it off the package itself (``__name__``).
+LEGACY_PACKAGE_NAMES = ("jarvis",)
+
__all__ = [
"CLI_COMMAND_NAME",
"CLI_COMMAND_NAMES",
@@ -186,6 +194,7 @@ __all__ = [
"LEGACY_CLI_COMMAND_NAMES",
"LEGACY_CONTROL_CLI_COMMAND_NAMES",
"LEGACY_OFFICIAL_REPO_SLUGS",
+ "LEGACY_PACKAGE_NAMES",
"LEGACY_PLUGIN_GROUP_NAMESPACES",
"DESKTOP_OUTPUT_MIRROR_DIR_NAME",
"DISTRIBUTION_NAME",
diff --git a/jarvis/core/update_contract.py b/jarvis/core/update_contract.py
index 0986fcddf3..585fa2d245 100644
--- a/jarvis/core/update_contract.py
+++ b/jarvis/core/update_contract.py
@@ -7,12 +7,13 @@ needs for that is stated by the tree itself in ``install/update-contract.json``,
so a release may move its package, its launcher or its config file and still be
reachable from the version before it.
-A tree without the file — every release before the file existed — is described
-by :data:`DEFAULT_CONTRACT`, which holds exactly the locations those releases
-use. The same answer is given for a file this version cannot trust: an unknown
-schema, malformed JSON, or a value that is not a plain relative location.
-Falling back is the fail-closed choice: the update then looks for the UI bundle
-in the default place, does not find it, and rolls back to the previous revision.
+A tree that states nothing is described by :data:`DEFAULT_CONTRACT`: the
+locations this version uses itself. Only a release from before the file existed
+states nothing, and an update never leads back to one. The same answer is given
+for a file this version cannot trust: an unknown schema, malformed JSON, or a
+value that is not a plain relative location. Falling back is the fail-closed
+choice: a release that moved its files is then looked for in the default place,
+is not found there, and the update rolls back to the previous revision.
Standard library only and no I/O at import time — the restart helper loads this
module, and it must stay a throwaway process.
diff --git a/jarvis/marketplace/bundled_servers.py b/jarvis/marketplace/bundled_servers.py
new file mode 100644
index 0000000000..71ee50ab58
--- /dev/null
+++ b/jarvis/marketplace/bundled_servers.py
@@ -0,0 +1,64 @@
+"""Which stored MCP commands start a server that ships inside this package.
+
+A catalog entry starts a bundled server with ``python -m <module>``. That
+command is stored configuration, not a reference the code owns: the seed
+catalog carries it, a user's catalog override keeps its own copy of it, and
+the browser evidence of a plugin is bound to it. So a command names its module
+the way it was published, and every reader that has to recognise a bundled
+server accepts the module under each name this package has been importable as.
+The earlier names keep resolving to the same modules, so such a command also
+still starts.
+
+Import-light: the route layer and the worker bridge both import this.
+"""
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
+
+__all__ = [
+ "AMD_SERVER_MODULES",
+ "CONNECTED_SERVER_MODULES",
+ "runs_amd_server",
+ "runs_bundled_server",
+ "runs_connected_server",
+]
+
+# Today's import name first, read off this module so that it is right wherever
+# the package lives, then every name it was published under: a stored command
+# that uses one of those is as much a bundled server.
+_PACKAGE_NAMES = tuple(dict.fromkeys((__name__.partition(".")[0], *LEGACY_PACKAGE_NAMES)))
+
+
+def _module_names(suffix: str) -> frozenset[str]:
+ return frozenset(f"{package}.{suffix}" for package in _PACKAGE_NAMES)
+
+
+#: The in-process REST bridge most first-party connectors run through.
+CONNECTED_SERVER_MODULES = _module_names("plugins.tool.connected_server")
+#: The AMD GPU status server.
+AMD_SERVER_MODULES = _module_names("marketplace.amd_mcp")
+
+
+def _module_run(command: Sequence[object]) -> str | None:
+ """The module of ``<interpreter> -m <module> ...``, else ``None``."""
+ if len(command) > 2 and command[1] == "-m" and isinstance(command[2], str):
+ return command[2]
+ return None
+
+
+def runs_connected_server(command: Sequence[object]) -> bool:
+ """True when ``command`` starts the bundled REST bridge."""
+ return _module_run(command) in CONNECTED_SERVER_MODULES
+
+
+def runs_amd_server(command: Sequence[object]) -> bool:
+ """True when ``command`` starts the bundled AMD GPU server."""
+ return _module_run(command) in AMD_SERVER_MODULES
+
+
+def runs_bundled_server(command: Sequence[object]) -> bool:
+ """True when ``command`` starts any server shipped inside this package."""
+ return runs_connected_server(command) or runs_amd_server(command)
diff --git a/jarvis/marketplace/mcp_bridge.py b/jarvis/marketplace/mcp_bridge.py
index 5b50d6f244..3979c8e7aa 100644
--- a/jarvis/marketplace/mcp_bridge.py
+++ b/jarvis/marketplace/mcp_bridge.py
@@ -26,6 +26,7 @@ import logging
import sys
from typing import Any
+from jarvis.marketplace.bundled_servers import runs_bundled_server, runs_connected_server
from jarvis.marketplace.catalog import PluginCatalog
from jarvis.marketplace.token_store import TokenStore
@@ -52,11 +53,7 @@ def _stdio_entry(spec: dict[str, Any], repl: dict[str, str]) -> dict[str, Any] |
return None
command = _resolve_placeholders(str(install[0]), repl)
args = [_resolve_placeholders(str(a), repl) for a in install[1:]]
- if (
- command == "python"
- and args[:1] == ["-m"]
- and args[1:2] in (["jarvis.plugins.tool.connected_server"], ["jarvis.marketplace.amd_mcp"])
- ):
+ if command == "python" and runs_bundled_server([command, *args]):
command = sys.executable
entry: dict[str, Any] = {"command": command, "args": args}
env_template = spec.get("env_template") or {}
@@ -112,10 +109,9 @@ def assemble_claude_mcp_servers(
transport = str(spec.get("transport") or "").lower()
if transport == "stdio":
entry = _stdio_entry(spec, repl)
- if entry is not None and entry.get("args", [])[:2] == [
- "-m",
- "jarvis.plugins.tool.connected_server",
- ]:
+ if entry is not None and runs_connected_server(
+ [entry["command"], *entry.get("args", [])]
+ ):
entry.setdefault("env", {})["JARVIS_CONNECTOR_AUTH_TYPE"] = (
"oauth" if tokens.extra.get("client_id") else "pat"
)
diff --git a/jarvis/marketplace/plugin_mcp.py b/jarvis/marketplace/plugin_mcp.py
index f82d5dc90b..d09439253e 100644
--- a/jarvis/marketplace/plugin_mcp.py
+++ b/jarvis/marketplace/plugin_mcp.py
@@ -11,6 +11,7 @@ from __future__ import annotations
import sys
+from jarvis.marketplace.bundled_servers import runs_bundled_server, runs_connected_server
from jarvis.marketplace.catalog import PluginSpec
from jarvis.marketplace.mcp_bridge import _resolve_placeholders, _token_replacements
from jarvis.marketplace.token_store import Tokens
@@ -60,16 +61,13 @@ def plugin_to_mcp_server_spec(
if not install:
return None
resolved_install = [_resolve_placeholders(str(a), repl) for a in install]
- if resolved_install[:2] == ["python", "-m"] and resolved_install[2:3] in (
- ["jarvis.plugins.tool.connected_server"],
- ["jarvis.marketplace.amd_mcp"],
- ):
+ if resolved_install[:1] == ["python"] and runs_bundled_server(resolved_install):
resolved_install[0] = sys.executable
env_template = spec.get("env_template") or {}
env_overrides = {
str(k): _resolve_placeholders(str(v), repl) for k, v in env_template.items()
}
- if resolved_install[1:3] == ["-m", "jarvis.plugins.tool.connected_server"]:
+ if runs_connected_server(resolved_install):
env_overrides["JARVIS_CONNECTOR_AUTH_TYPE"] = (
"oauth" if tokens.extra.get("client_id") else "pat"
)
diff --git a/jarvis/marketplace/plugin_registry.py b/jarvis/marketplace/plugin_registry.py
index 1c127dcda0..f3ec686eb4 100644
--- a/jarvis/marketplace/plugin_registry.py
+++ b/jarvis/marketplace/plugin_registry.py
@@ -22,6 +22,7 @@ from collections.abc import Callable
from typing import Any
from jarvis.core.protocols import RiskTier, Tool
+from jarvis.marketplace.bundled_servers import runs_connected_server
from jarvis.marketplace.catalog import PluginCatalog, PluginSpec
from jarvis.marketplace.catalog_data import load_catalog
from jarvis.marketplace.plugin_mcp import plugin_to_mcp_server_spec
@@ -593,7 +594,7 @@ class PluginToolRegistry:
def _default_client_factory(spec: Any, *, env_overrides: dict[str, str] | None = None) -> Any:
- if spec.install_command[1:3] == ["-m", "jarvis.plugins.tool.connected_server"]:
+ if runs_connected_server(spec.install_command):
from jarvis.marketplace.bundled_rest_client import BundledRestMcpClient
return BundledRestMcpClient(spec)
diff --git a/jarvis/skills/guards.py b/jarvis/skills/guards.py
index bccd8305d8..8f98fc5ce6 100644
--- a/jarvis/skills/guards.py
+++ b/jarvis/skills/guards.py
@@ -10,8 +10,8 @@ never disagree with what the brain actually did.
Design constraints (all load-bearing):
-* **Zero ``jarvis.*`` imports.** ``jarvis.brain`` already imports
- ``jarvis.skills``; importing back would close a cycle. Guards that need a
+* **Zero ``jarvis.*`` imports.** The brain (``jarvis/brain/``) already imports
+ this package; importing back would close a cycle. Guards that need a
brain-side verdict (the local-action gate, the force-spawn heuristic) receive
it as plain data from the caller instead of reaching for it. Everything here
is pure: same inputs, same verdict, no IO, no clock, no globals.
diff --git a/jarvis/ui/web/fast_bootstrap.py b/jarvis/ui/web/fast_bootstrap.py
index 92046a3093..8ddfe237ff 100644
--- a/jarvis/ui/web/fast_bootstrap.py
+++ b/jarvis/ui/web/fast_bootstrap.py
@@ -11,7 +11,7 @@ after is full speed.
Dependency-light on purpose: nothing heavy is imported at module load and
``uvicorn`` is imported lazily inside :meth:`serve`, so a caller can construct
and bind a :class:`FastBootstrap` *before* paying for ``import fastapi`` /
-``load_config`` / the ``jarvis.brain`` import graph — which is exactly what
+``load_config`` / the import graph of ``jarvis/brain/`` — which is exactly what
keeps those costs off the time-to-serving path.
Contract: the real app delegated to runs ON THE SAME EVENT LOOP that serves the
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index 28f5a0069c..22c1f14ccf 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -57,6 +57,7 @@ from jarvis.marketplace.auth import (
get_registry,
sanitize_provider_error,
)
+from jarvis.marketplace.bundled_servers import runs_amd_server, runs_connected_server
from jarvis.marketplace.catalog import (
CATEGORY_ORDER,
HostedMcpOAuthDcrAuth,
@@ -370,9 +371,9 @@ def _mcp_live(
reg = _live_plugin_registry()
if reg is not None and reg.is_bootstrapped() and reg.live_tool_count(plugin_id) == 0:
return False, reg.last_connect_error(plugin_id) or "No tools loaded; reconnect"
- if install[:3] == ["python", "-m", "jarvis.plugins.tool.connected_server"]:
+ if install[:1] == ["python"] and runs_connected_server(install):
return True, None # Bundled in-process bridge needs no PATH launcher.
- if install[:3] == ["python", "-m", "jarvis.marketplace.amd_mcp"]:
+ if install[:1] == ["python"] and runs_amd_server(install):
import shutil
available = shutil.which("amd-smi") is not None
diff --git a/jarvis/ui/web/update_routes.py b/jarvis/ui/web/update_routes.py
index 27ec88a31b..19d17916bc 100644
--- a/jarvis/ui/web/update_routes.py
+++ b/jarvis/ui/web/update_routes.py
@@ -696,7 +696,8 @@ async def _version_at_revision(root: Path, revision: str) -> str | None:
Where the version is written is asked of the TARGET revision's own update
contract, not assumed from this version's layout. A revision without a
- contract keeps its version where every such release keeps it.
+ contract is read as laid out like this version; ``pyproject.toml`` names
+ its version wherever the package is.
"""
raw_contract = await _git_output(["show", f"{revision}:{CONTRACT_PATH}"], cwd=root)
diff --git a/scripts/ci/privacy_gate/references/distribution-denylist.txt b/scripts/ci/privacy_gate/references/distribution-denylist.txt
index 965a70c1a7..b0c07cd599 100644
--- a/scripts/ci/privacy_gate/references/distribution-denylist.txt
+++ b/scripts/ci/privacy_gate/references/distribution-denylist.txt
@@ -273,17 +273,6 @@ marketing/**
# is ~490 KB of generated report artifact every clone would have to carry.
docs/reports/*marketing-readiness*
-# --- Unfinished TTS-eval harness (2026-07-08) --------------------------------
-# jarvis/speech/tts_eval/* is an internal, in-progress TTS quality-eval tool
-# (corpus + metrics + harness), committed by a parallel session's auto-save. It
-# is not user-facing (nothing in jarvis/ imports it), and its German test-corpus
-# sentences are not yet on the English-artifact allowlist. Slated for the 1.0.4
-# cut once finished + translated/allowlisted. Withhold the module and its tests
-# from the 1.0.3 release.
-jarvis/speech/tts_eval/**
-**/tts_eval/**
-tests/unit/speech/tts_eval/**
-
# --- Obsolete internal Realtime design notes (2026-07-13) -------------------
# These phase-0/1 execution notes still describe Realtime as default-off and
# include an obsolete agent commit recipe. Withhold them until they are replaced
diff --git a/scripts/ci/privacy_pre_push.py b/scripts/ci/privacy_pre_push.py
index 97bad981f1..545794474b 100644
--- a/scripts/ci/privacy_pre_push.py
+++ b/scripts/ci/privacy_pre_push.py
@@ -121,6 +121,15 @@ def forbidden_file(name: str, forbidden: set[str]) -> bool:
return name in forbidden
+#: Earlier import names of the package. A catalog manifest starts a bundled
+#: server by module name and keeps the name it was published with, so each of
+#: these stays an accepted spelling next to the name of the directory the
+#: manifests live in. This hook is standard library only, so the tuple restates
+#: ``LEGACY_PACKAGE_NAMES`` of the package's branding module;
+#: tests/unit/ci/test_public_mcp_privacy.py pins the two together.
+LEGACY_PACKAGE_NAMES = ("jarvis",)
+
+
def is_public_catalog_mcp(rel: str, text: str) -> bool:
"""Recognize only credential-free catalog manifests, using a strict schema subset.
@@ -175,10 +184,16 @@ def is_public_catalog_mcp(rel: str, text: str) -> bool:
return False
if server["type"] != "stdio" or server["command"] != "python":
return False
- expected = ["-m", "jarvis.plugins.tool.connected_server", plugin_id.replace("-", "_")]
- return server["args"] == expected or (
- plugin_id == "amd-gpu" and server["args"] == ["-m", "jarvis.marketplace.amd_mcp"]
- )
+ # The package the manifest belongs to is the directory it sits in.
+ packages = (rel.partition("/")[0], *LEGACY_PACKAGE_NAMES)
+ connector = plugin_id.replace("-", "_")
+ if server["args"] in [
+ ["-m", f"{package}.plugins.tool.connected_server", connector] for package in packages
+ ]:
+ return True
+ return plugin_id == "amd-gpu" and server["args"] in [
+ ["-m", f"{package}.marketplace.amd_mcp"] for package in packages
+ ]
except (ValueError, TypeError, RecursionError):
# Malformed or ambiguous JSON/URLs remain forbidden, without echoing content.
return False
diff --git a/scripts/rename/rewrite_package.py b/scripts/rename/rewrite_package.py
index a2d332ec51..5067c8eaa5 100644
--- a/scripts/rename/rewrite_package.py
+++ b/scripts/rename/rewrite_package.py
@@ -176,15 +176,19 @@ LEGACY_IDENTIFIERS: tuple[Legacy, ...] = (
"entry-point groups",
"jarvis.stt, jarvis.tool, ... are plugin group names installed plugins declare; the "
"additive stage adds the new groups next to them. A group that shares its name with "
- "a module (jarvis.brain) is told apart by context and reported when that fails.",
+ "a module (jarvis.brain) is told apart by context and reported when that fails. "
+ "jarvis.<group> and jarvis.<slot> are how a document writes any group at all.",
r"entry[-_]points?\W{{0,3}}[\"']{old}\.[a-z_<>*]+[\"']"
r"|\bgroup\s*=\s*[\"']{old}\.[a-z_]+[\"']"
- r"|entry_points(?:_for)?\(\s*[\"']{old}\.[a-z_]+[\"']",
+ r"|entry_points(?:_for)?\(\s*[\"']{old}\.[a-z_]+[\"']"
+ r"|{old}\.<(?:group|slot)>",
(
'[project.entry-points."jarvis.brain"]',
'[project.entry-points."jarvis.<group>"]',
'entry_points(group="jarvis.tool")',
'entry_points_for("jarvis.stt")',
+ "the earlier `jarvis.<group>` name stays valid",
+ "every plugin written before the rename registers as ``jarvis.<slot>``",
),
),
Legacy(
@@ -271,6 +275,20 @@ FROZEN_FILES: tuple[Frozen, ...] = (
Frozen("docs/BUGS.md", "the bug register cites paths as they were when a bug was found"),
Frozen("{pkg}/ui/web/dist/**", "generated bundle: moved as is, `npm run build` rewrites it"),
Frozen("{pkg}/ui/web/frontend/src/i18n/**", "i18n texts are product copy, not references"),
+ Frozen(
+ "{pkg}/marketplace/seed_catalog.json",
+ "stored plugin configuration: an entry starts its bundled server by module name "
+ "(`python -m <old>.plugins.tool.connected_server`), that command is copied into "
+ "every install's catalog override and is part of the `config_fingerprint` the "
+ "browser evidence in docs/marketplace/plugin-e2e-audit.json is bound to. Rewritten, "
+ "it would make that evidence stale and every stored command differ from the "
+ "catalog; the compatibility package keeps the old module names starting",
+ ),
+ Frozen(
+ "{pkg}/marketplace/plugins/**",
+ "the agent-plugin form of the same catalog entries: every manifest repeats its "
+ "entry's server command and has to stay equal to it",
+ ),
Frozen("**/package-lock.json", "lockfile, regenerated"),
Frozen("uv.lock", "lockfile, regenerated"),
Frozen("scripts/rename/**", "this codemod: its tables name the old identifiers as data"),
@@ -286,6 +304,10 @@ class LocalPrefix:
glob: str
reason: str
+ #: The names right below ``<old>/`` this entry is about. Empty: every
+ #: unresolved one in the file. Named: only those, so a path to a removed
+ #: module in the same document is still rewritten.
+ names: tuple[str, ...] = ()
UNRESOLVED_PATHS_KEPT: tuple[LocalPrefix, ...] = (
@@ -294,6 +316,27 @@ UNRESOLVED_PATHS_KEPT: tuple[LocalPrefix, ...] = (
"jarvis/<computer>/<time> names the git branch a remote pane's work comes back on",
),
LocalPrefix("tests/unit/agentic_ide/test_remote_*.py", "the same branch prefix, asserted"),
+ LocalPrefix(
+ "board-backend/README.md",
+ "`cd jarvis/board-backend` enters the folder a shell example cloned the repository into",
+ ("board-backend",),
+ ),
+ LocalPrefix(
+ "docs/agent-society/build-plan-m1-m2.md",
+ "`jarvis/agent session lists` names two chat surfaces, not a path",
+ ("agent",),
+ ),
+ LocalPrefix(
+ "docs/LLM-CONTEXT.md",
+ "jarvis/sub_jarvis/ is the tombstone of the deleted sub tier, named as a thing that "
+ "must stay dead; it is not tracked and does not move",
+ ("sub_jarvis",),
+ ),
+ LocalPrefix(
+ "docs/agent-society/research/branch-a-product-ui.md",
+ "the same tombstone",
+ ("sub_jarvis",),
+ ),
)
#: Entry-point group suffixes known without a pyproject (the real list is read
@@ -515,7 +558,11 @@ class Rewriter:
if entry.pattern
]
self._frozen = _for_packages((frozen.glob for frozen in FROZEN_FILES), old, new)
- self._kept_prefixes = _for_packages((kept.glob for kept in UNRESOLVED_PATHS_KEPT), old, new)
+ self._kept_prefixes = [
+ (pattern, kept.names)
+ for kept in UNRESOLVED_PATHS_KEPT
+ for pattern in _for_packages((kept.glob,), old, new)
+ ]
# ----- construction from a checkout
@@ -550,8 +597,13 @@ class Rewriter:
def is_frozen(self, path: str) -> bool:
return any(fnmatch.fnmatchcase(path, pattern) for pattern in self._frozen)
- def keeps_unresolved_paths(self, path: str) -> bool:
- return any(fnmatch.fnmatchcase(path, pattern) for pattern in self._kept_prefixes)
+ def keeps_unresolved_paths(self, path: str, name: str = "") -> bool:
+ """True when ``<old>/<name>`` in the file at ``path`` is a prefix of
+ another kind (``UNRESOLVED_PATHS_KEPT``)."""
+ return any(
+ fnmatch.fnmatchcase(path, pattern) and (not names or name in names)
+ for pattern, names in self._kept_prefixes
+ )
def resolves(self, name: str) -> bool:
"""True when ``name`` is an entry of the package directory."""
@@ -736,7 +788,7 @@ class Rewriter:
return None # ``<old>\b`` in a regular expression, ``<old>\n`` in a string
if state.is_web:
return "keep", "web source: tool prefix"
- if self.keeps_unresolved_paths(state.path):
+ if self.keeps_unresolved_paths(state.path, name):
return "keep", "prefix of another kind"
# ``a/<old>/x.py`` and ``b/<old>/x.py`` in a diff are the path itself.
in_diff = re.search(r"(?:^|[\s\"'`])[ab]/$", text[max(0, start - 3) : start]) is not None
diff --git a/tests/contract/test_realtime_provider_contract.py b/tests/contract/test_realtime_provider_contract.py
index 9c43809dd0..b5ad317a9d 100644
--- a/tests/contract/test_realtime_provider_contract.py
+++ b/tests/contract/test_realtime_provider_contract.py
@@ -17,6 +17,7 @@ from jarvis.plugins.realtime.openai_realtime import (
)
from jarvis.realtime.protocol import RealtimeEvent, RealtimeProvider
from jarvis.realtime.session import RealtimeVoiceSession
+from tests.package_names import is_package_module
# Every installed provider that declares supports_direct_tools=False must pass
# the delegate/decline contracts below. Empty today (the capability-limited
@@ -222,8 +223,8 @@ def test_plugin_module_imports_no_jarvis_modules(path: Path):
if isinstance(node, ast.Import)
for alias in node.names
]
- assert not any(name == "jarvis" or name.startswith("jarvis.") for name in imports)
- assert not any(name == "jarvis" or name.startswith("jarvis.") for name in direct_imports)
+ assert not any(is_package_module(name) for name in imports)
+ assert not any(is_package_module(name) for name in direct_imports)
@pytest.mark.parametrize(
diff --git a/tests/package_names.py b/tests/package_names.py
new file mode 100644
index 0000000000..5f6678d987
--- /dev/null
+++ b/tests/package_names.py
@@ -0,0 +1,24 @@
+"""The import names of the package under test.
+
+A guard that forbids or blocks imports of the package has to cover every name
+the package can be imported as: the one it has today and each earlier one that
+still resolves to the same modules. Tests take the names from here instead of
+spelling one out, so a guard keeps guarding when the package directory moves.
+"""
+
+from __future__ import annotations
+
+import jarvis as _package
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
+
+__all__ = ["PACKAGE_NAME", "PACKAGE_NAMES", "is_package_module"]
+
+#: The name the package is imported as today.
+PACKAGE_NAME = _package.__name__
+#: Every importable name, today's first.
+PACKAGE_NAMES = tuple(dict.fromkeys((PACKAGE_NAME, *LEGACY_PACKAGE_NAMES)))
+
+
+def is_package_module(name: str) -> bool:
+ """True when ``name`` is the package or a module inside it, under any of its names."""
+ return name.partition(".")[0] in PACKAGE_NAMES
diff --git a/tests/unit/agent_runtimes/test_runtime_configs.py b/tests/unit/agent_runtimes/test_runtime_configs.py
index 559b1884fb..1bfe3c555e 100644
--- a/tests/unit/agent_runtimes/test_runtime_configs.py
+++ b/tests/unit/agent_runtimes/test_runtime_configs.py
@@ -229,7 +229,7 @@ def test_openclaw_never_runs_background_turns_or_persona_files(tmp_path):
assert defaults["heartbeat"] == {"every": "0m"}
assert defaults["skipBootstrap"] is True
assert defaults["contextInjection"] == "never"
- assert defaults["model"]["primary"] == "jarvis/gpt-5.2"
+ assert defaults["model"]["primary"] == "jarvis/gpt-5.2" # rename-keep: a model id
assert config["session"]["reset"]["mode"] == "none"
assert "automations" in config["tools"]["deny"]
assert config["tools"]["toolSearch"] is False
diff --git a/tests/unit/ci/test_package_names.py b/tests/unit/ci/test_package_names.py
new file mode 100644
index 0000000000..42faa07fda
--- /dev/null
+++ b/tests/unit/ci/test_package_names.py
@@ -0,0 +1,27 @@
+"""The shared import-name helper that the import guards rely on."""
+
+from __future__ import annotations
+
+import jarvis
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
+from tests.package_names import PACKAGE_NAME, PACKAGE_NAMES, is_package_module
+
+
+def test_the_names_cover_the_imported_package_and_every_earlier_name() -> None:
+ assert PACKAGE_NAME == jarvis.__name__ == jarvis.core.branding.__name__.partition(".")[0]
+ assert PACKAGE_NAMES[0] == PACKAGE_NAME
+ assert set(LEGACY_PACKAGE_NAMES) <= set(PACKAGE_NAMES)
+ assert len(set(PACKAGE_NAMES)) == len(PACKAGE_NAMES)
+
+
+def test_a_module_of_the_package_is_recognised_under_each_name() -> None:
+ for name in PACKAGE_NAMES:
+ assert is_package_module(name)
+ assert is_package_module(f"{name}.core.config")
+ assert not is_package_module(f"{name}x")
+ assert not is_package_module(f"x{name}.core")
+
+
+def test_other_modules_are_not_the_package() -> None:
+ for name in ("", "fastapi", "tests.package_names", "os.path"):
+ assert not is_package_module(name)
diff --git a/tests/unit/ci/test_public_mcp_privacy.py b/tests/unit/ci/test_public_mcp_privacy.py
index 46f82f8cc1..21696c10d4 100644
--- a/tests/unit/ci/test_public_mcp_privacy.py
+++ b/tests/unit/ci/test_public_mcp_privacy.py
@@ -126,6 +126,40 @@ def test_arbitrary_stdio_commands_are_forbidden(args):
)
+def test_a_manifest_may_name_the_server_under_every_package_name():
+ """Published manifests keep the module name they were published with."""
+ from jarvis.core import branding
+
+ assert gate.LEGACY_PACKAGE_NAMES == branding.LEGACY_PACKAGE_NAMES
+ here = PATH.partition("/")[0]
+ assert here == branding.__name__.partition(".")[0]
+ for package in {here, *gate.LEGACY_PACKAGE_NAMES}:
+ server = {
+ "type": "stdio",
+ "command": "python",
+ "args": ["-m", f"{package}.plugins.tool.connected_server", "some_plugin"],
+ }
+ assert gate.is_public_catalog_mcp(
+ PATH.replace("github", "some-plugin"), manifest(server, "some_plugin")
+ ), package
+ amd = {
+ "type": "stdio",
+ "command": "python",
+ "args": ["-m", f"{package}.marketplace.amd_mcp"],
+ }
+ assert gate.is_public_catalog_mcp(
+ PATH.replace("github", "amd-gpu"), manifest(amd, "amd_gpu")
+ ), package
+ stranger = {
+ "type": "stdio",
+ "command": "python",
+ "args": ["-m", "other.plugins.tool.connected_server", "some_plugin"],
+ }
+ assert not gate.is_public_catalog_mcp(
+ PATH.replace("github", "some-plugin"), manifest(stranger, "some_plugin")
+ )
+
+
def test_normalized_stdio_identity_is_allowed():
server = {
"type": "stdio",
diff --git a/tests/unit/ci/test_rewrite_package.py b/tests/unit/ci/test_rewrite_package.py
index c685cc92bb..88a03599b6 100644
--- a/tests/unit/ci/test_rewrite_package.py
+++ b/tests/unit/ci/test_rewrite_package.py
@@ -6,6 +6,8 @@ and expectation, so the codemod itself never rewrites it (``FROZEN_FILES``).
from __future__ import annotations
+import json
+import re
import subprocess
import sys
from pathlib import Path
@@ -153,6 +155,22 @@ const own = /^jarvis\\//i.test(name) ? name.slice("jarvis/".length) : null;
_HISTORY = "- moved `jarvis/core/old.py`; run `python -m jarvis.ui.web.launcher`\n"
+# What the release before the move publishes for its updater.
+_UPDATE_CONTRACT = """{
+ "schema": 1,
+ "ui_bundle_dir": "jarvis/ui/web/dist",
+ "launcher_module": "jarvis.ui.web.launcher",
+ "version_file": "jarvis/__init__.py",
+ "config_file": "jarvis.toml",
+ "macos_app_dir_name": "Personal Jarvis.app",
+ "macos_bundle_id": "com.personal-jarvis.desktop"
+}
+"""
+
+# One catalog entry and its agent-plugin mirror: the same command twice.
+_BUNDLED_SERVER = '"install": ["python", "-m", "jarvis.plugins.tool.connected_server", "zoom"]'
+_SEED_CATALOG = '{"plugins": [{"id": "zoom", "mcp_server": {' + _BUNDLED_SERVER + "}}]}\n"
+
FILES: dict[str, str] = {
"jarvis/__init__.py": '"""The package."""\n\n__version__ = "1.2.3"\n',
"jarvis/__main__.py": _MAIN,
@@ -179,10 +197,16 @@ FILES: dict[str, str] = {
"jarvis/ui/web/frontend/src/i18n/locales/en.json": (
'{"hint": "Run python -m jarvis.ui.web.launcher, see jarvis/core/config.py"}\n'
),
+ "jarvis/marketplace/__init__.py": "",
+ "jarvis/marketplace/seed_catalog.json": _SEED_CATALOG,
+ "jarvis/marketplace/plugins/zoom/plugin.json": _SEED_CATALOG,
+ "jarvis/plugins/tool/__init__.py": "",
+ "jarvis/plugins/tool/connected_server.py": _MAIN,
"jarvis/mcp/__init__.py": "",
"jarvis/mcp/server.py": _MAIN,
"jarvis/mcp/agents/__init__.py": "",
"jarvis/mcp/agents/bridge.py": _MAIN,
+ "install/update-contract.json": _UPDATE_CONTRACT,
"pyproject.toml": _PYPROJECT,
"jarvis.spec": _SPEC,
"jarvis.toml.example": "# settings\n[brain]\n",
@@ -461,6 +485,80 @@ def test_history_and_generated_files_are_moved_but_not_rewritten(repo):
assert _read(repo, f"dodaios/{locale}") == FILES[f"jarvis/{locale}"]
+def test_the_seed_catalog_keeps_the_commands_installs_have_stored(repo):
+ """Its module names are configuration on disk and part of the evidence
+ fingerprint; the same command in any other file follows the package."""
+ codemod.apply(repo, OLD, NEW)
+
+ assert _read(repo, "dodaios/marketplace/seed_catalog.json") == _SEED_CATALOG
+ # Its agent-plugin form says the same thing and has to go on saying it.
+ assert _read(repo, "dodaios/marketplace/plugins/zoom/plugin.json") == _SEED_CATALOG
+ assert _rewritten(_SEED_CATALOG, "docs/example.json") == _SEED_CATALOG.replace(
+ "jarvis.plugins.tool", "dodaios.plugins.tool"
+ )
+ assert codemod.plan(repo, OLD, NEW)[0].pending is False
+
+
+def test_the_frozen_catalog_still_starts_its_server_through_the_old_name(repo):
+ codemod.apply(repo, OLD, NEW)
+ proc = subprocess.run(
+ [sys.executable, "-m", "jarvis.plugins.tool.connected_server"],
+ cwd=repo,
+ capture_output=True,
+ text=True,
+ check=False,
+ creationflags=_NO_WINDOW,
+ )
+ assert proc.returncode == 0, proc.stderr
+ assert "ran jarvis.plugins.tool.connected_server as __main__" in proc.stdout
+
+
+def test_a_named_prefix_of_another_kind_stays_and_real_paths_next_to_it_move():
+ """``UNRESOLVED_PATHS_KEPT`` with names: only those stay in that file."""
+ text = (
+ "a test that jarvis/agent session lists exclude society sessions\n"
+ "the lock pattern from `jarvis/cron/jobs.py:22` and `jarvis/core/config.py`\n"
+ )
+ rewriter = _rewriter()
+
+ data, result = rewriter.rewrite("docs/agent-society/build-plan-m1-m2.md", text.encode("utf-8"))
+
+ assert data.decode("utf-8") == (
+ "a test that jarvis/agent session lists exclude society sessions\n"
+ "the lock pattern from `dodaios/cron/jobs.py:22` and `dodaios/core/config.py`\n"
+ )
+ assert result.ambiguous == []
+ # Anywhere else the same words are still a question for a person.
+ _data, elsewhere = rewriter.rewrite("docs/other.md", text.encode("utf-8"))
+ assert [hit.line for hit in elsewhere.ambiguous] == [1]
+
+
+ "kept", codemod.UNRESOLVED_PATHS_KEPT, ids=[kept.glob for kept in codemod.UNRESOLVED_PATHS_KEPT]
+)
+def test_every_kept_prefix_says_why_and_is_kept(kept):
+ assert kept.reason
+ rewriter = _rewriter()
+ path = kept.glob.replace("{pkg}", OLD).replace("*", "x")
+ for name in kept.names or ("somebody",):
+ text = f"see jarvis/{name} here\n"
+ data, result = rewriter.rewrite(path, text.encode("utf-8"))
+ assert data.decode("utf-8") == text and result.ambiguous == [], (path, name)
+
+
+def test_a_placeholder_for_any_plugin_group_is_a_group_name():
+ text = (
+ "Each group is also read under its earlier name, `jarvis.<group>`.\n"
+ "# and `jarvis.<slot>` (what every plugin published earlier registers under).\n"
+ )
+ for path in ("docs/overview.md", "pyproject.toml", "notes/sample.py"):
+ data, result = _rewriter().rewrite(path, text.encode("utf-8"))
+ assert data.decode("utf-8") == text and result.ambiguous == [], path
+ # Any other placeholder may as well stand for a module: still reported.
+ _data, result = _rewriter().rewrite("docs/overview.md", b"import `jarvis.<module>`\n")
+ assert [hit.line for hit in result.ambiguous] == [1]
+
+
def test_a_line_with_the_pragma_is_left_alone():
text = (
"from jarvis.core import branding # rename-keep: read by an old updater\n"
@@ -850,6 +948,47 @@ def test_the_compatibility_package_carries_a_version_no_release_has(repo):
assert '__version__ = "1.2.3"' in _read(repo, "dodaios/__init__.py")
+# How an updater reads a release's version: releases up to 3.1.1 look in
+# ``jarvis/__init__.py`` and nowhere else first; later ones look in the file
+# the release's own update contract names.
+_VERSION_PATTERN = r'__version__\s*=\s*"([^"]+)"'
+
+
+def test_an_updater_from_before_the_contract_stops_at_the_compatibility_version(repo):
+ """It stages an update only when the version it reads equals the published
+ one. The first match in the old place must therefore be the version no
+ release has - and not, say, an example in a comment above it."""
+ codemod.apply(repo, OLD, NEW)
+
+ match = re.search(_VERSION_PATTERN, _read(repo, "jarvis/__init__.py"), re.MULTILINE)
+
+ assert match is not None and match.group(1) == codemod.STUB_VERSION == "0.0.0"
+
+
+def test_the_update_contract_leads_an_updater_to_the_moved_package(repo):
+ """The release that moves the package must say where everything went: the
+ version before it reads this file from the new revision and nothing else."""
+ codemod.apply(repo, OLD, NEW)
+
+ contract = json.loads(_read(repo, "install/update-contract.json"))
+
+ assert contract == {
+ "schema": 1,
+ "ui_bundle_dir": "dodaios/ui/web/dist",
+ "launcher_module": "dodaios.ui.web.launcher",
+ "version_file": "dodaios/__init__.py",
+ # Identifiers of the installation, not locations of the package.
+ "config_file": "jarvis.toml",
+ "macos_app_dir_name": "Personal Jarvis.app",
+ "macos_bundle_id": "com.personal-jarvis.desktop",
+ }
+ # Every location it names is really there after the move.
+ assert (repo / contract["ui_bundle_dir"] / "index.html").is_file()
+ assert (repo / (contract["launcher_module"].replace(".", "/") + ".py")).is_file()
+ version = re.search(_VERSION_PATTERN, _read(repo, contract["version_file"]), re.MULTILINE)
+ assert version is not None and version.group(1) == "1.2.3"
+
+
# --------------------------------------------------------------------------- this repository
diff --git a/tests/unit/cli/test_app_update.py b/tests/unit/cli/test_app_update.py
index a5f27717bd..094635d0f4 100644
--- a/tests/unit/cli/test_app_update.py
+++ b/tests/unit/cli/test_app_update.py
@@ -226,9 +226,13 @@ from pathlib import Path
from jarvis.cli import app_update
from jarvis.cli.app_update import FINALIZE_FLAG, PROBE_FLAG
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
root = Path(sys.argv[1])
outcome = json.loads(sys.argv[2])
+# Every name the package can be imported as: the one it has here, and the
+# earlier ones that still resolve to it.
+PACKAGE_NAMES = {app_update.__name__.partition(".")[0], *LEGACY_PACKAGE_NAMES}
class PackageIsGone(importlib.abc.MetaPathFinder):
@@ -236,7 +240,7 @@ class PackageIsGone(importlib.abc.MetaPathFinder):
self.late = []
def find_spec(self, name, path=None, target=None):
- if name == "jarvis" or name.startswith("jarvis."):
+ if name.partition(".")[0] in PACKAGE_NAMES:
self.late.append(name)
raise ModuleNotFoundError(f"No module named {name!r}", name=name)
return None
diff --git a/tests/unit/core/test_entry_point_group_spellings.py b/tests/unit/core/test_entry_point_group_spellings.py
index 7fdce2ad9e..db565b443a 100644
--- a/tests/unit/core/test_entry_point_group_spellings.py
+++ b/tests/unit/core/test_entry_point_group_spellings.py
@@ -105,7 +105,10 @@ def test_the_current_and_the_legacy_namespace_come_from_branding() -> None:
assert ep_module.group_spellings("dodaios.tool") == ("dodaios.tool", "jarvis.tool")
[email protected]("group", ["console_scripts", "jarvis", "other.tool", "jarvis."])
+ "group",
+ ["console_scripts", "jarvis", "other.tool", "jarvis."], # rename-keep: group names
+)
def test_a_group_outside_the_plugin_namespaces_has_one_spelling(group: str) -> None:
assert ep_module.group_spellings(group) == (group,)
diff --git a/tests/unit/core/test_identity_migration.py b/tests/unit/core/test_identity_migration.py
index 421107bfce..ef29fd47f4 100644
--- a/tests/unit/core/test_identity_migration.py
+++ b/tests/unit/core/test_identity_migration.py
@@ -41,6 +41,7 @@ from jarvis.core.identity_migration import (
)
from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS
from tests.fakes.fake_keyring_backend import FakeKeyringBackend
+from tests.package_names import PACKAGE_NAMES
MODULE_PATH = Path(engine.__file__).resolve()
@@ -617,8 +618,8 @@ _CHILD = textwrap.dedent(
spec = importlib.util.spec_from_file_location("identity_migration_by_path", module_path)
engine = importlib.util.module_from_spec(spec)
spec.loader.exec_module(engine)
- if any(name == "jarvis" or name.startswith("jarvis.") for name in sys.modules):
- sys.exit("the engine imported the jarvis package")
+ if any(name.partition(".")[0] in PACKAGE_NAMES for name in sys.modules):
+ sys.exit("the engine imported the package it belongs to")
def crash(source, target):
os._exit(70)
@@ -648,7 +649,9 @@ _CHILD = textwrap.dedent(
def child(tmp_path: Path) -> Iterator[Callable[..., subprocess.Popen[str]]]:
"""Start a separate Python process that runs one migration."""
script = tmp_path / "migrate_child.py"
- script.write_text(_CHILD, encoding="utf-8")
+ # The child must not import anything of the package, so the names it
+ # checks for are written into its source.
+ script.write_text(_CHILD.replace("PACKAGE_NAMES", repr(PACKAGE_NAMES)), encoding="utf-8")
started: list[subprocess.Popen[str]] = []
def start(mode: str, legacy: Path, current: Path, go: Path | None = None) -> subprocess.Popen:
diff --git a/tests/unit/core/test_update_contract.py b/tests/unit/core/test_update_contract.py
index 4441889363..30b6f3545f 100644
--- a/tests/unit/core/test_update_contract.py
+++ b/tests/unit/core/test_update_contract.py
@@ -12,7 +12,7 @@ import json
import re
import subprocess
import sys
-from dataclasses import asdict
+from dataclasses import asdict, replace
from pathlib import Path
import pytest
@@ -61,6 +61,28 @@ def test_the_contract_points_at_files_this_tree_really_has() -> None:
assert match.group(1) == jarvis.__version__
+def test_a_package_move_publishes_a_contract_this_reader_follows() -> None:
+ """The codemod that moves the package rewrites the tracked contract. An
+ installed copy of THIS version reads the result from the new release, so
+ it has to parse - under this reader - to the moved locations."""
+ from scripts.rename import rewrite_package as codemod
+
+ package = jarvis.__name__
+ moved = "pkg_after_the_move"
+ layout = ["__init__.py", "ui/web/launcher.py", "ui/web/dist/index.html"]
+ assert all((REPO / package / path).is_file() for path in layout)
+ shipped = (REPO / CONTRACT_PATH).read_bytes()
+
+ published = codemod.Rewriter(package, moved, layout).transform(CONTRACT_PATH, shipped)
+
+ assert parse_update_contract(published.decode("utf-8")) == replace(
+ read_update_contract(REPO),
+ ui_bundle_dir=f"{moved}/ui/web/dist",
+ launcher_module=f"{moved}.ui.web.launcher",
+ version_file=f"{moved}/__init__.py",
+ )
+
+
def test_the_contract_agrees_with_every_other_copy_of_these_names() -> None:
from jarvis.autostart.command import LAUNCHER_MODULE as autostart_launcher
from jarvis.ui import relauncher
diff --git a/tests/unit/install/test_installer_update_contract.py b/tests/unit/install/test_installer_update_contract.py
index df8becb1d8..60290f84ad 100644
--- a/tests/unit/install/test_installer_update_contract.py
+++ b/tests/unit/install/test_installer_update_contract.py
@@ -11,6 +11,8 @@ from types import SimpleNamespace
import pytest
+from tests.package_names import is_package_module
+
REPO = Path(__file__).resolve().parents[3]
_SPEC = importlib.util.spec_from_file_location(
"installer_update_contract", REPO / "install" / "installer.py"
@@ -210,12 +212,12 @@ def test_macos_launch_survives_missing_editable_import(
real_import = builtins.__import__
- def _no_jarvis(name, *args, **kwargs):
- if name.startswith("jarvis"):
- raise ModuleNotFoundError("No module named 'jarvis'")
+ def _no_package(name, *args, **kwargs):
+ if is_package_module(name):
+ raise ModuleNotFoundError(f"No module named {name!r}", name=name)
return real_import(name, *args, **kwargs)
- monkeypatch.setattr(builtins, "__import__", _no_jarvis)
+ monkeypatch.setattr(builtins, "__import__", _no_package)
installer.step_launch(headless=False, dry_run=True)
diff --git a/tests/unit/marketplace/test_bundled_servers.py b/tests/unit/marketplace/test_bundled_servers.py
new file mode 100644
index 0000000000..6e0eeeb23b
--- /dev/null
+++ b/tests/unit/marketplace/test_bundled_servers.py
@@ -0,0 +1,130 @@
+"""A stored MCP command keeps starting a bundled server under every package name.
+
+The seed catalog, a user's catalog override and the browser evidence of a
+plugin all carry the ``python -m <module>`` command a bundled server was
+published with. These tests pin that every reader recognises such a command by
+the published module name AND by the name the package is imported as today -
+they are the same string until the package moves, and both must keep working
+after it has.
+"""
+
+from __future__ import annotations
+
+import importlib
+import sys
+
+import pytest
+
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
+from jarvis.marketplace import bundled_servers
+from jarvis.marketplace.bundled_servers import (
+ AMD_SERVER_MODULES,
+ CONNECTED_SERVER_MODULES,
+ runs_amd_server,
+ runs_bundled_server,
+ runs_connected_server,
+)
+from jarvis.marketplace.catalog import PluginSpec
+from jarvis.marketplace.catalog_data import load_seed_catalog
+from jarvis.marketplace.mcp_bridge import _stdio_entry
+from jarvis.marketplace.plugin_mcp import plugin_to_mcp_server_spec
+from jarvis.marketplace.plugin_registry import _default_client_factory
+from jarvis.marketplace.token_store import Tokens
+
+# The names stored commands were published under. Written out on purpose: they
+# are data on disk in existing installations, not references to this package.
+PUBLISHED_CONNECTED = "jarvis.plugins.tool.connected_server" # rename-keep
+PUBLISHED_AMD = "jarvis.marketplace.amd_mcp" # rename-keep
+
+_PACKAGE = bundled_servers.__name__.partition(".")[0]
+
+
+def _bundled_seed_plugins() -> list[PluginSpec]:
+ return [
+ plugin
+ for plugin in load_seed_catalog().plugins
+ if plugin.mcp_server
+ and str(plugin.mcp_server.get("transport", "")).lower() == "stdio"
+ and list(plugin.mcp_server.get("install") or [])[:2] == ["python", "-m"]
+ ]
+
+
+def test_published_names_stay_bundled_servers() -> None:
+ assert PUBLISHED_CONNECTED.partition(".")[0] in LEGACY_PACKAGE_NAMES
+ assert PUBLISHED_CONNECTED in CONNECTED_SERVER_MODULES
+ assert PUBLISHED_AMD in AMD_SERVER_MODULES
+
+
+def test_the_name_the_package_is_imported_as_is_a_bundled_server() -> None:
+ assert f"{_PACKAGE}.plugins.tool.connected_server" in CONNECTED_SERVER_MODULES
+ assert f"{_PACKAGE}.marketplace.amd_mcp" in AMD_SERVER_MODULES
+ # Each accepted name is a real module, so a stored command still starts.
+ for name in sorted(CONNECTED_SERVER_MODULES | AMD_SERVER_MODULES):
+ assert importlib.import_module(name).__name__.startswith(_PACKAGE + ".")
+
+
+ "command",
+ [
+ ["python", "-m", PUBLISHED_CONNECTED, "zoom"],
+ [sys.executable, "-m", PUBLISHED_CONNECTED, "zoom"],
+ ["python", "-m", f"{_PACKAGE}.plugins.tool.connected_server", "zoom"],
+ ],
+)
+def test_connected_server_commands_are_recognised(command: list[str]) -> None:
+ assert runs_connected_server(command)
+ assert runs_bundled_server(command)
+ assert not runs_amd_server(command)
+
+
+def test_amd_server_command_is_recognised() -> None:
+ assert runs_amd_server(["python", "-m", PUBLISHED_AMD])
+ assert runs_bundled_server(["python", "-m", PUBLISHED_AMD])
+ assert not runs_connected_server(["python", "-m", PUBLISHED_AMD])
+
+
+ "command",
+ [
+ [],
+ ["python"],
+ ["python", "-m"],
+ ["python", "-c", PUBLISHED_CONNECTED],
+ ["python", "-m", "other.plugins.tool.connected_server"],
+ ["python", "-m", PUBLISHED_CONNECTED + ".evil"],
+ ["python", PUBLISHED_CONNECTED, "-m"],
+ ["python", "-m", ["not", "a", "name"]],
+ ["npx", "-y", "@scope/server"],
+ ],
+)
+def test_other_commands_are_not_bundled_servers(command: list[object]) -> None:
+ assert not runs_bundled_server(command)
+
+
+def test_the_seed_catalog_names_only_recognised_bundled_servers() -> None:
+ """The shipped catalog is the stored configuration every install starts from."""
+ plugins = _bundled_seed_plugins()
+ assert plugins, "the seed catalog ships bundled stdio servers"
+ for plugin in plugins:
+ assert runs_bundled_server(plugin.mcp_server["install"]), plugin.id
+
+
+def test_every_reader_treats_a_seed_entry_as_bundled() -> None:
+ """Worker bridge, in-process spec and client factory agree on the seed's commands."""
+ tokens = Tokens(access="token-under-test")
+ for plugin in _bundled_seed_plugins():
+ install = plugin.mcp_server["install"]
+
+ entry = _stdio_entry(plugin.mcp_server, {})
+ assert entry is not None
+ assert entry["command"] == sys.executable, plugin.id
+
+ built = plugin_to_mcp_server_spec(plugin, tokens)
+ assert built is not None
+ spec, env = built
+ assert spec.install_command[0] == sys.executable, plugin.id
+
+ if runs_connected_server(install):
+ assert env["JARVIS_CONNECTOR_AUTH_TYPE"] == "pat", plugin.id
+ client = _default_client_factory(spec, env_overrides=env)
+ assert type(client).__name__ == "BundledRestMcpClient", plugin.id
diff --git a/tests/unit/memory/wiki/test_secret_guard.py b/tests/unit/memory/wiki/test_secret_guard.py
index d855053e3a..cc4cb5aa3a 100644
--- a/tests/unit/memory/wiki/test_secret_guard.py
+++ b/tests/unit/memory/wiki/test_secret_guard.py
@@ -10,6 +10,10 @@ import pytest
from jarvis.memory.wiki.secret_guard import contains_secret, find_secrets
+# Assembled at runtime: the guard under test sees the complete PEM header, while
+# the repository's own secret scan never finds a key block in this file.
+_PEM_HEADER = "-----BEGIN RSA " + "PRIVATE KEY-----"
+
@pytest.mark.parametrize(
"body",
@@ -23,7 +27,7 @@ from jarvis.memory.wiki.secret_guard import contains_secret, find_secrets
"token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NSJ9.sig",
"google AIzaSyA1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7",
"key xai-aBcDeFgHiJkLmNoPqRsTuVwXyZ012345",
- "-----BEGIN RSA PRIVATE KEY-----",
+ _PEM_HEADER,
# 64-char hex = SHA-256-length opaque secret (the long-hex rule).
"checksum 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
],
diff --git a/tests/unit/screen_context/test_redaction.py b/tests/unit/screen_context/test_redaction.py
index d40367515e..54e5fa18e8 100644
--- a/tests/unit/screen_context/test_redaction.py
+++ b/tests/unit/screen_context/test_redaction.py
@@ -160,7 +160,9 @@ def test_multiple_pattern_families_are_all_applied() -> None:
def test_private_key_header_is_caught() -> None:
- scrubbed, _ = scrub_text("-----BEGIN OPENSSH PRIVATE KEY-----", build_patterns())
+ # Assembled at runtime so the repository's own secret scan finds no key block here.
+ header = "-----BEGIN OPENSSH " + "PRIVATE KEY-----"
+ scrubbed, _ = scrub_text(header, build_patterns())
assert "PRIVATE KEY" not in scrubbed
diff --git a/tests/unit/setup/test_obsidian_detector.py b/tests/unit/setup/test_obsidian_detector.py
index f53ac905b0..0ee8a5d8e6 100644
--- a/tests/unit/setup/test_obsidian_detector.py
+++ b/tests/unit/setup/test_obsidian_detector.py
@@ -332,7 +332,8 @@ def test_is_vault_registered_no_match() -> None:
def test_is_vault_registered_trailing_slash_robust() -> None:
"""One path with trailing backslash, the other without, still match."""
vaults = [
- VaultEntry(id="x", path=Path(r"C:\Users\Admin\Vaults\jarvis\\")),
+ # The folder name of somebody's vault, not the package.
+ VaultEntry(id="x", path=Path(r"C:\Users\Admin\Vaults\jarvis\\")), # rename-keep
]
expected = Path(r"C:\Users\Admin\Vaults\jarvis")
diff --git a/tests/unit/skills/test_guards.py b/tests/unit/skills/test_guards.py
index dbecdbb149..cf43269814 100644
--- a/tests/unit/skills/test_guards.py
+++ b/tests/unit/skills/test_guards.py
@@ -230,7 +230,7 @@ def test_explicit_heavy_request_stands_the_skill_down() -> None:
def test_guards_module_has_no_jarvis_imports() -> None:
- """A reverse import would close the jarvis.brain -> jarvis.skills cycle."""
+ """A reverse import would close the cycle between the brain and the skills package."""
from pathlib import Path
import jarvis.skills.guards as module
diff --git a/tests/unit/ui/test_relauncher_update_contract.py b/tests/unit/ui/test_relauncher_update_contract.py
index 7e4f8f91b5..e5d5f42b26 100644
--- a/tests/unit/ui/test_relauncher_update_contract.py
+++ b/tests/unit/ui/test_relauncher_update_contract.py
@@ -602,7 +602,11 @@ class _Crossing:
)
[email protected](params=["jarvis", "pkg_old"])
+# The package directory a tree is assumed to use when it states no contract.
+DEFAULT_PACKAGE = DEFAULT_CONTRACT.version_file.partition("/")[0]
+
+
[email protected](params=[DEFAULT_PACKAGE, "pkg_old"])
def crossing(request: pytest.FixtureRequest, tmp_path: Path) -> _Crossing:
"""``old`` keeps its package at the default place without a contract, or
elsewhere with one; ``new`` moved everything to ``pkg_new``."""
@@ -617,7 +621,7 @@ def crossing(request: pytest.FixtureRequest, tmp_path: Path) -> _Crossing:
_write_package(root, old_package, "1.0.0")
_write_installer(root, fails_on_request=False)
- if old_package != "jarvis":
+ if old_package != DEFAULT_PACKAGE:
_write_contract(
root,
UpdateContract(
@@ -803,11 +807,16 @@ if simulated != "native":
# real OS. Only the package under test sees the simulated one.
sys.platform = simulated
+from jarvis.core.branding import LEGACY_PACKAGE_NAMES
from jarvis.ui import relauncher
if preload == "skip":
relauncher._load_modules_needed_after_update = lambda: None
+# Every name the package can be imported as: the one it has here, and the
+# earlier ones that still resolve to it.
+PACKAGE_NAMES = {relauncher.__name__.partition(".")[0], *LEGACY_PACKAGE_NAMES}
+
class PackageIsGone(importlib.abc.MetaPathFinder):
# After the reset the old package is no longer on disk: refuse and record.
@@ -816,7 +825,7 @@ class PackageIsGone(importlib.abc.MetaPathFinder):
self.late = []
def find_spec(self, name, path=None, target=None):
- if name == "jarvis" or name.startswith("jarvis."):
+ if name.partition(".")[0] in PACKAGE_NAMES:
self.late.append(name)
raise ModuleNotFoundError(f"No module named {name!r}", name=name)
return None
@@ -865,7 +874,9 @@ def run_update_command(cmd, *, root, timeout):
if cmd[:3] == ["git", "reset", "--hard"]:
if guard not in sys.meta_path:
# From here on the checkout holds a release that moved its package.
- loaded_at_reset.extend(sorted(m for m in sys.modules if m.split(".")[0] == "jarvis"))
+ loaded_at_reset.extend(
+ sorted(m for m in sys.modules if m.partition(".")[0] in PACKAGE_NAMES)
+ )
sys.meta_path.insert(0, guard)
if cmd[3] == target:
checkout["on_target"] = True
diff --git a/tests/unit/ui/web/test_boot_critical_path_stays_light.py b/tests/unit/ui/web/test_boot_critical_path_stays_light.py
index 9bf1ef48c4..e1799cc16a 100644
--- a/tests/unit/ui/web/test_boot_critical_path_stays_light.py
+++ b/tests/unit/ui/web/test_boot_critical_path_stays_light.py
@@ -2,8 +2,8 @@
The desktop/headless serve-first boot only stays fast because the
``FastBootstrap`` can bind the port and serve the UI shell BEFORE the heavy
-imports (``fastapi``, the ``jarvis.brain`` graph, ``jarvis.core.config`` with
-its brain pulls) are paid. If a future change makes
+imports (``fastapi``, the brain graph under ``jarvis/brain/``,
+``jarvis.core.config`` with its brain pulls) are paid. If a future change makes
``jarvis.ui.web.fast_bootstrap`` transitively import any of those, the bind
moves back behind the heavy work and the boot silently regresses — the exact
"it keeps getting slower as I add features" rot this guards against.
@@ -18,9 +18,11 @@ from __future__ import annotations
import subprocess
import sys
+from tests.package_names import PACKAGE_NAME
+
# Modules that must NOT be pulled in merely by importing the bootstrap. Each is a
# multi-hundred-ms import that the serve-first boot deliberately defers.
-_FORBIDDEN = ("fastapi", "jarvis.brain", "jarvis.core.config")
+_FORBIDDEN = ("fastapi", f"{PACKAGE_NAME}.brain", f"{PACKAGE_NAME}.core.config")
def test_fast_bootstrap_import_stays_light() -> None:
diff --git a/tests/unit/voice_engine/test_package_contract.py b/tests/unit/voice_engine/test_package_contract.py
index 083de8859b..ff25d59301 100644
--- a/tests/unit/voice_engine/test_package_contract.py
+++ b/tests/unit/voice_engine/test_package_contract.py
@@ -8,6 +8,7 @@ from pathlib import Path
import jarvis.voice_engine as engine
from jarvis.voice_engine import models
+from tests.package_names import PACKAGE_NAMES, is_package_module
PACKAGE = Path(engine.__file__).parent
_HEAVY = {"onnxruntime", "sherpa_onnx", "torch", "pocket_tts", "faster_qwen3_tts", "mlx", "soxr",
@@ -27,12 +28,17 @@ def _imports(path: Path) -> list[tuple[str, bool]]:
return found
+def _is_engine_module(module: str) -> bool:
+ engines = [f"{package}.voice_engine" for package in PACKAGE_NAMES]
+ return any(module == engine or module.startswith(engine + ".") for engine in engines)
+
+
def test_engine_imports_nothing_from_the_app() -> None:
offenders = [
(path.name, module)
for path in PACKAGE.rglob("*.py")
for module, _ in _imports(path)
- if module.startswith("jarvis.") and not module.startswith("jarvis.voice_engine")
+ if is_package_module(module) and not _is_engine_module(module)
]
assert offenders == []