Implement M9.6 narrow secure dev-session protocol

Add protocol v1: versioned, bounded frames (Hello, Welcome, Intent,
IntentResult, environment/organism views, Close) carrying session, epoch
and commit watermark, with an explicit little-endian canonical codec, a
header-first FrameReader, seeded mutation tests and a libFuzzer target.
SessionAdmission enforces world/region scope, grant lifetime and skew,
single-use grants, one session per subject, epoch, replay, tick window
and per-session rate.

Dev identity is a 108-byte HMAC-SHA256 grant (PSA) that cannot be
created or verified outside the dev environment. Transport security is
TLS 1.3 only via pinned Mbed TLS 4.1.1 LTS with TLS 1.2, DTLS, tickets
and PSK compiled out, AEAD suites, ECDHE groups and a pinned dev CA.
Opt-in EVO_BUILD_NETWORK, new network CI suite. Sockets and region
integration follow in M9.7. ADR-0082 records the decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-01 18:53:55 -04:00
co-authored by Claude Opus 5.5
parent 9bb147de82
commit 8fbe093cc8
39 changed files with 3200 additions and 27 deletions
-7
View File
@@ -46,16 +46,9 @@ if(EVO_BUILD_CLIENT_PROBE)
endif()
if(EVO_BUILD_CLIENT)
add_library(evo_client_controls STATIC src/client/camera/camera.cpp src/client/input/input.cpp)
target_include_directories(evo_client_controls PUBLIC "${PROJECT_SOURCE_DIR}/include")
evo_owned_target(evo_client_controls)
add_library(evo_render_frame STATIC src/render/frame.cpp)
target_include_directories(evo_render_frame PUBLIC "${PROJECT_SOURCE_DIR}/include")
evo_owned_target(evo_render_frame)
# SDL-free environment presentation (M9.4): copies read-only world views, never the reverse.
add_library(evo_client_views STATIC src/client/views/environment_view.cpp src/client/views/organism_view.cpp)
target_link_libraries(evo_client_views PUBLIC evo::world evo::biology)
evo_owned_target(evo_client_views)
add_library(evo_render_environment STATIC src/render/environment/environment.cpp)
target_link_libraries(evo_render_environment PUBLIC evo_client_views evo_client_controls evo_render_frame)
evo_owned_target(evo_render_environment)
+53
View File
@@ -0,0 +1,53 @@
# 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)
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)
target_link_libraries(evo_network_tls PUBLIC evo_network_protocol PRIVATE mbedtls)
evo_owned_target(evo_network_tls)
if(BUILD_TESTING)
add_executable(evo-network-tests tests/network_protocol.cpp tests/network_tls.cpp
tests/network_main.cpp)
# The TLS test generates throwaway dev certificates with Mbed TLS directly.
target_link_libraries(evo-network-tests PRIVATE evo_network_tls 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()