Implement M9.7 dev region sessions with durable no-effect intentions

Run a non-blocking TLS 1.3 session server inside evo-server's loop:
environment views come from the region's own field/terrain stores with an
explicitly empty organism presentation; admitted intentions ride the next
synthetic input (content unchanged) and return a durable no-effect outcome
from the host's final acknowledgement, or not_committed when dropped.
Sessions are bound to their connection, epochs close stale sessions, and
connections have bounded output, input rate and deadlines.

SessionClient and evo-client --connect consume one single-use grant per
Hello (refusals before admission keep it), reset to a fresh baseline on
every session, keep stale views visible and report in-flight intentions as
unknown after loss. evo-dev-session generates dev credentials, grant
bundles and runs a restart probe. The dev deployment gains a drill-time,
loopback-only listener with an optional Secret, enforced by the policy
check, and tools/ops/session-drill.sh. Protocol v1 gains IntentOutcome and
the capacity close reason before any deployment. ADR-0083 records the
maintainer-confirmed decisions; M8-dev/stage remains not passed and no
cluster change was made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-01 20:12:18 -04:00
co-authored by Claude Opus 5.5
parent 8fbe093cc8
commit 8e319322f4
49 changed files with 3467 additions and 130 deletions
+1 -64
View File
@@ -1,5 +1,6 @@
#include "evo/network/protocol.hpp"
#include "evo/network/tls_channel.hpp"
#include "network_pki.hpp"
#include "network_test.hpp"
#include <array>
#include <deque>
@@ -11,70 +12,6 @@
namespace evo::network_test {
namespace {
using namespace evo::network;
constexpr const char* server_name = "dev-region.evolution.test";
// Throwaway test credentials; production/dev deployment keys are never generated here.
struct Key {
Key() {
mbedtls_pk_init(&pk);
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_set_key_type(&attributes, PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1));
psa_set_key_bits(&attributes, 256);
psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_EXPORT);
psa_set_key_algorithm(&attributes, PSA_ALG_ECDSA(PSA_ALG_SHA_256));
mbedtls_svc_key_id_t id = PSA_KEY_ID_NULL;
CHECK(psa_crypto_init() == PSA_SUCCESS &&
psa_generate_key(&attributes, &id) == PSA_SUCCESS);
CHECK(mbedtls_pk_copy_from_psa(id, &pk) == 0);
(void)psa_destroy_key(id);
}
~Key() {
mbedtls_pk_free(&pk);
}
Key(const Key&) = delete;
Key& operator=(const Key&) = delete;
[[nodiscard]] std::string pem() {
std::array<unsigned char, 4096> buffer{};
CHECK(mbedtls_pk_write_key_pem(&pk, buffer.data(), buffer.size()) == 0);
return reinterpret_cast<const char*>(buffer.data());
}
mbedtls_pk_context pk;
};
std::string certificate(Key& subject, Key& issuer, const char* subject_name,
const char* issuer_name, bool authority, unsigned char serial) {
mbedtls_x509write_cert crt;
mbedtls_x509write_crt_init(&crt);
mbedtls_x509write_crt_set_version(&crt, MBEDTLS_X509_CRT_VERSION_3);
mbedtls_x509write_crt_set_md_alg(&crt, MBEDTLS_MD_SHA256);
mbedtls_x509write_crt_set_subject_key(&crt, &subject.pk);
mbedtls_x509write_crt_set_issuer_key(&crt, &issuer.pk);
CHECK(mbedtls_x509write_crt_set_serial_raw(&crt, &serial, 1) == 0 &&
mbedtls_x509write_crt_set_validity(&crt, "20250101000000", "20991231235959") == 0 &&
mbedtls_x509write_crt_set_subject_name(&crt, subject_name) == 0 &&
mbedtls_x509write_crt_set_issuer_name(&crt, issuer_name) == 0 &&
mbedtls_x509write_crt_set_basic_constraints(&crt, authority ? 1 : 0, -1) == 0 &&
mbedtls_x509write_crt_set_key_usage(&crt, authority
? MBEDTLS_X509_KU_KEY_CERT_SIGN
: MBEDTLS_X509_KU_DIGITAL_SIGNATURE) == 0);
std::array<unsigned char, 4096> buffer{};
const int result = mbedtls_x509write_crt_pem(&crt, buffer.data(), buffer.size());
mbedtls_x509write_crt_free(&crt);
CHECK(result == 0);
return reinterpret_cast<const char*>(buffer.data());
}
struct Pki {
Pki(const char* name = server_name) {
authority =
certificate(ca_key, ca_key, "CN=AEvolution dev CA", "CN=AEvolution dev CA", true, 1);
const std::string subject = std::string{"CN="} + name;
server.certificate_chain_pem =
certificate(server_key, ca_key, subject.c_str(), "CN=AEvolution dev CA", false, 2);
server.private_key_pem = server_key.pem();
}
Key ca_key, server_key;
std::string authority;
ServerCredentials server;
};
// Two in-memory byte queues with optional faults.
struct Wire {