Files
ruvnet--ruflo/v3/implementation/adrs/ADR-041-hyperbolic-reasoning-plugin.md
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

19 KiB

ADR-041: Hyperbolic Reasoning Plugin

Status: Proposed Date: 2026-01-24 Category: Exotic SOTA Author: Plugin Architecture Team Version: 1.0.0 Deciders: Plugin Architecture Team, Geometric ML Research Team Supersedes: None

Context

Many real-world data structures exhibit hierarchical properties: file systems, organizational charts, taxonomies, dependency trees, and concept hierarchies. Traditional Euclidean embeddings struggle to represent these structures efficiently, requiring exponentially more dimensions. Hyperbolic geometry, with its natural tree-like structure, can represent hierarchies with logarithmic distortion using far fewer dimensions.

Decision

Create a Hyperbolic Reasoning Plugin that leverages RuVector's hyperbolic WASM packages to provide superior hierarchical reasoning, taxonomy navigation, and semantic relationship modeling through Poincare ball and Lorentz model embeddings.

Plugin Name

@claude-flow/plugin-hyperbolic-reasoning

Description

An exotic reasoning plugin implementing hyperbolic neural networks for superior hierarchical understanding. The plugin enables efficient representation of tree structures, taxonomic reasoning, and hierarchical entailment using Poincare ball embeddings with Mobius operations. Applications include improved ontology navigation, hierarchical code understanding, and organizational relationship modeling.

Key WASM Packages

Package Purpose
ruvector-hyperbolic-hnsw-wasm Hyperbolic nearest neighbor search
ruvector-attention-wasm Hyperbolic attention mechanisms
ruvector-gnn-wasm Hyperbolic graph neural networks
micro-hnsw-wasm Tangent space approximation search
sona Adaptive curvature learning

MCP Tools

1. hyperbolic/embed-hierarchy

Embed hierarchical data in hyperbolic space.

{
  name: 'hyperbolic/embed-hierarchy',
  description: 'Embed hierarchical structure in Poincare ball',
  inputSchema: {
    type: 'object',
    properties: {
      hierarchy: {
        type: 'object',
        description: 'Tree structure to embed',
        properties: {
          nodes: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                id: { type: 'string' },
                parent: { type: 'string' },
                features: { type: 'object' }
              }
            }
          },
          edges: { type: 'array', items: { type: 'object' } }
        }
      },
      model: {
        type: 'string',
        enum: ['poincare_ball', 'lorentz', 'klein', 'half_plane'],
        default: 'poincare_ball'
      },
      parameters: {
        type: 'object',
        properties: {
          dimensions: { type: 'number', default: 32 },
          curvature: { type: 'number', default: -1.0 },
          learnCurvature: { type: 'boolean', default: true }
        }
      }
    },
    required: ['hierarchy']
  }
}

2. hyperbolic/taxonomic-reason

Perform taxonomic reasoning in hyperbolic space.

{
  name: 'hyperbolic/taxonomic-reason',
  description: 'Taxonomic reasoning using hyperbolic entailment',
  inputSchema: {
    type: 'object',
    properties: {
      query: {
        type: 'object',
        properties: {
          type: {
            type: 'string',
            enum: ['is_a', 'subsumption', 'lowest_common_ancestor', 'path', 'similarity']
          },
          subject: { type: 'string' },
          object: { type: 'string' }
        }
      },
      taxonomy: { type: 'string', description: 'Taxonomy identifier' },
      inference: {
        type: 'object',
        properties: {
          transitive: { type: 'boolean', default: true },
          fuzzy: { type: 'boolean', default: false },
          confidence: { type: 'number', default: 0.8 }
        }
      }
    },
    required: ['query']
  }
}

Hierarchically-aware semantic search.

{
  name: 'hyperbolic/semantic-search',
  description: 'Semantic search with hierarchical awareness',
  inputSchema: {
    type: 'object',
    properties: {
      query: { type: 'string' },
      index: { type: 'string', description: 'Hyperbolic index identifier' },
      searchMode: {
        type: 'string',
        enum: ['nearest', 'subtree', 'ancestors', 'siblings', 'cone'],
        default: 'nearest'
      },
      constraints: {
        type: 'object',
        properties: {
          maxDepth: { type: 'number' },
          minDepth: { type: 'number' },
          subtreeRoot: { type: 'string' }
        }
      },
      topK: { type: 'number', default: 10 }
    },
    required: ['query', 'index']
  }
}

4. hyperbolic/hierarchy-compare

Compare hierarchical structures using hyperbolic alignment.

