fix(profiles): --clone-all skips the local-models runtime trees (models/, runtimes/, node/)
43e67d872 (local models) put three machine-scoped trees under the default
HERMES_HOME — models/ (GGUF weights, tens of GB), runtimes/ (managed
llama.cpp binaries) and node/ (managed Node) — and taught backup.py to
exclude them (_EXCLUDED_ROOT_DIRS). `hermes profile create X --clone-all`
from the default profile did not follow: it copied all three into the new
profile, which never reads them (models_dir() resolves from the default
root only) and cannot use them (the binaries are re-downloaded on demand),
turning a clone into a tens-of-GB copy.
Add the three names to _CLONE_ALL_DEFAULT_EXCLUDE_ROOT. The set is gated
on the source being the default profile, so a named profile that really
carries a models/ directory of its own keeps it; and the exclusion applies
at the source root only, so a skill's nested models/ directory is copied
as user data. Kept as a separate literal from backup.py's set on purpose
(backup also matches profiles/<name>/ and importing it here would be a
circular import) with a comment tying the two together.
This commit is contained in:
committed by
Teknium
parent
5f20bb8b63
commit
f11be8979c
@@ -40,11 +40,16 @@ _CLONE_ALL_STRIP: list[str] = ["gateway.pid", "gateway_state.json", "processes.j
|
||||
|
||||
# Infrastructure excluded from --clone-all ONLY when the source is the default profile
|
||||
# (``~/.hermes``): git checkout (+ ~3 GB venv), worktrees, sibling profiles, shared bins,
|
||||
# npm packages. Named profiles never hold these at root, so the gate avoids silently
|
||||
# dropping user data from a named-profile source. Export uses a root allow-list instead
|
||||
# (``_DEFAULT_EXPORT_INCLUDE_ROOT``): an archive is a portable snapshot, a clone must run.
|
||||
# npm packages, and the managed local-models trees — GGUF weights (tens of GB), the
|
||||
# llama.cpp runtime binaries and the managed Node install, all re-downloadable on demand
|
||||
# and resolved from the default root only. Named profiles never hold these at root, so the
|
||||
# gate avoids silently dropping user data from a named-profile source. Export uses a root
|
||||
# allow-list instead (``_DEFAULT_EXPORT_INCLUDE_ROOT``): an archive is a portable snapshot,
|
||||
# a clone must run. The last three mirror ``hermes_cli.backup._EXCLUDED_ROOT_DIRS`` — kept
|
||||
# as separate literals because importing it here would be circular; change both together.
|
||||
_CLONE_ALL_DEFAULT_EXCLUDE_ROOT: frozenset[str] = frozenset({
|
||||
"hermes-agent", ".worktrees", "profiles", "bin", "node_modules",
|
||||
"models", "runtimes", "node",
|
||||
})
|
||||
|
||||
# Per-profile history excluded from --clone-all for ANY source: SQLite session store
|
||||
|
||||
@@ -20,6 +20,7 @@ import yaml
|
||||
|
||||
from hermes_cli import profiles
|
||||
from hermes_cli.profiles import (
|
||||
_clone_all_copytree_ignore,
|
||||
normalize_profile_name,
|
||||
validate_profile_name,
|
||||
get_profile_dir,
|
||||
@@ -1263,3 +1264,59 @@ class TestResolveProfileEnvSpelling:
|
||||
assert Path(resolve_profile_env("default")) == _get_default_hermes_home()
|
||||
|
||||
|
||||
# ===================================================================
|
||||
# TestCloneAllExcludesRuntimeTrees
|
||||
# ===================================================================
|
||||
|
||||
class TestCloneAllExcludesRuntimeTrees:
|
||||
"""``--clone-all`` from the default profile must not copy the machine-scoped
|
||||
runtime trees the local-models flow puts under ``~/.hermes``: ``models/``
|
||||
(GGUF weights, tens of GB), ``runtimes/`` (llama.cpp binaries) and ``node/``
|
||||
(managed Node). ``backup.py`` already excludes exactly these; the clone-all
|
||||
ignore list had not followed.
|
||||
"""
|
||||
|
||||
RUNTIME_TREES = ("models", "runtimes", "node")
|
||||
|
||||
def _seed(self, home):
|
||||
(home / "models").mkdir(); (home / "models" / "big.gguf").write_bytes(b"\0" * 64)
|
||||
(home / "runtimes" / "llamacpp" / "bin").mkdir(parents=True)
|
||||
(home / "runtimes" / "llamacpp" / "bin" / "llama-server").write_text("bin")
|
||||
(home / "node" / "bin").mkdir(parents=True)
|
||||
(home / "node" / "bin" / "node").write_text("bin")
|
||||
(home / "skills" / "greet").mkdir(parents=True)
|
||||
(home / "skills" / "greet" / "SKILL.md").write_text("# greet\n")
|
||||
(home / "config.yaml").write_text("model: test\n")
|
||||
|
||||
def test_ignore_drops_runtime_trees_only_at_the_default_root(self, profile_env):
|
||||
default_home = profile_env / ".hermes"
|
||||
self._seed(default_home)
|
||||
# a skill that happens to carry a nested models/ dir is user data
|
||||
(default_home / "skills" / "greet" / "models").mkdir()
|
||||
ignore = _clone_all_copytree_ignore(default_home)
|
||||
|
||||
at_root = ignore(str(default_home), ["models", "runtimes", "node", "skills", "config.yaml"])
|
||||
nested = ignore(str(default_home / "skills" / "greet"), ["models", "SKILL.md"])
|
||||
|
||||
assert set(at_root) == set(self.RUNTIME_TREES)
|
||||
assert nested == []
|
||||
|
||||
def test_named_profile_source_keeps_its_own_runtime_dirs(self, profile_env):
|
||||
# The exclusion is gated on the default profile: a named profile that
|
||||
# really has a models/ dir of its own must not have it dropped.
|
||||
source = create_profile("source", no_alias=True)
|
||||
(source / "models").mkdir()
|
||||
ignore = _clone_all_copytree_ignore(source)
|
||||
|
||||
assert ignore(str(source), ["models", "runtimes", "node", "SOUL.md"]) == []
|
||||
|
||||
def test_clone_all_from_default_skips_runtime_trees_but_keeps_the_rest(self, profile_env):
|
||||
default_home = profile_env / ".hermes"
|
||||
self._seed(default_home)
|
||||
|
||||
clone = create_profile("clone", clone_all=True, no_alias=True)
|
||||
|
||||
for name in self.RUNTIME_TREES:
|
||||
assert not (clone / name).exists(), name
|
||||
assert (clone / "skills" / "greet" / "SKILL.md").is_file()
|
||||
assert (clone / "config.yaml").is_file()
|
||||
|
||||
Reference in New Issue
Block a user