# NETWORK TOOLS TCP TOOL CONTRACT (K2371–K2375) - **Move Range:** `K2371–K2375` - **Phase:** `Phase 18 — Daily Use Applications` - **Module:** `network_tools.tcp_tool` - **Title:** `Küçük TCP akış aracı` - **Invariant:** `EOF kısa read write ayrı işlenir` - **Positive Case:** `İki segment metin akışı` (`k2375-tcptwoseg`) - **Counterexample:** `Peer ortada reset` (`k2375-tcpmidreset`) - **Acceptance Criterion:** `Açık ECONNRESET kabuğu bozmaz` - **Crate:** `os-network-tools` (`src/tcp_tool.rs`) - **Inspection Symbol:** `os_network_tools_tcp_tool` ## 1. Scope and Invariants 1. **Separate EOF and Short Read/Write Handling (`K2371–K2372`):** - The TCP stream tool must distinguish clean EOF from short read and short write states (`conflated_eof_or_short_read_write == false`, `separate_eof_short_rw_states == 3`) and ensure explicit `ECONNRESET` handling never corrupts shell state (`explicit_econnreset_preserves_shell == true`). - Any attempt to conflate EOF with short read/write or allow a peer reset to corrupt shell state is deterministically refused (`NetworkToolsTcpToolError::ConflatedEofOrShortReadWrite`, `NetworkToolsTcpToolError::EconnresetCorruptedShellState`). 2. **Refusal of Mid-Stream Peer Reset (`K2373`):** - Mid-stream peer resets (`mid_stream_peer_reset == true`, `k2375-tcpmidreset`) are rejected with an explicit reset error before any stream completion receipt is committed (`NetworkToolsTcpToolError::MidStreamPeerReset`), keeping `silent_reset_corruptions == 0`. 3. **Two-Segment Text Stream Completion (`K2374–K2375`):** - The positive path (`k2375-tcptwoseg`) commits a 2-segment TCP text stream (`stream_text_segments == 2`) with 3 separate EOF/short-R/W state checks (`separate_eof_short_rw_states == 3`), 2 shell survival checks (`shell_survival_checks == 2`), and 0 silent reset corruptions (`silent_reset_corruptions == 0`), bound by a monotonic `tcp_tool_epoch` and FNV-1a digest (`compute_network_tools_tcp_tool_binding_digest`).