mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
PATCH per semver — pure bug fixes, no API changes. Fixes: #2432 — Unbounded sql.js MEMFS leak (~36 GB observed in production) Root cause: ControllerRegistry.initController() called controllers.set(name, ...) without closing the prior instance. SqlJsRvfBackend wrappers held an Emscripten MEMFS file (~11 MB each = sizeof memory.db) that only releases on explicit .close() — JS GC of the wrapper does NOT reclaim MEMFS because the sql.js module is a process singleton. Fix: added closePriorIfAny(name) helper, called before every controllers.set() site in v3/@claude-flow/memory/src/controller-registry.ts. Best-effort close (catches errors so replacement always proceeds). #2431 — graph-edge-writer.ts dual-write corrupts memory.db (ADR-130 regression) Root cause: sql.js opened memory.db, did in-memory writes, then called fs.writeFileSync(dbPath, db.export()) after every edge insert. This whole-file flush overwrote memory.db while the better-sqlite3 bridge was writing through its WAL — exactly the dual-write race that ADR-068 (#1257) removed. Symptom: PRAGMA integrity_check reports "database disk image is malformed (11)" after a single memory_store + causal-edge sequence. Fix: ported v3/@claude-flow/cli/src/memory/graph-edge-writer.ts from sql.js to better-sqlite3 + WAL mode. Same native engine as the bridge, no whole-file fsync, no race. Public API unchanged. Smoke-tested: 50 concurrent insertGraphEdge() calls + PRAGMA integrity_check → ok. Note: this is the minimum-safe fix. The architecturally cleaner fix (route edge writes through the bridge's controller layer per ADR-068) is deferred to a future ADR. The current fix removes the race by ensuring both writers share the same WAL-coordinated SQLite engine. Version bumps: - @claude-flow/memory 3.0.0-alpha.20 → 3.0.0-alpha.21 - @claude-flow/cli 3.13.0 → 3.13.1 (pins memory ^3.0.0-alpha.21) - claude-flow umbrella 3.13.0 → 3.13.1 - ruflo wrapper 3.13.0 → 3.13.1 Published to npm with all three dist-tags (latest, alpha, v3alpha) for each of the four packages. Verified post-publish: every package × every tag = 3.13.1 (memory at alpha.21). Co-Authored-By: RuFlo <ruv@ruv.net>