{
  name: 'hyperbolic/hierarchy-compare',
  description: 'Compare hierarchies using hyperbolic alignment',
  inputSchema: {
    type: 'object',
    properties: {
      source: { type: 'object', description: 'First hierarchy' },
      target: { type: 'object', description: 'Second hierarchy' },
      alignment: {
        type: 'string',
        enum: ['wasserstein', 'gromov_wasserstein', 'tree_edit', 'subtree_isomorphism'],
        default: 'gromov_wasserstein'
      },
      metrics: {
        type: 'array',
        items: {
          type: 'string',
          enum: ['structural_similarity', 'semantic_similarity', 'coverage', 'precision']
        }
      }
    },
    required: ['source', 'target']
  }
}

5. hyperbolic/entailment-graph

Build and query entailment graphs.

{
  name: 'hyperbolic/entailment-graph',
  description: 'Build entailment graph using hyperbolic embeddings',
  inputSchema: {
    type: 'object',
    properties: {
      action: {
        type: 'string',
        enum: ['build', 'query', 'expand', 'prune']
      },
      concepts: {
        type: 'array',
        items: {
          type: 'object',
          properties: {
            id: { type: 'string' },
            text: { type: 'string' },
            type: { type: 'string' }
          }
        }
      },
      entailmentThreshold: { type: 'number', default: 0.7 },
      transitiveClosure: { type: 'boolean', default: true },
      pruneStrategy: {
        type: 'string',
        enum: ['none', 'transitive_reduction', 'confidence_threshold']
      }
    },
    required: ['action']
  }
}

Use Cases

  1. Ontology Navigation: Efficiently traverse and query large knowledge graphs
  2. Code Hierarchy Understanding: Model inheritance, module structure, and dependencies
  3. Organizational Analysis: Understand reporting structures and influence networks
  4. Taxonomic Classification: Improved classification with hierarchical awareness
  5. Concept Entailment: Determine semantic relationships between concepts

Architecture

+------------------+     +----------------------+     +------------------+
| Hierarchical     |---->| Hyperbolic Engine    |---->| Reasoning        |
| Data Input       |     | (Poincare Ball)      |     | Results          |
+------------------+     +----------------------+     +------------------+
                                   |
              +--------------------+--------------------+
              |                    |                    |
       +------+------+     +-------+-------+    +------+------+
       | Poincare    |     | Hyperbolic    |    | Hyperbolic  |
       | Embeddings  |     | Attention     |    | GNN         |
       +-------------+     +---------------+    +-------------+
                                   |
                           +-------+-------+
                           | HNSW Index    |
                           | (Hyperbolic)  |
                           +---------------+

Hyperbolic Geometry Primer

Euclidean Space               Hyperbolic Space (Poincare Ball)

    *--*--*--*                         * (root at center)
    |  |  |  |                        /|\
    *--*--*--*           vs          * * * (children near edge)
    |  |  |  |                      /|\ |\
    *--*--*--*                     ****  **

Uniform density              Exponential capacity toward boundary

Key Properties

Property Euclidean Hyperbolic
Tree capacity O(n^d) O(exp(d))
Hierarchy distortion High Low
Dimensions needed Many Few
Parent-child No natural Radial distance
Sibling No natural Angular distance

Performance Targets

Metric Target Baseline (Euclidean) Improvement
Embedding (10K nodes) <10s ~30s (high-dim Euclidean) 3x
Hyperbolic search <5ms for 1M embeddings ~50ms (Euclidean HNSW) 10x
Taxonomic query <10ms per inference ~100ms (graph traversal) 10x
Hierarchy comparison <1s for 10K nodes ~30s (tree edit distance) 30x
Entailment graph build <30s for 100K concepts ~10min (pairwise comparison) 20x
Dimension efficiency 32-dim hyperbolic 512-dim Euclidean equivalent 16x memory

Security Considerations

Input Validation (CRITICAL)

All MCP tool inputs MUST be validated using Zod schemas:

// hyperbolic/embed-hierarchy input validation
const EmbedHierarchySchema = z.object({
  hierarchy: z.object({
    nodes: z.array(z.object({
      id: z.string().max(200),
      parent: z.string().max(200).nullable(),
      features: z.record(z.string(), z.unknown()).optional()
    })).min(1).max(1_000_000), // Max 1M nodes
    edges: z.array(z.object({
      source: z.string().max(200),
      target: z.string().max(200),
      weight: z.number().finite().optional()
    })).max(10_000_000).optional()
  }),
  model: z.enum(['poincare_ball', 'lorentz', 'klein', 'half_plane']).default('poincare_ball'),
  parameters: z.object({
    dimensions: z.number().int().min(2).max(512).default(32),
    curvature: z.number().min(-10).max(-0.01).default(-1.0),
    learnCurvature: z.boolean().default(true)
  }).optional()
});

