The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(termux): rebuild cached runtime notices with their libraries
ethernetdd4bcda813c7
diff --git a/scripts/termux/stage_runtime_libs.py b/scripts/termux/stage_runtime_libs.pyindex 03f5da7e1a4..d20aa29b20f 100644--- a/scripts/termux/stage_runtime_libs.py+++ b/scripts/termux/stage_runtime_libs.py@@ -145,9 +145,8 @@ def stage(payload: Path, table: dict, licenses: dict | None = None) -> Path:return out# A cache miss rebuilds from verified archives, never scratch extracts.- manifest_path.unlink(missing_ok=True)- if out.exists():- shutil.rmtree(out)+ if out.parent.exists():+ shutil.rmtree(out.parent)out.mkdir(parents=True, exist_ok=True)merged = 0diff --git a/tests/hermes_cli/test_cmd_update.py b/tests/hermes_cli/test_cmd_update.pyindex 2a29467de42..6d0991ed53d 100644--- a/tests/hermes_cli/test_cmd_update.py+++ b/tests/hermes_cli/test_cmd_update.py@@ -23,6 +23,9 @@ def _isolate_venv_holders(monkeypatch):import hermes_cli.main as cli_mainmonkeypatch.setattr(cli_main, "_detect_venv_python_processes", lambda: [])+ # Collection can import native extensions from other test files. This+ # suite tests branch and migration behavior, not Windows self-locking.+ monkeypatch.setattr(cli_main, "_detect_self_loaded_native_modules", lambda: [])def _make_run_side_effect(branch="main", verify_ok=True, commit_count="0"):@@ -309,6 +312,32 @@ class TestUpdateManagedPythonEnvIsolation:class TestCmdUpdateBranchFallback:"""cmd_update falls back to main when current branch has no remote counterpart."""+ def test_self_lock_defers_only_after_the_code_pull(self, mock_args, monkeypatch):+ from hermes_cli import main as hm++ events = []+ git_result = _make_run_side_effect(commit_count="1")++ def run(cmd, **kwargs):+ if "fetch" in cmd:+ events.append("fetch")+ if "merge" in cmd and "--ff-only" in cmd:+ events.append("code-merge")+ return git_result(cmd, **kwargs)++ def locked():+ events.append("self-lock")+ return ["held native extension"]++ monkeypatch.setattr(hm, "_detect_self_loaded_native_modules", locked)+ monkeypatch.setattr(hm, "_defer_update_for_self_lock", lambda modules: None)+ monkeypatch.setattr(hm, "_get_origin_url", lambda *args: "https://github.com/NousResearch/hermes-agent.git")+ with patch("shutil.which", return_value=None), patch("subprocess.run", side_effect=run):+ with pytest.raises(SystemExit) as exc:+ cmd_update(mock_args)+ assert exc.value.code == 2+ assert events.index("fetch") < events.index("code-merge") < events.index("self-lock")+diff --git a/tests/hermes_cli/test_update_self_lock.py b/tests/hermes_cli/test_update_self_lock.pyindex 95ab333b4c2..c02361a47bd 100644--- a/tests/hermes_cli/test_update_self_lock.py+++ b/tests/hermes_cli/test_update_self_lock.py@@ -232,31 +232,6 @@ def test_abort_helper_resumes_paused_gateways_before_exit():# ----------------------------------------------------------------------------def test_pre_fetch_flow_has_no_self_lock_preflight():- """#86780 regression: a loaded native module must not block the git fetch.-- The old preflight sat between the venv-holder sweep and the fetch, so a- universally-loaded module (bitwarden's module-level cryptography import)- deferred every update before any code was pulled — the Windows infinite- update loop. The deferral now lives at the dependency-sync boundaries- only; the stretch of _cmd_update_impl between the venv-holder sweep and- the fetch must not consult the detector at all.- """- import inspect-- src = inspect.getsource(update_cmd._cmd_update_impl)- fetch_idx = src.index("Fetching updates")- pre_fetch = src[:fetch_idx]- assert "_detect_self_loaded_native_modules()" not in pre_fetch- assert "_m()._abort_dependency_sync_if_self_locked" not in pre_fetch- # ... and it must still guard the dependency sync after the code swap- # (the sync itself lives in _sync_python_dependencies_after_pull).- post_fetch = src[fetch_idx:] + inspect.getsource(update_cmd._apply_pulled_update)- assert "_sync_python_dependencies_after_pull(" in post_fetch- sync_src = inspect.getsource(update_cmd._sync_python_dependencies_after_pull)- assert "_m()._abort_dependency_sync_if_self_locked" in sync_src--def test_zip_update_guards_dependency_sync():import inspectdiff --git a/tests/test_termux_runtime_libs.py b/tests/test_termux_runtime_libs.pyindex 24718dc14cd..b6fdf57737e 100644--- a/tests/test_termux_runtime_libs.py+++ b/tests/test_termux_runtime_libs.py@@ -205,6 +205,18 @@ def test_collision_identical_ok_conflicting_raises(tmp_path, lib_source):srl.stage(tmp_path / "payload", table)+def test_rebuild_removes_superseded_license_files(tmp_path, lib_source):+ _, table = lib_source+ out = _stage(tmp_path, table)+ stale = out.parent / "share/doc/obsolete/copyright"+ stale.parent.mkdir(parents=True)+ stale.write_text("old package notice", encoding="utf-8")+ table["liba"]["version"] = "next"+ srl.stage(tmp_path / "payload", table)+ assert not stale.exists()+ assert (out / "liba.so").is_file()++def test_stale_scratch_cannot_poison_a_rebuilt_cache(tmp_path, lib_source):_, table = lib_sourceout = _stage(tmp_path, table)