Skip to content

The agent that grows with you

fix(telemetry): pre-receipt exits keep their initiator; index.lock permission errors; bare-interpreter updates park

Teknium476e0f1138d1
diff --git a/hermes_cli/observability/shared_metrics_contract.py b/hermes_cli/observability/shared_metrics_contract.py
index 8d4e6f79a7b..5af5d2a6ec7 100644
--- a/hermes_cli/observability/shared_metrics_contract.py
+++ b/hermes_cli/observability/shared_metrics_contract.py
@@ -508,6 +508,7 @@ UPDATE_STOP_CLASSES = frozenset({
"not_git_checkout", # the install is not a git checkout (non-Windows)
"old_version_handoff", # an older updater's hand-off to this version could not finish
"parked_branch_blocked", # the checkout is parked on another branch that is unsafe to switch
+ "permission_denied", # (see above): git could not write a file it needs (e.g. index.lock's directory)
"stash_restore_rejected", # re-applied local changes broke Hermes; the update stopped
"syntax_rollback", # the pulled code failed the syntax check and was rolled back
"target_syntax_error", # the target failed the syntax check before anything moved
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index e3b5a333377..c616049f751 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -1082,7 +1082,10 @@ def _move_checkout_to(git_cmd, branch, merge_ref, target_sha, pre_pull_sha) -> N
if ancestry_detail:
print(f" {ancestry_detail}")
print(" Resolve the Git error and re-run `hermes update`; no reset was attempted.")
- _record_stop("git_index_locked" if "index.lock" in detail else "checkout_move_failed")
+ from hermes_cli.update_receipt import git_output_stop_class
+
+ # The shared classifier: an index.lock that EXISTS is another git's; "Permission denied" on it is not.
+ _record_stop(git_output_stop_class(detail, ["merge"], merge_result.returncode) or "checkout_move_failed")
sys.exit(1)
diff --git a/hermes_cli/update_receipt.py b/hermes_cli/update_receipt.py
index d09e1e81f21..1e12b560b2b 100644
--- a/hermes_cli/update_receipt.py
+++ b/hermes_cli/update_receipt.py
@@ -528,6 +528,11 @@ def record_stop_reason(reason: str) -> None:
_record("fact", f"update stop {reason}", "stop_class", reason)
+#: git could not write a file it needs (``index.lock``'s directory, a tracked file): an OS permission
+#: error, not a lock another git holds. SSH's ``Permission denied (publickey)`` is an auth failure.
+_GIT_FILE_PERMISSION = re.compile(r"Permission denied(?! *\()|\bEACCES\b")
+
+
def git_error_stop_class(exc: BaseException) -> Optional[str]:
"""The closed stop token for a git ``CalledProcessError`` that is about to end the run, or None.
@@ -538,9 +543,16 @@ def git_error_stop_class(exc: BaseException) -> Optional[str]:
output = exc.stderr or exc.output or ""
output = output.decode("utf-8", "replace") if isinstance(output, bytes) else str(output)
argv = [str(part) for part in exc.cmd] if isinstance(exc.cmd, (list, tuple)) else str(exc.cmd or "").split()
+ return git_output_stop_class(output, argv, exc.returncode)
+
+
+def git_output_stop_class(output: str, argv: list[str], returncode: Optional[int] = None) -> Optional[str]:
+ """:func:`git_error_stop_class` for a git call that returned instead of raising (``_git_run``)."""
if "index.lock" in output and "File exists" in output:
return "git_index_locked" # another git (or a killed one, #132089) holds the index lock
- if exc.returncode == 124 and "timed out after" in output:
+ if _GIT_FILE_PERMISSION.search(output):
+ return "permission_denied" # git may not write a file it needs (index.lock's dir, a tracked file)
+ if returncode == 124 and "timed out after" in output:
return "git_timeout" # update_cmd._git_run's own timeout text
if "No space left on device" in output:
return "disk_full"
@@ -551,6 +563,30 @@ def git_error_stop_class(exc: BaseException) -> Optional[str]:
return None
+def _started_by_handoff_partner() -> bool:
+ """True when the update marker names the Desktop hand-off this process runs under.
+
+ For an exit before the receipt opens, where this process may NOT hold the lock: at the
+ update-lock refusal the marker belongs to whichever update holds it, so "a pid other than
+ ours" (update_cmd._record_update_initiator, which runs under the lock) would call every
+ refusal Desktop-started. The claim is ours only when it names us as its delegate (the posix and
+ Windows hand-offs write that line before the update runs) or names our hand-off partner on
+ line 1 or the delegate line (``HERMES_UPDATE_HANDOFF_PID``, the Tauri updater; our parent, a
+ launcher between the hand-off and us). The marker is read raw: no liveness probe and no
+ cleanup (those are lock policy, not a metrics side effect).
+ """
+ from hermes_cli.update_lock import _handoff_pid, _parse_marker, update_marker_path
+
+ marker = _parse_marker(update_marker_path().read_bytes())
+ if marker.started_at is None:
+ return False
+ pid = os.getpid()
+ if marker.delegate_pid == pid:
+ return True
+ partners = {_handoff_pid(), os.getppid()} - {None, 0, 1, pid}
+ return bool(partners & {marker.pid, marker.delegate_pid})
+
+
def record_stop_without_receipt(reason: str, outcome: str) -> None:
"""Count an exit that fires before this run's receipt opens, in shared metrics only.
@@ -558,7 +594,8 @@ def record_stop_without_receipt(reason: str, outcome: str) -> None:
``latest.json`` and the running record belong to the update holding the lock (opening one
would replace its pointer and reconcile its archive), and the Git-operation refusal runs before
the receipt, plan and snapshot by design. The row is derived from the same fields a final
- receipt carries (``outcome`` is ``refused`` or ``failed``). Never raises.
+ receipt carries (``outcome`` is ``refused`` or ``failed``), including the initiator, so a
+ Desktop-started refusal reads ``kind=desktop`` like the same run's receipt would. Never raises.
"""
with suppress(Exception):
now = _utc_now_iso()
@@ -567,6 +604,9 @@ def record_stop_without_receipt(reason: str, outcome: str) -> None:
"outcome": "refused" if outcome == "refused" else "failed",
"stop_class": reason, "pre_update": {}, "stages": [], "steps": [], "fleet": [],
}
+ with suppress(Exception): # no marker, or an unreadable one: the CLI default
+ if _started_by_handoff_partner():
+ data["initiator"] = "desktop"
from hermes_cli.observability.shared_metrics_update import record_update_receipt
record_update_receipt(data)
@@ -733,26 +773,73 @@ def _metric_receipt(data: dict[str, Any]) -> dict[str, Any]:
}
+def _consent_reader_importable() -> bool:
+ """Whether this interpreter can load the config reader the recorder's consent gate uses.
+
+ False in the bare ``-I -S`` bootstrap interpreter that finalizes an update whose dependency
+ preparation failed (update_completion._settle_after_commit): it has the new tree but no
+ third-party packages, so ``hermes_cli.config`` dies on ``ruamel``. Only asked of an interpreter
+ that runs the new tree (never the pre-pull one, which must import nothing); the recorder's
+ pre-gate imports the same module next, so a working interpreter loads nothing extra."""
+ try:
+ import hermes_cli.config # noqa: F401
+ except ImportError: # ruamel and every other third-party package are missing here
+ return False
+ return True
+
+
+def _bare_collection_enabled() -> Optional[bool]:
+ """Consent as far as an interpreter without the config reader can tell: the loaded module's
+ answer if one is loaded, False when the profile has no config.yaml (the shipped default is off),
+ else None (unknowable here; the next normal start decides)."""
+ enabled = _collection_enabled_now()
+ if enabled is not None:
+ return enabled
+ from hermes_constants import get_hermes_home
+
+ try:
+ (get_hermes_home() / "config.yaml").stat()
+ except FileNotFoundError:
+ return False
+ except OSError:
+ return None
+ return None
+
+
+def _park_metric_receipt(data: dict[str, Any], enabled: Optional[bool]) -> None:
+ """Keep the bounded fields for the next Hermes start (stdlib only): ``report_pending_updates``
+ records them when collection is on, ``begin_process`` purges them when it is off. Collection
+ known off: park nothing and purge what an earlier run parked."""
+ from hermes_constants import get_hermes_home
+ from hermes_cli.runtime_state import _atomic_bytes
+
+ pending = get_hermes_home() / "telemetry" / "shared_metrics" / "pending_updates" # = PENDING_DIRNAME
+ if enabled is False:
+ import shutil
+
+ shutil.rmtree(pending, ignore_errors=True) # opted out: nothing parked may be counted later
+ return
+ pending.mkdir(parents=True, exist_ok=True)
+ _atomic_bytes(pending / f"{data.get('update_id')}.json", json.dumps(_metric_receipt(data), default=str).encode())
+
+
def _publish_shared_metrics(data: dict[str, Any]) -> None:
- """hermes.update.run/stage from this FINAL receipt; must never fail or slow the update."""
+ """hermes.update.run/stage from this FINAL receipt; must never fail or slow the update.
+
+ Rows are emitted only by an interpreter that can read consent with the real config reader.
+ Any other interpreter parks the bounded fields instead, and the next normal start applies the
+ collection gate (records them, or purges them when collection is off)."""
with suppress(Exception):
pre, post = data.get("pre_update") or {}, data.get("post_update") or {}
if data.get("pid") == os.getpid() and not (pre.get("sha") and pre.get("sha") == post.get("sha")):
# This interpreter began the run before the checkout swap: importing now would load
- # pulled code into it. Park the bounded fields (stdlib + loaded modules only); the next
- # Hermes start records them.
- from hermes_constants import get_hermes_home
- from hermes_cli.runtime_state import _atomic_bytes
-
- pending = get_hermes_home() / "telemetry" / "shared_metrics" / "pending_updates" # = PENDING_DIRNAME
- enabled = _collection_enabled_now()
- if enabled is False:
- import shutil
-
- shutil.rmtree(pending, ignore_errors=True) # opted out: nothing parked may be counted later
- elif enabled:
- pending.mkdir(parents=True, exist_ok=True)
- _atomic_bytes(pending / f"{data.get('update_id')}.json", json.dumps(_metric_receipt(data), default=str).encode())
+ # pulled code into it. Consent comes from the config module it already has loaded.
+ _park_metric_receipt(data, _collection_enabled_now())
+ return
+ if not _consent_reader_importable():
+ # The bare bootstrap interpreter (dependency preparation failed): no config reader, so
+ # it can neither read consent nor emit. Park, unless consent is knowably off.
+ _park_metric_receipt(data, _bare_collection_enabled())
return
from hermes_cli.observability.shared_metrics_update import record_update_receipt
diff --git a/tests/hermes_cli/test_shared_metrics_update_stop_reasons.py b/tests/hermes_cli/test_shared_metrics_update_stop_reasons.py
index 3690f51e103..f53e1bb453d 100644
--- a/tests/hermes_cli/test_shared_metrics_update_stop_reasons.py
+++ b/tests/hermes_cli/test_shared_metrics_update_stop_reasons.py
@@ -5,6 +5,8 @@ receipt opens still count once; a run that committed and owes work never reads `
from __future__ import annotations
import json
+import os
+import sys
from types import SimpleNamespace
import pytest
@@ -119,3 +121,134 @@ def test_exits_before_the_receipt_opens_count_once_and_leave_the_holders_receipt
("lock_held", "refused", "none"), ("git_in_progress", "failed", "other")]
assert all(contract.counter_dimensions_are_valid(contract.UPDATE_RUN_METRIC, r) for r in rows.runs())
assert (rows.home / "logs/update_receipts/latest.json").read_bytes() == holders
+
+
+def _marker(home, *lines: str) -> None:
+ (home / ".hermes-update-in-progress").parent.mkdir(parents=True, exist_ok=True)
+ (home / ".hermes-update-in-progress").write_text("".join(f"{line}\n" for line in lines))
+
+
+def test_an_exit_before_the_receipt_reads_desktop_only_under_its_own_hand_off(rows, monkeypatch):
+ """Invariant: a pre-receipt exit carries the initiator its receipt would: ``desktop`` when the
+ marker names this process as the hand-off's delegate or names its hand-off partner, ``cli`` when
+ the marker belongs to some other update (a terminal `hermes update` refused by a Desktop run)."""
+ import os
+
+ from hermes_cli.update_cmd_common import _record_stop
+
+ monkeypatch.delenv("HERMES_UPDATE_HANDOFF_PID", raising=False)
+ pid, other = os.getpid(), 999_999
+ _marker(rows.home, other, 1, "ct:1.000", f"delegate:{pid} ct:2.000") # the posix/Windows hand-off
+ _record_stop("lock_held", without_receipt="refused")
+ monkeypatch.setenv("HERMES_UPDATE_HANDOFF_PID", str(other)) # the Tauri updater's claim
+ _marker(rows.home, other, 1, "ct:1.000")
+ _record_stop("git_in_progress", without_receipt="failed")
+ monkeypatch.delenv("HERMES_UPDATE_HANDOFF_PID") # a CLI run refused by someone else's update
+ _record_stop("lock_held", without_receipt="refused")
+ (rows.home / ".hermes-update-in-progress").unlink()
+ _record_stop("managed_install", without_receipt="refused")
+
+ assert [(r["failure_class"], r["kind"]) for r in rows.runs()] == [
+ ("lock_held", "desktop"), ("git_in_progress", "desktop"), ("lock_held", "cli"), ("managed_install", "cli")]
+
+
[email protected](sys.platform == "win32" or os.geteuid() == 0, reason="POSIX permissions; root ignores them")
+def test_a_checkout_move_names_a_held_index_lock_apart_from_a_permission_error(rows, tmp_path, monkeypatch):
+ """Invariant: the fast-forward's git error goes through the shared classifier: an index.lock that
+ exists is ``git_index_locked``; git refused permission to create one is ``permission_denied``."""
+ import subprocess
+
+ from hermes_cli import update_cmd, update_cmd_git
+
+ monkeypatch.setattr(update_cmd, "_git_run", update_cmd_git._git_run) # the real git runner, no main import
+ repo = tmp_path / "repo"
+ monkeypatch.setenv("GIT_CONFIG_GLOBAL", os.devnull)
+ monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
+ cmd = ["git", "-C", str(repo), "-c", "user.name=t", "-c", "[email protected]"]
+ git = lambda *a: subprocess.run([*cmd, *a], check=True, capture_output=True, text=True).stdout.strip() # noqa: E731
+ repo.mkdir()
+ git("init", "-q")
+ (repo / "a").write_text("a")
+ git("add", "a")
+ git("commit", "-qm", "one")
+ old = git("rev-parse", "HEAD")
+ (repo / "a").write_text("b")
+ git("commit", "-qam", "two")
+ new = git("rev-parse", "HEAD")
+ git("reset", "-q", "--hard", old)
+
+ def move() -> str:
+ update_receipt.begin_update_receipt()
+ with pytest.raises(SystemExit):
+ update_cmd._move_checkout_to(cmd, "main", "origin/main", new, old)
+ path = update_receipt.finalize_pending_update_receipt(1, "sys.exit(1)")
+ return json.loads(path.read_text(encoding="utf-8"))["stop_class"]
+
+ (repo / ".git/index.lock").write_text("")
+ held = move()
+ (repo / ".git/index.lock").unlink()
+ index_dir = tmp_path / "readonly-index"
+ index_dir.mkdir()
+ (index_dir / "index").write_bytes((repo / ".git/index").read_bytes())
+ monkeypatch.setenv("GIT_INDEX_FILE", str(index_dir / "index"))
+ index_dir.chmod(0o555)
+ try:
+ denied = move()
+ finally:
+ index_dir.chmod(0o755)
+ assert (held, denied) == ("git_index_locked", "permission_denied")
+ assert git("rev-parse", "HEAD") == old
+
+
[email protected]("consent", ["on", "off"])
+def test_the_bare_bootstrap_interpreter_parks_and_the_next_start_applies_the_gate(rows, consent, monkeypatch):
+ """Invariant: a run finalized by the ``-I -S`` bootstrap interpreter (dependency preparation
+ failed; no ruamel, so it cannot read consent) never emits and never drops the run: it parks only
+ the bounded fields, and the next normal start applies the collection gate: counted once while
+ collection is on, purged unrecorded while it is off."""
+ import subprocess
+ from pathlib import Path
+
+ from hermes_cli.observability import shared_metrics_process as process_metrics
+
+ saved: list[tuple[str, dict]] = []
+ monkeypatch.setattr(relay_shared_metrics, "record_process_marks_saved",
+ lambda marks: saved.extend(marks) or len(marks), raising=False)
+ monkeypatch.setattr("hermes_cli.config.read_raw_config_readonly",
+ lambda: {"telemetry": {"shared_metrics": {"enabled": consent == "on"}}})
+ monkeypatch.setattr(process_metrics, "_STATE", {})
+ monkeypatch.setattr(process_metrics, "_report_dead_markers", lambda home, own: update_metrics.report_pending_updates())
+
+ home = rows.home
+ home.mkdir(parents=True, exist_ok=True)
+ (home / "config.yaml").write_text(f"telemetry:\n shared_metrics:\n enabled: {str(consent == 'on').lower()}\n")
+ pending = update_metrics.pending_updates_dir(home)
+ pending.mkdir(parents=True)
+ (pending / "earlier.json").write_text("{}")
+ receipt = {
+ "schema": 1, "pid": 0, "update_id": "0123456789abcdef0123456789abcdef", "outcome": "success",
+ "started_at": "2026-10-07T10:00:00+00:00", "finished_at": "2026-10-07T10:01:00+00:00", "exit_code": 0,
+ "argv": ["hermes", "update", "/home/alice/private"], "pre_update": {"sha": "a" * 40},
+ "stages": [{"name": "apply", "outcome": "success", "mode": "git"}, {"name": "deps", "outcome": "failed"}],
+ }
+ tree = Path(update_receipt.__file__).resolve().parents[1]
+ script = ("import json, sys; sys.path.insert(0, sys.argv[1]); from hermes_cli import update_receipt as r; "
+ "assert 'ruamel' not in sys.modules; r._publish_shared_metrics(json.loads(sys.argv[2]))")
+ subprocess.run([sys.executable, "-I", "-S", "-c", script, str(tree), json.dumps(receipt)], check=True,
+ env={"HERMES_HOME": str(home), "HOME": str(home.parent), "PATH": os.environ.get("PATH", "")})
+ parked = sorted(path.name for path in pending.glob("*.json"))
+ assert parked == ["0123456789abcdef0123456789abcdef.json", "earlier.json"] # nothing emitted, nothing lost
+ assert "alice" not in (pending / parked[0]).read_text()
+ assert rows.runs() == [] and not list(home.rglob("metrics.sqlite3"))
+
+ monkeypatch.setattr(process_metrics.threading, "Thread", lambda target, args, **kw: SimpleNamespace(
+ start=lambda: target(*args)))
+ monkeypatch.setattr(process_metrics.atexit, "register", lambda *a: None)
+ monkeypatch.setattr(process_metrics.sys, "excepthook", process_metrics.sys.excepthook)
+ process_metrics.begin_process("cli") # the next normal start
+ runs = [d for m, d in saved if m == contract.UPDATE_RUN_MARK]
+ if consent == "off":
+ assert runs == [] and not pending.exists()
+ else:
+ assert [(r["outcome"], r["failed_stage"], r["apply_mode"]) for r in runs] == [("success", "none", "git")]
+ assert list(pending.glob("*.json")) == []
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index b963d6c5a7e..09942823e34 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -353,7 +353,7 @@ itself ships.
| `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. Not counted: a process re-exec'd in place (e.g. `hermes sessions browse` resuming a session) and each dashboard Chat-tab terminal; a TUI/Desktop reconnect to the same backend never re-counts. |
-| `hermes.update.run` | kind, outcome, failed_stage, duration_bucket, from_version_age_bucket, apply_mode | Whether updates succeed, how long they take, where they fail, and how stale the version being updated from was. `outcome` is `success`, `noop`, `failed`, `refused`, or `partial` (committed, then interrupted or left the user's stashed changes parked; `hermes update` rows only). `hermes update` rows are derived from the final update receipt, once per run (`kind` is `desktop` when Desktop's source-checkout hand-off ran it); a run the pre-update interpreter finishes is parked locally with only the bounded fields the row needs, only while collection is on, and counted by the next start; Desktop packaged self-updates (`apply_mode=package`) are reported once by the app, after the restart that applies them. |
+| `hermes.update.run` | kind, outcome, failed_stage, duration_bucket, from_version_age_bucket, apply_mode | Whether updates succeed, how long they take, where they fail, and how stale the version being updated from was. `outcome` is `success`, `noop`, `failed`, `refused`, or `partial` (committed, then interrupted or left the user's stashed changes parked; `hermes update` rows only). `hermes update` rows are derived from the final update receipt, once per run (`kind` is `desktop` when Desktop's source-checkout hand-off ran it); a run the pre-update interpreter finishes, or the bare bootstrap interpreter finishes after dependency preparation failed (it cannot load the config reader), is parked locally with only the bounded fields the row needs and counted by the next start, which purges it unrecorded when collection is off (nothing is parked when that interpreter can already tell collection is off); Desktop packaged self-updates (`apply_mode=package`) are reported once by the app, after the restart that applies them. |
| `hermes.update.stage` | stage, outcome, duration_bucket | Per-stage result and wall time of `hermes update` (plan, snapshot, apply, deps, build, restart, verify), from the receipt's stage timestamps. |
| `hermes.process.exit` | process_kind, exit_kind, crash_class | How CLI / TUI / gateway / serve / cron-tick processes end (`clean`, `crash` with an exception family only, `killed`, `watchdog`), reported by the next start in the same profile from a local marker (a start with collection off deletes these markers, and pending `provider_setup` ones, unreported). Turns aborted by a turn watchdog also count as `exit_kind=watchdog`. |
@@ -506,7 +506,7 @@ they failed. Rows recorded before the change keep their old field set and still
| Metric | Dimensions added | Question it answers |
|---|---|---|
| `hermes.extension.install.count` | failure class, registry | Why skill, plugin and MCP installs fail, and which skills-hub source fails. `failure_class` is `none` on success, else a closed name for the failure exit that stopped the install. Skills: `ambiguous`, `auth_rejected`, `fetch_failed`, `invalid_bundle`, `invalid_name`, `not_found`, `rate_limited`, `scan_blocked`, `stale_index`. Plugins: `already_installed`, `clone_failed`, `deps_declined`, `deps_failed`, `git_missing`, `incompatible`, `invalid_source`, `manifest_invalid`, `non_interactive`, `removed_from_catalog`, `scan_blocked`. MCP servers: `auth_required`, `bootstrap_failed`, `clone_failed`, `config_invalid`, `config_rejected`, `connect_failed`, `git_missing`, `missing_credentials`, `server_start_failed`. Every kind may also read `exception`, `filesystem_error`, `network`, `other`, `permission`. A raised error without a named class is classified by its Python type only (`PermissionError` reads `permission`, connection and timeout errors `network`, other `OSError`s `filesystem_error`, anything else `exception`, its type name dropped). `registry` is set on skill rows only: the skills-hub adapter that resolved or served the skill, one of `browse-sh`, `clawhub`, `github`, `hermes-index`, `lobehub`, `official`, `skills-sh`, `url`, `well-known` (the adapter ids `tools/skills_hub_search.py::create_source_router` builds), `unresolved` when no adapter answered, `none` for built-in restores and every plugin/MCP row, `other` otherwise. A row whose `failure_class` is outside its kind's set, is `none` on a failure or set on a success, or that names a registry on a plugin/MCP row is invalid. Never the identifier, URL, error text or path; `name` keeps its existing catalog-or-`custom` rule. |
-| `hermes.update.run` | failure class | Why `hermes update` fails, next to where (`failed_stage`). `none` unless the outcome is `failed`, `refused` or `partial`. Derived from the final update receipt only: `build_failed`, `deps_failed`, `exception`, `fleet_stale`, `fleet_unverified`, `git_failed`, `interrupted`, `lock_held`, `managed_install`, `os_error`, `disk_full`, `permission_denied`, `restart_failed`, `subprocess_failed`, else `other`; Desktop packaged self-updates report `unknown` (their RPC carries a stage, never a reason). An exception that ended the run is read by its type name alone, never its message (a `PermissionError` reads `permission_denied`, an `OSError` whose errno is ENOSPC reads `disk_full`); a failed Windows gateway resume after the update reads `restart_failed`. Every exit that stops a run before its apply stage mark records one closed token at the exit itself, and the run reads it (a few of these, `syntax_rollback`, `stash_restore_rejected`, `unexpected_branch`, `head_moved`, fire after git moved the tree and put it back or left it for the next launch to restore): `fetch_failed`, `git_timeout` (a network git call hit the updater's time limit), `channel_unresolved`, `git_in_progress` (a merge/rebase/... was already running), `git_index_locked`, `merge_conflict` (local commits on a custom branch), `checkout_move_failed`, `branch_missing`, `parked_branch_blocked`, `detached_head`, `unexpected_branch`, `head_moved` (a ref moved mid-update), `target_unresolved`, `target_syntax_error` (refused before the move), `syntax_rollback` (moved, failed the syntax check, rolled back), `commit_point_refused` (the commit point could not be armed; nothing moved), `venv_foreign_owner`, `local_changes_blocked` (local changes git could not stash, or a dirty tree the ZIP fallback will not overwrite), `stash_restore_rejected`, `not_git_checkout`, `old_version_handoff` (an older updater's hand-off could not finish), `branch_unsupported`, `download_failed`, `zip_failed`, `disk_full`, `lock_held`, `managed_install`. `aborted_before_apply` is now only the fallback for such an exit with no recorded token. The update-lock refusal, the Git-operation refusal and the managed-install refusal fire before the run's receipt opens; they still write no receipt (the receipt store belongs to the update holding the lock) and record one row with that token. A token is read only while the run has no apply mark, so a reason can never outlive the exit that recorded it. A run that committed and then was interrupted, or whose stashed local changes could not be re-applied, reads outcome `partial` (`interrupted` / `local_changes_parked`, `failed_stage` `apply` for the latter), never `failed`; owed follow-ups alone keep the run a `success` (contract C3). A run the pre-update interpreter finishes is parked with the token, the exit code, the stop reason's leading exception type (or one of Hermes' two fixed phrases) and the restart/user-action flags (never argv, paths or messages), so it classifies exactly as the same run finished in-process. A failed run whose every stage mark passed now reads `failed_stage` `verify` (the post-restart verification wrote `partial`) or `restart` (a skipped restart left the fleet owing one) instead of `other`; a `partial` run with a failed build or restart mark keeps that stage, and its verify stage row is failed only when the fleet has a stale or down row. |
+| `hermes.update.run` | failure class | Why `hermes update` fails, next to where (`failed_stage`). `none` unless the outcome is `failed`, `refused` or `partial`. Derived from the final update receipt only: `build_failed`, `deps_failed`, `exception`, `fleet_stale`, `fleet_unverified`, `git_failed`, `interrupted`, `lock_held`, `managed_install`, `os_error`, `disk_full`, `permission_denied`, `restart_failed`, `subprocess_failed`, else `other`; Desktop packaged self-updates report `unknown` (their RPC carries a stage, never a reason). An exception that ended the run is read by its type name alone, never its message (a `PermissionError` reads `permission_denied`, an `OSError` whose errno is ENOSPC reads `disk_full`); a failed Windows gateway resume after the update reads `restart_failed`. Every exit that stops a run before its apply stage mark records one closed token at the exit itself, and the run reads it (a few of these, `syntax_rollback`, `stash_restore_rejected`, `unexpected_branch`, `head_moved`, fire after git moved the tree and put it back or left it for the next launch to restore): `fetch_failed`, `git_timeout` (a network git call hit the updater's time limit), `channel_unresolved`, `git_in_progress` (a merge/rebase/... was already running), `git_index_locked`, `merge_conflict` (local commits on a custom branch), `checkout_move_failed`, `branch_missing`, `parked_branch_blocked`, `detached_head`, `unexpected_branch`, `head_moved` (a ref moved mid-update), `target_unresolved`, `target_syntax_error` (refused before the move), `syntax_rollback` (moved, failed the syntax check, rolled back), `commit_point_refused` (the commit point could not be armed; nothing moved), `venv_foreign_owner`, `local_changes_blocked` (local changes git could not stash, or a dirty tree the ZIP fallback will not overwrite), `stash_restore_rejected`, `not_git_checkout`, `old_version_handoff` (an older updater's hand-off could not finish), `branch_unsupported`, `download_failed`, `zip_failed`, `disk_full`, `lock_held`, `managed_install`. `aborted_before_apply` is now only the fallback for such an exit with no recorded token. The update-lock refusal, the Git-operation refusal and the managed-install refusal fire before the run's receipt opens; they still write no receipt (the receipt store belongs to the update holding the lock) and record one row with that token, with `kind` `desktop` when the update marker names this run's Desktop hand-off (as its delegate or its hand-off partner), never merely because another update holds the marker. A git error that ended the checkout move reads `git_index_locked` only when git reports the index lock already exists; git refused permission to write it (or any file) reads `permission_denied`. A token is read only while the run has no apply mark, so a reason can never outlive the exit that recorded it. A run that committed and then was interrupted, or whose stashed local changes could not be re-applied, reads outcome `partial` (`interrupted` / `local_changes_parked`, `failed_stage` `apply` for the latter), never `failed`; owed follow-ups alone keep the run a `success` (contract C3). A run the pre-update interpreter finishes is parked with the token, the exit code, the stop reason's leading exception type (or one of Hermes' two fixed phrases) and the restart/user-action flags (never argv, paths or messages), so it classifies exactly as the same run finished in-process. A failed run whose every stage mark passed now reads `failed_stage` `verify` (the post-restart verification wrote `partial`) or `restart` (a skipped restart left the fleet owing one) instead of `other`; a `partial` run with a failed build or restart mark keeps that stage, and its verify stage row is failed only when the fleet has a stale or down row. |
<!-- ---- end iuf c1 ---- -->
<!-- ---- iuf c2 ---- -->
#### Fresh installs