Skip to content

Commit 1329330

Browse files
authored
docs(refactor): add Phase 1 preparation for internal header migration (#611)
Prepare for moving 118 implementation headers to src/internal/ as part of Epic #577 to reduce public API surface from 153 to < 40 headers. Changes: - Add comprehensive header audit document categorizing all 153 headers - Create migration guide with facade API usage examples - Add deprecation warnings to core headers (TCP/UDP client/server) - Document 4-phase refactoring plan The deprecation warnings inform users about upcoming v2.0 changes and direct them to use facade API instead of direct implementation headers. Users can suppress warnings with NETWORK_SYSTEM_SUPPRESS_DEPRECATION_WARNINGS. Files added: - docs/refactoring/HEADER_AUDIT_PHASE1.md - docs/refactoring/MIGRATION_GUIDE_V2.md - docs/refactoring/README.md Files modified: - include/kcenon/network/core/messaging_client.h - include/kcenon/network/core/messaging_server.h - include/kcenon/network/core/messaging_udp_client.h - include/kcenon/network/core/messaging_udp_server.h Related: #610, #577
1 parent 0948959 commit 1329330

7 files changed

Lines changed: 968 additions & 21 deletions

File tree

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# Header Audit - Phase 1: Preparation for Internal Migration
2+
3+
> **Issue**: #610
4+
> **Epic**: #577
5+
> **Date**: 2026-02-02
6+
> **Goal**: Reduce public headers from 153 to < 40 by moving implementation details to `src/internal/`
7+
8+
## Executive Summary
9+
10+
- **Current**: 153 public headers
11+
- **Target**: < 40 public headers
12+
- **Reduction**: ~113 headers (74%) to be moved to internal
13+
- **Approach**: Aggressive facade-first API with internal implementation hiding
14+
15+
## Public API (Keep in `include/`) - 35 headers
16+
17+
### Category 1: Facades (4 headers) ✅ KEEP
18+
Primary user-facing API for protocol access.
19+
20+
| Header | Purpose | Status |
21+
|--------|---------|--------|
22+
| `facade/tcp_facade.h` | TCP client/server factory | ✅ Public API |
23+
| `facade/udp_facade.h` | UDP client/server factory | ✅ Public API |
24+
| `facade/http_facade.h` | HTTP client/server factory | ✅ Public API |
25+
| `facade/websocket_facade.h` | WebSocket client/server factory | ✅ Public API |
26+
27+
### Category 2: Interfaces (14 headers) ✅ KEEP
28+
Abstract interfaces that define contracts.
29+
30+
| Header | Purpose | Status |
31+
|--------|---------|--------|
32+
| `interfaces/i_protocol_client.h` | Common protocol client interface | ✅ Public API |
33+
| `interfaces/i_protocol_server.h` | Common protocol server interface | ✅ Public API |
34+
| `interfaces/i_client.h` | Generic client interface | ✅ Public API |
35+
| `interfaces/i_server.h` | Generic server interface | ✅ Public API |
36+
| `interfaces/i_session.h` | Session interface | ✅ Public API |
37+
| `interfaces/i_udp_client.h` | UDP-specific client interface | ✅ Public API |
38+
| `interfaces/i_udp_server.h` | UDP-specific server interface | ✅ Public API |
39+
| `interfaces/i_websocket_client.h` | WebSocket-specific client interface | ✅ Public API |
40+
| `interfaces/i_websocket_server.h` | WebSocket-specific server interface | ✅ Public API |
41+
| `interfaces/i_quic_client.h` | QUIC-specific client interface | ✅ Public API |
42+
| `interfaces/i_quic_server.h` | QUIC-specific server interface | ✅ Public API |
43+
| `interfaces/i_network_component.h` | Base network component interface | ✅ Public API |
44+
| `interfaces/connection_observer.h` | Connection event observer | ✅ Public API |
45+
| `interfaces/interfaces.h` | Interface header aggregator | ✅ Public API |
46+
47+
### Category 3: Integration (13 headers) ✅ KEEP
48+
High-level integration and bridge components.
49+
50+
| Header | Purpose | Status |
51+
|--------|---------|--------|
52+
| `integration/network_system_bridge.h` | Unified integration facade | ✅ Public API |
53+
| `integration/i_network_bridge.h` | Network bridge interface | ✅ Public API |
54+
| `integration/messaging_bridge.h` | Messaging integration bridge | ✅ Public API |
55+
| `integration/observability_bridge.h` | Logger/monitor integration | ✅ Public API |
56+
| `integration/adapters/message_adapter.h` | Message format adapter | ✅ Public API |
57+
| `integration/adapters/bytes_adapter.h` | Bytes format adapter | ✅ Public API |
58+
| `integration/adapters/json_adapter.h` | JSON format adapter | ✅ Public API |
59+
| `integration/adapters/compressed_adapter.h` | Compression adapter | ✅ Public API |
60+
| `integration/legacy_messaging_adapter.h` | Legacy compatibility adapter | ✅ Public API |
61+
| `integration/logger_integration.h` | Logger integration | ✅ Public API |
62+
| `integration/monitor_integration.h` | Monitor integration | ✅ Public API |
63+
| `integration/circuit_breaker_integration.h` | Circuit breaker integration | ✅ Public API |
64+
| `integration/observer_integration.h` | Observer integration | ✅ Public API |
65+
66+
### Category 4: High-Level Utilities (4 headers) ✅ KEEP
67+
Essential utilities for using the library.
68+
69+
| Header | Purpose | Status |
70+
|--------|---------|--------|
71+
| `network_system.h` | Main library header | ✅ Public API |
72+
| `core/network_context.h` | ASIO context wrapper | ✅ Public API |
73+
| `core/connection_pool.h` | Connection pooling | ✅ Public API |
74+
| `core/session_handle.h` | Type-erased session handle | ✅ Public API |
75+
76+
**Total Public API: 35 headers**
77+
78+
---
79+
80+
## Internal Implementation (Move to `src/internal/`) - 118 headers
81+
82+
### Category 5: Core Protocol Implementations (27 headers) 🔄 MOVE TO INTERNAL
83+
Concrete implementations accessed via facades.
84+
85+
#### TCP Implementations (6 headers)
86+
| Header | Destination | Facade Replacement |
87+
|--------|-------------|-------------------|
88+
| `core/messaging_client.h` | `src/internal/tcp/messaging_client.h` | `tcp_facade::create_client()` |
89+
| `core/messaging_server.h` | `src/internal/tcp/messaging_server.h` | `tcp_facade::create_server()` |
90+
| `core/secure_messaging_client.h` | `src/internal/tcp/secure_messaging_client.h` | `tcp_facade::create_client({.use_ssl=true})` |
91+
| `core/secure_messaging_server.h` | `src/internal/tcp/secure_messaging_server.h` | `tcp_facade::create_server({.use_ssl=true})` |
92+
| `core/unified_messaging_client.h` | `src/internal/tcp/unified_messaging_client.h` | Use facade |
93+
| `core/unified_messaging_client.inl` | `src/internal/tcp/unified_messaging_client.inl` | Internal template |
94+
95+
#### UDP Implementations (7 headers)
96+
| Header | Destination | Facade Replacement |
97+
|--------|-------------|-------------------|
98+
| `core/messaging_udp_client.h` | `src/internal/udp/messaging_udp_client.h` | `udp_facade::create_client()` |
99+
| `core/messaging_udp_server.h` | `src/internal/udp/messaging_udp_server.h` | `udp_facade::create_server()` |
100+
| `core/secure_messaging_udp_client.h` | `src/internal/udp/secure_messaging_udp_client.h` | `udp_facade::create_client({.use_ssl=true})` |
101+
| `core/secure_messaging_udp_server.h` | `src/internal/udp/secure_messaging_udp_server.h` | `udp_facade::create_server({.use_ssl=true})` |
102+
| `core/reliable_udp_client.h` | `src/internal/udp/reliable_udp_client.h` | Use facade with reliability option |
103+
| `core/unified_udp_messaging_client.h` | `src/internal/udp/unified_udp_messaging_client.h` | Use facade |
104+
| `core/unified_udp_messaging_client.inl` | `src/internal/udp/unified_udp_messaging_client.inl` | Internal template |
105+
106+
#### HTTP/WebSocket Implementations (8 headers)
107+
| Header | Destination | Facade Replacement |
108+
|--------|-------------|-------------------|
109+
| `core/http_client.h` | `src/internal/http/http_client.h` | `http_facade::create_client()` |
110+
| `core/http_server.h` | `src/internal/http/http_server.h` | `http_facade::create_server()` |
111+
| `http/http_client.h` | `src/internal/http/http_client_impl.h` | Duplicate, consolidate |
112+
| `http/http_server.h` | `src/internal/http/http_server_impl.h` | Duplicate, consolidate |
113+
| `core/messaging_ws_client.h` | `src/internal/websocket/messaging_ws_client.h` | `websocket_facade::create_client()` |
114+
| `core/messaging_ws_server.h` | `src/internal/websocket/messaging_ws_server.h` | `websocket_facade::create_server()` |
115+
| `http/websocket_client.h` | `src/internal/websocket/websocket_client_impl.h` | Duplicate, consolidate |
116+
| `http/websocket_server.h` | `src/internal/websocket/websocket_server_impl.h` | Duplicate, consolidate |
117+
118+
#### QUIC Implementations (3 headers)
119+
| Header | Destination | Facade Replacement |
120+
|--------|-------------|-------------------|
121+
| `core/messaging_quic_client.h` | `src/internal/quic/messaging_quic_client.h` | Future QUIC facade |
122+
| `core/messaging_quic_server.h` | `src/internal/quic/messaging_quic_server.h` | Future QUIC facade |
123+
| `experimental/quic_client.h` | `src/internal/quic/experimental_quic_client.h` | Experimental API |
124+
125+
#### Session Management Implementations (3 headers)
126+
| Header | Destination | Facade Replacement |
127+
|--------|-------------|-------------------|
128+
| `core/session_manager.h` | `src/internal/session/session_manager.h` | Internal, accessed via server |
129+
| `session/messaging_session.h` | `src/internal/session/messaging_session.h` | Internal session impl |
130+
| `session/secure_session.h` | `src/internal/session/secure_session.h` | Internal session impl |
131+
132+
### Category 6: Protocol Implementation Details (31 headers) 🔄 MOVE TO INTERNAL
133+
134+
#### QUIC Protocol (19 headers)
135+
All QUIC protocol headers are internal implementation details:
136+
137+
| Header | Destination |
138+
|--------|-------------|
139+
| `protocols/quic/*.h` (19 files) | `src/internal/quic/protocol/` |
140+
141+
Examples:
142+
- `protocols/quic/quic_connection.h``src/internal/quic/protocol/quic_connection.h`
143+
- `protocols/quic/quic_stream.h``src/internal/quic/protocol/quic_stream.h`
144+
- `protocols/quic/crypto.h``src/internal/quic/protocol/crypto.h`
145+
146+
#### HTTP2 Protocol (6 headers)
147+
| Header | Destination |
148+
|--------|-------------|
149+
| `protocols/http2/*.h` (6 files) | `src/internal/http/http2/` |
150+
151+
#### gRPC Protocol (6 headers)
152+
| Header | Destination |
153+
|--------|-------------|
154+
| `protocols/grpc/*.h` (6 files) | `src/internal/grpc/` |
155+
156+
### Category 7: Internal Utilities (7 headers) 🔄 MOVE TO INTERNAL
157+
158+
| Header | Destination | Reason |
159+
|--------|-------------|--------|
160+
| `utils/buffer_pool.h` | `src/internal/utils/buffer_pool.h` | Implementation detail |
161+
| `utils/connection_tracker.h` | `src/internal/utils/connection_tracker.h` | Implementation detail |
162+
| `utils/retry_policy.h` | `src/internal/utils/retry_policy.h` | Implementation detail |
163+
| `utils/timeout_manager.h` | `src/internal/utils/timeout_manager.h` | Implementation detail |
164+
| `core/callback_indices.h` | `src/internal/utils/callback_indices.h` | Internal helper |
165+
| `core/session_concept.h` | `src/internal/session/session_concept.h` | C++20 concept, internal |
166+
| `core/session_model.h` | `src/internal/session/session_model.h` | Type erasure impl |
167+
168+
### Category 8: Experimental Features (4 headers) 🔄 MOVE TO INTERNAL
169+
170+
| Header | Destination | Reason |
171+
|--------|-------------|--------|
172+
| `experimental/quic_server.h` | `src/internal/quic/experimental_quic_server.h` | Unstable API |
173+
| `experimental/reliable_udp_client.h` | `src/internal/udp/experimental_reliable_udp_client.h` | Experimental |
174+
| `experimental/experimental_api.h` | `src/internal/experimental/experimental_api.h` | Unstable |
175+
| Remaining experimental headers | `src/internal/experimental/` | Unstable APIs |
176+
177+
### Category 9: Legacy/Compatibility (2 headers) 🔄 MOVE TO INTERNAL
178+
179+
| Header | Destination | Reason |
180+
|--------|-------------|--------|
181+
| `compat/legacy_aliases.h` | `src/internal/compat/legacy_aliases.h` | Compatibility only |
182+
| `compat/unified_compat.h` | `src/internal/compat/unified_compat.h` | Compatibility only |
183+
184+
### Category 10: Remaining Headers (47 headers) 🔍 REVIEW NEEDED
185+
186+
Additional headers in:
187+
- `unified/` directory (7 headers)
188+
- `utils/` directory (4 remaining headers)
189+
- `protocol/` directory (6 headers)
190+
- `config/` directory (3 headers)
191+
- `concepts/` directory (3 headers)
192+
- `session/` directory (1 remaining header)
193+
- `tracing/` directory (3 headers)
194+
- `metrics/` directory (3 headers)
195+
- `events/` directory (1 header)
196+
- `di/` directory (1 header)
197+
- `policy/` directory (1 header)
198+
- `http/` directory (2 remaining headers)
199+
- Others (12 headers)
200+
201+
**Action**: Detailed review needed for each header to determine public vs. internal classification.
202+
203+
---
204+
205+
## Migration Impact Analysis
206+
207+
### Breaking Changes
208+
209+
**High Impact** (Users must migrate):
210+
- Direct instantiation of `messaging_client`, `messaging_server` → Use `tcp_facade`
211+
- Direct instantiation of `messaging_udp_client`, `messaging_udp_server` → Use `udp_facade`
212+
- Direct use of QUIC protocol headers → Use future QUIC facade or marked experimental
213+
- Direct use of HTTP2/gRPC protocol headers → Internal details
214+
215+
**Medium Impact** (Advanced users):
216+
- Session management direct access → Use server/client interfaces
217+
- Internal utility usage → Use public alternatives or migrate to internal access
218+
219+
**Low Impact**:
220+
- Experimental feature users → Already expect instability
221+
- Legacy compatibility users → Migration guide provided
222+
223+
### Migration Path
224+
225+
1. **Immediate**: Update code to use facades (recommended, forward-compatible)
226+
2. **Transition**: Use `NETWORK_SYSTEM_EXPOSE_INTERNALS=ON` CMake option (temporary)
227+
3. **Advanced**: Access internal headers explicitly (not recommended, maintenance burden)
228+
229+
### Test Impact
230+
231+
- Unit tests will need `target_include_directories(PRIVATE src/internal)` for direct testing
232+
- Integration tests should use public facade API only
233+
- Examples must be updated to use facade API
234+
235+
---
236+
237+
## Next Steps
238+
239+
### Phase 1 Deliverables (This PR)
240+
1. ✅ This header audit document
241+
2. ⏳ Migration guide with facade usage examples
242+
3. ⏳ Add deprecation warnings to headers scheduled for moving
243+
4. ⏳ Update examples to use facade API
244+
245+
### Phase 2-4 (Subsequent PRs)
246+
- Phase 2: Move protocol implementations (4 PRs: TCP, UDP, HTTP/WS, QUIC)
247+
- Phase 3: Move protocol details (3 PRs: HTTP2, gRPC, utilities)
248+
- Phase 4: Cleanup and final documentation
249+
250+
---
251+
252+
**Prepared by**: Claude Code
253+
**Review Required**: @kcenon
254+
**Next**: Create migration guide

0 commit comments

Comments
 (0)