Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(e2e): end the WRC-HCC gate mktemp templates in the X run

Alfredo Lopez3dcdcb1c26fe
diff --git a/scripts/e2e/e2e-wrc-hcc-contracts.sh b/scripts/e2e/e2e-wrc-hcc-contracts.sh
index 71f650fe9..94f709711 100755
--- a/scripts/e2e/e2e-wrc-hcc-contracts.sh
+++ b/scripts/e2e/e2e-wrc-hcc-contracts.sh
@@ -69,7 +69,7 @@ require_command() {
}
start_wrc_port_forward() {
- WRC_PF_LOG="$(mktemp "${TMPDIR:-/tmp}/wrc-port-forward.XXXXXX.log")"
+ WRC_PF_LOG="$(mktemp "${TMPDIR:-/tmp}/wrc-port-forward.XXXXXX")"
# Start kubectl itself, not the kctl function: a backgrounded function runs in
# a subshell, so $! would be that subshell and stop_wrc_port_forward would leave
# kubectl running as an orphan with no ownership record.
@@ -292,7 +292,7 @@ ok "synthetic WorkflowRecipe applied"
start_wrc_port_forward
token="$(sign_wrc_status_token)"
-running_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-running-response.XXXXXX.json")"
+running_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-running-response.XXXXXX")"
running_http_status="$(curl -sS -o "$running_response_file" -w '%{http_code}' \
-X POST "http://127.0.0.1:${WRC_PORT}/api/v1/workflow/${WRC_RECIPE_NAME}/status" \
-H "Authorization: Bearer ${token}" \
@@ -315,7 +315,7 @@ else
exit 1
fi
-step_running_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-step-running-response.XXXXXX.json")"
+step_running_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-step-running-response.XXXXXX")"
step_running_payload='{"stepId":"tool-step","phase":"running","executor":"agentic"}'
step_running_http_status="$(curl -sS -o "$step_running_response_file" -w '%{http_code}' \
-X POST "http://127.0.0.1:${WRC_PORT}/api/v1/workflow/${WRC_RECIPE_NAME}/status" \
@@ -331,7 +331,7 @@ else
fi
rm -f "$step_running_response_file"
-premature_completed_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-premature-completed-response.XXXXXX.json")"
+premature_completed_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-premature-completed-response.XXXXXX")"
premature_completed_http_status="$(curl -sS -o "$premature_completed_response_file" -w '%{http_code}' \
-X POST "http://127.0.0.1:${WRC_PORT}/api/v1/workflow/${WRC_RECIPE_NAME}/status" \
-H "Authorization: Bearer ${token}" \
@@ -400,7 +400,7 @@ console.log(JSON.stringify({
}))
NODE
)"
-response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-status-response.XXXXXX.json")"
+response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-status-response.XXXXXX")"
http_status="$(curl -sS -o "$response_file" -w '%{http_code}' \
-X POST "http://127.0.0.1:${WRC_PORT}/api/v1/workflow/${WRC_RECIPE_NAME}/status" \
-H "Authorization: Bearer ${token}" \
@@ -423,7 +423,7 @@ else
exit 1
fi
-pending_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-pending-response.XXXXXX.json")"
+pending_response_file="$(mktemp "${TMPDIR:-/tmp}/wrc-pending-response.XXXXXX")"
pending_http_status="$(curl -sS -o "$pending_response_file" -w '%{http_code}' \
-X POST "http://127.0.0.1:${WRC_PORT}/api/v1/workflow/${WRC_RECIPE_NAME}/status" \
-H "Authorization: Bearer ${token}" \
diff --git a/scripts/tests/test-wrc-hcc-contracts-gate.sh b/scripts/tests/test-wrc-hcc-contracts-gate.sh
index 4d51566d3..d37a98239 100755
--- a/scripts/tests/test-wrc-hcc-contracts-gate.sh
+++ b/scripts/tests/test-wrc-hcc-contracts-gate.sh
@@ -357,4 +357,37 @@ else
fail "Makefile does not expose the WRC-HCC runtime gate with explicit profile ownership"
fi
+# BSD mktemp (macOS) substitutes the X run only at the END of the template. A
+# suffix after it (`...XXXXXX.log`) yields one fixed literal name, so a leftover
+# file or a concurrent run makes the next call fail with "File exists" and the
+# T2 Health gate dies with PROFILE_UNHEALTHY. Run every template the gate uses
+# twice: both calls must succeed and return different names.
+MKTEMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/wrc-hcc-mktemp-contract.XXXXXX")" || exit 1
+trap 'rm -rf "$READER_FIXTURE" "$MKTEMP_DIR"' EXIT
+mktemp_templates="$(grep -oE 'mktemp "[^"]+"' "$GATE" | sed -E 's/^mktemp //')"
+mktemp_template_count="$(printf '%s\n' "$mktemp_templates" | grep -c .)"
+mktemp_ok=1
+if [ "$mktemp_template_count" -lt 6 ]; then
+ mktemp_ok=0
+ echo " found only ${mktemp_template_count} mktemp templates in the gate, expected at least 6"
+fi
+while IFS= read -r template; do
+ [ -n "$template" ] || continue
+ expanded="$(TMPDIR="$MKTEMP_DIR" eval "printf '%s' $template")"
+ first="$(mktemp "$expanded" 2>/dev/null)" || first=""
+ second="$(mktemp "$expanded" 2>/dev/null)" || second=""
+ if [ -z "$first" ] || [ -z "$second" ] || [ "$first" = "$second" ]; then
+ mktemp_ok=0
+ echo " mktemp template is not unique on this platform: ${template}"
+ fi
+ rm -f "$first" "$second"
+done <<EOF
+$mktemp_templates
+EOF
+if [ "$mktemp_ok" = 1 ] && ! grep -qE 'mktemp "[^"]*XXXXXX[^"]+"' "$GATE"; then
+ pass "WRC-HCC contracts gate mktemp templates end in the X run and stay unique across calls"
+else
+ fail "WRC-HCC contracts gate uses a mktemp template with a suffix after the X run"
+fi
+
exit "$FAIL"