Skip to content

[EPIC] refactor: Consolidate cross-system infrastructure components #314

Description

@kcenon

Summary

Consolidate commonly duplicated infrastructure components across the ecosystem into common_system, following Kent Beck's Simple Design principles (No Duplication, Fewest Elements).

Background (Why)

Kent Beck's Principles Violations

Principle Issue Impact
No Duplication circuit_breaker exists in 3 systems Maintenance burden, inconsistent behavior
Fewest Elements Each system has its own stats structs Unnecessary complexity
Reveals Intention Placeholder implementations in bootstrapper Unclear system boundaries

Current Problems

  1. circuit_breaker duplication: Exists in thread_system, monitoring_system, and network_system
  2. Result pattern duplication: Each system may have its own error handling
  3. Stats interface fragmentation: No common interface for statistics collection
  4. Incomplete bootstrapper: register_core_services() and register_optional_services() are empty

Scope (What)

Components to Consolidate

common_system/include/kcenon/common/
├── resilience/
│   ├── circuit_breaker.h        # Moved from thread/monitoring/network
│   ├── retry_policy.h           # Common retry logic
│   └── error_boundary.h         # Common error handling
├── patterns/
│   └── stats_interface.h        # IStats common interface
└── di/
    └── unified_bootstrapper.h   # Complete implementation

Migration Strategy

  1. Extract common interface from existing implementations
  2. Implement in common_system with configuration options
  3. Update dependent systems to use common_system version
  4. Deprecate and remove duplicates

Child Issues

  • [Task] Extract common circuit_breaker to common_system
  • [Task] Create IStats common interface for statistics
  • [Task] Implement register_core_services() in unified_bootstrapper
  • [Task] Implement register_optional_services() in unified_bootstrapper
  • [Task] Complete IServiceScope implementation for scoped DI
  • [Task] Simplify result.h header structure

Acceptance Criteria

  • Single circuit_breaker implementation in common_system
  • Common IStats interface adopted by all systems
  • unified_bootstrapper fully functional
  • Scoped service resolution works correctly
  • All dependent system tests pass after migration
  • No duplicate circuit_breaker in thread/monitoring/network systems

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitectural changes and designepicEpic issue tracking multiple sub-taskspriority:highHigh priority issuerefactoringCode refactoring and improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions