Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(minikube): link the initial desktop operator during setup
Alfredo Lopezc98b2769916c
diff --git a/README.md b/README.mdindex 8dd235a47..7ca82c39c 100644--- a/README.md+++ b/README.md@@ -40,7 +40,9 @@> **This quick start runs the whole platform on a local [minikube](https://minikube.sigs.k8s.io/) cluster** — the fastest way to try Evenfire on your workstation.Stand up every service on minikube with one command, including a seeded agent-named `chatllm`:+named `chatllm`. On a fresh minimal install, setup consumes the first-run+admin bootstrap before any login, creates the matching Desktop identity, and+records the governed `initial_setup` GFS operator link atomically:```bashgit clone https://github.com/evenfire-ai/evenfire.git && cd evenfire@@ -50,6 +52,11 @@ MINIKUBE_IMAGE_TAG=latest make minikube-setup # see the note below on this ovemake minikube-status # wait for every deployment READY```+The seeded `[email protected]` Desktop account is therefore the initial GFS+operator. Re-running setup is idempotent: it may log in to verify the existing+active link, but it never recreates a revoked link or silently creates a second+ordinary member. If the link is missing, setup stops with an actionable error.+Then run the UIs from your workstation and say hello to the `chatllm` agent:```bashdiff --git a/docs/get-started/minikube.md b/docs/get-started/minikube.mdindex a1b376afa..01d14e82c 100644--- a/docs/get-started/minikube.md+++ b/docs/get-started/minikube.md@@ -29,6 +29,14 @@ MINIKUBE_IMAGE_TAG=latest make minikube-setup # first run ~15 min (pulling imamake minikube-status # wait for every deployment READY```+The default `minimal` seed is setup-first. Before it logs in as the technical+bootstrap admin, it consumes `/api/v1/admin/auth/setup`, which atomically+creates the `[email protected]` Desktop identity and its `initial_setup`+GFS operator link when `CONTROL_API_DESKTOP_GFS_OPERATOR_LINKING_ENABLED=true`.+The seed then verifies that link through the Control API. A rerun may fall back+to login only when the same active link is present; it fails closed instead of+creating an unlinked ordinary Desktop member or recreating a revoked link.+**You do not build images.** `make minikube-setup` pulls all 23 service imagesfrom `ghcr.io/evenfire-ai`, published for `linux/amd64` and `linux/arm64`, so anApple Silicon Mac pulls a native image rather than compiling anything. MCP@@ -55,8 +63,9 @@ make install-all && npm --prefix control-ui installnpm run ui # Control UI + Profile UI + Desktop App```-Log in as `[email protected]` using the `ADMIN_PASSWORD` you set in `.env`,-message the `chatllm` agent, and ask it to run a command or generate a PDF —+Log in as `[email protected]` using the `ADMIN_PASSWORD` you set in `.env`;+the same account is the initial GFS operator on a fresh self-hosted install.+Message the `chatllm` agent, and ask it to run a command or generate a PDF —then approve the tool call from the chat. The same password logs into theControl UI as `admin`. The Desktop App is the client you just used; Control UIis the admin console for the same fleet — both are toured indiff --git a/scripts/e2e/seed-e2e-data.sh b/scripts/e2e/seed-e2e-data.shindex 421de711d..8ec6f4c53 100755--- a/scripts/e2e/seed-e2e-data.sh+++ b/scripts/e2e/seed-e2e-data.sh@@ -47,7 +47,8 @@# E2E_PLUGIN_SDK_DEMO_TARGET_REF ordered policy target id (default: primary)# E2E_PLUGIN_SDK_DEMO_CREDENTIAL_SLOT Secret data key owned by provider (derived when omitted)# ADMIN_USERNAME admin user (default: admin)-# ADMIN_EMAIL bootstrap email (default: [email protected])+# ADMIN_EMAIL bootstrap email (default: [email protected] for+# SEED_PROFILE=minimal, otherwise [email protected])# ADMIN_PASSWORD admin pass (REQUIRED — bootstrap or rotated)# CONTROL_API_NS ns (default: control-plane)# ======================================================================@@ -66,6 +67,7 @@ source "${SCRIPT_DIR}/admin-credentials.sh"CONTEXT="${CONTEXT:-$(kubectl config current-context)}"KC="kubectl --context=${CONTEXT}"+SEED_PROFILE="${SEED_PROFILE:-e2e}"DEV_EMAIL="${E2E_DEV_LOGIN_EMAIL:[email protected]}"DEV_NAME="${E2E_DEV_LOGIN_NAME:-Test User}"DEV_EMAIL_2="${E2E_DEV_LOGIN_EMAIL_2:[email protected]}"@@ -98,7 +100,19 @@ AGENT_NAME="${E2E_HOST_REF:-chatllm}"CONTEXT_ID="${E2E_CONTEXT_ID:-context1}"ADMIN_USERNAME="${ADMIN_USERNAME:-admin}"-ADMIN_EMAIL="${ADMIN_EMAIL:[email protected]}"+if [ -z "${ADMIN_EMAIL:-}" ]; then+ if [ "$SEED_PROFILE" = "minimal" ]; then+ ADMIN_EMAIL="[email protected]"+ else+ ADMIN_EMAIL="[email protected]"+ fi+fi+if [ "$SEED_PROFILE" = "minimal" ] && [ -z "${E2E_DEV_LOGIN_EMAIL:-}" ]; then+ DEV_EMAIL="$ADMIN_EMAIL"+ if [ -z "${E2E_DEV_LOGIN_NAME:-}" ]; then+ DEV_NAME="admin"+ fi+fiADMIN_PASSWORD="$(e2e_resolve_admin_password "${REPO_ROOT}" || true)"DESKTOP_LOGIN_CREDENTIAL="$ADMIN_PASSWORD"SEED_DESKTOP_LOGIN="${E2E_SEED_DESKTOP_PASSWORDS:-}"@@ -449,35 +463,92 @@ capture_admin_session_cookie() {} > "$AUTH_COOKIE_JAR"}-# ─── Step 1: Admin login (bootstrap if cluster is fresh) ───────────────-log "Admin login as '$ADMIN_USERNAME'"-: > "$AUTH_HEADER_FILE"-ADMIN_RESP="$(curl -sS -w '\n%{http_code}' -D "$AUTH_HEADER_FILE" \- -X POST "$CAPI_BASE/admin/auth/login" \- -H 'Content-Type: application/json' \- -d "$(jq -cn --arg u "$ADMIN_USERNAME" --arg p "$ADMIN_PASSWORD" \- '{username: $u, password: $p}')" || true)"-ADMIN_BODY="$(echo "$ADMIN_RESP" | sed '$d')"-ADMIN_CODE="$(echo "$ADMIN_RESP" | tail -n1)"--if [[ "$ADMIN_CODE" =~ ^2 ]]; then+AUTH_CURL=(-b "$AUTH_COOKIE_JAR" -c "$AUTH_COOKIE_JAR" -H 'Content-Type: application/json')++admin_get() {+ local url="$1" label="$2"+ local resp code+ resp="$(curl -sS -w '\n%{http_code}' "$url" "${AUTH_CURL[@]}" || true)"+ code="$(echo "$resp" | tail -n1)"+ if [[ "$code" =~ ^2 ]]; then+ ADMIN_GET_BODY="$(echo "$resp" | sed '$d')"+ else+ die "$label → $code body=$(echo "$resp" | sed '$d')"+ fi+}++login_admin_only() {+ local resp body code+ log "Admin login as '$ADMIN_USERNAME'"+ : > "$AUTH_HEADER_FILE"+ resp="$(curl -sS -w '\n%{http_code}' -D "$AUTH_HEADER_FILE" \+ -X POST "$CAPI_BASE/admin/auth/login" \+ -H 'Content-Type: application/json' \+ -d "$(jq -cn --arg u "$ADMIN_USERNAME" --arg p "$ADMIN_PASSWORD" \+ '{username: $u, password: $p}')" || true)"+ body="$(echo "$resp" | sed '$d')"+ code="$(echo "$resp" | tail -n1)"+ if ! [[ "$code" =~ ^2 ]]; then+ die "Admin login failed (status=$code body=$body)"+ ficapture_admin_session_cookie || die "Admin login did not return an admin session cookie"ok "Admin session cookie obtained"-else- if [ "$ADMIN_CODE" != "401" ]; then- die "Admin login failed (status=$ADMIN_CODE body=$ADMIN_BODY)"- fi- # Fresh cluster → one-shot bootstrap. 409 means an admin already exists but- # the password we were given is wrong — that's a real auth failure, surface.- log "Login did not return an admin session; attempting first-time bootstrap"+}++perform_initial_setup() {+ local response: > "$AUTH_HEADER_FILE"- SETUP_RESP="$(curl -sS -w '\n%{http_code}' -D "$AUTH_HEADER_FILE" \+ response="$(curl -sS -w '\n%{http_code}' -D "$AUTH_HEADER_FILE" \-X POST "$CAPI_BASE/admin/auth/setup" \-H 'Content-Type: application/json' \-d "$(jq -cn --arg e "$ADMIN_EMAIL" --arg u "$ADMIN_USERNAME" --arg p "$ADMIN_PASSWORD" \'{email: $e, username: $u, password: $p}')" || true)"- SETUP_BODY="$(echo "$SETUP_RESP" | sed '$d')"- SETUP_CODE="$(echo "$SETUP_RESP" | tail -n1)"+ SETUP_BODY="$(echo "$response" | sed '$d')"+ SETUP_CODE="$(echo "$response" | tail -n1)"+}++verify_minimal_operator_bootstrap() {+ local admin_count status source desktop_user_id+ ADMIN_GET_BODY=""+ admin_get "$CAPI_BASE/admin/control-admins" "GET /admin/control-admins"+ admin_count="$(echo "$ADMIN_GET_BODY" | jq -r --arg username "$ADMIN_USERNAME" --arg email "${ADMIN_EMAIL,,}" \+ '[.admins[]? | select(.username == $username and ((.email // "") | ascii_downcase) == $email)] | length')"+ if [ "$admin_count" != "1" ]; then+ die "Minimal bootstrap did not produce exactly one admin '$ADMIN_USERNAME' with email '$ADMIN_EMAIL'"+ fi+ status="$(echo "$ADMIN_GET_BODY" | jq -r --arg username "$ADMIN_USERNAME" --arg email "${ADMIN_EMAIL,,}" \+ '.admins[] | select(.username == $username and ((.email // "") | ascii_downcase) == $email) | .gfsOperatorLink.status // "missing"')"+ source="$(echo "$ADMIN_GET_BODY" | jq -r --arg username "$ADMIN_USERNAME" --arg email "${ADMIN_EMAIL,,}" \+ '.admins[] | select(.username == $username and ((.email // "") | ascii_downcase) == $email) | .gfsOperatorLink.source // "missing"')"+ desktop_user_id="$(echo "$ADMIN_GET_BODY" | jq -r --arg username "$ADMIN_USERNAME" --arg email "${ADMIN_EMAIL,,}" \+ '.admins[] | select(.username == $username and ((.email // "") | ascii_downcase) == $email) | .gfsOperatorLink.desktopUserId // empty')"+ if [ "$status" != "active" ] || [ "$source" != "initial_setup" ] || [ -z "$desktop_user_id" ]; then+ die "Minimal bootstrap is incomplete: expected one active initial_setup Desktop link for '$ADMIN_EMAIL' (status=$status source=$source desktopUserId=${desktop_user_id:-missing}); refusing ordinary-user fallback"+ fi+ ok "Initial admin '$ADMIN_USERNAME' has active initial_setup Desktop operator link (desktopUserId=${desktop_user_id:0:8}…)"+}++login_first_legacy() {+ local response body code+ log "Admin login as '$ADMIN_USERNAME'"+ : > "$AUTH_HEADER_FILE"+ response="$(curl -sS -w '\n%{http_code}' -D "$AUTH_HEADER_FILE" \+ -X POST "$CAPI_BASE/admin/auth/login" \+ -H 'Content-Type: application/json' \+ -d "$(jq -cn --arg u "$ADMIN_USERNAME" --arg p "$ADMIN_PASSWORD" \+ '{username: $u, password: $p}')" || true)"+ body="$(echo "$response" | sed '$d')"+ code="$(echo "$response" | tail -n1)"+ if [[ "$code" =~ ^2 ]]; then+ capture_admin_session_cookie || die "Admin login did not return an admin session cookie"+ ok "Admin session cookie obtained"+ return+ fi+ if [ "$code" != "401" ]; then+ die "Admin login failed (status=$code body=$body)"+ fi+ log "Login did not return an admin session; attempting first-time bootstrap"+ perform_initial_setupif [ "$SETUP_CODE" = "409" ]; thendie "Admin already exists but login failed — ADMIN_PASSWORD is wrong for user '$ADMIN_USERNAME'"fi@@ -486,21 +557,31 @@ elseficapture_admin_session_cookie || die "Bootstrap did not return an admin session cookie"ok "Bootstrapped initial admin '$ADMIN_USERNAME'"-fi--AUTH_CURL=(-b "$AUTH_COOKIE_JAR" -c "$AUTH_COOKIE_JAR" -H 'Content-Type: application/json')+}-admin_get() {- local url="$1" label="$2"- local resp code- resp="$(curl -sS -w '\n%{http_code}' "$url" "${AUTH_CURL[@]}" || true)"- code="$(echo "$resp" | tail -n1)"- if [[ "$code" =~ ^2 ]]; then- ADMIN_GET_BODY="$(echo "$resp" | sed '$d')"+# ─── Step 1: Bootstrap before login for the minimal self-hosted path ───+# A fresh DB contains a technical bootstrap admin whose password already+# matches ADMIN_PASSWORD. Login-first therefore consumes the one-shot setup+# eligibility, then the normal /admin/users fallback creates an ordinary+# Desktop member without the governed initial_setup operator link. Minimal+# installs must consume setup first; reruns may fall back to login only after+# proving that the active initial_setup link still exists.+if [ "$SEED_PROFILE" = "minimal" ]; then+ log "Minimal self-hosted bootstrap: attempting /admin/auth/setup before any admin login"+ perform_initial_setup+ if [[ "$SETUP_CODE" =~ ^2 ]]; then+ capture_admin_session_cookie || die "Bootstrap did not return an admin session cookie"+ ok "Bootstrapped initial admin '$ADMIN_USERNAME' with Desktop workspace"+ elif [ "$SETUP_CODE" = "409" ]; then+ log "Initial setup already consumed; validating the existing governed link after login"+ login_admin_onlyelse- die "$label → $code body=$(echo "$resp" | sed '$d')"+ die "Bootstrap failed (status=$SETUP_CODE body=$SETUP_BODY)"fi-}+ verify_minimal_operator_bootstrap+else+ login_first_legacy+fiadmin_post() {local url="$1" body="$2" label="$3"diff --git a/scripts/minikube/full-setup.sh b/scripts/minikube/full-setup.shindex 0f9247a86..1713c40a2 100755--- a/scripts/minikube/full-setup.sh+++ b/scripts/minikube/full-setup.sh@@ -966,7 +966,12 @@ if [ "$RESET_DB" = true ]; thenelsewriter_dsn="$($KC -n gfs get secret gfs-controller-db -o 'jsonpath={.data.connection-string}')"if [ -n "${writer_dsn}" ]; then- if ! $KC rollout status deployment/control-api -n control-plane --timeout=5s >/dev/null 2>&1; then+ # apply-inter-service-tokens.sh intentionally restarts control-api before+ # this cutover check. A five-second probe races that rollout and makes an+ # otherwise healthy REUSE_DB rerun fail closed before the new pod can be+ # Ready. Keep the refusal, but wait for the same bounded rollout window+ # used by the main readiness gate.+ if ! $KC rollout status deployment/control-api -n control-plane --timeout=180s >/dev/null 2>&1; thenerr "Existing GFS writer detected but control-api is not Ready; refusing HCC cutover"exit 1fi@@ -1418,20 +1423,30 @@ elseelse# Minimal: the Control-UI admin IS the sole Desktop App member — no separate# seeded user. Point both the admin-bootstrap email and the seeded desktop- # user at the same evenfire-branded address so the seeder's (idempotent)- # user+team step converges on the admin identity that /admin/auth/setup- # already provisioned (users row + "<username> team" + chatllm/context1- # grants), instead of minting a second member/team. `[email protected]` would- # leak the internal code name onto a product surface (the Desktop member- # list) — evenfire branding belongs here (docs/concepts/code-names.md). If- # the best-effort admin desktop provisioning ever fails, the seeder still- # creates this one identity, so the minimal install is never member-less.- SEED_USER_DEFAULT_EMAIL="[email protected]"- SEED_USER_DEFAULT_NAME="admin"+ # user at the same evenfire-branded address. seed-e2e-data.sh consumes+ # /admin/auth/setup before login on a fresh DB, so this identity is created+ # atomically with the initial_setup operator link instead of minting a+ # second ordinary member/team. `[email protected]` would leak the internal+ # code name onto a product surface (the Desktop member list) — evenfire+ # branding belongs here (docs/concepts/code-names.md).: "${ADMIN_EMAIL:[email protected]}"+ SEED_USER_DEFAULT_EMAIL="$ADMIN_EMAIL"+ SEED_USER_DEFAULT_NAME="admin"+ fi+ if [ "$SEED_PROFILE" = "minimal" ]; then+ # The minimal quickstart owns the bootstrap identity. Do not let a+ # process/.env E2E override silently mint a second ordinary Desktop user;+ # only the explicitly named seed override is considered, and the guard+ # below still requires it to equal ADMIN_EMAIL.+ SEED_USER_EMAIL="${CLERUM_SEED_USER_EMAIL:-${SEED_USER_DEFAULT_EMAIL}}"+ else+ SEED_USER_EMAIL="${CLERUM_SEED_USER_EMAIL:-${CLERUM_TEST_USER_EMAIL:-${E2E_DEV_LOGIN_EMAIL:-${SEED_USER_DEFAULT_EMAIL}}}}"fi- SEED_USER_EMAIL="${CLERUM_SEED_USER_EMAIL:-${CLERUM_TEST_USER_EMAIL:-${E2E_DEV_LOGIN_EMAIL:-${SEED_USER_DEFAULT_EMAIL}}}}"SEED_USER_NAME="${E2E_DEV_LOGIN_NAME:-${SEED_USER_DEFAULT_NAME}}"+ if [ "$SEED_PROFILE" = "minimal" ] && [ "${SEED_USER_EMAIL,,}" != "${ADMIN_EMAIL,,}" ]; then+ err "SEED_PROFILE=minimal requires the Desktop identity email (${SEED_USER_EMAIL}) to equal the bootstrap admin email (${ADMIN_EMAIL}); refusing to create an unlinked ordinary member"+ exit 1+ filog "Seeding test user ${SEED_USER_EMAIL} → agent=chatllm, context=context1"SEED_USER_OK=trueif CONTEXT="${PROFILE}" ADMIN_PASSWORD="${ADMIN_PASSWORD}" \@@ -1444,14 +1459,15 @@ elseelseSEED_USER_OK=falseif [ "$SEED_PROFILE" = "minimal" ]; then- # This step is the only place that both creates the owner user AND- # rotates the bootstrap admin credential (POST /admin/auth/setup, called- # from seed-test-data.sh → scripts/e2e/seed-e2e-data.sh). generate-keys.sh- # bakes a hardcoded bcrypt hash of changeme123! into the admin Secret,- # and control-api/src/db.ts auto-inserts a live `admin` row from it on- # every fresh DB. If this step fails under the default (minimal)- # profile, that publicly-known credential is still live — a green- # summary would ship an install that is both unusable and insecure.+ # This step is the only place that both consumes the governed+ # /admin/auth/setup path and creates the owner Desktop identity. The+ # minimal seed is setup-first; it refuses to fall back to an ordinary+ # /admin/users member when the initial_setup operator link is missing.+ # generate-keys.sh bakes a hardcoded bcrypt hash of changeme123! into the+ # admin Secret, and control-api/src/db.ts auto-inserts a live `admin` row+ # from it on every fresh DB. If this step fails under the default+ # (minimal) profile, that publicly-known credential is still live — a+ # green summary would ship an install that is both unusable and insecure.# Abort instead; setup is idempotent, so re-running after the underlying# issue is fixed recovers cleanly.err "Test user seed failed under SEED_PROFILE=minimal — aborting. The bootstrap admin password may still be the publicly-known default (see generate-keys.sh) until this step succeeds. Fix the error above and re-run setup."diff --git a/scripts/tests/test-minikube-full-setup.sh b/scripts/tests/test-minikube-full-setup.shindex 2bd605e76..9133b0130 100755--- a/scripts/tests/test-minikube-full-setup.sh+++ b/scripts/tests/test-minikube-full-setup.sh@@ -250,7 +250,11 @@ assert_gfs_provisioning_follows_migrations_and_core_readiness() {ensure_line="$(grep -n 'ensure_control_postgres_ready' scripts/minikube/full-setup.sh | tail -1 | cut -d: -f1)"migration_line="$(grep -n 'deploy/scripts/run-control-api-db-migration.sh' scripts/minikube/full-setup.sh | head -1 | cut -d: -f1)"reconcile_after_migration="$(grep -n 'reconcile-gfs-deploy-credentials.sh' scripts/minikube/full-setup.sh | tail -1 | cut -d: -f1)"- control_ready_line="$(grep -n 'rollout status deployment/control-api.*timeout=180s' scripts/minikube/full-setup.sh | head -1 | cut -d: -f1)"+ # There are two intentional control-api readiness fences: the re-use path+ # waits before the HCC cutover, and the migration path waits afterwards.+ # Assert the post-migration fence here so adding the bounded re-use wait does+ # not make this ordering check select the earlier guard.+ control_ready_line="$(grep -n 'rollout status deployment/control-api.*timeout=180s' scripts/minikube/full-setup.sh | tail -1 | cut -d: -f1)"core_block="$(sed -n '/^CORE_DEPLOYS=(/,/^)/p' scripts/minikube/full-setup.sh)"reset_block="$(sed -n '/# 6a. Optional DB reset/,/# 6c. Re-apply generated service tokens/p' scripts/minikube/full-setup.sh)"wal_block="$(sed -n '/A stale or late corruption signature/,/err "${ns}\/\${name} NOT ready"/p' scripts/minikube/full-setup.sh)"@@ -514,6 +518,31 @@ assert_bootstrap_seed_deferral_rejects_non_local_or_e2e_modes() {rm -rf "$d"}+assert_minimal_seed_is_setup_first_and_link_fail_closed() {+ local seed="$REPO_ROOT/scripts/e2e/seed-e2e-data.sh"+ local minimal_block+ minimal_block="$(sed -n '/^if \[ "\$SEED_PROFILE" = "minimal" \]; then$/,/^else$/p' "$seed")"+ if printf '%s\n' "$minimal_block" | grep -Fq 'perform_initial_setup' && \+ printf '%s\n' "$minimal_block" | grep -Fq 'login_admin_only' && \+ printf '%s\n' "$minimal_block" | grep -Fq 'verify_minimal_operator_bootstrap' && \+ grep -Fq 'refusing ordinary-user fallback' "$seed"; then+ pass "minimal seed consumes setup before login and fails closed without an active initial_setup link"+ else+ fail "minimal seed does not prove setup-first ordering and fail-closed link verification"+ fi+}++assert_minimal_setup_requires_admin_identity_email() {+ if grep -Fq 'SEED_PROFILE=minimal requires the Desktop identity email' \+ "$REPO_ROOT/scripts/minikube/full-setup.sh" && \+ grep -Fq 'SEED_USER_DEFAULT_EMAIL="$ADMIN_EMAIL"' \+ "$REPO_ROOT/scripts/minikube/full-setup.sh"; then+ pass "minimal setup refuses a second unlinked Desktop identity"+ else+ fail "minimal setup can still create a Desktop identity different from the bootstrap admin"+ fi+}+assert_an_unknown_image_source_is_a_hard_error() {local out rcout="$(env PATH="$FULL_SETUP_STUB_DIR:$PATH" IMAGE_SOURCE=gchr \@@ -1106,6 +1135,8 @@ assert_image_source_local_is_honouredassert_bootstrap_seed_deferral_is_opt_inassert_bootstrap_seed_deferral_flag_resolves_for_local_minimalassert_bootstrap_seed_deferral_rejects_non_local_or_e2e_modes+assert_minimal_seed_is_setup_first_and_link_fail_closed+assert_minimal_setup_requires_admin_identity_emailassert_an_unknown_image_source_is_a_hard_errorassert_ghcr_mode_moves_only_the_render_dirassert_ghcr_mode_with_skip_uis_renders_the_no_uis_ghcr_overlay