Skip to content

Instantly share code, notes, and snippets.

@ruvnet
Last active July 5, 2026 17:33
Show Gist options
  • Select an option

  • Save ruvnet/d9c7611170025156baad38de3ddec878 to your computer and use it in GitHub Desktop.

Select an option

Save ruvnet/d9c7611170025156baad38de3ddec878 to your computer and use it in GitHub Desktop.
ruflo 3.25.0 — Lattice WASM embedder tier: real multi-model embeddings, fail-closed, usage & upgrade notes

⚠️ CORRECTION (important)

There is no @ruvector/lattice-wasm package — it 404s on npm, and no "Lattice" embedder package exists in the ruvector ecosystem. The models below (bge / qwen3-0.6b / paraphrase-miniLM) exist only in a Rust ONNX example, not a publishable package. What actually shipped in 3.25.0 is a fail-closed, optional adapter seam that degrades to ruvector-ONNX → hash when the (nonexistent) package is absent — so it is DORMANT / no-op today and causes no regression, but it is NOT a working multi-model embedder. The rest of this document describes the intended design; treat it as a proposal for a real embedder, not a shipped capability. Follow-up: remove the seam or wire it to a real embedder.


ruflo — Lattice WASM Embedder Tier (3.25.0)

TL;DR — ruflo now supports a real, multi-model WASM embedder as the primary embedding tier, ahead of the existing ONNX/hash path. It's optional, fail-closed, and zero-regression: if the package isn't installed, embeddings resolve exactly as before. When it is present, retrieval runs on better/more embedding models (miniLM, bge, multi-paraphrase-miniLM, GPU qwen3-0.6b).


1. Why — the substrate problem

The self-learning flywheel tunes the retrieval policy, but a policy is only as good as the vectors underneath it. Auditing ruflo's embedding substrate showed a split:

Path Reality
neural_patterns / memory search (ruvector) Real ONNX all‑MiniLM‑L6‑v2 (384‑dim) when ruvector loads
Fallback when ruvector/ONNX unavailable hash placeholder (deterministic, semantically meaningless)
Native‑rust ruvllm memory, memory controller, ruview text hash placeholders

On a hash‑fallback install, cosine similarity is noise — so "semantic" retrieval (and anything the flywheel optimizes over it) is limited there. The fix: put a real, multi‑model embedder in front of everything, without making it a hard dependency.

Note: the flywheel's shipped results (RR 0.496→0.758→0.847, the +0.0738 mint) were all measured on the real ONNX path (_realEmbedding: true), so those stand. This work raises the floor (real embeddings where there were placeholders) and the ceiling (models better than miniLM).


2. What shipped in 3.25.0

(a) Primary tier — done + verified. @ruvector/ruvllm-wasm‑style optional WASM adapter (src/ruvector/lattice-wasm.ts) wired as Tier ‑1 in neural_patterns' ensureEmbeddings(), ahead of ruvector‑ONNX → hash.

(b) Hash placeholders — partial. The primary memory/retrieval + memory-bridge paths route through generateEmbedding(), so they get Lattice‑first automatically. Converging the remaining native‑rust ruvllm / memory‑controller / ruview stub sites is a scoped follow‑up.

(c) Model selection — scaffolded. The adapter is model‑parameterized and env‑selectable now; adding embedding‑model as a flywheel axis is a follow‑up gated on a multi‑model backend being installed to benchmark against.


3. How it works (technical)

Tier order (first available wins):

Tier -1  Lattice WASM        ← NEW primary: miniLM / bge / paraphrase-miniLM / qwen3-0.6b
Tier  0  ruvector ONNX       (bundled all-MiniLM-L6-v2)
Tier 1-3 agentic-flow / @claude-flow/embeddings
Fallback hash               (deterministic, non-semantic)

Fail-closed by construction:

  • The package is loaded via a dynamic import that catches — absent ⇒ null ⇒ tier skipped.
  • WASM init (initSync({module: bytes}), ruvnet convention) is wrapped — init failure ⇒ tier skipped.
  • The API is probed tolerantly across plausible wasm-bindgen surfaces (embed(text, model), embed(text), embedText, new Embedder(model).embed) — an unexpected shape ⇒ tier skipped.
  • A real-embed verification probe runs before the tier is accepted (guards the "type-loads-but-runtime-fails" trap) — probe fails ⇒ tier skipped.
  • If any of these skip, callers fall straight through to ruvector-ONNX → hash. Zero regression.

Verified with the package absent:

latticeAvailable() → false
latticeEmbed('...') → null
neural_patterns embeddingProvider → ruvector@0.2.27 (bundled all-MiniLM-L6-v2), _realEmbedding: true

4. Usage

Env var Effect Default
RUFLO_LATTICE_WASM_PKG Package specifier for the Lattice WASM module @ruvector/lattice-wasm
RUFLO_EMBED_MODEL Which model to use minilm
# Upgrade
npx ruflo@latest        # or npx ruflo@3.25.0

# Once the Lattice WASM package is installed, it becomes the primary tier
# automatically. Select a model:
export RUFLO_EMBED_MODEL=bge          # or paraphrase-minilm, qwen3-0.6b
# Point at a differently-named/located package if needed:
export RUFLO_LATTICE_WASM_PKG=@ruvector/lattice-wasm
  • qwen3-0.6b (GPU) is opt-in — selected only when explicitly requested.
  • No action needed to stay safe: absent the package, behavior is unchanged.

5. Upgrade notes

  • Additive · backwards-compatible · fail-closed. No breaking changes; embeddings degrade to today's path when Lattice is absent.
  • @ruvector/lattice-wasm is NOT a hard dependency — it's an optional runtime dynamic import (never added to package.json), so installs never break if it's unavailable.
  • Signing keys unchanged.

6. Open — needs confirmation

To guarantee activation (rather than tolerant probing), confirm:

  1. the exact published package name (set RUFLO_LATTICE_WASM_PKG or pin it),
  2. the embed export signature (name + (text, model) → vector shape), and
  3. whether qwen3-0.6b requires a GPU at runtime or degrades.

With those, the follow-ups finalize: converge the remaining ruvllm/controller/ruview stubs onto the shared chain, and wire embedding-model as a real flywheel dimension (optimized against the frozen human eval + self-supervised held-out).

Packages: @claude-flow/cli@3.25.0, claude-flow@3.25.0, ruflo@3.25.0 Release: https://github.com/ruvnet/ruflo/releases/tag/v3.25.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment