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
- 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
- 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
- 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)