ferrous-di 0.2.0

Type-safe, performant dependency injection for Rust, inspired by Microsoft.Extensions.DependencyInjection
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
# Ferrous DI

An enterprise-grade, type-safe dependency injection framework for Rust with advanced features including async support, AOP patterns, module systems, and comprehensive reliability mechanisms.

[![Crates.io](https://img.shields.io/crates/v/ferrous-di)](https://crates.io/crates/ferrous-di)
[![Documentation](https://docs.rs/ferrous-di/badge.svg)](https://docs.rs/ferrous-di)
[![License](https://img.shields.io/crates/l/ferrous-di)](LICENSE)
[![Build Status](https://github.com/s1ntropy/ferrous-di/workflows/CI/badge.svg)](https://github.com/s1ntropy/ferrous-di/actions)
[![Coverage](https://codecov.io/gh/s1ntropy/ferrous-di/branch/main/graph/badge.svg)](https://codecov.io/gh/s1ntropy/ferrous-di)
[![Security Audit](https://github.com/s1ntropy/ferrous-di/workflows/Security%20Audit/badge.svg)](https://github.com/s1ntropy/ferrous-di/actions)

## Features

### Core DI Features
- **Type-safe**: Full compile-time type checking with zero runtime reflection
- **High Performance**: ~78ns singleton resolution, O(1) service lookups
- **Thread-safe**: All APIs are `Send + Sync` with lock-free hot paths
- **Service Lifetimes**: Singleton, Scoped, and Transient with proper isolation
- **Trait Support**: Single bindings and multi-bindings for trait objects
- **Circular Detection**: Comprehensive cycle detection with detailed error paths
- **Memory Safe**: Arc-based sharing with automatic cleanup

### Advanced Features
- **Async Support**: Async factories, lifecycle management, and disposal
- **AOP (Aspect-Oriented Programming)**: Method interception and decoration
- **Module System**: Hierarchical service organization and configuration
- **Diagnostics**: Service graph export, debugging tools, and telemetry
- **Reliability**: Circuit breakers, retries, and fault tolerance patterns
- **Web Integration**: Framework-agnostic patterns for web applications
- **Agent Architecture**: Durable agent patterns with state management
- **Performance Monitoring**: Built-in metrics and performance tracking

### Quality & Reliability
- **Professional Release Process**: Semantic versioning with migration guides
- **Comprehensive Testing**: 200+ tests including mutation and fuzz testing
- **Security Auditing**: Regular dependency and vulnerability scanning
- **Performance Benchmarking**: Automated regression detection
- **API Stability**: Multi-tier stability guarantees with clear deprecation policies

## Quick Start

Add ferrous-di to your `Cargo.toml`:

```toml
[dependencies]
ferrous-di = "0.1"

# With performance optimizations
ferrous-di = { version = "0.1", features = ["performance"] }

# With async support
ferrous-di = { version = "0.1", features = ["async"] }

# With diagnostics and debugging
ferrous-di = { version = "0.1", features = ["diagnostics"] }

# All features enabled
ferrous-di = { version = "0.1", features = ["performance", "async", "diagnostics"] }
```

### Basic Usage

```rust
use ferrous_di::{ServiceCollection, Lifetime};
use std::sync::Arc;

// Define your services
struct Database {
    connection_string: String,
}

struct UserService {
    db: Arc<Database>,
}

trait Logger: Send + Sync {
    fn log(&self, message: &str);
}

struct ConsoleLogger;
impl Logger for ConsoleLogger {
    fn log(&self, message: &str) {
        println!("[LOG] {}", message);
    }
}

// Configure services
let mut services = ServiceCollection::new();

// Register singleton
services.add_singleton(Database {
    connection_string: "postgresql://localhost".to_string(),
});

// Register with factory
services.add_scoped_factory::<UserService, _>(|resolver| {
    UserService {
        db: resolver.get_required::<Database>(),
    }
});

// Register trait
services.add_singleton_trait::<dyn Logger, _>(ConsoleLogger);

// Build provider
let provider = services.build();

// Resolve services
let db = provider.get_required::<Database>();
let logger = provider.get_required_trait::<dyn Logger>();

// Create scope for scoped services
let scope = provider.create_scope();
let user_service = scope.get_required::<UserService>();
```

## Service Lifetimes

### Singleton
Single instance per root provider, cached forever:

```rust
services.add_singleton(ExpensiveResource::new());
services.add_singleton_factory::<Database, _>(|_| {
    Database::connect("postgresql://localhost")
});
```

### Scoped
Single instance per scope, cached for scope lifetime:

```rust
services.add_scoped_factory::<RequestContext, _>(|_| {
    RequestContext::new(generate_request_id())
});

let scope = provider.create_scope();
let ctx1 = scope.get_required::<RequestContext>(); // Creates new
let ctx2 = scope.get_required::<RequestContext>(); // Returns same instance
```

### Transient
New instance per resolution, never cached:

```rust
services.add_transient_factory::<Command, _>(|resolver| {
    Command::new(resolver.get_required::<Database>())
});
```

## Trait Support

### Single Binding (Replace Semantics)
```rust
trait EmailService: Send + Sync {
    fn send(&self, to: &str, subject: &str, body: &str);
}

struct SmtpEmailService;
impl EmailService for SmtpEmailService {
    fn send(&self, to: &str, subject: &str, body: &str) {
        // SMTP implementation
    }
}

// Register trait implementation
services.add_singleton_trait::<dyn EmailService, _>(SmtpEmailService);

// Resolve single implementation
let email_service = provider.get_required_trait::<dyn EmailService>();
```

### Multi-Binding (Append Semantics)
```rust
trait Plugin: Send + Sync {
    fn name(&self) -> &str;
    fn execute(&self);
}

// Register multiple implementations
services.add_trait_implementation::<dyn Plugin, _>(AuthPlugin, Lifetime::Singleton);
services.add_trait_implementation::<dyn Plugin, _>(LoggingPlugin, Lifetime::Singleton);
services.add_trait_implementation::<dyn Plugin, _>(MetricsPlugin, Lifetime::Transient);

// Resolve all implementations
let plugins = provider.get_all_trait::<dyn Plugin>().unwrap();
for plugin in plugins {
    plugin.execute();
}
```

## Error Handling

Ferrous DI provides detailed error information:

```rust
use ferrous_di::DiError;

match provider.get::<UnregisteredService>() {
    Ok(service) => { /* use service */ }
    Err(DiError::NotFound(name)) => {
        eprintln!("Service not found: {}", name);
    }
    Err(DiError::Circular(path)) => {
        eprintln!("Circular dependency: {}", path.join(" -> "));
    }
    Err(DiError::WrongLifetime(msg)) => {
        eprintln!("Lifetime error: {}", msg);
    }
    Err(e) => {
        eprintln!("DI error: {}", e);
    }
}
```

For convenience, use the `get_required_*` methods that panic on error:

```rust
let service = provider.get_required::<MyService>(); // Panics if not found
let trait_service = provider.get_required_trait::<dyn MyTrait>();
```

## Advanced Examples

### Web Server with Request Scoping

See [examples/web_server_scope.rs](examples/web_server_scope.rs) for a complete example showing:

- Singleton services (database, configuration)
- Scoped services (request context, user session)
- Dependency injection in request handlers
- Proper scope isolation per HTTP request

```bash
cargo run --example web_server_scope
```

### Modular Service Registration

See [examples/modular_registration.rs](examples/modular_registration.rs) for advanced patterns:

```bash
cargo run --example modular_registration
```

### Durable Agent Architecture

See [examples/durable-agent/](examples/durable-agent/) for a complete agent system:

```bash
cd examples/durable-agent
cargo run
```

### Async Service Patterns

```rust
use ferrous_di::async_factories::AsyncFactory;

// Async service factory
struct DatabaseConnection;

#[async_trait]
impl AsyncFactory<DatabaseConnection> for DatabaseConnectionFactory {
    async fn create(&self, resolver: &dyn Resolver) -> DiResult<DatabaseConnection> {
        let config = resolver.get_required::<DatabaseConfig>();
        DatabaseConnection::connect(&config.url).await
    }
}

services.add_async_singleton_factory(DatabaseConnectionFactory);
```

### AOP and Service Decoration

```rust
use ferrous_di::decoration::ServiceDecorator;

// Logging decorator
struct LoggingDecorator<T> {
    inner: Arc<T>,
    logger: Arc<dyn Logger>,
}

impl<T: UserService> UserService for LoggingDecorator<T> {
    fn get_user(&self, id: UserId) -> Result<User, UserError> {
        self.logger.info(&format!("Getting user {}", id));
        let result = self.inner.get_user(id);
        match &result {
            Ok(_) => self.logger.info("User retrieved successfully"),
            Err(e) => self.logger.error(&format!("Failed to get user: {}", e)),
        }
        result
    }
}

services.add_decorator::<dyn UserService, _>(LoggingDecoratorFactory);
```

### Complex Dependency Graphs

```rust
struct Config { /* ... */ }
struct Database { config: Arc<Config> }
struct UserRepository { db: Arc<Database> }
struct UserService { repo: Arc<UserRepository> }

services.add_singleton(Config::load());
services.add_singleton_factory::<Database, _>(|r| {
    Database::new(r.get_required::<Config>())
});
services.add_scoped_factory::<UserRepository, _>(|r| {
    UserRepository::new(r.get_required::<Database>())
});
services.add_transient_factory::<UserService, _>(|r| {
    UserService::new(r.get_required::<UserRepository>())
});
```

### Module-Based Organization

```rust
use ferrous_di::collection::Module;

// Database module
struct DatabaseModule;
impl Module for DatabaseModule {
    fn configure(&self, services: &mut ServiceCollection) -> DiResult<()> {
        services.add_singleton_factory::<DatabasePool, _>(|r| {
            DatabasePool::new(r.get_required::<DatabaseConfig>())
        });
        services.add_scoped_factory::<UnitOfWork, _>(|r| {
            UnitOfWork::new(r.get_required::<DatabasePool>())
        });
        Ok(())
    }
}

// Application composition
let mut services = ServiceCollection::new();
services.add_module(DatabaseModule)?;
services.add_module(BusinessLogicModule)?;
services.add_module(WebModule)?;
```

## Performance

Ferrous DI is designed for high-performance dependency injection with enterprise-grade capabilities.

### Benchmark Results

Measured on Apple Silicon, compiled with `--release`:

| Operation | Time | Notes |
|-----------|------|-------|
| **Singleton hit** | ~78ns | Cached singleton resolution (hot path) |
| **Singleton cold** | ~437ns | First-time singleton creation with factory |
| **Scoped hit** | ~83ns | Cached scoped service within same scope |
| **Transient** | ~68ns | Fresh instance creation each time |
| **Concrete vs Trait** | ~86ns vs ~82ns | Minimal difference between concrete and trait |
| **Multi-binding (16 services)** | ~850ns | Resolving all 16 implementations |
| **Scope create/drop** | ~18ns | Empty scope lifecycle overhead |
| **Circular detection (depth 8)** | ~87ns | Deep dependency chain validation |
| **Using pattern (empty)** | ~152ns | Minimal overhead for scoped disposal |
| **Mixed workload** | ~872ns | Realistic 70/20/10 singleton/scoped/transient mix |

#### Contention Performance

| Threads | Time per Op | Throughput | Scaling |
|---------|------------|------------|---------|
| 1 thread | ~79ns | ~12.6M ops/sec | Baseline |
| 2 threads | ~155ns | ~12.9M ops/sec total | Good parallelization |
| 4 threads | ~206ns | ~19.4M ops/sec total | Continued scaling |
| 8 threads | ~168ns | ~47.6M ops/sec total | Excellent multi-core utilization |

### Performance Features

Enable high-performance optimizations with Cargo features:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["performance"] }
```

This enables all performance features:

- **`parking-lot`**: Faster mutex implementation (2-3x faster locking)
- **`ahash`**: High-performance hashing algorithm 
- **`smallvec`**: Stack-allocated vectors for small circular detection stacks
- **`once-cell`**: Lock-free singleton caching (planned)

#### Individual Features

Enable features selectively if you prefer:

```toml
[dependencies]  
ferrous-di = { version = "0.1", features = ["parking-lot", "ahash"] }
```

### Reproduction Instructions

To reproduce benchmarks on your hardware:

```bash
# Clone the repository
git clone https://github.com/s1ntropy/ferrous-di
cd ferrous-di

# Run benchmarks with performance features
cargo bench --features performance

# Run specific benchmarks
cargo bench --features performance -- singleton_hit
cargo bench --features performance -- contention
cargo bench --features performance -- mixed_workload

# Generate HTML reports (if gnuplot available)
cargo bench --features performance -- --output-format html
```

### Performance Optimizations

The library implements several performance optimizations:

1. **TypeId-based lookups**: O(1) service resolution using TypeId hash keys
2. **Arc-based sharing**: Zero-copy service instance sharing
3. **Minimal allocations**: Pre-allocated vectors, stack-allocated small collections
4. **Lock optimization**: Parking-lot mutexes for reduced contention
5. **Hash optimization**: AHash for faster HashMap operations
6. **Hot path optimization**: Singleton resolution avoids locks when possible

### Release Profile

The library is optimized with aggressive release settings:

```toml
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = false
```

This provides maximum performance for production use.

## Feature Flags

### Core Features

#### `std` (default)
Standard library support with std collections and threading:

```toml
[dependencies]
ferrous-di = "0.1"  # includes std by default
```

#### `async`
Enable async factories and lifecycle management:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["async"] }
```

```rust
use ferrous_di::async_factories::AsyncFactory;

// Async service creation
services.add_async_singleton_factory(DatabaseConnectionFactory);
let connection = provider.get_async::<DatabaseConnection>().await?;
```

### Performance Features

#### `performance`
Enable all performance optimizations:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["performance"] }
```

Individual performance features:
- **`parking-lot`**: Faster mutex implementation (2-3x faster locking)
- **`ahash`**: High-performance hashing algorithm 
- **`smallvec`**: Stack-allocated vectors for small collections
- **`once-cell`**: Lock-free singleton caching (experimental)

### Development Features

#### `diagnostics`
Enable comprehensive debugging and diagnostic tools:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["diagnostics"] }
```

```rust
#[cfg(feature = "diagnostics")]
{
    // Service graph visualization
    let graph = provider.export_service_graph()?;
    println!("{}", graph.to_dot_format());
    
    // Debugging information
    println!("{}", provider.to_debug_string());
    
    // Performance metrics
    let metrics = provider.get_metrics();
    println!("Resolution time: {:?}", metrics.avg_resolution_time);
}
```

#### `validation`
Enable service validation and health checks:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["validation"] }
```

### Integration Features

#### `web`
Web framework integration patterns:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["web"] }
```

#### `metrics`
Built-in metrics and telemetry:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["metrics"] }
```

### Experimental Features

#### `experimental`
Cutting-edge features under development:

```toml
[dependencies]
ferrous-di = { version = "0.1", features = ["experimental"] }
```

โš ๏ธ **Note**: Experimental features may change or be removed in minor versions.

## Testing & Quality Assurance

### Running Tests

Run the complete test suite:

```bash
cargo test
```

Run specific test categories:

```bash
cargo test basics              # Basic functionality tests
cargo test scopes              # Scoped service tests  
cargo test circular            # Circular dependency tests
cargo test advanced_features   # Named services, metadata, TryAdd
cargo test agent_features      # Durable agent patterns
cargo test modules             # Module system tests
cargo test disposal            # Resource cleanup tests
```

### Quality Gates

#### Mutation Testing
Test the quality of your tests with mutation testing:

```bash
cargo install cargo-mutants
cargo mutants
```

#### Fuzzing
Run property-based and fuzz testing:

```bash
cargo install cargo-fuzz
cargo fuzz run dependency_injection
cargo fuzz run service_registration
cargo fuzz run service_resolution
```

#### Security Auditing
Scan for security vulnerabilities:

```bash
cargo audit
```

#### Performance Benchmarking
Run performance benchmarks:

```bash
cargo bench --features performance
```

#### Code Coverage
Generate code coverage reports:

```bash
cargo install cargo-tarpaulin
cargo tarpaulin --out html --features performance
```


## Development Roadmap

### Completed Features โœ…
- **Phase 1**: Modular architecture with 25+ specialized modules
- **Phase 2**: Comprehensive CI/CD with multi-platform testing
- **Phase 3**: Complete documentation with examples and guides
- **Phase 4**: Advanced development tools and diagnostics
- **Phase 5**: Comprehensive testing (unit, integration, mutation, fuzz)
- **Phase 6**: Performance optimization and production readiness
- **Phase 7**: Professional release engineering process

### Current & Upcoming Features ๐Ÿšง
- **Phase 8**: Advanced agent features with state persistence
- **Phase 9**: Ecosystem integration and framework adapters
- **Phase 10**: API stabilization and v1.0 preparation

### Version Releases
- **v0.1**: Core DI with lifetimes, traits, circular detection โœ…
- **v0.2**: Async support, AOP patterns, module system
- **v0.3**: Advanced diagnostics, reliability patterns
- **v0.4**: Web integration, performance optimizations
- **v0.5**: Agent architecture, state management
- **v1.0**: Stable API, comprehensive ecosystem integration

### Long-term Vision
- **Enterprise Integration**: Support for complex enterprise patterns
- **Framework Ecosystem**: Deep integration with popular Rust frameworks
- **Cloud Native**: Kubernetes, service mesh, and cloud platform support
- **Tooling Ecosystem**: IDE extensions, debugging tools, and analysis

See [ROADMAP.md](ROADMAP.md) for detailed feature plans and timelines.

## Contributing

We welcome contributions from the community! This project follows professional development practices:

### Getting Started
1. Read [CONTRIBUTING.md]CONTRIBUTING.md for detailed guidelines
2. Check [CODE_OF_CONDUCT.md]CODE_OF_CONDUCT.md for community standards
3. Review [ARCHITECTURE.md]ARCHITECTURE.md to understand the codebase

### Development Process
- **Quality Gates**: All PRs must pass comprehensive testing and validation
- **Conventional Commits**: Follow conventional commit format for automatic changelog generation
- **API Stability**: Review [API_STABILITY.md]API_STABILITY.md for compatibility requirements
- **Release Process**: Understand our professional release engineering in [RELEASE_CHECKLIST.md]RELEASE_CHECKLIST.md

### Areas for Contribution
- ๐Ÿ› **Bug Fixes**: Help improve reliability and correctness
- ๐Ÿš€ **Performance**: Optimize hot paths and memory usage
- ๐Ÿ“š **Documentation**: Improve examples, guides, and API docs
- ๐Ÿงช **Testing**: Add test coverage, property tests, or benchmarks
- ๐Ÿ”ง **Tooling**: IDE integration, debugging tools, or analysis
- ๐ŸŒ **Integration**: Framework adapters and ecosystem support

### Security
For security vulnerabilities, please see [SECURITY.md](SECURITY.md) for responsible disclosure.

## License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE)
- MIT License ([LICENSE-MIT]LICENSE-MIT)

at your option.

---

## Project Status

Ferrous DI is actively developed and maintained with professional development practices:

- **๐Ÿ—๏ธ Architecture**: Enterprise-grade modular design
- **๐Ÿงช Testing**: 200+ tests with comprehensive coverage
- **๐Ÿ“š Documentation**: Complete API docs and examples
- **๐Ÿš€ Performance**: Production-ready with benchmarking
- **๐Ÿ”’ Security**: Regular auditing and vulnerability scanning
- **๐Ÿ“‹ Quality**: Professional release process with validation
- **๐Ÿค Community**: Open source with contributor guidelines

**Ready for Production**: Suitable for enterprise applications requiring high performance, reliability, and maintainability.

For questions, issues, or contributions, visit our [GitHub repository](https://github.com/s1ntropy/ferrous-di).

## Architecture & Design Philosophy

### Comparison with Microsoft.Extensions.DependencyInjection

| Feature | Ferrous DI | MS.DI | Notes |
|---------|------------|-------|-------|
| **Type Safety** | Compile-time | Runtime | Zero-cost abstractions vs reflection |
| **Performance** | ~78ns resolution | ~1000ns+ | TypeId-based O(1) lookups |
| **Memory Safety** | Built-in Arc sharing | Manual lifecycle | Rust ownership + Arc |
| **Async Support** | Native async/await | Task-based | First-class async factories |
| **Lifetimes** | Singleton, Scoped, Transient | Same | Compatible lifecycle semantics |
| **Multi-binding** | Explicit append semantics | Implicit append | Clear intention |
| **Circular Detection** | Compile + Runtime | Runtime | Multi-layered protection |
| **Thread Safety** | Lock-free hot paths | Thread-safe | Optimized for concurrent access |
| **Modularity** | Hierarchical modules | Service collections | Advanced composition |
| **Diagnostics** | Built-in graph export | Limited | Rich debugging capabilities |
| **AOP Support** | Native decoration | Third-party | Built-in interception |
| **Reliability** | Circuit breakers, retries | Manual | Enterprise patterns |

### Design Principles

1. **Zero-Cost Abstractions**: Compile-time optimization with runtime efficiency
2. **Memory Safety**: Rust ownership system prevents common DI pitfalls
3. **Performance First**: Designed for high-throughput, low-latency applications
4. **Enterprise Ready**: Professional patterns for complex applications
5. **Developer Experience**: Rich diagnostics and clear error messages
6. **Ecosystem Integration**: Framework-agnostic with deep integration support

### Unique Features

- **Agent Architecture**: Durable agent patterns with state management
- **Module System**: Hierarchical service organization and configuration
- **Performance Monitoring**: Built-in metrics and telemetry
- **Reliability Patterns**: Circuit breakers, retries, and fault tolerance
- **Professional Release Process**: Enterprise-grade release engineering
- **Comprehensive Testing**: Mutation testing, fuzzing, and property-based testing