Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Pulse /api/menubar reports four false signals (Hermes "down" on every Omarchy box, permanent "Conduit 0m", "tick stale" on a healthy daemon, "work" counts sessions); diff attached

Open 0bsolescence opened this issue 3 months ago • 3 comments

What I saw

Building an Omarchy bar widget over GET /api/menubar (the endpoint the macOS menu bar app reads) and mirroring it honestly made four standing misreports visible. All four come from Pulse, not the client, and the macOS bar has been shown the same things.

Signal Cause (7.40.4) Fix
Hermes sidecar down — gateway down on a machine that never installed the sidecar HERMES/Health.ts:167 treats ~/.hermes existing as installed. Omarchy's own Hermes CLI (omarchy-install-hermes-cli) creates ~/.hermes/skills on every Omarchy box Installed = a sidecar mark exists (gateway_state.json, gateway-starts.log, or cron/)
Conduit 0m creation today, every day, forever PULSE/modules/menubar.ts pushes a feed row whenever Conduit returns a numeric creationMinutes, including 0 No row at 0
Running — tick stale on a daemon that is fine menubar calls the daemon stale when state.json is >120s old, but pulse.ts only writes that file after a job runs. Six jobs, gaps over two minutes are normal. Polled twice on one healthy daemon: "stale", then "Running — 1d 1h" Pulse heartbeats lastTick on its own 30s timer, independent of the run loop (an in-loop write was not enough: the loop blocks on a running job and memory-consolidation is allowed 600s). 120s of silence now means two missed beats. Label reads "loop stalled". DaemonState gains lastTick?: number
counts.work labelled "work" It counts active Claude sessions from work.json (sessions filtered by phase), not the work board Not changed server-side; noting it so clients label it honestly

Reproduce (any Omarchy install of LifeOS ≥ 7.0)

ls ~/.hermes            # skills/ only, created by Omarchy, no sidecar
curl -s localhost:31337/api/menubar | jq '.hermes, [.feed[] | select(.subsystem=="conduit")], .daemon.status'
# → {"status":"down","summary":"gateway down"}, a conduit row with "0m", and "stale" during any quiet stretch

Diff

Against 7.40.4. Four files, 49 insertions, 2 deletions. writeState is tmp+rename, so the timer cannot interleave with the loop's own persist.

