Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(hive): re-arm message router on system resume so delivery survives sleep

Chaitanya Giria0609eadd536
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 607bc6e8..4c1b7ba8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,15 @@ All notable changes to this project are documented here. The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.3.1] — 2026-06-22
+
+A reliability patch for the hive message router. Completes the **wake-reliability hardening**
+started in 0.3.0 (which caught up missed *schedules* and auto-revived wedged *terminals* on wake,
+but left the *router* out).
+
+### Fixed
+- **Re-arm the hive message router on wake (god→worker delivery survives sleep).** The outbox→inbox router is a `setInterval` (`hive.routeOnce` every ~1.5s) that, like the always-on beats, freezes during true macOS system sleep. `onSystemResume()` already re-armed the mission scheduler, the fleet/breaker beats, and keep-awake on `powerMonitor` `resume`/`unlock-screen` — but it never re-armed the router. So after a long sleep (e.g. laptop closed overnight) the scheduler→god path recovered while **every agent's outbox silently stopped draining**: god→worker, worker↔worker, and broadcast mail piled up undelivered, and no `message` event was logged. The resume handler now re-arms the router (clear-then-set, idempotent) **and** immediately drains the accumulated backlog instead of waiting for the first post-wake tick; the renderer's idle inbox-wake nudge then wakes each parked recipient once its mail lands (`src/main/index.ts`). Verified by `scripts/verify-keepalive-catchup.mjs` (now also reproduces the pre-fix backlog stall and proves the re-arm + flush).
+
## [0.3.0] — 2026-06-21
A platform release: the floor stops being Claude-shaped. **Selectable agent engines** make
diff --git a/README.md b/README.md
index 8f67656d..1ac37572 100644
--- a/README.md
+++ b/README.md
@@ -267,7 +267,7 @@ Shipped in **v0.2.0–v0.3.0**:
- [x] **Slack-spawned ephemeral workers** — Michael spawns an isolated worker from a Slack request, replies in-thread, then tears it down safely (worktree GC + per-worker token caps), surfaced in a Workers tab.
- [x] **Temporal date-range skills + worker capability catalog** — named windows resolve to concrete ISO dates, and each worker can read exactly what tools/integrations it has.
- [x] **Agent Gallery + six off-the-shelf hires** — *The Hiring Fair* rebranded, with a visual Provider/Hive picker in onboarding and add-agent and feature-aware onboarding.
-- [x] **Wake-reliability hardening** — auto-revive wedged terminals and catch up missed schedules when the machine wakes.
+- [x] **Wake-reliability hardening** — auto-revive wedged terminals, catch up missed schedules, and re-arm the hive message router (draining any mail that piled up) when the machine wakes.
- [x] **Shareable hires** — import a role-configured agent from a `munderdifflin://hire` deep link or a local manifest; import pre-fills the Add-Agent modal (the human spawns), and the manifest is validated as untrusted input. Ready-made roles live in the [Agent Gallery](https://munderdiffl.in/hires/).
- [x] **Heartbeat** — scheduler heartbeat that re-engages the floor when it goes quiet, with last/next-fired times surfaced in the Schedules tab.
diff --git a/RELEASE.md b/RELEASE.md
index 4d39eb66..efa84f7a 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -1,4 +1,4 @@
-# Munder Difflin v0.3.0
+# Munder Difflin v0.3.1
**A local hive of Claude Code, Antigravity & Codex agents that run themselves** — messaging,
routing, and remembering, coordinated by a GOD orchestrator you talk to. Local-first and open source.
@@ -7,6 +7,18 @@ routing, and remembering, coordinated by a GOD orchestrator you talk to. Local-f
---
+## What's new in 0.3.1 — *Router survives sleep*
+
+A reliability patch. The hive message router (the loop that drains each agent's `outbox/` into
+recipients' `inbox/`) is a timer that **freezes during true macOS system sleep**. 0.3.0's
+wake-reliability hardening re-armed the scheduler and revived wedged terminals on wake, but the
+router was left out — so after a long sleep (laptop closed overnight) the GOD orchestrator's
+standups kept arriving while **agent-to-agent and god-to-worker mail silently stopped delivering**.
+On wake the harness now **re-arms the router and immediately drains whatever piled up**, so
+delegation keeps flowing after the machine sleeps. (Verified by `scripts/verify-keepalive-catchup.mjs`.)
+
+---
+
## What's new in 0.3.0 — *Selectable engines, integrations, and Slack-spawned workers*
The biggest platform release yet: the floor stops being Claude-shaped. Every hire — and Michael
diff --git a/docs/index.html b/docs/index.html
index b95678e3..003246b0 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -33,7 +33,7 @@
"url": "https://munderdiffl.in/",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux",
- "softwareVersion": "0.3.0",
+ "softwareVersion": "0.3.1",
"downloadUrl": "https://github.com/chaitanyagiri/munder-difflin/releases/latest",
"softwareHelp": "https://github.com/chaitanyagiri/munder-difflin#readme",
"license": "https://github.com/chaitanyagiri/munder-difflin/blob/main/LICENSE",
@@ -746,7 +746,7 @@
<!-- ===================== HERO ===================== -->
<header class="hero">
<div class="wrap">
- <div class="chip reveal">⚡ <b>v0.3.0</b> · Multi-provider · Open source · macOS · Windows</div>
+ <div class="chip reveal">⚡ <b>v0.3.1</b> · Multi-provider · Open source · macOS · Windows</div>
<h1 class="hero-title reveal">
Run a virtual <span style="color:var(--sky)">office of AI agents</span> on any computer.
</h1>
@@ -1582,7 +1582,7 @@
// download picker — pick macOS / Windows / Linux, click starts the download
(function () {
var REPO = 'chaitanyagiri/munder-difflin';
- var REL = '0.3.0'; // fallback version; live links are resolved from the GitHub API below
+ var REL = '0.3.1'; // fallback version; live links are resolved from the GitHub API below
var BASE = 'https://github.com/' + REPO + '/releases/latest/download/';
var PLATFORMS = [
{ key: 'mac', icon: '🍎', os: 'macOS', sub: 'Universal · Apple Silicon + Intel', match: 'mac-universal.dmg', file: 'Munder-Difflin-' + REL + '-mac-universal.dmg' },
diff --git a/package.json b/package.json
index 0f42e05d..d1d97e66 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "munder-difflin",
- "version": "0.3.0",
+ "version": "0.3.1",
"private": true,
"description": "Local multi-agent harness for Claude Code: autonomous agents that message, route, and remember — coordinated by a GOD orchestrator and visualized as avatars at work.",
"main": "out/main/index.js",
diff --git a/scripts/verify-keepalive-catchup.mjs b/scripts/verify-keepalive-catchup.mjs
index b126129f..0e12727f 100644
--- a/scripts/verify-keepalive-catchup.mjs
+++ b/scripts/verify-keepalive-catchup.mjs
@@ -13,6 +13,13 @@
// 3. A mission NOT yet due does not fire early on resume.
// 4. Overlapping resume + unlock-screen events collapse to ONE catch-up fire
// (onSystemResume is idempotent: clear-then-arm).
+// 5. PRE-FIX REGRESSION: the hive message router is a setInterval (routeOnce
+// every ~1.5s) that freezes across true system sleep just like the beats;
+// the old onSystemResume re-armed the scheduler + beats but NOT the router,
+// so an outbox that piled up while asleep stayed undelivered after wake.
+// 6. FIX: the new onSystemResume re-arms the router AND flushes the backlog
+// immediately on wake (no tick wait) — god->worker mail delivers on resume.
+// 7. FIX: the re-armed router keeps draining subsequent mail at its cadence.
// ---- fake clock + timer queue (libuv-style monotonic; we control advancement) --
let nowMs = 1_000_000; // arbitrary "boot" instant
@@ -90,5 +97,44 @@ onSystemResume(m); // 'unlock-screen' immediately after — must
advance(0);
ok(fireCount === 1, `resume+unlock collapse to ONE catch-up fire (idempotent) -> fireCount=${fireCount}`);
+// ---- router re-arm on wake (the god->worker delivery fix) -----------------------
+// Mirror of the hive message router: a setInterval that drains every agent's
+// outbox into recipient inboxes (hive.startRouter/stopRouter/routeOnce). Like the
+// always-on beats it freezes across true system sleep; the fix re-arms it AND
+// flushes the backlog in onSystemResume's new router block.
+const ROUTER_MS = 1500;
+let queue = 0; // outbox messages awaiting routing (e.g. god's pile-up)
+let delivered = 0; // messages routed into recipient inboxes
+let routerTimer = null;
+const routeOnce = () => { const n = queue; queue = 0; delivered += n; return n; }; // mirrors hive.routeOnce()
+const startRouter = () => { if (routerTimer === null) routerTimer = setI(routeOnce, ROUTER_MS); }; // idempotent, like hive.startRouter
+const stopRouter = () => { if (routerTimer !== null) { clr(routerTimer); routerTimer = null; } };
+const resumeOld = () => { /* BUG: scheduler/beats re-armed, router left frozen */ };
+const resumeNew = () => { stopRouter(); startRouter(); routeOnce(); }; // the new onSystemResume router block
+
+reset();
+startRouter();
+queue = 1; advance(ROUTER_MS);
+ok(delivered === 1, `awake: router drains a freshly-written outbox within one tick -> delivered=${delivered}`);
+
+stopRouter(); // true system sleep halts the libuv interval (dead until re-armed)
+queue += 3; // god's outbox accumulates while the floor is asleep
+advance(100 * ROUTER_MS); // wall-clock passes; the frozen timer never fires
+ok(delivered === 1, `asleep: frozen router does NOT drain the backlog -> delivered=${delivered}`);
+
+// (5) PRE-FIX: old resume leaves the router dead -> the backlog never delivers.
+resumeOld();
+advance(100 * ROUTER_MS);
+ok(delivered === 1, `pre-fix resume: backlog STAYS undelivered (reproduces the bug) -> delivered=${delivered}`);
+
+// (6) FIX: new resume re-arms + flushes immediately on wake (no tick wait).
+resumeNew();
+advance(0);
+ok(delivered === 4, `fixed resume: backlog flushed immediately on wake -> delivered=${delivered}`);
+
+// (7) FIX: the re-armed router keeps draining subsequent mail at its cadence.
+queue += 2; advance(ROUTER_MS);
+ok(delivered === 6, `fixed resume: re-armed router drains subsequent mail -> delivered=${delivered}`);
+
console.log(failures === 0 ? '\nALL CHECKS PASS' : `\n${failures} CHECK(S) FAILED`);
process.exit(failures === 0 ? 0 : 1);
diff --git a/src/main/index.ts b/src/main/index.ts
index 712a8c9c..6d2b6a6a 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -3127,9 +3127,24 @@ function healthCheckPtys(reason: string, awayMs: number | null): void {
* health-check the terminals. Idempotent: overlapping resume+unlock events
* collapse safely (clear-then-arm everywhere; at most one catch-up fire). */
function onSystemResume(reason: string): void {
- console.log(`[power] ${reason} — re-arming scheduler, beats, keep-awake`);
+ console.log(`[power] ${reason} — re-arming scheduler, beats, router, keep-awake`);
try { syncMissions(); } catch (e) { console.error('[power] syncMissions on resume', e); }
try { armAlwaysOnBeats(); } catch (e) { console.error('[power] armAlwaysOnBeats on resume', e); }
+ // The hive message router (outbox→inbox drain) is a setInterval that freezes
+ // during true system sleep exactly like the beats above — but it was the one
+ // always-on timer never re-armed on wake. Symptom: after a long sleep the
+ // scheduler→god path recovered (it injects straight into god's inbox), while
+ // every agent's outbox silently stopped draining, so god→worker and
+ // worker↔worker mail piled up undelivered. Re-arm the poll loop (clear-then-set,
+ // idempotent) and immediately drain the backlog that accrued while we were out
+ // instead of waiting for the first post-wake tick. The renderer's idle inbox-wake
+ // nudge (useHive.ts) then wakes each parked recipient once its mail lands.
+ try {
+ hive.stopRouter();
+ hive.startRouter();
+ const drained = hive.routeOnce();
+ if (drained > 0) console.log(`[power] ${reason} — flushed ${drained} queued hive message(s)`);
+ } catch (e) { console.error('[power] router re-arm on resume', e); }
try { syncKeepAwake(); } catch (e) { console.error('[power] syncKeepAwake on resume', e); }
const awayMs = lastSuspendAt != null ? Date.now() - lastSuspendAt : null;
// Give PTYs a beat to resume their pipes before judging them wedged; reset any