Skip to content

fix(mcp): rvlite tools now use ESM dynamic import for v0.2.x compatibility#306

Open
luminexo wants to merge 2374 commits intoruvnet:mainfrom
luminexo:fix/mcp-rvlite-esm-import
Open

fix(mcp): rvlite tools now use ESM dynamic import for v0.2.x compatibility#306
luminexo wants to merge 2374 commits intoruvnet:mainfrom
luminexo:fix/mcp-rvlite-esm-import

Conversation

@luminexo
Copy link
Copy Markdown

Summary

Fixes #302

The MCP server tools rvlite_sql, rvlite_cypher, and rvlite_sparql were failing with "rvlite package not installed" because they used CJS require('rvlite') on an ESM-only package (v0.2.x).

Root Cause

  • rvlite v0.2.x removed CJS entry point
  • require('rvlite') returns empty object {}
  • MCP tools checked for rvlite.CypherEngine, found undefined, and reported "not installed"

Fix

  • Changed from CJS require() to ESM dynamic import('rvlite/wasm')
  • Added proper WASM initialization via initSync() with buffer
  • Added engine caching to avoid re-initializing on every call
  • Added helpful error messages for ESM-related failures

Testing

The fix follows the same pattern used in the issue report's workaround:

// Before (broken)
const rvlite = require('rvlite');  // → {} (empty object)
const db = new rvlite.Database();  // → TypeError

// After (fixed)
const rvlite = await import('rvlite/wasm');
const { readFileSync } = await import('fs');
rvlite.initSync(readFileSync('node_modules/rvlite/dist/wasm/rvlite_bg.wasm'));
const db = new rvlite.Database();  // → Works!

Files Changed

  • npm/packages/ruvector/bin/mcp-server.js — Updated rvlite_sql, rvlite_cypher, rvlite_sparql handlers

Impact

  • All rvlite_* MCP tools will now work correctly with rvlite v0.2.x
  • Backward compatible with future versions that may restore CJS support
  • No changes to external API — tools return same JSON format

ruvnet and others added 30 commits March 8, 2026 16:17
Adds browser WASM bindings for neural-trader-core, coherence, and replay
crates using the established wasm-bindgen pattern. Includes BigInt-safe
serialization, hex ID helpers, 10 unit tests, 43 Node.js smoke tests,
comprehensive README, and animated dot-matrix visuals for π.ruv.io.

Co-Authored-By: claude-flow <ruv@ruv.net>
feat: neural trader — market graph types, MinCut coherence gate, reservoir replay
  Built from commit fb510ae

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Defines a cognition kernel for the Agentic Age with 6 primitives
(task, capability, region, queue, timer, proof), 12 syscalls, and
RVF as the native boot object. Includes coherence-aware scheduler,
proof-gated mutation as kernel invariant, seL4-inspired capabilities,
io_uring-style queue IPC, 8 demo applications, and a two-phase build
path (Linux-hosted nucleus → bare metal AArch64).