// hyperbolic/taxonomic-reason input validation
const TaxonomicReasonSchema = z.object({
  query: z.object({
    type: z.enum(['is_a', 'subsumption', 'lowest_common_ancestor', 'path', 'similarity']),
    subject: z.string().max(500),
    object: z.string().max(500).optional()
  }),
  taxonomy: z.string().max(200),
  inference: z.object({
    transitive: z.boolean().default(true),
    fuzzy: z.boolean().default(false),
    confidence: z.number().min(0).max(1).default(0.8)
  }).optional()
});

// hyperbolic/semantic-search input validation
const SemanticSearchSchema = z.object({
  query: z.string().max(5000),
  index: z.string().max(200),
  searchMode: z.enum(['nearest', 'subtree', 'ancestors', 'siblings', 'cone']).default('nearest'),
  constraints: z.object({
    maxDepth: z.number().int().min(0).max(100).optional(),
    minDepth: z.number().int().min(0).max(100).optional(),
    subtreeRoot: z.string().max(200).optional()
  }).optional(),
  topK: z.number().int().min(1).max(10000).default(10)
});

// hyperbolic/entailment-graph input validation
const EntailmentGraphSchema = z.object({
  action: z.enum(['build', 'query', 'expand', 'prune']),
  concepts: z.array(z.object({
    id: z.string().max(200),
    text: z.string().max(5000),
    type: z.string().max(100).optional()
  })).max(100000).optional(),
  entailmentThreshold: z.number().min(0).max(1).default(0.7),
  transitiveClosure: z.boolean().default(true),
  pruneStrategy: z.enum(['none', 'transitive_reduction', 'confidence_threshold']).optional()
});

WASM Security Constraints

Constraint Value Rationale
Memory Limit 2GB max Handle large hierarchies
CPU Time Limit 300 seconds for embedding Large graph embedding takes time
Node Limit 1M nodes max Bound computational complexity
Edge Limit 10M edges max Prevent memory exhaustion
Dimension Limit 512 max Reasonable embedding size

Numerical Security (CRITICAL for Hyperbolic)

// Hyperbolic operations have numerical instabilities near boundary
// MUST implement defensive numerical handling

const POINCARE_BALL_EPS = 1e-10;  // Minimum distance from boundary
const MAX_NORM = 1 - POINCARE_BALL_EPS;  // Maximum vector norm

// Clip vectors to stay within Poincare ball
function clipToBall(vector: number[], curvature: number): number[] {
  const norm = Math.sqrt(vector.reduce((sum, v) => sum + v * v, 0));
  const maxNorm = MAX_NORM / Math.sqrt(-curvature);

  if (norm > maxNorm) {
    const scale = maxNorm / norm;
    return vector.map(v => v * scale);
  }

  return vector;
}

// Safe Mobius addition (handles edge cases)
function safeMobiusAdd(x: number[], y: number[], c: number): number[] {
  // Check inputs are finite
  if (!x.every(Number.isFinite) || !y.every(Number.isFinite)) {
    throw new NumericalError('Non-finite input to Mobius addition');
  }

  // Clip to ball before operation
  x = clipToBall(x, c);
  y = clipToBall(y, c);

  // Perform operation with numerical guards
  // ... implementation with overflow checking
}

Output Validation

// Validate all hyperbolic outputs for numerical sanity
function validateHyperbolicOutput(result: HyperbolicResult): ValidationResult {
  // Check embeddings are within Poincare ball
  for (const embedding of result.embeddings) {
    const norm = Math.sqrt(embedding.reduce((sum, v) => sum + v * v, 0));
    if (norm >= 1.0) {
      return { valid: false, error: 'Embedding outside Poincare ball' };
    }
    if (!embedding.every(Number.isFinite)) {
      return { valid: false, error: 'Non-finite embedding values' };
    }
  }

  // Check distances are non-negative
  for (const distance of result.distances || []) {
    if (distance < 0 || !Number.isFinite(distance)) {
      return { valid: false, error: 'Invalid distance value' };
    }
  }

  return { valid: true };
}

Identified Security Risks

