oxirs-vec 0.2.4

Vector index abstractions for semantic similarity and AI-augmented querying
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
//! Advanced SPARQL Service Endpoint for Vector Operations
//!
//! This module implements SERVICE vec:endpoint functionality for federated vector search,
//! custom function registration, and advanced SPARQL integration features.

use crate::{
    sparql_integration::{
        CustomVectorFunction, PerformanceMonitor, VectorServiceArg, VectorServiceResult,
    },
    Vector,
};
use anyhow::{anyhow, Result};
use parking_lot::RwLock;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::{Duration, Instant};

/// Federated vector service endpoint
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FederatedServiceEndpoint {
    pub endpoint_uri: String,
    pub service_type: ServiceType,
    pub capabilities: Vec<ServiceCapability>,
    pub authentication: Option<AuthenticationInfo>,
    pub retry_config: RetryConfiguration,
    pub timeout: Duration,
    pub health_status: ServiceHealthStatus,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServiceType {
    VectorSearch,
    EmbeddingGeneration,
    SimilarityComputation,
    Hybrid, // Supports multiple capabilities
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ServiceCapability {
    KNNSearch,
    ThresholdSearch,
    TextEmbedding,
    ImageEmbedding,
    SimilarityCalculation,
    CustomFunction(String),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuthenticationInfo {
    pub auth_type: AuthenticationType,
    pub credentials: HashMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AuthenticationType {
    None,
    ApiKey,
    OAuth2,
    BasicAuth,
    Custom(String),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RetryConfiguration {
    pub max_retries: usize,
    pub initial_delay: Duration,
    pub max_delay: Duration,
    pub backoff_multiplier: f32,
}

impl Default for RetryConfiguration {
    fn default() -> Self {
        Self {
            max_retries: 3,
            initial_delay: Duration::from_millis(100),
            max_delay: Duration::from_secs(10),
            backoff_multiplier: 2.0,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServiceHealthStatus {
    Healthy,
    Degraded,
    Unhealthy,
    Unknown,
}

/// SERVICE endpoint manager for federated vector operations
pub struct ServiceEndpointManager {
    endpoints: Arc<RwLock<HashMap<String, FederatedServiceEndpoint>>>,
    load_balancer: LoadBalancer,
    health_checker: HealthChecker,
    performance_monitor: PerformanceMonitor,
}

impl Default for ServiceEndpointManager {
    fn default() -> Self {
        Self::new()
    }
}

impl ServiceEndpointManager {
    pub fn new() -> Self {
        Self {
            endpoints: Arc::new(RwLock::new(HashMap::new())),
            load_balancer: LoadBalancer::new(),
            health_checker: HealthChecker::new(),
            performance_monitor: PerformanceMonitor::new(),
        }
    }

    /// Register a new service endpoint
    pub fn register_endpoint(&self, endpoint: FederatedServiceEndpoint) -> Result<()> {
        let mut endpoints = self.endpoints.write();
        endpoints.insert(endpoint.endpoint_uri.clone(), endpoint);
        Ok(())
    }

    /// Execute a federated vector search
    pub async fn execute_federated_search(
        &self,
        query: &FederatedVectorQuery,
    ) -> Result<FederatedSearchResult> {
        let start_time = Instant::now();

        // Select appropriate endpoints based on query requirements
        let selected_endpoints = self.select_endpoints(query)?;

        // Execute query on multiple endpoints in parallel
        let mut partial_results = Vec::new();
        for endpoint in selected_endpoints {
            match self.execute_on_endpoint(&endpoint, query).await {
                Ok(result) => partial_results.push(result),
                Err(e) => {
                    // Log error but continue with other endpoints
                    eprintln!(
                        "Error executing on endpoint {}: {}",
                        endpoint.endpoint_uri, e
                    );
                }
            }
        }

        // Merge results from all endpoints
        let merged_result = self.merge_federated_results(partial_results, query)?;

        let duration = start_time.elapsed();
        self.performance_monitor.record_query(duration, true);

        Ok(merged_result)
    }

    /// Select appropriate endpoints for a query
    fn select_endpoints(
        &self,
        query: &FederatedVectorQuery,
    ) -> Result<Vec<FederatedServiceEndpoint>> {
        let endpoints = self.endpoints.read();
        let mut suitable_endpoints = Vec::new();

        for endpoint in endpoints.values() {
            if self.endpoint_supports_query(endpoint, query) {
                suitable_endpoints.push(endpoint.clone());
            }
        }

        if suitable_endpoints.is_empty() {
            return Err(anyhow!("No suitable endpoints found for query"));
        }

        // Apply load balancing
        Ok(self.load_balancer.balance_endpoints(suitable_endpoints))
    }

    /// Check if endpoint supports the given query
    fn endpoint_supports_query(
        &self,
        endpoint: &FederatedServiceEndpoint,
        query: &FederatedVectorQuery,
    ) -> bool {
        match &query.operation {
            FederatedOperation::KNNSearch { .. } => endpoint
                .capabilities
                .contains(&ServiceCapability::KNNSearch),
            FederatedOperation::ThresholdSearch { .. } => endpoint
                .capabilities
                .contains(&ServiceCapability::ThresholdSearch),
            FederatedOperation::SimilarityCalculation { .. } => endpoint
                .capabilities
                .contains(&ServiceCapability::SimilarityCalculation),
            FederatedOperation::CustomFunction { function_name, .. } => endpoint
                .capabilities
                .contains(&ServiceCapability::CustomFunction(function_name.clone())),
        }
    }

    /// Execute query on a specific endpoint
    async fn execute_on_endpoint(
        &self,
        endpoint: &FederatedServiceEndpoint,
        query: &FederatedVectorQuery,
    ) -> Result<PartialSearchResult> {
        // Implementation would depend on the actual service protocol
        // For now, we'll simulate the execution

        let start_time = Instant::now();

        // Simulate network request with retry logic
        let result = self.execute_with_retry(endpoint, query).await?;

        let duration = start_time.elapsed();
        self.performance_monitor
            .record_operation(&format!("endpoint_{}", endpoint.endpoint_uri), duration);

        Ok(result)
    }

    /// Execute with retry logic
    async fn execute_with_retry(
        &self,
        endpoint: &FederatedServiceEndpoint,
        query: &FederatedVectorQuery,
    ) -> Result<PartialSearchResult> {
        let mut attempt = 0;
        let mut delay = endpoint.retry_config.initial_delay;

        loop {
            match self.try_execute(endpoint, query).await {
                Ok(result) => return Ok(result),
                Err(_e) if attempt < endpoint.retry_config.max_retries => {
                    attempt += 1;

                    // Wait before retry
                    tokio::time::sleep(delay).await;

                    // Increase delay for next attempt
                    delay = std::cmp::min(
                        Duration::from_millis(
                            (delay.as_millis() as f32 * endpoint.retry_config.backoff_multiplier)
                                as u64,
                        ),
                        endpoint.retry_config.max_delay,
                    );
                }
                Err(e) => return Err(e),
            }
        }
    }

    /// Try to execute on endpoint (single attempt)
    async fn try_execute(
        &self,
        endpoint: &FederatedServiceEndpoint,
        query: &FederatedVectorQuery,
    ) -> Result<PartialSearchResult> {
        // Simulate the actual service call
        // In a real implementation, this would make HTTP requests to the endpoint

        match &query.operation {
            FederatedOperation::KNNSearch { .. } => {
                // Simulate KNN search result
                Ok(PartialSearchResult {
                    endpoint_uri: endpoint.endpoint_uri.clone(),
                    results: vec![
                        ("http://example.org/doc1".to_string(), 0.95),
                        ("http://example.org/doc2".to_string(), 0.87),
                    ],
                    metadata: HashMap::new(),
                })
            }
            _ => {
                // Placeholder for other operations
                Ok(PartialSearchResult {
                    endpoint_uri: endpoint.endpoint_uri.clone(),
                    results: Vec::new(),
                    metadata: HashMap::new(),
                })
            }
        }
    }

    /// Merge results from multiple endpoints
    fn merge_federated_results(
        &self,
        partial_results: Vec<PartialSearchResult>,
        query: &FederatedVectorQuery,
    ) -> Result<FederatedSearchResult> {
        let mut all_results = Vec::new();
        let mut source_endpoints = Vec::new();
        let merged_count = partial_results.len();

        for partial in partial_results {
            source_endpoints.push(partial.endpoint_uri.clone());
            all_results.extend(partial.results);
        }

        // Sort by similarity score (descending)
        all_results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));

        // Apply global limit if specified
        if let Some(limit) = query.global_limit {
            all_results.truncate(limit);
        }

        Ok(FederatedSearchResult {
            results: all_results,
            source_endpoints,
            execution_time: Duration::from_millis(0), // Would be calculated properly
            merged_count,
        })
    }

    /// Get endpoint health status
    pub async fn check_endpoint_health(&self, endpoint_uri: &str) -> Result<ServiceHealthStatus> {
        self.health_checker.check_health(endpoint_uri).await
    }

    /// Update endpoint health status
    pub fn update_endpoint_health(&self, endpoint_uri: &str, status: ServiceHealthStatus) {
        let mut endpoints = self.endpoints.write();
        if let Some(endpoint) = endpoints.get_mut(endpoint_uri) {
            endpoint.health_status = status;
        }
    }
}

/// Load balancer for distributing queries across endpoints
pub struct LoadBalancer {
    strategy: LoadBalancingStrategy,
}

#[derive(Debug, Clone)]
pub enum LoadBalancingStrategy {
    RoundRobin,
    LeastConnections,
    WeightedRandom,
    HealthBased,
}

impl LoadBalancer {
    pub fn new() -> Self {
        Self {
            strategy: LoadBalancingStrategy::HealthBased,
        }
    }

    pub fn balance_endpoints(
        &self,
        endpoints: Vec<FederatedServiceEndpoint>,
    ) -> Vec<FederatedServiceEndpoint> {
        match self.strategy {
            LoadBalancingStrategy::HealthBased => {
                let mut healthy_endpoints: Vec<_> = endpoints
                    .iter()
                    .filter(|e| matches!(e.health_status, ServiceHealthStatus::Healthy))
                    .cloned()
                    .collect();

                if healthy_endpoints.is_empty() {
                    // Fall back to degraded endpoints if no healthy ones
                    healthy_endpoints = endpoints
                        .iter()
                        .filter(|e| matches!(e.health_status, ServiceHealthStatus::Degraded))
                        .cloned()
                        .collect();
                }

                healthy_endpoints
            }
            _ => endpoints, // Other strategies would be implemented here
        }
    }
}

impl Default for LoadBalancer {
    fn default() -> Self {
        Self::new()
    }
}

/// Health checker for monitoring endpoint availability
pub struct HealthChecker {
    check_interval: Duration,
}

impl HealthChecker {
    pub fn new() -> Self {
        Self {
            check_interval: Duration::from_secs(30),
        }
    }

    pub async fn check_health(&self, endpoint_uri: &str) -> Result<ServiceHealthStatus> {
        // Simulate health check
        // In a real implementation, this would make a health check request

        if endpoint_uri.contains("unhealthy") {
            Ok(ServiceHealthStatus::Unhealthy)
        } else if endpoint_uri.contains("degraded") {
            Ok(ServiceHealthStatus::Degraded)
        } else {
            Ok(ServiceHealthStatus::Healthy)
        }
    }
}

impl Default for HealthChecker {
    fn default() -> Self {
        Self::new()
    }
}

/// Custom function registry for user-defined vector operations
pub struct CustomFunctionRegistry {
    functions: Arc<RwLock<HashMap<String, Box<dyn CustomVectorFunction>>>>,
    metadata: Arc<RwLock<HashMap<String, FunctionMetadata>>>,
}

#[derive(Debug, Clone)]
pub struct FunctionMetadata {
    pub name: String,
    pub description: String,
    pub parameters: Vec<ParameterInfo>,
    pub return_type: ReturnType,
    pub examples: Vec<String>,
}

#[derive(Debug, Clone)]
pub struct ParameterInfo {
    pub name: String,
    pub param_type: ParameterType,
    pub required: bool,
    pub description: String,
    pub default_value: Option<String>,
}

#[derive(Debug, Clone)]
pub enum ParameterType {
    Vector,
    String,
    Number,
    Boolean,
    URI,
}

#[derive(Debug, Clone)]
pub enum ReturnType {
    Vector,
    Number,
    String,
    Boolean,
    Array(Box<ReturnType>),
}

impl CustomFunctionRegistry {
    pub fn new() -> Self {
        Self {
            functions: Arc::new(RwLock::new(HashMap::new())),
            metadata: Arc::new(RwLock::new(HashMap::new())),
        }
    }

    /// Register a custom function
    pub fn register_function(
        &self,
        name: String,
        function: Box<dyn CustomVectorFunction>,
        metadata: FunctionMetadata,
    ) -> Result<()> {
        let mut functions = self.functions.write();
        let mut meta = self.metadata.write();

        if functions.contains_key(&name) {
            return Err(anyhow!("Function '{}' is already registered", name));
        }

        functions.insert(name.clone(), function);
        meta.insert(name, metadata);

        Ok(())
    }

    /// Execute a custom function
    pub fn execute_function(
        &self,
        name: &str,
        args: &[VectorServiceArg],
    ) -> Result<VectorServiceResult> {
        let functions = self.functions.read();

        if let Some(function) = functions.get(name) {
            function.execute(args)
        } else {
            Err(anyhow!("Function '{}' not found", name))
        }
    }

    /// Get function metadata
    pub fn get_metadata(&self, name: &str) -> Option<FunctionMetadata> {
        let metadata = self.metadata.read();
        metadata.get(name).cloned()
    }

    /// List all registered functions
    pub fn list_functions(&self) -> Vec<String> {
        let functions = self.functions.read();
        functions.keys().cloned().collect()
    }

    /// Unregister a function
    pub fn unregister_function(&self, name: &str) -> Result<()> {
        let mut functions = self.functions.write();
        let mut metadata = self.metadata.write();

        functions.remove(name);
        metadata.remove(name);

        Ok(())
    }
}

impl Default for CustomFunctionRegistry {
    fn default() -> Self {
        Self::new()
    }
}

/// Query types for federated vector operations
#[derive(Debug, Clone)]
pub struct FederatedVectorQuery {
    pub operation: FederatedOperation,
    pub scope: QueryScope,
    pub global_limit: Option<usize>,
    pub timeout: Option<Duration>,
    pub explain: bool,
}

#[derive(Debug, Clone)]
pub enum FederatedOperation {
    KNNSearch {
        vector: Vector,
        k: usize,
        threshold: Option<f32>,
    },
    ThresholdSearch {
        vector: Vector,
        threshold: f32,
    },
    SimilarityCalculation {
        vector1: Vector,
        vector2: Vector,
    },
    CustomFunction {
        function_name: String,
        arguments: Vec<VectorServiceArg>,
    },
}

#[derive(Debug, Clone)]
pub enum QueryScope {
    All,
    Endpoints(Vec<String>),
    GraphScope(String),
}

/// Results from federated search operations
#[derive(Debug, Clone)]
pub struct FederatedSearchResult {
    pub results: Vec<(String, f32)>,
    pub source_endpoints: Vec<String>,
    pub execution_time: Duration,
    pub merged_count: usize,
}

#[derive(Debug, Clone)]
pub struct PartialSearchResult {
    pub endpoint_uri: String,
    pub results: Vec<(String, f32)>,
    pub metadata: HashMap<String, String>,
}

/// Example custom functions
pub struct CosineSimilarityFunction;

impl CustomVectorFunction for CosineSimilarityFunction {
    fn execute(&self, args: &[VectorServiceArg]) -> Result<VectorServiceResult> {
        if args.len() != 2 {
            return Err(anyhow!(
                "CosineSimilarity requires exactly 2 vector arguments"
            ));
        }

        let vector1 = match &args[0] {
            VectorServiceArg::Vector(v) => v,
            _ => return Err(anyhow!("First argument must be a vector")),
        };

        let vector2 = match &args[1] {
            VectorServiceArg::Vector(v) => v,
            _ => return Err(anyhow!("Second argument must be a vector")),
        };

        let similarity = vector1.cosine_similarity(vector2)?;
        Ok(VectorServiceResult::Number(similarity))
    }

    fn arity(&self) -> usize {
        2
    }

    fn description(&self) -> String {
        "Calculate cosine similarity between two vectors".to_string()
    }
}

pub struct VectorMagnitudeFunction;

impl CustomVectorFunction for VectorMagnitudeFunction {
    fn execute(&self, args: &[VectorServiceArg]) -> Result<VectorServiceResult> {
        if args.len() != 1 {
            return Err(anyhow!(
                "VectorMagnitude requires exactly 1 vector argument"
            ));
        }

        let vector = match &args[0] {
            VectorServiceArg::Vector(v) => v,
            _ => return Err(anyhow!("Argument must be a vector")),
        };

        let magnitude = vector.magnitude();
        Ok(VectorServiceResult::Number(magnitude))
    }

    fn arity(&self) -> usize {
        1
    }

    fn description(&self) -> String {
        "Calculate the magnitude (L2 norm) of a vector".to_string()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_endpoint_registration() {
        let manager = ServiceEndpointManager::new();

        let endpoint = FederatedServiceEndpoint {
            endpoint_uri: "http://example.org/vector-service".to_string(),
            service_type: ServiceType::VectorSearch,
            capabilities: vec![
                ServiceCapability::KNNSearch,
                ServiceCapability::ThresholdSearch,
            ],
            authentication: None,
            retry_config: RetryConfiguration::default(),
            timeout: Duration::from_secs(30),
            health_status: ServiceHealthStatus::Healthy,
        };

        assert!(manager.register_endpoint(endpoint).is_ok());
    }

    #[test]
    fn test_custom_function_registry() {
        let registry = CustomFunctionRegistry::new();

        let metadata = FunctionMetadata {
            name: "cosine_similarity".to_string(),
            description: "Calculate cosine similarity".to_string(),
            parameters: vec![
                ParameterInfo {
                    name: "vector1".to_string(),
                    param_type: ParameterType::Vector,
                    required: true,
                    description: "First vector".to_string(),
                    default_value: None,
                },
                ParameterInfo {
                    name: "vector2".to_string(),
                    param_type: ParameterType::Vector,
                    required: true,
                    description: "Second vector".to_string(),
                    default_value: None,
                },
            ],
            return_type: ReturnType::Number,
            examples: vec!["cosine_similarity(?v1, ?v2)".to_string()],
        };

        let function = Box::new(CosineSimilarityFunction);

        assert!(registry
            .register_function("cosine_similarity".to_string(), function, metadata,)
            .is_ok());

        let functions = registry.list_functions();
        assert!(functions.contains(&"cosine_similarity".to_string()));
    }

    #[test]
    fn test_cosine_similarity_function() -> Result<()> {
        let function = CosineSimilarityFunction;

        let v1 = Vector::new(vec![1.0, 0.0, 0.0]);
        let v2 = Vector::new(vec![1.0, 0.0, 0.0]);

        let args = vec![VectorServiceArg::Vector(v1), VectorServiceArg::Vector(v2)];

        let result = function.execute(&args)?;

        match result {
            VectorServiceResult::Number(similarity) => {
                assert!((similarity - 1.0).abs() < 0.001); // Should be 1.0 for identical vectors
            }
            _ => panic!("Expected number result"),
        }
        Ok(())
    }

    #[test]
    fn test_load_balancer() {
        let balancer = LoadBalancer::new();

        let endpoints = vec![
            FederatedServiceEndpoint {
                endpoint_uri: "http://healthy.example.org".to_string(),
                service_type: ServiceType::VectorSearch,
                capabilities: vec![ServiceCapability::KNNSearch],
                authentication: None,
                retry_config: RetryConfiguration::default(),
                timeout: Duration::from_secs(30),
                health_status: ServiceHealthStatus::Healthy,
            },
            FederatedServiceEndpoint {
                endpoint_uri: "http://unhealthy.example.org".to_string(),
                service_type: ServiceType::VectorSearch,
                capabilities: vec![ServiceCapability::KNNSearch],
                authentication: None,
                retry_config: RetryConfiguration::default(),
                timeout: Duration::from_secs(30),
                health_status: ServiceHealthStatus::Unhealthy,
            },
        ];

        let balanced = balancer.balance_endpoints(endpoints);

        // Should only return healthy endpoints
        assert_eq!(balanced.len(), 1);
        assert_eq!(balanced[0].endpoint_uri, "http://healthy.example.org");
    }
}