Skip to content

The agent that grows with you

feat(shared-metrics): Microsoft Store installs report their own install_method

ethernet0c864cebfb0f
diff --git a/hermes_cli/observability/schemas/hermes.shared_metrics.v4.schema.json b/hermes_cli/observability/schemas/hermes.shared_metrics.v4.schema.json
index 36e771a9b49..612abaca109 100644
--- a/hermes_cli/observability/schemas/hermes.shared_metrics.v4.schema.json
+++ b/hermes_cli/observability/schemas/hermes.shared_metrics.v4.schema.json
@@ -70,6 +70,7 @@
"git",
"home-manager",
"homebrew",
+ "microsoft-store",
"nixos",
"pip",
"unknown"
diff --git a/hermes_cli/observability/shared_metrics_contract.py b/hermes_cli/observability/shared_metrics_contract.py
index 83e593a81c0..aff5e6f634f 100644
--- a/hermes_cli/observability/shared_metrics_contract.py
+++ b/hermes_cli/observability/shared_metrics_contract.py
@@ -138,7 +138,7 @@ SKILL_POST_PATCH_STATES = frozenset({"no_new_patch", "not_applicable", "reused_a
CLIENT_OS_FAMILIES = frozenset({"linux", "macos", "unknown", "windows"})
CLIENT_ARCHITECTURES = frozenset({"arm", "arm64", "unknown", "x86", "x86_64"})
CLIENT_INSTALL_METHODS = frozenset({
- "apt", "docker", "git", "home-manager", "homebrew", "nixos", "pip", "unknown",
+ "apt", "docker", "git", "home-manager", "homebrew", "microsoft-store", "nixos", "pip", "unknown",
})
CLIENT_RESOURCE_KEYS = frozenset({"architecture", "hermes_version", "install_method", "os_family"})
diff --git a/hermes_cli/observability/shared_metrics_desktop.py b/hermes_cli/observability/shared_metrics_desktop.py
index c20852d2955..340f7f6379a 100644
--- a/hermes_cli/observability/shared_metrics_desktop.py
+++ b/hermes_cli/observability/shared_metrics_desktop.py
@@ -90,14 +90,14 @@ def friction_pair(kind: Any, detail: Any) -> tuple[str, str] | None:
def _store_and_resource() -> tuple[Any, dict[str, str]]:
"""The active profile's store and client resource (the subscriber's), for rows that latch
durably or belong to a past period and so cannot ride the relay's current-day marks."""
- from hermes_cli.config import detect_install_method
from hermes_cli.version_info import get_version_info
from .shared_metrics import SharedMetricsStore
+ from .shared_metrics_install import detect_client_install_method
return SharedMetricsStore(), contract.client_resource(
get_version_info().base_version, os_name=platform.system(), architecture=platform.machine(),
- install_method=detect_install_method(),
+ install_method=detect_client_install_method(),
)
diff --git a/hermes_cli/observability/shared_metrics_install.py b/hermes_cli/observability/shared_metrics_install.py
index 81e7d6a8033..a9145d3c78b 100644
--- a/hermes_cli/observability/shared_metrics_install.py
+++ b/hermes_cli/observability/shared_metrics_install.py
@@ -61,6 +61,19 @@ def _project_root() -> Path:
return get_project_root()
+def detect_client_install_method() -> str:
+ """``detect_install_method()``, except the Microsoft Store build, which the stamp names and
+ that function's update-gating vocabulary has no word for (it would read ``unknown``).
+ Kept out of ``detect_install_method`` on purpose: update and uninstall branch on its result."""
+ from hermes_cli.config import detect_install_method
+ from hermes_cli.steward import read_install_stamp
+
+ root = _project_root()
+ if read_install_stamp(root).get("updateMechanism") == "microsoft-store":
+ return "microsoft-store"
+ return detect_install_method(root)
+
+
def release_channel(config: dict[str, Any]) -> str:
"""The channel this install follows: a package's baked channel, a source install's channel
record, else the checkout's branch (``main`` for main/master, ``dev`` for any other)."""
diff --git a/hermes_cli/observability/shared_metrics_subscriber.py b/hermes_cli/observability/shared_metrics_subscriber.py
index 5c6a9e83762..078c371aab6 100644
--- a/hermes_cli/observability/shared_metrics_subscriber.py
+++ b/hermes_cli/observability/shared_metrics_subscriber.py
@@ -8,13 +8,13 @@ import threading
from typing import Any
from agent.relay_runtime import RUNTIME_INSTANCE_KEY
-from hermes_cli.config import detect_install_method
from hermes_constants import get_hermes_home
from . import shared_metrics_engagement as engagement
from . import shared_metrics_signals as signals
from .shared_metrics import SharedMetricsStore
from .shared_metrics_fields import milestones_for
+from .shared_metrics_install import detect_client_install_method
from .shared_metrics_contract import (
CLIENT_ACTIVE_METRIC,
COMMIT_TICKET_KEY,
@@ -80,7 +80,7 @@ class SharedMetricsSubscriber:
hermes_version,
os_name=platform.system(),
architecture=platform.machine(),
- install_method=detect_install_method(),
+ install_method=detect_client_install_method(),
)
self._runtime_id = runtime_id
self._active = True
diff --git a/tests/hermes_cli/test_relay_shared_metrics.py b/tests/hermes_cli/test_relay_shared_metrics.py
index a4eaa4852c1..38ff899d2d0 100644
--- a/tests/hermes_cli/test_relay_shared_metrics.py
+++ b/tests/hermes_cli/test_relay_shared_metrics.py
@@ -521,6 +521,7 @@ def test_client_resource_classification_is_bounded():
assert client_install_method("Homebrew") == "homebrew"
assert client_install_method("nix") == "nixos"
assert client_install_method("apt") == "apt"
+ assert client_install_method("microsoft-store") == "microsoft-store"
assert client_resource(
"",
@@ -534,6 +535,19 @@ def test_client_resource_classification_is_bounded():
install_method="unknown",
)
+def test_microsoft_store_stamp_reports_its_own_install_method(tmp_path, monkeypatch):
+ """The Store build's stamp is the only place it is named; ``detect_install_method`` has no word for it."""
+ from hermes_cli.observability.shared_metrics_install import detect_client_install_method
+
+ monkeypatch.setattr("hermes_cli.config.get_project_root", lambda: tmp_path)
+ stamp = tmp_path / "install-stamp.json"
+ stamp.write_text(json.dumps({"updateMechanism": "microsoft-store"}), encoding="utf-8")
+ assert detect_client_install_method() == "microsoft-store"
+
+ stamp.write_text(json.dumps({"updateMechanism": "app-installer"}), encoding="utf-8")
+ assert detect_client_install_method() == "unknown"
+
+
def test_package_schema_matches_the_client_resource_contract():
schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
resource = schema["properties"]["resource"]