Repository navigation
Add persistent node delivery and protected wake service with Hermes recovery - #148
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93db4623f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const poll = async () => { await node.tick(); try { await node.announce(); } catch { console.error(JSON.stringify({node:c.id,stage:'announce',errorClass:'HealthPublicationFailure'})); } }; | ||
| void poll(); | ||
| const timer = setInterval(() => void poll(), 15000); |
There was a problem hiding this comment.
Serialize health announcements with polling state writes
When a delivery takes longer than the 15-second polling interval and healthRoom is configured, the next poll() skips the busy tick() but still calls announce(). Both operations can then persist concurrently through the same .tmp file. Releasing a delayed delivery and health POST together reproduces an ENOENT during rename; overlapping writes also undermine the atomic state-save guarantee. Serialize the entire polling/announcement cycle, and ensure wake-triggered ticks cannot race announcement persistence.
Useful? React with 👍 / 👎.
| if (state.seen.includes(m.id) || state.pending.some(p => p.id === m.id)) continue; | ||
| const sender = typeof m.from === 'string' ? m.from : ''; | ||
| const mentioned = m.body.match(/@[a-z0-9_-]+/gi) || []; | ||
| if (state.ready && sender.toLowerCase() !== c.handle.toLowerCase() && mentioned.some(h => h.toLowerCase() === c.handle.toLowerCase()) && (!c.nodeTag || m.body.includes(c.nodeTag))) state.pending.push({ id: m.id, room, from: sender, body: m.body }); |
There was a problem hiding this comment.
Preserve attachment and reply fields in queued messages
When a mention refers to an attached image/file or replies to another message, this projection drops image_url, file_url, reply_to, and all other message metadata before delivery. The Hermes adapter only receives this reduced object, so it cannot inspect the attachment or identify the referenced task. The existing GroupMind adapter explicitly preserves attachment information and reply context. Queue the complete message, adding the room without discarding its other fields.
Useful? React with 👍 / 👎.
| state.deadLetters.push(message); state.seen.push(message.id); | ||
| } | ||
| } | ||
| state.seen = state.seen.slice(-5000); await persist(state); |
There was a problem hiding this comment.
Bound seen history even when no deliveries occur
In watched rooms with ordinary traffic but no mentions of this node, every new message is appended to state.seen, while the only 5,000-entry truncation runs inside the pending-delivery loop. Consequently, the persistent service accumulates history indefinitely, repeatedly scanning it with includes() and rewriting the entire growing state file every poll. A no-mention reproduction reaches 6,039 entries without any pruning. Apply bounded-history retention on the normal polling path as well, preserving the necessary boundaries for each watched room.
Useful? React with 👍 / 👎.
Add a Linux user-service command for durable GroupMind mention delivery, an authenticated tailnet-bound wake endpoint, and change-only health reports. A receipt-aware Hermes adapter resumes an explicit session and can rotate a confirmed context-full session while retaining transcript IDs and persistent commitments.
Delivery retries use backoff and dead letters; long offline catch-up gaps are reported explicitly after a bounded re-baseline. Readiness is separate from attention, and an acknowledgement command archives attention before clearing it. Shared @deep configurations require an explicit node tag; a distinct owner-provisioned handle is preferred.
Validation: full npm test passes 950/950; diff check clean. Tests cover request authentication, message injection resistance, routing collisions, retry/dead-letter progression, context recovery, durable receipts and attention archival. Hermes protocol source checked at accb82032cfe8f62d7e8675f0409f3cd1a840b8f; no live inference or fleet installation performed.
Deployment requires local protocol/identity preflight, a separate commitments file and single service ownership of each state file. Delivery is at least once; crash replay must respect delivery IDs. Backlog re-baselining can skip unknown older work and reports that limitation. No identity registration, SSH permission change or service installation is included.