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
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
fix(hive): bounce and log mail to an id with no inbox instead of dropping it
hyperstream-pro614de6855542
diff --git a/package.json b/package.jsonindex 97bb375a..89abb8d1 100644--- a/package.json+++ b/package.json@@ -19,7 +19,7 @@"typecheck:node": "tsc --noEmit -p tsconfig.node.json","typecheck:web": "tsc --noEmit -p tsconfig.web.json","typecheck": "npm run typecheck:node && npm run typecheck:web",- "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/terminal-selection.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-task-mutation.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/release-notes.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/ide-image.test.cjs test/win-cmd-shim.test.cjs test/hive-windows-prompt.test.cjs test/release-drop.test.cjs test/skills.test.cjs test/skills-install.test.cjs test/hero-payload.test.cjs",+ "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/terminal-selection.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-task-mutation.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/release-notes.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs test/ide-image.test.cjs test/win-cmd-shim.test.cjs test/hive-windows-prompt.test.cjs test/hive-unknown-recipient.test.cjs test/release-drop.test.cjs test/skills.test.cjs test/skills-install.test.cjs test/hero-payload.test.cjs","check:links": "node tools/check-release-links.cjs","dist": "npm run build && electron-builder","dist:mac": "npm run build && electron-builder --mac",diff --git a/src/main/hive.ts b/src/main/hive.tsindex ce5cd937..420951d0 100644--- a/src/main/hive.ts+++ b/src/main/hive.ts@@ -1164,11 +1164,14 @@ export class HiveManager {};}- /** Atomically deliver a message into a recipient agent's inbox. */- private deliver(msg: HiveMessage, toId: string): void {+ /** Atomically deliver a message into a recipient agent's inbox.+ * Returns false when the recipient has no inbox, so the caller can bounce and+ * log the drop rather than let the message vanish. */+ private deliver(msg: HiveMessage, toId: string): boolean {const inbox = join(this.agentDir(toId), 'inbox');- if (!existsSync(inbox)) return; // unknown recipient — dropped (logged by caller)+ if (!existsSync(inbox)) return false; // unknown recipient — the caller reports itthis.atomicWriteJson(join(inbox, `${msg.id}.json`), msg);+ return true;}/** Inject a message directly (used by the orchestrator / UI / tests). */@@ -1205,6 +1208,9 @@ export class HiveManager {&& canReceiveInbox(reg.agents[a]?.provider))// Never deliver to self — guards a god → "human" message looping back to god.: [resolveTo(msg.to)].filter((t) => t !== msg.from);+ // Targets that actually took delivery. The log below reports these instead of+ // intent, so a bounced or dropped message can never read as delivered.+ const delivered: string[] = [];for (const t of targets) {// The send-only prep assistant must never be a delivery target: it doesn't// drain an inbox, so direct mail to it would rot unread (observed live: a@@ -1232,7 +1238,7 @@ export class HiveManager {to: godId,subject: `[undeliverable — "${t}" runs ${reg.agents[t]?.provider ?? 'a hookless CLI'} and the terminal handoff failed (renderer unavailable); relay this to it] ${msg.subject}`}, godId);- }+ } else delivered.push(t);continue;}// 1d — proxy-tier providers (qwen) CAN receive inbox, but only via a@@ -1248,12 +1254,24 @@ export class HiveManager {to: godId,subject: `[undeliverable — "${t}" runs ${reg.agents[t]?.provider ?? 'a proxy-tier CLI'} and the terminal handoff failed (renderer unavailable); relay this to it] ${msg.subject}`}, godId);- }+ } else delivered.push(t);continue;}- this.deliver(msg, t);+ if (this.deliver(msg, t)) { delivered.push(t); continue; }+ // No agents/<t>/inbox — an id that isn't on the floor. This was the one+ // delivery failure with neither bounce nor log, so the sender saw a routed+ // message and the mail simply ceased to exist. Record the drop beside the+ // hop-cap one and bounce to god, mirroring the undeliverable bounces above.+ this.appendLog({ kind: 'drop', reason: 'no-inbox', from: msg.from, to: t, id: msg.id });+ if (t !== godId) {+ this.deliver({+ ...msg,+ to: godId,+ subject: `[undeliverable — no agent "${t}" on this floor; check the id against the roster] ${msg.subject}`+ }, godId);+ }}- this.appendLog({ kind: 'message', from: msg.from, to: msg.to, act: msg.act, subject: msg.subject, id: msg.id });+ this.appendLog({ kind: 'message', from: msg.from, to: msg.to, act: msg.act, subject: msg.subject, id: msg.id, delivered });this.emitMessage(msg, targets);// Main-process observer (e.g. the closing-time controller watching for the// team's ACKs and the god's COMPLETE). Best-effort, never breaks routing.diff --git a/test/hive-unknown-recipient.test.cjs b/test/hive-unknown-recipient.test.cjsnew file mode 100644index 00000000..f2eccba0--- /dev/null+++ b/test/hive-unknown-recipient.test.cjs@@ -0,0 +1,82 @@+'use strict';++/**+ * Regression for the silent unknown-recipient drop. `deliver()` returned early+ * when `agents/<to>/inbox` did not exist — no write, no bounce, no log — while+ * `routeOnce` still archived the outbox file to `.sent/` and `log.jsonl` still+ * recorded `kind:"message"`. A mis-addressed message therefore ceased to exist+ * with every observability surface reporting success; on one floor 14 of 32+ * messages vanished that way before anyone noticed.+ *+ * Unknown-recipient was the only delivery failure with neither a bounce (the+ * prep-assistant and hookless-provider cases have one) nor a drop log (the+ * hop-cap case has one). It now has both, and the message log reports the+ * targets that actually took delivery rather than the sender's intent.+ */++const test = require('node:test');+const assert = require('node:assert/strict');+const fs = require('node:fs');+const os = require('node:os');+const path = require('node:path');+const loadTs = require('./load-ts.cjs');++const { HiveManager } = loadTs('src/main/hive.ts');++async function floor(t) {+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'md-unknown-to-'));+ t.after(() => fs.rmSync(home, { recursive: true, force: true }));+ const hive = new HiveManager(() => home);+ await hive.ensureAgent({ id: 'god-1', name: 'Michael', provider: 'claude', cwd: home, isGod: true });+ await hive.ensureAgent({ id: 'jim-1', name: 'Jim', provider: 'claude', cwd: home });+ return { home, hive };+}++const entries = (hive, kind) => hive.logTail(500).filter((e) => e.kind === kind);++test('mail to an id with no inbox bounces to god and is logged as a drop', async (t) => {+ const { hive } = await floor(t);++ // "jim" is the display name; the contract is the agent id, so nothing resolves.+ hive.send({ to: 'jim', act: 'request', subject: 'T15 — start the build', body: 'go' }, 'god-1');++ assert.equal(hive.inbox('jim-1').length, 0, 'nothing should reach the real agent');++ const dropped = entries(hive, 'drop').filter((e) => e.reason === 'no-inbox');+ assert.equal(dropped.length, 1);+ assert.equal(dropped[0].to, 'jim');+ assert.equal(dropped[0].from, 'god-1');++ const bounced = hive.inbox('god-1');+ assert.equal(bounced.length, 1);+ assert.match(bounced[0].subject, /^\[undeliverable — no agent "jim"/);+ assert.match(bounced[0].subject, /T15 — start the build$/);+ assert.equal(bounced[0].body, 'go', 'the bounce carries the original body');+});++test('the message log records delivered targets, not intent', async (t) => {+ const { hive } = await floor(t);++ hive.send({ to: 'jim-1', act: 'inform', subject: 'landed' }, 'god-1');+ hive.send({ to: 'scheduler', act: 'inform', subject: 'standup' }, 'jim-1');++ const [ok, lost] = entries(hive, 'message');+ assert.deepEqual(ok.delivered, ['jim-1']);+ assert.deepEqual(lost.delivered, [], 'a message nobody received must not read as delivered');+});++test('an unknown recipient does not stop the rest of a broadcast', async (t) => {+ const { hive } = await floor(t);+ // A registry entry whose agent directory was never created — the same shape a+ // stale roster leaves behind.+ const reg = JSON.parse(fs.readFileSync(path.join(hive.root(), 'registry.json'), 'utf8'));+ reg.agents['ghost-1'] = { id: 'ghost-1', name: 'Ghost', provider: 'claude', cwd: '.' };+ fs.writeFileSync(path.join(hive.root(), 'registry.json'), JSON.stringify(reg, null, 2));++ hive.send({ to: 'broadcast', act: 'inform', subject: 'all hands' }, 'god-1');++ assert.equal(hive.inbox('jim-1').length, 1, 'the live agent still gets the broadcast');+ const [msg] = entries(hive, 'message');+ assert.deepEqual(msg.delivered, ['jim-1']);+ assert.equal(entries(hive, 'drop').filter((e) => e.to === 'ghost-1').length, 1);+});