Skip to content

The agent that grows with you

fix(webapp): a corrupt desktop-half marker timestamp is stale metadata, not an outage

Teknium07f075c291ba
diff --git a/hermes_cli/desktop_plugin_halves.py b/hermes_cli/desktop_plugin_halves.py
index 937a8dc8dfe..e1a7169812e 100644
--- a/hermes_cli/desktop_plugin_halves.py
+++ b/hermes_cli/desktop_plugin_halves.py
@@ -80,7 +80,14 @@ def _read_marker(folder: Path) -> dict | None:
marker = json.loads((folder / PACKAGE_MARKER).read_text(encoding="utf-8-sig"))
except (OSError, ValueError):
return None
- return marker if isinstance(marker, dict) and marker.get("package") and marker.get("source") else None
+ if not (isinstance(marker, dict) and marker.get("package") and marker.get("source")):
+ return None
+ mtime = marker.get("sourceMtimeMs")
+ if isinstance(mtime, bool) or not isinstance(mtime, (int, float)):
+ # A hand-edited or truncated timestamp is stale metadata: the next pass re-copies the half
+ # instead of raising mid-reconcile and taking every other plugin down with it.
+ marker["sourceMtimeMs"] = -1
+ return marker
def _write_marker(folder: Path, marker: dict) -> None:
diff --git a/tests/hermes_cli/test_webapp_desktop_plugin_halves.py b/tests/hermes_cli/test_webapp_desktop_plugin_halves.py
index 6e3c426e1f8..116e63d2b3c 100644
--- a/tests/hermes_cli/test_webapp_desktop_plugin_halves.py
+++ b/tests/hermes_cli/test_webapp_desktop_plugin_halves.py
@@ -59,6 +59,13 @@ def test_an_installed_package_brings_its_desktop_half_until_it_is_uninstalled(we
# The marker is what pairs the half with its agent row and keeps it off until enabled.
assert (marker["package"], marker["source"]) == ("radar", str(source))
+ # A corrupt timestamp in one marker is stale metadata, never an error that hides every plugin.
+ marker_path = hermes_root / "desktop-plugins" / "radar" / ".hermes-package.json"
+ marker_path.write_text(json.dumps({**marker, "sourceMtimeMs": None}), encoding="utf-8")
+ loaded = _loaded(webapp)
+ assert loaded["notes"] == ("mine", None)
+ assert isinstance(loaded["radar"][1]["sourceMtimeMs"], (int, float))
+
(source / "plugin.js").write_text("export default { v: 2 }", encoding="utf-8")
later = os.stat(source / "plugin.js").st_mtime + 5
os.utime(source / "plugin.js", (later, later))