# Pull Request: Sprint 9 - Task 19: Dependency Injection for Worker Pool
**Branch:** `claude/code-review-analysis-01VdzHhgB4j3anBVcS6Wicoc`
**Base:** `main`
**Status:** ✅ Ready for Review
## Summary
Refactored acceleration router from global singleton to class-based architecture with dependency injection support, enabling better testability and multiple worker pool management.
## Changes
### Architecture Improvements
- ✅ Removed global singleton pattern from `acceleration-router.ts`
- ✅ Created `AccelerationRouter` class with DI support
- ✅ Added `WorkerPoolManager` for managing multiple named pools
- ✅ Maintained 100% backward compatibility
### New Features
**AccelerationRouter Class:**
- Constructor accepts optional `WorkerPool` for DI
- `initialize()` - lazy pool creation
- `shutdown()` - lifecycle management (skips injected pools)
- All routing methods as instance methods
**WorkerPoolManager:**
- `createPool(name, config)` - named pool creation
- `getPool(name)` - pool retrieval
- `removePool(name)` - pool removal
- `shutdownAll()` - graceful shutdown
- `getAllStats()` / `getAggregateStats()` - metrics
## Testing
**New Tests:** 52 (100% passing)
- `test/unit/workers/pool-manager.test.ts` (24 tests)
- `test/unit/acceleration-router-di.test.ts` (28 tests)
**Total:** 713 tests (470 unit + 232 correctness + 11 integration)
## Files
**Created:**
- `src/workers/pool-manager.ts`
- `test/unit/workers/pool-manager.test.ts`
- `test/unit/acceleration-router-di.test.ts`
**Modified:**
- `src/acceleration-router.ts` (class-based refactor)
- `src/index-wasm.ts` (DI examples)
- `CHANGELOG.md`
## Verification
```bash
npm run type-check # ✅ Pass
npm test # ✅ 713/713 passing
```
## Migration
```typescript
// Old (still works)
const result = await routedMatrixMultiply(a, b);
// New (recommended)
const router = new AccelerationRouter();
await router.initialize();
const { result } = await router.matrixMultiply(a, b);
await router.shutdown();
```
---
**Sprint 9 Progress:** Task 19 ✅ | Tasks 20, 22, 23 ⏳