Skip to main content
Glama
README.md
# 🧠 Sanctify-Hivemind

**A multi-agent orchestration framework for autonomous operations on live systems.**

Hivemind lets a *swarm* of specialized AI agents take a one-line goal, decompose it
into a task graph, execute tool calls against a **real production environment**,
independently verify every action, and roll back on failure β€” with a full,
replayable audit trace.

WordPress is the **first environment adapter** (and a demanding one: live sites,
credentials, no room for "oops"). But the framework is environment-agnostic β€”
the interesting part is the *architecture*, not the CMS.

> The website is the proving ground. The product is the agent system.

---

## Why this exists

Letting an LLM *act* on a live system is easy to demo and terrifying to run. The
hard problems aren't "call an API" β€” they're:

1. **Coordination** β€” how do you decompose a fuzzy goal into ordered, parallelizable
   work and delegate it to the right specialists?
2. **Safety on production** β€” how do you let an agent write to a live system without
   a bad step causing an outage?
3. **Reliability** β€” how do you know an action actually *worked*, and recover when it
   didn't, without a human watching every step?

Hivemind is an opinionated answer to those three, learned the hard way from real
incident-response and site-operations work.

---

## Architecture

```
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          goal  ───────► β”‚        Orchestrator          β”‚
   "harden + audit       β”‚  goal β†’ task DAG β†’ schedule   β”‚
    this site"           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚ dispatch (parallel where independent)
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β–Ό                        β–Ό                         β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚  Recon     β”‚          β”‚  Security  β”‚    ...      β”‚   SEO      β”‚   ◄── specialist agents
          β”‚  Agent     β”‚          β”‚  Agent     β”‚            β”‚  Agent     β”‚
          β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                β”‚  tool calls (typed, capability-scoped)          β”‚
                β–Ό                        β–Ό                         β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚        Tool Registry  +  Capability / Permission model     β”‚
          β”‚   read-only vs write Β· allowlists Β· human-approval gate     β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚  Environment Adapter (WordPress: REST Β· FTP Β· Browser)     β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β–Ό   every write is wrapped by:
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚  Safety Engine   snapshot β†’ act β†’ health-check β†’ rollback   β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   reject/retry   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚  Critic /  │◄─────────────────│  every action's outcome   β”‚
          β”‚  Verifier  │─── approve ─────►│  checked against the goal β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

   Cross-cutting:  Memory (world-model + shared blackboard + pattern store)
                   Audit Trace (every decision + tool call, replayable)
                   Cognition (pluggable LLM backends / SuperBrain)
```

### The six systems

| System | Responsibility | Why engineers care |
|---|---|---|
| **Orchestrator** | Goal β†’ task DAG β†’ parallel/sequential scheduling β†’ delegation | Real task decomposition, not a linear script |
| **Tool Registry + Capability model** | Typed tools with permission scoping (read vs write, allowlists, approval gate) | The "how do you let an agent touch prod safely" answer |
| **Safety Engine** | Snapshot-before-act, post-act health check, auto-rollback, circuit breakers | Responsible autonomy on live systems |
| **Critic / Verifier** | Independent check of each action vs. the goal; retry or roll back | Actor–critic on real infra β€” separates agents from LLM wrappers |
| **Memory** | Per-environment world-model, shared blackboard, reusable pattern store | Agents don't start cold; they coordinate + learn |
| **Audit Trace** | Every decision and tool call logged + replayable | Debuggability, trust, post-mortems |

---

## Design principles

- **Environment-agnostic core.** WordPress is an adapter; the orchestrator/critic/
  safety layers know nothing about it.
- **Capability-scoped by default.** Agents get the *least* access needed. Writes are
  explicit, gated, and reversible.
- **Verify everything.** No action is "done" until an independent critic confirms it
  against the goal.
- **Every write is a transaction.** snapshot β†’ act β†’ verify β†’ commit or rollback.
- **Model-agnostic cognition.** Reasoning is pluggable (local rules, hosted LLMs, or
  SuperBrain as the cognition/decision layer).
- **Credential-free repo.** Secrets live in env / a secret manager, per environment,
  never committed.

---

## Repository layout

```
Sanctify-Hivemind/
β”œβ”€β”€ hivemind/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ tools.py          # typed tool registry + capability/permission model
β”‚   β”‚   β”œβ”€β”€ safety.py         # snapshot/rollback, health checks, audit trace
β”‚   β”‚   β”œβ”€β”€ agent.py          # base agent contract
β”‚   β”‚   β”œβ”€β”€ orchestrator.py   # goal β†’ task DAG β†’ scheduler β†’ delegation
β”‚   β”‚   β”œβ”€β”€ critic.py         # verification / actor-critic loop
β”‚   β”‚   └── memory.py         # world-model, blackboard, pattern store
β”‚   β”œβ”€β”€ environments/
β”‚   β”‚   └── wordpress/        # the WordPress adapter (first environment)
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ recon.py          # site reconnaissance specialist
β”‚   β”‚   └── security.py       # security specialist (malware/CVE)
β”‚   └── cognition/            # pluggable LLM/SuperBrain backends
β”œβ”€β”€ examples/                 # runnable end-to-end demos
β”œβ”€β”€ traces/                   # replayable run logs (gitignored)
β”œβ”€β”€ tests/
└── .kiro/                    # steering + skill (SuperBrain integration)
```

---

## Status

🚧 **Vertical slice.** The core (orchestrator, tools, safety, critic, memory), the
WordPress adapter, and the Security/Recon specialists run a real goal end-to-end.
Additional specialists (SEO, Frontend, Content) plug into the same contracts.

The Security agent currently detects:
- the self-healing **"Smooth Backup Ink" (SCV)** file-malware family (IOC scan),
- **vulnerable plugins/themes** via a versioned CVE rules library (ThemeREX Addons,
  Slider Revolution), and
- the **Japanese-keyword-hack / cloaked SEO spam** class β€” by fetching the page *as
  Googlebot* and diffing against a normal browser, catching spam that is invisible to
  visitors but indexed by Google (foreign-script titles, counterfeit-goods phrases,
  spam sitemap URLs).

## Use it from any AI assistant (MCP)

Hivemind ships an **MCP server** (`hivemind-mcp`) so it plugs in as a native tool for
**Kiro, ChatGPT (desktop), Codex, and the Gemini CLI**, and as a **library/CLI** for
Grok or any code-running agent.

```bash
pip install -e ".[mcp,wordpress]"
hivemind-mcp        # stdio MCP server exposing recon / security_scan / seo_spam_scan / run_goal
```

Point the target site via the server's env (`WP_URL`) β€” **the model never supplies
credentials or the target**, which prevents prompt-driven SSRF / secret leakage.

πŸ‘‰ **Copy-paste config for each assistant is in [USAGE.md](USAGE.md).**

| Tool | Access | Purpose |
|------|--------|---------|
| `hivemind.recon` | read-only | Fingerprint stack, plugins, exposure |
| `hivemind.security_scan` | read-only | Malware IOCs + vulnerable-plugin CVEs |
| `hivemind.seo_spam_scan` | read-only | Japanese/Russian keyword-hack + cloaking |
| `hivemind.run_goal` | varies | Run a natural-language goal end-to-end |

## Credits

Built and maintained by **[Sanctify β€” Digital Marketing Agency, Goa](https://www.sanctify.in/)**.

Sanctify-Hivemind was distilled from real-world WordPress security incident response,
SEO, and site-operations work. If it helps you, a link back to
[www.sanctify.in](https://www.sanctify.in/) is appreciated.

## License

MIT Β© [Sanctify](https://www.sanctify.in/)