Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
perf(runtime): stop prepare reinstalling managed deps that are already current (#1603)
Call White1e6589bda912
diff --git a/tests/test_local_deps.py b/tests/test_local_deps.pyindex d10a5f8ef..61fef0996 100644--- a/tests/test_local_deps.py+++ b/tests/test_local_deps.py@@ -823,6 +823,263 @@ def test_reconcile_askill_auto_update_skips_when_disabled(monkeypatch):assert out == {"ok": True, "skipped": True, "reason": "askill_auto_update_disabled"}+def test_refresh_askill_if_stale_does_not_run_the_installer_when_current(monkeypatch):+ # The askill.sh installer re-downloads the CLI whenever it runs, so the+ # shared currency owner must answer "already current" without invoking it.+ monkeypatch.setattr(+ api,+ "askill_update_status",+ lambda **_: {+ "id": "askill",+ "installed": True,+ "version": "0.1.14",+ "status": "ready",+ "path": "/x/askill",+ "latest_version": "0.1.14",+ "has_update": False,+ },+ )+ monkeypatch.setattr(api, "ensure_askill_installed", lambda force=False: pytest.fail("should not install"))++ out = api.refresh_askill_if_stale()++ assert out["ok"] is True+ assert out["reason"] == "up_to_date"+ assert "action" not in out+++def test_refresh_askill_if_stale_ignores_the_auto_update_gate(monkeypatch):+ # ``VIBE_ASKILL_AUTO_UPDATE`` disables the update-checker cadence, not the+ # lifecycle refresh that ``vibe runtime prepare`` performs; keeping the gate+ # in the cadence wrapper is what lets both callers share one decision.+ monkeypatch.setenv("VIBE_ASKILL_AUTO_UPDATE", "0")+ monkeypatch.setattr(+ api,+ "askill_update_status",+ lambda **_: {+ "id": "askill",+ "installed": True,+ "version": "0.1.13",+ "status": "ready",+ "latest_version": "0.1.14",+ "has_update": True,+ },+ )+ calls = []+ monkeypatch.setattr(+ api,+ "ensure_askill_installed",+ lambda force=False: calls.append(force) or {"ok": True, "installed": True, "changed": True, "path": "/x/askill"},+ )++ out = api.refresh_askill_if_stale()++ assert calls == [True]+ assert out["action"] == "update"+++def test_refresh_avault_if_stale_does_not_force_when_the_pin_is_satisfied(monkeypatch):+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: "/usr/local/bin/avault")+ monkeypatch.setattr(api, "_probe_avault_version", lambda _path: api.AVAULT_VERSION)+ monkeypatch.setattr(api, "install_avault", lambda force=False: pytest.fail("should not reinstall the pinned release"))++ out = api.refresh_avault_if_stale()++ assert out["ok"] is True+ assert out["changed"] is False+ assert out["version"] == api.AVAULT_VERSION+++def test_refresh_avault_if_stale_upgrades_a_binary_below_the_pin(monkeypatch):+ # Skipping the install is conditional on the pin, not unconditional: prepare+ # still has to raise a stale managed binary on upgrade.+ stale = api.AVAULT_P2_MIN_VERSION+ assert api._version_at_least(api.AVAULT_VERSION, stale)+ state = {"version": stale}+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: "/usr/local/bin/avault")+ monkeypatch.setattr(api, "_probe_avault_version", lambda _path: state["version"])+ calls = []++ def _install(force=False):+ calls.append(force)+ state["version"] = api.AVAULT_VERSION+ return {"ok": True}++ monkeypatch.setattr(api, "install_avault", _install)++ out = api.refresh_avault_if_stale()++ assert calls == [True]+ assert out["ok"] is True+ assert out["version"] == api.AVAULT_VERSION+++def test_refresh_avault_if_stale_installs_when_missing(monkeypatch):+ state = {"path": None}+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: state["path"])+ monkeypatch.setattr(api, "_probe_avault_version", lambda path: api.AVAULT_VERSION if path else None)+ calls = []++ def _install(force=False):+ calls.append(force)+ state["path"] = "/usr/local/bin/avault"+ return {"ok": True}++ monkeypatch.setattr(api, "install_avault", _install)++ out = api.refresh_avault_if_stale()++ assert calls == [True]+ assert out["ok"] is True+ assert out["installed"] is True+ assert out["version"] == api.AVAULT_VERSION+++def _stub_avault_install_state(monkeypatch, *, version, ready_floor):+ """Answer every avault code path from one fake on-disk install."""+ state = {"version": version, "installs": 0}+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: "/usr/local/bin/avault" if state["version"] else None)+ monkeypatch.setattr(api, "_probe_avault_version", lambda path: state["version"] if path else None)+ monkeypatch.setattr(api, "_avault_ready_min_version", lambda: ready_floor)+ monkeypatch.setattr(+ api,+ "_managed_avault_release_satisfies_ready_minimum",+ lambda: api._version_at_least(api.AVAULT_VERSION, ready_floor),+ )++ def _install(force=False):+ state["installs"] += 1+ state["version"] = api.AVAULT_VERSION+ return {"ok": True, "changed": True}++ monkeypatch.setattr(api, "install_avault", _install)+ return state+++ "version, ready_floor",+ [+ (None, api.AVAULT_VERSION),+ ("0.1.1", api.AVAULT_VERSION),+ (api.AVAULT_VERSION, api.AVAULT_VERSION),+ ("99.0.0", api.AVAULT_VERSION),+ (api.AVAULT_VERSION, "99.0.0"),+ ],+)+def test_refresh_avault_if_stale_never_answers_healthier_than_forcing(monkeypatch, version, ready_floor):+ # The property the whole change rests on: skipping a redundant download may+ # not change the verdict. Whatever ``ensure_avault_installed(force=True)``+ # concludes about an install state, the currency path must conclude the same+ # thing — it may only skip the reinstall. Being at the pin is not the whole+ # of being ready: when the readiness floor is raised ahead of the published+ # pin, a binary equal to the pin is still ``upgrade_required``, and only the+ # forced path used to say so.+ forced_state = _stub_avault_install_state(monkeypatch, version=version, ready_floor=ready_floor)+ forced = api.ensure_avault_installed(force=True)++ stale_state = _stub_avault_install_state(monkeypatch, version=version, ready_floor=ready_floor)+ stale = api.refresh_avault_if_stale()++ assert stale["ok"] == forced["ok"]+ assert stale.get("status") == forced.get("status")+ assert stale.get("reason") == forced.get("reason")+ assert stale_state["installs"] <= forced_state["installs"]+++def test_refresh_askill_if_stale_repairs_an_unreadable_binary_without_the_latest_probe(monkeypatch):+ # A binary that cannot report its version is broken, not current, and that+ # verdict must not depend on the upstream probe answering: prepare used to+ # force this install unconditionally, so gating the repair on a reachable+ # latest would report a broken askill as ready during a network blip.+ monkeypatch.setattr(+ api,+ "askill_status",+ lambda: {"id": "askill", "installed": True, "version": None, "status": "unknown", "path": "/x/askill"},+ )+ monkeypatch.setattr(api, "_cached_latest_askill", lambda: None)+ calls = []+ monkeypatch.setattr(+ api,+ "ensure_askill_installed",+ lambda force=False: calls.append(force) or {"ok": True, "installed": True, "changed": True, "path": "/x/askill"},+ )++ out = api.refresh_askill_if_stale()++ assert calls == [True]+ assert out["action"] == "refresh_unknown_version"+++# Strings a version probe can produce that no comparison can order: absent,+# empty, a development build, a git description, a partial number. The point is+# not the list — it is that each one makes `_compare_versions` answer False, the+# same answer it gives for "already newest", which is how "cannot tell" used to+# be read as "current".+UNORDERABLE_VERSIONS = [None, "", "dev", "unknown", "askill", "g1a2b3c", "0.1.x"]++[email protected]("version", UNORDERABLE_VERSIONS)+def test_askill_status_calls_an_unorderable_version_unknown(monkeypatch, version):+ # One field owns the fact, so prepare and the Dependencies page cannot+ # disagree about whether a binary reporting `dev` is healthy.+ monkeypatch.setattr(+ api,+ "askill_status",+ lambda: {"id": "askill", "installed": True, "version": version, "status": "ready", "path": "/x/askill"},+ )+ monkeypatch.setattr(api, "_cached_latest_askill", lambda: "0.1.14")++ assert api.askill_update_status()["status"] == "unknown"++[email protected]("version", UNORDERABLE_VERSIONS)+def test_refresh_askill_if_stale_repairs_an_unorderable_local_version(monkeypatch, version):+ # `up_to_date` must be an affirmative verdict, never the branch everything+ # unrecognised falls into. A version that cannot be ordered against the+ # published one means unknown, and unknown gets the repair the forced path+ # would have performed — asserted over the shapes a probe can produce rather+ # than over the one the review happened to name.+ monkeypatch.setattr(+ api,+ "askill_status",+ lambda: {"id": "askill", "installed": True, "version": version, "status": "ready", "path": "/x/askill"},+ )+ monkeypatch.setattr(api, "_cached_latest_askill", lambda: "0.1.14")+ calls = []+ monkeypatch.setattr(+ api,+ "ensure_askill_installed",+ lambda force=False: calls.append(force) or {"ok": True, "installed": True, "changed": True},+ )++ out = api.refresh_askill_if_stale()++ assert calls == [True], f"{version!r} is not a version we can trust as current"+ assert out["action"] == "refresh_unknown_version"++[email protected]("latest", UNORDERABLE_VERSIONS)+def test_refresh_askill_if_stale_needs_an_orderable_latest_to_claim_currency(monkeypatch, latest):+ # The same rule on the upstream side: with nothing orderable to compare+ # against, staleness is undecided. The owner reports that instead of+ # currency, and each caller decides (prepare installs, the cadence skips).+ monkeypatch.setattr(+ api,+ "askill_status",+ lambda: {"id": "askill", "installed": True, "version": "0.1.14", "status": "ready", "path": "/x/askill"},+ )+ monkeypatch.setattr(api, "_cached_latest_askill", lambda: latest)+ monkeypatch.setattr(api, "ensure_askill_installed", lambda force=False: pytest.fail("the owner decides, it does not install here"))++ out = api.refresh_askill_if_stale()++ assert out["reason"] == "latest_unavailable"++def test_dependencies_status_shape(monkeypatch):monkeypatch.setattr(api.V2Config,diff --git a/tests/test_show_pages.py b/tests/test_show_pages.pyindex 085ffbbe1..b5ac6ce5d 100644--- a/tests/test_show_pages.py+++ b/tests/test_show_pages.py@@ -29,7 +29,7 @@ from core.show_pages import (show_public_event_write_token,)from storage.pagination import PageRequest-from vibe import cli+from vibe import api, cli@dataclass(frozen=True)@@ -48,12 +48,12 @@ def _stub_runtime_prepare_dependencies():calls = {"askill": [], "avault": [], "tmux": [], "git": []}- def fake_askill(offline=False):- calls["askill"].append({"offline": offline})+ def fake_askill(offline=False, force=False):+ calls["askill"].append({"offline": offline, "force": force})return askill_result or {"ok": True, "installed": True}- def fake_avault(offline=False):- calls["avault"].append({"offline": offline})+ def fake_avault(offline=False, force=False):+ calls["avault"].append({"offline": offline, "force": force})return avault_result or {"ok": True, "installed": True}def fake_tmux(offline=False, force=False):@@ -292,45 +292,29 @@ def test_runtime_prepare_cli_strict_allows_unsupported_git_platform(monkeypatch,def test_runtime_prepare_cli_skips_avault_offline(monkeypatch, capsys):parser = cli.build_parser()args = parser.parse_args(["runtime", "prepare", "--offline", "--json"])- seen = {"askill": None, "avault": None, "tmux": None, "git": None}class FakeRuntimeManager:def prepare(self, *, force=False, offline=None):assert offline is Truereturn {"ok": True}- def fake_askill(offline=False):- seen["askill"] = offline- return {"ok": True, "skipped": True, "reason": "offline"}-- def fake_avault(offline=False):- seen["avault"] = offline- return {"ok": True, "skipped": True, "reason": "offline"}-- def fake_tmux(offline=False, force=False):- seen["tmux"] = {"offline": offline, "force": force}- return {"ok": True, "skipped": True, "reason": "offline"}-- def fake_git(offline=None, force=False):- seen["git"] = {"offline": offline, "force": force}- return {"ok": True, "installed": True}-monkeypatch.setattr(cli, "_show_runtime_manager_from_args", lambda parsed: FakeRuntimeManager())- monkeypatch.setattr(cli, "_ensure_askill_during_prepare", fake_askill)- monkeypatch.setattr(cli, "_ensure_avault_during_prepare", fake_avault)- monkeypatch.setattr(cli, "_ensure_tmux_during_prepare", fake_tmux)- monkeypatch.setattr(cli, "_ensure_git_during_prepare", fake_git)+ offline_result = {"ok": True, "skipped": True, "reason": "offline"}+ calls = _stub_runtime_prepare_dependencies(+ monkeypatch,+ askill_result=offline_result,+ avault_result=offline_result,+ tmux_result=offline_result,+ )assert cli.cmd_runtime(args) == 0payload = json.loads(capsys.readouterr().out)- assert seen == {- "askill": True,- "avault": True,- "tmux": {"offline": True, "force": False},- "git": {"offline": True, "force": False},- }- assert payload["avault"] == {"ok": True, "skipped": True, "reason": "offline"}- assert payload["tmux"] == {"ok": True, "skipped": True, "reason": "offline"}+ for phase, recorded in calls.items():+ assert recorded, f"{phase} phase did not run"+ assert all(call["offline"] for call in recorded), phase+ assert all(call["force"] is False for call in recorded), phase+ assert payload["avault"] == offline_result+ assert payload["tmux"] == offline_resultassert payload["git"] == {"ok": True, "installed": True}@@ -372,6 +356,115 @@ def test_runtime_prepare_tmux_runs_when_terminal_enabled(monkeypatch):assert calls == [True]+def test_runtime_prepare_downloads_nothing_when_managed_deps_are_current(monkeypatch):+ # Prepare is the chokepoint that keeps managed local deps current, which is+ # not the same as reinstalling them: every install here is a network download+ # (askill ~30s, avault ~20s), so a prepare with nothing to change must reach+ # none of them. Stubbing the installers rather than the decision keeps this+ # honest whichever way the wrappers ask the question.+ monkeypatch.delenv("VIBE_INSTALL_SKIP_ASKILL", raising=False)+ monkeypatch.delenv("VIBE_INSTALL_SKIP_AVAULT", raising=False)+ monkeypatch.setattr(api, "install_askill", lambda: pytest.fail("askill must not reinstall when current"))+ monkeypatch.setattr(api, "install_avault", lambda force=False: pytest.fail("avault must not reinstall when current"))+ monkeypatch.setattr(+ api,+ "askill_status",+ lambda: {"id": "askill", "installed": True, "version": "0.1.14", "status": "ready", "path": "/x/askill"},+ )+ monkeypatch.setattr(api, "_cached_latest_askill", lambda: "0.1.14")+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: "/usr/local/bin/avault")+ monkeypatch.setattr(api, "_probe_avault_version", lambda _path: api.AVAULT_VERSION)++ askill = cli._ensure_askill_during_prepare()+ avault = cli._ensure_avault_during_prepare()++ assert askill == {+ "ok": True,+ "installed": True,+ "changed": False,+ "path": "/x/askill",+ "version": "0.1.14",+ }+ assert avault["ok"] is True+ assert avault["changed"] is False+ assert avault["version"] == api.AVAULT_VERSION++[email protected]("reason", ["latest_unavailable", "a_reason_invented_after_this_test"])+def test_runtime_prepare_installs_when_currency_was_not_established(monkeypatch, reason):+ # "I did not install" and "it is current" are different facts, and prepare+ # may only report ready for the second. `up_to_date` is the one verdict that+ # states it; every other non-install verdict — the upstream probe failing+ # today, whatever is added later — means unknown, so prepare installs rather+ # than printing `askill ready.` off a check that never happened. Keyed on the+ # verdict rather than on a list of reasons, so a reason added later inherits+ # the safe branch instead of a false pass.+ monkeypatch.delenv("VIBE_INSTALL_SKIP_ASKILL", raising=False)+ monkeypatch.setattr(+ api,+ "refresh_askill_if_stale",+ lambda: {"ok": True, "skipped": True, "reason": reason, "status": {"path": "/x/askill", "version": "0.1.14"}},+ )+ forced = []+ monkeypatch.setattr(+ api,+ "ensure_askill_installed",+ lambda force=False: forced.append(force) or {"ok": True, "installed": True, "changed": True},+ )++ out = cli._ensure_askill_during_prepare()++ assert forced == [True], "an unestablished currency must reach the installer"+ assert out["changed"] is True+ assert out["action"] == "refresh_currency_unknown"+++def test_runtime_prepare_force_still_reinstalls_current_managed_deps(monkeypatch):+ # The mirror of the test above, and the boundary of the change: making the+ # ordinary prepare cheap must not take the repair away. A corrupted binary+ # can still report the current version, so `--force` has to reach the+ # installer for exactly the states the currency check skips.+ monkeypatch.delenv("VIBE_INSTALL_SKIP_ASKILL", raising=False)+ monkeypatch.delenv("VIBE_INSTALL_SKIP_AVAULT", raising=False)+ installed = []+ monkeypatch.setattr(api, "refresh_askill_if_stale", lambda: pytest.fail("--force must not settle for a currency check"))+ monkeypatch.setattr(api, "refresh_avault_if_stale", lambda: pytest.fail("--force must not settle for a currency check"))+ monkeypatch.setattr(api, "install_askill", lambda: installed.append("askill") or {"ok": True})+ monkeypatch.setattr(api, "install_avault", lambda force=False: installed.append("avault") or {"ok": True, "changed": True})+ monkeypatch.setattr(api, "_configured_avault_cli_path", lambda: "avault")+ monkeypatch.setattr(api, "resolve_cli_path", lambda _b: "/usr/local/bin/askill")+ monkeypatch.setattr(api, "_probe_avault_version", lambda _path: api.AVAULT_VERSION)++ assert cli._ensure_askill_during_prepare(force=True)["ok"] is True+ assert cli._ensure_avault_during_prepare(force=True)["ok"] is True+ assert installed == ["askill", "avault"]+++def test_runtime_prepare_force_reaches_every_managed_dependency(monkeypatch):+ # `--force` is advertised by the parser as "reinstall even when the cached+ # runtime matches", so it belongs to every dependency phase, not to the ones+ # that happen to accept it. Asserted over whatever phases ran rather than a+ # list of names, so a phase added later fails here instead of silently+ # ignoring the flag.+ parser = cli.build_parser()+ args = parser.parse_args(["runtime", "prepare", "--force"])++ class FakeRuntimeManager:+ def prepare(self, *, force=False, offline=None):+ assert force is True+ return {"ok": True}++ monkeypatch.setattr(cli, "_show_runtime_manager_from_args", lambda parsed: FakeRuntimeManager())+ calls = _stub_runtime_prepare_dependencies(monkeypatch)++ assert cli.cmd_runtime(args) == 0+ assert calls, "prepare recorded no dependency phases"+ for phase, recorded in calls.items():+ assert recorded, f"{phase} phase did not run"+ assert all(call["force"] is True for call in recorded), phase++def _save_config() -> V2Config:config = V2Config(mode="self_host",diff --git a/vibe/api.py b/vibe/api.pyindex e643fdf4a..0f65294ef 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -7469,6 +7469,35 @@ def _probe_avault_version(path: str | None) -> str | None:return None+def refresh_avault_if_stale() -> dict:+ """Bring avault to the managed pin, installing only when that changes it.++ Sibling of ``refresh_askill_if_stale`` for the version-pinned dependency, so+ both managed local deps answer "am I current?" before paying for an install.+ The wanted version is ``AVAULT_VERSION`` rather than an upstream latest, so+ the staleness question is answered locally with no download at all.++ ``force`` on ``ensure_avault_installed`` stays a repair verb — it reinstalls+ an equal or older managed release on purpose — so callers that only want the+ pin satisfied come here instead of charging every call a ~20s reinstall of+ the release that is already on disk.++ Skipping the install may never report a healthier state than forcing it+ would. Being at the pin is not the whole of being current: when the+ readiness floor is raised ahead of the published pin, a binary equal to+ ``AVAULT_VERSION`` is still ``upgrade_required``, and only the forced path+ surfaces that release gap. So the question is asked of the status as a+ whole, not of the version alone.+ """+ status = avault_status()+ current = (+ bool(status.get("installed"))+ and status.get("status") == "ready"+ and _version_at_least(status.get("version"), AVAULT_VERSION)+ )+ return ensure_avault_installed(force=not current)++def avault_status() -> dict:"""Report whether avault is installed and its version (best-effort)."""path = _resolve_avault_cli_path()@@ -8119,23 +8148,33 @@ def askill_update_status(*, include_latest: bool = True) -> dict:"has_update": has_update,"auto_update": not _askill_auto_update_disabled(),}- if current.get("installed") and current_version is None:+ if current.get("installed") and not _is_comparable_version(current_version):+ # Not just a missing version: a version nobody can order (``dev``, a git+ # sha) tells us as little as no version at all, and every consumer —+ # the Dependencies page, prepare — must read the same fact from the same+ # field rather than re-deriving it from the raw string.out["status"] = "unknown"return out-def reconcile_askill_auto_update() -> dict:- """Install or refresh askill as a required managed dependency.+def refresh_askill_if_stale() -> dict:+ """Bring askill to the published version, installing only when that changes it.- This runs from the shared update checker cadence but is intentionally- independent of ``update.auto_update``. Avibe owns askill as a local runtime- dependency for Skills; disabling product self-upgrades must not strand that- dependency on an incompatible CLI contract. Operators can still disable this- reconcile loop with ``VIBE_ASKILL_AUTO_UPDATE=0`` or ``VIBE_INSTALL_SKIP_ASKILL``.- """- if _askill_auto_update_disabled():- return {"ok": True, "skipped": True, "reason": "askill_auto_update_disabled"}+ The single owner of "is the managed askill current, and make it so". Every+ caller that wants currency asks this instead of forcing an install, because+ the askill.sh installer re-downloads the CLI on every run: answering the+ question costs one cached version probe, answering it by reinstalling costs+ ~30s of network even when the local binary is already the published version.+ ``refresh_avault_if_stale`` is the same rule for the version-pinned sibling.++ Callers own their own policy gate; this function only decides staleness. An+ install attempt is reported by ``action``, so its absence means the+ dependency was already current.+ ``up_to_date`` is an affirmative verdict, never a fallthrough: it requires+ two versions that could actually be ordered. Anything else is unknown, and+ unknown is answered by the repair the forced path would have done.+ """status = askill_update_status()if not status.get("installed"):result = ensure_askill_installed(force=False)@@ -8143,17 +8182,31 @@ def reconcile_askill_auto_update() -> dict:return resultlatest = status.get("latest_version")- if latest is None:- return {"ok": True, "skipped": True, "reason": "latest_unavailable", "status": status}-- if status.get("version") is None:+ if status.get("status") == "unknown":+ # A binary whose version cannot be ordered is not current, it is broken —+ # whether it reported nothing or reported ``dev``. The status field owns+ # that judgement (see ``askill_update_status``) so this path and the+ # Dependencies page cannot disagree. Deciding it before the+ # ``latest_unavailable`` exit keeps the repair from being gated on+ # network reachability: callers that used to force this install+ # unconditionally would otherwise be told a broken askill is ready+ # whenever the latest lookup failed too.logger.info("askill local version is unknown; refreshing managed dependency")result = ensure_askill_installed(force=True)result["action"] = "refresh_unknown_version"result["latest_version"] = latestreturn result+ if not _is_comparable_version(latest):+ # No usable upstream version to compare against — missing, or a string+ # that cannot be ordered. Either way staleness is undecided, which is a+ # different fact from being current; each caller owns what to do with it+ # (prepare installs, the update cadence skips).+ return {"ok": True, "skipped": True, "reason": "latest_unavailable", "status": status}+if not status.get("has_update"):+ # Two comparable versions, compared: this is the one state that may claim+ # currency, and it is reached only by having established it.return {"ok": True, "skipped": True, "reason": "up_to_date", "status": status}logger.info("askill update available: %s -> %s", status.get("version"), latest)@@ -8166,6 +8219,20 @@ def reconcile_askill_auto_update() -> dict:return result+def reconcile_askill_auto_update() -> dict:+ """Install or refresh askill as a required managed dependency.++ This runs from the shared update checker cadence but is intentionally+ independent of ``update.auto_update``. Avibe owns askill as a local runtime+ dependency for Skills; disabling product self-upgrades must not strand that+ dependency on an incompatible CLI contract. Operators can still disable this+ reconcile loop with ``VIBE_ASKILL_AUTO_UPDATE=0`` or ``VIBE_INSTALL_SKIP_ASKILL``.+ """+ if _askill_auto_update_disabled():+ return {"ok": True, "skipped": True, "reason": "askill_auto_update_disabled"}+ return refresh_askill_if_stale()++# =============================================================================# Dependencies aggregate + manual install jobs (askill / show runtime)# =============================================================================@@ -8787,15 +8854,48 @@ def _cached_latest(name: str) -> str | None:return latest+def _is_comparable_version(value: str | None) -> bool:+ """Whether *value* can be ordered against another version at all.++ The single owner of "do we actually have a version?", because a nonempty+ string is not the same fact: ``askill --version`` answers ``askill dev`` on a+ development build, and the last token of that is stored as the version. Both+ comparison helpers deliberately return False for anything they cannot parse,+ so every caller that asks a comparison instead of asking this reads "cannot+ tell" as "no update available" — which is how a broken binary comes to look+ current. Ask this first; a False answer means unknown, not healthy.+ """+ if not value:+ return False+ try:+ from packaging.version import InvalidVersion, Version++ try:+ Version(value)+ return True+ except InvalidVersion:+ pass+ except Exception: # pragma: no cover - packaging is a transitive dep+ pass++ core = value.split("+", 1)[0].split("-", 1)[0]+ try:+ tuple(int(part) for part in core.split("."))+ except ValueError:+ return False+ return True++def _compare_versions(current: str | None, latest: str | None) -> bool:"""Return True when *latest* is strictly greater than *current*.Honors PEP 440 / semver pre-release ordering when possible (e.g. ``0.77.1``is greater than ``0.77.1-beta.0``). Falls back to a conservative numerictuple comparison; returns False on any parsing failure so we never nag the- user with a phantom update.+ user with a phantom update. That conservatism is why "no update" is not a+ statement about health: use ``_is_comparable_version`` to tell the two apart."""- if not current or not latest or current == latest:+ if not _is_comparable_version(current) or not _is_comparable_version(latest) or current == latest:return Falsetry:diff --git a/vibe/cli.py b/vibe/cli.pyindex 47563819f..a4fe8a4ab 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -14162,10 +14162,11 @@ def cmd_runtime(args) -> int:if command == "prepare":offline = True if getattr(args, "offline", False) else Nonepayload = manager.prepare(force=getattr(args, "force", False), offline=offline)- askill = _ensure_askill_during_prepare(offline=bool(offline))- tmux = _ensure_tmux_during_prepare(offline=bool(offline), force=getattr(args, "force", False))- git = _ensure_git_during_prepare(offline=offline, force=getattr(args, "force", False))- avault = _ensure_avault_during_prepare(offline=bool(offline))+ force = bool(getattr(args, "force", False))+ askill = _ensure_askill_during_prepare(offline=bool(offline), force=force)+ tmux = _ensure_tmux_during_prepare(offline=bool(offline), force=force)+ git = _ensure_git_during_prepare(offline=offline, force=force)+ avault = _ensure_avault_during_prepare(offline=bool(offline), force=force)payload["askill"] = askillpayload["avault"] = avaultpayload["tmux"] = tmux@@ -14317,25 +14318,67 @@ def _prepare_show_runtime_after_install(vibe_path: str | None) -> None:print(detail)-def _ensure_askill_during_prepare(offline: bool = False) -> dict:+def _ensure_askill_during_prepare(offline: bool = False, force: bool = False) -> dict:"""Ensure askill (a required local dependency) alongside the Show Runtime.Folded into ``vibe runtime prepare`` so askill auto-installs at exactly thesame lifecycle points as the Show Page runtime (post install / upgrade),with a ``VIBE_INSTALL_SKIP_ASKILL`` escape hatch mirroring the Show Runtimeone. Skipped under ``--offline`` (the askill installer needs the network).- Refreshes askill to latest even when a binary already exists — prepare is- the chokepoint that keeps required local deps current on upgrade. An askill- hiccup never fails the prepare; the Dependencies page offers a manual retry.+ Refreshes askill to latest so prepare stays the chokepoint that keeps+ required local deps current on upgrade, but asks whether that refresh would+ change anything before running the installer: askill.sh re-downloads the CLI+ on every run, so an unconditional refresh charged every prepare ~30s to+ install the version already on disk. An askill hiccup never fails the+ prepare; the Dependencies page offers a manual retry.++ ``force`` is prepare's ``--force``, and it means repair, not currency: a+ corrupted binary can still report the current version, so an explicit+ ``vibe runtime prepare --force`` must reinstall rather than ask. Currency is+ the default; repair stays available on request, exactly as it is for the+ Show Runtime, tmux, and git phases.++ Only an explicit ``up_to_date`` verdict may report ready. Any other verdict+ that installed nothing means currency was not established, not that it holds,+ so prepare installs instead of claiming a fact it never checked."""if offline:return {"ok": True, "skipped": True, "reason": "offline"}if os.environ.get("VIBE_INSTALL_SKIP_ASKILL", "").strip().lower() in _TRUTHY_ENV_VALUES:return {"ok": True, "skipped": True, "reason": "VIBE_INSTALL_SKIP_ASKILL"}try:- return api.ensure_askill_installed(force=True)+ if force:+ return api.ensure_askill_installed(force=True)+ result = api.refresh_askill_if_stale()+ if not (result.get("ok") and result.get("action") is None):+ return result+ if result.get("reason") != "up_to_date":+ # The owner skipped without establishing currency — today that is+ # ``latest_unavailable``, when the upstream version probe failed.+ # Prepare is the chokepoint that must *make* the dependency current,+ # so with no evidence either way it does what it did before this fast+ # path existed and installs. The probe and the askill.sh installer+ # are independent paths: a rate-limited or blipped version lookup+ # says nothing about whether the install would succeed, and reporting+ # ready off the back of it would claim currency we never checked.+ # Only ``up_to_date`` may report ready, so a skip reason added later+ # takes this branch rather than inheriting a false pass.+ refreshed = api.ensure_askill_installed(force=True)+ refreshed["action"] = "refresh_currency_unknown"+ return refreshedexcept Exception as exc: # noqa: BLE001return {"ok": False, "message": str(exc)}+ # Already current, and the owner said so: report ready rather than skipped so+ # prepare's dependency lines read the same way as the pinned providers when+ # nothing needed doing.+ status = result.get("status") or {}+ return {+ "ok": True,+ "installed": True,+ "changed": False,+ "path": status.get("path"),+ "version": status.get("version"),+ }def _ensure_tmux_during_prepare(offline: bool = False, force: bool = False) -> dict:@@ -14388,14 +14431,23 @@ def _clean_git_runtime(*, keep_previous: int, dry_run: bool = False) -> dict:return {"ok": False, "removed": [], "message": str(exc)}-def _ensure_avault_during_prepare(offline: bool = False) -> dict:- """Ensure avault (the Vault custody core) alongside other local deps."""+def _ensure_avault_during_prepare(offline: bool = False, force: bool = False) -> dict:+ """Ensure avault (the Vault custody core) alongside other local deps.++ Raises avault to the managed pin on upgrade, but only downloads when the pin+ is not already satisfied: the reinstall it used to force on every prepare+ took ~20s to put back the release that was already installed. ``force`` is+ prepare's ``--force`` repair request and still reinstalls the managed+ release, since a corrupted binary can report the pinned version.+ """if offline:return {"ok": True, "skipped": True, "reason": "offline"}if os.environ.get("VIBE_INSTALL_SKIP_AVAULT", "").strip().lower() in _TRUTHY_ENV_VALUES:return {"ok": True, "skipped": True, "reason": "VIBE_INSTALL_SKIP_AVAULT"}try:- return api.ensure_avault_installed(force=True)+ if force:+ return api.ensure_avault_installed(force=True)+ return api.refresh_avault_if_stale()except Exception as exc: # noqa: BLE001return {"ok": False, "message": str(exc)}