Runtime identity resolved through hermes_cli.__version__ (a static 0.0.0 on source installs, rewritten by release stamping) leaked v0.0.0 into About, /api/health, User-Agents, and plugin compat, and source updates showed "couldn't reach update server" because identity and channel authority disagreed with the checkout. Now: get_version_info() resolves install stamp -> live git -> unknown, never pyproject metadata, never a package constant. Source checkouts derive identity from their reachable release tag; the completion tail of every successful install/update/historical takeover atomically rewrites install-stamp.json with that identity; a stale source stamp whose commit no longer matches HEAD defers to live git. ACP/TUI use derived_version for display and base_version for protocol fields; all ~44 runtime __version__ consumers migrated; hermes_cli.__version__ and generated _version.py are gone; release stamping only touches the native manifests external builders consume (nix/tauri/cargo) and passes release identity straight into write_install_stamp.py; pyproject.toml stays inert 0.0.0. Desktop no longer synthesizes a competing install-stamp.json: the checkout owns its stamp, and desktop-bootstrap classification keys on the bootstrap-complete marker. verify-bootstrap-version-stamp.py now cross-checks the checkout's stamp (baseVersion + commit == HEAD). Validation: 31-file focused suite green (version identity, stamping, adoption, providers, gateway, acp/tui runtime identity, api server via extras env, release graph); desktop tsc + 25 vitest green; real-repo probe: base=unknown derived=git.0635606.dirty source=git on this checkout; clean-env imports resolve entirely from this tree; windows footgun + compat-pointer scans clean.
49 lines
2.3 KiB
Python
49 lines
2.3 KiB
Python
"""Passive checks use the same release selection as explicit source updates."""
|
|
|
|
import json
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
from hermes_cli import banner, source_check
|
|
from hermes_cli.source_releases import SourceTarget
|
|
from hermes_cli.update_channel import install_id
|
|
from hermes_cli.version_info import get_version_info
|
|
|
|
|
|
@pytest.mark.parametrize("channel", ["stable", "canary", "preview-from-r2"])
|
|
def test_release_channel_never_compares_main_or_reuses_main_cache(tmp_path, monkeypatch, channel):
|
|
from hermes_constants import get_hermes_home
|
|
|
|
root = tmp_path / "source"
|
|
root.mkdir()
|
|
(root / ".git").mkdir()
|
|
monkeypatch.setenv("HERMES_INSTALL_ROOT", str(root))
|
|
monkeypatch.delenv("HERMES_REVISION", raising=False)
|
|
monkeypatch.setattr("hermes_cli.config.get_project_root", lambda: root)
|
|
head = "a" * 40
|
|
target = "b" * 40
|
|
monkeypatch.setattr(source_check, "_git_stdout", lambda args, **kw: head if args == ["rev-parse", "HEAD"] else "https://github.com/example/fork.git")
|
|
(get_hermes_home() / "config.yaml").write_text(json.dumps({
|
|
"update": {"installs": {install_id(root): {"path": str(root), "channel": channel}}}
|
|
}))
|
|
(get_hermes_home() / ".update_check").write_text(json.dumps({
|
|
"rev": None, "ver": get_version_info().derived_version,
|
|
"head": head, "behind": 99, "ts": 10**12,
|
|
}))
|
|
resolve = Mock(return_value=SourceTarget(channel, channel, "example/fork", commit=target, version="1.2.3"))
|
|
monkeypatch.setattr(source_check, "resolve_source_target", resolve)
|
|
main = Mock(side_effect=AssertionError("release must not check a branch"))
|
|
monkeypatch.setattr(source_check, "_branch_tip", main)
|
|
status = source_check.check_for_updates(passive=True)
|
|
assert status["behind"] == source_check.UPDATE_AVAILABLE_NO_COUNT
|
|
resolve.assert_called_once_with(channel, ["git"], root, repository="example/fork")
|
|
main.assert_not_called()
|
|
assert status["channel"] == channel
|
|
assert status["targetSha"] == target
|
|
# The selected release may be an ancestor (a requested canary → stable switch).
|
|
# That is still a different release, not "already current" or "behind main".
|
|
label = banner.format_banner_version_label()
|
|
assert channel in label
|
|
assert "upstream" not in label
|