Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(test-infra): repair the native Windows soak transport and release checks
Martin Vogel636dd3f92cc0
diff --git a/scripts/smoke-fixture-server.py b/scripts/smoke-fixture-server.pyindex 5fbfedf31..279dcffad 100755--- a/scripts/smoke-fixture-server.py+++ b/scripts/smoke-fixture-server.py@@ -23,7 +23,6 @@ def publish_port(port_file: pathlib.Path, port: int) -> None:) as temporary:temporary.write(f"{port}\n")temporary.flush()- os.fsync(temporary.fileno())temporary_path = pathlib.Path(temporary.name)try:os.replace(temporary_path, port_file)diff --git a/scripts/soak-test.sh b/scripts/soak-test.shindex 864cf36cd..25db7a82e 100755--- a/scripts/soak-test.sh+++ b/scripts/soak-test.sh@@ -65,8 +65,10 @@ soak_stamp_windows_dir() {}SOAK_WIN_ROOT=""+SOAK_NATIVE_WINDOWS=falseif [[ "$BINARY" == *.exe ]] && command -v cygpath >/dev/null 2>&1 &&! command -v winepath >/dev/null 2>&1; then+ SOAK_NATIVE_WINDOWS=true# The server's cache-private hardening walks the FULL ancestor chain of# both the executable and the cache dir and fails (or silently disables# diagnostics) on any ancestor granting mutation to untrusted SIDs. The@@ -157,6 +159,57 @@ soak_cleanup() {[ -z "${SOAK_WIN_ROOT:-}" ] || rm -rf -- "$SOAK_WIN_ROOT"}+# MSYS filesystem FIFOs do not provide a faithful stdin stream to a native+# Windows process: the child observes a clean EOF before the writer's first+# request. Use Bash's anonymous coprocess pipes for that one platform. Keep the+# coproc syntax inside eval so macOS's system Bash 3.2 can still parse this+# script; that branch is reached only by MSYS2 Bash 5. POSIX hosts retain the+# established FIFO transport.+start_mcp_server() {+ local stderr_mode="$1"+ if $SOAK_NATIVE_WINDOWS; then+ unset CBM_SOAK_SERVER CBM_SOAK_SERVER_PID || true+ if [ "$stderr_mode" = "append" ]; then+ eval 'coproc CBM_SOAK_SERVER {+ export CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE"+ export CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info CBM_LOG_FORMAT=text+ exec "$BINARY" 2>>"$RESULTS_DIR/server-stderr.log"+ }'+ else+ eval 'coproc CBM_SOAK_SERVER {+ export CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE"+ export CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info CBM_LOG_FORMAT=text+ exec "$BINARY" 2>"$RESULTS_DIR/server-stderr.log"+ }'+ fi+ SERVER_PID=$CBM_SOAK_SERVER_PID+ local server_read_fd="${CBM_SOAK_SERVER[0]}"+ local server_write_fd="${CBM_SOAK_SERVER[1]}"+ exec 3>&"$server_write_fd"+ exec 4<&"$server_read_fd"+ # Only fd3/fd4 may retain the parent endpoints. Otherwise closing fd3+ # during crash/shutdown would leave the original writer open and the+ # native frontend would never observe EOF.+ eval "exec ${server_write_fd}>&-"+ eval "exec ${server_read_fd}<&-"+ return+ fi++ if [ "$stderr_mode" = "append" ]; then+ CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE" CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info \+ CBM_LOG_FORMAT=text "$BINARY" < "$SERVER_IN" > "$SERVER_OUT" \+ 2>>"$RESULTS_DIR/server-stderr.log" &+ else+ CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE" CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info \+ CBM_LOG_FORMAT=text "$BINARY" < "$SERVER_IN" > "$SERVER_OUT" \+ 2>"$RESULTS_DIR/server-stderr.log" &+ fi+ SERVER_PID=$!+ # Open fds AFTER server starts (otherwise FIFO open blocks).+ exec 3>"$SERVER_IN"+ exec 4<"$SERVER_OUT"+}+trap soak_cleanup EXITtrap 'exit 130' INT TERM@@ -498,46 +551,41 @@ collect_snapshot() {SNAPSHOT_ATTEMPTS=$((SNAPSHOT_ATTEMPTS + 1))refresh_diagnostics_paths || return 0if [ -f "$DIAG_FILE" ]; then- python3 -c "-import json, time-d = json.load(open('$DIAG_FILE'))+ cat "$DIAG_FILE" 2>/dev/null | python3 -c '+import json, sys, time+d = json.load(sys.stdin)# Use heap_committed if available, otherwise RSS (mimalloc may report 0 for committed)-mem = d.get('heap_committed_bytes', 0)-if mem == 0: mem = d.get('rss_bytes', 0)-print(f\"{int(time.time())},{d.get('uptime_s',0)},{d.get('rss_bytes',0)},{mem},{d.get('fd_count',0)},{d.get('query_count',0)},{d.get('query_max_us',0)}\")-" 2>/dev/null >> "$METRICS_CSV"+mem = d.get("heap_committed_bytes", 0)+if mem == 0: mem = d.get("rss_bytes", 0)+print("{},{},{},{},{},{},{}".format(+ int(time.time()), d.get("uptime_s", 0), d.get("rss_bytes", 0), mem,+ d.get("fd_count", 0), d.get("query_count", 0), d.get("query_max_us", 0)))+' 2>/dev/null >> "$METRICS_CSV"fi}diagnostics_json_value() {local key="$1"refresh_diagnostics_paths || return 1- python3 -c '+ cat "$DIAG_FILE" 2>/dev/null | python3 -c 'import jsonimport sys-with open(sys.argv[1], encoding="utf-8") as stream:- value = json.load(stream).get(sys.argv[2], "")+value = json.load(sys.stdin).get(sys.argv[1], "")print(value)-' "$DIAG_FILE" "$key" 2>/dev/null+' "$key" 2>/dev/null}# ── Phase 1: Start MCP server with diagnostics ──────────────────echo "--- Phase 1: start server ---"# Bidirectional pipes: fd3 = server stdin (write), fd4 = server stdout (read)-SERVER_IN=$(mktemp -u).in-SERVER_OUT=$(mktemp -u).out-mkfifo "$SERVER_IN" "$SERVER_OUT"--CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE" CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info \- CBM_LOG_FORMAT=text "$BINARY" < "$SERVER_IN" > "$SERVER_OUT" \- 2>"$RESULTS_DIR/server-stderr.log" &-SERVER_PID=$!--# Open fds AFTER server starts (otherwise fifo blocks)-exec 3>"$SERVER_IN" # write to server stdin-exec 4<"$SERVER_OUT" # read from server stdout+if ! $SOAK_NATIVE_WINDOWS; then+ SERVER_IN=$(mktemp -u).in+ SERVER_OUT=$(mktemp -u).out+ mkfifo "$SERVER_IN" "$SERVER_OUT"+fi+start_mcp_server truncatesleep 3if ! kill -0 "$SERVER_PID" 2>/dev/null; then@@ -707,12 +755,7 @@ if [ "$SKIP_CRASH" != "--skip-crash-test" ] && [ "$CBM_SOAK_MODE" != "query-leakfi# Restart server- CBM_CACHE_DIR="$SOAK_CACHE_DIR_VALUE" CBM_DIAGNOSTICS=1 CBM_LOG_LEVEL=info \- CBM_LOG_FORMAT=text "$BINARY" < "$SERVER_IN" > "$SERVER_OUT" \- 2>>"$RESULTS_DIR/server-stderr.log" &- SERVER_PID=$!- exec 3>"$SERVER_IN"- exec 4<"$SERVER_OUT"+ start_mcp_server appendsleep 3if kill -0 "$SERVER_PID" 2>/dev/null; thendiff --git a/src/daemon/ipc.c b/src/daemon/ipc.cindex 349a7d553..2b0d729c8 100644--- a/src/daemon/ipc.c+++ b/src/daemon/ipc.c@@ -92,14 +92,21 @@ static char *string_format(const char *format, ...) {return result;}+#ifndef _WIN32static cbm_daemon_ipc_posix_publication_hook_fn g_posix_publication_hook_for_test;static void *g_posix_publication_hook_context_for_test;+#endifstatic atomic_uint g_windows_legacy_guard_release_failures_for_test;void cbm_daemon_ipc_posix_publication_hook_set_for_test(cbm_daemon_ipc_posix_publication_hook_fn hook, void *context) {+#ifndef _WIN32g_posix_publication_hook_context_for_test = context;g_posix_publication_hook_for_test = hook;+#else+ (void)hook;+ (void)context;+#endif}void cbm_daemon_ipc_windows_legacy_guard_release_failures_set_for_test(unsigned int count) {diff --git a/test-infrastructure/docker-compose.yml b/test-infrastructure/docker-compose.ymlindex 5ed91df6a..9e2a62239 100644--- a/test-infrastructure/docker-compose.yml+++ b/test-infrastructure/docker-compose.yml@@ -177,28 +177,10 @@ services:command:- |scripts/build.sh CC=x86_64-w64-mingw32-clang CXX=x86_64-w64-mingw32-clang++ BUILD_DIR=build/win-cross &&- mv build/win-cross/codebase-memory-mcp build/win-cross/codebase-memory-mcp.exe 2>/dev/null || true &&- WINEDEBUG=-all scripts/smoke-test.sh ./build/win-cross/codebase-memory-mcp.exe-- # ── Windows soak (cross-compile + Wine) ───────────────────- # Soak is the one place a CPU cap is meaningful: sustained runs under- # deliberate resource starvation surface scheduling/backpressure behaviour the- # full-parallel correctness suite does not target. Opt in with- # CBM_LOCAL_CI_CPUS=<n>; default 0 = unlimited, so normal soak runs stay fast.- soak-windows:- build:- context: ..- dockerfile: test-infrastructure/Dockerfile.mingw- platform: linux/amd64- cpus: ${CBM_LOCAL_CI_CPUS:-0}- volumes:- - ..:/src- entrypoint: ["/bin/bash", "-c"]- command:- - |- scripts/build.sh CC=x86_64-w64-mingw32-clang CXX=x86_64-w64-mingw32-clang++ BUILD_DIR=build/win-cross &&- mv build/win-cross/codebase-memory-mcp build/win-cross/codebase-memory-mcp.exe 2>/dev/null || true &&- CBM_DIAGNOSTICS=1 WINEDEBUG=-all scripts/soak-test.sh ./build/win-cross/codebase-memory-mcp.exe 10+ mv build/win-cross/codebase-memory-mcp.exe build/win-cross/codebase-memory-mcp.payload.exe &&+ mv build/win-cross/codebase-memory-mcp-launcher.exe build/win-cross/codebase-memory-mcp.exe &&+ WINEDEBUG=-all wine64 ./build/win-cross/codebase-memory-mcp.payload.exe --version &&+ WINEDEBUG=-all wine64 cmd /c build/win-cross/codebase-memory-mcp.exe --version# ── Linux portable (Alpine musl static) ────────────────────test-portable:diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.shindex 815a3cce7..0c1b536e9 100755--- a/test-infrastructure/run.sh+++ b/test-infrastructure/run.sh@@ -6,7 +6,7 @@# Linux arm64: test (ASan+LeakSan) + build (-O2) [native, fast]# Linux amd64: test + build [QEMU, slower]# Linux portable: Alpine musl static build + smoke [portable binary]-# Windows: cross-compile with mingw-w64 [compile-check; use+# Windows: cross-compile + Wine version check [fast check only; use# vm/win.sh for mandatory real-Windows verification]# macOS: run natively (not in Docker)#@@ -27,6 +27,7 @@# ./test-infrastructure/run.sh all # above + amd64 + Windows Wine smoke# ./test-infrastructure/run.sh portable # Alpine portable build + smoke only# ./test-infrastructure/run.sh windows # Windows cross-compile only+# ./test-infrastructure/run.sh soak-windows # native Windows VM, 10 min# ./test-infrastructure/run.sh test # Linux arm64 test only (no perf)# ./test-infrastructure/run.sh perf # Linux arm64 perf/incremental only# ./test-infrastructure/run.sh tsan # Linux arm64 ThreadSanitizer race gate@@ -61,6 +62,11 @@ print_real_windows_gate() {echo "=== Real-Windows gate remains: vm/win.sh sync, test, guards, smoke-install ==="}+if [ "${1:-full}" = "soak-windows" ]; then+ echo "=== Windows: native daemon soak (real Windows VM, 10 min) ==="+ exec "$ROOT/test-infrastructure/vm/win.sh" soak 10+fi+if ! docker info >/dev/null 2>&1; thenecho "ERROR: no Docker daemon reachable." >&2echo " Start one first — on macOS: colima start --vm-type vz --vz-rosetta --cpu 12 --memory 16" >&2@@ -126,17 +132,13 @@ case "${1:-full}" in$COMPOSE run --rm -e CBM_SKIP_PERF=1 test-portable;;windows)- echo "=== Windows: cross-compile + smoke (Wine) ==="+ echo "=== Windows: cross-compile + launcher/payload version check (Wine) ==="$COMPOSE run --rm smoke-windows;;smoke-windows)- echo "=== Windows: smoke test (cross-compile + Wine) ==="+ echo "=== Windows: launcher/payload version check (cross-compile + Wine) ==="$COMPOSE run --rm smoke-windows;;- soak-windows)- echo "=== Windows: soak test (cross-compile + Wine, 10 min) ==="- $COMPOSE run --rm soak-windows- ;;amd64)echo "=== Linux amd64: test + build ==="$COMPOSE run --rm -e CBM_SKIP_PERF=1 test-amd64@@ -157,7 +159,7 @@ case "${1:-full}" in$COMPOSE run --rm -e CBM_SKIP_PERF=1 test-amd64$COMPOSE run --rm build-amd64$COMPOSE run --rm smoke-amd64- echo "=== Windows: cross-compile + smoke (Wine) ==="+ echo "=== Windows: cross-compile + launcher/payload version check (Wine) ==="$COMPOSE run --rm smoke-windowsprint_real_windows_gate;;diff --git a/test-infrastructure/vm/README.md b/test-infrastructure/vm/README.mdindex 3ea888a7f..77fb53340 100644--- a/test-infrastructure/vm/README.md+++ b/test-infrastructure/vm/README.md@@ -67,6 +67,7 @@ vm/win.sh sync # mirror the uncommitted worktree and rebuild beforevm/win.sh test cli daemon_ipc # run suites natively, secondsvm/win.sh guards # the Windows guard scriptsvm/win.sh smoke-install # managed-install E2E, stderr VISIBLE+vm/win.sh soak 10 # native daemon endurance gatevm/win.sh sh "cd /c/cbm && gdb ..." # anything, interactivelyvm/win.sh push-file src/cli/cli.c /c/cbm/src/cli/cli.c # WIP iteration```diff --git a/test-infrastructure/vm/vm-run-tests.sh b/test-infrastructure/vm/vm-run-tests.shindex 5a58fdb10..5f20ec6d7 100644--- a/test-infrastructure/vm/vm-run-tests.sh+++ b/test-infrastructure/vm/vm-run-tests.sh@@ -1,7 +1,7 @@#!/usr/bin/env bash# vm-run-tests.sh — run C test suites on the Windows VM under a CI-shaped# protected temp root. Runs ON the VM (MSYS2 shell), invoked by win.sh-# test / ubsan-test / trap-ubsan-test.+# test / ubsan-test / trap-ubsan-test / soak.## Why the temp root: the daemon/coordination suites fail closed on the# MSYS-shared /tmp (C:\msys64\tmp), whose ancestry grants mutation rights to@@ -21,7 +21,21 @@ RUNNER="${CBM_VM_RUNNER:-build/c/test-runner}"LOG="${CBM_VM_TEST_LOG:-/tmp/win-test.log}"[ $# -ge 1 ] || { echo "usage: vm-run-tests.sh <suite...> | --par" >&2; exit 2; }-[ -x "$RUNNER" ] || { echo "ERROR: runner '$RUNNER' missing — build first" >&2; exit 2; }+if [ "$1" = "--soak" ]; then+ [ $# -eq 2 ] || { echo "usage: vm-run-tests.sh --soak <positive-minutes>" >&2; exit 2; }+ duration="$2"+ case "$duration" in+ ''|*[!0-9]*) echo "usage: vm-run-tests.sh --soak <positive-minutes>" >&2; exit 2 ;;+ esac+ [ "$duration" -gt 0 ] ||+ { echo "usage: vm-run-tests.sh --soak <positive-minutes>" >&2; exit 2; }+ binary="${CBM_VM_SOAK_BINARY:-build/c/codebase-memory-mcp.exe}"+ [ -x "$binary" ] || { echo "ERROR: binary '$binary' missing — build first" >&2; exit 2; }+ artifact="$binary"+else+ [ -x "$RUNNER" ] || { echo "ERROR: runner '$RUNNER' missing — build first" >&2; exit 2; }+ artifact="$RUNNER"+fi# Stale roots from earlier runs are removed up front; the current root is kept# after the run for post-mortem inspection.@@ -61,7 +75,7 @@ export TEMP TMP TMPDIR# Two steps, both idempotent: protect the DIRECTORY (inheritance flags are# directory-only — a /T re-root leaves files with empty, deny-all DACLs),# then /reset the children so they re-inherit the clean set from it.-runner_dir_w="$(cygpath -w "$(dirname "$RUNNER")")"+runner_dir_w="$(cygpath -w "$(dirname "$artifact")")"me="$(whoami | tr -d '\r')"MSYS2_ARG_CONV_EXCL='*' icacls "$runner_dir_w" /inheritance:r \/grant:r "${me}:(OI)(CI)F" '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' \@@ -70,6 +84,18 @@ MSYS2_ARG_CONV_EXCL='*' icacls "${runner_dir_w}\\*" /reset /T /C /Q >/dev/null 2echo "=== vm-run-tests: runner=$RUNNER temp=$TEMP suites: $* ==="+if [ "$1" = "--soak" ]; then+ echo "=== vm-run-tests: binary=$binary temp=$TEMP soak=${duration}m ==="+ scripts/soak-test.sh "$binary" "$duration" 2>&1 | tee "$LOG"+ rc="${PIPESTATUS[0]}"+ if ! grep -Fq '=== soak-test: PASSED ===' "$LOG"; then+ echo "GUARD: native Windows soak produced no completion summary; treating as failure " \+ "(soak rc=$rc)" >&2+ exit 90+ fi+ exit "$rc"+fi+# --par runs the repo's full parallel harness (wave + tail scheduling,# per-shard union guard, manifest) under this same protected environment;# explicit suite names keep the direct single-runner invocation.diff --git a/test-infrastructure/vm/win.sh b/test-infrastructure/vm/win.shindex 46f99268b..2bba1dbc2 100755--- a/test-infrastructure/vm/win.sh+++ b/test-infrastructure/vm/win.sh@@ -13,6 +13,7 @@# win.sh test <suite...> # run test-runner suites (native ARM64)# win.sh guards # clean UI product build + Windows guards# win.sh smoke-install # real managed-install E2E (Phase 8 class)+# win.sh soak [minutes] # native daemon endurance gate (default 10m)# win.sh sh <command...> # arbitrary command in CLANGARM64 env# win.sh push-file <local> <vm> # scp one file into the VM (WIP iteration)# win.sh test-par # full suite, parallel on all VM cores@@ -141,6 +142,18 @@ smoke-install)# CI smoke Phase 8 exercises, isolated beneath a disposable profile root.vm clangarm64 "cd /c/cbm && bash test-infrastructure/vm/vm-smoke.sh";;+soak)+ duration="${1:-10}"+ case "$duration" in+ ''|*[!0-9]*) echo "usage: win.sh soak [positive-minutes]" >&2; exit 2 ;;+ esac+ if [ "$duration" -le 0 ]; then+ echo "usage: win.sh soak [positive-minutes]" >&2+ exit 2+ fi+ vm clangarm64 "cd /c/cbm && CBM_VM_TEST_LOG=/tmp/win-soak.log bash \+ test-infrastructure/vm/vm-run-tests.sh --soak '$duration'"+ ;;sh)vm clangarm64 "$*";;diff --git a/tests/test_smoke_fixture_contract.sh b/tests/test_smoke_fixture_contract.shindex cb93ec05a..fb2995061 100755--- a/tests/test_smoke_fixture_contract.sh+++ b/tests/test_smoke_fixture_contract.sh@@ -40,6 +40,9 @@ smoke_local = read("scripts/smoke-local.sh")vm_smoke = read("test-infrastructure/vm/vm-smoke.sh")windows_path_guard = read("test-infrastructure/vm/windows-user-path-guard.ps1")compose = read("test-infrastructure/docker-compose.yml")+local_ci = read("test-infrastructure/run.sh")+windows_vm = read("test-infrastructure/vm/win.sh")+windows_vm_runner = read("test-infrastructure/vm/vm-run-tests.sh")pr_workflow = read(".github/workflows/pr.yml")test_driver = read("scripts/test.sh")cli_source = read("src/cli/cli.c")@@ -55,6 +58,10 @@ require("--port-file" in helper_source and "os.replace" in helper_source,"fixture server must publish its assigned port atomically through a file",)+require(+ "os.fsync(" not in helper_source,+ "fixture readiness publication must not wait for crash-durability sync",+)require("socket.socket" not in smoke_local and "python3 -m http.server" not in smoke_local,"smoke-local.sh must not reserve/release a port or launch a separate http.server",@@ -228,6 +235,48 @@ for service in ("smoke:", "smoke-amd64:"):"scripts/smoke-local.sh" in section,f"docker-compose {service[:-1]} service must run smoke-local.sh",)+for service in ("smoke-windows:",):+ match = re.search(+ rf"^ {re.escape(service)}\n(?P<body>.*?)(?=^ [A-Za-z0-9_-]+:|\Z)",+ compose,+ re.MULTILINE | re.DOTALL,+ )+ section = match.group("body") if match else ""+ require(+ "mv build/win-cross/codebase-memory-mcp.exe "+ "build/win-cross/codebase-memory-mcp.payload.exe" in section+ and "mv build/win-cross/codebase-memory-mcp-launcher.exe "+ "build/win-cross/codebase-memory-mcp.exe" in section,+ f"docker-compose {service[:-1]} must assemble the Windows launcher/payload pair",+ )+require(+ "wine64 ./build/win-cross/codebase-memory-mcp.payload.exe --version" in compose+ and "wine64 cmd /c build/win-cross/codebase-memory-mcp.exe --version" in compose,+ "docker-compose Windows cross-smoke must execute the payload through Wine and the launcher "+ "through a Wine Windows parent",+)+require(+ "soak-windows:" not in compose,+ "docker-compose must not advertise a Wine daemon soak that cannot enforce Windows security "+ "and locking semantics",+)+require(+ 'if [ "${1:-full}" = "soak-windows" ]' in local_ci+ and 'exec "$ROOT/test-infrastructure/vm/win.sh" soak 10' in local_ci,+ "the maintained Windows soak entry point must route to the real Windows VM",+)+require(+ "soak)" in windows_vm+ and "vm-run-tests.sh --soak '$duration'" in windows_vm,+ "the Windows VM driver must route the native daemon soak through its protected-temp harness",+)+require(+ 'if [ "$1" = "--soak" ]' in windows_vm_runner+ and 'scripts/soak-test.sh "$binary" "$duration"' in windows_vm_runner+ and "=== soak-test: PASSED ===" in windows_vm_runner,+ "the Windows VM harness must run and completion-guard the native daemon soak under its "+ "protected temp root",+)require(pr_workflow.count("scripts/smoke-local.sh") >= 2,"PR Ubuntu and macOS smoke steps must run smoke-local.sh",@@ -330,10 +379,40 @@ if helper.is_file():breaktime.sleep(0.02)require(port > 0, "fixture server must publish a nonzero assigned port")- if port == 0 and log_file.is_file():- details = log_file.read_text(encoding="utf-8", errors="replace").strip()- if details:- failures.append(f"fixture server startup log: {details}")+ if port == 0:+ # A bare "no port" verdict is unactionable on a runner we+ # cannot reproduce locally: this failed macOS-Intel-only+ # and the conditional startup-log line named nothing+ # because the log was empty. Report the observable state+ # unconditionally so the next remote run identifies the+ # cause instead of costing another blind round.+ waited = 30 - max(0.0, deadline - time.monotonic())+ exit_status = process.poll()+ if log_file.is_file():+ details = log_file.read_text(+ encoding="utf-8", errors="replace"+ ).strip()+ else:+ details = "(no server.log created)"+ if port_file.is_file():+ raw = port_file.read_text(encoding="ascii", errors="replace")+ port_state = f"exists content={raw!r}"+ else:+ port_state = "absent"+ leftovers = sorted(+ entry.name+ for entry in temp_path.iterdir()+ if entry.name.startswith(f".{port_file.name}.")+ )+ failures.append(+ "fixture server diagnostics: "+ f"waited={waited:.1f}s "+ f"exit_status={'alive' if exit_status is None else exit_status} "+ f"port_file={port_state} "+ f"staged_temp_files={leftovers or 'none'} "+ f"interpreter={sys.executable} "+ f"startup_log={details or '(empty)'}"+ )if port > 0:opener = urllib.request.build_opener(urllib.request.ProxyHandler({})diff --git a/tests/test_soak_daemon_recovery_contract.sh b/tests/test_soak_daemon_recovery_contract.shindex 6908d398c..4b9444c7d 100644--- a/tests/test_soak_daemon_recovery_contract.sh+++ b/tests/test_soak_daemon_recovery_contract.sh@@ -22,6 +22,11 @@ for required in \'FAIL: soak DACL normalize' \'FAIL: soak DACL stamp' \'FAIL: soak child DACL reset' \+ 'SOAK_NATIVE_WINDOWS=false' \+ "eval 'coproc CBM_SOAK_SERVER {" \+ 'SERVER_PID=$CBM_SOAK_SERVER_PID' \+ 'start_mcp_server truncate' \+ 'start_mcp_server append' \'def handle_${i}(request):' \'trace_path "{\"project\":\"$PROJ_NAME\",\"function_name\":\"handle_1\",\"direction\":\"both\"}"' \'wait_for_daemon_stop "$DAEMON_STOP_COUNT"' \@@ -44,6 +49,12 @@ if grep -Fq '"repo_path":"$SOAK_PROJECT"' "$soak"; thenexit 1fi+if grep -Fq "json.load(open('\$DIAG_FILE'))" "$soak" ||+ grep -Fq 'with open(sys.argv[1]' "$soak"; then+ echo "FAIL: native Windows Python must consume diagnostics through stdin, not an MSYS path" >&2+ exit 1+fi+if grep -Fq 'ps -o %cpu= -p "$SERVER_PID"' "$soak"; thenecho "FAIL: soak idle CPU must not measure only the thin frontend" >&2exit 1