pulse-menubar-fixes.diff
diff --git a/LifeOS/install/LIFEOS/HERMES/Health.ts b/LifeOS/install/LIFEOS/HERMES/Health.ts
index 9bab5b4..e3d9a6f 100644
--- a/LifeOS/install/LIFEOS/HERMES/Health.ts
+++ b/LifeOS/install/LIFEOS/HERMES/Health.ts
@@ -164,7 +164,14 @@ export function checkHermesHealth(): HermesHealth {
   const checkedAt = new Date().toISOString();
   const home = hermesHome();
 
-  if (!existsSync(home)) {
+  // A bare home directory is not an install. Omarchy's own Hermes CLI
+  // (`omarchy-install-hermes-cli`) creates ~/.hermes/skills on every Omarchy
+  // box, and that alone reported the LifeOS sidecar as "down — gateway down"
+  // on every Linux perch (2026-09-04). Installed means the sidecar has left
+  // one of its own marks: gateway state, a start log, or its cron dir.
+  const sidecarMarks = ["gateway_state.json", "gateway-starts.log", "cron"];
+  const installed = existsSync(home) && sidecarMarks.some((m) => existsSync(join(home, m)));
+  if (!installed) {
     return {
       status: "absent",
       summary: "Hermes sidecar not installed",
diff --git a/LifeOS/install/LIFEOS/PULSE/lib.ts b/LifeOS/install/LIFEOS/PULSE/lib.ts
index ed4650f..9d2776e 100644
--- a/LifeOS/install/LIFEOS/PULSE/lib.ts
+++ b/LifeOS/install/LIFEOS/PULSE/lib.ts
@@ -87,6 +87,8 @@ export interface JobState {
 }
 
 export interface DaemonState {
+  /** Written every run-loop pass (≤ MAX_SLEEP_MS apart); readers treat its age as loop liveness. */
+  lastTick?: number
   version: 1
   jobs: Record<string, JobState>
   startedAt: number
diff --git a/LifeOS/install/LIFEOS/PULSE/modules/menubar.ts b/LifeOS/install/LIFEOS/PULSE/modules/menubar.ts
index 073c62d..a934203 100644
--- a/LifeOS/install/LIFEOS/PULSE/modules/menubar.ts
+++ b/LifeOS/install/LIFEOS/PULSE/modules/menubar.ts
@@ -143,7 +143,9 @@ function daemonBlock(): MenuBarPayload["daemon"] {
     if (!alive && fileAgeSec > 120) return { status: "stopped", label: "Stopped", uptimeSec: 0, failingJobs, jobCount }
     if (failingJobs > 0)
       return { status: "failing", label: `Failing — ${failingJobs} job${failingJobs === 1 ? "" : "s"}`, uptimeSec: 0, failingJobs, jobCount }
-    if (fileAgeSec > 120) return { status: "stale", label: "Running — tick stale", uptimeSec: 0, failingJobs, jobCount }
+    // Pulse heartbeats state.json every loop pass (MAX_SLEEP_MS = 60s), so 120s
+    // here means two consecutive passes were missed: a wedged loop, not a quiet one.
+    if (fileAgeSec > 120) return { status: "stale", label: "Running — loop stalled", uptimeSec: 0, failingJobs, jobCount }
     const uptimeSec = Math.max(0, Math.floor(Date.now() / 1000 - (st.startedAt || 0) / 1000))
     return { status: "running", label: `Running — ${fmtUptime(uptimeSec)}`, uptimeSec, failingJobs, jobCount }
   } catch {
@@ -245,6 +247,12 @@ async function buildPayload(): Promise<MenuBarPayload> {
     const rec = typeof conduit.todayRecordPublic === "function" ? conduit.todayRecordPublic() : null
     if (rec && typeof rec.creationMinutes === "number") {
       conduitMinutes = rec.creationMinutes
+    }
+    // A zero-minute day is not an event. A Conduit that is installed but dark
+    // (config present, nothing captured) must add no row — the same rule the
+    // Hermes block applies to an absent sidecar. Verified 2026-09-04: the row
+    // was showing "Conduit 0m creation today" on every LifeOS bar.
+    if (rec && typeof rec.creationMinutes === "number" && rec.creationMinutes > 0) {
       // Stable "today" stamp — a daily summary row, not a discrete event, so it must not
       // re-badge on every poll (it would never clear once seen).
       feed.push({
diff --git a/LifeOS/install/LIFEOS/PULSE/pulse.ts b/LifeOS/install/LIFEOS/PULSE/pulse.ts
index e1ca0e2..6e676be 100755
--- a/LifeOS/install/LIFEOS/PULSE/pulse.ts
+++ b/LifeOS/install/LIFEOS/PULSE/pulse.ts
@@ -1112,6 +1112,35 @@ async function main() {
   // public PR #1644, @elhoim
   const badScheduleJobs = new Set<string>()
 
+  // Heartbeat, independent of the run loop. state.json used to be written only
+
+  // after a job ran, so any quiet stretch over two minutes read as "tick stale"
+
+  // on every menu bar (2026-09-04). A write inside the loop was not enough: the
+
+  // loop blocks on a running job, and memory-consolidation is allowed 600s
+
+  // (codex review, same day). This timer keeps writing while a job runs, so the
+
+  // file's age means what readers assume: how long since the daemon last proved
+
+  // itself alive. writeState is atomic (tmp + rename), so it cannot interleave
+
+  // with the loop's own persist.
+
+  const heartbeat = setInterval(() => {
+
+    state.lastTick = Date.now()
+
+    writeState(STATE_PATH, state).catch((err) =>
+
+      log("error", "Failed to persist heartbeat", { error: String(err) })
+
+    )
+
+  }, 30_000)
+
+
   while (!shuttingDown) {
     const tickStart = Date.now()
     const now = new Date()
@@ -1205,6 +1234,7 @@ async function main() {
   }
 
   // ── Cleanup ──
+  clearInterval(heartbeat)
   server.stop()
   if (imessageModule) imessageModule.stopIMessage?.()
   if (assistantModule) assistantModule.stopAssistant?.()

The client, if useful

io.github.0bsolescence.lifeos-glance — a read-only Omarchy (Quickshell) bar widget over the same /api/menubar contract: daemon health glyph, session count, feed in the tooltip. kinds: ["bar-widget"], no process spawn, no write path, loopback by default. https://github.com/0bsolescence/omarchy-lifeos-glance — submitted to the Omarchy marketplace as omacom/omarchy-plugin-marketplace#4901. Happy to move it in-tree beside the macOS app if you'd rather own it.

Written with AI assistance; every claim above was reproduced on two installs before filing.

0bsolescence avatar Sep 04 '26 19:09 0bsolescence

Verification note, since two of my earlier reports (#2017, #2018) turned out to be largely already-fixed upstream and I'd rather not waste your time twice.

I checked all four against upstream main at 5e2f2e8 rather than against my fork. All four files are byte-identical to my own pre-fix baseline, so every defect above is live on current upstream:

  • LifeOS/install/LIFEOS/HERMES/Health.ts:167 — still if (!existsSync(home)), so a bare ~/.hermes still reads as installed.
  • LifeOS/install/LIFEOS/PULSE/modules/menubar.ts:246 — the Conduit row is still pushed on any numeric creationMinutes, including 0.
  • LifeOS/install/LIFEOS/PULSE/pulse.ts — writeState(STATE_PATH, …) appears exactly twice, after a job and at shutdown; there is no heartbeat, and menubar.ts:146 still calls 120s stale.
  • LifeOS/install/LIFEOS/PULSE/lib.ts:89 — DaemonState has no lastTick.

One correction to my own diff while I'm here: my first attempt heartbeated inside the run loop, which a cross-vendor review caught as insufficient — the loop blocks while a job runs and memory-consolidation is allowed 600s, so a healthy daemon could still read stale for minutes. The attached diff is the corrected version: a 30s setInterval, cleared on shutdown. writeState is tmp+rename, so it cannot interleave with the loop's own persist.

The fourth item (counts.work counting sessions) is a note, not a patch — how to label it is your call, and my client just labels it "sessions" locally.

0bsolescence avatar Sep 04 '26 19:09 0bsolescence

This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.

Confirmed 3 of 4 on our install (7.40.4). PULSE/modules/menubar.ts still pushes a Conduit feed row whenever creationMinutes is numeric including 0 (lines 246-258), and still labels a >120s-stale state.json as "Running — tick stale" (line 146); PULSE/lib.ts has no lastTick field and pulse.ts has no 30s heartbeat timer. Can't check the 4th (Hermes) the same way — LIFEOS/HERMES/Health.ts doesn't exist on this install at all.

waveman2020-sudo avatar Sep 15 '26 15:09 waveman2020-sudo

Three of the four are fixed at source: Hermes 'installed' now needs a sidecar mark, the 0m Conduit row is suppressed, and the tick heartbeat exists (with every state write on its own temp name, which the attached diff would have raced). The 'work' count is labelled for what it counts. Next release carries it. Thanks, @0bsolescence.

danielmiessler avatar Sep 17 '26 21:09 danielmiessler