Risk ID Severity Description Mitigation
HYPER-SEC-001 HIGH DoS via deeply nested hierarchies Depth limits, progressive processing
HYPER-SEC-002 HIGH Numerical overflow near boundary Boundary clipping, epsilon guards
HYPER-SEC-003 MEDIUM NaN/Infinity propagation Input/output validation
HYPER-SEC-004 MEDIUM Memory exhaustion via large graphs Node/edge limits
HYPER-SEC-005 LOW Curvature manipulation attacks Curvature bounds (-10 to -0.01)

Denial of Service Prevention

// Hierarchies can be crafted to cause exponential blowup
function validateHierarchy(hierarchy: Hierarchy): ValidationResult {
  // Check for cycles (would cause infinite traversal)
  if (hasCycle(hierarchy)) {
    return { valid: false, error: 'Hierarchy contains cycles' };
  }

  // Check depth (very deep hierarchies cause numerical issues)
  const maxDepth = computeMaxDepth(hierarchy);
  if (maxDepth > 100) {
    return { valid: false, error: `Hierarchy too deep: ${maxDepth} > 100` };
  }

  // Check branching factor (wide trees cause memory issues)
  const maxBranching = computeMaxBranching(hierarchy);
  if (maxBranching > 10000) {
    return { valid: false, error: `Branching factor too high: ${maxBranching}` };
  }

  return { valid: true };
}

Rate Limiting

const HyperbolicRateLimits = {
  'hyperbolic/embed-hierarchy': { requestsPerMinute: 5, maxConcurrent: 1 },
  'hyperbolic/taxonomic-reason': { requestsPerMinute: 60, maxConcurrent: 5 },
  'hyperbolic/semantic-search': { requestsPerMinute: 60, maxConcurrent: 5 },
  'hyperbolic/hierarchy-compare': { requestsPerMinute: 10, maxConcurrent: 2 },
  'hyperbolic/entailment-graph': { requestsPerMinute: 10, maxConcurrent: 2 }
};

Risk Assessment

Risk Likelihood Impact Mitigation
Numerical instability Medium Medium Boundary clipping, numerical stabilization
Non-hierarchical data Medium Low Automatic fallback to Euclidean
Curvature tuning Medium Low Adaptive curvature via SONA
Training complexity High Medium Pretrained embeddings, transfer learning

Mobius Operations

The plugin implements core Mobius operations for the Poincare ball:

// Mobius addition: x + y in hyperbolic space
mobius_add(x: Vector, y: Vector, c: number): Vector

// Mobius scalar multiplication
mobius_scalar(r: number, x: Vector, c: number): Vector

// Exponential map: tangent space -> hyperbolic
exp_map(v: Vector, c: number): Vector

// Logarithmic map: hyperbolic -> tangent space
log_map(x: Vector, c: number): Vector

// Hyperbolic distance
hyperbolic_distance(x: Vector, y: Vector, c: number): number

Implementation Notes

Phase 1: Core Embeddings

  • Poincare ball model implementation
  • Hyperbolic distance metrics
  • Basic HNSW adaptation

Phase 2: Neural Operations

  • Hyperbolic attention mechanisms
  • Hyperbolic GNN layers
  • Adaptive curvature learning

Phase 3: Applications

  • Taxonomic reasoning engine
  • Hierarchy comparison tools
  • Entailment graph construction

Dependencies

{
  "dependencies": {
    "ruvector-hyperbolic-hnsw-wasm": "^0.1.0",
    "ruvector-attention-wasm": "^0.1.0",
    "ruvector-gnn-wasm": "^0.1.0",
    "micro-hnsw-wasm": "^0.2.0",
    "sona": "^0.1.0"
  }
}

Curvature Learning

The plugin supports learning optimal curvature per hierarchy:

Flat hierarchy (organization chart)  --> Low curvature (-0.1)
Deep hierarchy (taxonomy)            --> High curvature (-2.0)
Mixed hierarchy                      --> Adaptive curvature via SONA

Consequences

Positive

  • Orders of magnitude better hierarchy representation
  • Natural modeling of taxonomic relationships
  • Significant dimension reduction for tree-like data

Negative

  • Numerical instability near boundary (mitigated by clipping)
  • Not all data is hierarchical
  • Learning requires specialized optimization

Neutral

  • Can fallback to Euclidean for non-hierarchical data
ADR Relationship
ADR-004: Plugin Architecture Foundation - Defines plugin structure
ADR-017: RuVector Integration Dependency - Provides WASM packages
ADR-023: ONNX Hyperbolic Embeddings Dependency - Embedding initialization
ADR-032: Healthcare Clinical Related - Medical ontology hierarchies
ADR-034: Legal Contracts Related - Legal taxonomy navigation
ADR-035: Code Intelligence Related - Code hierarchy analysis

References


Last Updated: 2026-01-24