Skip to content

The agent that grows with you

feat(metrics): startup latency and install version-lag/hardware fields

teknium12b3e1c399580
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 47d87b82b51..1abeb8ee371 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -665,6 +665,15 @@ export interface SharedMetricsSlashCommandParams {
export interface SharedMetricsSlashCommandResult {
ok: boolean
}
+/** ``elapsed_ms`` = the client's own launch (TUI process start / Desktop app start) to ready (TUI gateway ready / Desktop backend attached), measured once per launch by the client. The client names its surface because a Desktop may attach to a URL/cloud backend where ``HERMES_DESKTOP`` is unset; without it the backend falls back to its own client detection. */
+export interface SharedMetricsStartupLatencyParams {
+ profile?: string | null
+ elapsed_ms: number
+ surface?: 'desktop_attach' | 'tui' | null
+}
+export interface SharedMetricsStartupLatencyResult {
+ ok: boolean
+}
export interface ModelOptionsParams {
profile?: string | null
session_id?: string | null
@@ -5163,6 +5172,8 @@ export interface RpcMethods {
'shared_metrics.set': { params: SharedMetricsSetParams; result: SharedMetricsConsentResult }
/** Count one user-typed slash command (fire-and-forget; a no-op unless shared metrics are on). */
'shared_metrics.slash_command': { params: SharedMetricsSlashCommandParams; result: SharedMetricsSlashCommandResult }
+ /** Record one client launch-to-ready latency (fire-and-forget; a no-op unless shared metrics are on). */
+ 'shared_metrics.startup_latency': { params: SharedMetricsStartupLatencyParams; result: SharedMetricsStartupLatencyResult }
/** Pure read of the focused profile's shared-metrics opt-ins (collection, upload, answered). */
'shared_metrics.status': { params: ProfileParams; result: SharedMetricsConsentResult }
/** Run a safe (non-dangerous) shell command captured for ``!cmd`` / inline substitution. */
@@ -5449,6 +5460,7 @@ export const RPC_METHODS = [
'setup.status',
'shared_metrics.set',
'shared_metrics.slash_command',
+ 'shared_metrics.startup_latency',
'shared_metrics.status',
'shell.exec',
'skills.manage',
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index cfc5d4c19c9..3185d05a844 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -3624,6 +3624,24 @@
}
}
},
+ {
+ "name": "shared_metrics.startup_latency",
+ "summary": "Record one client launch-to-ready latency (fire-and-forget; a no-op unless shared metrics are on).",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/SharedMetricsStartupLatencyParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/SharedMetricsStartupLatencyResult"
+ }
+ }
+ },
{
"name": "shared_metrics.status",
"summary": "Pure read of the focused profile's shared-metrics opt-ins (collection, upload, answered).",
@@ -32034,6 +32052,63 @@
"title": "SharedMetricsSlashCommandResult",
"type": "object"
},
+ "SharedMetricsStartupLatencyParams": {
+ "additionalProperties": false,
+ "description": "``elapsed_ms`` = the client's own launch (TUI process start / Desktop app start) to ready\n(TUI gateway ready / Desktop backend attached), measured once per launch by the client. The\nclient names its surface because a Desktop may attach to a URL/cloud backend where\n``HERMES_DESKTOP`` is unset; without it the backend falls back to its own client detection.",
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "elapsed_ms": {
+ "title": "Elapsed Ms",
+ "type": "number"
+ },
+ "surface": {
+ "anyOf": [
+ {
+ "enum": [
+ "desktop_attach",
+ "tui"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Surface"
+ }
+ },
+ "required": [
+ "elapsed_ms"
+ ],
+ "title": "SharedMetricsStartupLatencyParams",
+ "type": "object"
+ },
+ "SharedMetricsStartupLatencyResult": {
+ "additionalProperties": false,
+ "properties": {
+ "ok": {
+ "title": "Ok",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "ok"
+ ],
+ "title": "SharedMetricsStartupLatencyResult",
+ "type": "object"
+ },
"ShellExecParams": {
"additionalProperties": false,
"properties": {
diff --git a/cli.py b/cli.py
index 89b865df47e..81327ec70a1 100644
--- a/cli.py
+++ b/cli.py
@@ -1416,6 +1416,8 @@ class HermesCLI(CLIInitMixin, CLITuiRuntimeMixin, CLIProcessNotificationsMixin,
app = self._tui_build_application(layout, kb, style)
_disable_prompt_toolkit_cpr_warning(app)
app.after_render += self._pet_flush_kitty_frame
+ from hermes_cli.observability.shared_metrics_startup import cli_prompt_ready_handler
+ app.after_render += cli_prompt_ready_handler()
self._app = app
# Ghost status-bar lines on resize: pt's renderer scrolls the terminal after each
diff --git a/gateway/run_startup.py b/gateway/run_startup.py
index 8492b2b42ca..b0fd257e300 100644
--- a/gateway/run_startup.py
+++ b/gateway/run_startup.py
@@ -1630,6 +1630,8 @@ class GatewayStartupMixin:
self._update_runtime_status(self._serving_state())
await self._start_finish_wiring(connected_count)
self._start_spawn_background_watchers()
+ from hermes_cli.observability.shared_metrics_startup import record_process_ready
+ record_process_ready("gateway_boot", background=True)
logger.info("Press Ctrl+C to stop")
return True
diff --git a/hermes_cli/cli_single_query.py b/hermes_cli/cli_single_query.py
index bb3ecb86dee..1e4deb01fa2 100644
--- a/hermes_cli/cli_single_query.py
+++ b/hermes_cli/cli_single_query.py
@@ -474,6 +474,8 @@ def _run_single_query_mode(cli, query, image, quiet, oneshot, stream_json: bool
try:
query, single_query_images = _collect_query_images(query, image)
single_query_image_urls = _collect_kanban_task_images(single_query_images)
+ from hermes_cli.observability.shared_metrics_startup import record_cli_one_shot_ready
+ record_cli_one_shot_ready()
if quiet:
# Quiet mode: suppress banner, spinner, tool previews.
cli.tool_progress_mode = "off"
diff --git a/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json b/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json
index 05b782862e9..e8711194a98 100644
--- a/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json
+++ b/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json
@@ -183,6 +183,9 @@
},
{
"$ref": "#/$defs/context_peak_counter"
+ },
+ {
+ "$ref": "#/$defs/startup_latency_counter"
}
]
}
@@ -999,9 +1002,64 @@
"singularity",
"ssh"
]
+ },
+ "behind_bucket": {
+ "enum": [
+ "0",
+ "1",
+ "2",
+ "3_to_5",
+ "6_to_10",
+ "gte_11",
+ "unknown"
+ ]
+ },
+ "gpu_class": {
+ "enum": [
+ "amd",
+ "apple_silicon",
+ "intel",
+ "none",
+ "nvidia",
+ "unknown"
+ ]
+ },
+ "local_model_provider_used": {
+ "enum": [
+ "no",
+ "yes"
+ ]
+ },
+ "ram_bucket": {
+ "enum": [
+ "lt_8g",
+ "8g_to_16g",
+ "16g_to_32g",
+ "32g_to_64g",
+ "64g_to_128g",
+ "gte_128g",
+ "unknown"
+ ]
+ },
+ "release_channel": {
+ "enum": [
+ "dev",
+ "main",
+ "stable",
+ "unknown"
+ ]
+ },
+ "version_age_bucket": {
+ "enum": [
+ "lt_7d",
+ "7d_to_30d",
+ "30d_to_90d",
+ "gte_90d",
+ "unknown"
+ ]
}
},
- "description": "The five decision-data fields are absent on snapshots counted before they existed."
+ "description": "The five decision-data fields are absent on snapshots counted before they existed. The six version-lag/channel/hardware fields are absent on snapshots counted before they existed."
},
"value": {
"const": 1
@@ -2143,6 +2201,57 @@
"minimum": 1
}
}
+ },
+ "startup_latency_counter": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "name",
+ "type",
+ "dimensions",
+ "value"
+ ],
+ "properties": {
+ "name": {
+ "const": "hermes.startup.latency"
+ },
+ "type": {
+ "const": "counter"
+ },
+ "dimensions": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "latency_bucket",
+ "surface"
+ ],
+ "properties": {
+ "latency_bucket": {
+ "enum": [
+ "lt_500ms",
+ "500ms_to_1s",
+ "1s_to_2s",
+ "2s_to_5s",
+ "5s_to_10s",
+ "gte_10s"
+ ]
+ },
+ "surface": {
+ "enum": [
+ "cli",
+ "desktop_attach",
+ "gateway_boot",
+ "serve_boot",
+ "tui"
+ ]
+ }
+ }
+ },
+ "value": {
+ "type": "integer",
+ "minimum": 1
+ }
+ }
}
}
}
diff --git a/hermes_cli/observability/shared_metrics_contract.py b/hermes_cli/observability/shared_metrics_contract.py
index 67deb4a1936..8d535edf84f 100644
--- a/hermes_cli/observability/shared_metrics_contract.py
+++ b/hermes_cli/observability/shared_metrics_contract.py
@@ -34,6 +34,8 @@ MODEL_SWITCH_MARK = "hermes.model_switch"
FALLBACK_MARK = "hermes.fallback"
SLASH_COMMAND_MARK = "hermes.slash_command"
EXTENSION_INSTALL_MARK = "hermes.extension.install"
+# ---- v4 install ----
+STARTUP_LATENCY_MARK = "hermes.startup.latency"
SUBSCRIBER_NAME = "hermes.nemo_relay.shared_metrics"
CLIENT_ACTIVE_METRIC = "hermes.client.active"
LEGACY_MODEL_CALL_METRIC = "hermes.model_call.count"
@@ -73,6 +75,8 @@ MODEL_TOOL_QUALITY_METRIC = "hermes.model_tool_quality.count"
MODEL_FRICTION_METRIC = "hermes.model_friction.count"
CONTEXT_PEAK_METRIC = "hermes.context_peak.count"
# ---- end v4 model ----
+# ---- v4 install ----
+STARTUP_LATENCY_METRIC = "hermes.startup.latency"
MODEL_IDENTIFIER_MAX_LENGTH = 256
PROVIDER_IDENTIFIER_MAX_LENGTH = 64
_METRIC_IDENTIFIER_CHARACTERS = frozenset("abcdefghijklmnopqrstuvwxyz0123456789._:/@+-")
@@ -253,6 +257,24 @@ REPLY_LATENCY_BUCKETS = frozenset({"lt_2s", "2s_to_5s", "5s_to_15s", "15s_to_60s
CRON_RUN_OUTCOMES = frozenset({"success", "failed", "missed", "skipped"})
CRON_DELIVERY_KINDS = frozenset({"local", "platform", "webhook", "none", "other"})
+# ---- v4 install ----
+STARTUP_SURFACES = frozenset({"cli", "desktop_attach", "gateway_boot", "serve_boot", "tui"})
+STARTUP_LATENCY_BUCKETS = frozenset({
+ "lt_500ms", "500ms_to_1s", "1s_to_2s", "2s_to_5s", "5s_to_10s", "gte_10s",
+})
+RELEASE_CHANNELS = frozenset({"dev", "main", "stable", "unknown"})
+VERSION_AGE_BUCKETS = frozenset({"lt_7d", "7d_to_30d", "30d_to_90d", "gte_90d", "unknown"})
+BEHIND_BUCKETS = COUNT_BUCKETS | {"unknown"}
+RAM_BUCKETS = frozenset({
+ "lt_8g", "8g_to_16g", "16g_to_32g", "32g_to_64g", "64g_to_128g", "gte_128g", "unknown",
+})
+GPU_CLASSES = frozenset({"amd", "apple_silicon", "intel", "none", "nvidia", "unknown"})
+YES_NO = frozenset({"no", "yes"})
+_INSTALL_V4_SNAPSHOT_DIMENSIONS = {
+ "behind_bucket": BEHIND_BUCKETS, "gpu_class": GPU_CLASSES, "local_model_provider_used": YES_NO,
+ "ram_bucket": RAM_BUCKETS, "release_channel": RELEASE_CHANNELS, "version_age_bucket": VERSION_AGE_BUCKETS,
+}
+
_ARCHITECTURE_ALIASES = {
"amd64": "x86_64", "x64": "x86_64", "x86_64": "x86_64",
"aarch64": "arm64", "arm64": "arm64",
@@ -372,6 +394,7 @@ _COUNTER_DIMENSION_VALUES: dict[str, dict[str, frozenset[str]]] = {
"memory_provider": MEMORY_PROVIDERS, "messaging_platform_count_bucket": SIZE_BUCKETS,
"plugin_count_bucket": SIZE_BUCKETS, "profile_count_bucket": SIZE_BUCKETS,
"skill_count_bucket": SIZE_BUCKETS, "terminal_backend": TERMINAL_BACKENDS,
+ **_INSTALL_V4_SNAPSHOT_DIMENSIONS,
},
SESSION_METRIC: {
"active_duration_bucket": SESSION_DURATION_BUCKETS, "entrypoint": TASK_ENTRYPOINTS,
@@ -429,6 +452,8 @@ _COUNTER_DIMENSION_VALUES: dict[str, dict[str, frozenset[str]]] = {
"window_bucket": CONTEXT_WINDOW_BUCKETS,
},
# ---- end v4 model ----
+ # ---- v4 install ----
+ STARTUP_LATENCY_METRIC: {"latency_bucket": STARTUP_LATENCY_BUCKETS, "surface": STARTUP_SURFACES},
}
_MODEL_ROUTE_MAX_LENGTHS = {
"model": MODEL_IDENTIFIER_MAX_LENGTH, "provider": PROVIDER_IDENTIFIER_MAX_LENGTH,
@@ -462,8 +487,11 @@ _LEGACY_METRIC_FIELDS: dict[str, tuple[frozenset[str], ...]] = {
SKILL_LOAD_METRIC: (_METRIC_FIELDS[SKILL_LOAD_METRIC] - {"skill_name"},),
INSTALL_SNAPSHOT_METRIC: (_METRIC_FIELDS[INSTALL_SNAPSHOT_METRIC] - {
"display_language", "install_age_bucket", "main_provider", "messaging_platform_count_bucket",
- "terminal_backend",
- },),
+ "terminal_backend", *_INSTALL_V4_SNAPSHOT_DIMENSIONS,
+ },
+ # ---- v4 install ----
+ _METRIC_FIELDS[INSTALL_SNAPSHOT_METRIC] - set(_INSTALL_V4_SNAPSHOT_DIMENSIONS),
+ ),
}
COUNTER_METRICS = frozenset(_METRIC_FIELDS) - {LEGACY_MODEL_CALL_METRIC}
# Counters whose value is a summed quantity rather than an event count.
@@ -488,6 +516,8 @@ _DECISION_MARK_METRICS = {
MODEL_TOOL_QUALITY_MARK: MODEL_TOOL_QUALITY_METRIC, MODEL_FRICTION_MARK: MODEL_FRICTION_METRIC,
CONTEXT_PEAK_MARK: CONTEXT_PEAK_METRIC,
# ---- end v4 model ----
+ # ---- v4 install ----
+ STARTUP_LATENCY_MARK: STARTUP_LATENCY_METRIC,
}
diff --git a/hermes_cli/observability/shared_metrics_install.py b/hermes_cli/observability/shared_metrics_install.py
new file mode 100644
index 00000000000..eb203fb0890
--- /dev/null
+++ b/hermes_cli/observability/shared_metrics_install.py
@@ -0,0 +1,179 @@
+"""Install-snapshot fields for version lag, release channel and coarse hardware.
+
+Everything here is read offline: the installed version's own commit date, the install stamp and
+per-install channel record, the update check's cached result (never a network call), and cached
+``hermes_platform.host`` facts. Only closed enums and buckets leave; the git remote, branch names,
+paths and endpoint URLs stay local.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+import time
+from pathlib import Path
+from typing import Any
+
+from . import shared_metrics_contract as contract
+from .shared_metrics_contract import _bucket, _norm
+
+logger = logging.getLogger(__name__)
+
+_DAY_S = 86_400
+_VERSION_AGE_THRESHOLDS = ((7 * _DAY_S, "lt_7d"), (30 * _DAY_S, "7d_to_30d"), (90 * _DAY_S, "30d_to_90d"))
+_GIB = 1024 ** 3
+# The OS reports installed RAM minus firmware/iGPU reservations (a 16 GB laptop shows ~15.5 GiB),
+# so the total is scaled up before bucketing to land on the nominal size users buy.
+_RAM_NOMINAL_FACTOR = 1.1
+_RAM_THRESHOLDS = (
+ (8, "lt_8g"), (16, "8g_to_16g"), (32, "16g_to_32g"), (64, "32g_to_64g"), (128, "64g_to_128g"),
+)
+# A cached behind count this old no longer says anything about how current the install is.
+_BEHIND_MAX_AGE_S = 7 * _DAY_S
+_CHANNELS = {"stable": "stable", "main": "main", "canary": "main"}
+_MAIN_BRANCHES = frozenset({"main", "master"})
+# Provider ids that always name a server on the user's own machine or network.
+_LOCAL_PROVIDER_ALIASES = frozenset({"ollama", "local", "vllm", "llamacpp", "llama.cpp", "llama-cpp", "lmstudio"})
+_INHERITS_MAIN = frozenset({"", "auto", "main"})
+
+
+def _sub(config: Any, key: str) -> Any:
+ return config.get(key) if isinstance(config, dict) else None
+
+
+def _safe(reader, default: str) -> str:
+ try:
+ return reader()
+ except Exception:
+ logger.debug("Shared-metrics install field %s unavailable", getattr(reader, "__name__", reader), exc_info=True)
+ return default
+
+
+def _version_info():
+ from hermes_cli.version_info import get_version_info
+
+ return get_version_info()
+
+
+def _project_root() -> Path:
+ from hermes_cli.config import get_project_root
+
+ return get_project_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)."""
+ from hermes_cli.update_channel import _package_channel, _read_stamp, resolve_update_channel
+
+ root = _project_root()
+ resolved = resolve_update_channel(config, root)
+ if resolved != "main" or _package_channel(_read_stamp(root)):
+ return _CHANNELS.get(resolved, "unknown")
+ branch = _version_info().branch
+ if not branch:
+ return "unknown"
+ return "main" if branch in _MAIN_BRANCHES else "dev"
+
+
+def version_age_bucket(now: float | None = None) -> str:
+ """Age of the INSTALLED version, from its own commit date (stamp or checkout)."""
+ committed = _version_info().commit_date
+ if not isinstance(committed, int) or committed <= 0:
+ return "unknown"
+ age = max(0.0, (now or time.time()) - committed)
+ return _bucket(age, _VERSION_AGE_THRESHOLDS, "gte_90d")
+
+
+def behind_bucket(home: Path | None = None, now: float | None = None) -> str:
+ """Commits/releases behind, from the update check's cached result for this exact revision."""
+ from hermes_cli.update_channel import install_id
+ from hermes_constants import get_hermes_home
+
+ root = _project_root()
+ cache_file = (home or get_hermes_home()) / "source-checks" / f"{install_id(root)}.json"
+ try:
+ cached = json.loads(cache_file.read_text(encoding="utf-8-sig"))
+ except (OSError, ValueError):
+ return "unknown"
+ if not isinstance(cached, dict):
+ return "unknown"
+ status, identity, ts = cached.get("status"), cached.get("identity"), cached.get("ts")
+ behind = status.get("behind") if isinstance(status, dict) else None
+ head = identity.get("head") if isinstance(identity, dict) else None
+ commit = _version_info().commit
+ if (
+ isinstance(behind, bool) or not isinstance(behind, int) or behind < 0
+ or not isinstance(ts, (int, float)) or not 0 <= (now or time.time()) - ts < _BEHIND_MAX_AGE_S
+ or (head and commit and head != commit)
+ ):
+ return "unknown"
+ return contract.count_bucket(behind)
+
+
+def ram_bucket() -> str:
+ from hermes_platform.host.facts import ram_total_bytes
+
+ total = ram_total_bytes()
+ if not total:
+ return "unknown"
+ return _bucket(total * _RAM_NOMINAL_FACTOR / _GIB, _RAM_THRESHOLDS, "gte_128g")
+
+
+def gpu_class() -> str:
+ from hermes_platform.host.facts import gpu_class as host_gpu_class
+
+ value = host_gpu_class()
+ return value if value in contract.GPU_CLASSES else "unknown"
+
+
+def _is_local_endpoint(base_url: Any) -> bool:
+ if not isinstance(base_url, str) or not base_url.strip():
+ return False
+ from agent.model_metadata import is_local_endpoint
+
+ return is_local_endpoint(base_url)
+
+
+def _custom_base_url(provider: str) -> Any:
+ from hermes_cli.runtime_provider_custom import _get_named_custom_provider
+
+ entry = _get_named_custom_provider(provider)
+ return entry.get("base_url") if isinstance(entry, dict) else None
+
+
+def _slot_is_local(slot: Any) -> bool:
+ provider = _norm(_sub(slot, "provider"))
+ if provider in _LOCAL_PROVIDER_ALIASES:
+ return True
+ if _is_local_endpoint(_sub(slot, "base_url")):
+ return True
+ from .shared_metrics_catalog import CUSTOM, _safe as catalog_safe, user_named_model_providers
+
+ if provider in catalog_safe(user_named_model_providers) - {CUSTOM}:
+ return True
+ return provider.startswith(f"{CUSTOM}:") and _is_local_endpoint(_custom_base_url(provider))
+
+
+def local_model_provider_used(config: dict[str, Any]) -> str:
+ """``yes`` when the main model or any auxiliary task runs on a local/self-hosted server."""
+ model = _sub(config, "model")
+ auxiliary = _sub(config, "auxiliary")
+ slots = [model] if isinstance(model, dict) else []
+ if isinstance(auxiliary, dict):
+ slots += [s for s in auxiliary.values() if isinstance(s, dict) and _norm(s.get("provider")) not in _INHERITS_MAIN]
+ return "yes" if any(_slot_is_local(slot) for slot in slots) else "no"
+
+
+def install_v4_snapshot_fields(config: dict[str, Any]) -> dict[str, str]:
+ """The version-lag, channel and hardware dimensions of the daily snapshot."""
+ fields = {
+ "behind_bucket": _safe(behind_bucket, "unknown"),
+ "gpu_class": _safe(gpu_class, "unknown"),
+ "local_model_provider_used": _safe(lambda: local_model_provider_used(config), "no"),
+ "ram_bucket": _safe(ram_bucket, "unknown"),
+ "release_channel": _safe(lambda: release_channel(config), "unknown"),
+ "version_age_bucket": _safe(version_age_bucket, "unknown"),
+ }
+ allowed = contract._INSTALL_V4_SNAPSHOT_DIMENSIONS
+ return {k: v if v in allowed[k] else ("no" if k == "local_model_provider_used" else "unknown") for k, v in fields.items()}
diff --git a/hermes_cli/observability/shared_metrics_snapshot.py b/hermes_cli/observability/shared_metrics_snapshot.py
index 48b61b46e86..f15dd831cbf 100644
--- a/hermes_cli/observability/shared_metrics_snapshot.py
+++ b/hermes_cli/observability/shared_metrics_snapshot.py
@@ -126,7 +126,9 @@ def collect_install_snapshot(config: dict[str, Any]) -> dict[str, str]:
language = "other"
with contextlib.suppress(Exception):
language = _display_language()
- return contract.install_snapshot_fields(
+ from .shared_metrics_install import install_v4_snapshot_fields
+
+ return {**contract.install_snapshot_fields(
memory_provider=_sub(_sub(config, "memory"), "provider"),
mcp_servers=_mcp_server_count(config),
plugins=_plugin_count(config),
@@ -138,4 +140,4 @@ def collect_install_snapshot(config: dict[str, Any]) -> dict[str, str]:
main_provider=_sub(model, "provider") if isinstance(model, dict) else None,
terminal_backend=_sub(_sub(config, "terminal"), "backend"),
display_language=language,
- )
+ ), **install_v4_snapshot_fields(config)}
diff --git a/hermes_cli/observability/shared_metrics_startup.py b/hermes_cli/observability/shared_metrics_startup.py
new file mode 100644
index 00000000000..07efe7373dd
--- /dev/null
+++ b/hermes_cli/observability/shared_metrics_startup.py
@@ -0,0 +1,121 @@
+"""Startup / attach latency: one bucketed row per process start and surface.
+
+In-process surfaces (classic CLI, messaging gateway, ``hermes serve``) measure from the OS process
+creation time, the earliest timestamp available (it includes interpreter start and imports), to the
+moment they are ready. The Ink TUI and the Desktop app measure on their own side and report through
+the ``shared_metrics.startup_latency`` RPC. Recording goes through the shared ``_emit`` gate, so a
+profile without shared metrics enabled records nothing.
+"""
+
+from __future__ import annotations
+
+import contextvars
+import logging
+import os
+import threading
+import time
+from typing import Any
+
+from . import shared_metrics_contract as contract
+from .shared_metrics_contract import _bucket, _non_negative_number
+
+logger = logging.getLogger(__name__)
+
+_THRESHOLDS_MS = (
+ (500, "lt_500ms"), (1_000, "500ms_to_1s"), (2_000, "1s_to_2s"), (5_000, "2s_to_5s"), (10_000, "5s_to_10s"),
+)
+# (pid, surface): a forked child re-arms, a surface in this process counts once.
+_recorded: set[tuple[int, str]] = set()
+_lock = threading.Lock()
+
+
+def latency_bucket(elapsed_ms: Any) -> str | None:
+ value = _non_negative_number(elapsed_ms)
+ return None if value is None else _bucket(value, _THRESHOLDS_MS, "gte_10s")
+
+
+def startup_latency_fields(*, surface: Any, elapsed_ms: Any) -> dict[str, str] | None:
+ bucket = latency_bucket(elapsed_ms)
+ if surface not in contract.STARTUP_SURFACES or bucket is None:
+ return None
+ return {"latency_bucket": bucket, "surface": surface}
+
+
+def record_startup_latency(*, surface: str, elapsed_ms: Any) -> None:
+ """Record one measured startup (no-op unless shared metrics are on; never raises)."""
+ from .shared_metrics_events import _emit
+
+ _emit(contract.STARTUP_LATENCY_MARK, startup_latency_fields, surface=surface, elapsed_ms=elapsed_ms)
+
+
+def process_started_at() -> float | None:
+ """Epoch seconds at which the OS created this process, or ``None`` when unreadable."""
+ try:
+ import psutil
+
+ return float(psutil.Process(os.getpid()).create_time())
+ except Exception:
+ return None
+
+
+def _claim(surface: str) -> bool:
+ key = (os.getpid(), surface)
+ with _lock:
+ if key in _recorded:
+ return False
+ _recorded.add(key)
+ return True
+
+
+def _record_since_process_start(surface: str, ready_at: float) -> None:
+ started = process_started_at()
+ if started is not None:
+ record_startup_latency(surface=surface, elapsed_ms=max(0.0, ready_at - started) * 1000)
+
+
+def record_process_ready(surface: str, *, background: bool = False) -> None:
+ """``surface`` became ready now: record process-start -> now once per process.
+
+ ``background`` hands the (possibly cold, ~seconds) metrics runtime start to a daemon thread
+ under the caller's contextvars (profile binding), so an event loop never waits on it; the
+ ready time is taken before the hand-off.
+ """
+ ready_at = time.time()
+ try:
+ if not _claim(surface):
+ return
+ if not background:
+ _record_since_process_start(surface, ready_at)
+ return
+ context = contextvars.copy_context()
+ threading.Thread(
+ target=context.run, args=(_record_since_process_start, surface, ready_at),
+ name="hermes-startup-latency", daemon=True,
+ ).start()
+ except Exception:
+ logger.debug("Startup latency for %s not recorded", surface, exc_info=True)
+
+
+def cli_prompt_ready_handler():
+ """A prompt_toolkit ``after_render`` handler that records the first rendered prompt once."""
+
+ def _on_render(_app: Any) -> None:
+ record_process_ready("cli", background=True)
+
+ return _on_render
+
+
+def record_cli_one_shot_ready() -> None:
+ """A ``-q`` run is ready to dispatch its query. Kanban workers are dispatched processes, not a
+ user waiting on a prompt, so they stay out of the CLI startup distribution."""
+ if not os.environ.get("HERMES_KANBAN_TASK"):
+ record_process_ready("cli")
+
+
+def record_rpc_startup_latency(*, client_surface: Any, elapsed_ms: Any) -> None:
+ """The TUI / Desktop client's own launch -> ready measurement, reported once per launch by the
+ client. ``client_surface`` is the client's declared surface or the backend's detection
+ (``desktop``/``tui``); anything else records nothing."""
+ surface = {"desktop": "desktop_attach", "desktop_attach": "desktop_attach", "tui": "tui"}.get(client_surface)
+ if surface is not None:
+ record_startup_latency(surface=surface, elapsed_ms=elapsed_ms)
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py
index e96e20c5d5c..a8320d45cb9 100644
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@ -1600,6 +1600,9 @@ def start_server(
initial_profile=initial_profile,
start_mcp_discovery_after_bind=start_mcp_discovery_after_bind,
)
+ if headless:
+ from hermes_cli.observability.shared_metrics_startup import record_process_ready
+ record_process_ready("serve_boot", background=True)
await server.main_loop()
if server.started:
diff --git a/tests/hermes_cli/test_relay_shared_metrics_runtime.py b/tests/hermes_cli/test_relay_shared_metrics_runtime.py
index a41c407ace3..c83e5b45df1 100644
--- a/tests/hermes_cli/test_relay_shared_metrics_runtime.py
+++ b/tests/hermes_cli/test_relay_shared_metrics_runtime.py
@@ -2760,7 +2760,8 @@ def test_install_snapshot_is_daily_and_carries_only_bucketed_counts(
"main_provider": "none", "mcp_server_count_bucket": "1", "memory_provider": "plugin",
"messaging_platform_count_bucket": "0", "plugin_count_bucket": "3_to_5",
"profile_count_bucket": snapshot["profile_count_bucket"], "skill_count_bucket": "0",
- "terminal_backend": "local",
+ "terminal_backend": "local", "local_model_provider_used": "no",
+ **{k: snapshot[k] for k in ("behind_bucket", "gpu_class", "ram_bucket", "release_channel", "version_age_bucket")},
}
diff --git a/tests/hermes_cli/test_shared_metrics_install_v4.py b/tests/hermes_cli/test_shared_metrics_install_v4.py
new file mode 100644
index 00000000000..90a72fe3721
--- /dev/null
+++ b/tests/hermes_cli/test_shared_metrics_install_v4.py
@@ -0,0 +1,294 @@
+"""Startup latency and the install snapshot's version-lag, channel and hardware fields."""
+
+from __future__ import annotations
+
+import json
+import os
+import time
+from types import SimpleNamespace
+
+import pytest
+
+import hermes_cli.observability.relay_shared_metrics as relay
+import hermes_cli.observability.shared_metrics_install as install
+import hermes_cli.observability.shared_metrics_startup as startup
+import tui_gateway.server as server
+from hermes_cli.observability import shared_metrics_contract as contract
+from hermes_platform.host import facts
+
+
+def marks(monkeypatch):
+ recorded: list[tuple[str, dict]] = []
+ monkeypatch.setattr(relay, "enabled", lambda: True)
+ monkeypatch.setattr(relay, "record_process_mark", lambda mark, data: recorded.append((mark, data)))
+ monkeypatch.setattr(startup, "_recorded", set())
+ return recorded
+
+
[email protected](("elapsed_ms", "bucket"), [
+ (0, "lt_500ms"), (499.9, "lt_500ms"), (500, "500ms_to_1s"), (1_999, "1s_to_2s"),
+ (2_000, "2s_to_5s"), (9_999, "5s_to_10s"), (10_000, "gte_10s"), (3_600_000, "gte_10s"),
+])
+def test_startup_latency_buckets_are_valid_counter_dimensions(elapsed_ms, bucket):
+ fields = startup.startup_latency_fields(surface="gateway_boot", elapsed_ms=elapsed_ms)
+
+ assert fields == {"latency_bucket": bucket, "surface": "gateway_boot"}
+ assert contract.counter_dimensions_are_valid(contract.STARTUP_LATENCY_METRIC, fields)
+
+
[email protected]("raw", [{"surface": "web", "elapsed_ms": 10}, {"surface": "cli", "elapsed_ms": -1},
+ {"surface": "cli", "elapsed_ms": "fast"}, {"surface": "cli", "elapsed_ms": True}])
+def test_startup_latency_rejects_unknown_surfaces_and_bad_durations(raw):
+ assert startup.startup_latency_fields(**raw) is None
+
+
+def test_process_ready_records_process_start_to_now_once_per_surface(marks, monkeypatch):
+ monkeypatch.setattr(startup, "process_started_at", lambda: time.time() - 1.5)
+
+ startup.record_process_ready("cli")
+ startup.record_process_ready("cli")
+ startup.record_process_ready("gateway_boot")
+
+ assert marks == [
+ (contract.STARTUP_LATENCY_MARK, {"latency_bucket": "1s_to_2s", "surface": "cli"}),
+ (contract.STARTUP_LATENCY_MARK, {"latency_bucket": "1s_to_2s", "surface": "gateway_boot"}),
+ ]
+
+
+def test_process_ready_records_nothing_when_shared_metrics_are_off(marks, monkeypatch):
+ monkeypatch.setattr(relay, "enabled", lambda: False)
+
+ startup.record_process_ready("serve_boot")
+
+ assert marks == []
+
+
+def test_background_ready_record_does_not_block_and_still_lands(marks, monkeypatch):
+ monkeypatch.setattr(startup, "process_started_at", lambda: time.time() - 0.1)
+
+ startup.record_process_ready("serve_boot", background=True)
+ for _ in range(200):
+ if marks:
+ break
+ time.sleep(0.01)
+
+ assert marks == [(contract.STARTUP_LATENCY_MARK, {"latency_bucket": "lt_500ms", "surface": "serve_boot"})]
+
+
+def test_kanban_worker_one_shot_is_not_a_cli_startup(marks, monkeypatch):
+ monkeypatch.setattr(startup, "process_started_at", lambda: time.time())
+ monkeypatch.setenv("HERMES_KANBAN_TASK", "t_1")
+
+ startup.record_cli_one_shot_ready()
+
+ assert marks == []
+
+
+def _rpc(params: dict) -> dict:
+ return server.handle_request(
+ {"jsonrpc": "2.0", "id": "r1", "method": "shared_metrics.startup_latency", "params": params})
+
+
+def test_rpc_takes_the_declared_surface_else_env_detection(marks, monkeypatch):
+ monkeypatch.delenv("HERMES_DESKTOP", raising=False)
+ monkeypatch.delenv("HERMES_DESKTOP_TERMINAL", raising=False)
+
+ # A Desktop attached to a URL/cloud backend: no HERMES_DESKTOP here, the client says who it is.
+ assert _rpc({"elapsed_ms": 2500, "surface": "desktop_attach"})["result"] == {"ok": True}
+ assert _rpc({"elapsed_ms": 700})["result"] == {"ok": True}
+ monkeypatch.setenv("HERMES_DESKTOP", "1")
+ assert _rpc({"elapsed_ms": 12_000})["result"] == {"ok": True}
+ assert _rpc({"elapsed_ms": -5, "surface": "tui"})["result"] == {"ok": True}
+
+ assert [data for _, data in marks] == [
+ {"latency_bucket": "2s_to_5s", "surface": "desktop_attach"},
+ {"latency_bucket": "500ms_to_1s", "surface": "tui"},
+ {"latency_bucket": "gte_10s", "surface": "desktop_attach"},
+ ]
+
+
+def test_cli_first_rendered_prompt_records_once(marks, monkeypatch):
+ monkeypatch.setattr(startup, "process_started_at", lambda: time.time() - 0.2)
+ on_render = startup.cli_prompt_ready_handler()
+
+ for _ in range(3):
+ on_render(object())
+ for _ in range(200):
+ if marks:
+ break
+ time.sleep(0.01)
+ time.sleep(0.05)
+
+ assert marks == [(contract.STARTUP_LATENCY_MARK, {"latency_bucket": "lt_500ms", "surface": "cli"})]
+
+
+# ---- install snapshot ----
+
+_FULL_V4 = {
+ "behind_bucket": "unknown", "gpu_class": "nvidia", "local_model_provider_used": "yes",
+ "ram_bucket": "16g_to_32g", "release_channel": "stable", "version_age_bucket": "lt_7d",
+}
+
+
+def test_install_snapshot_accepts_v4_fields_and_rows_counted_before_them():
+ legacy = {
+ "cron_job_count_bucket": "0", "display_language": "en", "install_age_bucket": "lt_1h",
+ "main_provider": "openrouter", "mcp_server_count_bucket": "0", "memory_provider": "builtin",
+ "messaging_platform_count_bucket": "0", "plugin_count_bucket": "0", "profile_count_bucket": "1",
+ "skill_count_bucket": "0", "terminal_backend": "local",
+ }
+
+ assert contract.counter_dimensions_are_valid(contract.INSTALL_SNAPSHOT_METRIC, legacy)
+ assert contract.counter_dimensions_are_valid(contract.INSTALL_SNAPSHOT_METRIC, {**legacy, **_FULL_V4})
+ assert not contract.counter_dimensions_are_valid(
+ contract.INSTALL_SNAPSHOT_METRIC, {**legacy, **_FULL_V4, "gpu_class": "rtx-4090"})
+ partial = {**legacy, "ram_bucket": "lt_8g"}
+ assert not contract.counter_dimensions_are_valid(contract.INSTALL_SNAPSHOT_METRIC, partial)
+
+
[email protected](("gib", "bucket"), [
+ (3.8, "lt_8g"), (7.6, "8g_to_16g"), (15.5, "16g_to_32g"), (31.2, "32g_to_64g"),
+ (62.6, "64g_to_128g"), (125.7, "gte_128g"), (512, "gte_128g"),
+])
+def test_ram_buckets_land_on_the_nominal_size(monkeypatch, gib, bucket):
+ monkeypatch.setattr(facts, "ram_total_bytes", lambda: int(gib * 1024 ** 3))
+
+ assert install.ram_bucket() == bucket
+
+
+def test_ram_unknown_when_the_os_does_not_say(monkeypatch):
+ monkeypatch.setattr(facts, "ram_total_bytes", lambda: None)
+
+ assert install.ram_bucket() == "unknown"
+
+
+def test_meminfo_total_is_parsed_in_bytes():
+ assert facts.parse_meminfo_total("MemFree: 12 kB\nMemTotal: 65681892 kB\n") == 65681892 * 1024
+ assert facts.parse_meminfo_total("garbage") is None
+
+
[email protected](("vendors", "gpu"), [
+ (["0x8086", "0x10de"], "nvidia"), (["0x8086", "0x1002"], "amd"), (["0x8086"], "intel"),
+ (["0x1af4"], "none"), ([], "none"), (["10DE"], "nvidia"),
+])
+def test_gpu_vendor_priority_prefers_the_discrete_card(vendors, gpu):
+ assert facts.classify_gpu_vendors(vendors) == gpu
+
+
+def _version(**kw):
+ base = {"commit": "a" * 40, "commit_date": None, "branch": None}
+ return SimpleNamespace(**{**base, **kw})
+
+
[email protected](("days", "bucket"), [(0.5, "lt_7d"), (8, "7d_to_30d"), (45, "30d_to_90d"), (400, "gte_90d")])
+def test_version_age_is_the_installed_commit_age(monkeypatch, days, bucket):
+ now = 1_800_000_000
+ monkeypatch.setattr(install, "_version_info", lambda: _version(commit_date=int(now - days * 86_400)))
+
+ assert install.version_age_bucket(now=now) == bucket
+
+
+def test_version_age_unknown_without_a_commit_date(monkeypatch):
+ monkeypatch.setattr(install, "_version_info", lambda: _version(commit_date=None))
+
+ assert install.version_age_bucket() == "unknown"
+
+
+def _write_update_cache(home, root, *, behind, head, ts):
+ from hermes_cli.update_channel import install_id
+
+ path = home / "source-checks" / f"{install_id(root)}.json"
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(json.dumps({"ts": ts, "identity": {"head": head}, "status": {"behind": behind}}))
+
+
+def test_behind_comes_only_from_a_fresh_cached_check_of_this_revision(tmp_path, monkeypatch):
+ root = tmp_path / "checkout"
+ root.mkdir()
+ monkeypatch.setattr(install, "_project_root", lambda: root)
+ monkeypatch.setattr(install, "_version_info", lambda: _version())
+ home = tmp_path / "home"
+ now = time.time()
+
+ assert install.behind_bucket(home=home, now=now) == "unknown"
+ _write_update_cache(home, root, behind=4, head="a" * 40, ts=now - 3600)
+ assert install.behind_bucket(home=home, now=now) == "3_to_5"
+ _write_update_cache(home, root, behind=0, head="a" * 40, ts=now - 60)
+ assert install.behind_bucket(home=home, now=now) == "0"
+ # Checked before the install moved to another revision: that count is about a different commit.
+ _write_update_cache(home, root, behind=4, head="b" * 40, ts=now - 60)
+ assert install.behind_bucket(home=home, now=now) == "unknown"
+ _write_update_cache(home, root, behind=4, head="a" * 40, ts=now - 8 * 86_400)
+ assert install.behind_bucket(home=home, now=now) == "unknown"
+
+
+def test_behind_never_touches_the_network(tmp_path, monkeypatch):
+ import socket
+
+ def _no_network(*_a, **_k):
+ raise AssertionError("snapshot must not open a socket")
+
+ monkeypatch.setattr(socket, "create_connection", _no_network)
+ monkeypatch.setattr(socket.socket, "connect", _no_network)
+ monkeypatch.setattr(install, "_project_root", lambda: tmp_path)
+
+ assert install.behind_bucket(home=tmp_path) == "unknown"
+
+
[email protected](("branch", "channel"), [("main", "main"), ("master", "main"), ("feat/x", "dev"), (None, "unknown")])
+def test_source_checkout_channel_follows_its_branch_never_its_remote(tmp_path, monkeypatch, branch, channel):
+ monkeypatch.setattr(install, "_project_root", lambda: tmp_path)
+ monkeypatch.setattr(install, "_version_info", lambda: _version(branch=branch))
+
+ assert install.release_channel({}) == channel
+
+
[email protected](("tag", "channel"), [("v0.13.0", "stable"), ("v0.13.0+canary.20260927T120000Z", "main")])
+def test_packaged_build_channel_is_its_baked_channel_not_its_branch(tmp_path, monkeypatch, tag, channel):
+ from hermes_cli.update_channel import is_canary_tag
+
+ if channel == "main":
+ assert is_canary_tag(tag)
+ (tmp_path / "install-stamp.json").write_text(json.dumps({"updateMechanism": "electron-updater", "tag": tag}))
+ monkeypatch.setattr(install, "_project_root", lambda: tmp_path)
+ monkeypatch.setattr(install, "_version_info", lambda: _version(branch="feat/x"))
+
+ assert install.release_channel({}) == channel
+
+
[email protected](("config", "used"), [
+ ({"model": {"provider": "openrouter", "default": "x"}}, "no"),
+ ({"model": {"provider": "ollama"}}, "yes"),
+ ({"model": {"provider": "custom", "base_url": "http://127.0.0.1:8080/v1"}}, "yes"),
+ ({"model": {"provider": "custom", "base_url": "https://api.example.com/v1"}}, "no"),
+ ({"model": {"provider": "openrouter"}, "auxiliary": {"vision": {"provider": "lmstudio"}}}, "yes"),
+ ({"model": {"provider": "openrouter"}, "auxiliary": {"compression": {"provider": "auto", "base_url": "http://localhost:1"}}}, "no"),
+ ({}, "no"),
+])
+def test_local_model_use_covers_main_and_auxiliary_slots(config, used):
+ assert install.local_model_provider_used(config) == used
+
+
+def test_snapshot_fields_degrade_to_unknown_when_a_reader_breaks(monkeypatch):
+ def _boom(*_a, **_k):
+ raise OSError("unreadable")
+
+ for name in ("behind_bucket", "gpu_class", "ram_bucket", "release_channel", "version_age_bucket",
+ "local_model_provider_used"):
+ monkeypatch.setattr(install, name, _boom)
+
+ assert install.install_v4_snapshot_fields({}) == {
+ "behind_bucket": "unknown", "gpu_class": "unknown", "local_model_provider_used": "no",
+ "ram_bucket": "unknown", "release_channel": "unknown", "version_age_bucket": "unknown",
+ }
+
+
[email protected](not os.path.isdir("/sys/class/drm") and not os.path.exists("/proc/meminfo"),
+ reason="needs a Linux host")
+def test_host_facts_are_cached_and_in_vocabulary():
+ facts.clear_caches()
+
+ assert facts.gpu_class() in contract.GPU_CLASSES
+ assert facts.gpu_class.cache_info().currsize == 1
+ assert (facts.ram_total_bytes() or 0) >= 0
diff --git a/tui_gateway/contracts/config_free_tier_control.py b/tui_gateway/contracts/config_free_tier_control.py
index 7a702a817fe..a08c30bcc57 100644
--- a/tui_gateway/contracts/config_free_tier_control.py
+++ b/tui_gateway/contracts/config_free_tier_control.py
@@ -257,6 +257,25 @@ method("shared_metrics.slash_command", params=SharedMetricsSlashCommandParams,
doc="Count one user-typed slash command (fire-and-forget; a no-op unless shared metrics are on).")
+class SharedMetricsStartupLatencyParams(ProfileParams):
+ """``elapsed_ms`` = the client's own launch (TUI process start / Desktop app start) to ready
+ (TUI gateway ready / Desktop backend attached), measured once per launch by the client. The
+ client names its surface because a Desktop may attach to a URL/cloud backend where
+ ``HERMES_DESKTOP`` is unset; without it the backend falls back to its own client detection."""
+
+ elapsed_ms: float
+ surface: Literal["desktop_attach", "tui"] | None = None
+
+
+class SharedMetricsStartupLatencyResult(Result):
+ ok: bool
+
+
+method("shared_metrics.startup_latency", params=SharedMetricsStartupLatencyParams,
+ result=SharedMetricsStartupLatencyResult,
+ doc="Record one client launch-to-ready latency (fire-and-forget; a no-op unless shared metrics are on).")
+
+
# ── model.options ─────────────────────────────────────────────────────────────────────────────
diff --git a/tui_gateway/methods_shared_metrics.py b/tui_gateway/methods_shared_metrics.py
index 270417c7440..fc61bb79cf4 100644
--- a/tui_gateway/methods_shared_metrics.py
+++ b/tui_gateway/methods_shared_metrics.py
@@ -97,5 +97,19 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"ok": True})
+@method("shared_metrics.startup_latency")
+@_profile_scoped
+def _(rid, params: dict) -> dict:
+ """The Ink TUI (gateway ready) and Desktop (backend attached) each report their own launch ->
+ ready time once per launch. A Desktop on a URL/cloud backend has no ``HERMES_DESKTOP`` here, so
+ the client's declared surface wins over env detection. Always ``{ok: true}``."""
+ from hermes_cli.observability.shared_metrics_startup import record_rpc_startup_latency
+
+ record_rpc_startup_latency(
+ client_surface=params.get("surface") or _resolve_session_platform(), elapsed_ms=params.get("elapsed_ms"),
+ )
+ return _ok(rid, {"ok": True})
+
+
def register(server) -> None:
bind_module(globals(), server, skip=("_",))
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index a2780037724..9806cf947f4 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -260,6 +260,30 @@ names are never read into the event. The same compare-and-set latch as `hermes.c
row per install per day, and the producer checks the latch before walking the
skills tree.
+<!-- ---- v4 install ---- -->
+The snapshot also carries six version-lag, channel and hardware fields, all read
+offline (no network call, no subprocess):
+
+- `release_channel` (`stable`, `main`, `dev`, `unknown`): a packaged build's baked
+ channel (canary builds of main read `main`), a source install's channel record,
+ else the checkout's branch (`main` for main/master, `dev` for any other branch).
+ The git remote URL and branch names are never read into the event.
+- `version_age_bucket` (`lt_7d` … `gte_90d`, `unknown`): age of the *installed*
+ version, from its own commit date in the install stamp or checkout.
+- `behind_bucket` (`0`, `1`, `2`, `3_to_5`, `6_to_10`, `gte_11`, `unknown`): commits
+ or releases behind, only from the update check's cached result for this exact
+ revision and under 7 days old; otherwise `unknown`.
+- `ram_bucket` (`lt_8g` … `gte_128g`, `unknown`): installed memory rounded to its
+ nominal size (the OS total scaled by 1.1 for firmware reservations).
+- `gpu_class` (`nvidia`, `amd`, `intel`, `apple_silicon`, `none`, `unknown`): the
+ highest-priority GPU vendor from `/proc/driver/nvidia` or DRM PCI vendor ids on
+ Linux, the display-adapter registry class on Windows, native arm64 on macOS.
+ Never a model name, driver version or VRAM size.
+- `local_model_provider_used` (`yes`/`no`): whether the main model or any
+ auxiliary task runs on a local or self-hosted server (a local provider id such
+ as Ollama/LM Studio/llama.cpp, or a loopback/private-network base URL). The
+ URL itself stays local.
+
### Decision-data metrics
These answer product questions the activity counters cannot: what makes people
@@ -288,6 +312,7 @@ itself ships.
| `hermes.platform.delivery` | platform, outcome (`sent`/`failed`), failure class (`rate_limited`/`too_long`/`auth`/`network`/`forbidden`/`other`) | How often replies fail to reach the user per platform (one count per logical reply, retries included). |
| `hermes.gateway.reply_latency` | platform, first-response bucket (`lt_2s` … `gte_60s`) | Time from an accepted inbound message to the first visible reply text (stream first chunk or final message). |
| `hermes.cron.run` | outcome (`success`/`failed`/`missed`/`skipped`), delivery kind (`local`/`platform`/`webhook`/`none`/`other`), duration bucket | Do scheduled jobs run, fail, get skipped by a gate or overlap, or get missed while Hermes was down. Job names, prompts, schedules and targets are never included. |
+| `hermes.startup.latency` | surface (`cli`, `tui`, `desktop_attach`, `gateway_boot`, `serve_boot`), latency bucket (`lt_500ms` … `gte_10s`) | How long each surface takes from launch to usable, so startup regressions show per surface and release. One row per process start: CLI = process start to first rendered prompt (or a `-q` query dispatched; Kanban workers excluded), TUI = Ink process start to gateway ready, Desktop = app start to backend attached, gateway = process start to adapters connected, `hermes serve` = process start to listening. |
Sessions are summarized when they close (finalize, reset or process exit);
delegated child sessions are not counted separately. Milestones latch in the