Skill guidance for advanced agentdb vector search implementation.
/plugin marketplace add DNYoussef/context-cascade/plugin install dnyoussef-context-cascade@DNYoussef/context-cascadeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
PROCESS.mdREADME.mdSKILL-meta.yamlprocess-diagram.gvBefore writing ANY code, you MUST check:
.claude/library/catalog.json.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.mdD:\Projects\*| Match | Action |
|---|---|
| Library >90% | REUSE directly |
| Library 70-90% | ADAPT minimally |
| Pattern exists | FOLLOW pattern |
| In project | EXTRACT |
| No match | BUILD (add to library after) |
Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration for building distributed AI systems, multi-agent coordination, and advanced vector search applications.
Use this skill when you need to:
Objective: Initialize multi-database AgentDB infrastructure with proper configuration
Agent: backend-dev
Steps:
npm install agentdb-advanced@latest
npm install @agentdb/quic-sync @agentdb/distributed
import { AgentDB } from 'agentdb-advanced';
import { QUICSync } from '@agentdb/quic-sync';
const primaryDB = new AgentDB({
name: 'primary-vector-db',
dimensions: 1536, // OpenAI embedding size
indexType: 'hnsw',
distanceMetric: 'cosine',
persistPath: './data/primary',
advanced: {
enableQUIC: true,
multiDB: true,
hybridSearch: true
}
});
await primaryDB.initialize();
const replicas = await Promise.all([
AgentDB.createReplica('replica-1', {
primary: primaryDB,
syncMode: 'quic',
persistPath: './data/replica-1'
}),
AgentDB.createReplica('replica-2', {
primary: primaryDB,
syncMode: 'quic',
persistPath: './data/replica-2'
})
]);
const monitor = primaryDB.createMonitor({
checkInterval: 5000,
metrics: ['latency', 'throughput', 'replication-lag'],
alerts: {
replicationLag: 1000, // ms
errorRate: 0.01
}
});
monitor.on('alert', (alert) => {
console.error('Database alert:', alert);
});
Memory Pattern:
await agentDB.memory.store('agentdb/infrastructure/config', {
primary: primaryDB.id,
replicas: replicas.map(r => r.id),
syncMode: 'quic',
timestamp: Date.now()
});
Validation:
Evidence-Based Validation:
// Self-consistency check across replicas
const testVector = Array(1536).fill(0).map(() => Math.random());
await primaryDB.insert({ id: 'test-1', vector: testVector });
// Wait for sync
await new Promise(resolve => setTimeout(resolve, 100));
// Verify consistency
const checks = await Promise.all(
replicas.map(r => r.get('test-1'))
);
const consistent = checks.every(c =>
c && vectorEquals(c.vector, testVector)
);
console.log('Consistency check:', consistent ? 'PASS' : 'FAIL');
Objective: Setup QUIC synchronization, multi-DB coordination, and advanced routing
Agent: ml-developer
Steps:
import { QUICConfig } from '@agentdb/quic-sync';
const quicSync = new QUICSync({
primary: primaryDB,
replicas: replicas,
config: {
maxStreams: 100,
idleTimeout: 30000,
keepAlive: 5000,
congestionControl: 'cubic',
prioritization: 'weighted-round-robin'
}
});
await quicSync.start();
// Monitor sync performance
quicSync.on('sync-complete', (stats) => {
console.log('Sync stats:', {
duration: stats.duration,
vectorsSynced: stats.count,
throughput: stats.count / (stats.duration / 1000)
});
});
import { MultiDBRouter } from '@agentdb/distributed';
const router = new MultiDBRouter({
databases: [primaryDB, ...replicas],
strategy: 'load-balanced', // or 'nearest', 'round-robin'
healthCheck: {
interval: 5000,
timeout: 1000
}
});
// Query routing
const searchResults = await router.search({
vector: queryVector,
topK: 10,
strategy: 'fan-out-merge' // Query all, merge results
});
import { DistributedCoordinator } from '@agentdb/distributed';
const coordinator = new DistributedCoordinator({
databases: [primaryDB, ...replicas],
consensus: 'raft', // or 'gossip', 'quorum'
leaderElection: true
});
await coordinator.start();
// Handle leadership changes
coordinator.on('leader-elected', (leader) => {
console.log('New leader:', leader.id);
primaryDB = leader;
});
const failoverPolicy = {
maxRetries: 3,
retryDelay: 1000,
fallbackStrategy: 'replica-promotion',
autoRecovery: true
};
router.setFailoverPolicy(failoverPolicy);
Memory Pattern:
await agentDB.memory.store('agentdb/advanced/quic-config', {
syncMode: 'quic',
streams: quicSync.activeStreams,
routingStrategy: 'load-balanced',
coordinator: coordinator.id
});
Validation:
Evidence-Based Validation:
// Program-of-thought: Test multi-DB coordination
async function validateCoordination() {
// Step 1: Insert on primary
const testId = 'coord-test-' + Date.now();
await primaryDB.insert({ id: testId, vector: testVector });
// Step 2: Wait for QUIC sync
await quicSync.waitForSync(testId, { timeout: 2000 });
// Step 3: Query through router
const results = await router.search({
vector: testVector,
topK: 1,
filter: { id: testId }
});
// Step 4: Verify result from any replica
return results[0]?.id === testId;
}
const coordValid = await validateCoordination();
console.log('Coordination validation:', coordValid ? 'PASS' : 'FAIL');
Objective: Create specialized distance functions for domain-specific similarity
Agent: ml-developer
Steps:
import { DistanceMetric } from 'agentdb-advanced';
interface CustomMetricConfig {
name: string;
weightedDimensions?: number[];
transformFunction?: (vector: number[]) => number[];
combineMetrics?: {
metrics: string[];
weights: number[];
};
}
const weightedEuclidean: DistanceMetric = {
name: 'weighted-euclidean',
compute: (a: number[], b: number[], weights?: number[]) => {
if (!weights) weights = Array(a.length).fill(1);
let sum = 0;
for (let i = 0; i < a.length; i++) {
sum += weights[i] * Math.pow(a[i] - b[i], 2);
}
return Math.sqrt(sum);
},
normalize: true
};
primaryDB.registerMetric(weightedEuclidean);
const hybridSimilarity: DistanceMetric = {
name: 'hybrid-similarity',
compute: (a: number[], b: number[], metadata?: any) => {
// Vector similarity (cosine)
const dotProduct = a.reduce((sum, val, i) => sum + val * b[i], 0);
const magA = Math.sqrt(a.reduce((sum, val) => sum + val * val, 0));
const magB = Math.sqrt(b.reduce((sum, val) => sum + val * val, 0));
const cosineSim = dotProduct / (magA * magB);
// Scalar similarity (if metadata present)
let scalarSim = 0;
if (metadata) {
scalarSim = 1 - Math.abs(metadata.timestamp - Date.now()) / 1e9;
}
// Combine (70% vector, 30% scalar)
return 0.7 * (1 - cosineSim) + 0.3 * (1 - scalarSim);
}
};
primaryDB.registerMetric(hybridSimilarity);
// Example: Code similarity metric
const codeSimilarity: DistanceMetric = {
name: 'code-similarity',
compute: (a: number[], b: number[], metadata?: any) => {
// Vector component
const vectorDist = cosineDistance(a, b);
// Syntactic similarity
const syntaxSim = metadata?.ast_similarity || 0;
// Semantic similarity
const semanticSim = metadata?.semantic_similarity || 0;
// Weighted combination
return 0.5 * vectorDist + 0.3 * (1 - syntaxSim) + 0.2 * (1 - semanticSim);
}
};
primaryDB.registerMetric(codeSimilarity);
async function benchmarkMetrics() {
const testVectors = generateTestVectors(1000);
const queryVector = testVectors[0];
const metrics = ['cosine', 'euclidean', 'weighted-euclidean', 'hybrid-similarity'];
const results: Record<string, any> = {};
for (const metric of metrics) {
const start = performance.now();
const searchResults = await primaryDB.search({
vector: queryVector,
topK: 10,
metric: metric
});
const duration = performance.now() - start;
results[metric] = {
duration,
results: searchResults.length,
accuracy: calculateAccuracy(searchResults)
};
}
return results;
}
const benchmark = await benchmarkMetrics();
await agentDB.memory.store('agentdb/metrics/benchmark', benchmark);
Memory Pattern:
await agentDB.memory.store('agentdb/custom-metrics/registry', {
metrics: ['weighted-euclidean', 'hybrid-similarity', 'code-similarity'],
benchmark: benchmark,
recommended: 'hybrid-similarity'
});
Validation:
Evidence-Based Validation:
// Chain-of-verification: Validate metric properties
async function verifyMetricProperties(metric: string) {
const checks = {
nonNegativity: true,
symmetry: true,
triangleInequality: true
};
const testVectors = [
Array(1536).fill(0).map(() => Math.random()),
Array(1536).fill(0).map(() => Math.random()),
Array(1536).fill(0).map(() => Math.random())
];
// Check non-negativity
const d1 = await primaryDB.distance(testVectors[0], testVectors[1], metric);
checks.nonNegativity = d1 >= 0;
// Check symmetry: d(a,b) = d(b,a)
const d2 = await primaryDB.distance(testVectors[1], testVectors[0], metric);
checks.symmetry = Math.abs(d1 - d2) < 1e-6;
// Check triangle inequality: d(a,c) <= d(a,b) + d(b,c)
const dac = await primaryDB.distance(testVectors[0], testVectors[2], metric);
const dbc = await primaryDB.distance(testVectors[1], testVectors[2], metric);
checks.triangleInequality = dac <= d1 + dbc + 1e-6;
return checks;
}
const metricValid = await verifyMetricProperties('hybrid-similarity');
console.log('Metric validation:', metricValid);
Objective: Apply indexing, caching, and optimization techniques for production performance
Agent: performance-analyzer
Steps:
await primaryDB.createIndex({
type: 'hnsw',
params: {
M: 16, // Number of connections per layer
efConstruction: 200, // Construction time accuracy
efSearch: 100, // Search time accuracy
maxElements: 1000000
}
});
// Enable index for all replicas
await Promise.all(
replicas.map(r => r.syncIndex(primaryDB))
);
import { QueryCache } from '@agentdb/optimization';
const cache = new QueryCache({
maxSize: 10000,
ttl: 3600000, // 1 hour
strategy: 'lru',
hashFunction: 'xxhash64'
});
primaryDB.setCache(cache);
// Cache hit monitoring
cache.on('hit', (key, entry) => {
console.log('Cache hit:', { key, age: Date.now() - entry.timestamp });
});
import { Quantization } from '@agentdb/optimization';
const quantizer = new Quantization({
method: 'product-quantization',
codebookSize: 256,
subvectors: 8,
compressionRatio: 4 // 4x memory reduction
});
await primaryDB.applyQuantization(quantizer);
// Verify accuracy after quantization
const accuracyTest = await benchmarkAccuracy(primaryDB, testQueries);
console.log('Post-quantization accuracy:', accuracyTest);
import { BatchProcessor } from '@agentdb/optimization';
const batchProcessor = new BatchProcessor({
batchSize: 1000,
flushInterval: 5000,
parallelBatches: 4
});
// Batch inserts
const vectors = generateVectors(10000);
await batchProcessor.insertBatch(primaryDB, vectors);
// Batch searches
const queries = generateQueries(100);
const results = await batchProcessor.searchBatch(primaryDB, queries, {
topK: 10,
parallel: true
});
async function comprehensiveBenchmark() {
const benchmark = {
insertThroughput: 0,
searchLatency: 0,
searchThroughput: 0,
memoryUsage: 0,
cacheHitRate: 0
};
// Insert throughput
const insertStart = performance.now();
await batchProcessor.insertBatch(primaryDB, generateVectors(10000));
benchmark.insertThroughput = 10000 / ((performance.now() - insertStart) / 1000);
// Search latency (p50, p95, p99)
const latencies: number[] = [];
for (let i = 0; i < 1000; i++) {
const start = performance.now();
await primaryDB.search({ vector: generateQuery(), topK: 10 });
latencies.push(performance.now() - start);
}
latencies.sort((a, b) => a - b);
benchmark.searchLatency = {
p50: latencies[Math.floor(latencies.length * 0.5)],
p95: latencies[Math.floor(latencies.length * 0.95)],
p99: latencies[Math.floor(latencies.length * 0.99)]
};
// Memory usage
benchmark.memoryUsage = await primaryDB.getMemoryUsage();
// Cache hit rate
const cacheStats = cache.getStats();
benchmark.cacheHitRate = cacheStats.hits / (cacheStats.hits + cacheStats.misses);
return benchmark;
}
const perfResults = await comprehensiveBenchmark();
await agentDB.memory.store('agentdb/optimization/benchmark', perfResults);
Memory Pattern:
await agentDB.memory.store('agentdb/optimization/config', {
indexing: { type: 'hnsw', params: {...} },
caching: { enabled: true, hitRate: perfResults.cacheHitRate },
quantization: { method: 'product-quantization', ratio: 4 },
performance: perfResults
});
Validation:
Evidence-Based Validation:
// Multi-agent consensus on performance targets
async function validatePerformanceTargets() {
const targets = {
searchLatencyP95: 10, // ms
insertThroughput: 50000, // vectors/sec
memoryEfficiency: 4, // compression ratio
cacheHitRate: 0.7 // 70%
};
const results = await comprehensiveBenchmark();
const validations = {
latency: results.searchLatency.p95 <= targets.searchLatencyP95,
throughput: results.insertThroughput >= targets.insertThroughput,
memory: results.memoryUsage.compressionRatio >= targets.memoryEfficiency,
cache: results.cacheHitRate >= targets.cacheHitRate
};
const allPass = Object.values(validations).every(v => v);
return { validations, allPass, results };
}
const perfValidation = await validatePerformanceTargets();
console.log('Performance validation:', perfValidation);
Objective: Deploy to production with monitoring, alerting, and operational procedures
Agent: backend-dev
Steps:
const productionConfig = {
cluster: {
primary: {
host: process.env.PRIMARY_HOST,
port: parseInt(process.env.PRIMARY_PORT),
replicas: 2
},
replicas: [
{ host: process.env.REPLICA1_HOST, port: parseInt(process.env.REPLICA1_PORT) },
{ host: process.env.REPLICA2_HOST, port: parseInt(process.env.REPLICA2_PORT) }
]
},
monitoring: {
enabled: true,
exporters: ['prometheus', 'cloudwatch'],
alerts: {
replicationLag: 1000,
errorRate: 0.01,
latencyP95: 50
}
},
backup: {
enabled: true,
interval: 3600000, // 1 hour
retention: 7 // days
}
};
await deployCluster(productionConfig);
import { MetricsExporter } from '@agentdb/monitoring';
const exporter = new MetricsExporter({
exporters: [
{
type: 'prometheus',
port: 9090,
metrics: [
'agentdb_search_latency',
'agentdb_insert_throughput',
'agentdb_replication_lag',
'agentdb_cache_hit_rate',
'agentdb_memory_usage'
]
},
{
type: 'cloudwatch',
namespace: 'AgentDB/Production',
region: 'us-east-1'
}
]
});
await exporter.start();
// Custom metrics
exporter.registerMetric('agentdb_custom_queries', 'counter',
'Custom metric queries executed'
);
import { AlertManager } from '@agentdb/monitoring';
const alertManager = new AlertManager({
channels: [
{ type: 'email', recipients: ['ops@company.com'] },
{ type: 'slack', webhook: process.env.SLACK_WEBHOOK },
{ type: 'pagerduty', apiKey: process.env.PAGERDUTY_KEY }
],
rules: [
{
metric: 'agentdb_replication_lag',
condition: '> 1000',
severity: 'critical',
message: 'Replication lag exceeds 1 second'
},
{
metric: 'agentdb_search_latency_p95',
condition: '> 50',
severity: 'warning',
message: 'Search latency P95 exceeds 50ms'
},
{
metric: 'agentdb_error_rate',
condition: '> 0.01',
severity: 'critical',
message: 'Error rate exceeds 1%'
}
]
});
await alertManager.start();
import express from 'express';
const healthApp = express();
healthApp.get('/health', async (req, res) => {
const health = {
status: 'healthy',
timestamp: Date.now(),
databases: await Promise.all([
primaryDB.healthCheck(),
...replicas.map(r => r.healthCheck())
]),
quic: quicSync.isHealthy(),
coordinator: coordinator.getStatus()
};
const allHealthy = health.databases.every(db => db.status === 'healthy');
res.status(allHealthy ? 200 : 503).json(health);
});
healthApp.get('/metrics', async (req, res) => {
const metrics = await exporter.getMetrics();
res.set('Content-Type', 'text/plain');
res.send(metrics);
});
healthApp.listen(8080);
const runbook = {
deployment: {
steps: [
'1. Verify configuration in production.env',
'2. Deploy primary database first',
'3. Deploy replicas with QUIC sync enabled',
'4. Verify replication lag < 100ms',
'5. Enable monitoring and alerting',
'6. Run smoke tests',
'7. Gradually increase traffic'
]
},
troubleshooting: {
'High replication lag': [
'Check network connectivity between nodes',
'Verify QUIC streams are not saturated',
'Consider increasing QUIC maxStreams',
'Check primary database load'
],
'Slow search queries': [
'Verify HNSW index is built',
'Check cache hit rate',
'Review query patterns',
'Consider adjusting efSearch parameter'
],
'Leader election failure': [
'Check coordinator logs',
'Verify quorum availability',
'Check network partitions',
'Manually trigger election if needed'
]
},
backup: {
schedule: 'Hourly incremental, daily full',
retention: '7 days',
restore: [
'1. Stop affected database instance',
'2. Download backup from S3',
'3. Restore data directory',
'4. Start database with --recovery flag',
'5. Verify data integrity',
'6. Rejoin cluster'
]
}
};
await agentDB.memory.store('agentdb/production/runbook', runbook);
Memory Pattern:
await agentDB.memory.store('agentdb/production/deployment', {
config: productionConfig,
deployed: Date.now(),
monitoring: {
dashboards: ['prometheus:3000', 'grafana:3001'],
alerts: alertManager.getRules()
},
runbook: runbook
});
Validation:
Evidence-Based Validation:
// Self-consistency check: Production readiness
async function validateProductionReadiness() {
const checks = {
deployment: false,
monitoring: false,
alerting: false,
healthChecks: false,
backup: false,
documentation: false
};
// Check deployment
const clusterStatus = await coordinator.getClusterStatus();
checks.deployment = clusterStatus.healthy && clusterStatus.nodes.length >= 3;
// Check monitoring
const metrics = await exporter.getMetrics();
checks.monitoring = metrics.length > 0;
// Check alerting
const alertStatus = await alertManager.getStatus();
checks.alerting = alertStatus.active && alertStatus.channels.length > 0;
// Check health endpoint
const healthResponse = await fetch('http://localhost:8080/health');
checks.healthChecks = healthResponse.status === 200;
// Check backup configuration
const backupStatus = await checkBackupStatus();
checks.backup = backupStatus.enabled && backupStatus.lastBackup !== null;
// Check documentation
const docs = await agentDB.memory.retrieve('agentdb/production/runbook');
checks.documentation = docs !== null;
const readiness = Object.values(checks).every(c => c);
return { checks, readiness };
}
const prodReadiness = await validateProductionReadiness();
console.log('Production readiness:', prodReadiness);
#!/bin/bash
# deploy-advanced-agentdb.sh
set -e
echo "Advanced AgentDB Deployment Script"
echo "==================================="
# Phase 1: Infrastructure Setup
echo "Phase 1: Setting up infrastructure..."
npm install agentdb-advanced @agentdb/quic-sync @agentdb/distributed @agentdb/optimization @agentdb/monitoring
# Phase 2: Initialize databases
echo "Phase 2: Initializing databases..."
node -e "
const { AgentDB } = require('agentdb-advanced');
const primary = new AgentDB({
name: 'primary',
dimensions: 1536,
advanced: { enableQUIC: true, multiDB: true }
});
await primary.initialize();
console.log('Primary database initialized');
"
# Phase 3: Deploy replicas
echo "Phase 3: Deploying replicas..."
for i in 1 2; do
node -e "
const { AgentDB } = require('agentdb-advanced');
const replica = await AgentDB.createReplica('replica-$i', {
syncMode: 'quic'
});
console.log('Replica $i deployed');
"
done
# Phase 4: Configure monitoring
echo "Phase 4: Configuring monitoring..."
node -e "
const { MetricsExporter } = require('@agentdb/monitoring');
const exporter = new MetricsExporter({
exporters: [{ type: 'prometheus', port: 9090 }]
});
await exporter.start();
console.log('Monitoring configured');
"
# Phase 5: Run validation
echo "Phase 5: Running validation..."
npm run test:integration
echo "Deployment complete!"
// quickstart-advanced.ts
import { setupAdvancedAgentDB } from './setup';
async function quickStart() {
console.log('Starting Advanced AgentDB Quick Setup...');
// 1. Setup infrastructure
const { primary, replicas, router } = await setupAdvancedAgentDB({
dimensions: 1536,
replicaCount: 2,
enableQUIC: true
});
// 2. Load sample data
console.log('Loading sample data...');
const vectors = generateSampleVectors(10000);
await router.insertBatch(vectors);
// 3. Test searches
console.log('Testing searches...');
const query = vectors[0];
const results = await router.search({
vector: query,
topK: 10,
metric: 'cosine'
});
console.log('Search results:', results.length);
// 4. Verify replication
console.log('Verifying replication...');
const syncStatus = await router.getSyncStatus();
console.log('Replication lag:', syncStatus.lag, 'ms');
console.log('Quick setup complete!');
}
quickStart().catch(console.error);
// Store cluster configuration
await memory.store('agentdb/cluster/config', {
topology: 'distributed',
nodes: [primary, ...replicas],
syncMode: 'quic',
timestamp: Date.now()
});
// Store performance metrics
await memory.store('agentdb/metrics/latest', {
searchLatency: perfResults.searchLatency,
throughput: perfResults.insertThroughput,
cacheHitRate: perfResults.cacheHitRate
});
// Store custom metrics registry
await memory.store('agentdb/metrics/custom', {
registered: ['weighted-euclidean', 'hybrid-similarity'],
active: 'hybrid-similarity',
benchmarks: benchmark
});
// Store operational state
await memory.store('agentdb/operations/state', {
deployed: true,
healthy: true,
leader: coordinator.getLeader(),
lastBackup: backupTimestamp
});
Multi-Database Consistency (Self-Consistency)
Performance Targets (Benchmarking)
Custom Metrics Validity (Chain-of-Verification)
Production Readiness (Multi-Agent Consensus)
Issue: High replication lag
// Diagnose
const diagnostics = await quicSync.diagnose();
console.log('QUIC diagnostics:', diagnostics);
// Fix: Increase stream capacity
await quicSync.reconfigure({
maxStreams: 200,
congestionControl: 'bbr'
});
Issue: Slow queries after quantization
// Check accuracy loss
const accuracy = await benchmarkAccuracy(primaryDB, testQueries);
if (accuracy < 0.95) {
// Adjust quantization parameters
await primaryDB.applyQuantization({
method: 'product-quantization',
compressionRatio: 2 // Reduce compression
});
}
Issue: Cache thrashing
// Analyze cache patterns
const cacheStats = cache.getDetailedStats();
console.log('Cache stats:', cacheStats);
// Adjust cache size or TTL
cache.reconfigure({
maxSize: 20000, // Increase size
ttl: 7200000 // Increase TTL to 2 hours
});
This skill operates using AgentDB's npm package and API only. No additional MCP servers required.
All AgentDB advanced operations are performed through:
npx agentdb@latestimport { AgentDB, QUICSync, DistributedCoordinator } from 'agentdb-advanced'Advanced AgentDB Vector Search Implementation operates on 3 fundamental principles:
Traditional TCP-based replication suffers from head-of-line blocking (one lost packet stalls entire stream) and connection setup overhead (3-way handshake adds 50-150ms latency). QUIC's multiplexed streams and 0-RTT connection resumption enable sub-100ms replication lag across distributed databases, maintaining consistency without sacrificing performance.
In practice:
Generic distance metrics (cosine, Euclidean) assume all vector dimensions contribute equally to similarity. Domain-specific applications require weighted dimensions (emphasizing recent timestamps for time-series), hybrid metrics (combining vector and scalar features), or specialized functions (code similarity using AST structure + embeddings).
In practice:
Single-node vector search creates bottlenecks at scale. Fan-out routing distributes queries across multiple replicas in parallel, merges results, and balances load to maximize throughput. This enables horizontal scaling where adding replicas proportionally increases query capacity.
In practice:
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Synchronous Replication Blocking Writes | Requiring all replicas to acknowledge before write returns creates latency spikes (200ms+ for 3 replicas across regions). Writes become bottlenecked by slowest replica or network partition. | Use asynchronous QUIC replication with eventual consistency. Primary returns immediately after local write, QUIC streams propagate to replicas in background. Accept <100ms replication lag for 10x write throughput improvement. Implement read-your-writes consistency where needed. |
| Custom Metric Without Validation - Break HNSW Index Assumptions | HNSW indexes assume distance metrics satisfy triangle inequality and symmetry. Violating these properties causes index corruption, incorrect nearest neighbors, and silent accuracy degradation. | Implement comprehensive metric validation (Phase 3 chain-of-verification): test non-negativity d(a,b)>=0, symmetry d(a,b)=d(b,a), triangle inequality d(a,c)<=d(a,b)+d(b,c). Run validation on 1000+ random vector triples before deploying metric to production. |
| Query All Replicas Always - Waste Network and Compute on Low-Traffic Systems | Fan-out-merge routing sends every query to all replicas regardless of load. For low-traffic systems (100 QPS), this wastes 3x network bandwidth and compute capacity while adding merge latency overhead. | Implement adaptive routing: use single-replica for low load (<1000 QPS), load-balanced for medium (1K-10K QPS), fan-out-merge only for high load (>10K QPS). Monitor query latency distribution and switch strategies based on p95 latency targets. |
Advanced AgentDB Vector Search Implementation enables production-scale distributed vector databases through three sophisticated capabilities: QUIC synchronization for sub-100ms replication lag, custom distance metrics for domain-specific similarity, and multi-database routing for horizontal scalability. The 5-phase SOP systematically guides infrastructure setup, advanced feature configuration, custom metric implementation, performance optimization, and production deployment with comprehensive monitoring and operational runbooks. This transforms basic vector search into enterprise-grade systems handling millions of queries per second with 99.9%+ uptime.
This skill is critical when scaling beyond single-node deployments to handle massive query volumes (>10K QPS), implementing high-availability architectures with automatic failover, or building domain-specific search requiring specialized similarity functions. The key architectural decision is choosing the right synchronization model - synchronous replication guarantees consistency but limits write throughput, asynchronous QUIC replication enables high-speed writes with eventual consistency trade-offs. Most production systems choose asynchronous with <100ms replication lag as the optimal balance.
Custom distance metrics unlock powerful domain applications but require rigorous validation. Generic cosine similarity fails for tasks like code search (needs AST structure), document retrieval (needs recency weighting), or fraud detection (needs anomaly scoring). The metric validation framework prevents silent accuracy degradation by verifying mathematical properties before production deployment. Combined with HNSW indexing, quantization, and caching from the optimization skill, you achieve both specialized similarity functions and sub-10ms query latency - enabling intelligent search experiences that feel magical to users while remaining cost-effective at scale. The comprehensive monitoring, alerting, and runbooks ensure systems remain operational through network partitions, replica failures, and traffic spikes that inevitably occur in production environments.
This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.