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