Skip to content

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

TypeScript

ci: port monorepo pre-merge gates to ci-public and add leak guards

Jose Ramirez5b0d1f72bfe9
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.yml
index 9022f2efb..87b2ca655 100644
--- a/.github/workflows/ci-public.yml
+++ b/.github/workflows/ci-public.yml
@@ -113,3 +113,332 @@ jobs:
if: matrix.service != 'mcp-servers'
working-directory: ${{ matrix.service }}
run: npx tsc --noEmit
+
+ # ─── control-api real-Postgres migration ─────────────────────────────────
+ # Runs the DB migration against a real Postgres 16 — catches the exact class
+ # of failure (a config/env gap surfacing at migration time) that otherwise
+ # only appears at deploy. Runs unconditionally in the public repo (no
+ # paths-filter): correctness over CI minutes on a low-volume repo.
+ control-api-migration:
+ name: Control API migration (Postgres 16)
+ runs-on: ubuntu-latest
+ services:
+ postgres:
+ image: postgres:16-alpine
+ env:
+ POSTGRES_USER: postgres
+ POSTGRES_DB: postgres
+ POSTGRES_HOST_AUTH_METHOD: trust
+ ports: ['15433:5432']
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 5s
+ --health-timeout 5s
+ --health-retries 10
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ with:
+ node-version: '24'
+ cache: npm
+ cache-dependency-path: control-api/package-lock.json
+
+ - name: Install dependencies
+ working-directory: control-api
+ run: npm ci
+
+ - name: Install workflow-runtime-core dependencies
+ working-directory: packages/workflow-runtime-core
+ run: npm ci
+
+ - name: Build workflow-runtime-core
+ working-directory: packages/workflow-runtime-core
+ run: npm run build
+
+ - name: Run real Postgres migration integration
+ working-directory: control-api
+ env:
+ CONTROL_API_REAL_PG_ADMIN_URL: postgresql://[email protected]:15433/postgres
+ run: npm test -- --run test/db.realPostgresMigration.integration.test.ts
+
+ # ─── control-ui build check ──────────────────────────────────────────────
+ # control-ui is intentionally NOT in the build/test matrix: its vitest suite
+ # has known pre-existing failures and its tsconfig spans test files, so the
+ # matrix's `npm test` + bare `tsc --noEmit` would be red. A clean install +
+ # production `next build` runs the TypeScript typecheck and ESLint over the
+ # app and fails on any compile error.
+ control-ui-build:
+ name: Build (control-ui)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ with:
+ node-version: '24'
+ cache: npm
+ cache-dependency-path: control-ui/package-lock.json
+ - name: Install dependencies
+ working-directory: control-ui
+ run: npm ci
+ - name: Build (next build — typecheck + lint + compile)
+ working-directory: control-ui
+ run: npm run build
+
+ # ─── Registry contract — boot evenfire-registry and drive the real client ──
+ # Catches wire-format drift in clerumRegistryClient.ts before merge. Requires
+ # CROSS_REPO_READ_TOKEN (a fine-grained PAT with Contents:read on the sibling
+ # registry repo). When the secret is absent — every fork PR, and any repo
+ # where ops has not provisioned it — the job short-circuits with a warning
+ # instead of failing, exactly like the monorepo gate.
+ registry-contract:
+ name: Registry contract (consumer → registry)
+ runs-on: ubuntu-latest
+ services:
+ postgres:
+ image: postgres:16-alpine
+ env:
+ POSTGRES_USER: postgres
+ POSTGRES_PASSWORD: postgres
+ POSTGRES_DB: registry
+ ports: ['15432:5432']
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 5s
+ --health-timeout 5s
+ --health-retries 10
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+
+ - name: Check cross-repo token availability
+ id: token_check
+ env:
+ CROSS_REPO_READ_TOKEN: ${{ secrets.CROSS_REPO_READ_TOKEN }}
+ run: |
+ if [ -z "$CROSS_REPO_READ_TOKEN" ]; then
+ echo "::warning::CROSS_REPO_READ_TOKEN not set — skipping registry-contract job. Provision the secret in repo Settings → Secrets to enable cross-repo contract tests."
+ echo "skip=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "skip=false" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Checkout evenfire-registry
+ if: steps.token_check.outputs.skip != 'true'
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ repository: keyper-labs/evenfire-registry
+ path: evenfire-registry
+ token: ${{ secrets.CROSS_REPO_READ_TOKEN }}
+
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ if: steps.token_check.outputs.skip != 'true'
+ with:
+ node-version: '24'
+ cache: 'npm'
+ cache-dependency-path: |
+ workflow-recipes/package-lock.json
+ evenfire-registry/package-lock.json
+
+ - name: Boot evenfire-registry
+ if: steps.token_check.outputs.skip != 'true'
+ working-directory: evenfire-registry
+ # NOTE: registry reads CLERUM_REGISTRY_PORT (not PORT). Without this
+ # the server binds to its 8085 default and the readiness poll on 18085
+ # times out.
+ run: |
+ npm ci
+ npm run build
+ CLERUM_REGISTRY_PORT=18085 \
+ CLERUM_REGISTRY_DB_URL=postgres://postgres:[email protected]:15432/registry \
+ CLERUM_REGISTRY_AUTH_ENABLED=false \
+ node dist/main.js &
+ echo $! > /tmp/registry.pid
+ for _ in $(seq 1 20); do
+ if curl -sf http://127.0.0.1:18085/health >/dev/null 2>&1; then
+ echo "Registry ready"
+ break
+ fi
+ sleep 1
+ done
+ curl -sf http://127.0.0.1:18085/health || (echo "Registry never became ready" && exit 1)
+
+ - name: Run consumer integration tests against the booted registry
+ if: steps.token_check.outputs.skip != 'true'
+ working-directory: workflow-recipes
+ env:
+ TEST_REGISTRY_URL: http://127.0.0.1:18085
+ run: |
+ npm ci
+ npm test -- --run test/integration/clerumRegistryClient.test.ts
+
+ - name: Stop registry
+ if: always() && steps.token_check.outputs.skip != 'true'
+ run: |
+ if [ -f /tmp/registry.pid ]; then
+ kill "$(cat /tmp/registry.pid)" 2>/dev/null || true
+ fi
+
+ # ─── Bash syntax + shell test gates ───────────────────────────────────────
+ # `bash -n` is a parse-only check; catches dangling braces / bad substitutions
+ # that would break `make minikube-*` at runtime. The named script tests assert
+ # generated-manifest and gate-orchestration contracts.
+ shell-syntax:
+ name: Shell script syntax (bash -n)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+
+ - name: Run bash -n on all .sh files
+ run: |
+ fail=0
+ while IFS= read -r f; do
+ if ! bash -n "$f" 2>err_out; then
+ echo "::error file=$f::bash syntax error"
+ cat err_out
+ fail=1
+ fi
+ done < <(find deploy/scripts scripts -type f -name '*.sh' 2>/dev/null)
+ exit $fail
+
+ - name: Validate governed tracing operations gate orchestration
+ run: bash scripts/tests/test-governed-tracing-operations-gate.sh
+
+ - name: Test HCC watch-recovery gate coordination
+ run: bash scripts/tests/test-hcc-watch-recovery-gate.sh
+
+ - name: Test Plugin Workload SDK auth bootstrap policy
+ run: bash scripts/tests/test-plugin-workload-sdk-auth-bootstrap.sh
+
+ - name: Test GFS grant WorkflowRecipe seed rendering
+ run: bash scripts/tests/test-seed-gfs-grant-workflow.sh
+
+ - name: Test minikube detect-k8s-api-ip template rendering
+ run: bash scripts/tests/test-minikube-detect-k8s-api-ip.sh
+
+ # ─── Platform NGINX image guard (CVE baseline) ────────────────────────────
+ nginx-image-guard:
+ name: Validate platform NGINX images
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - name: Run NGINX image guard
+ run: bash scripts/validate-nginx-images.sh
+
+ # ─── Cf-Access header-read guard ──────────────────────────────────────────
+ cf-access-header-guard:
+ name: Validate Cf-Access header reads
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - name: No unannotated Cf-Access-* header reads
+ run: bash scripts/check-no-cf-access-header-read.sh
+
+ # ─── Deploy manifest check (public overlays) ──────────────────────────────
+ # The public repo carries base + minikube overlays only; the gcp-dev/gcp-prod
+ # overlays live in keyper-labs/evenfire-infra and are rendered by infra CI.
+ # Here we render the minikube overlays and assert the base/overlay contracts
+ # that are checkable without the gcp overlays.
+ deploy-manifest-check:
+ name: Deploy Manifest Check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+
+ - name: Install kubectl (pinned)
+ run: |
+ curl -fsSLo kubectl "https://dl.k8s.io/release/v1.31.3/bin/linux/amd64/kubectl"
+ chmod +x kubectl
+ sudo mv kubectl /usr/local/bin/kubectl
+ kubectl version --client
+
+ - name: Render minikube overlays
+ run: |
+ # The minikube k8s-api-ip patch is rendered from a template at setup
+ # time (deploy/scripts/minikube-detect-k8s-api-ip.sh) and gitignored, so
+ # a fresh checkout has only the .template. Render a placeholder CIDR here
+ # so `kubectl kustomize` can build the overlay in CI (no cluster needed).
+ sed 's#__K8S_API_IP__#10.96.0.1#g' \
+ deploy/overlays/minikube/patches/k8s-api-ip.yaml.template \
+ > deploy/overlays/minikube/patches/k8s-api-ip.yaml
+ kubectl kustomize deploy/overlays/minikube > /tmp/clerum-minikube.yaml
+ kubectl kustomize deploy/overlays/minikube-no-uis > /tmp/clerum-minikube-no-uis.yaml
+
+ - name: cloudflared must not render into the minikube overlays
+ run: |
+ for f in /tmp/clerum-minikube.yaml /tmp/clerum-minikube-no-uis.yaml; do
+ if grep -q 'name: cloudflared' "$f"; then
+ echo "::error::cloudflared leaked into $f (minikube must not include the ingress namespace)"
+ exit 1
+ fi
+ done
+
+ # ── #273 retirement gate ─────────────────────────────────────────
+ # The static `clerum-channel-reader` Deployment was retired in #273.
+ # Per-Host pods (`channel-reader-<host>`) created by HCC now own the
+ # channel-reader role. Re-introducing the static Deployment would collide
+ # with per-Host pods on Telegram's `getUpdates` long-poll (Telegram 409s
+ # the loser). ServiceAccount/ConfigMap/ClusterRole/ClusterRoleBinding named
+ # `clerum-channel-reader` ARE allowed — they're shared by per-Host pods.
+ - name: No static clerum-channel-reader Deployment (issue #273)
+ run: |
+ python3 - <<'PY'
+ import re, sys
+ fail = False
+ for path in ('/tmp/clerum-minikube.yaml', '/tmp/clerum-minikube-no-uis.yaml'):
+ with open(path) as f:
+ text = f.read()
+ for doc in re.split(r'^---\s*$', text, flags=re.MULTILINE):
+ if not doc.strip():
+ continue
+ kind = None
+ name = None
+ for line in doc.splitlines():
+ m = re.match(r'^kind:\s*(\S+)', line)
+ if m:
+ kind = m.group(1)
+ continue
+ m = re.match(r'^ name:\s*(\S+)', line)
+ if m and name is None:
+ name = m.group(1)
+ if kind == 'Deployment' and name == 'clerum-channel-reader':
+ sys.stderr.write(
+ f"::error file={path}::"
+ f"Static `clerum-channel-reader` Deployment is reintroduced. "
+ f"This was retired in #273 — use per-Host `channel-reader-<host>` "
+ f"pods created by HCC instead.\n"
+ )
+ fail = True
+ sys.exit(1 if fail else 0)
+ PY
+
+ # ─── Leak guards: infra identifiers + secrets ─────────────────────────────
+ # The public repo must never carry the private GCP project, GKE context
+ # names, non-sanctioned *.evenfire.ai hostnames (infra-identifier denylist),
+ # or real credentials (gitleaks). gitleaks scans the tracked tree via
+ # `git archive` so the result is deterministic (no .git internals, no
+ # node_modules) and matches the .gitleaks.toml calibration.
+ leak-guards:
+ name: Leak guards (identifiers + secrets)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+
+ - name: No internal infrastructure identifiers
+ run: bash scripts/ci/check-no-infra-identifiers.sh
+
+ - name: Install gitleaks (pinned)
+ run: |
+ VER=8.30.1
+ curl -fsSLo gitleaks.tar.gz \
+ "https://github.com/gitleaks/gitleaks/releases/download/v${VER}/gitleaks_${VER}_linux_x64.tar.gz"
+ tar -xzf gitleaks.tar.gz gitleaks
+ sudo mv gitleaks /usr/local/bin/gitleaks
+ gitleaks version
+
+ - name: gitleaks secret scan (tracked tree)
+ run: |
+ mkdir -p /tmp/gl-scan
+ git archive --format=tar HEAD | tar -x -C /tmp/gl-scan
+ cd /tmp/gl-scan
+ gitleaks dir . -c "${GITHUB_WORKSPACE}/.gitleaks.toml" \
+ --no-banner --redact --exit-code 1
diff --git a/.gitleaks.toml b/.gitleaks.toml
index ece89a31f..61cc7a6f5 100644
--- a/.gitleaks.toml
+++ b/.gitleaks.toml
@@ -21,6 +21,22 @@ paths = [
'''^\.env\.test$''',
'''^\.env\..*\.example$''',
'''^\.env\.example$''',
+ # Test + fixture surface — fake credentials by design (unit tests, e2e
+ # helpers, example manifests). Verified 2026-07-24: every flagged value here
+ # is a deliberately-fake fixture key.
+ '''\.test\.(ts|tsx|js|jsx|mjs|cjs)$''',
+ '''(^|/)__tests__/''',
+ '''(^|/)tests?/''',
+ '''(^|/)e2e/''',
+ '''(^|/)fixtures?/''',
+ '''(^|/)examples?/''',
+ # Documented CLERUM_DEV_MODE fallback JWT keys (DEV_*_JWT_PRIVATE_KEY) and the
+ # production boot-guard that fingerprints them to REFUSE dev keys in prod.
+ # Throwaway keys, not real secrets. See the file for the guard.
+ '''^control-api/src/config\.ts$''',
+ # `export const deriveOAuthEncryptionKey = deriveAes256GcmKey` — a function
+ # alias the generic-api-key entropy heuristic mis-reads as a secret.
+ '''^control-api/src/oauth/encryption\.ts$''',
]
regexes = [
diff --git a/control-ui/e2e/host-stateless-channel-rejection.spec.ts b/control-ui/e2e/host-stateless-channel-rejection.spec.ts
index 89dfc426d..ecf8655fe 100644
--- a/control-ui/e2e/host-stateless-channel-rejection.spec.ts
+++ b/control-ui/e2e/host-stateless-channel-rejection.spec.ts
@@ -37,7 +37,7 @@
* NOT chatllm-stateless (avoids colliding with the transient Test 2d window of
* scripts/e2e/e2e-stateless-suspend-wake.sh on a shared profile).
* 4. E2E_KUBECONTEXT (or CONTEXT) — an allowed kubectl context (clerum-test /
- * clerum-codex-* / gke_eventfire-*_clerum-dev). Passed to every kubectl call.
+ * clerum-codex-* / gke_<project>_<zone>_<cluster>). Passed to every kubectl call.
*/
import { execFileSync } from 'node:child_process'
import { type Page, expect, test } from '@playwright/test'
diff --git a/scripts/ci/check-no-infra-identifiers.sh b/scripts/ci/check-no-infra-identifiers.sh
new file mode 100755
index 000000000..0d8fd9404
--- /dev/null
+++ b/scripts/ci/check-no-infra-identifiers.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+#
+# CI guard: fail if any internal infrastructure identifier leaked into the
+# public tree. The public repo (evenfire-ai/evenfire) must never carry the
+# private GCP project, GKE cluster/context names, or non-sanctioned
+# *.evenfire.ai hostnames — those live only in keyper-labs/evenfire-infra and
+# are supplied by the infra overlays at assemble time.
+#
+# Sanctioned public hostnames (shared services that genericized public config
+# legitimately references): registry / registration / brain .evenfire.ai.
+#
+# This checker necessarily names the forbidden patterns, so it excludes itself
+# from the scan. Lockfiles are excluded — transitive registry URLs in a
+# package-lock are not our identifiers.
+#
+# Scans the git-tracked tree only (what CI checks out). Exit 1 on any hit.
+
+set -uo pipefail
+
+EXCLUDES=(
+ ':(exclude)scripts/ci/check-no-infra-identifiers.sh'
+ ':(exclude)**/package-lock.json'
+ ':(exclude)**/*.lock'
+)
+
+fail=0
+
+flag() { # <label> <extended-regex>
+ local label="$1" pattern="$2" hits
+ hits="$(git grep -nIE "$pattern" -- "${EXCLUDES[@]}" 2>/dev/null || true)"
+ if [ -n "$hits" ]; then
+ echo "::error::${label} must not appear in the public tree:"
+ echo "$hits"
+ fail=1
+ fi
+}
+
+# 1. GCP project id + project number.
+flag "GCP project id (eventfire-491421)" 'eventfire-491421'
+flag "GCP project number (1043065809701)" '1043065809701'
+
+# 2. Fully-qualified GKE context / cluster names (gke_<project>_<zone>_<cluster>).
+flag "GKE context/cluster name (gke_eventfire-)" 'gke_eventfire-'
+
+# 3. Non-sanctioned *.evenfire.ai hostnames.
+# Allow only the shared public services: registry / registration / brain.
+bad="$(
+ git grep -nIE '[A-Za-z0-9_.-]+\.evenfire\.ai' -- "${EXCLUDES[@]}" 2>/dev/null \
+ | grep -oE '[A-Za-z0-9_.-]+\.evenfire\.ai' \
+ | grep -vE '^(registry|registration|brain)\.evenfire\.ai$' \
+ | sort -u \
+ || true
+)"
+if [ -n "$bad" ]; then
+ echo "::error::Non-sanctioned *.evenfire.ai hostname(s) in the public tree (allow: registry/registration/brain):"
+ echo "$bad" | sed 's/^/ /'
+ echo "--- locations ---"
+ while IFS= read -r host; do
+ git grep -nIF "$host" -- "${EXCLUDES[@]}" 2>/dev/null || true
+ done <<< "$bad"
+ fail=1
+fi
+
+if [ "$fail" -ne 0 ]; then
+ echo ""
+ echo "These identifiers belong in keyper-labs/evenfire-infra, not the public repo."
+ echo "If a hostname is a NEW sanctioned shared service, extend the allowlist in"
+ echo "scripts/ci/check-no-infra-identifiers.sh."
+ exit 1
+fi
+
+echo "infra-identifier check: clean (no private GCP project / GKE context / non-sanctioned *.evenfire.ai)."
diff --git a/scripts/validate-nginx-images.sh b/scripts/validate-nginx-images.sh
index 2bf1abb0a..40fd4fda6 100755
--- a/scripts/validate-nginx-images.sh
+++ b/scripts/validate-nginx-images.sh
@@ -39,6 +39,16 @@ scan_paths=(
"workflow-recipes/tests/fixtures/workflow/invalid-scheduling-no-steps.yaml"
)
+# Keep only paths present in this checkout so the guard is portable across the
+# public repo (base + minikube, no gcp overlays) and the infra-assembled tree
+# (with gcp-dev/gcp-prod overlays). Missing paths are skipped, not errors — the
+# base manifests the overlays inherit from are always scanned.
+_present=()
+for _p in "${scan_paths[@]}"; do
+ [ -e "$PROJECT_DIR/$_p" ] && _present+=("$_p")
+done
+scan_paths=("${_present[@]}")
+
require_text() {
local path="$1"
local text="$2"