DEV Community

Daniel
Daniel

Posted on

MatrixSwarm Real-Time Agent Resurrection: Socket-Free Ops with Inotify and Pod Protocol

What If Your System Could Heal Itself?

No Docker. No systemd babysitting. No Kubernetes overhead. Just a swarm of raw, folder-born agents watching each other, resurrecting their fallen, and maintaining a live operational tree using the filesystem itself. This is MatrixSwarm.

In this post, you'll learn how to build a socketless, real-time agent orchestration protocol using inotify, ephemeral pods, and JSON-based directives. It's fast. It's fault-tolerant. And it's weirdly beautiful.

๐Ÿ› ๏ธ What Weโ€™re Building

Youโ€™ll walk away with a working agent architecture that supports:

๐ŸŽฏ Stateless agent spawning from JSON directives

๐Ÿ’€ Self-detecting agent death using hello.token/ heartbeat watchers

โ™ป๏ธ Resurrection on failure via spawn_queue/ trigger files

๐Ÿ“‚ Command delivery via payload/ folders (no sockets needed)

๐Ÿง  Matrix as the root coordinator with Sentinel and Scavenger delegation

๐Ÿงฑ Core Concepts

  1. Agent Pod Directory Structure

Every agent lives in its own ephemeral folder (e.g., /pod/{uuid}), and its communication structure is rooted at /comm/{permanent_id}.

Each pod includes:

hello.token/ โ€” heartbeat files written by the agent every few seconds

payload/ โ€” incoming command files like stop, restart, or inject

outbox/ โ€” outgoing messages or logs

live.json.enc โ€” encrypted directives passed from Matrix

  1. Spawn-on-Failure with Inotify

Sentinel watches its delegated agentsโ€™ hello.token/ directories. If no new heartbeat file appears after a timeout, Sentinel:

Triggers a spawn request by writing a file to /spawn_queue/

Matrix picks up the request, reads the permanent_id, and relaunches the agent

The new agent reattaches and resumes heartbeat

  1. CLI-Controlled Commands

You can inject commands into an agentโ€™s payload/ directory:

{
"cmd": "replace",
"agent": "sqlite3",
"uuid": "old-uuid",
"directives": {...}
}

Matrix reads it. The tree updates. The agent is killed and replaced live.

๐Ÿ” Real Use Cases
Upload folder monitor

GitHub Actions trigger

Discord file drop responder

Email inbox reader

Remote camera frame detector

๐Ÿ”— Get Started
GitHub: https://github.com/matrixswarm/matrixswarm

Website: https://matrixswarm.com

YouTube: MatrixSwarm OS โ€“ Spawn, Kill, Resurrect

X/Twitter: @matrixswarm

๐Ÿ“œ Fork It Clause
MatrixSwarm is open.
Fork it.
Or Fork U.
(The swarm is open. Bring tools or get logged.)

Top comments (0)