Co-Authored-By: claude-flow <ruv@ruv.net>
feat: ADR-087 RuVix Cognition Kernel
Adds Section 20 (Security Hardening Notes) addressing: root task
privilege attenuation post-boot, capability delegation depth limits,
boot RVF proof bootstrap resolution, Reflex proof cache scoping,
zero-copy IPC TOCTOU mitigation, and boot signature failure behavior.
All findings are specification clarifications, not structural flaws.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit a962506

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 7c0a8db

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…ettings (ruvnet#250)

Stop writing empty mcpServers: {} to settings.json which could trigger
Claude Code to regenerate .mcp.json, stripping user-added fields like
autoStart. Doctor --fix now cleans up stale empty mcpServers entries.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 28f8e1e

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Add remote MCP SSE connection instructions to the Guide modal (MCP tab)
and the main page terminal section. Users can now connect via
`claude mcp add pi-brain --transport sse https://pi.ruv.io/sse`
without any local install.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 4be2bbc

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Restructure Guide modal MCP tab to lead with SSE (one command, no
install) and demote npx/Cargo to an optional "Local install" step.
Update main page terminal section to show SSE first.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit d253b15

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
CreatePageRequest previously required embedding and witness_hash
fields, causing 422 errors when clients (including MCP SSE) omitted
them. Now matches ShareRequest behavior: #[serde(default)] on
embedding, witness_hash, tags, and evidence_links. Server
auto-generates 128-dim embedding via ruvllm and SHAKE-256 witness
hash when not provided.

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 3f46761

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
ruvnet#252)

* feat: add CNN contrastive learning crate with SIMD optimization

- Add ruvector-cnn crate with SIMD-optimized convolutions and contrastive losses
- Implement InfoNCE (SimCLR) and TripletLoss for contrastive learning
- Add MobileNet-V3 inspired backbone architecture
- Include AVX2, NEON, WASM SIMD support with scalar fallback
- Add WASM bindings (ruvector-cnn-wasm) for browser/Node.js
- Add npm package with TypeScript definitions
- Include comprehensive research docs and ADR-088
- 36 tests passing

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat: add npm package JavaScript wrapper and TypeScript definitions

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(ruvector-cnn): implement real SIMD and fix stubbed code

## SIMD Implementations (was using scalar fallbacks)
- AVX2: conv_3x3_avx2, conv_3x3_avx2_fma, depthwise_conv_3x3_avx2
- AVX2: global_avg_pool_avx2, max_pool_2x2_avx2
- WASM: conv_3x3_wasm, depthwise_conv_3x3_wasm

All now use real SIMD intrinsics processing 8 (AVX2) or 4 (WASM)
channels simultaneously with scalar fallback for remainders.

## Backbone Fixes
- Deprecated MobileNetV3Small/Large (use unified MobileNetV3 instead)
- Implemented actual block processing in forward() methods
- Fixed hardcoded channel counts in global_avg_pool calls

## Dead Code Fixes
- Added #[allow(dead_code)] for momentum field (used in training)
- Added #[allow(dead_code)] for rng field (feature-gated)
- Added #[cfg(feature = "augmentation")] for rand::Rng import
- Commented out undefined "parallel" feature reference

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(ruvector-cnn): add Winograd F(2,3) and π-calibrated INT8 quantization

- Add Winograd F(2,3) transforms for 2.25x faster 3x3 convolutions
- Implement π-calibrated INT8 quantization with anti-resonance offsets
- Apply 4x loop unrolling with 4 accumulators to AVX2 convolutions
- Update README with practical intro, capabilities table, benchmarks
- Update npm README with simpler language and examples
- Add CNN image embeddings to root README capabilities

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat: publish @ruvector/cnn v0.1.0 WASM npm package

- Add unsafe blocks for WASM SIMD intrinsics (v128_load/v128_store)
- Disable wasm-opt to avoid SIMD validation issues
- Build and include WASM bindings in npm package
- Update npm package.json with all WASM files
- Published to npm as @ruvector/cnn@0.1.0

Co-Authored-By: claude-flow <ruv@ruv.net>

---------

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
  Built from commit d172324

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
- Single-file HTML demo with modern dark theme UI
- Drag & drop image upload + camera capture
- Real-time embedding extraction and visualization
- Similarity matrix comparing multiple images
- Performance metrics display (~5ms per image)
- Falls back to demo mode if WASM fails to load
- ADR-089 documenting the approach

Deploy to: https://ruvnet.github.io/ruvector/demo/cnn/

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
Co-Authored-By: claude-flow <ruv@ruv.net>
Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 91a55d2

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 864b02e

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
- Use object format for init: { module_or_path: url }
- Use WasmCnnEmbedder (not CnnEmbedder)
- Use snake_case methods: embedding_dim, cosine_similarity

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit c4e8469

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
- Host ruvector_cnn_wasm.js and .wasm in docs/cnn/
- Add detailed console.log for debugging WASM init
- Remove CDN dependency for reliability

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 457a4bc

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
- Real-time embedding extraction at ~30+ FPS
- Live FPS and latency display
- Reference image comparison with similarity score
- Live embedding visualization
- Center-crop to square for consistent input

Co-Authored-By: claude-flow <ruv@ruv.net>
  Built from commit 42522e2

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
ruvnet and others added 29 commits March 24, 2026 22:37
Wire pi@ruv.io as the brain's email identity via Resend.com for
notifications, discovery digests, and conversational interaction.

- Add src/notify.rs: Resend HTTP client with 11 rate-limited categories,
  styled HTML templates, open tracking pixel, and unsubscribe links
- Add 8 new routes: test, status, send, welcome, help, digest, pixel, opens
- All /v1/notify/* endpoints gated by BRAIN_SYSTEM_KEY auth
- Cloud Scheduler job brain-daily-digest at 8 AM PT for discovery emails
- RESEND_API_KEY secret mounted on Cloud Run (ruvbrain-00133-r2t)
- 4 test emails verified delivered to ruv@ruv.net

Co-Authored-By: claude-flow <ruv@ruv.net>
- Add Email tab to Encyclopedia Galactica modal with subscribe form
- Add email subscription CTA in "Ready to connect" section
- Add Subscribe link in footer navigation
- Add POST /v1/notify/subscribe (public) — sends welcome email
- Add POST /v1/notify/unsubscribe (public) — handles opt-out
- Mark inbound email commands as "coming soon" (Resend webhooks TBD)
- Add subscribeEmail() JS with fallback to mailto

Co-Authored-By: claude-flow <ruv@ruv.net>
- Add POST /v1/email/inbound webhook handler for Resend inbound emails
- Parse email subjects for commands: search, status, help, drift, etc
- Semantic search via email: reply with "search <query>" to get results
- Remove "coming soon" label from email commands on website
- MX record updated: ruv.io -> inbound-smtp.resend.com (priority 10)
- Webhook registered: pi.ruv.io/v1/email/inbound (ID: 55c6592c)
- Old GoDaddy MX records removed from Cloudflare

Co-Authored-By: claude-flow <ruv@ruv.net>
- Add POST /v1/chat/google endpoint for Google Chat webhook
- Handle ADDED_TO_SPACE (welcome), MESSAGE (commands), REMOVED_FROM_SPACE
- Commands: search, status, drift, recent, help + free-text auto-search
- Rich Cards V2 responses with header, key-value widgets, and links
- Service account pi-brain-chat created with Cloud Run invoker role
- ADR-126 documents architecture, marketplace config, deployment steps

Co-Authored-By: claude-flow <ruv@ruv.net>
- Add 'text' field to all Chat card responses (required for HTTP endpoint mode)
- Parse Chat events from raw bytes for resilience against unknown fields
- Log raw payload on parse failure for debugging
- Return helpful fallback text on malformed events

Co-Authored-By: claude-flow <ruv@ruv.net>
Implement data-oblivious KV cache and embedding compression based on
TurboQuant (ICLR 2026). Two-stage pipeline: PolarQuant (Hadamard
rotation + scalar quantization) + QJL residual correction (1-bit),
achieving ~3.5 bits per value with geometry-preserving compression.

New modules:
- turbo_quant.rs: Core TurboQuantCompressor with compress/decompress,
  TurboQuantCacheTier for KV cache, TurboQuantEmbeddingStore for
  RuVector integration, asymmetric inner product for attention
- TurboQuantKvCache: Three-tier cache (FP16 hot + TurboQuant cold)
  integrated into kv_cache.rs with auto-migration

Key features:
- 2.5/3.0/3.5/4.0 bit configurations with QJL residual toggle
- ~6x memory reduction on cold tier, preserves inner product geometry
- Bitstream packing handles non-byte-aligned bit widths
- Embedding store with batch build, search, and nearest-neighbor
- 13 passing tests covering roundtrip, compression, inner products,
  batch ops, KV cache tier, eviction, and embedding search

https://claude.ai/code/session_011ogX2uc7Zf8d8aQ3UAbNcd
Comprehensive research document covering TurboQuant (ICLR 2026) and its
mapping to ruvLLM. Covers algorithm details, performance results,
integration architecture, PiQ3 comparison, risks/mitigations, and
implementation summary.

https://claude.ai/code/session_011ogX2uc7Zf8d8aQ3UAbNcd
…c reasoning

Add autonomous Gist publishing for novel discoveries with novelty gates,
enhanced cognitive tick loop (60s lightweight + 5min full cycle), expanded
symbolic reasoning with cross-domain inference, and dashboard UI improvements.

Co-Authored-By: claude-flow <ruv@ruv.net>
…egration

feat(brain): Resend email integration with pixel tracking
  Built from commit cd96526

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
Resolve Code Quality CI failure by applying cargo fmt.

Co-Authored-By: claude-flow <ruv@ruv.net>
…benchmarks

- Add rotated-domain inner product (skip inverse Hadamard via orthogonal
  invariance: <Hq,Hk> = <q,k>), ~2x faster for attention computation
- Add batch-optimized variant that rotates query once across all keys
- Add Criterion benchmark suite: compression, decompression, inner product,
  KV cache ops, embedding store, dimension scaling, memory efficiency
- 5 new tests verifying optimized methods match original results
- All 18 TurboQuant tests passing

Co-Authored-By: claude-flow <ruv@ruv.net>
…P3oo2

feat(ruvllm): TurboQuant KV cache & vector compression
  Built from commit 7acf180

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…y gates

Problems fixed:
- Every gist was "X shows weak co-occurrence with Y (confidence: 50%)"
- Same generic cluster labels (debug, architecture, geopolitics) recycled
- Novelty thresholds too low (2 inferences, 100 evidence, 0.008 strange loop)
- Rate limit too permissive (4 hours = 6 gists/day of noise)
- No content-level dedup

Changes:
- Raise novelty thresholds: 5 inferences, 500 evidence, 0.05 strange loop
- Add MIN_INFERENCE_CONFIDENCE (60%) — filter out weak signals before publishing
- Add strong_inferences() / strong_propositions() quality filters
- Raise cross-domain similarity threshold from 0.3 to 0.45 at source
- Raise predicate thresholds (may_influence: 0.75, associated_with: 0.55)
- Rate limit: 24 hours between gists (was 4 hours)
- Content-based dedup (category + dominant inference, not just title)
- 3-pass research loop: (1) Gemini grounded research on topics,
  (2) brain memory search for internal context, (3) Gemini synthesis
- Deleted all 45 old repetitive gists

Co-Authored-By: claude-flow <ruv@ruv.net>
Co-Authored-By: claude-flow <ruv@ruv.net>
Google Workspace Add-ons expect responses wrapped in:
  { "hostAppDataAction": { "chatDataActionMarkup": { "createMessageAction": { "message": {...} } } } }

Returning a raw Message object causes Google Chat to show "not responding"
even though the HTTP status is 200. The endpoint was receiving requests
correctly (confirmed via Cloud Run logs) but responses were being silently
dropped by the Add-ons framework.

Ref: https://developers.google.com/workspace/add-ons/chat/build

Co-Authored-By: claude-flow <ruv@ruv.net>
Revert DataActions wrapper — HTTP endpoint Chat apps should return
plain Message objects. Added raw payload logging to debug why Google
Chat shows "not responding" despite 200 OK responses.

Co-Authored-By: claude-flow <ruv@ruv.net>
The correct Add-ons envelope uses `chatDataAction` (NOT `chatDataActionMarkup`):
  { "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }

Previous attempts:
1. Plain Message → 200 OK but "not responding" (wrong format for Add-ons)
2. chatDataActionMarkup → 200 OK but "not responding" (wrong field name)
3. chatDataAction → this should work per quickstart-http docs

Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http

Co-Authored-By: claude-flow <ruv@ruv.net>
Google Workspace Add-ons wrap the Chat event differently than legacy Chat API:
- Add-on: { "chat": { "messagePayload": { "message": {...} } } }
- Legacy: { "type": "MESSAGE", "message": {...} }

The handler now detects which format is used and parses accordingly.
Also handles appCommandPayload for slash commands.

Response uses confirmed correct format:
  { "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }

Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http

Co-Authored-By: claude-flow <ruv@ruv.net>
Replace raw search fallback with Gemini Flash + Google Grounding for
non-command messages. Gemini receives:
- Brain context (memory count, edges, drift)
- Semantic search results from the query
- Recent brain activity
- Google Search grounding for real-world context

Synthesizes conversational HTML responses for Google Chat cards.
Falls back to raw search if Gemini is unavailable.
25s timeout to stay within Chat's 30s limit.

Slash commands (status, drift, search, recent, help) still use
direct handlers for instant response.

Co-Authored-By: claude-flow <ruv@ruv.net>
…ions

- Expand search context from 300 to 600 chars per memory
- Include tags in search results
- Directive prompt: speak as the brain, cite memories by title,
  synthesize across results, add Google Search context
- Increase max output from 1024 to 2048 tokens
- Increase truncation limit from 1500 to 3000 chars
- Add "Ask me about..." follow-up suggestions
- Temperature 0.4 → 0.5 for more engaging responses

Co-Authored-By: claude-flow <ruv@ruv.net>
Problem: gists still publishing recycled "X associated_with Y" noise.

Threshold changes:
- MIN_NEW_INFERENCES: 5 → 10
- MIN_EVIDENCE: 500 → 1000
- MIN_STRANGE_LOOP_SCORE: 0.05 → 0.1
- MIN_PROPOSITIONS: 10 → 20
- MIN_SONA_PATTERNS: 0 → 1 (require SONA learning)
- MIN_PARETO_GROWTH: 2 → 3
- MIN_INFERENCE_CONFIDENCE: 0.60 → 0.70
- New: MIN_UNIQUE_CATEGORIES = 4 (prevent recycling same domains)
- Rate limit: 24h → 72h (3 days between gists)
- Cross-domain similarity: 0.45 → 0.55

Quality filters:
- Reject ALL "may be associated with", "co-occurs with", "similar_to"
- Reject inferences < 50 chars
- Require 3+ strong inferences, 5+ strong propositions, 4+ unique categories
- Kill co_occurs_with and similar_to entirely from publishable set

Target: ~1 gist per week, only for genuinely novel cross-domain discoveries.

Co-Authored-By: claude-flow <ruv@ruv.net>
Previous categories (architecture, pattern, solution, convention, security,
performance, tooling, debug) were too generic — every discovery was just
"debug associated_with architecture" noise.

New categories span practical to exotic:
- Research: sota, discovery, hypothesis, cross_domain
- AI/ML: neural_architecture, compression, self_learning, reinforcement_learning, graph_intelligence
- Systems: distributed_systems, edge_computing, hardware_acceleration
- Frontier: quantum, neuromorphic, bio_computing, cognitive_science, formal_methods
- Applied: geopolitics, climate, biomedical, space, finance
- Meta: meta_cognition, benchmark

Backward compatible — serde snake_case, existing memories still deserialize.
Custom(String) still accepted for any unlisted category.

Co-Authored-By: claude-flow <ruv@ruv.net>
fix(brain): overhaul gist quality — 3-pass research loop, strict novelty gates
  Built from commit e5eb8cc

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
  Built from commit 762cb59

  Platforms updated:
  - linux-x64-gnu
  - linux-arm64-gnu
  - darwin-x64
  - darwin-arm64
  - win32-x64-msvc

  🤖 Generated by GitHub Actions
…ility

Issue: ruvnet#302

- Changed from CJS require('rvlite') to ESM dynamic import('rvlite/wasm')
- Added initSync() with WASM buffer for proper initialization
- Added engine caching to avoid re-initializing on every call
- Added helpful error messages for ESM-related failures

The rvlite package v0.2.x is ESM-only. The previous CJS require()
returned an empty object, causing all rvlite_sql, rvlite_cypher,
and rvlite_sparql tools to fail with 'package not installed' errors.

With this fix, the MCP server correctly loads the ESM module and
initializes the WASM binary for Node.js environments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mcp): rvlite_cypher tool reports 'not installed' — CJS require() on ESM-only package

3 participants