https://github.com/pacphi/ruflo-machine-ref
Make ruflo + Claude Code rock-solid on modern Node (24/26): native SQLite (no silent data loss), ~84k fewer tokens per session, and configure-once-per-machine setup that keeps every repo clean. A thin, reversible layer over ruflo.
https://github.com/pacphi/ruflo-machine-ref
anthropic better-sqlite3 claude claude-code developer-tools mcp nodejs ruflo
Last synced: 26 days ago
JSON representation
Make ruflo + Claude Code rock-solid on modern Node (24/26): native SQLite (no silent data loss), ~84k fewer tokens per session, and configure-once-per-machine setup that keeps every repo clean. A thin, reversible layer over ruflo.
- Host: GitHub
- URL: https://github.com/pacphi/ruflo-machine-ref
- Owner: pacphi
- License: mit
- Created: 2026-05-28T19:41:26.000Z (27 days ago)
- Default Branch: main
- Last Pushed: 2026-05-29T01:41:40.000Z (27 days ago)
- Last Synced: 2026-05-29T03:21:59.512Z (27 days ago)
- Topics: anthropic, better-sqlite3, claude, claude-code, developer-tools, mcp, nodejs, ruflo
- Language: Shell
- Size: 32.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π§° ruflo-machine-ref
**A small, friendly setup kit that makes [ruflo](https://github.com/ruvnet/ruflo) actually work the way it promises β reliable memory, *active* self-learning, verified security, and an at-a-glance status line β especially on modern Node (24/26), where a stock install quietly breaks in ways that still look "green."**
> One-time setup per machine. One command to heal after upgrades. Nothing committed to your repos unless you mean it.
---
## π€ What is this, in plain words?
[**ruflo**](https://github.com/ruvnet/ruflo) is an AI orchestration toolkit for [Claude Code](https://claude.com/claude-code) β it gives your AI assistant a memory that survives across sessions, the ability to learn from what works, multi-agent coordination, and security scanning.
The catch: on the versions of Node.js most developers run today, ruflo **silently falls back to a degraded mode**. It still says "β
OK", but underneath:
- πΎ the **memory** that's supposed to persistβ¦ doesn't (writes vanish),
- π§ the **self-learning** that's supposed to be onβ¦ stays asleep,
- π the optional **quality-engineering** add-on won't even finish installing,
- π and you have no easy way to *see* which of these is actually working.
This kit closes all of those gaps with a few small, reversible helper scripts β and gives you a **status line** that shows, at a glance, exactly what's live.
> π **Not a developer?** You only need three commands: `./install.sh` (once), then `ruflo-onboard` inside a project, and `ruflo-resync` after any upgrade. The rest of this README explains the "why" for the curious.
---
## β‘ The 30-second version
| You want⦠| Stock ruflo on Node 24/26 | With this kit |
|---|---|---|
| πΎ Memory that persists across sessions | Says "saved" but loses data | Saves for real, and **verifies** it landed on disk |
| π§ Self-learning that's actually on | Reports "Not loaded" | **Active & proven** (trains β patterns persist) |
| π‘οΈ Security scanning | Ships but undocumented/unverified | **Verified**: scan, secrets, prompt-injection defense |
| π Agentic-QE quality fleet (optional) | `aqe init` fails on Node 24/26 | **Installs cleanly** (same bug, auto-fixed) |
| π Knowing what's active | No indication | **Status-line footer** shows π§ / π‘οΈ / π live |
| π Surviving an upgrade | Re-breaks silently every upgrade | **`ruflo-resync`** β one command re-heals everything |
| π° Token budget | ~84k tokens/session of MCP tool defs | MCP optional; CLI-first saves the tokens |
---
## π§© What's actually wrong (the short story)
Modern Node.js (24 and 26) changed its native-addon ABI. ruflo's deeper dependencies pin an **old `better-sqlite3`** that has no prebuilt binary for those Node versions and won't compile against them. npm treats it as optional and **skips it silently**, so ruflo drops to a pure-JavaScript SQLite fallback whose write path **loses data** β while still printing success.
That single root cause cascades:
1. πΎ **Memory loss** β the headline symptom.
2. π§ **Dormant self-learning** β the same missing binary keeps the ruvector engine (SONA, HNSW, ReasoningBank) asleep.
3. π **Agentic-QE won't initialize** β it's a *separate* package ([`agentic-qe`](https://github.com/proffesor-for-testing/agentic-qe)) with the *same* bug.
> π **A note on prior art.** A colleague, **Ciprian Melian**, wrote an excellent project-scoped repair kit as a gist ([link](https://gist.github.com/ciprianmelian/eb7e8ff7d24018141ca34bb8a7e216a6)) that pairs ruflo with agentic-qe. This kit builds on those ideas but takes a **machine-wide, upgrade-safe** approach β and our investigation found that several of the gist's source patches are now **already upstream in ruflo 3.10.5** (the real remaining lever is the missing native binary, not the source patches). The full story is in [docs/BACKGROUND.md](docs/BACKGROUND.md).
The deep dive β ABI tables, the exact files, why "HNSW: Not loaded" is a cosmetic lie β lives in **[docs/BACKGROUND.md](docs/BACKGROUND.md)**.
---
## β¨ What this kit gives you
- π©Ή **Native SQLite, everywhere ruflo needs it** β `ruflo-patch-native` swaps the broken dependency for one that works on Node 24/26.
- π§ **Activated + *proven* self-learning** β `ruflo-enable-learning` turns ruvector on and asserts it (5 real capability probes, not the misleading status text); `ruflo-learning-verify` trains a cycle and confirms patterns persist to disk.
- π‘οΈ **Verified security surface** β `ruflo-security-verify` confirms `@claude-flow/security` + `@claude-flow/aidefence` load, that prompt-injection defense actually fires, and flags the known CVE-database gap.
- π **Opt-in agentic-qe** β `ruflo-setup-aqe` fixes the same native-SQLite bug in agentic-qe, then initializes it (with half-init repair).
- π **A status-line footer** that shows π§ self-learning, π‘οΈ security, and π agentic-qe β each only when genuinely active.
- π **`ruflo-resync`** β one command to re-apply *everything* after a ruflo or agentic-qe upgrade.
- π§Ή **Clean repos & cheap sessions** β strips MCP cruft `ruflo init` would commit, pins an absolute memory path, and keeps MCP optional to save ~84k tokens/session.
- β©οΈ **Reversible** β `uninstall.sh` backs up and removes the machine-level setup; `--this-project` also reverts a repo's statusline patches.
---
## β
Prerequisites
This kit *configures and heals* ruflo β it doesn't bundle it. You need a few
things on your machine first. `install.sh` checks for these and can install the
npm packages for you (interactively, or via flags).
**Required (install.sh aborts if missing):**
| Tool | Why | Get it |
|---|---|---|
| Node.js (20β26 supported) | runtime for ruflo & the helpers | |
| npm | installs the global packages | ships with Node.js |
| `ruflo` | the orchestration toolkit this kit configures | `npm i -g ruflo` (install.sh can do this) |
**Recommended (install.sh warns, then continues):**
| Tool | Why |
|---|---|
| `claude` (Claude Code) | the agent this all runs inside |
| `sqlite3` | the status line + memory verifications read the DBs |
| `git` | to clone/update this kit |
**Optional (only for the QE fleet):**
| Tool | Why | Get it |
|---|---|---|
| `agentic-qe` (`aqe`) | the standalone quality-engineering fleet (π segment) | `npm i -g agentic-qe` (install.sh `--with-aqe`) |
> π **"Security" and "learning" are not separate installs.** `@claude-flow/security`,
> `@claude-flow/aidefence`, and the ruvector self-learning engine all ship *inside*
> ruflo β this kit *activates and verifies* them. So the "full boat" is just two
> npm packages (`ruflo` + `agentic-qe`); the kit lights up the rest.
---
## π Quick start
The fastest path β install the kit, prereqs, and heal in one go:
```bash
# 1. Get the kit
git clone https://github.com/pacphi/ruflo-machine-ref.git && cd ruflo-machine-ref
# 2. Bootstrap the machine (pick your level)
./install.sh # friendly interactive onboard (asks per step)
./install.sh --full --yes # "full boat": ruflo + agentic-qe + heal, no prompts
./install.sh --ruflo-only # just ruflo + heal
./install.sh --minimal # only lay down the kit files (you have the prereqs)
exec $SHELL # load the helper functions
# 3. In any project you work in
cd ~/my-project
ruflo-onboard # clean setup + prove self-learning persists, in one step
ruflo-onboard --aqe # β¦and also initialize the agentic-qe fleet here
```
Try `./install.sh --dry-run` first to preview exactly what it will do.
πͺ **Prefer CLI-only (no MCP, ~84k tokens saved per session)?** Skip
`ruflo-setup-machine`; the installed `~/.claude/CLAUDE.md` reference teaches
Claude Code to drive ruflo through plain Bash.
---
## π οΈ The commands
| Command | What it does |
|---|---|
| π `ruflo-resync [--aqe]` | **The one you'll use most.** After any ruflo/agentic-qe upgrade, re-applies everything the upgrade wipes: native SQLite (ruflo + agentic-qe) + self-learning assert + statusline footer. `--aqe` also refreshes QE skills. |
| π `ruflo-onboard [--with-security] [--aqe]` | **Per-repo, run from inside it.** One command: clean `setup-project` β prove learning persists β (`--aqe`) initialize agentic-qe. Prints what's active + what's next. |
| ποΈ `ruflo-setup-project [--with-security]` | Per repo: clean init, strip MCP cruft, pin an absolute DB path, native patch, activate memory/swarm/daemon, **verify a write persists**, sanitize CLAUDE.md, heal the status line. `--with-security` adds a security pass. |
| π©Ή `ruflo-patch-native [--check]` | Make ruflo's agentdb use native `better-sqlite3` on Node β₯24. |
| π§ `ruflo-enable-learning [--check]` | Activate ruvector self-learning and assert it (5 capability probes). |
| β
`ruflo-learning-verify [--keep]` | Prove the learning loop: train in an isolated dir, assert patterns persist 0 β N on disk. |
| ποΈ `ruflo-neural-train [argsβ¦]` | Wraps `ruflo neural train` in the current project and caches the MicroLoRA Ξ for the status-line SONA segment (ruflo doesn't persist it). Args pass through. |
| π‘οΈ `ruflo-security-verify [--quick]` | Verify `@claude-flow/security` + `aidefence` load, injection defense fires, scan/secrets run; flag the CVE-DB gap. |
| π `ruflo-setup-aqe [--force]` | **Opt-in.** Fix agentic-qe's native-SQLite bug, then initialize it in a repo (with half-init repair). |
| πΎ `ruflo-memory-checkpoint [db]` | Force a WAL checkpoint to recover stale memory reads. |
| π§½ `ruflo-remove-mcp` | Remove ruflo MCP from **all** scopes (recover ~84k tokens/session). |
| π `ruflo-setup-machine` | One-time: register ruflo MCP at **user** scope (all projects). Optional. |
| π `ruflo-parity-test [--cleanup]` | 20-check end-to-end memory smoke test in an isolated `/tmp` dir. |
| π `ruflo-reference-refresh [--diff\|--regenerate]` | Inspect/rebuild the machine-wide CLAUDE.md ruflo block from the template. |
---
## π§ Which command do I run?
**`install.sh` is the front door you walk through once; the functions are how you live in the house.**
| | `install.sh` | The functions |
|---|---|---|
| **Nature** | a script run *from the kit repo* | commands on your `PATH`, available everywhere after install |
| **Frequency** | once per machine (+ rarely, to re-lay the kit) | ongoing, day-to-day |
| **Scope** | machine-level bootstrap | machine-recurring **and** per-project |
On first run the functions aren't sourced yet, so `install.sh` sources them
in-process and calls the *same* `ruflo-patch-native` / `ruflo-enable-learning`
to heal β one source of truth, no drift. After that you never need `install.sh`
for healing again.
| Situation | Run this | Why not the other |
|---|---|---|
| π Brand-new machine | **`install.sh`** | nothing's on PATH yet β only the script can bootstrap |
| π Re-cloned kit / new shell / wiped `~/.local/bin` | **`install.sh`** | re-lays the kit files (idempotent, backs up) |
| β¬οΈ After `npm i -g ruflo@latest` (or aqe) | **`ruflo-resync`** | the upgrade only wiped native binaries β re-running install.sh is the heavier wrong tool |
| π Starting in a new repo | **`ruflo-onboard`** | per-project; install.sh is machine-level and won't touch your repo |
| π Routine checks | **functions** (`ruflo-parity-test`, `ruflo-learning-verify`) | no reason to re-bootstrap |
**Rule of thumb:**
- *"I'm setting up"* β `install.sh` (once).
- *"I upgraded ruflo/aqe"* β `ruflo-resync`.
- *"I'm starting work in a repo"* β `ruflo-onboard`.
---
## π The status line
When set up with this kit, a two-line footer is appended **below** ruflo's own status line. It's append-only β it never rewrites ruflo's lines, so a ruflo update can't break it. Each piece appears **only when that feature is genuinely active**:
```
β RuFlo V3.10.5 β you β β main β Opus 4.x β
ποΈ DDD Domains β¦ π€ Swarm β¦ π§ Architecture β¦ β ruflo's own lines + the kit's
π AgentDB β¦ β SONA/aidefence line (all ruflo)
π§ SONA [βββββ] 50 patterns Β· 55 traj Β· Ξ1.32 LoRA Β· β‘ HNSW π‘ aidefence on β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ β divider (matches ruflo's header rule)
π Agentic QE V3.10.1 π 23 patterns Β· π§ 114 traj Β· 𧬠543 vecβ‘ Β· πΎ 16MB
```
Every field renders only when its data is actually present (numbers above are illustrative):
- π§ **SONA** β `[bar]` is a volume gauge (~10 patterns/dot); `patterns`/`traj` from `.claude-flow/neural/stats.json`; `Ξ LoRA` is shown only after you run `ruflo-neural-train` (it caches the transient MicroLoRA delta, which ruflo doesn't persist); `β‘ HNSW` only when a vector index exists.
- π‘οΈ **aidefence on** β proactive prompt-injection/PII defense is loaded (ruflo's native line already shows the `CVE n/m` count, so this signals the *other* half).
- π **Agentic QE** β `V` is the installed `agentic-qe` package version (read from its `package.json`, mirroring `RuFlo V` in ruflo's header); `π patterns` / `π§ traj` / `𧬠vec` / `πΎ size` from a few guarded `sqlite3` reads of `.agentic-qe/memory.db` (the `vec` count comes from `qe_pattern_embeddings`, falling back to `vectors`/`embeddings` across aqe versions). The branch is already in ruflo's header line, so it's not repeated here.
---
## π Keeping it working after upgrades
Every `npm install -g ruflo@latest` (or `agentic-qe@latest`) re-resolves dependency pins, **drops the native binaries again**, and regenerates the status line β so self-learning goes dormant and the footer disappears. You don't have to remember everything an upgrade wipes:
```bash
npm install -g ruflo@latest # or agentic-qe@latest
ruflo-resync # β¨ one command heals it all
ruflo-resync --aqe # β¦and also refresh agentic-qe skills
```
---
## 𧬠Node version policy (important)
ruflo's memory & learning are healthy out of the box on **Node 22 LTS**, and need the patch on **Node 24/26**:
| Node | ABI | Stock backend | What to do |
|------|-----|---------------|------------|
| β€ 22 (LTS) | β€ 127 | β
native | nothing β `ruflo-resync` just confirms green |
| 24 | 137 | β οΈ JS fallback (loses data) | `ruflo-resync` |
| 26 | 147 | β οΈ JS fallback (loses data) | `ruflo-resync` |
The patch keys off Node's ABI, so it's safe to run on any version (it no-ops where unneeded). Prefer zero patching? Run ruflo on **Node 22 LTS**.
---
## π
Why not just the ruflo one-liner?
The popular quickstart works for an afternoon in one repo:
```bash
ruflo init --full --start-all --force && claude mcp add ruflo -- ruflo mcp start && ruflo doctor
```
β¦but it bakes in choices that don't age well across many projects and modern Node:
| Concern | The one-liner | This kit |
|---|---|---|
| π **Mindset** | Per-project, repeated every repo | Configure the machine once, reuse everywhere |
| π **`.mcp.json`** | Written with cloud-SaaS servers β easy to commit by accident | Stripped; nothing project-scoped committed unless you mean it |
| π° **Token cost** | MCP always on β ~84k tokens/session | MCP optional; CLI-first reference keeps sessions lean |
| πΎ **Memory on Node 24/26** | `doctor` says "healthy" while writes silently vanish | Native SQLite + a real storeβdisk verification |
| π§ **Self-learning** | Looks "Not loaded"; no way to tell if it works | Activated and **proven** via a train/persist test |
| β©οΈ **Reversibility** | Manual cleanup | `uninstall.sh` reverses the setup with backups (`--this-project` also reverts a repo's statusline) |
It's not a replacement for ruflo β just a thin, reversible layer that picks safe defaults and closes the gaps.
---
## π¦ What's in the box
```
ruflo-machine-ref/
βββ install.sh # machine bootstrap: prereqs + kit + heal (profiles, interactive)
βββ uninstall.sh # clean reversal (opt-in --purge for global npm packages)
βββ bin/
β βββ ruflo-patch-native # native better-sqlite3 on Node β₯24
β βββ ruflo-parity-test # 20-check end-to-end memory smoke test
β βββ ruflo-enable-learning # activate + assert ruvector self-learning
β βββ ruflo-learning-verify # prove the learning loop persists
β βββ ruflo-security-verify # verify security scan/defend/secrets + aidefence
βββ shell/
β βββ ruflo-functions.sh # ruflo-resync, ruflo-onboard, ruflo-setup-project, ruflo-setup-aqe, β¦
βββ claude/
β βββ ruflo-reference.md # the machine-wide CLAUDE.md ruflo block (CLI-first)
βββ docs/
βββ BACKGROUND.md # the full root-cause story (memory + learning + aqe + security)
βββ TROUBLESHOOTING.md # symptom β diagnosis β fix
βββ superpowers/ # the design spec + implementation plan
```
---
## ποΈ Uninstall
```bash
./uninstall.sh # kit footprint only: bin scripts, template, CLAUDE.md block, rc line
./uninstall.sh --this-project # ALSO revert the kit's statusline patches in the current repo
./uninstall.sh --remove-ruflo # ALSO npm-uninstall global ruflo (machine-wide; asks first)
./uninstall.sh --remove-aqe # ALSO npm-uninstall global agentic-qe (machine-wide; asks first)
./uninstall.sh --purge # --remove-ruflo + --remove-aqe
./uninstall.sh --dry-run # preview without changing anything
```
The plain `uninstall.sh` removes only machine-level kit setup; your ruflo
install, memory DBs, and **project files** are left untouched. The
`--remove-ruflo` / `--remove-aqe` / `--purge` flags reach the *global npm
packages* β they affect every project on the machine, so each one prompts to
confirm (pass `--yes` to skip in scripts). Add `--this-project` from a repo root
to revert that repo's statusline patches too (it backs up first and leaves all
ruflo/agentic-qe data alone β use `ruflo cleanup --force` for per-project data).
---
## π Further reading
- π [docs/BACKGROUND.md](docs/BACKGROUND.md) β the full root-cause investigation (Node/ABI/WASM, why self-learning looked dormant, the agentic-qe variant, the security surface)
- π§ [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) β symptom β diagnosis β fix runbook
- π§± [docs/superpowers/](docs/superpowers/) β the design spec and implementation plan behind the self-learning work
---
## π Credits & citations
This kit stands on the shoulders of several projects and people:
- π§ **ruflo** (a.k.a. claude-flow) by ruvnet β the orchestration toolkit this kit configures:
- π **agentic-qe** by *proffesor-for-testing* β the standalone quality-engineering fleet:
- π **Ciprian Melian's setup-and-repair gist** β prior art that paired ruflo with agentic-qe and inspired this kit's direction:
- π **Upstream tracking issue** for the memory/Node bug family: [ruvnet/ruflo#2219](https://github.com/ruvnet/ruflo/issues/2219)
- ποΈ **better-sqlite3** β the native SQLite binding at the heart of the fix:
- π€ **Claude Code** by Anthropic β the agent this all runs inside:
> Target: macOS / Linux Β· zsh or bash Β· ruflo 3.10.x Β· Node 20β26 Β· Python 3.10+.
> A thin, reversible layer β not a fork. PRs and issues welcome.