Files
aevolution/cmake/Network.cmake
T
dingoandClaude Opus 5.5 c588be237c Fix M9.4-M9.7 review findings in the dev session stack
- TLS: replace send() with a bounded queue/flush; an interrupted record is
  retried with identical arguments and later frames wait behind it, so no
  queued frame is lost or reordered; close() flushes first.
- Carriers: server-issued 'I','N' | 48-bit epoch | 64-bit ordinal ids
  replace the aliasing low-32-bit packing; client sequences are kept
  separately for replies; out-of-range epochs are refused, never truncated.
- Grants: a durable, fsynced, fail-closed consumed-grant ledger
  (--session-grant-ledger, /objects/dev-session-grants.v1 in dev) keeps
  single-use grants consumed across process and pod restarts.
- Liveness: protocol v1 (undeployed) gains Heartbeat and the timeout close
  reason; both sides heartbeat when idle and treat 5 s of silence as dead.
- Client sends are bounded and unresolved tracking starts at send time.
- ci-client configures with an explicit C compiler.

Each finding has a regression test; ADR-0083, the schema, operations doc
and VALIDATION record the corrections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 05:44:44 -04:00

72 lines
4.1 KiB
CMake

# M9.6 dev session protocol and TLS adapter (ADR-0082). Opt-in; never part of the
# headless simulation. Mbed TLS comes only from the explicitly prepared, pinned source.
include("${PROJECT_SOURCE_DIR}/tools/mbedtls-pin.cmake")
set(mbedtls_source "${PROJECT_SOURCE_DIR}/build/external/mbedtls/mbedtls-${EVO_MBEDTLS_VERSION}")
if(NOT EXISTS "${mbedtls_source}/evo-verified.sha256")
message(FATAL_ERROR "Prepare Mbed TLS explicitly: cmake -P tools/prepare-mbedtls.cmake")
endif()
file(STRINGS "${mbedtls_source}/evo-verified.sha256" verified)
if(NOT verified STREQUAL EVO_MBEDTLS_SHA256)
message(FATAL_ERROR "Prepared Mbed TLS does not match the reviewed source pin")
endif()
enable_language(C)
set(ENABLE_PROGRAMS OFF CACHE BOOL "" FORCE)
set(ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(GEN_FILES OFF CACHE BOOL "" FORCE)
set(USE_STATIC_MBEDTLS_LIBRARY ON CACHE BOOL "" FORCE)
set(USE_SHARED_MBEDTLS_LIBRARY OFF CACHE BOOL "" FORCE)
set(USE_STATIC_TF_PSA_CRYPTO_LIBRARY ON CACHE BOOL "" FORCE)
set(USE_SHARED_TF_PSA_CRYPTO_LIBRARY OFF CACHE BOOL "" FORCE)
set(DISABLE_PACKAGE_CONFIG_AND_INSTALL ON CACHE BOOL "" FORCE)
# Warnings-as-errors is policy for owned code. Upstream's own -Werror turns
# compiler-version-specific diagnostics (GCC 13 -O3 maybe-uninitialized in
# ssl_tls.c) into build failures of unmodified upstream sources.
set(MBEDTLS_FATAL_WARNINGS OFF CACHE BOOL "" FORCE)
set(TF_PSA_CRYPTO_FATAL_WARNINGS OFF CACHE BOOL "" FORCE)
set(MBEDTLS_USER_CONFIG_FILE "${PROJECT_SOURCE_DIR}/third_party/mbedtls/evo_mbedtls_config.h"
CACHE FILEPATH "Owned TLS 1.3-only restriction (ADR-0082)" FORCE)
# Upstream code is not compiled with project warning policy or our sanitizer
# instrumentation guarantees; only owned targets use evo_owned_target.
add_subdirectory("${mbedtls_source}" "${PROJECT_BINARY_DIR}/mbedtls" EXCLUDE_FROM_ALL SYSTEM)
# Dependency-free protocol: framing, envelopes, admission. No Mbed TLS types.
add_library(evo_network_protocol STATIC src/network/protocol/codec.cpp
src/network/protocol/admission.cpp)
target_link_libraries(evo_network_protocol PUBLIC evo_client_views evo_client_controls)
evo_owned_target(evo_network_protocol)
# Mbed TLS adapters: dev grants (HMAC-SHA256 via PSA) and the TLS 1.3 channel.
add_library(evo_network_tls STATIC src/network/tls/dev_grant.cpp src/network/tls/channel.cpp
src/network/tls/dev_credentials.cpp)
target_link_libraries(evo_network_tls PUBLIC evo_network_protocol PRIVATE mbedtls)
evo_owned_target(evo_network_tls)
# M9.7 sessions: non-blocking TCP, the host-agnostic session server and the client.
add_library(evo_network_session STATIC src/network/socket/tcp.cpp src/network/session/server.cpp
src/network/session/client.cpp src/network/session/grant_ledger.cpp)
target_link_libraries(evo_network_session PUBLIC evo_network_tls)
if(WIN32)
target_link_libraries(evo_network_session PRIVATE ws2_32)
endif()
evo_owned_target(evo_network_session)
# Dev credential and grant tool (ADR-0083); generates throwaway-scale dev secrets only.
add_executable(evo-dev-session apps/evo-dev-session/main.cpp)
target_link_libraries(evo-dev-session PRIVATE evo_network_session)
evo_owned_target(evo-dev-session)
if(BUILD_TESTING)
add_executable(evo-network-tests tests/network_protocol.cpp tests/network_tls.cpp
tests/network_session.cpp tests/network_main.cpp)
# The TLS tests generate throwaway dev certificates with Mbed TLS directly.
target_link_libraries(evo-network-tests PRIVATE evo_network_session mbedtls)
evo_owned_target(evo-network-tests)
add_test(NAME network COMMAND evo-network-tests)
set_tests_properties(network PROPERTIES TIMEOUT 120 LABELS "network")
endif()
if(EVO_BUILD_FUZZER)
# Coverage-guided codec fuzzing (Linux Clang; see the EVO_BUILD_FUZZER guard).
add_executable(evo-dev-session-fuzz tests/fuzz/dev_session_fuzz.cpp
src/network/protocol/codec.cpp)
target_link_libraries(evo-dev-session-fuzz PRIVATE evo_client_views evo_client_controls)
evo_owned_target(evo-dev-session-fuzz)
target_compile_options(evo-dev-session-fuzz PRIVATE -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer)
target_link_options(evo-dev-session-fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
endif()