Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUva69e3133d3a4
diff --git a/v3/@claude-flow/embeddings/__tests__/core.test.ts b/v3/@claude-flow/embeddings/__tests__/core.test.ts
new file mode 100644
index 0000000000..797295beda
--- /dev/null
+++ b/v3/@claude-flow/embeddings/__tests__/core.test.ts
@@ -0,0 +1,68 @@
+/**
+ * Core utility tests for @claude-flow/embeddings
+ * Tests chunking, normalization, and hyperbolic without heavy deps
+ */
+
+import { describe, it, expect } from 'vitest';
+
+// Import only lightweight utilities - not embedding-service
+import {
+ chunkText,
+ estimateTokens,
+} from '../src/chunking.js';
+
+import {
+ l2Normalize,
+ l2Norm,
+ isNormalized,
+} from '../src/normalization.js';
+
+import {
+ euclideanToPoincare,
+ isInPoincareBall,
+} from '../src/hyperbolic.js';
+
+describe('Chunking', () => {
+ it('chunks text into multiple parts', () => {
+ const text = 'Hello world. This is a test. Another sentence here.';
+ const result = chunkText(text, { maxChunkSize: 30, strategy: 'character' });
+ expect(result.totalChunks).toBeGreaterThan(1);
+ });
+
+ it('estimates tokens correctly', () => {
+ expect(estimateTokens('Hello world')).toBe(3);
+ });
+
+ it('returns original text for short input', () => {
+ const result = chunkText('Short', { maxChunkSize: 100 });
+ expect(result.totalChunks).toBe(1);
+ });
+});
+
+describe('Normalization', () => {
+ it('L2 normalize creates unit vector', () => {
+ const vec = new Float32Array([3, 4, 0]);
+ const normalized = l2Normalize(vec);
+ expect(l2Norm(normalized)).toBeCloseTo(1, 5);
+ });
+
+ it('isNormalized detects normalized vectors', () => {
+ const vec = new Float32Array([3, 4, 0]);
+ expect(isNormalized(vec)).toBe(false);
+ expect(isNormalized(l2Normalize(vec))).toBe(true);
+ });
+});
+
+describe('Hyperbolic', () => {
+ it('euclideanToPoincare stays in ball', () => {
+ const vec = new Float32Array([0.5, 0.3, 0.2]);
+ const poincare = euclideanToPoincare(vec);
+ expect(isInPoincareBall(poincare)).toBe(true);
+ });
+
+ it('origin maps to origin', () => {
+ const origin = new Float32Array([0, 0, 0]);
+ const poincare = euclideanToPoincare(origin);
+ expect(Array.from(poincare).every(v => Math.abs(v) < 1e-10)).toBe(true);
+ });
+});