Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
FAIL=0
pass() { echo "PASS: $1"; }
fail() { echo "FAIL: $1"; FAIL=1; }
MANIFEST="$ROOT/deploy/base/control-plane/codex-llm-proxy.yaml"
KUSTOMIZE="$ROOT/deploy/base/control-plane/kustomization.yaml"
CONFIGMAPS="$ROOT/deploy/base/control-plane/configmaps.yaml"
RBAC="$ROOT/deploy/base/control-plane/rbac.yaml"
NETWORKPOLICIES="$ROOT/deploy/base/control-plane/networkpolicies.yaml"
TOKENS="$ROOT/deploy/scripts/apply-inter-service-tokens.sh"
IMAGES="$ROOT/deploy/images.json"
BUILD_IMAGES="$ROOT/scripts/minikube/build-images.sh"
WORKFLOW="$ROOT/.github/workflows/build-publish.yml"
GHCR="$ROOT/deploy/components/ghcr-images/kustomization.yaml"
MINIKUBE="$ROOT/deploy/overlays/minikube/kustomization.yaml"
if [[ ! -f "$MANIFEST" ]]; then
fail "missing $MANIFEST"
exit 1
fi
python3 - "$MANIFEST" "$KUSTOMIZE" "$CONFIGMAPS" "$RBAC" "$NETWORKPOLICIES" "$TOKENS" "$IMAGES" "$BUILD_IMAGES" "$WORKFLOW" "$GHCR" "$MINIKUBE" <<'PY'
import json, pathlib, re, sys
manifest, kustomize, configmaps, rbac, networkpolicies, tokens, images, build_images, workflow, ghcr, minikube = map(pathlib.Path, sys.argv[1:])
errors = []
def active(path):
"""The file without its comment lines, so a commented-out value never
satisfies an assertion."""
lines = path.read_text().splitlines()
return "\n".join(line for line in lines if not line.lstrip().startswith("#")) + "\n"
text = active(manifest)
for needle in (
"kind: Deployment",
"kind: Service",
"kind: ServiceAccount",
"name: codex-llm-proxy",
"automountServiceAccountToken: false",
"type: ClusterIP",
"name: runtime",
"name: admin",
"name: metrics",
"readOnlyRootFilesystem: true",
"runAsNonRoot: true",
"type: RuntimeDefault",
"drop: [ALL]",
"CODEX_LLM_PROXY_JWT_PUBLIC_KEY",
"CODEX_LLM_PROXY_CONTROL_API_TOKEN",
"CODEX_LLM_PROXY_EXECUTION_ENABLED",
"control-api-rpc-gateway.control-plane.svc",
):
if needle not in text:
errors.append(f"manifest missing {needle}")
# The per-attempt cap is the minimum of every source, so a stale value here
# silently holds it below the 30 min contract ceiling.
for var in ("CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS", "CODEX_LLM_PROXY_MAX_DEADLINE_MS"):
if f' {var}: "1800000"\n' not in text:
errors.append(f"manifest must set {var} to 1800000")
if "kind: Role" in text or "kind: RoleBinding" in text:
errors.append("proxy manifest must not declare Role/RoleBinding")
if "kind: ClusterRole" in text or "kind: ClusterRoleBinding" in text:
errors.append("proxy manifest must not declare ClusterRole/ClusterRoleBinding")
if "kind: Namespace" in text or "kind: CustomResourceDefinition" in text:
errors.append("proxy must not introduce a namespace or CRD")
if "kind: Ingress" in text or "kind: Gateway" in text:
errors.append("proxy must not expose Ingress or Gateway")
if "automountServiceAccountToken: true" in text:
errors.append("proxy must not automount a service account token")
if "type: LoadBalancer" in text or "type: NodePort" in text:
errors.append("proxy Service must stay ClusterIP")
for forbidden in (
"DATABASE_URL",
"POSTGRES",
"CONTROL_API_DATABASE",
"control-api-internal-tokens",
"CONTROL_API_INTERNAL_SERVICE_TOKENS",
"CONTROL_API_INTERNAL_TOKENS",
):
if forbidden in text:
errors.append(f"proxy must not carry {forbidden}")
if re.search(r"capabilities:[\s\S]{0,80}\n\s+add:", text):
errors.append("proxy must not add Linux capabilities")
container_block = re.search(r"^ containers:\n((?: .+\n)+)", text, re.M)
named_containers = re.findall(
r"^ - name: (\S+)", container_block.group(1) if container_block else "", re.M
)
if named_containers != ["codex-llm-proxy"]:
errors.append(f"proxy must keep a single container, found {named_containers}")
# Measured on the shipping design (#739 D5): eight 8 MiB streams, two 24 MiB
# visual streams and three queued 8 MiB bodies peaked at 790 MiB of RSS with a
# 384 MiB old space and at 886-1009 MiB without it. The byte-based BodyBudget
# also admits about eight compact bodies of the worst structure the contract
# admits (#806 Q1), each a ~44 MiB tree once parsed. With 8 held streams, 8
# queued bodies and two visual streams, a 640 MiB old space aborted 3 of 3 and
# 768 MiB passed 3 of 3; that load peaked at 1327-1460 MiB of RSS on macOS (not
# cgroup memory). The limit is the maximum plus 25 %, rounded up to 2048Mi. The
# request stays at 768Mi (owner decision on review M4), so the scheduler
# reserves 768Mi and the burst up to the limit is not reserved on the node.
memory_limit = re.search(r"limits:\n\s+cpu: \S+\n\s+memory: (\S+)", text)
memory_request = re.search(r"requests:\n\s+cpu: \S+\n\s+memory: (\S+)", text)
heap_cap = re.search(
r"- name: NODE_OPTIONS\n\s+value: \"--max-old-space-size=(\d+)\"", text
)
if not memory_limit or memory_limit.group(1) != "2048Mi":
errors.append("proxy memory limit must be 2048Mi")
if not memory_request or memory_request.group(1) != "768Mi":
errors.append("proxy memory request must be 768Mi")
if not heap_cap or heap_cap.group(1) != "768":
errors.append("proxy must cap the V8 old space at 768 MiB through NODE_OPTIONS")
# #739 D6: on SIGTERM the proxy stops accepting and waits for its open streams
# (main.ts awaits servers.close()), so the grace period must outlast the
# longest stream plus 60 s for redeem and finalize. Derived from the same
# manifest, so the two values cannot drift apart.
stream_ms = re.findall(r'^ CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS: "(\d+)"$', text, re.M)
grace = re.findall(r"^\s+terminationGracePeriodSeconds: (\d+)$", text, re.M)
print(
f"parsed CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS={stream_ms} "
f"terminationGracePeriodSeconds={grace}"
)
if len(stream_ms) != 1 or len(grace) != 1:
errors.append(
"manifest must set CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS and "
"terminationGracePeriodSeconds exactly once"
)
else:
# Queue wait 60 + body read 10 + redeem 15 + finalize 30 (one retry)
# + margin 20. The proxy's test/deployManifest.test.ts derives the same
# sum from code.
required_grace = -(-int(stream_ms[0]) // 1000) + 135
if int(grace[0]) != required_grace:
errors.append(
f"terminationGracePeriodSeconds must be {required_grace} "
f"(MAX_STREAM_DURATION_MS / 1000 + 135), found {grace[0]}"
)
if "codex-llm-proxy.yaml" not in active(kustomize):
errors.append("kustomization does not include codex-llm-proxy.yaml")
rbac_text = active(rbac)
if re.search(r"name:\s*codex-llm-proxy", rbac_text):
errors.append("rbac.yaml must not grant the proxy a Role")
cm = active(configmaps)
if "location = /api/v1/mcp-host/llm/provider-attempts/authorize" not in cm:
errors.append("workflow gateway missing exact authorize location")
if "location = /api/v1/internal/llm/provider-attempts/redeem" not in cm:
errors.append("rpc gateway missing exact redeem location")
if "location = /api/v1/internal/llm/provider-attempts/finalize" not in cm:
errors.append("rpc gateway missing exact finalize location")
if cm.count("location / {\n return 403;") < 2:
errors.append("gateways must keep catch-all 403")
if "kind: Service" in cm and "codex-llm-gateway" in cm:
errors.append("must not add a third gateway")
if re.search(r"location\s+/api/v1/mcp-host/llm", cm):
errors.append("authorize path must stay exact-match, not a prefix wildcard")
if re.search(r"location\s+/api/v1/internal/llm", cm):
errors.append("redeem/finalize paths must stay exact-match, not a prefix wildcard")
if "codex-llm-gateway" in text or "nginx-codex" in cm:
errors.append("must not introduce a dedicated Codex gateway")
np = active(networkpolicies)
ingress = np[np.find("name: codex-llm-proxy-ingress"): np.find("name: codex-llm-proxy-egress")]
egress = np[np.find("name: codex-llm-proxy-egress"):]
if "namespaceSelector: {}" in ingress:
errors.append("proxy ingress must not admit every namespace")
if "podSelector: {}" in ingress.split("spec:", 1)[-1][:400]:
errors.append("proxy ingress must not select every pod")
if "cidr: 0.0.0.0/0" in ingress:
errors.append("proxy ingress must not open the public internet")
token_src = active(tokens)
if "codex-llm-proxy=${TOKEN_CODEX_LLM_PROXY}" not in token_src and "codex-llm-proxy=${TOKEN_CODEX" not in token_src:
errors.append("apply-inter-service-tokens.sh must project a dedicated codex-llm-proxy token")
if "codex-llm-proxy-secrets" not in token_src:
errors.append("proxy must receive only its dedicated secret, not the full token map")
manifest_json = json.loads(images.read_text())
row = next((item for item in manifest_json["images"] if item["name"] == "codex-llm-proxy"), None)
if not row:
errors.append("images.json missing codex-llm-proxy")
else:
paths = row.get("source_paths") or []
if "codex-llm-proxy/**" not in paths:
errors.append("images.json must watch codex-llm-proxy/**")
if "packages/llm-provider-attempt-contract/**" not in paths:
errors.append("images.json must watch packages/llm-provider-attempt-contract/**")
if row.get("published") is not True or row.get("deployed_to_minikube") is not True:
errors.append("codex-llm-proxy must be published and deployed_to_minikube")
for consumer in ("control-api", "mcp-host", "mcp-host-slim", "mcp-host-full", "mcp-host-desktop"):
item = next((entry for entry in manifest_json["images"] if entry["name"] == consumer), None)
if not item:
errors.append(f"images.json missing {consumer}")
continue
if "packages/llm-provider-attempt-contract/**" not in (item.get("source_paths") or []):
errors.append(f"{consumer} source_paths must include packages/llm-provider-attempt-contract/**")
build = active(build_images)
if "clerum/codex-llm-proxy:test" not in build:
errors.append("build-images.sh missing clerum/codex-llm-proxy:test")
if 'build_image "codex-llm-proxy"' not in build:
errors.append("build-images.sh missing build_image codex-llm-proxy")
wf = active(workflow)
if "- image: codex-llm-proxy" not in wf:
errors.append("build-publish.yml missing matrix image")
if "packages/llm-provider-attempt-contract/**" not in wf:
errors.append("build-publish.yml filters must watch the attempt contract")
if "clerum/codex-llm-proxy" not in active(ghcr):
errors.append("ghcr-images component missing rewrite")
if "clerum/codex-llm-proxy" not in active(minikube):
errors.append("minikube overlay images: missing codex-llm-proxy")
# The public base ships Codex subscriptions off and each environment's overlay
# turns them on; keyper-labs/evenfire-infra CI asserts the base half on every
# dev commit. The minikube overlay turns both switches on (#739).
if "CONTROL_API_CODEX_SUBSCRIPTION_ENABLED: 'false'" not in cm:
errors.append("base control-api config must keep Codex subscriptions disabled")
if 'CODEX_LLM_PROXY_EXECUTION_ENABLED: "false"' not in text:
errors.append("base codex-llm-proxy config must keep execution disabled")
# The proxy derives its body limit from the contract plus the envelope
# allowance; a literal in base would freeze it at a stale value.
if "CODEX_LLM_PROXY_MAX_BODY_BYTES" in text:
errors.append("base codex-llm-proxy config must not set CODEX_LLM_PROXY_MAX_BODY_BYTES")
overlay = minikube.parent
overlay_cm = active(overlay / "configmaps/control-api-config.yaml")
for needle in (
"CONTROL_API_CODEX_SUBSCRIPTION_ENABLED: 'true'",
"CODEX_LLM_PROXY_EXECUTION_ENABLED: 'true'",
):
if needle not in overlay_cm:
errors.append(f"minikube control-api-config must set {needle}")
if "CODEX_LLM_PROXY_EXECUTION_ENABLED: 'true'" not in active(
overlay / "configmaps/codex-llm-proxy-config.yaml"
):
errors.append("minikube codex-llm-proxy-config must enable execution")
if errors:
print("\n".join(errors))
sys.exit(1)
print("ok")
PY
if [[ $? -eq 0 ]]; then
pass "codex-llm-proxy deploy contract"
else
fail "codex-llm-proxy deploy contract"
fi
exit "$FAIL"