From 797d3248f0289277fd823a1b10e8e331aa5fa191 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 12 Oct 2026 15:13:36 +0000 Subject: [PATCH] Forward stub trace variables into the clean serve process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: env -i dropped SVC_STUB_*, so recovery tests saw an empty serve record even though the bound DSN was still passed. Evidence: SELF python3 -m unittest tests.test_svc.SvcDbRecoveryTests tests.test_svc_lifecycle_isolation — 34 tests OK. Impact: only SVC_STUB_* is added at launch; serve.env still omits them, and caller AGENT_SYSTEM_* stays out of the process. Refs: #485 Co-authored-by: Cursor --- scripts/svc.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/svc.sh b/scripts/svc.sh index d3b3f6a8..e1d577b5 100755 --- a/scripts/svc.sh +++ b/scripts/svc.sh @@ -1394,6 +1394,13 @@ svc_launch_serve() { if [ "${#guard_env[@]}" -gt 0 ]; then args+=("${guard_env[@]}") fi + # 桩只靠 SVC_STUB_* 找到记录目录。这些变量不写入 serve.env,避免 recover + # 把某次测试路径固化进实例;生产调用方没有它们。 + local k + while IFS= read -r k; do + [ -n "$k" ] || continue + args+=("$k=${!k}") + done < <(compgen -e | grep -E '^SVC_STUB_' || true) # shellcheck disable=SC2086 nohup "${args[@]}" "$ENV_BIN" serve $exec_args >> "$ENV_DIR/svc.log" 2>&1 9>&- & }