Summary
Strengthen messaging_system's optional dependency guards to ensure clean builds in isolation and provide robust fallback implementations when optional dependencies are unavailable.
5W1H Specification
- Who: messaging_system maintainers
- What: Audit and strengthen conditional compilation guards for optional dependencies
- Where:
adapters/, collectors/, CMakeLists.txt
- When: v0.4.0.0 release cycle
- Why:
- messaging_system has multiple optional dependencies (network, monitoring)
- Guards must be consistent and complete
- Fallback implementations must be functional, not just compile stubs
- How:
- Audit all
#if KCENON_WITH_* guards
- Ensure each guarded section has a fallback
- Add CMake preset for isolated build testing
Priority
MEDIUM - Risk level: LOW per CROSS_MODULE_INTEGRATION.md (required deps are lower tier)
Current Dependency Analysis
| Dependency |
Type |
Guard |
Fallback |
| common_system |
REQUIRED |
None |
N/A |
| thread_system |
REQUIRED |
None |
N/A |
| container_system |
REQUIRED |
None |
N/A |
| network_system |
OPTIONAL |
KCENON_WITH_NETWORK_SYSTEM |
error::not_supported |
| monitoring_system |
OPTIONAL |
KCENON_WITH_MONITORING_SYSTEM |
stub class |
Current Guard Files
| File |
Guard |
Purpose |
adapters/http_transport.h |
#if KCENON_WITH_NETWORK_SYSTEM |
HTTP message transport |
adapters/websocket_transport.h |
#if KCENON_WITH_NETWORK_SYSTEM |
WebSocket transport |
collectors/message_bus_collector.h |
#if KCENON_WITH_MONITORING_SYSTEM |
Bus metrics |
Issues to Address
1. Incomplete Fallback for network_system
// Current: Returns error for all operations
#if !KCENON_WITH_NETWORK_SYSTEM
class http_transport {
auto send(const message& msg) -> Result<void> {
return error::not_supported("network_system not available");
}
};
#endif
// Improved: Add compile-time detection + runtime check
#if !KCENON_WITH_NETWORK_SYSTEM
class http_transport {
public:
static constexpr bool is_available = false;
auto send(const message& msg) -> Result<void> {
static_assert(!is_available,
"http_transport requires KCENON_WITH_NETWORK_SYSTEM");
return error::not_supported("network_system not available");
}
};
#else
class http_transport {
public:
static constexpr bool is_available = true;
// ... actual implementation
};
#endif
2. Missing Fallback for monitoring_system
// Current: May have incomplete stub
#if KCENON_WITH_MONITORING_SYSTEM
class message_bus_collector { /* real impl */ };
#else
class message_bus_collector { /* needs verification */ };
#endif
// Improved: Explicit null implementation
#if !KCENON_WITH_MONITORING_SYSTEM
class null_message_bus_collector {
public:
void record_message_sent(const message&) { /* no-op */ }
void record_message_received(const message&) { /* no-op */ }
void record_error(std::string_view) { /* no-op */ }
static auto instance() -> null_message_bus_collector& {
static null_message_bus_collector instance;
return instance;
}
};
using message_bus_collector = null_message_bus_collector;
#endif
Tasks
CMake Isolated Build Preset
# CMakePresets.json
{
"configurePresets": [
{
"name": "isolated",
"displayName": "Isolated Build (no optional deps)",
"description": "Build with only required dependencies",
"cacheVariables": {
"KCENON_WITH_NETWORK_SYSTEM": "OFF",
"KCENON_WITH_MONITORING_SYSTEM": "OFF"
}
}
]
}
Acceptance Criteria
Verification Script
#!/bin/bash
# scripts/verify_isolated_build.sh
echo "Building messaging_system without optional dependencies..."
cmake -B build_isolated \
-DKCENON_WITH_NETWORK_SYSTEM=OFF \
-DKCENON_WITH_MONITORING_SYSTEM=OFF
cmake --build build_isolated
echo "Running tests in isolated mode..."
ctest --test-dir build_isolated --output-on-failure
echo "Isolated build verification complete."
Dependencies
- None - This is a hardening task
Parent Epic
Related Issues
Summary
Strengthen messaging_system's optional dependency guards to ensure clean builds in isolation and provide robust fallback implementations when optional dependencies are unavailable.
5W1H Specification
adapters/,collectors/, CMakeLists.txt#if KCENON_WITH_*guardsPriority
MEDIUM - Risk level: LOW per CROSS_MODULE_INTEGRATION.md (required deps are lower tier)
Current Dependency Analysis
KCENON_WITH_NETWORK_SYSTEMerror::not_supportedKCENON_WITH_MONITORING_SYSTEMCurrent Guard Files
adapters/http_transport.h#if KCENON_WITH_NETWORK_SYSTEMadapters/websocket_transport.h#if KCENON_WITH_NETWORK_SYSTEMcollectors/message_bus_collector.h#if KCENON_WITH_MONITORING_SYSTEMIssues to Address
1. Incomplete Fallback for network_system
2. Missing Fallback for monitoring_system
Tasks
KCENON_WITH_*guards#elsefallbackstatic constexpr bool is_availableto each optional componentCMake Isolated Build Preset
Acceptance Criteria
cmake --preset=isolated && cmake --build --preset=isolatedsucceedsis_availableconstexprVerification Script
Dependencies
Parent Epic
Related Issues