# Net implementation plan Status: planning only. All feature tasks below are PLANNED. Source baseline: `f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`, inspected 2026-11-24. Authority: [requirements](../REQUIREMENTS.md) R-002–R-006, R-009–R-016; [architecture](../ARCHITECTURE.md) C-02–C-06, C-11, C-13. ## Existing capability and evidence The public namespace is `Void::Net`. [Http.hpp](../../../include/Void/Net/Http.hpp) exposes synchronous `HttpClient`, owning request/response strings, HTTP and SOCKS5 proxy configuration, a 30-second request timeout, opt-in redirects, and a 64 MiB body limit. Zero currently means unlimited. Non-2xx responses are successful transport results. [Http.cpp](../../../src/Net/Http.cpp) constructs an Asio context and socket per hop; there is no connection pool. Its watchdog starts after resolution/connect, and each redirect restarts the phase budget. Certificate checking defaults off; enabling it sets peer verification but the inspected handshake only sets SNI, not expected-host verification. Redirects retain the original method, body, and headers. [Server.hpp](../../../include/Void/Net/Server.hpp) and [Server.cpp](../../../src/Net/Server.cpp) provide `Router`, `StaticFileResolver`, and `WebSocketSessions`. Routing snapshots a handler before invoking it outside the lock; the session registry also invokes callbacks/close outside its lock. These are useful transport-neutral components, not an HTTP listener or a WebSocket framing engine. Static resolution rejects traversal and canonical symlink escapes but returns a path; opening that path later needs protection against filesystem replacement races. [Socket.hpp](../../../include/Void/Net/Socket.hpp) and [Socket.cpp](../../../src/Net/Socket.cpp) implement connected blocking UDP on POSIX; Windows operations report unsupported. `wait_readable` uses poll. [Url.hpp](../../../include/Void/Net/Url.hpp) / [Url.cpp](../../../src/Net/Url.cpp) use Boost.URL and accept URI references as well as absolute URIs. [module.cmake](../../../src/Net/module.cmake) declares Functional, Text, Boost headers/Beast/Asio/URL, OpenSSL, and Threads. Existing tests cover loopback GET/POST, invalid URL/refusal and a stalled response in [HttpClient.cpp](../../../tests/standalone/Net/HttpClient.cpp); router/static/session helpers in [Server.cpp](../../../tests/standalone/Net/Server.cpp); parsing in [Url.cpp](../../../tests/standalone/Net/Url.cpp); and closed/moved UDP state in [Socket.cpp](../../../tests/standalone/Net/Socket.cpp). They do not establish TLS, proxy, real server, WebSocket wire, or sustained reuse conformance. Graph coverage was checked for all these files: Http.hpp lines 112/115 and Server.hpp 207/211/214 have parse gaps and were read directly. Other paths reported matching metadata with no recorded issue; graph edges are advisory, source is authoritative. ## Target interfaces and backend ownership NEW illustrative APIs below are not compiling examples. `OperationOptions` and `Task` refer to [Async](Async.md)'s C-03 types; byte streams and descriptor lifetime belong to [IO](../subsystems/IO.md). Net owns protocol state, endpoint resolution policy, TLS contexts, parsers, pools, and listener/session policy. No constructor starts workers. ```cpp // NEW shapes in Void::Net; Result is C-02 shorthand. struct ClientPolicy { TlsPolicy tls; RedirectPolicy redirects; PoolLimits pool; }; class Client { Task> send(StreamingRequest, OperationOptions); Task> shutdown(OperationOptions); }; class HttpServer { static Result create(IOContext&, ServerPolicy, Handler); Task> listen(Endpoint, OperationOptions); Task> shutdown(OperationOptions); }; // StreamingResponse owns its connection lease until consumed or cancelled. // Handler receives headers plus a bounded body reader and returns a body producer. ``` Choose native incremental HTTP/1.1 and WebSocket codecs over native IO; retain a separately selectable Boost migration adapter until wire conformance gates pass. Keep OpenSSL as the TLS backend; do not implement cryptographic primitives. Initial Linux IO is level-triggered epoll, owned by IO, with bounded work per readiness turn to avoid monopolizing the executor. Readiness is not a whole-message completion. See [epoll semantics](https://man7.org/linux/man-pages/man7/epoll.7.html). Native URL parsing must preserve encoded components and implement RFC reference resolution before replacing Boost.URL. HTTP/2, QUIC, compression, and proxy servers are later named capabilities, not claims of the first release. ## Protocol and operation rules 1. Admit against byte/operation budgets; validate absolute http/https destinations, authority, numeric ports, header syntax, and explicit proxy credential lengths. URI references remain a separate parsing API; they cannot silently become a host. 2. Establish one absolute steady deadline at admission. DNS, capacity waiting, address attempts, connect, proxy negotiation, TLS, redirects and body transfer consume it. Resolver workers retain owned inputs after caller cancellation; late results are discarded and accounted until worker completion. 3. Verify trusted chain and DNS/IP peer identity by default; SNI alone is inadequate. TLS minimum is 1.2, allow 1.3 through backend negotiation. Trust stores are explicit immutable configuration snapshots. Insecure test policy must be conspicuously named and opt-in. Follow the separate verification and identity setup in the [OpenSSL 3.5 client guide](https://docs.openssl.org/3.5/man7/ossl-guide-tls-client-block/). 4. Parse HTTP framing incrementally: reject conflicting Content-Length values and Transfer-Encoding/Content-Length ambiguity, enforce CRLF and header limits, handle informational responses, HEAD/no-body statuses, chunk extensions/trailers and close-delimited bodies. Never reuse a connection with uncertain message boundaries. Protocol conformance fixtures must cover RFC 9110/9112 before native promotion. 5. Default redirects remain disabled; enabling follows only 301/302/303/307/308, up to five hops. 303 changes non-HEAD to GET and drops body/body headers; 301/302 preserve method and require explicit replay permission for non-safe methods; 307/308 preserve method and require a replayable body. Reject HTTPS downgrade by default. Resolve relative references correctly; compare scheme/host/effective port. On origin change, strip Authorization, Cookie and caller-declared sensitive headers; always rebuild Host and keep Proxy-Authorization confined to its proxy hop. No implicit cookie jar. 6. Pool by origin, proxy identity and TLS/trust-policy generation. HTTP/1.1 initially allows one exchange per connection, no pipelining. Return a lease only after body and trailers finish; abandon/cancel closes it. No automatic replay after bytes may have reached a peer. Upper layers supply idempotency policy. 7. Server accept → TLS → bounded headers/body → dispatch → streamed response → reuse. Handler errors map through a configurable sanitized error mapper; no route is 404, known path with wrong method is 405 with Allow. Disable further admission on stop, drain admitted requests, then cancel/join connections. Static serving opens beneath a retained directory handle through IO/System capability checks, not a stale pathname. 8. WebSocket upgrade validates version/key/Connection/Upgrade, origin policy and selected subprotocol. Enforce client masking, server non-masking, fragmentation/control-frame rules, UTF-8 text and close reasons, ping/pong and one close handshake. Disable extensions initially. Frame callbacks borrow payload only during invocation; retained payloads require owned copies. RFC 6455 fixtures and an independent peer are gates. ## Bounds and failure matrix NEW defaults: 256 total client connections, 8/origin, 128 idle, 30-second idle eviction; 1,024 admitted client operations; 4,096 server connections and 256 executing handlers. Headers: 32 KiB aggregate/100 fields/8 KiB start line. Buffered bodies: 8 MiB; streaming uses 64 KiB chunks, 256 KiB per-direction windows and a 256 MiB module buffer budget. WebSocket messages: 1 MiB, output: 64 messages or 4 MiB/session; either bound rejects admission. Limits include in-flight buffers. Body streaming has an explicit optional total-byte quota; there is no accidental zero-as-unlimited. Server headers expire at 10 seconds, idle at 30 seconds, admitted request at 30 seconds by default; a public long-lived stream must opt into its own liveness policy. Shutdown grace: 10 seconds. | Trigger | Terminal behavior and cleanup | Required evidence | | --- | --- | --- | | DNS/connect/proxy/TLS timeout | Timeout with phase; one completion; close/retire state | Stall every phase under one deadline | | Unknown CA / wrong hostname | Peer verification error before request bytes | Separate fixtures for trust and identity | | Body/header limit or malformed framing | Protocol/limit error; connection unusable | Split bytes at every boundary; smuggling corpus | | Capacity exhaustion | Overload before allocation; optional cancellable capacity wait | Queue plus in-flight accounting | | Cancellation mid-upload | Cancelled/unknown remote effect; close lease, retain buffers until IO ends | Stop/completion races, no replay | | Slow consumer / WebSocket output full | Await explicit capacity or return overload; bounded memory | Slow-reader soak with max RSS | | Handler throws or stream fails | Sanitized 500 before headers, otherwise terminate connection | Faulting handlers outside locks | | Shutdown with peer stalled | Stop admission, grace then cancel/join; no callbacks after join | Destruction and descriptor-reuse races | ## Ordered implementation backlog Every row is PLANNED; dependencies refer to completed evidence gates, not file existence. | ID | Phase / dependencies | Scope and acceptance | Recommended role | | --- | --- | --- | --- | | M-NET-01 | P0; baseline | Freeze current client/router/URL fixtures and secure-behavior gaps; installed Net-only consumer records actual dependencies | sol_implementer | | M-NET-02 | P1; M-NET-01, IO/Async/Time contracts | NEW context, resolver, socket/listener and deadline adapters; every phase cancellable without borrowed-state escape | astra_implementer | | M-NET-03 | P2; M-NET-02 | OpenSSL peer+identity defaults, proxy validation, redirect algorithm; trust/hostname/cross-origin matrix passes on Boost adapter first | astra_implementer | | M-NET-04 | P2; M-NET-03 | Native HTTP codec, real HTTP/HTTPS server, streaming, pool and safe static open; RFC corpus, fuzzing, independent peers pass | astra_implementer | | M-NET-05 | P2; M-NET-04 | Native WebSocket client/server and session lifecycle; fragmented/control/close/UTF-8 conformance and shutdown races pass | sol_implementer | | M-NET-06 | P3; M-NET-05 | Backend parity and performance gate; keep Boost selectable until migration consumer and workload evidence permit default switch | astra_implementer | | M-NET-07 | P4; M-NET-06, RPC/Messaging gates | Distributed transport stress, reconnect and bounded streaming workloads; no safety claims inferred from availability alone | sol_implementer | ## Validation, compatibility and rollback CURRENT checks are existing `VoidTests` and `VoidInstalledComponentConsumers` registered in [tests/CMakeLists.txt](../../../tests/CMakeLists.txt). They were not rerun for this documentation task. Current source fixtures are evidence of coverage intent, not new passing results. PROPOSED checks add deterministic resolver/clock fault injection, TLS/proxy loopback peers, parser fuzz targets and independent HTTP/WebSocket clients; targets must be added before commands are advertised. Use [VALIDATION](../VALIDATION.md) and [BUILD-AND-DISTRIBUTION](../BUILD-AND-DISTRIBUTION.md) for the actual build gate. Measure small reused requests, connection churn, large streaming downloads, many idle WebSockets and slow consumers: p50/p95/p99, throughput, allocations, peak RSS/CPU, file descriptors, handshake counts and build cost under [PERFORMANCE](../PERFORMANCE.md). Separate cold DNS/TLS from warm pool results and Boost from native. Major-release migration replaces unsafe defaults and whole-body APIs with secure configuration and streaming, with an owning buffered convenience adapter. Existing `HttpClient` remains documented during transition; a synchronous wrapper cannot block the executor needed for its completion. Keep non-2xx transport-result semantics. Pools must be recreated when trust/proxy identity changes. Roll back backend selection only between operations; never replay an uncertain write on the old backend. See [MIGRATION](../MIGRATION.md), [RPC](../subsystems/RPC.md), [Security](Security.md), and [NetworkedApplications](../platforms/NetworkedApplications.md).