Skip to content

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

TypeScript

fix: close PR 416 validation findings

Alfredo Lopeze43a94841e4f
diff --git a/Makefile b/Makefile
index 376106c29..ba6a4be01 100644
--- a/Makefile
+++ b/Makefile
@@ -470,11 +470,36 @@ minikube-sync-auth-key-body:
.PHONY: minikube-sync-auth-key-if-present
minikube-sync-auth-key-if-present: ## Sync JWT public key only when minikube auth resources already exist
- @if ! $(KC) get secret rpc-proxy-secrets -n rpc-proxy >/dev/null 2>&1; then \
- echo "Skipping auth key sync (rpc-proxy-secrets not found yet)."; \
- elif ! $(KC) get configmap mcp-host-config -n mcp-host >/dev/null 2>&1; then \
- echo "Skipping auth key sync (mcp-host-config not found yet)."; \
- elif [ "$(T2_MUTATION_LOCK_WRAPPED)" = "true" ]; then \
+ @kubectl_probe_is_not_found() { \
+ probe_output="$$1"; \
+ probe_kind="$$2"; \
+ probe_name="$$3"; \
+ [[ "$$probe_output" =~ ^Error[[:space:]]+from[[:space:]]+server[[:space:]]+\(NotFound\):[[:space:]] ]] || return 1; \
+ probe_detail="$${probe_output#*): }"; \
+ case "$$probe_kind" in \
+ secret) case "$$probe_detail" in secret\ *|secrets\ *) ;; *) return 1 ;; esac ;; \
+ configmap) case "$$probe_detail" in configmap\ *|configmaps\ *) ;; *) return 1 ;; esac ;; \
+ *) return 1 ;; \
+ esac; \
+ [[ "$$probe_detail" == *"\"$$probe_name\""* ]] || return 1; \
+ }; \
+ rpc_probe_status=0; \
+ rpc_probe_output="$$( $(KC) get secret rpc-proxy-secrets -n rpc-proxy 2>&1 )" || rpc_probe_status=$$?; \
+ if [ "$$rpc_probe_status" -ne 0 ]; then \
+ if kubectl_probe_is_not_found "$$rpc_probe_output" secret rpc-proxy-secrets; then \
+ echo "Skipping auth key sync (rpc-proxy-secrets not found yet)."; exit 0; \
+ fi; \
+ printf '%s\n' "$$rpc_probe_output" >&2; exit "$$rpc_probe_status"; \
+ fi; \
+ mcp_probe_status=0; \
+ mcp_probe_output="$$( $(KC) get configmap mcp-host-config -n mcp-host 2>&1 )" || mcp_probe_status=$$?; \
+ if [ "$$mcp_probe_status" -ne 0 ]; then \
+ if kubectl_probe_is_not_found "$$mcp_probe_output" configmap mcp-host-config; then \
+ echo "Skipping auth key sync (mcp-host-config not found yet)."; exit 0; \
+ fi; \
+ printf '%s\n' "$$mcp_probe_output" >&2; exit "$$mcp_probe_status"; \
+ fi; \
+ if [ "$(T2_MUTATION_LOCK_WRAPPED)" = "true" ]; then \
$(MAKE) --no-print-directory minikube-sync-auth-key-body; \
else \
$(MAKE) --no-print-directory minikube-sync-auth-key; \
diff --git a/scripts/minikube/full-setup.sh b/scripts/minikube/full-setup.sh
index edfb9654f..40db9ba24 100755
--- a/scripts/minikube/full-setup.sh
+++ b/scripts/minikube/full-setup.sh
@@ -1052,9 +1052,11 @@ else
# rewriting (it strips the restartedAt annotation, so a generation wait
# loops until timeout).
GFS_READER_ROLLOUT_AUTHORIZED=true ALLOWED_CONTEXTS="${PROFILE}" CONTEXT="${PROFILE}" \
+ T2_SKIP_LOCK=true \
bash "${PROJECT_DIR}/scripts/minikube/settle-gfs-reader-rollout.sh"
PATH="${PROJECT_DIR}/scripts/minikube/gfs-rollout-shim:${PATH}" \
GFS_RESTORE_ACTIVE_NOLOGIN=true GFS_RECOVER_ABANDONED_STATE=true \
+ T2_SKIP_LOCK=true \
CONTEXT="${PROFILE}" \
bash "${PROJECT_DIR}/deploy/scripts/reconcile-gfs-deploy-credentials.sh"
# A staged sync may have deferred active-pod proof until the reconciler
@@ -1127,9 +1129,11 @@ else
GFS_AUTH_SYNC_ALLOW_STAGED=true \
bash "${SCRIPT_DIR}/sync-auth-key.sh" --context="${PROFILE}" --require-gfs
GFS_READER_ROLLOUT_AUTHORIZED=true ALLOWED_CONTEXTS="${PROFILE}" CONTEXT="${PROFILE}" \
+ T2_SKIP_LOCK=true \
bash "${PROJECT_DIR}/scripts/minikube/settle-gfs-reader-rollout.sh"
PATH="${PROJECT_DIR}/scripts/minikube/gfs-rollout-shim:${PATH}" \
GFS_RESTORE_ACTIVE_NOLOGIN=true GFS_RECOVER_ABANDONED_STATE=true \
+ T2_SKIP_LOCK=true \
CONTEXT="${PROFILE}" \
bash "${PROJECT_DIR}/deploy/scripts/reconcile-gfs-deploy-credentials.sh"
# The preceding staged sync is allowed to wait for this DSN-producing
diff --git a/scripts/minikube/settle-gfs-reader-rollout.sh b/scripts/minikube/settle-gfs-reader-rollout.sh
index 4b0a839f2..5167c5227 100755
--- a/scripts/minikube/settle-gfs-reader-rollout.sh
+++ b/scripts/minikube/settle-gfs-reader-rollout.sh
@@ -106,10 +106,15 @@ else
[ "${GFS_READER_ROLLOUT_AUTHORIZED:-false}" = true ] ||
die 'non-T2 reader settlement requires explicit GFS_READER_ROLLOUT_AUTHORIZED=true'
authorized=false
- IFS=',' read -r -a allowed_contexts <<<"${ALLOWED_CONTEXTS:-}"
- for allowed_context in "${allowed_contexts[@]}"; do
- [ "$allowed_context" = "$CONTEXT" ] && authorized=true
- done
+ # Bash 3.2 expands an empty array as an unset variable under `set -u`.
+ # Leave the explicit authorization failure below in charge when the caller
+ # omits ALLOWED_CONTEXTS instead of masking it with an array expansion error.
+ if [ -n "${ALLOWED_CONTEXTS:-}" ]; then
+ IFS=',' read -r -a allowed_contexts <<<"${ALLOWED_CONTEXTS}"
+ for allowed_context in "${allowed_contexts[@]}"; do
+ [ "$allowed_context" = "$CONTEXT" ] && authorized=true
+ done
+ fi
[ "$authorized" = true ] ||
die "non-T2 reader settlement context is not in the explicit ALLOWED_CONTEXTS list: $CONTEXT"
fi
@@ -168,9 +173,12 @@ while IFS='|' read -r rs_name rs_owner rs_replicas rs_ready rs_rev; do
scaled_rs_names+=("$rs_name")
done <<<"$rs_rows"
-for rs_name in "${scaled_rs_names[@]}"; do
- wait_for_scaled_rs "$rs_name"
-done
+# Bash 3.2 treats an empty array expansion as unbound with `set -u`.
+if [ "${#scaled_rs_names[@]}" -gt 0 ]; then
+ for rs_name in "${scaled_rs_names[@]}"; do
+ wait_for_scaled_rs "$rs_name"
+ done
+fi
pod_rows="$(kc -n "$GFS_NS" get pods -l "$SELECTOR" -o \
'jsonpath={range .items[*]}{.metadata.name}{"|"}{.status.conditions[?(@.type=="Ready")].status}{"|"}{.metadata.deletionTimestamp}{"|"}{.status.containerStatuses[0].state.waiting.reason}{"\n"}{end}' \
diff --git a/scripts/minikube/t2-common.sh b/scripts/minikube/t2-common.sh
index 5fdc7e33e..ea0d1e258 100755
--- a/scripts/minikube/t2-common.sh
+++ b/scripts/minikube/t2-common.sh
@@ -83,8 +83,16 @@ T2_REQUIRED_NAMESPACES="$T2_REQUIRED_NAMESPACES"
if [ -z "$T2_REQUIRED_NAMESPACES" ]; then T2_REQUIRED_NAMESPACES="control-plane gfs mcp-host mcp-server profiles rpc-proxy channels sandbox-recipes sandbox-ui webhook-ingress registry"; fi
T2_REQUIRED_SERVICES="$T2_REQUIRED_SERVICES"
if [ -z "$T2_REQUIRED_SERVICES" ]; then T2_REQUIRED_SERVICES="control-plane/control-postgres control-plane/control-api control-plane/control-ui control-plane/host-context-controller control-plane/workflow-recipes profiles/external-rest-api profiles/profile-ui rpc-proxy/rpc-proxy mcp-server/mcp-proxy"; fi
+# An empty or unset scope uses the production contract: every core Deployment
+# is mandatory and every additional Deployment in the inventory is evaluated.
+# Tests may provide a non-empty scope for isolated fixtures; that explicit
+# scope remains narrowed to the listed deployments.
T2_REQUIRED_DEPLOYMENTS="$T2_REQUIRED_DEPLOYMENTS"
-if [ -z "$T2_REQUIRED_DEPLOYMENTS" ]; then T2_REQUIRED_DEPLOYMENTS="control-plane/control-api control-plane/host-context-controller profiles/external-rest-api rpc-proxy/rpc-proxy mcp-host/chatllm"; fi
+T2_REQUIRED_DEPLOYMENTS_INCLUDE_ADDITIONAL=false
+if [ -z "${T2_REQUIRED_DEPLOYMENTS//[[:space:]]/}" ]; then
+ T2_REQUIRED_DEPLOYMENTS="control-plane/control-api control-plane/host-context-controller profiles/external-rest-api rpc-proxy/rpc-proxy mcp-host/chatllm"
+ T2_REQUIRED_DEPLOYMENTS_INCLUDE_ADDITIONAL=true
+fi
T2_REQUIRED_SECRETS="$T2_REQUIRED_SECRETS"
if [ -z "$T2_REQUIRED_SECRETS" ]; then T2_REQUIRED_SECRETS="control-plane/control-postgres control-plane/control-api-secrets control-plane/control-ui-secrets control-plane/inter-service-tokens profiles/external-rest-api-secrets rpc-proxy/rpc-proxy-secrets mcp-host/chatllm-api-keys gfs/gfs-controller-db gfs/gfs-controller-reader-db"; fi
T2_REQUIRED_CONFIGMAPS="$T2_REQUIRED_CONFIGMAPS"
@@ -552,24 +560,38 @@ t2_deployment_check() {
T2_NEXT_COMMAND="MINIKUBE_PROFILE=$T2_PROFILE make minikube-setup-local"
t2_fail PROFILE_UNHEALTHY 'deployment readiness inventory is unavailable'
fi
- if ! unready="$(python3 - "$deployment_json" "$T2_REQUIRED_DEPLOYMENTS" 2>/dev/null <<'PY'
+ if ! unready="$(python3 - "$deployment_json" "$T2_REQUIRED_DEPLOYMENTS" "$T2_REQUIRED_DEPLOYMENTS_INCLUDE_ADDITIONAL" 2>/dev/null <<'PY'
import json
import sys
payload = json.loads(sys.argv[1])
-required_refs = {}
+scope_refs = {}
for ref in sys.argv[2].split():
namespace, separator, name = ref.partition("/")
if not separator or not namespace or not name:
raise ValueError("invalid required deployment reference")
- required_refs[(namespace, name)] = None
-bad = []
+ scope_refs[(namespace, name)] = None
+include_additional = sys.argv[3] == "true"
+
+inventory = {}
+inventory_order = []
for item in payload.get("items", []):
metadata = item.get("metadata") or {}
identity = (metadata.get("namespace"), metadata.get("name"))
- if identity in required_refs:
- required_refs[identity] = item
+ if identity not in inventory:
+ inventory_order.append(identity)
+ inventory[identity] = item
-for (namespace, name), item in required_refs.items():
+selected = []
+if scope_refs:
+ for identity in scope_refs:
+ selected.append((identity, inventory.get(identity)))
+ if include_additional:
+ selected.extend((identity, inventory[identity]) for identity in inventory_order if identity not in scope_refs)
+else:
+ selected = [(identity, inventory[identity]) for identity in inventory_order]
+
+bad = []
+for (namespace, name), item in selected:
if item is None:
bad.append(f"{namespace}/{name} missing")
continue
diff --git a/scripts/tests/test-minikube-makefile.sh b/scripts/tests/test-minikube-makefile.sh
index 009c4a47f..768f6c611 100755
--- a/scripts/tests/test-minikube-makefile.sh
+++ b/scripts/tests/test-minikube-makefile.sh
@@ -10,7 +10,7 @@ fail() { echo "FAIL: $1"; FAIL=1; }
assert_succeeds_dry() {
local target="$1"
- if make -n "$target" >/dev/null 2>&1; then
+ if make -n MAKE=: "$target" >/dev/null 2>&1; then
echo "PASS: make -n $target parses"
else
echo "FAIL: make -n $target failed to parse"
@@ -77,7 +77,6 @@ assert_make_contains() {
assert_succeeds_dry minikube-start
assert_succeeds_dry minikube-deploy-all
assert_succeeds_dry minikube-deploy-all-body
-assert_succeeds_dry minikube-sync-auth-key-if-present
assert_succeeds_dry minikube-verify-networkpolicies
assert_contains minikube-start "minikube-sync-auth-key-if-present"
@@ -91,6 +90,8 @@ assert_contains minikube-verify-networkpolicies "verify-networkpolicies.sh --ove
assert_contains minikube-sync-auth-key-if-present "rpc-proxy-secrets"
assert_file_contains Makefile "T2_MUTATION_LOCK_WRAPPED"
assert_contains minikube-sync-auth-key-if-present "minikube-sync-auth-key"
+assert_contains minikube-sync-auth-key-if-present "NotFound"
+assert_contains minikube-sync-auth-key-if-present "rpc_probe_status"
assert_not_contains minikube-sync-auth-key-if-present "canonical T2 profile lock is not held"
assert_contains minikube-deploy-all-body "set -o pipefail"
assert_contains minikube-deploy-all-body "mktemp"
@@ -259,4 +260,134 @@ assert_minikube_setup_e2e_fixtures_are_gated_on_evaluated_image_source
assert_minikube_setup_e2e_still_uses_the_pull_path
assert_the_tag_override_reaches_the_setup_script
+# Resource probes may skip only an explicit NotFound. A forbidden/API failure
+# must stop the target before it can certify a partially reachable profile.
+assert_auth_probe_error_handling() {
+ local stub_root output status
+ stub_root="$(mktemp -d)"
+ output="$stub_root/output"
+ cat > "$stub_root/kubectl" <<'STUB'
+#!/usr/bin/env bash
+if [[ "$*" == *"get configmap mcp-host-config"* ]]; then
+ printf '%s\n' "${KUBECTL_MCP_PROBE_ERROR:-${KUBECTL_PROBE_ERROR:-}}" >&2
+ exit "${KUBECTL_MCP_PROBE_STATUS:-${KUBECTL_PROBE_STATUS:-1}}"
+fi
+printf '%s\n' "${KUBECTL_PROBE_ERROR:-}" >&2
+exit "${KUBECTL_PROBE_STATUS:-1}"
+STUB
+ chmod +x "$stub_root/kubectl"
+
+ if KUBECTL_PROBE_ERROR='Error from server (NotFound): secrets "rpc-proxy-secrets" not found' \
+ PATH="$stub_root:$PATH" make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ pass "minikube-sync-auth-key-if-present skips an explicit NotFound"
+ else
+ fail "minikube-sync-auth-key-if-present did not skip an explicit NotFound: $(cat "$output")"
+ fi
+
+ if KUBECTL_PROBE_ERROR='Error from server (NotFound): configmaps "rpc-proxy-secrets" not found' \
+ PATH="$stub_root:$PATH" make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present confused a wrong-kind NotFound with the Secret probe"
+ else
+ status=$?
+ if [ "$status" -ne 0 ]; then
+ pass "minikube-sync-auth-key-if-present rejects a wrong-kind NotFound"
+ else
+ fail "minikube-sync-auth-key-if-present returned an unexpected status for a wrong-kind NotFound"
+ fi
+ fi
+
+ if KUBECTL_PROBE_STATUS=0 \
+ KUBECTL_MCP_PROBE_ERROR='Error from server (NotFound): configmaps "mcp-host-config" not found' \
+ KUBECTL_MCP_PROBE_STATUS=1 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ pass "minikube-sync-auth-key-if-present skips an explicit ConfigMap NotFound"
+ else
+ fail "minikube-sync-auth-key-if-present did not skip an explicit ConfigMap NotFound: $(cat "$output")"
+ fi
+
+ if KUBECTL_PROBE_ERROR='Error from server (Forbidden): secrets is forbidden' \
+ PATH="$stub_root:$PATH" make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present swallowed a Forbidden probe error: $(cat "$output")"
+ else
+ status=$?
+ if [ "$status" -ne 0 ]; then
+ pass "minikube-sync-auth-key-if-present fails closed on a Forbidden probe error"
+ else
+ fail "minikube-sync-auth-key-if-present returned an unexpected status for a Forbidden probe error"
+ fi
+ fi
+
+ if KUBECTL_PROBE_STATUS=0 \
+ KUBECTL_MCP_PROBE_ERROR='Error from server (Forbidden): configmaps is forbidden' \
+ KUBECTL_MCP_PROBE_STATUS=1 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present swallowed a ConfigMap Forbidden probe error: $(cat "$output")"
+ else
+ status=$?
+ if [ "$status" -ne 0 ]; then
+ pass "minikube-sync-auth-key-if-present fails closed on a ConfigMap Forbidden probe error"
+ else
+ fail "minikube-sync-auth-key-if-present returned an unexpected status for a ConfigMap Forbidden probe error"
+ fi
+ fi
+
+ if KUBECTL_PROBE_ERROR='/bin/bash: kubectl: command not found' \
+ KUBECTL_PROBE_STATUS=127 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present swallowed command-not-found"
+ else
+ status=$?
+ if [ "$status" -ne 0 ] && grep -Fq 'command not found' "$output"; then
+ pass "minikube-sync-auth-key-if-present propagates command-not-found"
+ else
+ fail "minikube-sync-auth-key-if-present did not preserve command-not-found failure: status=$status output=$(cat "$output")"
+ fi
+ fi
+
+ if KUBECTL_PROBE_ERROR='Unable to connect to the server: net/http: TLS handshake timeout' \
+ KUBECTL_PROBE_STATUS=1 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present swallowed a timeout probe error"
+ else
+ status=$?
+ if [ "$status" -ne 0 ]; then
+ pass "minikube-sync-auth-key-if-present propagates timeout probe errors"
+ else
+ fail "minikube-sync-auth-key-if-present returned an unexpected status for a timeout probe error"
+ fi
+ fi
+
+ if KUBECTL_PROBE_ERROR='error: context "probe-contract" does not exist' \
+ KUBECTL_PROBE_STATUS=1 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ fail "minikube-sync-auth-key-if-present swallowed a context probe error"
+ else
+ status=$?
+ if [ "$status" -ne 0 ]; then
+ pass "minikube-sync-auth-key-if-present propagates context probe errors"
+ else
+ fail "minikube-sync-auth-key-if-present returned an unexpected status for a context probe error"
+ fi
+ fi
+
+ if KUBECTL_PROBE_STATUS=0 KUBECTL_MCP_PROBE_STATUS=0 PATH="$stub_root:$PATH" \
+ make -C "$REPO_ROOT" minikube-sync-auth-key-if-present MAKE=: \
+ MINIKUBE_PROFILE=probe-contract >"$output" 2>&1; then
+ pass "minikube-sync-auth-key-if-present proceeds when both probes succeed"
+ else
+ fail "minikube-sync-auth-key-if-present rejected successful probes: $(cat "$output")"
+ fi
+ rm -rf "$stub_root"
+}
+
+assert_auth_probe_error_handling
+
exit $FAIL
diff --git a/scripts/tests/test-minikube-settle-gfs-reader-rollout.sh b/scripts/tests/test-minikube-settle-gfs-reader-rollout.sh
index c03134af3..834b70e35 100755
--- a/scripts/tests/test-minikube-settle-gfs-reader-rollout.sh
+++ b/scripts/tests/test-minikube-settle-gfs-reader-rollout.sh
@@ -7,6 +7,10 @@ SCRIPT="$ROOT/scripts/minikube/settle-gfs-reader-rollout.sh"
fail() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
bash -n "$SCRIPT"
+grep -Fq 'if [ "${#scaled_rs_names[@]}" -gt 0 ]; then' "$SCRIPT" ||
+ fail 'settle must guard empty ReplicaSet arrays under Bash 3.2 set -u'
+grep -Fq 'if [ -n "${ALLOWED_CONTEXTS:-}" ]; then' "$SCRIPT" ||
+ fail 'settle must guard empty authorization-context arrays under Bash 3.2 set -u'
run_settle() {
local fake_dir repo profile sha
diff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.sh
index 872a4d3d2..dfc20664e 100755
--- a/scripts/tests/test-minikube-t2-contract.sh
+++ b/scripts/tests/test-minikube-t2-contract.sh
@@ -229,6 +229,10 @@ if [[ "$(grep -c -- '--require-gfs' "$ROOT/scripts/minikube/full-setup.sh")" -lt
echo 'FAIL: every GFS-specific full-setup auth sync must require a non-empty source key' >&2
exit 1
fi
+if [[ "$(grep -c 'T2_SKIP_LOCK=true' "$ROOT/scripts/minikube/full-setup.sh")" -lt 4 ]]; then
+ echo 'FAIL: full-setup GFS child mutators must validate the parent lease instead of acquiring a second lock' >&2
+ exit 1
+fi
if grep -Eq 'make minikube-pre-gate-sync|pre-gate-sync\.sh' "$PREFLIGHT"; then
echo 'FAIL: preflight invokes pre-gate-sync' >&2
diff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.sh
index 3a7bf5e1e..4edcb6e79 100755
--- a/scripts/tests/test-minikube-t2-scenarios.sh
+++ b/scripts/tests/test-minikube-t2-scenarios.sh
@@ -292,6 +292,33 @@ env "${repo_env[@]}" READY_JSON="$ready_json" \
multi_ready_json='{"items":[{"metadata":{"namespace":"gfs","name":"gfsc-reader","generation":7},"spec":{"replicas":1},"status":{"observedGeneration":7,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"gfs","name":"gfsc-writer","generation":11},"spec":{"replicas":1},"status":{"observedGeneration":11,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"unrelated","generation":3},"spec":{"replicas":1},"status":{"observedGeneration":3,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS='gfs/gfsc-reader gfs/gfsc-writer' MULTI_READY_JSON="$multi_ready_json" \
bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$MULTI_READY_JSON"; }; t2_deployment_check' bash "$COMMON"
+
+# The default scope is fail-closed even when the API returns an empty inventory.
+empty_inventory_json='{"items":[]}'
+expect_code PROFILE_UNHEALTHY default-empty-inventory default-empty-inventory \
+ env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS= EMPTY_INVENTORY_JSON="$empty_inventory_json" \
+ bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$EMPTY_INVENTORY_JSON"; }; t2_deployment_check' bash "$COMMON"
+
+# A missing core Deployment is reported even when the other core Deployments
+# are healthy; the inventory cannot silently shrink the required contract.
+missing_core_json='{"items":[{"metadata":{"namespace":"control-plane","name":"control-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"host-context-controller","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"profiles","name":"external-rest-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"rpc-proxy","name":"rpc-proxy","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
+expect_code PROFILE_UNHEALTHY missing-core-deployment missing-core-deployment \
+ env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS= MISSING_CORE_JSON="$missing_core_json" \
+ bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$MISSING_CORE_JSON"; }; t2_deployment_check' bash "$COMMON"
+
+# All five core Deployments ready is a valid default-scope pass.
+default_core_ready_json='{"items":[{"metadata":{"namespace":"control-plane","name":"control-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"host-context-controller","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"profiles","name":"external-rest-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"rpc-proxy","name":"rpc-proxy","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"mcp-host","name":"chatllm","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
+env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS= DEFAULT_CORE_READY_JSON="$default_core_ready_json" \
+ bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$DEFAULT_CORE_READY_JSON"; }; t2_deployment_check' bash "$COMMON"
+
+# Production scope also evaluates every additional Deployment. Keep the five
+# core Deployments healthy while an otherwise out-of-scope UI is unready; the
+# old allowlist passed this fixture and certified a broken profile.
+out_of_scope_unready_json='{"items":[{"metadata":{"namespace":"control-plane","name":"control-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"host-context-controller","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"profiles","name":"external-rest-api","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"rpc-proxy","name":"rpc-proxy","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"mcp-host","name":"chatllm","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}},{"metadata":{"namespace":"control-plane","name":"control-ui","generation":1},"spec":{"replicas":1},"status":{"observedGeneration":1,"updatedReplicas":1,"readyReplicas":0,"availableReplicas":0,"unavailableReplicas":1}}]}'
+expect_code PROFILE_UNHEALTHY out-of-scope-unready out-of-scope-unready \
+ env "${repo_env[@]}" T2_REQUIRED_DEPLOYMENTS= OUT_OF_SCOPE_JSON="$out_of_scope_unready_json" \
+ bash -c 'source "$1"; T2_PLAN_MODE=false; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$OUT_OF_SCOPE_JSON"; }; t2_deployment_check' bash "$COMMON"
+
stale_generation_json='{"items":[{"metadata":{"namespace":"gfs","name":"gfsc-reader","generation":8},"spec":{"replicas":1},"status":{"observedGeneration":7,"updatedReplicas":1,"readyReplicas":1,"availableReplicas":1,"unavailableReplicas":0}}]}'
expect_code PROFILE_UNHEALTHY stale-generation stale-generation \
env "${repo_env[@]}" INVALID_INVENTORY="$stale_generation_json" \
@@ -355,6 +382,7 @@ grep -Fq 'wait-gfs-reader-ready.sh' "$ROOT/scripts/minikube/pre-gate-sync.sh" ||
[[ "$(grep -c 'scripts/minikube/settle-gfs-reader-rollout.sh' "$ROOT/scripts/minikube/full-setup.sh")" -ge 2 ]] || fail 'full-setup REUSE_DB must settle a Ready gfsc-reader leftover rollout claim before both reconciles'
[[ "$(grep -c 'gfs-rollout-shim' "$ROOT/scripts/minikube/full-setup.sh")" -ge 2 ]] || fail 'full-setup REUSE_DB reconciles must use the HCC-safe reader rollout wait on both calls'
[[ "$(grep -c 'sync-auth-key.sh' "$ROOT/scripts/minikube/full-setup.sh")" -ge 3 ]] || fail 'full-setup must re-sync gfs-config.jwt-public-key before both GFS reconciles'
+[[ "$(grep -c 'T2_SKIP_LOCK=true' "$ROOT/scripts/minikube/full-setup.sh")" -ge 4 ]] || fail 'full-setup GFS child mutators must validate the parent lease instead of acquiring a second lock'
grep -Fq 'T2_LOCK_ROOT' "$COMMON"
grep -Fq 't2_mutation_lock' "$COMMON"
grep -Fq 't2_lock_validate_inherited' "$COMMON"