You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "Yicong-Huang (via GitHub)" <gi...@apache.org> on 2026/06/28 08:43:38 UTC

Re: [PR] feat(infra): add `bin/local-dev.sh` dev-stack manager + TUI [texera]

Yicong-Huang commented on code in PR #5961:
URL: https://github.com/apache/texera/pull/5961#discussion_r3487604851


##########
bin/local-dev.sh:
##########
@@ -0,0 +1,2533 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# bin/local-dev.sh -- Manage the Texera local dev stack from a single script.
+#
+# Subcommands:
+#   bin/local-dev.sh                          DEFAULT — one-shot text
+#                                             dashboard (same as `status`).
+#                                             Non-interactive, prints once and
+#                                             exits — safe in scripts/CI.
+#   bin/local-dev.sh -i  | --interactive      Launch the Textual TUI dashboard
+#                                             (live states, SRC dirty
+#                                             indicator, command prompt,
+#                                             double-click for logs, ↑/↓
+#                                             history, Ctrl-C twice to quit).
+#                                             Requires Python + textual.
+#   bin/local-dev.sh status                   same as no-arg invocation.
+#   bin/local-dev.sh up   [--fresh|--build|--no-build] [--skip=svc1,svc2]
+#                                             Default: skip build if no source/lock
+#                                             changes since last build. --build forces
+#                                             incremental sbt dist + yarn/bun install.
+#                                             --fresh runs `sbt clean dist`. --no-build
+#                                             skips the build step entirely.
+#   bin/local-dev.sh down [--skip=svc1,svc2]  stop every non-skipped service.
+#   bin/local-dev.sh start <service>          start one service (no rebuild).
+#   bin/local-dev.sh stop  <service>          stop one service.
+#   bin/local-dev.sh <service>                rebuild only that service incrementally
+#                                             (sbt <Project>/dist), then bounce it.
+#                                             frontend / agent-service are refused
+#                                             (they have their own watch mode).
+#   bin/local-dev.sh logs <service>           tail this service's log.
+#   bin/local-dev.sh w | watch [interval]     Hands-off monitor: redraw the
+#                                             dashboard every <interval>s
+#                                             (default 2). No prompt; Ctrl-C
+#                                             to exit.
+#
+# Managed services (start order):
+#   config-service                 :9094  JVM (sbt ConfigService)
+#   access-control-service         :9096  JVM (sbt AccessControlService)
+#   file-service                   :9092  JVM (sbt FileService)
+#   workflow-compiling-service     :9090  JVM (sbt WorkflowCompilingService)
+#   computing-unit-managing-service :8082 JVM (sbt ComputingUnitManagingService)
+#   texera-web                     :8080  JVM (sbt WorkflowExecutionService, amber)
+#   computing-unit-master          :8085  JVM (rides amber dist; no own sbt project)
+#   agent-service                  :3001  Bun --watch (cd agent-service && bun run dev)
+#   frontend                       :4200  ng serve via cd frontend && yarn start
+#
+# Docker infra (postgres / minio / lakefs / lakekeeper / litellm) is NOT managed
+# here -- bring those up yourself before `up`. The script will warn if expected
+# ports are unreachable.
+#
+# Logs and pid book-keeping live under: ${TEXERA_LOCAL_DEV_DIR:-/tmp/texera-local-dev}
+
+set -euo pipefail
+# Unmatched globs in bash default to the literal pattern (we handle that
+# in-place at every glob site). `failglob` / `nullglob` are opt-in per glob
+# via `( shopt -s nullglob; ... )` subshells where we need empty-on-no-match.
+
+REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+cd "$REPO_ROOT"
+
+STATE_DIR="${TEXERA_LOCAL_DEV_DIR:-/tmp/texera-local-dev}"
+LOG_DIR="$STATE_DIR/logs"
+BUILD_STAMP_DIR="$STATE_DIR/build-stamps"
+# Per-service phase markers: shell writes `<phase>\t<epoch>` here as it
+# walks each service through stop → build → start; the TUI reads them
+# every tick and renders an animated transitional state in the STATE
+# column. Removed once the service is up / on stale-after-90s.
+PHASE_DIR="$STATE_DIR/svc-phase"
+mkdir -p "$LOG_DIR" "$BUILD_STAMP_DIR" "$PHASE_DIR"
+
+# --------- associative-array shim for bash 3.2 ---------
+# Apple ships bash 3.2 at /bin/bash and we ship licensing as bash 3.2 too,
+# so we can't use `declare -A`. Every old `MAP[$key]=val` / `${MAP[$key]}`
+# is reshaped as a function call against a flat namespace of synthetic
+# variables `_amap__<MAP>__<key>`. Keys containing `-` get mangled to `_`
+# so they're valid identifier chars.
+amap_set() {
+    local _map="$1" _key="${2//-/_}" _val="$3"
+    eval "_amap__${_map}__${_key}=\$_val"
+}
+amap_get() {
+    local _map="$1" _key="${2//-/_}"
+    local _var="_amap__${_map}__${_key}"
+    eval "printf '%s' \"\${$_var:-}\""
+}
+amap_has() {
+    local _map="$1" _key="${2//-/_}"
+    local _var="_amap__${_map}__${_key}"
+    eval "[[ \${$_var+x} ]]"
+}
+amap_append() {
+    # amap_append MAP key suffix — append to existing value (or seed it).
+    local _map="$1" _key="${2//-/_}" _suffix="$3"
+    local _var="_amap__${_map}__${_key}"
+    eval "$_var=\"\${$_var:-}\$_suffix\""
+}
+
+# --------- toolchain (JDK 17 + node) ---------
+# Detect a JDK 17 installation rather than pinning one path. We try, in
+# order: (1) caller-set $JAVA_HOME if it really is 17, (2) macOS's official
+# locator `/usr/libexec/java_home -v 17`, (3) Homebrew on Apple Silicon +
+# Intel, (4) common Linux distro paths (openjdk / temurin / corretto / zulu),
+# (5) SDKMAN, (6) asdf, (7) the `java` on PATH if its `-version` says 17.
+# Fall through to a clear install hint if none match.
+_java_is_17() {
+    local home="$1"
+    [[ -x "$home/bin/java" ]] || return 1
+    "$home/bin/java" -version 2>&1 | head -1 | grep -q '"17[.]' || return 1
+    return 0
+}
+
+_find_jdk17() {
+    local cand=""
+    # 1. Respect $JAVA_HOME if the caller already set it AND it's 17.
+    if [[ -n "${JAVA_HOME:-}" ]] && _java_is_17 "$JAVA_HOME"; then
+        printf '%s\n' "$JAVA_HOME"; return 0
+    fi
+    # 2. macOS native locator (works for any vendor installed via /Library).
+    if command -v /usr/libexec/java_home >/dev/null 2>&1; then
+        cand=$(/usr/libexec/java_home -v 17 2>/dev/null) || cand=""
+        if [[ -n "$cand" ]] && _java_is_17 "$cand"; then
+            printf '%s\n' "$cand"; return 0
+        fi
+    fi
+    # 3. Homebrew — try `brew --prefix openjdk@17` first, then both well-
+    #    known prefixes as a fallback (script may run without brew on PATH
+    #    if /etc/zprofile didn't fire).
+    if command -v brew >/dev/null 2>&1; then
+        cand=$(brew --prefix openjdk@17 2>/dev/null) || cand=""
+        [[ -n "$cand" ]] && _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    fi
+    for cand in /opt/homebrew/opt/openjdk@17 /usr/local/opt/openjdk@17; do
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    done
+    # 4. Linux distro layouts. Glob first match.
+    # bash equivalents of zsh's `*(N)` "null on no match" qualifier: enable
+    # `shopt -s nullglob` locally so an unmatched pattern expands to zero
+    # words. We localize it in a subshell so it doesn't leak out and break
+    # the unquoted globs elsewhere (e.g. unzip's zip glob).
+    local matched=""
+    matched=$(shopt -s nullglob; \
+        for cand in \
+            /usr/lib/jvm/java-17-openjdk* \
+            /usr/lib/jvm/temurin-17-jdk* \
+            /usr/lib/jvm/java-17-amazon-corretto* \
+            /usr/lib/jvm/zulu-17* \
+            /usr/lib/jvm/jdk-17*; do
+            printf '%s\n' "$cand"
+        done)
+    while IFS= read -r cand; do
+        [[ -z "$cand" ]] && continue
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    done <<< "$matched"
+    # 5. SDKMAN (`sdk install java 17.x-...`) — pick the lex-largest 17.* dir.
+    if [[ -d "$HOME/.sdkman/candidates/java" ]]; then
+        matched=$(shopt -s nullglob; \
+            for cand in "$HOME"/.sdkman/candidates/java/17.*; do
+                printf '%s\n' "$cand"
+            done)
+        while IFS= read -r cand; do
+            [[ -z "$cand" ]] && continue
+            _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+        done <<< "$matched"
+    fi
+    # 6. asdf.
+    if [[ -d "$HOME/.asdf/installs/java" ]]; then
+        matched=$(shopt -s nullglob; \
+            for cand in "$HOME"/.asdf/installs/java/*17*; do
+                printf '%s\n' "$cand"
+            done)
+        while IFS= read -r cand; do
+            [[ -z "$cand" ]] && continue
+            _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+        done <<< "$matched"
+    fi
+    # 7. Whatever `java` is on PATH, IF it's 17 — covers cases like Docker
+    #    images or distro-managed defaults.
+    cand=$(command -v java 2>/dev/null) || cand=""
+    if [[ -n "$cand" ]]; then
+        cand="$(dirname "$(dirname "$cand")")"
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    fi
+    return 1
+}
+
+# Print the current java environment alongside detection results so the
+# user can see *why* JDK 17 lookup failed (wrong version pinned, JAVA_HOME
+# pointing at JDK 21, etc) — not just "couldn't find one".
+_diagnose_jdk17() {
+    echo "" >&2
+    echo "  current java environment:" >&2
+    if [[ -n "${JAVA_HOME:-}" ]]; then
+        local jhver=""
+        jhver=$("$JAVA_HOME/bin/java" -version 2>&1 | head -1 || echo "(unreadable)")
+        echo "    \$JAVA_HOME = $JAVA_HOME" >&2
+        echo "                ↳ $jhver" >&2
+    else
+        echo "    \$JAVA_HOME (unset)" >&2
+    fi
+    local path_java=""
+    path_java=$(command -v java 2>/dev/null) || true
+    if [[ -n "$path_java" ]]; then
+        local pver=""
+        pver=$("$path_java" -version 2>&1 | head -1 || echo "(unreadable)")
+        echo "    \`java\` on PATH → $path_java" >&2
+        echo "                ↳ $pver" >&2
+    else
+        echo "    \`java\` on PATH (not found)" >&2
+    fi
+    if command -v /usr/libexec/java_home >/dev/null 2>&1; then
+        local jh17=""
+        jh17=$(/usr/libexec/java_home -v 17 2>/dev/null) || jh17="(none registered)"
+        echo "    /usr/libexec/java_home -v 17 → $jh17" >&2
+    fi
+    if command -v brew >/dev/null 2>&1; then
+        local brewp=""
+        brewp=$(brew --prefix openjdk@17 2>/dev/null) || brewp="(not installed)"
+        echo "    brew --prefix openjdk@17 → $brewp" >&2
+    fi
+    echo "" >&2
+    echo "  likely cause:" >&2
+    if [[ -n "${JAVA_HOME:-}" ]] && [[ -n "$path_java" ]]; then
+        echo "    JAVA_HOME points at the wrong JDK (probably not 17)." >&2
+        echo "    Either fix JAVA_HOME or unset it to let auto-detect try other paths." >&2
+    elif [[ -n "$path_java" ]]; then
+        echo "    \`java\` on PATH is not JDK 17. Install a 17 sibling or set JAVA_HOME=/path/to/jdk-17." >&2
+    else
+        echo "    No JDK is installed anywhere we know to look." >&2
+    fi
+    echo "" >&2
+}
+
+JAVA_HOME_DETECTED="$(_find_jdk17)" || {
+    echo "FATAL: could not find a JDK 17 install." >&2
+    _diagnose_jdk17
+    echo "  fix:" >&2
+    echo "    macOS:   brew install openjdk@17" >&2
+    echo "    Linux:   apt install openjdk-17-jdk    # or yum/dnf equivalent" >&2
+    echo "    SDKMAN:  sdk install java 17.0.13-tem" >&2
+    echo "    or set JAVA_HOME=/path/to/jdk-17 explicitly" >&2
+    echo "" >&2
+    exit 1
+}
+export JAVA_HOME="$JAVA_HOME_DETECTED"
+export PATH="$JAVA_HOME/bin:$PATH"
+
+# Node: source the user's version manager (if any) so the right `node` is on
+# PATH for yarn/bun/ng. Try nvm, fnm, volta in that order; `command -v node`
+# remains the ultimate fallback.
+if [[ -z "${NVM_DIR:-}" && -d "$HOME/.nvm" ]]; then
+    export NVM_DIR="$HOME/.nvm"
+fi
+if [[ -n "${NVM_DIR:-}" && -s "$NVM_DIR/nvm.sh" ]]; then
+    # shellcheck disable=SC1091
+    \. "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true
+elif command -v fnm >/dev/null 2>&1; then
+    eval "$(fnm env --use-on-cd 2>/dev/null)" || true
+elif [[ -s "$HOME/.volta/load.sh" ]]; then
+    # shellcheck disable=SC1091
+    \. "$HOME/.volta/load.sh" >/dev/null 2>&1 || true
+fi
+
+# --------- runtime env for backend ---------
+# Detect the host's primary LAN IP so we can use it as the MinIO endpoint.
+# It has to be the same string from both directions:
+#   • host-native JVMs need it to reach localhost-published port 9000
+#   • the lakekeeper container needs it to do server-side S3 ops (validation,
+#     compaction) AND to return URLs to clients that *they* can reach
+# `localhost` only works for the host. `texera-minio` only works inside the
+# docker network. The host's LAN IP works from BOTH (host loopback for the
+# host, docker NAT'd out-and-back for the container).
+_detect_host_lan_ip() {
+    local iface="" ip=""
+    # 1. The interface backing the default route — most reliable on a
+    #    laptop that may have wifi + thunderbolt + tailscale all active.
+    iface=$(route get default 2>/dev/null | awk '/interface:/{print $2; exit}')
+    if [[ -n "$iface" ]]; then
+        ip=$(ipconfig getifaddr "$iface" 2>/dev/null)
+        [[ -n "$ip" && "$ip" != 127.* ]] && { printf '%s\n' "$ip"; return 0; }
+    fi
+    # 2. Fallback: linux `hostname -I`-equivalent walk over en*.
+    for iface in en0 en1 en2 en3 en4 en5 en6 en7 en8 en9 en10; do
+        ip=$(ipconfig getifaddr "$iface" 2>/dev/null)
+        [[ -n "$ip" && "$ip" != 127.* ]] && { printf '%s\n' "$ip"; return 0; }
+    done
+    return 1
+}
+# Lazy resolver — called from subcommands that actually need to publish a
+# host-reachable S3 endpoint (cmd_up, cmd_auto). Subcommands like
+# `version`, `status`, `--help`, or `-i` don't talk to MinIO and shouldn't
+# refuse to run just because the laptop is offline.
+_require_host_lan_ip() {
+    [[ -n "${HOST_LAN_IP:-}" ]] && return 0
+    HOST_LAN_IP="$(_detect_host_lan_ip)" || HOST_LAN_IP=""
+    if [[ -z "$HOST_LAN_IP" ]]; then
+        echo "FATAL: could not detect a host LAN IP." >&2
+        echo "       MinIO needs an address reachable from both docker (lakekeeper" >&2
+        echo "       does S3 ops) and the host (JVMs read signed URLs back); none" >&2
+        echo "       of \`route get default\` / en0-en10 had a non-loopback IPv4." >&2
+        echo "       Connect to a network or export HOST_LAN_IP=<your-IP> explicitly." >&2
+        exit 1
+    fi
+    export HOST_LAN_IP
+    # STORAGE_S3_ENDPOINT below uses the parameter-default form so it
+    # picks up HOST_LAN_IP once we set it here.
+    export STORAGE_S3_ENDPOINT="${STORAGE_S3_ENDPOINT:-http://$HOST_LAN_IP:9000}"
+}
+
+export STORAGE_JDBC_URL="${STORAGE_JDBC_URL:-jdbc:postgresql://localhost:5432/texera_db?currentSchema=texera_db,public}"
+export STORAGE_JDBC_USERNAME="${STORAGE_JDBC_USERNAME:-texera}"
+export STORAGE_JDBC_PASSWORD="${STORAGE_JDBC_PASSWORD:-password}"
+# STORAGE_S3_ENDPOINT is set lazily by _require_host_lan_ip — only the
+# subcommands that actually touch MinIO (infra_up + cmd_up + cmd_auto)
+# trigger that detection, so `version` / `status` / `-i` work offline.
+export STORAGE_S3_AUTH_USERNAME="${STORAGE_S3_AUTH_USERNAME:-texera_minio}"
+export STORAGE_S3_AUTH_PASSWORD="${STORAGE_S3_AUTH_PASSWORD:-password}"
+export STORAGE_S3_REGION="${STORAGE_S3_REGION:-us-west-2}"
+export STORAGE_ICEBERG_CATALOG_TYPE="${STORAGE_ICEBERG_CATALOG_TYPE:-rest}"
+export STORAGE_ICEBERG_CATALOG_REST_URI="${STORAGE_ICEBERG_CATALOG_REST_URI:-http://localhost:8181/catalog}"
+export STORAGE_ICEBERG_CATALOG_REST_WAREHOUSE_NAME="${STORAGE_ICEBERG_CATALOG_REST_WAREHOUSE_NAME:-texera}"
+export STORAGE_ICEBERG_CATALOG_REST_S3_BUCKET="${STORAGE_ICEBERG_CATALOG_REST_S3_BUCKET:-texera-iceberg}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_USERNAME="${STORAGE_ICEBERG_CATALOG_POSTGRES_USERNAME:-texera}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_PASSWORD="${STORAGE_ICEBERG_CATALOG_POSTGRES_PASSWORD:-password}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_URI_WITHOUT_SCHEME="${STORAGE_ICEBERG_CATALOG_POSTGRES_URI_WITHOUT_SCHEME:-localhost:5432/texera_iceberg_catalog}"
+export STORAGE_LAKEFS_ENDPOINT="${STORAGE_LAKEFS_ENDPOINT:-http://localhost:8000/api/v1}"
+export STORAGE_LAKEFS_AUTH_USERNAME="${STORAGE_LAKEFS_AUTH_USERNAME:-AKIAIOSFOLKFSSAMPLES}"
+export STORAGE_LAKEFS_AUTH_PASSWORD="${STORAGE_LAKEFS_AUTH_PASSWORD:-wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY}"
+export STORAGE_LAKEFS_AUTH_API_SECRET="${STORAGE_LAKEFS_AUTH_API_SECRET:-random_string_for_lakefs}"
+export UDF_PYTHON_PATH="${UDF_PYTHON_PATH:-$(command -v python3 2>/dev/null || command -v python 2>/dev/null)}"
+export TEXERA_DASHBOARD_SERVICE_ENDPOINT="${TEXERA_DASHBOARD_SERVICE_ENDPOINT:-http://localhost:8080}"
+export WORKFLOW_COMPILING_SERVICE_ENDPOINT="${WORKFLOW_COMPILING_SERVICE_ENDPOINT:-http://localhost:9090}"
+export WORKFLOW_EXECUTION_SERVICE_ENDPOINT="${WORKFLOW_EXECUTION_SERVICE_ENDPOINT:-http://localhost:8085}"
+export FILE_SERVICE_GET_PRESIGNED_URL_ENDPOINT="${FILE_SERVICE_GET_PRESIGNED_URL_ENDPOINT:-http://localhost:9092/api/dataset/presign-download}"
+export FILE_SERVICE_UPLOAD_ONE_FILE_TO_DATASET_ENDPOINT="${FILE_SERVICE_UPLOAD_ONE_FILE_TO_DATASET_ENDPOINT:-http://localhost:9092/api/dataset/did/upload}"
+export LITELLM_BASE_URL="${LITELLM_BASE_URL:-http://localhost:4000}"
+export LITELLM_MASTER_KEY="${LITELLM_MASTER_KEY:-sk-texera-internal-do-not-share}"
+export LLM_ENDPOINT="${LLM_ENDPOINT:-http://localhost:8080}"
+export LLM_API_KEY="${LLM_API_KEY:-dummy}"
+
+# --------- texera version (dynamic) ---------
+# The sbt-native-packager dist directory and jar names embed the project
+# version (e.g. target/config-service-<VERSION>/...). That version moves
+# across branches (1.3.0-incubating-SNAPSHOT on main, 1.2.0-incubating on
+# release/v1.2, …) so resolve it from build.sbt at startup rather than
+# hardcoding. Override via the TEXERA_VERSION env var to target a sibling
+# tree or if the build.sbt parse fails.
+_texera_version() {
+    grep -E '^[[:space:]]*ThisBuild[[:space:]]*/[[:space:]]*version[[:space:]]*:=[[:space:]]*"' \
+        "$REPO_ROOT/build.sbt" 2>/dev/null \
+        | head -1 \
+        | sed -E 's/.*"([^"]+)".*/\1/'
+}
+TEXERA_VERSION="${TEXERA_VERSION:-$(_texera_version)}"
+if [[ -z "$TEXERA_VERSION" ]]; then
+    # tui_warn isn't defined yet at this point in the script; print raw.
+    printf "FATAL: could not detect texera version from %s/build.sbt\n" "$REPO_ROOT" >&2
+    printf "       Set the TEXERA_VERSION env var to bypass.\n" >&2
+    exit 1
+fi
+
+# --------- sbt dependency graph (parsed from build.sbt) ---------
+# We parse the build.sbt's project + .dependsOn() declarations so that the
+# per-service "did anything that affects me change?" check can prune to
+# the actual transitive closure. Without this, every JVM service watches
+# every common/* dir and `cmd_auto` rebuilds half the stack whenever
+# common/workflow-operator changes, even though config-service has zero
+# dependency on it.
+#
+# Populates two amap maps keyed by sbt project name plus a parallel
+# indexed-array of keys so we can iterate without `${!MAP[@]}`:
+#   amap_get SBT_PATH ConfigService → "config-service"
+#   amap_get SBT_DEPS ConfigService → "Auth Config"   (space-separated)
+#   SBT_DEPS_KEYS=(ConfigService AccessControlService …)
+SBT_DEPS_KEYS=()
+
+_parse_sbt() {
+    local file="$REPO_ROOT/build.sbt"
+    [[ -f "$file" ]] || return 1
+    local current="" line=""
+    local decl_re='^lazy[[:space:]]+val[[:space:]]+([A-Z][A-Za-z0-9]*)[[:space:]]*=[[:space:]]*\(project[[:space:]]+in[[:space:]]+file\("([^"]+)"\)\)'
+    local deps_re='\.dependsOn\(([^)]*)\)'
+
+    # Helper: split a comma-list of dependsOn args, dropping test-scope
+    # and non-project tokens, then append unique main-scope refs.
+    _absorb() {
+        local args="$1"
+        local IFS_OLD="$IFS"
+        IFS=','
+        # shellcheck disable=SC2206
+        local parts=($args)
+        IFS="$IFS_OLD"
+        local arg="" existing=""
+        for arg in "${parts[@]}"; do
+            arg="${arg// /}"
+            arg="${arg//$'\t'/}"
+            [[ "$arg" == *"%"* ]] && continue
+            [[ "$arg" =~ ^[A-Z] ]] || continue
+            existing=$(amap_get SBT_DEPS "$current")
+            case " $existing " in
+                *" $arg "*) ;;
+                *) amap_append SBT_DEPS "$current" " $arg" ;;
+            esac
+        done
+    }
+
+    while IFS= read -r line; do
+        local rest="$line"
+        if [[ "$line" =~ $decl_re ]]; then
+            current="${BASH_REMATCH[1]}"
+            amap_set SBT_PATH "$current" "${BASH_REMATCH[2]}"
+            amap_set SBT_DEPS "$current" ""
+            SBT_DEPS_KEYS+=("$current")
+            # Don't `continue` — `.dependsOn(...)` can chain on the SAME
+            # line as the declaration (WorkflowOperator's one-liner does
+            # this). Fall through so the loop below catches it.
+        elif [[ "$line" =~ ^lazy[[:space:]]+val ]]; then
+            # Other `lazy val` (settings, etc) breaks attribution.
+            current=""
+            continue
+        fi
+        [[ -z "$current" ]] && continue
+        # Scan ALL `.dependsOn(...)` matches on this line — some lines
+        # chain `.dependsOn(A).dependsOn(B % "test->test")` and we must
+        # see both to filter correctly.
+        while [[ "$rest" =~ $deps_re ]]; do
+            _absorb "${BASH_REMATCH[1]}"
+            rest="${rest#*"${BASH_REMATCH[0]}"}"
+        done
+    done < "$file"
+    # Trim leading space on every entry.
+    local p="" cur=""
+    for p in "${SBT_DEPS_KEYS[@]}"; do
+        cur=$(amap_get SBT_DEPS "$p")
+        amap_set SBT_DEPS "$p" "${cur# }"
+    done
+    return 0
+}
+_parse_sbt || true
+
+# BFS from $1 over SBT_DEPS, emit one `<path>/src` per visited project.
+# Caller can also pass an explicit fallback list for the unparseable case.
+_sbt_transitive_src_dirs() {
+    local root="$1"
+    [[ -z "$root" ]] && return 1
+    amap_has SBT_PATH "$root" || return 1
+    # `_visited_` namespace is a per-call amap. We can't easily clear all
+    # entries (bash 3.2 has no `${!_visited_*}` glob over set vars without
+    # `compgen`, but `compgen -v` IS available). We unset matching vars
+    # at function exit so successive calls start clean.
+    local queue=("$root")
+    local p="" path="" d="" key="" var=""
+    while ((${#queue[@]} > 0)); do
+        p="${queue[0]}"
+        queue=("${queue[@]:1}")
+        key="${p//-/_}"
+        var="_amap__visited__${key}"
+        eval "[[ \${$var+x} ]]" && continue
+        eval "$var=1"
+        path=$(amap_get SBT_PATH "$p")
+        [[ -n "$path" ]] && printf '%s/src\n' "$path"
+        local deps=""
+        deps=$(amap_get SBT_DEPS "$p")
+        for d in $deps; do
+            queue+=("$d")
+        done
+    done
+    # Clean up our visited markers so the next caller starts fresh.
+    local v=""
+    for v in $(compgen -v _amap__visited__ 2>/dev/null); do
+        unset "$v"
+    done
+    return 0
+}
+
+# --------- service catalog ---------
+SERVICES=(
+    postgres
+    minio
+    lakefs
+    lakekeeper
+    litellm
+    config-service
+    access-control-service
+    file-service
+    workflow-compiling-service
+    computing-unit-master
+    computing-unit-managing-service
+    texera-web
+    agent-service
+    frontend
+)
+
+# Service catalog. Under bash 3.2 this would normally be `typeset -A` maps;
+# we use the `amap_*` helpers defined above instead. Each amap_set call
+# stores into a synthetic var name (e.g. `_amap__SVC_TYPE__postgres`).
+
+# Each docker service is now its own row in the dashboard. start/stop still
+# batch through infra_up/infra_down because `docker compose up -d` and
+# `docker compose down` operate at the project level.
+amap_set SVC_TYPE postgres   docker; amap_set SVC_PORT postgres   5432; amap_set SVC_CWD postgres   "."
+amap_set SVC_TYPE minio      docker; amap_set SVC_PORT minio      9000; amap_set SVC_CWD minio      "."
+amap_set SVC_TYPE lakefs     docker; amap_set SVC_PORT lakefs     8000; amap_set SVC_CWD lakefs     "."
+amap_set SVC_TYPE lakekeeper docker; amap_set SVC_PORT lakekeeper 8181; amap_set SVC_CWD lakekeeper "."
+amap_set SVC_TYPE litellm    docker; amap_set SVC_PORT litellm    4000; amap_set SVC_CWD litellm    "."
+
+amap_set SVC_TYPE       config-service jvm
+amap_set SVC_PORT       config-service 9094
+amap_set SVC_SBT        config-service ConfigService
+amap_set SVC_LAUNCHER   config-service "target/config-service-${TEXERA_VERSION}/bin/config-service"
+amap_set SVC_CWD        config-service "."
+amap_set SVC_ZIP_GLOB   config-service "config-service/target/universal/config-service-*.zip"
+amap_set SVC_UNZIP_DEST config-service "target/"
+amap_set SVC_HEALTH     config-service "/api/healthcheck"
+
+amap_set SVC_TYPE       access-control-service jvm
+amap_set SVC_PORT       access-control-service 9096
+amap_set SVC_SBT        access-control-service AccessControlService
+amap_set SVC_LAUNCHER   access-control-service "target/access-control-service-${TEXERA_VERSION}/bin/access-control-service"
+amap_set SVC_CWD        access-control-service "."
+amap_set SVC_ZIP_GLOB   access-control-service "access-control-service/target/universal/access-control-service-*.zip"
+amap_set SVC_UNZIP_DEST access-control-service "target/"
+amap_set SVC_HEALTH     access-control-service "/api/healthcheck"
+
+amap_set SVC_TYPE       file-service jvm
+amap_set SVC_PORT       file-service 9092
+amap_set SVC_SBT        file-service FileService
+amap_set SVC_LAUNCHER   file-service "target/file-service-${TEXERA_VERSION}/bin/file-service"
+amap_set SVC_CWD        file-service "."
+amap_set SVC_ZIP_GLOB   file-service "file-service/target/universal/file-service-*.zip"
+amap_set SVC_UNZIP_DEST file-service "target/"
+amap_set SVC_HEALTH     file-service "/api/healthcheck"
+
+amap_set SVC_TYPE       workflow-compiling-service jvm
+amap_set SVC_PORT       workflow-compiling-service 9090
+amap_set SVC_SBT        workflow-compiling-service WorkflowCompilingService
+amap_set SVC_LAUNCHER   workflow-compiling-service "target/workflow-compiling-service-${TEXERA_VERSION}/bin/workflow-compiling-service"
+amap_set SVC_CWD        workflow-compiling-service "."
+amap_set SVC_ZIP_GLOB   workflow-compiling-service "workflow-compiling-service/target/universal/workflow-compiling-service-*.zip"
+amap_set SVC_UNZIP_DEST workflow-compiling-service "target/"
+amap_set SVC_HEALTH     workflow-compiling-service "/api/healthcheck"
+
+amap_set SVC_TYPE       computing-unit-managing-service jvm
+amap_set SVC_PORT       computing-unit-managing-service 8082
+amap_set SVC_SBT        computing-unit-managing-service ComputingUnitManagingService
+amap_set SVC_LAUNCHER   computing-unit-managing-service "target/computing-unit-managing-service-${TEXERA_VERSION}/bin/computing-unit-managing-service"
+amap_set SVC_CWD        computing-unit-managing-service "."
+amap_set SVC_ZIP_GLOB   computing-unit-managing-service "computing-unit-managing-service/target/universal/computing-unit-managing-service-*.zip"
+amap_set SVC_UNZIP_DEST computing-unit-managing-service "target/"
+amap_set SVC_HEALTH     computing-unit-managing-service ""
+
+amap_set SVC_TYPE       texera-web jvm
+amap_set SVC_PORT       texera-web 8080
+amap_set SVC_SBT        texera-web WorkflowExecutionService
+amap_set SVC_LAUNCHER   texera-web "target/amber-${TEXERA_VERSION}/bin/texera-web-application"
+amap_set SVC_CWD        texera-web "amber"
+amap_set SVC_ZIP_GLOB   texera-web "amber/target/universal/amber-*.zip"
+amap_set SVC_UNZIP_DEST texera-web "amber/target/"
+amap_set SVC_HEALTH     texera-web "/api/healthcheck"
+
+# computing-unit-master shares the amber dist with texera-web: sbt-native-
+# packager emits both `bin/texera-web-application` and `bin/computing-unit-master`
+# launchers under `amber/target/amber-<VERSION>/`. We register it as a separate
+# service for status/start/stop but leave SVC_SBT / SVC_ZIP_GLOB empty so the
+# build pipeline knows to skip it (the texera-web build path already produces
+# its launcher). Source-dir and canary-jar lookups treat it identically to
+# texera-web — see _svc_src_dirs / svc_src_changed / svc_artifact_mtime.
+amap_set SVC_TYPE       computing-unit-master jvm
+amap_set SVC_PORT       computing-unit-master 8085
+amap_set SVC_SBT        computing-unit-master ""
+amap_set SVC_LAUNCHER   computing-unit-master "target/amber-${TEXERA_VERSION}/bin/computing-unit-master"
+amap_set SVC_CWD        computing-unit-master "amber"
+amap_set SVC_ZIP_GLOB   computing-unit-master ""
+amap_set SVC_UNZIP_DEST computing-unit-master ""
+amap_set SVC_HEALTH     computing-unit-master ""
+
+amap_set SVC_TYPE   agent-service bun
+amap_set SVC_PORT   agent-service 3001
+amap_set SVC_CWD    agent-service "agent-service"
+amap_set SVC_HEALTH agent-service "/api/healthcheck"
+
+amap_set SVC_TYPE   frontend yarn
+amap_set SVC_PORT   frontend 4200
+amap_set SVC_CWD    frontend "frontend"
+amap_set SVC_HEALTH frontend ""
+
+# --------- docker infra config ---------
+DOCKER_PROJECT="texera-local-dev"
+DOCKER_COMPOSE_FILE="$REPO_ROOT/bin/single-node/docker-compose.yml"
+DOCKER_OVERLAY_FILE="$REPO_ROOT/bin/local-dev/docker-compose.override.yml"
+DOCKER_ENV_FILE="$REPO_ROOT/bin/single-node/.env"
+DOCKER_INFRA_SERVICES=(postgres minio minio-init lakefs lakekeeper-migrate lakekeeper lakekeeper-init litellm)
+DOCKER_INFRA_LONGLIVED=(postgres minio lakefs lakekeeper litellm)  # exclude one-shot init jobs
+
+# Build the array of -f flags: base single-node compose + local-dev overlay
+# (the overlay publishes infra ports to the host, which the upstream compose
+# intentionally does not do).
+docker_compose_files() {
+    local args=(-f "$DOCKER_COMPOSE_FILE")
+    [[ -f "$DOCKER_OVERLAY_FILE" ]] && args+=(-f "$DOCKER_OVERLAY_FILE")
+    printf '%s\n' "${args[@]}"
+}
+
+# --------- TUI helpers ---------
+if [[ -t 1 ]] && [[ "${TERM:-}" != "dumb" ]]; then
+    BOLD=$'\e[1m'; DIM=$'\e[2m'
+    RED=$'\e[31m'; GREEN=$'\e[32m'; YELLOW=$'\e[33m'
+    BLUE=$'\e[34m'; MAGENTA=$'\e[35m'; CYAN=$'\e[36m'
+    GRAY=$'\e[90m'; BRIGHT=$'\e[97m'
+    RESET=$'\e[0m'
+else
+    BOLD="" DIM="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" GRAY="" BRIGHT="" RESET=""
+fi
+
+TUI_WIDTH=$(tput cols 2>/dev/null || echo 80)
+[[ -z "$TUI_WIDTH" || "$TUI_WIDTH" -lt 60 ]] && TUI_WIDTH=80
+(( TUI_WIDTH > 100 )) && TUI_WIDTH=100   # cap for readability
+
+# Symbols
+SYM_RUN="●"; SYM_STOP="○"; SYM_WARN="⚠"; SYM_OK="✓"; SYM_ERR="✗"
+SYM_SECT="▸"; SYM_LIST="•"; SYM_PROG="→"
+
+tui_hline() {
+    local ch="${1:-─}" w="${2:-$TUI_WIDTH}"
+    printf "${ch}%.0s" $(seq 1 "$w")
+}
+
+tui_trunc() {
+    local s="$1" n="$2"
+    if (( ${#s} > n )); then
+        printf "%s…" "${s:0:$((n-1))}"
+    else
+        printf "%s" "$s"
+    fi
+}
+
+tui_banner() {
+    local title="$1" subtitle="${2:-}"
+    local w=$TUI_WIDTH
+    # Row layout: │ + 2 spaces + content + 2 spaces + │ = w  →  inner = w - 6
+    local inner=$((w - 6))
+    title="$(tui_trunc "$title" "$inner")"
+    subtitle="$(tui_trunc "$subtitle" "$inner")"
+    printf "${BLUE}╭"; tui_hline "─" $((w-2)); printf "╮${RESET}\n"
+    printf "${BLUE}│${RESET}  ${BOLD}${BRIGHT}%-*s${RESET}  ${BLUE}│${RESET}\n" "$inner" "$title"
+    if [[ -n "$subtitle" ]]; then
+        printf "${BLUE}│${RESET}  ${DIM}%-*s${RESET}  ${BLUE}│${RESET}\n" "$inner" "$subtitle"
+    fi
+    printf "${BLUE}╰"; tui_hline "─" $((w-2)); printf "╯${RESET}\n"
+}
+
+tui_section() {
+    printf "\n${BOLD}${MAGENTA}${SYM_SECT}${RESET} ${BOLD}%s${RESET}\n" "$1"
+}
+
+tui_ok()    { printf "  ${GREEN}${SYM_OK}${RESET}  %s\n" "$*"; }
+tui_err()   { printf "  ${RED}${SYM_ERR}${RESET}  %s\n" "$*"; }
+tui_warn()  { printf "  ${YELLOW}${SYM_WARN}${RESET}  %s\n" "$*"; }
+tui_info()  { printf "  ${CYAN}${SYM_LIST}${RESET}  %s\n" "$*"; }
+tui_step()  { printf "  ${DIM}${SYM_PROG}${RESET}  ${DIM}%s${RESET}\n" "$*"; }
+tui_skip()  { printf "  ${GRAY}${SYM_STOP}${RESET}  ${GRAY}%s${RESET}\n" "$*"; }
+
+tui_state_symbol() {
+    case "$1" in
+        running)              printf "${GREEN}${SYM_RUN}${RESET}" ;;
+        starting)             printf "${YELLOW}${SYM_WARN}${RESET}" ;;
+        unhealthy|failed)     printf "${RED}${SYM_ERR}${RESET}" ;;
+        partial:*|external:*) printf "${YELLOW}${SYM_WARN}${RESET}" ;;
+        exited)               printf "${GRAY}${SYM_OK}${RESET}" ;;
+        *)                    printf "${GRAY}${SYM_STOP}${RESET}" ;;
+    esac
+}
+
+tui_state_color() {
+    case "$1" in
+        running)              echo "$GREEN" ;;
+        starting)             echo "$YELLOW" ;;
+        unhealthy|failed)     echo "$RED" ;;
+        partial:*|external:*) echo "$YELLOW" ;;
+        exited)               echo "$GRAY" ;;
+        *)                    echo "$GRAY" ;;
+    esac
+}
+
+# Show a spinner next to $msg while $pid runs. Caller is responsible for
+# `wait $pid` afterwards to capture exit code.
+tui_spinner() {
+    local pid="$1" msg="$2"
+    if [[ ! -t 1 ]]; then
+        printf "  ${BLUE}${SYM_PROG}${RESET}  ${DIM}%s (no-TTY, no spinner)${RESET}\n" "$msg"
+        return
+    fi
+    # Use an array (vs a single multibyte string + byte indexing) because
+    # bash's `${str:i:1}` is byte-wise — each braille glyph is 3 UTF-8
+    # bytes, so a byte index would print broken half-chars.
+    local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
+    local n=${#frames[@]}
+    local i=0
+    local start_ts=$SECONDS
+    printf "\e[?25l"   # hide cursor
+    while kill -0 "$pid" 2>/dev/null; do
+        local elapsed=$((SECONDS - start_ts))
+        local frame="${frames[i % n]}"
+        printf "\r  ${BLUE}%s${RESET}  ${DIM}%s${RESET} ${GRAY}(%ds)${RESET}     " \
+            "$frame" "$msg" "$elapsed"
+        sleep 0.1
+        i=$((i+1))
+    done
+    printf "\r%-${TUI_WIDTH}s\r" " "
+    printf "\e[?25h"   # show cursor
+}
+
+# Run a command in the background with output captured to $log, show spinner,
+# return command's exit code.
+tui_run_with_spinner() {
+    local log="$1" msg="$2"
+    shift 2
+    "$@" >"$log" 2>&1 &
+    local pid=$!
+    tui_spinner "$pid" "$msg"
+    wait "$pid"
+}
+
+# In-place panel that polls each non-skipped service's port and redraws the
+# whole panel until all are healthy or timed out. Sets a trap so Ctrl-C
+# restores the cursor.
+tui_wait_panel() {
+    local svcs=()
+    for svc in "${SERVICES[@]}"; do
+        is_skipped "$svc" && continue
+        svcs+=("$svc")
+    done
+    local n=${#svcs[@]}
+    (( n == 0 )) && return 0
+
+    local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
+    local n_frames=${#frames[@]}
+    local start_ts=$SECONDS
+    # JVM + docker services bind their port within ~10-30s; 90s leaves slack
+    # for cold-cache machines. The frontend's `ng serve` does a full Angular
+    # compile before listening — on a fresh checkout that's 90-180s easily,
+    # so give yarn-typed services 5 minutes. bun is in between.
+    local timeout_default=90
+    local timeout_yarn=300
+    local timeout_bun=120
+    local frame_idx=0
+    local first_render=true
+    local n_done=0
+    local n_failed=0
+    local svc="" i=0 state="" state_color="" state_sym="" port_str="" elapsed=0 spinner_frame=""
+
+    if [[ ! -t 1 ]]; then
+        # Non-TTY: redrawing would just spam lines. Poll each service to
+        # completion (or per-service timeout) and print one line per
+        # transition. Crucially we WAIT for docker containers to leave
+        # `starting`/`unhealthy` rather than treating an in-flight state as
+        # a failure — the previous one-shot check exited rc=1 within ~20s
+        # of `up` if e.g. lakefs hadn't reached `running` yet, which is its
+        # normal cold-start state.
+        local n_done=0 n_failed=0
+        local svc_timeout=0 waited=0 final_state=""
+        for svc in "${svcs[@]}"; do
+            svc_timeout=$timeout_default
+            case "$(amap_get SVC_TYPE "$svc")" in
+                yarn) svc_timeout=$timeout_yarn ;;
+                bun)  svc_timeout=$timeout_bun  ;;
+            esac
+            waited=0
+            final_state=""
+            while (( waited < svc_timeout )); do
+                if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+                    case "$(docker_svc_state "$svc")" in
+                        running|exited)        final_state="ok";    break ;;
+                        unhealthy|failed)      final_state="bad";   break ;;
+                        # starting / created / restarting / paused / "" → keep waiting
+                    esac
+                else
+                    [[ -n "$(listen_pid_for_port "$(amap_get SVC_PORT "$svc")")" ]] && { final_state="ok"; break; }
+                fi
+                sleep 1
+                waited=$((waited+1))
+            done
+            case "$final_state" in
+                ok)
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_OK" "$svc" "$(amap_get SVC_PORT "$svc")" "healthy"
+                    n_done=$((n_done+1)) ;;
+                bad)
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_ERR" "$svc" "$(amap_get SVC_PORT "$svc")" "unhealthy"
+                    n_failed=$((n_failed+1)) ;;
+                *)  # timed out without ever reaching a terminal state
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_ERR" "$svc" "$(amap_get SVC_PORT "$svc")" "timeout (${waited}s)"
+                    n_failed=$((n_failed+1)) ;;
+            esac
+        done
+        return $((n_failed > 0))
+    fi
+
+    printf "\e[?25l"   # hide cursor
+    trap 'printf "\e[?25h"' EXIT INT TERM
+
+    while true; do
+        elapsed=$((SECONDS - start_ts))
+        n_done=0
+        n_failed=0
+
+        if ! $first_render && [[ -t 1 ]]; then
+            printf "\e[${n}A"   # move cursor to top of panel
+        fi
+        first_render=false
+
+        spinner_frame="${frames[frame_idx % n_frames]}"
+
+        for svc in "${svcs[@]}"; do
+            state_color="" state_sym=""
+            # Per-service wait budget — yarn (ng serve cold compile) gets the
+            # most slack, bun a moderate amount, everything else the default.
+            local svc_timeout=$timeout_default
+            case "$(amap_get SVC_TYPE "$svc")" in
+                yarn) svc_timeout=$timeout_yarn ;;
+                bun)  svc_timeout=$timeout_bun  ;;
+            esac
+            if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+                local dstate=""
+                dstate=$(docker_svc_state "$svc")
+                case "$dstate" in
+                    running|exited)
+                        state="$dstate"
+                        state_color="$GREEN"; state_sym="${GREEN}${SYM_OK}${RESET}"
+                        n_done=$((n_done+1)) ;;
+                    starting)
+                        state="starting (${elapsed}s)"
+                        state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}" ;;
+                    unhealthy|failed)
+                        state="$dstate"
+                        state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                        n_failed=$((n_failed+1)) ;;
+                    *)
+                        if (( elapsed >= svc_timeout )); then
+                            state="timeout"
+                            state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                            n_failed=$((n_failed+1))
+                        else
+                            state="${dstate} (${elapsed}s)"
+                            state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}"
+                        fi ;;
+                esac
+                port_str=":$(amap_get SVC_PORT "$svc")"
+            else
+                if [[ -n "$(listen_pid_for_port "$(amap_get SVC_PORT "$svc")")" ]]; then
+                    state="healthy"
+                    state_color="$GREEN"; state_sym="${GREEN}${SYM_OK}${RESET}"
+                    n_done=$((n_done+1))
+                elif (( elapsed >= svc_timeout )); then
+                    state="timeout — see bin/local-dev.sh logs $svc"
+                    state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                    n_failed=$((n_failed+1))
+                else
+                    state="starting (${elapsed}s)"
+                    state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}"
+                fi
+                port_str=":$(amap_get SVC_PORT "$svc")"
+            fi
+
+            [[ -t 1 ]] && printf "\e[2K"
+            printf "  %s  %-32s ${DIM}%-7s${RESET}  ${state_color}%s${RESET}\n" \
+                "$state_sym" "$svc" "$port_str" "$state"
+        done
+
+        if (( n_done + n_failed == n )); then
+            break
+        fi
+
+        frame_idx=$((frame_idx + 1))
+        sleep 0.2
+    done
+
+    if [[ -t 1 ]]; then
+        printf "\e[?25h"
+        trap - EXIT INT TERM
+    fi
+
+    return $((n_failed > 0))
+}
+
+# --------- toolchain install hints ---------
+# Print install instructions for a missing toolchain. Used by both startup
+# detection failures and runtime "command not found" surfaces. Keeps the
+# guidance in one place so every failure mode looks the same.
+_install_hint() {
+    local tool="$1"
+    case "$tool" in
+        java)
+            printf "  ${BOLD}install JDK 17:${RESET}\n"
+            printf "    macOS:   brew install openjdk@17\n"
+            printf "    Linux:   apt install openjdk-17-jdk    ${DIM}# or yum/dnf equivalent${RESET}\n"
+            printf "    SDKMAN:  sdk install java 17.0.13-tem\n"
+            printf "  or set JAVA_HOME=/path/to/jdk-17 explicitly\n"
+            ;;
+        python)
+            printf "  ${BOLD}install Python 3.10+ and the TUI deps:${RESET}\n"
+            printf "    macOS:   brew install python@3.12\n"
+            printf "    Linux:   apt install python3 python3-pip\n"
+            printf "    then:    python3 -m pip install -r %s/amber/dev-requirements.txt\n" "$REPO_ROOT"
+            printf "  or set TEXERA_PYTHON=/path/to/python explicitly (must have textual installed)\n"
+            ;;
+        node)
+            printf "  ${BOLD}install Node 20+ (needed for frontend & agent-service):${RESET}\n"
+            printf "    macOS:   brew install node\n"
+            printf "    nvm:     nvm install --lts && nvm use --lts\n"
+            printf "    fnm:     fnm install --lts\n"
+            printf "    volta:   volta install node\n"
+            ;;
+        yarn)
+            printf "  ${BOLD}install yarn (needed for the frontend):${RESET}\n"
+            printf "    macOS:   brew install yarn\n"
+            printf "    npm:     npm install -g yarn\n"
+            printf "    corepack: corepack enable\n"
+            ;;
+        bun)
+            printf "  ${BOLD}install bun (needed for agent-service):${RESET}\n"
+            printf "    macOS:   brew install oven-sh/bun/bun\n"
+            printf "    curl:    curl -fsSL https://bun.sh/install | bash\n"
+            ;;
+        sbt)
+            printf "  ${BOLD}install sbt (needed to build the JVM services):${RESET}\n"
+            printf "    macOS:   brew install sbt\n"
+            printf "    Linux:   see https://www.scala-sbt.org/download.html\n"
+            ;;
+        docker)
+            printf "  ${BOLD}install Docker (needed for postgres/minio/lakefs/lakekeeper/litellm):${RESET}\n"
+            printf "    macOS:   download Docker Desktop from https://docker.com/products/docker-desktop\n"
+            printf "    Linux:   apt install docker.io docker-compose-plugin\n"
+            ;;
+        *)
+            printf "  ${DIM}no install hint for: %s${RESET}\n" "$tool"
+            ;;
+    esac
+}
+
+# Inspect the user's Node/yarn/bun setup and print what we actually find,
+# so "yarn not found" reads as "you have node 18 but no yarn" instead of
+# the generic install hint. Called from start_one's frontend/agent paths.
+_diagnose_node() {
+    printf "\n  ${BOLD}node environment:${RESET}\n"
+    for tool in node npm yarn bun corepack; do
+        local p=""
+        p=$(command -v "$tool" 2>/dev/null) || true
+        if [[ -n "$p" ]]; then
+            local v=""
+            v=$("$tool" --version 2>&1 | head -1) || v="(no --version)"
+            printf "    ${GREEN}✓${RESET} %-8s → %s  ${DIM}(%s)${RESET}\n" "$tool" "$p" "$v"
+        else
+            printf "    ${RED}✗${RESET} %-8s ${DIM}not on PATH${RESET}\n" "$tool"
+        fi
+    done
+    printf "\n  ${BOLD}version manager:${RESET}\n"
+    if [[ -n "${NVM_DIR:-}" && -s "${NVM_DIR}/nvm.sh" ]]; then
+        printf "    nvm  → ${DIM}%s${RESET}\n" "$NVM_DIR"
+    elif command -v fnm >/dev/null 2>&1; then
+        printf "    fnm  → ${DIM}%s${RESET}\n" "$(command -v fnm)"
+    elif [[ -s "$HOME/.volta/load.sh" ]]; then
+        printf "    volta → ${DIM}%s${RESET}\n" "$HOME/.volta"
+    else
+        printf "    ${DIM}none detected (using whatever \`node\` is on PATH)${RESET}\n"
+    fi
+    printf "\n"
+}
+
+# --------- helpers ---------
+listen_pid_for_port() {
+    # || true so pipefail doesn't kill us when nothing is listening
+    lsof -nP -iTCP:"$1" -sTCP:LISTEN -t 2>/dev/null | head -1 || true
+}
+
+# Returns the count of long-lived infra services currently running under our project.
+infra_running_count() {
+    docker compose -p "$DOCKER_PROJECT" ps --services --filter status=running 2>/dev/null | grep -cxE "$(IFS=\|; echo "${DOCKER_INFRA_LONGLIVED[*]}")" || true
+}
+
+# Returns one of: stopped | running | partial:N | external — aggregate view
+# across all infra containers, used by infra_up/infra_down and the wait panel.
+infra_state() {
+    local running=""
+    running=$(infra_running_count)
+    if [[ "$running" -eq ${#DOCKER_INFRA_LONGLIVED[@]} ]]; then
+        echo "running"
+    elif [[ "$running" -gt 0 ]]; then
+        echo "partial:$running"
+    else
+        local taken=0
+        for port in 5432 9000 8000 8181 4000; do
+            [[ -n "$(listen_pid_for_port "$port")" ]] && taken=$((taken+1))
+        done
+        if [[ "$taken" -gt 0 ]]; then
+            echo "external:$taken/5"
+        else
+            echo "stopped"
+        fi
+    fi
+}
+
+# Cached snapshot of `docker compose ps -a`. Refreshed at most once per second
+# (5 docker services × per-row ~200 ms `docker ps` call would otherwise tank
+# the render).
+_docker_states_cache=""
+_docker_states_cache_ts=-1
+
+_refresh_docker_states_cache() {
+    if (( _docker_states_cache_ts < 0 || SECONDS - _docker_states_cache_ts >= 1 )); then
+        _docker_states_cache=$(docker compose -p "$DOCKER_PROJECT" ps -a \
+            --format '{{.Service}}|{{.State}}|{{.Status}}' 2>/dev/null)
+        _docker_states_cache_ts=$SECONDS
+    fi
+}
+
+# Per-service state for any of postgres/minio/lakefs/lakekeeper/litellm.
+# Returns one of: running | starting | unhealthy | exited | failed | stopped
+docker_svc_state() {
+    local svc="$1"
+    _refresh_docker_states_cache
+    local line=""
+    line=$(printf '%s\n' "$_docker_states_cache" | grep "^${svc}|" | head -1 || true)
+    if [[ -z "$line" ]]; then
+        echo "stopped"
+        return
+    fi
+    local rest="${line#*|}"
+    local dstate="${rest%%|*}"     # NB: not `status` — zsh reserves $status
+    local dstatus="${rest#*|}"
+    case "$dstate" in
+        running)
+            if [[ "$dstatus" == *'(healthy)'* ]]; then echo "running"
+            elif [[ "$dstatus" == *'(health: starting)'* ]]; then echo "starting"
+            elif [[ "$dstatus" == *'(unhealthy)'* ]]; then echo "unhealthy"
+            else echo "running"
+            fi ;;
+        exited)
+            if [[ "$dstatus" == 'Exited (0)'* ]]; then echo "exited"
+            else echo "failed"
+            fi ;;
+        created|restarting|paused|removing) echo "starting" ;;
+        *) echo "stopped" ;;
+    esac
+}
+
+infra_up() {
+    # Resolve the host LAN IP now (lazy) — both the docker compose stack
+    # (lakekeeper-init reads STORAGE_S3_ENDPOINT) and the host JVMs about
+    # to start need it pointing at a host-reachable MinIO.
+    _require_host_lan_ip
+    if [[ "$(infra_state)" == external:* ]]; then
+        tui_err "infra: ports already taken by non-script containers"
+        printf "  ${DIM}Likely an old project (e.g. \`texera-dev\`) is running. Stop it first:${RESET}\n"
+        printf "  ${DIM}  docker compose -p texera-dev down${RESET}\n"
+        return 1
+    fi
+    local files=($(docker_compose_files))
+    tui_step "infra: docker compose up -d  ${DIM}(in-place TTY progress)${RESET}"
+    # No stdout redirect → docker compose detects TTY and renders an in-place
+    # progress panel that overwrites itself instead of appending event lines.
+    # --progress=tty forces it even if stdout looks like a pipe.
+    docker compose --progress auto -p "$DOCKER_PROJECT" --env-file "$DOCKER_ENV_FILE" "${files[@]}" \
+        up -d "${DOCKER_INFRA_SERVICES[@]}"
+    tui_ok "infra: 5 containers up"
+}
+
+infra_down() {
+    tui_step "infra: docker compose -p $DOCKER_PROJECT down  ${DIM}(in-place TTY progress)${RESET}"
+    docker compose --progress auto -p "$DOCKER_PROJECT" down || true
+    tui_ok "infra: stopped"
+}
+
+# Ensure the texera_db schema exists in the postgres container. The compose
+# file mounts sql/*.sql to /docker-entrypoint-initdb.d, but Postgres only
+# runs those on first init (empty data dir). If the volume was carried over
+# from an older texera version (e.g. before the `feedback` table was added)
+# the schema will be missing relations that current code references, the
+# jOOQ codegen produces an incomplete Tables.java, and sbt compile fails on
+# `not found: value FEEDBACK`. Probe for a canonical table and re-run
+# texera_ddl.sql if it's absent.
+infra_ensure_db_schema() {
+    local pg="texera-postgres"
+    # Wait briefly for postgres to be ready — `up -d` returned but the
+    # container may still be running its own init sequence.
+    local i=0
+    while (( i < 30 )); do
+        if docker exec "$pg" pg_isready -U texera -d texera_db -q 2>/dev/null; then
+            break
+        fi
+        sleep 1
+        i=$((i+1))
+    done
+    if (( i >= 30 )); then
+        tui_warn "postgres: not ready after 30s -- skipping schema check"
+        return 0
+    fi
+    # `feedback` is one of the newer tables; if it exists we assume the
+    # whole schema is current. (texera_ddl.sql is idempotent with
+    # CREATE TABLE IF NOT EXISTS, so re-applying it is safe even if some
+    # tables already exist, but skipping the copy + exec is faster.)
+    local has_feedback=""
+    has_feedback=$(docker exec "$pg" psql -U texera -d texera_db -tAc \
+        "SELECT 1 FROM pg_tables WHERE schemaname='texera_db' AND tablename='feedback'" \
+        2>/dev/null || true)
+    if [[ "$has_feedback" == "1" ]]; then
+        tui_skip "postgres: schema already current"
+        return 0
+    fi
+    tui_step "postgres: applying sql/texera_ddl.sql (one-time bootstrap)"
+    local ddl="$REPO_ROOT/sql/texera_ddl.sql"
+    if [[ ! -f "$ddl" ]]; then
+        tui_warn "postgres: $ddl not found -- skipping (jOOQ codegen may fail)"
+        return 0
+    fi
+    docker cp "$ddl" "$pg":/tmp/texera_ddl.sql >/dev/null
+    if docker exec -u postgres "$pg" psql -U texera -f /tmp/texera_ddl.sql >/dev/null 2>&1; then
+        tui_ok "postgres: schema bootstrapped"
+    else
+        tui_warn "postgres: ddl exec returned non-zero (check container logs)"
+    fi
+}
+
+svc_running_pid() {
+    listen_pid_for_port "$(amap_get SVC_PORT "$1")"
+}
+
+# Compact-format a duration in seconds:
+#   "—" for <0, "12s", "5m 23s", "2h 14m", "3d 4h"
+_format_uptime() {
+    local s="${1:-0}"
+    if (( s < 0 ));     then printf "—"; return; fi
+    if (( s < 60 ));    then printf "%ds" "$s"; return; fi
+    if (( s < 3600 ));  then printf "%dm %ds" $((s/60)) $((s%60)); return; fi
+    if (( s < 86400 )); then printf "%dh %dm" $((s/3600)) $(((s%3600)/60)); return; fi
+    printf "%dd %dh" $((s/86400)) $(((s%86400)/3600))
+}
+
+# Translate ps -o etime output (`[[DD-]hh:]mm:ss`) to whole seconds.
+_etime_to_seconds() {
+    local et="$1"
+    # bash quirk: in `local a=$x b=$a`, the right-hand `$a` resolves
+    # against the *outer* scope (before this `local` declares either).
+    # Putting `rest` on its own line ensures it sees the fresh `et`.
+    local rest="$et" days=0 h=0 m=0 s=0
+    if [[ "$rest" == *-* ]]; then
+        days="${rest%%-*}"
+        rest="${rest#*-}"
+    fi
+    # `IFS=: read -ra` reliably splits on `:` without the local-IFS-vs-
+    # array-literal trap.
+    local parts=()
+    IFS=: read -ra parts <<< "$rest"
+    case "${#parts[@]}" in
+        3) h=${parts[0]}; m=${parts[1]}; s=${parts[2]} ;;
+        2) m=${parts[0]}; s=${parts[1]} ;;
+        *) s=${parts[0]} ;;
+    esac
+    # Force base-10 so "08" / "09" don't blow up under bash's octal default.
+    printf '%d' "$((10#${days:-0}*86400 + 10#${h:-0}*3600 + 10#${m:-0}*60 + 10#${s:-0}))"
+}
+
+# Translate a number of bytes to a 4-char-ish human string ("85M", "1.2G").
+_format_bytes() {
+    local b="${1:-0}"
+    if (( b < 1024 ));         then printf "%dB"   "$b"; return; fi
+    if (( b < 1048576 ));      then printf "%dK"   $((b/1024)); return; fi
+    if (( b < 1073741824 ));   then printf "%dM"   $((b/1048576)); return; fi
+    # GB → 1 decimal place
+    local g_int=$((b / 1073741824)) g_frac=$(( (b % 1073741824) * 10 / 1073741824 ))
+    printf "%d.%dG" "$g_int" "$g_frac"
+}
+
+# Compact "8.2%" formatter from a string like "0.50" or "8.2".
+_format_pct() {
+    local p="${1:-0}"
+    # Strip optional trailing %, normalise weird inputs
+    p="${p%%%}"
+    [[ -z "$p" || "$p" == "-" ]] && { printf "—"; return; }
+    # Round to 1 decimal place using awk to avoid bash's lack of float math
+    printf '%s%%' "$(awk -v v="$p" 'BEGIN { printf "%.1f", v }' 2>/dev/null)"
+}
+
+# Container name for a docker-typed service. Most use `texera-<svc>`, but
+# `litellm` ships unprefixed in upstream's compose.
+_docker_container_for() {
+    case "$1" in
+        litellm) printf "litellm" ;;
+        *)       printf "texera-%s" "$1" ;;
+    esac
+}
+
+# Uptime for a service. Native: `ps -o etime` (POSIX, works on mac+linux).
+# Docker: parse the container's ISO-8601 .State.StartedAt against `date -u`.
+# Echoes "—" when not running.
+svc_uptime() {
+    local svc="$1"
+    if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+        local container="" since=""
+        container=$(_docker_container_for "$svc")
+        since=$(docker inspect -f '{{.State.StartedAt}}' "$container" 2>/dev/null) || { printf "—"; return; }
+        [[ -z "$since" || "$since" == "0001-01-01T00:00:00Z" ]] && { printf "—"; return; }
+        local now=0 started=0
+        now=$(date -u +%s 2>/dev/null) || { printf "—"; return; }
+        # macOS `date -j` parses ISO without fractional seconds — trim them.
+        started=$(date -u -j -f "%Y-%m-%dT%H:%M:%S" "${since%%.*}" +%s 2>/dev/null) || {
+            # GNU date fallback
+            started=$(date -u -d "${since%%.*}" +%s 2>/dev/null) || { printf "—"; return; }
+        }
+        local elapsed=$((now - started))
+        (( elapsed < 0 )) && elapsed=0
+        _format_uptime "$elapsed"
+        return
+    fi
+    local pid=""
+    pid=$(svc_running_pid "$svc") || true
+    [[ -z "$pid" ]] && { printf "—"; return; }
+    local et=""
+    et=$(ps -p "$pid" -o etime= 2>/dev/null | tr -d ' ')
+    [[ -z "$et" ]] && { printf "—"; return; }
+    _format_uptime "$(_etime_to_seconds "$et")"
+}
+
+# CPU% + RSS for a running native process. Returns "cpu%|rss_bytes".
+# Cheap enough (<5ms) that we can call it per service per tick.
+svc_proc_cpu_mem() {
+    local pid=""
+    pid=$(svc_running_pid "$1") || true
+    [[ -z "$pid" ]] && { printf "—|—"; return; }
+    local cpu="" rss=""
+    # macOS ps emits RSS in KB. Linux's `ps -o rss=` is also KB.
+    read -r cpu rss <<< "$(ps -p "$pid" -o pcpu=,rss= 2>/dev/null | tr -s ' ')"
+    [[ -z "$cpu" || -z "$rss" ]] && { printf "—|—"; return; }
+    printf "%s|%s" "$(_format_pct "$cpu")" "$(_format_bytes $((rss * 1024)))"
+}
+
+# Bulk docker stats — one slow `docker stats --no-stream` call returns CPU
+# + memory for every running container. Callers can grep their service out
+# of the result instead of paying the 1-2 second cost N times. Format:
+#   <container>|<cpu%>|<used-bytes>
+_docker_stats_snapshot() {
+    docker stats --no-stream --format '{{.Name}}|{{.CPUPerc}}|{{.MemUsage}}' 2>/dev/null \
+        | while IFS='|' read -r name cpu memu; do
+            # MemUsage is like "85.2MiB / 1.95GiB" — keep only the first
+            # half and translate IEC units to bytes.
+            local used="${memu%% *}"   # "85.2MiB"
+            local val="${used%[A-Za-z]*}"
+            local unit="${used##*[0-9.]}"
+            local bytes=0
+            case "$unit" in
+                KB|KiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1024 }') ;;
+                MB|MiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1048576 }') ;;
+                GB|GiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1073741824 }') ;;
+                *)      bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v }') ;;
+            esac
+            printf "%s|%s|%s\n" "$name" "$(_format_pct "${cpu%%%}")" "$(_format_bytes "$bytes")"
+        done
+}
+
+svc_artifact_mtime() {
+    local svc="$1" type=""
+    type=$(amap_get SVC_TYPE "$svc")
+    case "$type" in
+        jvm)
+            local launcher="$(amap_get SVC_CWD "$svc")/$(amap_get SVC_LAUNCHER "$svc")"
+            launcher="${launcher#./}"
+            local jar_dir=""
+            jar_dir="$(dirname "$(dirname "$launcher")")/lib"
+            if [[ -d "$jar_dir" ]]; then
+                # `shopt -s nullglob` localised in a subshell so an
+                # unmatched glob yields no words instead of the literal
+                # pattern. Capture into a string then split into an array.
+                local globbed=""
+                globbed=$(shopt -s nullglob; \
+                    printf '%s\n' "$jar_dir"/org.apache.texera."${svc}"-*.jar)
+                local main_jars=()
+                while IFS= read -r _f; do
+                    [[ -n "$_f" ]] && main_jars+=("$_f")
+                done <<< "$globbed"
+                if [[ ${#main_jars[@]} -eq 0 && ( "$svc" == "texera-web" || "$svc" == "computing-unit-master" ) ]]; then
+                    globbed=$(shopt -s nullglob; \
+                        printf '%s\n' "$jar_dir"/org.apache.texera.amber-*.jar)
+                    while IFS= read -r _f; do
+                        [[ -n "$_f" ]] && main_jars+=("$_f")
+                    done <<< "$globbed"
+                fi
+                if [[ ${#main_jars[@]} -gt 0 ]]; then
+                    stat -f "%Sm" -t "%Y-%m-%d %H:%M" "${main_jars[0]}"
+                    return
+                fi
+            fi
+            echo "—"
+            ;;
+        bun)    stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$(amap_get SVC_CWD "$svc")/bun.lock" 2>/dev/null || echo "—" ;;
+        yarn)   stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$(amap_get SVC_CWD "$svc")/yarn.lock" 2>/dev/null || echo "—" ;;
+        docker) echo "—" ;;
+    esac
+}
+
+is_skipped() {
+    [[ ",${SKIP_LIST:-}," == *",$1,"* ]]
+}
+
+wait_for_port() {
+    local port="$1" timeout="${2:-90}" i=0
+    while (( i < timeout )); do
+        [[ -n "$(listen_pid_for_port "$port")" ]] && return 0
+        sleep 1
+        i=$((i+1))
+    done
+    return 1
+}
+
+# Write a transitional phase for $svc so the TUI dashboard can render it
+# in the STATE column with animated dots. Cleared by phase_clear or after
+# 90s (TUI side stale check).
+phase_set() {
+    local svc="$1" phase="$2"
+    printf '%s\t%s\n' "$phase" "$(date +%s)" > "$PHASE_DIR/$svc" 2>/dev/null || true
+}
+phase_clear() {
+    local svc="$1"
+    rm -f "$PHASE_DIR/$svc" 2>/dev/null || true
+}
+
+stop_one() {
+    local svc="$1"
+    if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+        phase_set "$svc" stopping
+        tui_step "$svc: docker compose stop $svc"
+        docker compose -p "$DOCKER_PROJECT" stop "$svc" >/dev/null 2>&1 || true
+        phase_clear "$svc"
+        tui_ok "$svc: stopped"
+        return
+    fi
+    local pid=""
+    pid=$(svc_running_pid "$svc")
+    if [[ -z "$pid" ]]; then
+        tui_skip "$svc: already stopped"
+        return 0
+    fi
+    phase_set "$svc" stopping
+    tui_step "$svc: stopping PID $pid"
+    kill "$pid" 2>/dev/null || true
+    local i=0
+    while (( i < 30 )) && kill -0 "$pid" 2>/dev/null; do
+        sleep 0.5
+        i=$((i+1))
+    done
+    if kill -0 "$pid" 2>/dev/null; then
+        tui_warn "$svc: SIGKILL $pid"
+        kill -9 "$pid" 2>/dev/null || true
+    fi
+    phase_clear "$svc"
+    tui_ok "$svc: stopped"
+}
+
+start_one() {
+    local svc="$1"
+    local type=""
+    type=$(amap_get SVC_TYPE "$svc")
+    # JVMs and docker services need STORAGE_S3_ENDPOINT exported before
+    # launch (JVM clients dial MinIO; lakekeeper bakes the URL into the
+    # warehouse storage profile). yarn/bun watch services don't.
+    if [[ "$type" == "jvm" || "$type" == "docker" ]]; then
+        _require_host_lan_ip
+    fi
+    if [[ "$type" == "docker" ]]; then
+        local dstate=""
+        dstate=$(docker_svc_state "$svc")
+        if [[ "$dstate" == "running" ]]; then
+            tui_ok "$svc: already running"
+            return 0
+        fi
+        phase_set "$svc" starting
+        tui_step "$svc: docker compose up -d $svc"
+        local files=()
+        while read -r f; do files+=("$f"); done < <(docker_compose_files | tr ' ' '\n')
+        docker compose --progress auto -p "$DOCKER_PROJECT" --env-file "$DOCKER_ENV_FILE" \
+            "${files[@]}" up -d "$svc" >/dev/null 2>&1
+        # Don't clear the phase yet — docker `up -d` returns before the
+        # container is healthy. The TUI's docker_state poller will flip
+        # the row to "running" once the container reports healthy; the
+        # stale-after-90s rule covers cleanup if that never happens.
+        tui_ok "$svc: started"
+        return
+    fi
+    if [[ -n "$(svc_running_pid "$svc")" ]]; then
+        tui_ok "$svc: already running ${DIM}(PID $(svc_running_pid "$svc"))${RESET}"
+        return 0
+    fi
+    local cwd="" log="$LOG_DIR/$svc.log"
+    cwd=$(amap_get SVC_CWD "$svc")
+    phase_set "$svc" starting
+    tui_step "$svc: starting ${DIM}(log: $log)${RESET}"
+    case "$type" in
+        jvm)
+            local launcher=""
+            launcher=$(amap_get SVC_LAUNCHER "$svc")
+            if [[ ! -x "$cwd/$launcher" ]]; then
+                phase_clear "$svc"
+                tui_err "$svc: launcher missing at $cwd/$launcher -- run \`bin/local-dev.sh up\` to build first"
+                return 1
+            fi
+            ( cd "$cwd" && nohup "./$launcher" >"$log" 2>&1 </dev/null & )
+            ;;
+        bun)
+            if ! command -v bun >/dev/null 2>&1; then
+                tui_err "$svc: \`bun\` not found on PATH"
+                _diagnose_node
+                _install_hint bun
+                return 1
+            fi
+            ( cd "$cwd" && nohup bun run dev >"$log" 2>&1 </dev/null & )
+            ;;
+        yarn)
+            if ! command -v yarn >/dev/null 2>&1; then
+                tui_err "$svc: \`yarn\` not found on PATH"
+                _diagnose_node
+                if ! command -v node >/dev/null 2>&1; then
+                    _install_hint node
+                else
+                    _install_hint yarn
+                fi
+                return 1
+            fi
+            ( cd "$cwd" && nohup yarn start >"$log" 2>&1 </dev/null & )
+            ;;
+    esac
+}
+
+build_one_jvm() {
+    local svc="$1" proj=""
+    proj=$(amap_get SVC_SBT "$svc")
+    local log="$LOG_DIR/sbt-${svc}.log"
+    # Empty SVC_SBT means this service rides another service's dist (e.g.
+    # computing-unit-master shares amber's). Nothing to build directly — the
+    # launcher is produced when its sibling builds. Stamp `svc` so the dirty
+    # indicator can clear if amber/src actually matches.
+    if [[ -z "$proj" ]]; then
+        tui_skip "$svc: no own sbt project (built with its sibling)"
+        svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc" 2>/dev/null || true
+        return 0
+    fi
+    phase_set "$svc" building
+    if tui_run_with_spinner "$log" "sbt $proj/dist  ${DIM}(log: $log)${RESET}" \
+        sbt -no-colors "$proj/dist"; then
+        local zip_glob="" unzip_dest=""
+        zip_glob=$(amap_get SVC_ZIP_GLOB "$svc")
+        unzip_dest=$(amap_get SVC_UNZIP_DEST "$svc")
+        tui_step "unzip ${zip_glob} → ${unzip_dest}"
+        # shellcheck disable=SC2086
+        unzip -oq ${zip_glob} -d "${unzip_dest}"
+        # Stamp = SHA-1 of the source we just built from. Clears the `*` and
+        # lets us tell content-vs-mtime apart on the next dirty check.
+        svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc"
+        tui_ok "$svc: build done"
+        # Don't clear the phase yet — the caller (cmd_update_one) will
+        # transition us through stop_one/start_one which overwrite it.
+        # If something else is the caller, the TUI's "phase cleared once
+        # poller sees running" rule covers us.
+    else
+        phase_clear "$svc"
+        tui_err "$svc: sbt $proj/dist FAILED  ${DIM}(tail -f $log)${RESET}"
+        return 1
+    fi
+}
+
+# True if ANY JVM service's source changed (content-hash) since its last build.
+# This is what `up`/`build` use to decide whether to skip the sbt step. It
+# is the same check the dashboard's SRC `*` indicator uses, just OR'd across
+# all JVM services.
+any_jvm_src_changed() {
+    local svc=""
+    for svc in "${SERVICES[@]}"; do
+        [[ "$(amap_get SVC_TYPE "$svc")" == "jvm" ]] || continue
+        if svc_src_changed "$svc" 2>/dev/null; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+# DEPRECATED — kept only as a documentation breadcrumb. Used to be the mtime-
+# based check `up --auto` consulted; replaced by any_jvm_src_changed because
+# git checkouts move mtimes without changing content.
+needs_jvm_build() {
+    local canary="amber/target/amber-${TEXERA_VERSION}/lib/org.apache.texera.amber-${TEXERA_VERSION}.jar"
+    [[ ! -f "$canary" ]] && return 0
+    local newer=""
+    newer=$(find amber/src common/dao/src common/config/src common/auth/src \
+        common/workflow-core/src common/workflow-operator/src common/pybuilder/src \
+        config-service/src access-control-service/src file-service/src \
+        workflow-compiling-service/src computing-unit-managing-service/src \
+        build.sbt amber/build.sbt config-service/build.sbt access-control-service/build.sbt \
+        file-service/build.sbt workflow-compiling-service/build.sbt \
+        computing-unit-managing-service/build.sbt project/JdkOptions.scala project/plugins.sbt \
+        \( -newer "$canary" \) -type f -print 2>/dev/null | head -1)
+    [[ -n "$newer" ]]
+}
+
+needs_yarn_install() {
+    [[ ! -f frontend/node_modules/.yarn-state.yml ]] && return 0
+    [[ frontend/yarn.lock -nt frontend/node_modules/.yarn-state.yml ]] && return 0
+    [[ frontend/package.json -nt frontend/node_modules/.yarn-state.yml ]] && return 0
+    return 1
+}
+
+needs_bun_install() {
+    [[ ! -d agent-service/node_modules ]] && return 0
+    [[ agent-service/bun.lock -nt agent-service/node_modules ]] && return 0
+    [[ agent-service/package.json -nt agent-service/node_modules ]] && return 0
+    return 1
+}
+
+# Cache of per-service transitive src dirs, populated once at startup by
+# _precompute_src_dirs(). Each entry (in the SVC_SRC_DIRS amap) is a
+# newline-separated list — callers consume via `while read` (same shape
+# as the old _svc_src_dirs output).
+
+_precompute_src_dirs() {
+    local svc="" entry="" dirs=""
+    for svc in "${SERVICES[@]}"; do
+        [[ "$(amap_get SVC_TYPE "$svc")" == "jvm" ]] || continue
+        entry=$(amap_get SVC_SBT "$svc")
+        # computing-unit-master rides amber's dist (no SVC_SBT of its
+        # own); enter the graph at the producing project explicitly.
+        if [[ -z "$entry" && "$svc" == "computing-unit-master" ]]; then
+            entry="WorkflowExecutionService"
+        fi
+        if [[ -z "$entry" ]]; then
+            echo "FATAL: service '$svc' has no SVC_SBT entry and no" >&2
+            echo "       SHARED_SBT_PROJECT mapping — can't compute its" >&2
+            echo "       transitive source-dir closure." >&2
+            exit 1
+        fi
+        if ! amap_has SBT_PATH "$entry"; then
+            echo "FATAL: sbt project '$entry' (for service '$svc') is not" >&2
+            echo "       in the parsed build.sbt graph. Either build.sbt" >&2
+            echo "       parsing failed or the project was renamed/removed." >&2
+            exit 1
+        fi
+        dirs="$(_sbt_transitive_src_dirs "$entry")"
+        if [[ -z "$dirs" ]]; then
+            echo "FATAL: transitive source-dir closure for '$svc' is empty." >&2
+            exit 1
+        fi
+        amap_set SVC_SRC_DIRS "$svc" "$dirs"
+    done
+}
+
+# Look up the pre-populated cache.
+_svc_src_dirs() {
+    local svc="$1"
+    local cached=""
+    cached=$(amap_get SVC_SRC_DIRS "$svc")
+    if [[ -z "$cached" ]]; then
+        echo "FATAL: _svc_src_dirs: '$svc' missing from SVC_SRC_DIRS" >&2
+        echo "       (did _precompute_src_dirs run?)" >&2
+        exit 1
+    fi
+    printf '%s\n' "$cached"
+}
+
+# Compute a SHA-1 over the content of every .scala/.java/.proto file that
+# matters for this service. ~100 ms; called only on the slow path of
+# svc_src_changed and from the post-build stamp write.
+svc_source_hash() {
+    local svc="$1"
+    local dirs=()
+    local d=""
+    while IFS= read -r d; do
+        [[ -n "$d" ]] && dirs+=("$d")
+    done < <(_svc_src_dirs "$svc")
+    find "${dirs[@]}" \
+        \( -name "*.scala" -o -name "*.java" -o -name "*.proto" \) \
+        -type f -print0 2>/dev/null \
+        | sort -z \
+        | xargs -0 cat 2>/dev/null \
+        | shasum -a 1 \
+        | awk '{print $1}'
+}
+
+# Per-service dirty check (the SRC * indicator). Two-stage:
+#   Fast path  (~22 ms): is any tracked source newer than the stamp file's
+#                        mtime? If not, definitely clean.
+#   Slow path (~100 ms): compute current source hash and compare to the hash
+#                        we stored at last build time. If they match, the
+#                        mtime moved without content moving (typical for git
+#                        checkout) — refresh the stamp mtime so we skip the
+#                        slow path next tick. If they differ, dirty.
+svc_src_changed() {
+    local svc="$1"
+    case "$(amap_get SVC_TYPE "$svc")" in
+        jvm)
+            local stamp="$BUILD_STAMP_DIR/$svc"
+            # Lazy seed: if we have a jar but no stamp, assume the jar matches
+            # current sources and seed with the hash. First REPL after a fresh
+            # checkout pays this once (~100 ms) and is clean afterwards.
+            if [[ ! -s "$stamp" ]]; then
+                local jar=""
+                if [[ "$svc" == "texera-web" || "$svc" == "computing-unit-master" ]]; then
+                    jar="amber/target/amber-${TEXERA_VERSION}/lib/org.apache.texera.amber-${TEXERA_VERSION}.jar"
+                else
+                    jar="target/${svc}-${TEXERA_VERSION}/lib/org.apache.texera.${svc}-${TEXERA_VERSION}.jar"
+                fi
+                [[ ! -f "$jar" ]] && return 0   # no jar, definitely dirty
+                svc_source_hash "$svc" > "$stamp"
+                return 1
+            fi
+
+            # Fast path: any tracked source mtime newer than stamp's mtime?
+            local dirs=() d=""
+            while IFS= read -r d; do
+                [[ -n "$d" ]] && dirs+=("$d")
+            done < <(_svc_src_dirs "$svc")
+            local newer=""
+            newer=$(find "${dirs[@]}" \
+                \( -name "*.scala" -o -name "*.java" -o -name "*.proto" \) \
+                -newer "$stamp" -type f -print 2>/dev/null | head -1)
+            if [[ -z "$newer" ]]; then
+                return 1   # nothing changed since last stamp → clean
+            fi
+
+            # Slow path: did the content actually change, or just mtimes?
+            local current_hash="" stored_hash=""
+            current_hash=$(svc_source_hash "$svc")
+            stored_hash=$(cat "$stamp" 2>/dev/null)
+            if [[ "$current_hash" == "$stored_hash" ]]; then
+                # Same content, just newer mtimes (git checkout, touch, etc.).
+                # Refresh stamp mtime to skip the slow path next tick.
+                touch "$stamp"
+                return 1
+            fi
+            return 0   # content really changed → dirty
+            ;;
+        yarn)   needs_yarn_install ;;
+        bun)    needs_bun_install ;;
+        docker) return 1 ;;
+    esac
+}
+
+build_all() {
+    BUILD_DID_RUN=false
+    local log="$LOG_DIR/sbt-dist.log"
+    if [[ "${FRESH:-false}" == "true" ]]; then
+        if tui_run_with_spinner "$log" "sbt clean dist  ${DIM}(log: $log)${RESET}" \
+            sbt -no-colors clean dist; then
+            tui_ok "sbt: clean dist done"
+            BUILD_DID_RUN=true
+        else
+            tui_err "sbt: clean dist FAILED  ${DIM}(tail -f $log)${RESET}"
+            return 1
+        fi
+    elif [[ "${BUILD:-auto}" == "auto" ]] && ! any_jvm_src_changed; then
+        tui_skip "sbt dist: skipped (no source changes since last build)"
+        return 0
+    else
+        if tui_run_with_spinner "$log" "sbt dist  ${DIM}(log: $log)${RESET}" \
+            sbt -no-colors dist; then
+            tui_ok "sbt: dist done"
+            BUILD_DID_RUN=true
+        else
+            tui_err "sbt: dist FAILED  ${DIM}(tail -f $log)${RESET}"
+            return 1
+        fi
+    fi
+    # Stop any running JVMs BEFORE unzip — overwriting jars under a live JVM
+    # corrupts its lazy class loads and the service silently dies later.
+    if [[ "$BUILD_DID_RUN" == "true" ]]; then
+        local svc="" pid=""
+        for svc in "${SERVICES[@]}"; do
+            [[ "$(amap_get SVC_TYPE "$svc")" == "jvm" ]] || continue
+            pid=$(svc_running_pid "$svc")
+            [[ -z "$pid" ]] && continue
+            tui_step "$svc: pre-bouncing PID $pid (jars about to change)"
+            kill "$pid" 2>/dev/null || true
+        done
+        # Wait briefly for them to actually exit
+        local waited=0
+        while (( waited < 10 )); do
+            local still_up=0
+            for svc in "${SERVICES[@]}"; do
+                [[ "$(amap_get SVC_TYPE "$svc")" == "jvm" ]] || continue
+                [[ -n "$(svc_running_pid "$svc")" ]] && still_up=$((still_up+1))
+            done
+            (( still_up == 0 )) && break
+            sleep 0.5
+            waited=$((waited+1))
+        done
+    fi
+    tui_step "unzipping dist artifacts"
+    local zip_glob="" unzip_dest=""
+    for svc in "${SERVICES[@]}"; do
+        [[ "$(amap_get SVC_TYPE "$svc")" == "jvm" ]] || continue
+        zip_glob=$(amap_get SVC_ZIP_GLOB "$svc")
+        unzip_dest=$(amap_get SVC_UNZIP_DEST "$svc")
+        # Sibling services (empty ZIP_GLOB) share another service's dist —
+        # just stamp them as clean since the unzip already happened for the
+        # twin holding the build.
+        if [[ -z "$zip_glob" ]]; then
+            svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc" 2>/dev/null || true
+            continue
+        fi
+        # shellcheck disable=SC2086
+        if unzip -oq ${zip_glob} -d "${unzip_dest}" 2>/dev/null; then
+            svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc"
+        else
+            tui_warn "${zip_glob} not produced"
+        fi
+    done
+    tui_ok "artifacts unzipped"
+}
+
+refresh_node_deps() {
+    if ! is_skipped frontend; then
+        if [[ "${BUILD:-auto}" == "auto" ]] && ! needs_yarn_install; then
+            tui_skip "yarn install: skipped (lock unchanged)"
+        else
+            local log="$LOG_DIR/yarn-install.log"
+            if tui_run_with_spinner "$log" "yarn install (frontend)  ${DIM}(log: $log)${RESET}" \
+                bash -c "cd frontend && yarn install"; then
+                tui_ok "yarn: deps refreshed"
+            else
+                tui_warn "yarn install failed  ${DIM}(tail -f $log)${RESET}"
+            fi
+        fi
+    fi
+    if ! is_skipped agent-service; then
+        if [[ "${BUILD:-auto}" == "auto" ]] && ! needs_bun_install; then
+            tui_skip "bun install: skipped (lock unchanged)"
+        else
+            local log="$LOG_DIR/bun-install.log"
+            if tui_run_with_spinner "$log" "bun install (agent-service)  ${DIM}(log: $log)${RESET}" \
+                bash -c "cd agent-service && bun install"; then
+                tui_ok "bun: deps refreshed"
+            else
+                tui_warn "bun install failed  ${DIM}(tail -f $log)${RESET}"
+            fi
+        fi
+    fi
+}
+
+# --------- subcommands ---------
+cmd_status() {
+    local branch="" sha=""
+    branch=$(git -C "$REPO_ROOT" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "?")
+    sha=$(git -C "$REPO_ROOT" rev-parse --short HEAD 2>/dev/null || echo "?")
+    tui_banner "Texera Local Dev" "branch: $branch  @  $sha"
+
+    # One docker stats call up front — paying the ~2s docker-API cost once
+    # is cheaper than running it per docker service. Indexed by container
+    # name → "cpu%|mem" so the per-row formatting is just a lookup.
+    # `_DSTATS` is an amap (bash 3.2: no associative arrays).
+    while IFS='|' read -r name cpu mem; do
+        [[ -n "$name" ]] && amap_set _DSTATS "$name" "$cpu|$mem"
+    done < <(_docker_stats_snapshot)
+
+    printf "\n"
+    printf "    ${BOLD}%-32s %-6s %-9s %-10s %-7s %-7s %s${RESET}\n" \
+        "SERVICE" "PORT" "PID" "UPTIME" "CPU%" "MEM" "STATE"
+    printf "    ${GRAY}"
+    tui_hline "─" 32; printf " "
+    tui_hline "─" 6;  printf " "
+    tui_hline "─" 9;  printf " "
+    tui_hline "─" 10; printf " "
+    tui_hline "─" 7;  printf " "
+    tui_hline "─" 7;  printf " "
+    tui_hline "─" 12; printf "${RESET}\n"
+
+    local n_running=0 n_total=0 frontend_up=false
+    for svc in "${SERVICES[@]}"; do
+        n_total=$((n_total+1))
+        local pid="—" state="stopped" uptime="—" cpu="—" mem="—"
+        if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+            state=$(docker_svc_state "$svc")
+            if [[ "$state" == "running" ]]; then
+                local container="" dstat=""
+                container=$(_docker_container_for "$svc")
+                dstat=$(amap_get _DSTATS "$container")
+                if [[ -n "$dstat" ]]; then
+                    cpu="${dstat%|*}"
+                    mem="${dstat#*|}"
+                fi
+                uptime=$(svc_uptime "$svc")
+            fi
+        else
+            local found_pid=""
+            found_pid=$(svc_running_pid "$svc")
+            if [[ -n "$found_pid" ]]; then
+                state="running"; pid="$found_pid"
+                uptime=$(svc_uptime "$svc")
+                local cm=""
+                cm=$(svc_proc_cpu_mem "$svc")
+                cpu="${cm%|*}"
+                mem="${cm#*|}"
+            fi
+        fi
+        [[ "$state" == "running" ]] && n_running=$((n_running+1))
+        [[ "$svc" == "frontend" && "$state" == "running" ]] && frontend_up=true
+
+        local sym="" color=""
+        sym=$(tui_state_symbol "$state")
+        color=$(tui_state_color "$state")
+        printf "  %s " "$sym"
+        printf "${color}%-32s${RESET} %-6s ${DIM}%-9s${RESET} %-10s %-7s %-7s ${color}%s${RESET}\n" \
+            "$svc" "$(amap_get SVC_PORT "$svc")" "$pid" "$uptime" "$cpu" "$mem" "$state"
+    done
+    printf "\n"
+
+    local summary_color="$YELLOW"
+    (( n_running == n_total )) && summary_color="$GREEN"
+    (( n_running == 0 )) && summary_color="$GRAY"
+    printf "  ${BOLD}Status${RESET}: ${summary_color}%d of %d services running${RESET}\n" "$n_running" "$n_total"
+
+    printf "\n"
+    printf "  ${CYAN}${SYM_LIST}${RESET}  Logs:    ${DIM}%s${RESET}\n" "$LOG_DIR/<service>.log"
+    printf "  ${CYAN}${SYM_LIST}${RESET}  Docker:  ${DIM}docker compose -p %s ps${RESET}\n" "$DOCKER_PROJECT"
+    if $frontend_up; then
+        printf "  ${CYAN}${SYM_LIST}${RESET}  Open:    ${BOLD}${GREEN}http://localhost:4200${RESET}  ${GREEN}(frontend live)${RESET}\n"
+    else
+        printf "  ${CYAN}${SYM_LIST}${RESET}  Open:    ${DIM}http://localhost:4200  (frontend not running yet)${RESET}\n"
+    fi
+
+    printf "\n  ${BOLD}Common operations${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh up${RESET}            ${DIM}# bring up the whole stack (build + start)${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh down${RESET}          ${DIM}# stop every service${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh auto${RESET}          ${DIM}# rebuild + bounce only the services whose source changed${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh <svc>${RESET}         ${DIM}# rebuild that one JVM service and bounce it${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh start <svc>${RESET}   ${DIM}# start one service without rebuilding${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh stop  <svc>${RESET}   ${DIM}# stop one service${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh logs  <svc>${RESET}   ${DIM}# tail a service's log${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh -i${RESET}            ${DIM}# open the live TUI (needs Python + textual)${RESET}\n"
+    printf "    ${BOLD}bin/local-dev.sh --help${RESET}        ${DIM}# full reference${RESET}\n"
+    printf "\n"
+}
+
+cmd_up() {
+    SKIP_LIST=""
+    FRESH=false
+    BUILD=auto       # auto (skip if no source change) | force | no
+    while [[ $# -gt 0 ]]; do
+        case "$1" in
+            --skip=*)   SKIP_LIST="${1#--skip=}" ;;
+            --fresh)    FRESH=true; BUILD=force ;;
+            --build)    BUILD=force ;;
+            --no-build) BUILD=no ;;
+            *) tui_err "unknown flag: $1" >&2; exit 2 ;;
+        esac
+        shift
+    done
+
+    local n_skip=0
+    [[ -n "$SKIP_LIST" ]] && n_skip=$(echo "$SKIP_LIST" | tr ',' '\n' | wc -l | tr -d ' ')
+    local skip_label="none"
+    (( n_skip > 0 )) && skip_label="$n_skip service(s)"
+    tui_banner "Texera Local Dev — bringing stack up" "JDK 17 · skip=$skip_label · build=$BUILD"
+
+    # ── Pre-flight short-circuit ───────────────────────────────────────────
+    # If nothing's changed AND every service is already running, just say so
+    # and exit. Saves the user from scrolling through 30+ "already running"
+    # lines for the common "I just want to check" case.
+    if [[ "$BUILD" == "auto" && -z "$SKIP_LIST" ]]; then
+        local nothing_to_build=true
+        any_jvm_src_changed   && nothing_to_build=false
+        needs_yarn_install    && nothing_to_build=false
+        needs_bun_install     && nothing_to_build=false
+
+        local all_running=true svc=""
+        for svc in "${SERVICES[@]}"; do
+            if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+                [[ "$(docker_svc_state "$svc")" == "running" ]] || { all_running=false; break; }
+            else
+                [[ -n "$(svc_running_pid "$svc")" ]] || { all_running=false; break; }
+            fi
+        done
+
+        if $nothing_to_build && $all_running; then
+            tui_section "Pre-flight"
+            tui_ok "no source/lock changes since last build"
+            tui_ok "all ${#SERVICES[@]} services already running"
+            printf "\n  ${BOLD}${GREEN}${SYM_OK} nothing to do${RESET}  ${DIM}(use \`u --build\` to force a rebuild, or \`<svc>\` to bounce just one)${RESET}\n\n"
+            return 0
+        fi
+    fi
+
+    if [[ "$BUILD" != "no" ]]; then
+        tui_section "Build"
+        build_all
+        refresh_node_deps
+    else
+        tui_section "Build"
+        tui_skip "build: --no-build (using existing artifacts)"
+    fi
+
+    # ▸ Services -- docker compose has its own TTY panel; native services we
+    # kick off silently in the background, then a single redrawing panel below
+    # shows progress for ALL of them.
+    tui_section "Services  ${DIM}(launching)${RESET}"
+    local svc="" cwd="" log="" type="" launcher=""
+
+    # One project-level `docker compose up -d` for every non-skipped docker
+    # row — much faster than five separate calls.
+    local has_docker_targets=false
+    for svc in "${SERVICES[@]}"; do
+        [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]] || continue
+        is_skipped "$svc" && continue
+        has_docker_targets=true
+        break
+    done
+    if $has_docker_targets; then
+        case "$(infra_state)" in
+            running)    tui_ok "infra: already running" ;;
+            external:*) tui_err "infra: ports taken by non-script containers"
+                        printf "  ${DIM}docker compose -p texera-dev down${RESET}\n" ;;
+            *)          infra_up || true ;;
+        esac
+        # Whether infra is fresh or already up, make sure the texera_db
+        # schema is current — JVMs about to start expect it (jOOQ + Iceberg
+        # both need real tables).
+        infra_ensure_db_schema
+    fi
+
+    for svc in "${SERVICES[@]}"; do
+        is_skipped "$svc" && { tui_skip "$svc: --skip"; continue; }
+        type=$(amap_get SVC_TYPE "$svc")
+        [[ "$type" == "docker" ]] && continue   # already handled by infra_up
+        if [[ -n "$(svc_running_pid "$svc")" ]]; then
+            tui_ok "$svc: already running ${DIM}(PID $(svc_running_pid "$svc"))${RESET}"
+            continue
+        fi
+        cwd=$(amap_get SVC_CWD "$svc")
+        log="$LOG_DIR/$svc.log"
+        tui_step "$svc: launching → ${DIM}$log${RESET}"
+        case "$type" in
+            jvm)
+                launcher=$(amap_get SVC_LAUNCHER "$svc")
+                if [[ ! -x "$cwd/$launcher" ]]; then
+                    tui_err "$svc: launcher missing at $cwd/$launcher"
+                    continue
+                fi
+                ( cd "$cwd" && nohup "./$launcher" >"$log" 2>&1 </dev/null & ) ;;
+            bun)  ( cd "$cwd" && nohup bun run dev >"$log" 2>&1 </dev/null & ) ;;
+            yarn) ( cd "$cwd" && nohup yarn start  >"$log" 2>&1 </dev/null & ) ;;
+        esac
+    done
+
+    tui_section "Health  ${DIM}(refreshing in place)${RESET}"
+    local ec=0
+    tui_wait_panel || ec=$?
+
+    printf "\n"
+    local ok=0 total=0 failed=0
+    for svc in "${SERVICES[@]}"; do
+        is_skipped "$svc" && continue
+        total=$((total+1))
+        if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+            case "$(docker_svc_state "$svc")" in
+                running|exited) ok=$((ok+1)) ;;
+                *)              failed=$((failed+1)) ;;
+            esac
+        else
+            [[ -n "$(svc_running_pid "$svc")" ]] && ok=$((ok+1)) || failed=$((failed+1))
+        fi
+    done
+    if (( failed == 0 )); then
+        printf "  ${BOLD}${GREEN}${SYM_OK} %d of %d services healthy${RESET}\n" "$ok" "$total"
+    else
+        printf "  ${BOLD}${YELLOW}${SYM_WARN} %d of %d services healthy${RESET}  ${RED}(%d failed)${RESET}\n" \
+            "$ok" "$total" "$failed"
+    fi
+    printf "\n"
+
+    cmd_status
+    [[ $ec -eq 0 ]]
+}
+
+# `auto`: the minimal "make the running services match my current source" path.
+# Walks every service, identifies what's actually dirty (content-hash for JVM,
+# lock mtime for yarn/bun, never for docker), and only touches those:
+#   - dirty JVM, currently running   → rebuild + bounce
+#   - dirty JVM, currently stopped   → rebuild only (don't auto-start)
+#   - dirty yarn (frontend lock)     → yarn install + bounce frontend if up
+#   - dirty bun (agent-service lock) → bun install (bun --watch reloads itself)
+# Clean services are left alone — no pre-bounce, no restart.
+cmd_auto() {
+    SKIP_LIST=""
+    while [[ $# -gt 0 ]]; do
+        case "$1" in
+            --skip=*) SKIP_LIST="${1#--skip=}" ;;
+            *) tui_err "unknown flag: $1" >&2; exit 2 ;;
+        esac
+        shift
+    done
+
+    tui_banner "Texera Local Dev — auto bounce" \
+        "rebuild + bounce only what changed since last build"
+
+    # ── Scan ──────────────────────────────────────────────────────────────
+    tui_section "Scan"
+    local svc=""
+    local dirty_jvms=()
+    local need_yarn=false
+    local need_bun=false
+    for svc in "${SERVICES[@]}"; do
+        is_skipped "$svc" && continue
+        case "$(amap_get SVC_TYPE "$svc")" in
+            jvm)
+                if svc_src_changed "$svc"; then
+                    dirty_jvms+=("$svc")
+                    tui_warn "$svc: source changed since last build"
+                fi ;;
+            yarn)
+                if needs_yarn_install; then
+                    need_yarn=true
+                    tui_warn "frontend: yarn.lock newer than node_modules — needs install"
+                fi ;;
+            bun)
+                if needs_bun_install; then
+                    need_bun=true
+                    tui_warn "agent-service: bun.lock newer than node_modules — needs install"
+                fi ;;
+        esac
+    done
+
+    if (( ${#dirty_jvms[@]} == 0 )) && ! $need_yarn && ! $need_bun; then
+        tui_ok "everything up-to-date — nothing to bounce"
+        printf "\n"
+        return 0
+    fi
+
+    # ── Build ─────────────────────────────────────────────────────────────
+    # One `sbt dist` covers every dirty JVM in a single sbt invocation; sbt's
+    # own incremental compiler only recompiles the subprojects that need it,
+    # and we only unzip + bounce the dirty ones below — clean services don't
+    # get pre-bounced just because the build ran.
+    if (( ${#dirty_jvms[@]} > 0 )); then
+        tui_section "Build  ${DIM}(${#dirty_jvms[@]} JVM service(s) dirty)${RESET}"
+        # Mark each dirty service as "building" so the TUI shows the
+        # animation across the whole sbt window (~30s+). Without this the
+        # dashboard stays on the prior STATE during the slow build.
+        local _s=""
+        for _s in "${dirty_jvms[@]}"; do
+            phase_set "$_s" building
+        done
+        local log="$LOG_DIR/sbt-dist.log"
+        if ! tui_run_with_spinner "$log" "sbt dist  ${DIM}(log: $log)${RESET}" \
+                sbt -no-colors dist; then
+            for _s in "${dirty_jvms[@]}"; do
+                phase_clear "$_s"
+            done
+            tui_err "sbt dist failed  ${DIM}(tail -f $log)${RESET}"
+            return 1
+        fi
+        tui_ok "sbt: dist done"
+    fi
+
+    # ── Bounce dirty JVMs ────────────────────────────────────────────────
+    # Two passes so siblings can coexist:
+    #   1) stop + (maybe-)unzip + stamp every dirty service
+    #   2) start the ones that were running when we entered
+    #
+    # Pass 1 needs to finish before pass 2 because computing-unit-master
+    # shares amber's dist with texera-web: cu-master has empty SVC_ZIP_GLOB
+    # / SVC_UNZIP_DEST, so its "rebuild" is just waiting for texera-web's
+    # iteration to unzip amber. If we kept the previous single-pass loop
+    # we'd `continue` past start_one whenever ZIP_GLOB was empty and the
+    # sibling never came back up.
+    local n_bounced=0 n_rebuilt=0
+    # `_was_running` is an amap (bash 3.2: no associative arrays). Keyed by
+    # svc → the PID we observed at the start of pass 1, "" if not running.
+    # Cleared with `unset` at the top so a re-invocation (e.g. interactive
+    # REPL would have, if we still had one) starts fresh.
+    local _wr_var=""
+    for _wr_var in $(compgen -v _amap___was_running__ 2>/dev/null); do
+        unset "$_wr_var"
+    done
+    if (( ${#dirty_jvms[@]} > 0 )); then
+        tui_section "Bounce"
+        # Pass 1: stop running pids; unzip own dist if we have one.
+        for svc in "${dirty_jvms[@]}"; do
+            local pid=""
+            pid=$(svc_running_pid "$svc")
+            amap_set _was_running "$svc" "$pid"
+            if [[ -n "$pid" ]]; then
+                # Flip the dashboard from `building` to `stopping` while we
+                # SIGTERM/SIGKILL the JVM, then back to `building` for the
+                # unzip step below. Without these the user only sees one
+                # state during the whole bounce.
+                phase_set "$svc" stopping
+                tui_step "$svc: stopping PID $pid before unzip"
+                kill "$pid" 2>/dev/null || true
+                local i=0
+                while (( i < 30 )) && kill -0 "$pid" 2>/dev/null; do
+                    sleep 0.5
+                    i=$((i+1))
+                done
+                kill -0 "$pid" 2>/dev/null && kill -9 "$pid" 2>/dev/null
+            fi
+            local zip_glob="" unzip_dest=""
+            zip_glob=$(amap_get SVC_ZIP_GLOB "$svc")
+            unzip_dest=$(amap_get SVC_UNZIP_DEST "$svc")
+            if [[ -z "$zip_glob" ]]; then
+                # Sibling service (e.g. computing-unit-master): no own dist
+                # to unzip — its launcher comes from the twin's unzip later
+                # in this pass. Just stamp it clean.
+                phase_set "$svc" building
+                svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc" 2>/dev/null || true
+                n_rebuilt=$((n_rebuilt+1))
+                continue
+            fi
+            phase_set "$svc" building
+            # shellcheck disable=SC2086
+            if unzip -oq ${zip_glob} -d "${unzip_dest}" 2>/dev/null; then
+                svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc"
+                n_rebuilt=$((n_rebuilt+1))
+            else
+                tui_warn "$svc: ${zip_glob} not produced — skipping"
+            fi
+        done
+        # amber's two siblings (texera-web + computing-unit-master) are
+        # *intended* to run together — they share the dist and they're
+        # both required for a working stack. If either was running before
+        # the auto pass, treat the whole group as "should be running" so
+        # the other doesn't end up silently dead just because it had
+        # already crashed / been left stopped from an earlier session.
+        local AMBER_SIBLINGS=(texera-web computing-unit-master)
+        local amber_group_active=false
+        local s=""
+        for s in "${AMBER_SIBLINGS[@]}"; do
+            [[ -n "$(amap_get _was_running "$s")" ]] && amber_group_active=true
+        done
+
+        # Pass 2: start the ones that had been running, plus any amber
+        # sibling that is dirty when the group is "active". By now every
+        # sibling's launcher is on disk (the twin's unzip in pass 1
+        # populated `amber/target/amber-<VERSION>/bin/*`).
+        for svc in "${dirty_jvms[@]}"; do
+            local should_start=false
+            if [[ -n "$(amap_get _was_running "$svc")" ]]; then
+                should_start=true
+            elif $amber_group_active && { [[ "$svc" == "texera-web" ]] || [[ "$svc" == "computing-unit-master" ]]; }; then
+                should_start=true
+                tui_step "$svc: was stopped but its sibling is active — starting too"
+            fi
+            if $should_start; then
+                start_one "$svc"
+                n_bounced=$((n_bounced+1))
+            else
+                tui_skip "$svc: was stopped — rebuilt but not started"
+            fi

Review Comment:
   Fixed in 6088c54a2 — added `phase_clear` on cmd_auto's skip path and start_one's bun/yarn launcher-missing branches.



##########
bin/local-dev-tui.py:
##########
@@ -0,0 +1,1627 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""bin/local-dev-tui.py — Textual dashboard for the Texera local dev stack.
+
+Lives next to bin/local-dev.sh; the shell script remains the canonical engine
+(build, start, stop, status) and this TUI shells out to it for every action.
+The dashboard itself owns state polling, dirty-source detection, and the
+prompt loop.  Textual handles diff rendering so the screen doesn't accrete in
+scrollback the way the old zsh `\\e[H` redraw did.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import contextlib
+import hashlib
+import os
+import re
+import shlex
+import shutil
+import subprocess
+import time
+from dataclasses import dataclass, field
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Optional
+
+from rich.text import Text
+from textual import events, work
+from textual.app import App, ComposeResult
+from textual.binding import Binding
+from textual.containers import Vertical
+from textual.reactive import reactive
+from textual.widgets import DataTable, Input, RichLog, Static
+
+# ─────────────────── Constants ───────────────────
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+STATE_DIR = Path(os.environ.get("TEXERA_LOCAL_DEV_DIR", "/tmp/texera-local-dev"))
+LOG_DIR = STATE_DIR / "logs"
+BUILD_STAMP_DIR = STATE_DIR / "build-stamps"
+# Per-service phase markers written by the shell during stop/build/start.
+# Each file holds `<phase>\t<epoch>` — we read it back in _tick_state and
+# render an animated transitional STATE if it's recent (<90s).
+PHASE_DIR = STATE_DIR / "svc-phase"
+PHASE_STALE_S = 90.0
+REPL_LOG = LOG_DIR / "repl.log"
+LOG_DIR.mkdir(parents=True, exist_ok=True)
+BUILD_STAMP_DIR.mkdir(parents=True, exist_ok=True)
+
+LOCAL_DEV_SH = REPO_ROOT / "bin" / "local-dev.sh"
+DOCKER_PROJECT = "texera-local-dev"
+
+HISTORY_FILE = STATE_DIR / "tui-history"
+MAX_HISTORY = 500
+
+SOURCE_SUFFIXES = {".scala", ".java", ".proto"}
+
+# Single source of truth for per-JVM-service source dirs is the SBT build
+# graph in build.sbt. We parse it instead of hardcoding `common/*` so that
+# adding a `lazy val NewCommon = (project in file("common/new"))` and a
+# corresponding `.dependsOn(NewCommon)` automatically flows through to
+# dirty-detection without anyone touching this file.
+
+
+def _parse_sbt_deps() -> dict[str, dict]:
+    """Walk `build.sbt` and return a dependency graph keyed by sbt project
+    name. Each entry is `{"path": <repo-relative dir>, "deps": [..main-scope
+    deps..]}`. Test-only `% "test->test"` deps are filtered out — they
+    can't affect a service's runtime artifact, so they don't drive dirty.
+    """
+    bs = REPO_ROOT / "build.sbt"
+    try:
+        text = bs.read_text(encoding="utf-8", errors="replace")
+    except OSError:
+        return {}
+
+    proj_re = re.compile(
+        r'^lazy\s+val\s+([A-Z][A-Za-z0-9]*)\s*=\s*\(project\s+in\s+file\("([^"]+)"\)\)',
+        re.MULTILINE,
+    )
+    matches = list(proj_re.finditer(text))
+    if not matches:
+        return {}
+
+    graph: dict[str, dict] = {}
+    for i, m in enumerate(matches):
+        name = m.group(1)
+        path = m.group(2)
+        # The "block" for this project spans from this match to the next
+        # `lazy val ... = (project in file(...))` (or end of file). All the
+        # chained `.dependsOn(...)` calls live in there.
+        end = matches[i + 1].start() if i + 1 < len(matches) else len(text)
+        block = text[m.start():end]
+
+        deps: list[str] = []
+        for arg_list in re.findall(r"\.dependsOn\(([^)]*)\)", block):
+            for arg in arg_list.split(","):
+                arg = arg.strip()
+                # Skip test-scope (`X % "test->test"`) — runtime build
+                # doesn't ship those classes.
+                if "%" in arg:
+                    continue
+                # Strip any trailing whitespace / comments. Project refs
+                # are bare identifiers.
+                ref = arg.split()[0] if arg else ""
+                if ref and ref[0].isupper():
+                    deps.append(ref)
+        graph[name] = {"path": path, "deps": deps}
+    return graph
+
+
+def _transitive_src_dirs(sbt_project: Optional[str], graph: dict[str, dict]) -> list[str]:
+    """Return source dirs for sbt_project AND every project it transitively
+    depends on. Each dir is `<project_path>/src` (the canonical sbt source
+    location). Order is stable; duplicates removed. Raises if the graph
+    is empty or `sbt_project` isn't in it — silently falling back to a
+    hardcoded common/* list would mask a real build.sbt drift."""
+    if not graph:
+        raise RuntimeError("build.sbt dependency graph is empty — parse failed")
+    if not sbt_project or sbt_project not in graph:
+        raise RuntimeError(
+            f"sbt project {sbt_project!r} not found in build.sbt graph; "
+            f"known projects: {sorted(graph.keys())}"
+        )
+    visited: set[str] = set()
+    out: list[str] = []
+
+    def walk(name: str) -> None:
+        if name in visited or name not in graph:
+            return
+        visited.add(name)
+        path = graph[name]["path"]
+        src = f"{path}/src"
+        if src not in out:
+            out.append(src)
+        for d in graph[name]["deps"]:
+            walk(d)
+    walk(sbt_project)
+    return out
+
+
+_SBT_GRAPH = _parse_sbt_deps()
+
+
+# Per-sbt-project transitive closure, memoised. Computed once on first
+# touch; subsequent dirty checks are O(1) lookup vs the prior O(deps)
+# BFS per call.
+_SBT_TRANSITIVE_CACHE: dict[str, list[str]] = {}
+
+
+def _transitive_src_dirs_cached(sbt_project: Optional[str]) -> list[str]:
+    if sbt_project is None:
+        return _transitive_src_dirs(None, _SBT_GRAPH)
+    if sbt_project not in _SBT_TRANSITIVE_CACHE:
+        _SBT_TRANSITIVE_CACHE[sbt_project] = _transitive_src_dirs(sbt_project, _SBT_GRAPH)
+    return _SBT_TRANSITIVE_CACHE[sbt_project]
+
+POLL_INTERVAL_S = 1.0     # how often to refresh service state
+DIRTY_INTERVAL_S = 2.0    # how often to recompute dirty indicators
+
+# Services whose own runtime watches the filesystem and rebuilds on source
+# change: `yarn start` runs `ng serve` (Angular dev server, hot-reload) and
+# `bun run --watch` reloads the agent-service on change.  The dashboard
+# surfaces this in the SRC column so the user doesn't try to bounce them
+# unnecessarily; the ★ "dirty" indicator only flashes for them when the lock
+# file changes (i.e. an actual dep refresh is needed).
+WATCH_TYPES = {"yarn", "bun"}
+
+
+# ─────────────────── Texera version (dynamic) ───────────────────
+
+_VERSION_RE = re.compile(
+    r'^\s*ThisBuild\s*/\s*version\s*:=\s*"([^"]+)"', re.MULTILINE
+)
+
+
+def texera_version() -> str:
+    """Parse the project version from build.sbt so artifact paths track
+    whatever branch the developer is on (it's 1.3.0-incubating-SNAPSHOT on
+    main today, was 1.2.0-incubating on release/v1.2, will differ again).
+    Override with `TEXERA_VERSION` env var to bypass parsing."""
+    env = os.environ.get("TEXERA_VERSION")
+    if env:
+        return env
+    bs = REPO_ROOT / "build.sbt"
+    if not bs.exists():
+        raise RuntimeError(
+            f"build.sbt not found at {bs} — set TEXERA_VERSION to bypass"
+        )
+    m = _VERSION_RE.search(bs.read_text(errors="replace"))
+    if not m:
+        raise RuntimeError(
+            f"could not find `ThisBuild / version := \"…\"` in {bs} — "
+            f"set TEXERA_VERSION to bypass"
+        )
+    return m.group(1)
+
+
+TEXERA_VERSION = texera_version()
+
+
+# ─────────────────── Service catalog ───────────────────
+
+@dataclass
+class Service:
+    name: str
+    type: str             # "docker" | "jvm" | "yarn" | "bun"
+    port: int
+    sbt_project: Optional[str] = None     # for jvm
+    own_src: Optional[str] = None         # for jvm
+    artifact_jar: Optional[str] = None    # for jvm
+
+
+def _jvm(name: str, port: int, project: Optional[str], own_src: str) -> Service:
+    """sbt-native-packager lays the dist out as
+    `target/<artifact>-<VERSION>/lib/org.apache.texera.<artifact>-<VERSION>.jar`
+    for every subproject. amber is the exception: its sbt subproject is
+    named `amber` (not `texera-web`) and the dist goes under `amber/target/`
+    rather than the repo-level `target/`. computing-unit-master rides that
+    same amber dist as a sibling launcher — its `project` is None because
+    no separate sbt invocation produces it."""
+    is_amber_svc = name in ("texera-web", "computing-unit-master")
+    artifact = "amber" if is_amber_svc else name
+    target_prefix = "amber/" if is_amber_svc else ""
+    jar = (
+        f"{target_prefix}target/{artifact}-{TEXERA_VERSION}/lib/"
+        f"org.apache.texera.{artifact}-{TEXERA_VERSION}.jar"
+    )
+    return Service(name, "jvm", port, sbt_project=project,
+                   own_src=own_src, artifact_jar=jar)
+
+
+SERVICES: list[Service] = [
+    Service("postgres",   "docker", 5432),
+    Service("minio",      "docker", 9000),
+    Service("lakefs",     "docker", 8000),
+    Service("lakekeeper", "docker", 8181),
+    Service("litellm",    "docker", 4000),
+    _jvm("config-service",                  9094, "ConfigService",
+         "config-service/src"),
+    _jvm("access-control-service",          9096, "AccessControlService",
+         "access-control-service/src"),
+    _jvm("file-service",                    9092, "FileService",
+         "file-service/src"),
+    _jvm("workflow-compiling-service",      9090, "WorkflowCompilingService",
+         "workflow-compiling-service/src"),
+    _jvm("computing-unit-master",           8085, None,
+         "amber/src"),
+    _jvm("computing-unit-managing-service", 8082, "ComputingUnitManagingService",
+         "computing-unit-managing-service/src"),
+    _jvm("texera-web",                      8080, "WorkflowExecutionService",
+         "amber/src"),
+    Service("agent-service", "bun",  3001),
+    Service("frontend",      "yarn", 4200),
+]
+
+SERVICES_BY_NAME = {s.name: s for s in SERVICES}
+
+
+# ─────────────────── Live state model ───────────────────
+
+def read_svc_phase(svc_name: str) -> Optional[str]:
+    """Return the shell-written phase (`stopping` / `building` / `starting`)
+    or None if absent / stale. Stale-after-90s guards against a crashed
+    `bin/local-dev.sh` leaving an orphan file."""
+    f = PHASE_DIR / svc_name
+    try:
+        text = f.read_text().strip()
+    except OSError:
+        return None
+    if not text:
+        return None
+    parts = text.split("\t", 1)
+    phase = parts[0]
+    try:
+        ts = float(parts[1]) if len(parts) > 1 else 0.0
+    except ValueError:
+        ts = 0.0
+    if ts and (time.time() - ts) > PHASE_STALE_S:
+        return None
+    return phase
+
+
+@dataclass
+class LiveState:
+    """Snapshot of the world this tick — what the dashboard renders."""
+    docker: dict[str, tuple[str, str]] = field(default_factory=dict)   # name -> (state, status)
+    pids: dict[str, Optional[str]] = field(default_factory=dict)       # name -> pid or None
+    dirty: dict[str, bool] = field(default_factory=dict)
+    mtimes: dict[str, Optional[str]] = field(default_factory=dict)
+    # Per-service resource usage (computed every poll for native services
+    # via cheap `ps`; refreshed less often for docker via `docker stats`
+    # since that call costs ~2s).
+    uptimes: dict[str, str] = field(default_factory=dict)              # name -> "12m" / "—"
+    cpu_pct: dict[str, str] = field(default_factory=dict)              # name -> "8.2%" / "—"
+    mem_use: dict[str, str] = field(default_factory=dict)              # name -> "85M" / "—"
+    phases:  dict[str, str] = field(default_factory=dict)              # name -> "stopping"/"building"/"starting" or ""
+
+
+# ─────────────────── Helpers ───────────────────
+
+async def _run_capture(*argv: str) -> str:
+    proc = await asyncio.create_subprocess_exec(
+        *argv,
+        stdout=asyncio.subprocess.PIPE,
+        stderr=asyncio.subprocess.DEVNULL,
+    )
+    stdout, _ = await proc.communicate()
+    return stdout.decode(errors="replace")
+
+
+async def lsof_port_pid(port: int) -> Optional[str]:
+    out = await _run_capture("lsof", "-nP", f"-iTCP:{port}", "-sTCP:LISTEN", "-t")
+    out = out.strip()
+    return out.split("\n", 1)[0] if out else None
+
+
+async def docker_ps_all() -> dict[str, tuple[str, str]]:
+    out = await _run_capture(
+        "docker", "compose", "-p", DOCKER_PROJECT, "ps", "-a",
+        "--format", "{{.Service}}|{{.State}}|{{.Status}}",
+    )
+    result: dict[str, tuple[str, str]] = {}
+    for line in out.splitlines():
+        parts = line.split("|", 2)
+        if len(parts) == 3:
+            result[parts[0]] = (parts[1], parts[2])
+    return result
+
+
+def docker_state(svc_state: str, svc_status: str) -> str:
+    """Map docker's raw state/status to the small palette the dashboard renders."""
+    if svc_state == "running":
+        if "(healthy)" in svc_status:
+            return "running"
+        if "(health: starting)" in svc_status:
+            return "starting"
+        if "(unhealthy)" in svc_status:
+            return "unhealthy"
+        return "running"
+    if svc_state == "exited":
+        return "exited" if svc_status.startswith("Exited (0)") else "failed"
+    if svc_state in ("created", "restarting", "paused", "removing"):
+        return "starting"
+    return "stopped"
+
+
+# ─────────────────── Dirty-source detection (content hash) ───────────────────
+
+# ─────────────────── Uptime / resource helpers ───────────────────
+
+def _format_uptime(secs: int) -> str:
+    """Compact duration: `12s`, `5m 23s`, `2h 14m`, `3d 4h`."""
+    if secs < 0:
+        return "—"
+    if secs < 60:
+        return f"{secs}s"
+    if secs < 3600:
+        return f"{secs // 60}m {secs % 60}s"
+    if secs < 86400:
+        return f"{secs // 3600}h {(secs % 3600) // 60}m"
+    return f"{secs // 86400}d {(secs % 86400) // 3600}h"
+
+
+def _format_bytes(n: int) -> str:
+    """Bytes → short human string (`85M`, `1.2G`, `467K`)."""
+    if n < 1024:
+        return f"{n}B"
+    if n < 1024 ** 2:
+        return f"{n // 1024}K"
+    if n < 1024 ** 3:
+        return f"{n // (1024 ** 2)}M"
+    return f"{n / (1024 ** 3):.1f}G"
+
+
+def _parse_etime(et: str) -> int:
+    """`ps -o etime` format `[[DD-]hh:]mm:ss` → seconds."""
+    et = et.strip()
+    if not et:
+        return -1
+    days = 0
+    if "-" in et:
+        d, et = et.split("-", 1)
+        days = int(d or 0)
+    parts = et.split(":")
+    try:
+        if len(parts) == 3:
+            h, m, s = (int(p or 0) for p in parts)
+        elif len(parts) == 2:
+            h = 0
+            m, s = (int(p or 0) for p in parts)
+        else:
+            h = m = 0
+            s = int(parts[0] or 0)
+    except ValueError:
+        return -1
+    return days * 86400 + h * 3600 + m * 60 + s
+
+
+def _docker_container_for(svc_name: str) -> str:
+    """Container names: most are `texera-<svc>`; `litellm` is unprefixed."""
+    if svc_name == "litellm":
+        return "litellm"
+    return f"texera-{svc_name}"
+
+
+_DOCKER_STATS_CACHE: dict[str, tuple[str, str]] = {}
+_DOCKER_STATS_TS: float = 0.0
+_DOCKER_STATS_TTL = 5.0  # seconds — docker stats --no-stream costs ~2s, don't run it more than this
+
+
+def _refresh_docker_stats() -> None:
+    """Single `docker stats --no-stream` pass; refreshes the cached
+    container → (cpu%, mem) map. Called from a background worker so the
+    main poll tick stays cheap."""
+    global _DOCKER_STATS_CACHE, _DOCKER_STATS_TS
+    try:
+        out = subprocess.run(
+            ["docker", "stats", "--no-stream",
+             "--format", "{{.Name}}|{{.CPUPerc}}|{{.MemUsage}}"],
+            capture_output=True, text=True, timeout=8,
+        ).stdout
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return
+    fresh: dict[str, tuple[str, str]] = {}
+    for line in out.splitlines():
+        parts = line.split("|")
+        if len(parts) != 3:
+            continue
+        name, cpu, memu = parts
+        # MemUsage is "85.2MiB / 1.95GiB" — strip the "/ total" half.
+        used = memu.split(" /")[0].strip()
+        # Normalise to our own _format_bytes shape: parse the IEC unit suffix.
+        m = re.match(r"^([0-9.]+)\s*([KMGTPE]?i?B)?$", used)
+        if m:
+            val = float(m.group(1))
+            unit = (m.group(2) or "B").lower()
+            mult = {
+                "b":    1,
+                "kb":   1024,    "kib": 1024,
+                "mb":   1024**2, "mib": 1024**2,
+                "gb":   1024**3, "gib": 1024**3,
+                "tb":   1024**4, "tib": 1024**4,
+            }.get(unit, 1)
+            mem_str = _format_bytes(int(val * mult))
+        else:
+            mem_str = used or "—"
+        fresh[name] = (cpu, mem_str)
+    _DOCKER_STATS_CACHE = fresh
+    _DOCKER_STATS_TS = time.time()
+
+
+def proc_uptime_cpu_mem(pid: str) -> tuple[str, str, str]:
+    """For a native PID return (uptime, cpu%, mem) — `—` if not running."""
+    try:
+        out = subprocess.run(
+            ["ps", "-p", pid, "-o", "etime=,pcpu=,rss="],
+            capture_output=True, text=True, timeout=2,
+        ).stdout.strip()
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return ("—", "—", "—")
+    if not out:
+        return ("—", "—", "—")
+    parts = out.split()
+    if len(parts) < 3:
+        return ("—", "—", "—")
+    etime, cpu, rss_kb = parts[0], parts[1], parts[2]
+    secs = _parse_etime(etime)
+    try:
+        mem = _format_bytes(int(rss_kb) * 1024)
+    except ValueError:
+        mem = "—"
+    return (_format_uptime(secs), f"{cpu}%", mem)
+
+
+def container_uptime(svc_name: str) -> str:
+    """ISO StartedAt → human duration. Empty if not started."""
+    container = _docker_container_for(svc_name)
+    try:
+        out = subprocess.run(
+            ["docker", "inspect", "-f", "{{.State.StartedAt}}", container],
+            capture_output=True, text=True, timeout=2,
+        ).stdout.strip()
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return "—"
+    if not out or out.startswith("0001-01-01"):
+        return "—"
+    try:
+        # ISO 8601 with fractional + Z. Trim to the second.
+        trimmed = out.split(".", 1)[0].rstrip("Z")
+        started = datetime.strptime(trimmed, "%Y-%m-%dT%H:%M:%S").replace(tzinfo=timezone.utc)
+    except ValueError:
+        return "—"
+    elapsed = (datetime.now(timezone.utc) - started).total_seconds()
+    return _format_uptime(max(0, int(elapsed)))
+
+
+def _jvm_src_dirs(svc: Service) -> list[Path]:
+    # Derive the source-dir set from the SBT dependency graph in build.sbt.
+    # Services that share another's sbt project (e.g. computing-unit-master
+    # rides amber's dist) enter the graph at the *producing* project via
+    # SHARED_SBT_PROJECT.
+    SHARED_SBT_PROJECT = {
+        "computing-unit-master": "WorkflowExecutionService",
+    }
+    project = svc.sbt_project or SHARED_SBT_PROJECT.get(svc.name)
+    if not project:
+        raise RuntimeError(
+            f"service {svc.name!r} has no sbt_project and no SHARED_SBT_PROJECT "
+            f"mapping — can't compute its source-dir closure"
+        )
+    src_dirs = _transitive_src_dirs_cached(project)
+    return [REPO_ROOT / d for d in src_dirs if (REPO_ROOT / d).exists()]
+
+
+def _jvm_source_files(svc: Service) -> list[Path]:
+    files: list[Path] = []
+    for d in _jvm_src_dirs(svc):
+        for f in d.rglob("*"):
+            if f.is_file() and f.suffix in SOURCE_SUFFIXES:
+                files.append(f)
+    files.sort()
+    return files
+
+
+def source_hash(svc: Service) -> str:
+    h = hashlib.sha1()
+    for f in _jvm_source_files(svc):
+        try:
+            h.update(f.read_bytes())
+        except OSError:
+            pass
+    return h.hexdigest()
+
+
+def _newest_mtime_after(files: list[Path], stamp_mtime: float) -> bool:
+    for f in files:
+        try:
+            if f.stat().st_mtime > stamp_mtime:
+                return True
+        except OSError:
+            continue
+    return False
+
+
+def is_dirty(svc: Service) -> bool:
+    """Did the service's relevant source change since the last build?
+
+    JVM: SHA-1 of all .scala/.java/.proto bytes vs. the hash we wrote at the
+    last build, with an mtime fast filter so 99% of ticks are O(stat).
+    yarn/bun: lock vs. node_modules dir mtime — cheap.
+    docker: always clean.
+    """
+    if svc.type == "docker":
+        return False
+    if svc.type == "jvm":
+        return _jvm_is_dirty(svc)
+    if svc.type == "yarn":
+        nm = REPO_ROOT / "frontend" / "node_modules" / ".yarn-state.yml"
+        lock = REPO_ROOT / "frontend" / "yarn.lock"
+        if not nm.exists():
+            return True
+        return lock.stat().st_mtime > nm.stat().st_mtime
+    if svc.type == "bun":
+        nm = REPO_ROOT / "agent-service" / "node_modules"
+        lock = REPO_ROOT / "agent-service" / "bun.lock"
+        if not nm.exists():
+            return True
+        return lock.stat().st_mtime > nm.stat().st_mtime
+    return False
+
+
+def _jvm_is_dirty(svc: Service) -> bool:
+    stamp = BUILD_STAMP_DIR / svc.name
+    if not stamp.exists() or stamp.stat().st_size == 0:
+        # Lazy seed: if a jar is present, assume it matches current source and
+        # write the hash. First REPL after a fresh checkout pays this once.
+        jar = REPO_ROOT / svc.artifact_jar if svc.artifact_jar else None
+        if jar is None or not jar.exists():
+            return True
+        stamp.write_text(source_hash(svc))
+        return False
+
+    files = _jvm_source_files(svc)

Review Comment:
   Fixed in 6088c54a2 — `source_hash` now takes an optional pre-collected files list; the slow path reuses the one the mtime filter already built.



##########
bin/local-dev-tui.py:
##########
@@ -0,0 +1,1627 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""bin/local-dev-tui.py — Textual dashboard for the Texera local dev stack.
+
+Lives next to bin/local-dev.sh; the shell script remains the canonical engine
+(build, start, stop, status) and this TUI shells out to it for every action.
+The dashboard itself owns state polling, dirty-source detection, and the
+prompt loop.  Textual handles diff rendering so the screen doesn't accrete in
+scrollback the way the old zsh `\\e[H` redraw did.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import contextlib
+import hashlib
+import os
+import re
+import shlex
+import shutil
+import subprocess
+import time
+from dataclasses import dataclass, field
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Optional
+
+from rich.text import Text
+from textual import events, work
+from textual.app import App, ComposeResult
+from textual.binding import Binding
+from textual.containers import Vertical
+from textual.reactive import reactive
+from textual.widgets import DataTable, Input, RichLog, Static
+
+# ─────────────────── Constants ───────────────────
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+STATE_DIR = Path(os.environ.get("TEXERA_LOCAL_DEV_DIR", "/tmp/texera-local-dev"))
+LOG_DIR = STATE_DIR / "logs"
+BUILD_STAMP_DIR = STATE_DIR / "build-stamps"
+# Per-service phase markers written by the shell during stop/build/start.
+# Each file holds `<phase>\t<epoch>` — we read it back in _tick_state and
+# render an animated transitional STATE if it's recent (<90s).
+PHASE_DIR = STATE_DIR / "svc-phase"
+PHASE_STALE_S = 90.0
+REPL_LOG = LOG_DIR / "repl.log"
+LOG_DIR.mkdir(parents=True, exist_ok=True)
+BUILD_STAMP_DIR.mkdir(parents=True, exist_ok=True)
+
+LOCAL_DEV_SH = REPO_ROOT / "bin" / "local-dev.sh"
+DOCKER_PROJECT = "texera-local-dev"
+
+HISTORY_FILE = STATE_DIR / "tui-history"
+MAX_HISTORY = 500
+
+SOURCE_SUFFIXES = {".scala", ".java", ".proto"}
+
+# Single source of truth for per-JVM-service source dirs is the SBT build
+# graph in build.sbt. We parse it instead of hardcoding `common/*` so that
+# adding a `lazy val NewCommon = (project in file("common/new"))` and a
+# corresponding `.dependsOn(NewCommon)` automatically flows through to
+# dirty-detection without anyone touching this file.
+
+
+def _parse_sbt_deps() -> dict[str, dict]:
+    """Walk `build.sbt` and return a dependency graph keyed by sbt project
+    name. Each entry is `{"path": <repo-relative dir>, "deps": [..main-scope
+    deps..]}`. Test-only `% "test->test"` deps are filtered out — they
+    can't affect a service's runtime artifact, so they don't drive dirty.
+    """
+    bs = REPO_ROOT / "build.sbt"
+    try:
+        text = bs.read_text(encoding="utf-8", errors="replace")
+    except OSError:

Review Comment:
   Tightened in 6088c54a2 — Python sorts by raw bytes (`str(p).encode()`) so the order matches GNU `sort -z` exactly. Collapsing to one implementation is a bigger refactor; filing as a follow-up.



##########
bin/local-dev-tui.py:
##########
@@ -0,0 +1,1627 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""bin/local-dev-tui.py — Textual dashboard for the Texera local dev stack.
+
+Lives next to bin/local-dev.sh; the shell script remains the canonical engine
+(build, start, stop, status) and this TUI shells out to it for every action.
+The dashboard itself owns state polling, dirty-source detection, and the
+prompt loop.  Textual handles diff rendering so the screen doesn't accrete in
+scrollback the way the old zsh `\\e[H` redraw did.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import contextlib
+import hashlib
+import os
+import re
+import shlex
+import shutil
+import subprocess
+import time
+from dataclasses import dataclass, field
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Optional
+
+from rich.text import Text
+from textual import events, work
+from textual.app import App, ComposeResult
+from textual.binding import Binding
+from textual.containers import Vertical
+from textual.reactive import reactive
+from textual.widgets import DataTable, Input, RichLog, Static
+
+# ─────────────────── Constants ───────────────────
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+STATE_DIR = Path(os.environ.get("TEXERA_LOCAL_DEV_DIR", "/tmp/texera-local-dev"))
+LOG_DIR = STATE_DIR / "logs"
+BUILD_STAMP_DIR = STATE_DIR / "build-stamps"
+# Per-service phase markers written by the shell during stop/build/start.
+# Each file holds `<phase>\t<epoch>` — we read it back in _tick_state and
+# render an animated transitional STATE if it's recent (<90s).
+PHASE_DIR = STATE_DIR / "svc-phase"
+PHASE_STALE_S = 90.0
+REPL_LOG = LOG_DIR / "repl.log"
+LOG_DIR.mkdir(parents=True, exist_ok=True)
+BUILD_STAMP_DIR.mkdir(parents=True, exist_ok=True)
+
+LOCAL_DEV_SH = REPO_ROOT / "bin" / "local-dev.sh"
+DOCKER_PROJECT = "texera-local-dev"
+
+HISTORY_FILE = STATE_DIR / "tui-history"
+MAX_HISTORY = 500
+
+SOURCE_SUFFIXES = {".scala", ".java", ".proto"}
+
+# Single source of truth for per-JVM-service source dirs is the SBT build
+# graph in build.sbt. We parse it instead of hardcoding `common/*` so that
+# adding a `lazy val NewCommon = (project in file("common/new"))` and a
+# corresponding `.dependsOn(NewCommon)` automatically flows through to
+# dirty-detection without anyone touching this file.
+
+
+def _parse_sbt_deps() -> dict[str, dict]:
+    """Walk `build.sbt` and return a dependency graph keyed by sbt project
+    name. Each entry is `{"path": <repo-relative dir>, "deps": [..main-scope
+    deps..]}`. Test-only `% "test->test"` deps are filtered out — they
+    can't affect a service's runtime artifact, so they don't drive dirty.
+    """
+    bs = REPO_ROOT / "build.sbt"
+    try:
+        text = bs.read_text(encoding="utf-8", errors="replace")
+    except OSError:
+        return {}
+
+    proj_re = re.compile(
+        r'^lazy\s+val\s+([A-Z][A-Za-z0-9]*)\s*=\s*\(project\s+in\s+file\("([^"]+)"\)\)',
+        re.MULTILINE,
+    )
+    matches = list(proj_re.finditer(text))
+    if not matches:
+        return {}
+
+    graph: dict[str, dict] = {}
+    for i, m in enumerate(matches):
+        name = m.group(1)
+        path = m.group(2)
+        # The "block" for this project spans from this match to the next
+        # `lazy val ... = (project in file(...))` (or end of file). All the
+        # chained `.dependsOn(...)` calls live in there.
+        end = matches[i + 1].start() if i + 1 < len(matches) else len(text)
+        block = text[m.start():end]
+
+        deps: list[str] = []
+        for arg_list in re.findall(r"\.dependsOn\(([^)]*)\)", block):
+            for arg in arg_list.split(","):
+                arg = arg.strip()
+                # Skip test-scope (`X % "test->test"`) — runtime build
+                # doesn't ship those classes.
+                if "%" in arg:
+                    continue
+                # Strip any trailing whitespace / comments. Project refs
+                # are bare identifiers.
+                ref = arg.split()[0] if arg else ""
+                if ref and ref[0].isupper():
+                    deps.append(ref)
+        graph[name] = {"path": path, "deps": deps}
+    return graph
+
+
+def _transitive_src_dirs(sbt_project: Optional[str], graph: dict[str, dict]) -> list[str]:
+    """Return source dirs for sbt_project AND every project it transitively
+    depends on. Each dir is `<project_path>/src` (the canonical sbt source
+    location). Order is stable; duplicates removed. Raises if the graph
+    is empty or `sbt_project` isn't in it — silently falling back to a
+    hardcoded common/* list would mask a real build.sbt drift."""
+    if not graph:
+        raise RuntimeError("build.sbt dependency graph is empty — parse failed")
+    if not sbt_project or sbt_project not in graph:
+        raise RuntimeError(
+            f"sbt project {sbt_project!r} not found in build.sbt graph; "
+            f"known projects: {sorted(graph.keys())}"
+        )
+    visited: set[str] = set()
+    out: list[str] = []
+
+    def walk(name: str) -> None:
+        if name in visited or name not in graph:
+            return
+        visited.add(name)
+        path = graph[name]["path"]
+        src = f"{path}/src"
+        if src not in out:
+            out.append(src)
+        for d in graph[name]["deps"]:
+            walk(d)
+    walk(sbt_project)
+    return out
+
+
+_SBT_GRAPH = _parse_sbt_deps()
+
+
+# Per-sbt-project transitive closure, memoised. Computed once on first
+# touch; subsequent dirty checks are O(1) lookup vs the prior O(deps)
+# BFS per call.
+_SBT_TRANSITIVE_CACHE: dict[str, list[str]] = {}
+
+
+def _transitive_src_dirs_cached(sbt_project: Optional[str]) -> list[str]:
+    if sbt_project is None:
+        return _transitive_src_dirs(None, _SBT_GRAPH)
+    if sbt_project not in _SBT_TRANSITIVE_CACHE:
+        _SBT_TRANSITIVE_CACHE[sbt_project] = _transitive_src_dirs(sbt_project, _SBT_GRAPH)
+    return _SBT_TRANSITIVE_CACHE[sbt_project]
+
+POLL_INTERVAL_S = 1.0     # how often to refresh service state
+DIRTY_INTERVAL_S = 2.0    # how often to recompute dirty indicators
+
+# Services whose own runtime watches the filesystem and rebuilds on source
+# change: `yarn start` runs `ng serve` (Angular dev server, hot-reload) and
+# `bun run --watch` reloads the agent-service on change.  The dashboard
+# surfaces this in the SRC column so the user doesn't try to bounce them
+# unnecessarily; the ★ "dirty" indicator only flashes for them when the lock
+# file changes (i.e. an actual dep refresh is needed).
+WATCH_TYPES = {"yarn", "bun"}
+
+
+# ─────────────────── Texera version (dynamic) ───────────────────
+
+_VERSION_RE = re.compile(
+    r'^\s*ThisBuild\s*/\s*version\s*:=\s*"([^"]+)"', re.MULTILINE
+)
+
+
+def texera_version() -> str:
+    """Parse the project version from build.sbt so artifact paths track
+    whatever branch the developer is on (it's 1.3.0-incubating-SNAPSHOT on
+    main today, was 1.2.0-incubating on release/v1.2, will differ again).
+    Override with `TEXERA_VERSION` env var to bypass parsing."""
+    env = os.environ.get("TEXERA_VERSION")
+    if env:
+        return env
+    bs = REPO_ROOT / "build.sbt"
+    if not bs.exists():
+        raise RuntimeError(
+            f"build.sbt not found at {bs} — set TEXERA_VERSION to bypass"
+        )
+    m = _VERSION_RE.search(bs.read_text(errors="replace"))
+    if not m:
+        raise RuntimeError(
+            f"could not find `ThisBuild / version := \"…\"` in {bs} — "
+            f"set TEXERA_VERSION to bypass"
+        )
+    return m.group(1)
+
+
+TEXERA_VERSION = texera_version()
+
+
+# ─────────────────── Service catalog ───────────────────
+
+@dataclass
+class Service:
+    name: str
+    type: str             # "docker" | "jvm" | "yarn" | "bun"
+    port: int
+    sbt_project: Optional[str] = None     # for jvm
+    own_src: Optional[str] = None         # for jvm
+    artifact_jar: Optional[str] = None    # for jvm
+
+
+def _jvm(name: str, port: int, project: Optional[str], own_src: str) -> Service:
+    """sbt-native-packager lays the dist out as
+    `target/<artifact>-<VERSION>/lib/org.apache.texera.<artifact>-<VERSION>.jar`
+    for every subproject. amber is the exception: its sbt subproject is
+    named `amber` (not `texera-web`) and the dist goes under `amber/target/`
+    rather than the repo-level `target/`. computing-unit-master rides that
+    same amber dist as a sibling launcher — its `project` is None because
+    no separate sbt invocation produces it."""
+    is_amber_svc = name in ("texera-web", "computing-unit-master")
+    artifact = "amber" if is_amber_svc else name
+    target_prefix = "amber/" if is_amber_svc else ""
+    jar = (
+        f"{target_prefix}target/{artifact}-{TEXERA_VERSION}/lib/"
+        f"org.apache.texera.{artifact}-{TEXERA_VERSION}.jar"
+    )
+    return Service(name, "jvm", port, sbt_project=project,
+                   own_src=own_src, artifact_jar=jar)
+
+
+SERVICES: list[Service] = [
+    Service("postgres",   "docker", 5432),
+    Service("minio",      "docker", 9000),
+    Service("lakefs",     "docker", 8000),
+    Service("lakekeeper", "docker", 8181),
+    Service("litellm",    "docker", 4000),
+    _jvm("config-service",                  9094, "ConfigService",
+         "config-service/src"),
+    _jvm("access-control-service",          9096, "AccessControlService",
+         "access-control-service/src"),
+    _jvm("file-service",                    9092, "FileService",
+         "file-service/src"),
+    _jvm("workflow-compiling-service",      9090, "WorkflowCompilingService",
+         "workflow-compiling-service/src"),
+    _jvm("computing-unit-master",           8085, None,
+         "amber/src"),
+    _jvm("computing-unit-managing-service", 8082, "ComputingUnitManagingService",
+         "computing-unit-managing-service/src"),
+    _jvm("texera-web",                      8080, "WorkflowExecutionService",
+         "amber/src"),
+    Service("agent-service", "bun",  3001),
+    Service("frontend",      "yarn", 4200),
+]
+
+SERVICES_BY_NAME = {s.name: s for s in SERVICES}
+
+
+# ─────────────────── Live state model ───────────────────
+
+def read_svc_phase(svc_name: str) -> Optional[str]:
+    """Return the shell-written phase (`stopping` / `building` / `starting`)
+    or None if absent / stale. Stale-after-90s guards against a crashed
+    `bin/local-dev.sh` leaving an orphan file."""
+    f = PHASE_DIR / svc_name
+    try:
+        text = f.read_text().strip()
+    except OSError:
+        return None
+    if not text:
+        return None
+    parts = text.split("\t", 1)
+    phase = parts[0]
+    try:
+        ts = float(parts[1]) if len(parts) > 1 else 0.0
+    except ValueError:
+        ts = 0.0
+    if ts and (time.time() - ts) > PHASE_STALE_S:
+        return None
+    return phase
+
+
+@dataclass
+class LiveState:
+    """Snapshot of the world this tick — what the dashboard renders."""
+    docker: dict[str, tuple[str, str]] = field(default_factory=dict)   # name -> (state, status)
+    pids: dict[str, Optional[str]] = field(default_factory=dict)       # name -> pid or None
+    dirty: dict[str, bool] = field(default_factory=dict)
+    mtimes: dict[str, Optional[str]] = field(default_factory=dict)
+    # Per-service resource usage (computed every poll for native services
+    # via cheap `ps`; refreshed less often for docker via `docker stats`
+    # since that call costs ~2s).
+    uptimes: dict[str, str] = field(default_factory=dict)              # name -> "12m" / "—"
+    cpu_pct: dict[str, str] = field(default_factory=dict)              # name -> "8.2%" / "—"
+    mem_use: dict[str, str] = field(default_factory=dict)              # name -> "85M" / "—"
+    phases:  dict[str, str] = field(default_factory=dict)              # name -> "stopping"/"building"/"starting" or ""
+
+
+# ─────────────────── Helpers ───────────────────
+
+async def _run_capture(*argv: str) -> str:
+    proc = await asyncio.create_subprocess_exec(
+        *argv,
+        stdout=asyncio.subprocess.PIPE,
+        stderr=asyncio.subprocess.DEVNULL,
+    )
+    stdout, _ = await proc.communicate()
+    return stdout.decode(errors="replace")
+
+
+async def lsof_port_pid(port: int) -> Optional[str]:
+    out = await _run_capture("lsof", "-nP", f"-iTCP:{port}", "-sTCP:LISTEN", "-t")
+    out = out.strip()
+    return out.split("\n", 1)[0] if out else None
+
+
+async def docker_ps_all() -> dict[str, tuple[str, str]]:
+    out = await _run_capture(
+        "docker", "compose", "-p", DOCKER_PROJECT, "ps", "-a",
+        "--format", "{{.Service}}|{{.State}}|{{.Status}}",
+    )
+    result: dict[str, tuple[str, str]] = {}
+    for line in out.splitlines():
+        parts = line.split("|", 2)
+        if len(parts) == 3:
+            result[parts[0]] = (parts[1], parts[2])
+    return result
+
+
+def docker_state(svc_state: str, svc_status: str) -> str:
+    """Map docker's raw state/status to the small palette the dashboard renders."""
+    if svc_state == "running":
+        if "(healthy)" in svc_status:
+            return "running"
+        if "(health: starting)" in svc_status:
+            return "starting"
+        if "(unhealthy)" in svc_status:
+            return "unhealthy"
+        return "running"
+    if svc_state == "exited":
+        return "exited" if svc_status.startswith("Exited (0)") else "failed"
+    if svc_state in ("created", "restarting", "paused", "removing"):
+        return "starting"
+    return "stopped"
+
+
+# ─────────────────── Dirty-source detection (content hash) ───────────────────
+
+# ─────────────────── Uptime / resource helpers ───────────────────
+
+def _format_uptime(secs: int) -> str:
+    """Compact duration: `12s`, `5m 23s`, `2h 14m`, `3d 4h`."""
+    if secs < 0:
+        return "—"
+    if secs < 60:
+        return f"{secs}s"
+    if secs < 3600:
+        return f"{secs // 60}m {secs % 60}s"
+    if secs < 86400:
+        return f"{secs // 3600}h {(secs % 3600) // 60}m"
+    return f"{secs // 86400}d {(secs % 86400) // 3600}h"
+
+
+def _format_bytes(n: int) -> str:
+    """Bytes → short human string (`85M`, `1.2G`, `467K`)."""
+    if n < 1024:
+        return f"{n}B"
+    if n < 1024 ** 2:
+        return f"{n // 1024}K"
+    if n < 1024 ** 3:
+        return f"{n // (1024 ** 2)}M"
+    return f"{n / (1024 ** 3):.1f}G"
+
+
+def _parse_etime(et: str) -> int:
+    """`ps -o etime` format `[[DD-]hh:]mm:ss` → seconds."""
+    et = et.strip()
+    if not et:
+        return -1
+    days = 0
+    if "-" in et:
+        d, et = et.split("-", 1)
+        days = int(d or 0)
+    parts = et.split(":")
+    try:
+        if len(parts) == 3:
+            h, m, s = (int(p or 0) for p in parts)
+        elif len(parts) == 2:
+            h = 0
+            m, s = (int(p or 0) for p in parts)
+        else:
+            h = m = 0
+            s = int(parts[0] or 0)
+    except ValueError:
+        return -1
+    return days * 86400 + h * 3600 + m * 60 + s
+
+
+def _docker_container_for(svc_name: str) -> str:
+    """Container names: most are `texera-<svc>`; `litellm` is unprefixed."""
+    if svc_name == "litellm":
+        return "litellm"
+    return f"texera-{svc_name}"
+
+
+_DOCKER_STATS_CACHE: dict[str, tuple[str, str]] = {}
+_DOCKER_STATS_TS: float = 0.0
+_DOCKER_STATS_TTL = 5.0  # seconds — docker stats --no-stream costs ~2s, don't run it more than this
+
+
+def _refresh_docker_stats() -> None:
+    """Single `docker stats --no-stream` pass; refreshes the cached
+    container → (cpu%, mem) map. Called from a background worker so the
+    main poll tick stays cheap."""
+    global _DOCKER_STATS_CACHE, _DOCKER_STATS_TS
+    try:
+        out = subprocess.run(
+            ["docker", "stats", "--no-stream",
+             "--format", "{{.Name}}|{{.CPUPerc}}|{{.MemUsage}}"],
+            capture_output=True, text=True, timeout=8,
+        ).stdout
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return
+    fresh: dict[str, tuple[str, str]] = {}
+    for line in out.splitlines():
+        parts = line.split("|")
+        if len(parts) != 3:
+            continue
+        name, cpu, memu = parts
+        # MemUsage is "85.2MiB / 1.95GiB" — strip the "/ total" half.
+        used = memu.split(" /")[0].strip()
+        # Normalise to our own _format_bytes shape: parse the IEC unit suffix.
+        m = re.match(r"^([0-9.]+)\s*([KMGTPE]?i?B)?$", used)
+        if m:
+            val = float(m.group(1))
+            unit = (m.group(2) or "B").lower()
+            mult = {
+                "b":    1,
+                "kb":   1024,    "kib": 1024,
+                "mb":   1024**2, "mib": 1024**2,
+                "gb":   1024**3, "gib": 1024**3,
+                "tb":   1024**4, "tib": 1024**4,
+            }.get(unit, 1)
+            mem_str = _format_bytes(int(val * mult))
+        else:
+            mem_str = used or "—"
+        fresh[name] = (cpu, mem_str)
+    _DOCKER_STATS_CACHE = fresh
+    _DOCKER_STATS_TS = time.time()
+
+
+def proc_uptime_cpu_mem(pid: str) -> tuple[str, str, str]:
+    """For a native PID return (uptime, cpu%, mem) — `—` if not running."""
+    try:
+        out = subprocess.run(
+            ["ps", "-p", pid, "-o", "etime=,pcpu=,rss="],
+            capture_output=True, text=True, timeout=2,
+        ).stdout.strip()
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return ("—", "—", "—")
+    if not out:
+        return ("—", "—", "—")
+    parts = out.split()
+    if len(parts) < 3:
+        return ("—", "—", "—")
+    etime, cpu, rss_kb = parts[0], parts[1], parts[2]
+    secs = _parse_etime(etime)
+    try:
+        mem = _format_bytes(int(rss_kb) * 1024)
+    except ValueError:
+        mem = "—"
+    return (_format_uptime(secs), f"{cpu}%", mem)
+
+
+def container_uptime(svc_name: str) -> str:
+    """ISO StartedAt → human duration. Empty if not started."""
+    container = _docker_container_for(svc_name)
+    try:
+        out = subprocess.run(
+            ["docker", "inspect", "-f", "{{.State.StartedAt}}", container],
+            capture_output=True, text=True, timeout=2,
+        ).stdout.strip()
+    except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
+        return "—"
+    if not out or out.startswith("0001-01-01"):
+        return "—"
+    try:
+        # ISO 8601 with fractional + Z. Trim to the second.
+        trimmed = out.split(".", 1)[0].rstrip("Z")
+        started = datetime.strptime(trimmed, "%Y-%m-%dT%H:%M:%S").replace(tzinfo=timezone.utc)
+    except ValueError:
+        return "—"
+    elapsed = (datetime.now(timezone.utc) - started).total_seconds()
+    return _format_uptime(max(0, int(elapsed)))
+
+
+def _jvm_src_dirs(svc: Service) -> list[Path]:
+    # Derive the source-dir set from the SBT dependency graph in build.sbt.
+    # Services that share another's sbt project (e.g. computing-unit-master
+    # rides amber's dist) enter the graph at the *producing* project via
+    # SHARED_SBT_PROJECT.
+    SHARED_SBT_PROJECT = {
+        "computing-unit-master": "WorkflowExecutionService",
+    }
+    project = svc.sbt_project or SHARED_SBT_PROJECT.get(svc.name)
+    if not project:
+        raise RuntimeError(
+            f"service {svc.name!r} has no sbt_project and no SHARED_SBT_PROJECT "
+            f"mapping — can't compute its source-dir closure"
+        )
+    src_dirs = _transitive_src_dirs_cached(project)
+    return [REPO_ROOT / d for d in src_dirs if (REPO_ROOT / d).exists()]
+
+
+def _jvm_source_files(svc: Service) -> list[Path]:
+    files: list[Path] = []
+    for d in _jvm_src_dirs(svc):
+        for f in d.rglob("*"):
+            if f.is_file() and f.suffix in SOURCE_SUFFIXES:
+                files.append(f)
+    files.sort()
+    return files
+
+
+def source_hash(svc: Service) -> str:
+    h = hashlib.sha1()
+    for f in _jvm_source_files(svc):
+        try:
+            h.update(f.read_bytes())
+        except OSError:
+            pass
+    return h.hexdigest()
+
+
+def _newest_mtime_after(files: list[Path], stamp_mtime: float) -> bool:
+    for f in files:
+        try:
+            if f.stat().st_mtime > stamp_mtime:
+                return True
+        except OSError:
+            continue
+    return False
+
+
+def is_dirty(svc: Service) -> bool:
+    """Did the service's relevant source change since the last build?
+
+    JVM: SHA-1 of all .scala/.java/.proto bytes vs. the hash we wrote at the
+    last build, with an mtime fast filter so 99% of ticks are O(stat).
+    yarn/bun: lock vs. node_modules dir mtime — cheap.
+    docker: always clean.
+    """
+    if svc.type == "docker":
+        return False
+    if svc.type == "jvm":
+        return _jvm_is_dirty(svc)
+    if svc.type == "yarn":
+        nm = REPO_ROOT / "frontend" / "node_modules" / ".yarn-state.yml"
+        lock = REPO_ROOT / "frontend" / "yarn.lock"
+        if not nm.exists():
+            return True
+        return lock.stat().st_mtime > nm.stat().st_mtime

Review Comment:
   Fixed in 6088c54a2 — added `lock.exists()` guard on both yarn and bun branches.



##########
bin/local-dev-tui.py:
##########
@@ -0,0 +1,1627 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""bin/local-dev-tui.py — Textual dashboard for the Texera local dev stack.
+
+Lives next to bin/local-dev.sh; the shell script remains the canonical engine
+(build, start, stop, status) and this TUI shells out to it for every action.
+The dashboard itself owns state polling, dirty-source detection, and the
+prompt loop.  Textual handles diff rendering so the screen doesn't accrete in
+scrollback the way the old zsh `\\e[H` redraw did.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import contextlib
+import hashlib
+import os
+import re
+import shlex
+import shutil
+import subprocess
+import time
+from dataclasses import dataclass, field
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Optional
+
+from rich.text import Text
+from textual import events, work
+from textual.app import App, ComposeResult
+from textual.binding import Binding
+from textual.containers import Vertical
+from textual.reactive import reactive
+from textual.widgets import DataTable, Input, RichLog, Static
+
+# ─────────────────── Constants ───────────────────
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+STATE_DIR = Path(os.environ.get("TEXERA_LOCAL_DEV_DIR", "/tmp/texera-local-dev"))
+LOG_DIR = STATE_DIR / "logs"
+BUILD_STAMP_DIR = STATE_DIR / "build-stamps"
+# Per-service phase markers written by the shell during stop/build/start.
+# Each file holds `<phase>\t<epoch>` — we read it back in _tick_state and
+# render an animated transitional STATE if it's recent (<90s).
+PHASE_DIR = STATE_DIR / "svc-phase"
+PHASE_STALE_S = 90.0
+REPL_LOG = LOG_DIR / "repl.log"
+LOG_DIR.mkdir(parents=True, exist_ok=True)
+BUILD_STAMP_DIR.mkdir(parents=True, exist_ok=True)
+
+LOCAL_DEV_SH = REPO_ROOT / "bin" / "local-dev.sh"
+DOCKER_PROJECT = "texera-local-dev"
+
+HISTORY_FILE = STATE_DIR / "tui-history"
+MAX_HISTORY = 500
+
+SOURCE_SUFFIXES = {".scala", ".java", ".proto"}
+
+# Single source of truth for per-JVM-service source dirs is the SBT build
+# graph in build.sbt. We parse it instead of hardcoding `common/*` so that
+# adding a `lazy val NewCommon = (project in file("common/new"))` and a
+# corresponding `.dependsOn(NewCommon)` automatically flows through to
+# dirty-detection without anyone touching this file.
+
+
+def _parse_sbt_deps() -> dict[str, dict]:
+    """Walk `build.sbt` and return a dependency graph keyed by sbt project
+    name. Each entry is `{"path": <repo-relative dir>, "deps": [..main-scope
+    deps..]}`. Test-only `% "test->test"` deps are filtered out — they
+    can't affect a service's runtime artifact, so they don't drive dirty.
+    """
+    bs = REPO_ROOT / "build.sbt"
+    try:
+        text = bs.read_text(encoding="utf-8", errors="replace")
+    except OSError:
+        return {}
+
+    proj_re = re.compile(
+        r'^lazy\s+val\s+([A-Z][A-Za-z0-9]*)\s*=\s*\(project\s+in\s+file\("([^"]+)"\)\)',
+        re.MULTILINE,
+    )
+    matches = list(proj_re.finditer(text))
+    if not matches:
+        return {}
+
+    graph: dict[str, dict] = {}
+    for i, m in enumerate(matches):
+        name = m.group(1)
+        path = m.group(2)
+        # The "block" for this project spans from this match to the next
+        # `lazy val ... = (project in file(...))` (or end of file). All the
+        # chained `.dependsOn(...)` calls live in there.
+        end = matches[i + 1].start() if i + 1 < len(matches) else len(text)
+        block = text[m.start():end]
+
+        deps: list[str] = []
+        for arg_list in re.findall(r"\.dependsOn\(([^)]*)\)", block):
+            for arg in arg_list.split(","):
+                arg = arg.strip()
+                # Skip test-scope (`X % "test->test"`) — runtime build
+                # doesn't ship those classes.
+                if "%" in arg:
+                    continue
+                # Strip any trailing whitespace / comments. Project refs
+                # are bare identifiers.
+                ref = arg.split()[0] if arg else ""
+                if ref and ref[0].isupper():
+                    deps.append(ref)
+        graph[name] = {"path": path, "deps": deps}
+    return graph
+

Review Comment:
   Fixed in 6088c54a2 — narrowed to match only `% "test->test" / % "test" / % Test` in both the Python parser and the shell one.



##########
bin/local-dev.sh:
##########
@@ -0,0 +1,2533 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# bin/local-dev.sh -- Manage the Texera local dev stack from a single script.
+#
+# Subcommands:
+#   bin/local-dev.sh                          DEFAULT — one-shot text
+#                                             dashboard (same as `status`).
+#                                             Non-interactive, prints once and
+#                                             exits — safe in scripts/CI.
+#   bin/local-dev.sh -i  | --interactive      Launch the Textual TUI dashboard
+#                                             (live states, SRC dirty
+#                                             indicator, command prompt,
+#                                             double-click for logs, ↑/↓
+#                                             history, Ctrl-C twice to quit).
+#                                             Requires Python + textual.
+#   bin/local-dev.sh status                   same as no-arg invocation.
+#   bin/local-dev.sh up   [--fresh|--build|--no-build] [--skip=svc1,svc2]
+#                                             Default: skip build if no source/lock
+#                                             changes since last build. --build forces
+#                                             incremental sbt dist + yarn/bun install.
+#                                             --fresh runs `sbt clean dist`. --no-build
+#                                             skips the build step entirely.
+#   bin/local-dev.sh down [--skip=svc1,svc2]  stop every non-skipped service.
+#   bin/local-dev.sh start <service>          start one service (no rebuild).
+#   bin/local-dev.sh stop  <service>          stop one service.
+#   bin/local-dev.sh <service>                rebuild only that service incrementally
+#                                             (sbt <Project>/dist), then bounce it.
+#                                             frontend / agent-service are refused
+#                                             (they have their own watch mode).
+#   bin/local-dev.sh logs <service>           tail this service's log.
+#   bin/local-dev.sh w | watch [interval]     Hands-off monitor: redraw the
+#                                             dashboard every <interval>s
+#                                             (default 2). No prompt; Ctrl-C
+#                                             to exit.
+#
+# Managed services (start order):
+#   config-service                 :9094  JVM (sbt ConfigService)
+#   access-control-service         :9096  JVM (sbt AccessControlService)
+#   file-service                   :9092  JVM (sbt FileService)
+#   workflow-compiling-service     :9090  JVM (sbt WorkflowCompilingService)
+#   computing-unit-managing-service :8082 JVM (sbt ComputingUnitManagingService)
+#   texera-web                     :8080  JVM (sbt WorkflowExecutionService, amber)
+#   computing-unit-master          :8085  JVM (rides amber dist; no own sbt project)
+#   agent-service                  :3001  Bun --watch (cd agent-service && bun run dev)
+#   frontend                       :4200  ng serve via cd frontend && yarn start
+#
+# Docker infra (postgres / minio / lakefs / lakekeeper / litellm) is NOT managed
+# here -- bring those up yourself before `up`. The script will warn if expected
+# ports are unreachable.
+#
+# Logs and pid book-keeping live under: ${TEXERA_LOCAL_DEV_DIR:-/tmp/texera-local-dev}
+
+set -euo pipefail
+# Unmatched globs in bash default to the literal pattern (we handle that
+# in-place at every glob site). `failglob` / `nullglob` are opt-in per glob
+# via `( shopt -s nullglob; ... )` subshells where we need empty-on-no-match.
+
+REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+cd "$REPO_ROOT"
+
+STATE_DIR="${TEXERA_LOCAL_DEV_DIR:-/tmp/texera-local-dev}"
+LOG_DIR="$STATE_DIR/logs"
+BUILD_STAMP_DIR="$STATE_DIR/build-stamps"
+# Per-service phase markers: shell writes `<phase>\t<epoch>` here as it
+# walks each service through stop → build → start; the TUI reads them
+# every tick and renders an animated transitional state in the STATE
+# column. Removed once the service is up / on stale-after-90s.
+PHASE_DIR="$STATE_DIR/svc-phase"
+mkdir -p "$LOG_DIR" "$BUILD_STAMP_DIR" "$PHASE_DIR"
+
+# --------- associative-array shim for bash 3.2 ---------
+# Apple ships bash 3.2 at /bin/bash and we ship licensing as bash 3.2 too,
+# so we can't use `declare -A`. Every old `MAP[$key]=val` / `${MAP[$key]}`
+# is reshaped as a function call against a flat namespace of synthetic
+# variables `_amap__<MAP>__<key>`. Keys containing `-` get mangled to `_`
+# so they're valid identifier chars.
+amap_set() {
+    local _map="$1" _key="${2//-/_}" _val="$3"
+    eval "_amap__${_map}__${_key}=\$_val"
+}
+amap_get() {
+    local _map="$1" _key="${2//-/_}"
+    local _var="_amap__${_map}__${_key}"
+    eval "printf '%s' \"\${$_var:-}\""
+}
+amap_has() {
+    local _map="$1" _key="${2//-/_}"
+    local _var="_amap__${_map}__${_key}"
+    eval "[[ \${$_var+x} ]]"
+}
+amap_append() {
+    # amap_append MAP key suffix — append to existing value (or seed it).
+    local _map="$1" _key="${2//-/_}" _suffix="$3"
+    local _var="_amap__${_map}__${_key}"
+    eval "$_var=\"\${$_var:-}\$_suffix\""
+}
+
+# --------- toolchain (JDK 17 + node) ---------
+# Detect a JDK 17 installation rather than pinning one path. We try, in
+# order: (1) caller-set $JAVA_HOME if it really is 17, (2) macOS's official
+# locator `/usr/libexec/java_home -v 17`, (3) Homebrew on Apple Silicon +
+# Intel, (4) common Linux distro paths (openjdk / temurin / corretto / zulu),
+# (5) SDKMAN, (6) asdf, (7) the `java` on PATH if its `-version` says 17.
+# Fall through to a clear install hint if none match.
+_java_is_17() {
+    local home="$1"
+    [[ -x "$home/bin/java" ]] || return 1
+    "$home/bin/java" -version 2>&1 | head -1 | grep -q '"17[.]' || return 1
+    return 0
+}
+
+_find_jdk17() {
+    local cand=""
+    # 1. Respect $JAVA_HOME if the caller already set it AND it's 17.
+    if [[ -n "${JAVA_HOME:-}" ]] && _java_is_17 "$JAVA_HOME"; then
+        printf '%s\n' "$JAVA_HOME"; return 0
+    fi
+    # 2. macOS native locator (works for any vendor installed via /Library).
+    if command -v /usr/libexec/java_home >/dev/null 2>&1; then
+        cand=$(/usr/libexec/java_home -v 17 2>/dev/null) || cand=""
+        if [[ -n "$cand" ]] && _java_is_17 "$cand"; then
+            printf '%s\n' "$cand"; return 0
+        fi
+    fi
+    # 3. Homebrew — try `brew --prefix openjdk@17` first, then both well-
+    #    known prefixes as a fallback (script may run without brew on PATH
+    #    if /etc/zprofile didn't fire).
+    if command -v brew >/dev/null 2>&1; then
+        cand=$(brew --prefix openjdk@17 2>/dev/null) || cand=""
+        [[ -n "$cand" ]] && _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    fi
+    for cand in /opt/homebrew/opt/openjdk@17 /usr/local/opt/openjdk@17; do
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    done
+    # 4. Linux distro layouts. Glob first match.
+    # bash equivalents of zsh's `*(N)` "null on no match" qualifier: enable
+    # `shopt -s nullglob` locally so an unmatched pattern expands to zero
+    # words. We localize it in a subshell so it doesn't leak out and break
+    # the unquoted globs elsewhere (e.g. unzip's zip glob).
+    local matched=""
+    matched=$(shopt -s nullglob; \
+        for cand in \
+            /usr/lib/jvm/java-17-openjdk* \
+            /usr/lib/jvm/temurin-17-jdk* \
+            /usr/lib/jvm/java-17-amazon-corretto* \
+            /usr/lib/jvm/zulu-17* \
+            /usr/lib/jvm/jdk-17*; do
+            printf '%s\n' "$cand"
+        done)
+    while IFS= read -r cand; do
+        [[ -z "$cand" ]] && continue
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    done <<< "$matched"
+    # 5. SDKMAN (`sdk install java 17.x-...`) — pick the lex-largest 17.* dir.
+    if [[ -d "$HOME/.sdkman/candidates/java" ]]; then
+        matched=$(shopt -s nullglob; \
+            for cand in "$HOME"/.sdkman/candidates/java/17.*; do
+                printf '%s\n' "$cand"
+            done)
+        while IFS= read -r cand; do
+            [[ -z "$cand" ]] && continue
+            _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+        done <<< "$matched"
+    fi
+    # 6. asdf.
+    if [[ -d "$HOME/.asdf/installs/java" ]]; then
+        matched=$(shopt -s nullglob; \
+            for cand in "$HOME"/.asdf/installs/java/*17*; do
+                printf '%s\n' "$cand"
+            done)
+        while IFS= read -r cand; do
+            [[ -z "$cand" ]] && continue
+            _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+        done <<< "$matched"
+    fi
+    # 7. Whatever `java` is on PATH, IF it's 17 — covers cases like Docker
+    #    images or distro-managed defaults.
+    cand=$(command -v java 2>/dev/null) || cand=""
+    if [[ -n "$cand" ]]; then
+        cand="$(dirname "$(dirname "$cand")")"
+        _java_is_17 "$cand" && { printf '%s\n' "$cand"; return 0; }
+    fi
+    return 1
+}
+
+# Print the current java environment alongside detection results so the
+# user can see *why* JDK 17 lookup failed (wrong version pinned, JAVA_HOME
+# pointing at JDK 21, etc) — not just "couldn't find one".
+_diagnose_jdk17() {
+    echo "" >&2
+    echo "  current java environment:" >&2
+    if [[ -n "${JAVA_HOME:-}" ]]; then
+        local jhver=""
+        jhver=$("$JAVA_HOME/bin/java" -version 2>&1 | head -1 || echo "(unreadable)")
+        echo "    \$JAVA_HOME = $JAVA_HOME" >&2
+        echo "                ↳ $jhver" >&2
+    else
+        echo "    \$JAVA_HOME (unset)" >&2
+    fi
+    local path_java=""
+    path_java=$(command -v java 2>/dev/null) || true
+    if [[ -n "$path_java" ]]; then
+        local pver=""
+        pver=$("$path_java" -version 2>&1 | head -1 || echo "(unreadable)")
+        echo "    \`java\` on PATH → $path_java" >&2
+        echo "                ↳ $pver" >&2
+    else
+        echo "    \`java\` on PATH (not found)" >&2
+    fi
+    if command -v /usr/libexec/java_home >/dev/null 2>&1; then
+        local jh17=""
+        jh17=$(/usr/libexec/java_home -v 17 2>/dev/null) || jh17="(none registered)"
+        echo "    /usr/libexec/java_home -v 17 → $jh17" >&2
+    fi
+    if command -v brew >/dev/null 2>&1; then
+        local brewp=""
+        brewp=$(brew --prefix openjdk@17 2>/dev/null) || brewp="(not installed)"
+        echo "    brew --prefix openjdk@17 → $brewp" >&2
+    fi
+    echo "" >&2
+    echo "  likely cause:" >&2
+    if [[ -n "${JAVA_HOME:-}" ]] && [[ -n "$path_java" ]]; then
+        echo "    JAVA_HOME points at the wrong JDK (probably not 17)." >&2
+        echo "    Either fix JAVA_HOME or unset it to let auto-detect try other paths." >&2
+    elif [[ -n "$path_java" ]]; then
+        echo "    \`java\` on PATH is not JDK 17. Install a 17 sibling or set JAVA_HOME=/path/to/jdk-17." >&2
+    else
+        echo "    No JDK is installed anywhere we know to look." >&2
+    fi
+    echo "" >&2
+}
+
+JAVA_HOME_DETECTED="$(_find_jdk17)" || {
+    echo "FATAL: could not find a JDK 17 install." >&2
+    _diagnose_jdk17
+    echo "  fix:" >&2
+    echo "    macOS:   brew install openjdk@17" >&2
+    echo "    Linux:   apt install openjdk-17-jdk    # or yum/dnf equivalent" >&2
+    echo "    SDKMAN:  sdk install java 17.0.13-tem" >&2
+    echo "    or set JAVA_HOME=/path/to/jdk-17 explicitly" >&2
+    echo "" >&2
+    exit 1
+}
+export JAVA_HOME="$JAVA_HOME_DETECTED"
+export PATH="$JAVA_HOME/bin:$PATH"
+
+# Node: source the user's version manager (if any) so the right `node` is on
+# PATH for yarn/bun/ng. Try nvm, fnm, volta in that order; `command -v node`
+# remains the ultimate fallback.
+if [[ -z "${NVM_DIR:-}" && -d "$HOME/.nvm" ]]; then
+    export NVM_DIR="$HOME/.nvm"
+fi
+if [[ -n "${NVM_DIR:-}" && -s "$NVM_DIR/nvm.sh" ]]; then
+    # shellcheck disable=SC1091
+    \. "$NVM_DIR/nvm.sh" >/dev/null 2>&1 || true
+elif command -v fnm >/dev/null 2>&1; then
+    eval "$(fnm env --use-on-cd 2>/dev/null)" || true
+elif [[ -s "$HOME/.volta/load.sh" ]]; then
+    # shellcheck disable=SC1091
+    \. "$HOME/.volta/load.sh" >/dev/null 2>&1 || true
+fi
+
+# --------- runtime env for backend ---------
+# Detect the host's primary LAN IP so we can use it as the MinIO endpoint.
+# It has to be the same string from both directions:
+#   • host-native JVMs need it to reach localhost-published port 9000
+#   • the lakekeeper container needs it to do server-side S3 ops (validation,
+#     compaction) AND to return URLs to clients that *they* can reach
+# `localhost` only works for the host. `texera-minio` only works inside the
+# docker network. The host's LAN IP works from BOTH (host loopback for the
+# host, docker NAT'd out-and-back for the container).
+_detect_host_lan_ip() {
+    local iface="" ip=""
+    # 1. The interface backing the default route — most reliable on a
+    #    laptop that may have wifi + thunderbolt + tailscale all active.
+    iface=$(route get default 2>/dev/null | awk '/interface:/{print $2; exit}')
+    if [[ -n "$iface" ]]; then
+        ip=$(ipconfig getifaddr "$iface" 2>/dev/null)
+        [[ -n "$ip" && "$ip" != 127.* ]] && { printf '%s\n' "$ip"; return 0; }
+    fi
+    # 2. Fallback: linux `hostname -I`-equivalent walk over en*.
+    for iface in en0 en1 en2 en3 en4 en5 en6 en7 en8 en9 en10; do
+        ip=$(ipconfig getifaddr "$iface" 2>/dev/null)
+        [[ -n "$ip" && "$ip" != 127.* ]] && { printf '%s\n' "$ip"; return 0; }
+    done
+    return 1
+}
+# Lazy resolver — called from subcommands that actually need to publish a
+# host-reachable S3 endpoint (cmd_up, cmd_auto). Subcommands like
+# `version`, `status`, `--help`, or `-i` don't talk to MinIO and shouldn't
+# refuse to run just because the laptop is offline.
+_require_host_lan_ip() {
+    [[ -n "${HOST_LAN_IP:-}" ]] && return 0
+    HOST_LAN_IP="$(_detect_host_lan_ip)" || HOST_LAN_IP=""
+    if [[ -z "$HOST_LAN_IP" ]]; then
+        echo "FATAL: could not detect a host LAN IP." >&2
+        echo "       MinIO needs an address reachable from both docker (lakekeeper" >&2
+        echo "       does S3 ops) and the host (JVMs read signed URLs back); none" >&2
+        echo "       of \`route get default\` / en0-en10 had a non-loopback IPv4." >&2
+        echo "       Connect to a network or export HOST_LAN_IP=<your-IP> explicitly." >&2
+        exit 1
+    fi
+    export HOST_LAN_IP
+    # STORAGE_S3_ENDPOINT below uses the parameter-default form so it
+    # picks up HOST_LAN_IP once we set it here.
+    export STORAGE_S3_ENDPOINT="${STORAGE_S3_ENDPOINT:-http://$HOST_LAN_IP:9000}"
+}
+
+export STORAGE_JDBC_URL="${STORAGE_JDBC_URL:-jdbc:postgresql://localhost:5432/texera_db?currentSchema=texera_db,public}"
+export STORAGE_JDBC_USERNAME="${STORAGE_JDBC_USERNAME:-texera}"
+export STORAGE_JDBC_PASSWORD="${STORAGE_JDBC_PASSWORD:-password}"
+# STORAGE_S3_ENDPOINT is set lazily by _require_host_lan_ip — only the
+# subcommands that actually touch MinIO (infra_up + cmd_up + cmd_auto)
+# trigger that detection, so `version` / `status` / `-i` work offline.
+export STORAGE_S3_AUTH_USERNAME="${STORAGE_S3_AUTH_USERNAME:-texera_minio}"
+export STORAGE_S3_AUTH_PASSWORD="${STORAGE_S3_AUTH_PASSWORD:-password}"
+export STORAGE_S3_REGION="${STORAGE_S3_REGION:-us-west-2}"
+export STORAGE_ICEBERG_CATALOG_TYPE="${STORAGE_ICEBERG_CATALOG_TYPE:-rest}"
+export STORAGE_ICEBERG_CATALOG_REST_URI="${STORAGE_ICEBERG_CATALOG_REST_URI:-http://localhost:8181/catalog}"
+export STORAGE_ICEBERG_CATALOG_REST_WAREHOUSE_NAME="${STORAGE_ICEBERG_CATALOG_REST_WAREHOUSE_NAME:-texera}"
+export STORAGE_ICEBERG_CATALOG_REST_S3_BUCKET="${STORAGE_ICEBERG_CATALOG_REST_S3_BUCKET:-texera-iceberg}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_USERNAME="${STORAGE_ICEBERG_CATALOG_POSTGRES_USERNAME:-texera}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_PASSWORD="${STORAGE_ICEBERG_CATALOG_POSTGRES_PASSWORD:-password}"
+export STORAGE_ICEBERG_CATALOG_POSTGRES_URI_WITHOUT_SCHEME="${STORAGE_ICEBERG_CATALOG_POSTGRES_URI_WITHOUT_SCHEME:-localhost:5432/texera_iceberg_catalog}"
+export STORAGE_LAKEFS_ENDPOINT="${STORAGE_LAKEFS_ENDPOINT:-http://localhost:8000/api/v1}"
+export STORAGE_LAKEFS_AUTH_USERNAME="${STORAGE_LAKEFS_AUTH_USERNAME:-AKIAIOSFOLKFSSAMPLES}"
+export STORAGE_LAKEFS_AUTH_PASSWORD="${STORAGE_LAKEFS_AUTH_PASSWORD:-wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY}"
+export STORAGE_LAKEFS_AUTH_API_SECRET="${STORAGE_LAKEFS_AUTH_API_SECRET:-random_string_for_lakefs}"
+export UDF_PYTHON_PATH="${UDF_PYTHON_PATH:-$(command -v python3 2>/dev/null || command -v python 2>/dev/null)}"
+export TEXERA_DASHBOARD_SERVICE_ENDPOINT="${TEXERA_DASHBOARD_SERVICE_ENDPOINT:-http://localhost:8080}"
+export WORKFLOW_COMPILING_SERVICE_ENDPOINT="${WORKFLOW_COMPILING_SERVICE_ENDPOINT:-http://localhost:9090}"
+export WORKFLOW_EXECUTION_SERVICE_ENDPOINT="${WORKFLOW_EXECUTION_SERVICE_ENDPOINT:-http://localhost:8085}"
+export FILE_SERVICE_GET_PRESIGNED_URL_ENDPOINT="${FILE_SERVICE_GET_PRESIGNED_URL_ENDPOINT:-http://localhost:9092/api/dataset/presign-download}"
+export FILE_SERVICE_UPLOAD_ONE_FILE_TO_DATASET_ENDPOINT="${FILE_SERVICE_UPLOAD_ONE_FILE_TO_DATASET_ENDPOINT:-http://localhost:9092/api/dataset/did/upload}"
+export LITELLM_BASE_URL="${LITELLM_BASE_URL:-http://localhost:4000}"
+export LITELLM_MASTER_KEY="${LITELLM_MASTER_KEY:-sk-texera-internal-do-not-share}"
+export LLM_ENDPOINT="${LLM_ENDPOINT:-http://localhost:8080}"
+export LLM_API_KEY="${LLM_API_KEY:-dummy}"
+
+# --------- texera version (dynamic) ---------
+# The sbt-native-packager dist directory and jar names embed the project
+# version (e.g. target/config-service-<VERSION>/...). That version moves
+# across branches (1.3.0-incubating-SNAPSHOT on main, 1.2.0-incubating on
+# release/v1.2, …) so resolve it from build.sbt at startup rather than
+# hardcoding. Override via the TEXERA_VERSION env var to target a sibling
+# tree or if the build.sbt parse fails.
+_texera_version() {
+    grep -E '^[[:space:]]*ThisBuild[[:space:]]*/[[:space:]]*version[[:space:]]*:=[[:space:]]*"' \
+        "$REPO_ROOT/build.sbt" 2>/dev/null \
+        | head -1 \
+        | sed -E 's/.*"([^"]+)".*/\1/'
+}
+TEXERA_VERSION="${TEXERA_VERSION:-$(_texera_version)}"
+if [[ -z "$TEXERA_VERSION" ]]; then
+    # tui_warn isn't defined yet at this point in the script; print raw.
+    printf "FATAL: could not detect texera version from %s/build.sbt\n" "$REPO_ROOT" >&2
+    printf "       Set the TEXERA_VERSION env var to bypass.\n" >&2
+    exit 1
+fi
+
+# --------- sbt dependency graph (parsed from build.sbt) ---------
+# We parse the build.sbt's project + .dependsOn() declarations so that the
+# per-service "did anything that affects me change?" check can prune to
+# the actual transitive closure. Without this, every JVM service watches
+# every common/* dir and `cmd_auto` rebuilds half the stack whenever
+# common/workflow-operator changes, even though config-service has zero
+# dependency on it.
+#
+# Populates two amap maps keyed by sbt project name plus a parallel
+# indexed-array of keys so we can iterate without `${!MAP[@]}`:
+#   amap_get SBT_PATH ConfigService → "config-service"
+#   amap_get SBT_DEPS ConfigService → "Auth Config"   (space-separated)
+#   SBT_DEPS_KEYS=(ConfigService AccessControlService …)
+SBT_DEPS_KEYS=()
+
+_parse_sbt() {
+    local file="$REPO_ROOT/build.sbt"
+    [[ -f "$file" ]] || return 1
+    local current="" line=""
+    local decl_re='^lazy[[:space:]]+val[[:space:]]+([A-Z][A-Za-z0-9]*)[[:space:]]*=[[:space:]]*\(project[[:space:]]+in[[:space:]]+file\("([^"]+)"\)\)'
+    local deps_re='\.dependsOn\(([^)]*)\)'
+
+    # Helper: split a comma-list of dependsOn args, dropping test-scope
+    # and non-project tokens, then append unique main-scope refs.
+    _absorb() {
+        local args="$1"
+        local IFS_OLD="$IFS"
+        IFS=','
+        # shellcheck disable=SC2206
+        local parts=($args)
+        IFS="$IFS_OLD"
+        local arg="" existing=""
+        for arg in "${parts[@]}"; do
+            arg="${arg// /}"
+            arg="${arg//$'\t'/}"
+            [[ "$arg" == *"%"* ]] && continue
+            [[ "$arg" =~ ^[A-Z] ]] || continue
+            existing=$(amap_get SBT_DEPS "$current")
+            case " $existing " in
+                *" $arg "*) ;;
+                *) amap_append SBT_DEPS "$current" " $arg" ;;
+            esac
+        done
+    }
+
+    while IFS= read -r line; do
+        local rest="$line"
+        if [[ "$line" =~ $decl_re ]]; then
+            current="${BASH_REMATCH[1]}"
+            amap_set SBT_PATH "$current" "${BASH_REMATCH[2]}"
+            amap_set SBT_DEPS "$current" ""
+            SBT_DEPS_KEYS+=("$current")
+            # Don't `continue` — `.dependsOn(...)` can chain on the SAME
+            # line as the declaration (WorkflowOperator's one-liner does
+            # this). Fall through so the loop below catches it.
+        elif [[ "$line" =~ ^lazy[[:space:]]+val ]]; then
+            # Other `lazy val` (settings, etc) breaks attribution.
+            current=""
+            continue
+        fi
+        [[ -z "$current" ]] && continue
+        # Scan ALL `.dependsOn(...)` matches on this line — some lines
+        # chain `.dependsOn(A).dependsOn(B % "test->test")` and we must
+        # see both to filter correctly.
+        while [[ "$rest" =~ $deps_re ]]; do
+            _absorb "${BASH_REMATCH[1]}"
+            rest="${rest#*"${BASH_REMATCH[0]}"}"
+        done
+    done < "$file"
+    # Trim leading space on every entry.
+    local p="" cur=""
+    for p in "${SBT_DEPS_KEYS[@]}"; do
+        cur=$(amap_get SBT_DEPS "$p")
+        amap_set SBT_DEPS "$p" "${cur# }"
+    done
+    return 0
+}
+_parse_sbt || true
+
+# BFS from $1 over SBT_DEPS, emit one `<path>/src` per visited project.
+# Caller can also pass an explicit fallback list for the unparseable case.
+_sbt_transitive_src_dirs() {
+    local root="$1"
+    [[ -z "$root" ]] && return 1
+    amap_has SBT_PATH "$root" || return 1
+    # `_visited_` namespace is a per-call amap. We can't easily clear all
+    # entries (bash 3.2 has no `${!_visited_*}` glob over set vars without
+    # `compgen`, but `compgen -v` IS available). We unset matching vars
+    # at function exit so successive calls start clean.
+    local queue=("$root")
+    local p="" path="" d="" key="" var=""
+    while ((${#queue[@]} > 0)); do
+        p="${queue[0]}"
+        queue=("${queue[@]:1}")
+        key="${p//-/_}"
+        var="_amap__visited__${key}"
+        eval "[[ \${$var+x} ]]" && continue
+        eval "$var=1"
+        path=$(amap_get SBT_PATH "$p")
+        [[ -n "$path" ]] && printf '%s/src\n' "$path"
+        local deps=""
+        deps=$(amap_get SBT_DEPS "$p")
+        for d in $deps; do
+            queue+=("$d")
+        done
+    done
+    # Clean up our visited markers so the next caller starts fresh.
+    local v=""
+    for v in $(compgen -v _amap__visited__ 2>/dev/null); do
+        unset "$v"
+    done
+    return 0
+}
+
+# --------- service catalog ---------
+SERVICES=(
+    postgres
+    minio
+    lakefs
+    lakekeeper
+    litellm
+    config-service
+    access-control-service
+    file-service
+    workflow-compiling-service
+    computing-unit-master
+    computing-unit-managing-service
+    texera-web
+    agent-service
+    frontend
+)
+
+# Service catalog. Under bash 3.2 this would normally be `typeset -A` maps;
+# we use the `amap_*` helpers defined above instead. Each amap_set call
+# stores into a synthetic var name (e.g. `_amap__SVC_TYPE__postgres`).
+
+# Each docker service is now its own row in the dashboard. start/stop still
+# batch through infra_up/infra_down because `docker compose up -d` and
+# `docker compose down` operate at the project level.
+amap_set SVC_TYPE postgres   docker; amap_set SVC_PORT postgres   5432; amap_set SVC_CWD postgres   "."
+amap_set SVC_TYPE minio      docker; amap_set SVC_PORT minio      9000; amap_set SVC_CWD minio      "."
+amap_set SVC_TYPE lakefs     docker; amap_set SVC_PORT lakefs     8000; amap_set SVC_CWD lakefs     "."
+amap_set SVC_TYPE lakekeeper docker; amap_set SVC_PORT lakekeeper 8181; amap_set SVC_CWD lakekeeper "."
+amap_set SVC_TYPE litellm    docker; amap_set SVC_PORT litellm    4000; amap_set SVC_CWD litellm    "."
+
+amap_set SVC_TYPE       config-service jvm
+amap_set SVC_PORT       config-service 9094
+amap_set SVC_SBT        config-service ConfigService
+amap_set SVC_LAUNCHER   config-service "target/config-service-${TEXERA_VERSION}/bin/config-service"
+amap_set SVC_CWD        config-service "."
+amap_set SVC_ZIP_GLOB   config-service "config-service/target/universal/config-service-*.zip"
+amap_set SVC_UNZIP_DEST config-service "target/"
+amap_set SVC_HEALTH     config-service "/api/healthcheck"
+
+amap_set SVC_TYPE       access-control-service jvm
+amap_set SVC_PORT       access-control-service 9096
+amap_set SVC_SBT        access-control-service AccessControlService
+amap_set SVC_LAUNCHER   access-control-service "target/access-control-service-${TEXERA_VERSION}/bin/access-control-service"
+amap_set SVC_CWD        access-control-service "."
+amap_set SVC_ZIP_GLOB   access-control-service "access-control-service/target/universal/access-control-service-*.zip"
+amap_set SVC_UNZIP_DEST access-control-service "target/"
+amap_set SVC_HEALTH     access-control-service "/api/healthcheck"
+
+amap_set SVC_TYPE       file-service jvm
+amap_set SVC_PORT       file-service 9092
+amap_set SVC_SBT        file-service FileService
+amap_set SVC_LAUNCHER   file-service "target/file-service-${TEXERA_VERSION}/bin/file-service"
+amap_set SVC_CWD        file-service "."
+amap_set SVC_ZIP_GLOB   file-service "file-service/target/universal/file-service-*.zip"
+amap_set SVC_UNZIP_DEST file-service "target/"
+amap_set SVC_HEALTH     file-service "/api/healthcheck"
+
+amap_set SVC_TYPE       workflow-compiling-service jvm
+amap_set SVC_PORT       workflow-compiling-service 9090
+amap_set SVC_SBT        workflow-compiling-service WorkflowCompilingService
+amap_set SVC_LAUNCHER   workflow-compiling-service "target/workflow-compiling-service-${TEXERA_VERSION}/bin/workflow-compiling-service"
+amap_set SVC_CWD        workflow-compiling-service "."
+amap_set SVC_ZIP_GLOB   workflow-compiling-service "workflow-compiling-service/target/universal/workflow-compiling-service-*.zip"
+amap_set SVC_UNZIP_DEST workflow-compiling-service "target/"
+amap_set SVC_HEALTH     workflow-compiling-service "/api/healthcheck"
+
+amap_set SVC_TYPE       computing-unit-managing-service jvm
+amap_set SVC_PORT       computing-unit-managing-service 8082
+amap_set SVC_SBT        computing-unit-managing-service ComputingUnitManagingService
+amap_set SVC_LAUNCHER   computing-unit-managing-service "target/computing-unit-managing-service-${TEXERA_VERSION}/bin/computing-unit-managing-service"
+amap_set SVC_CWD        computing-unit-managing-service "."
+amap_set SVC_ZIP_GLOB   computing-unit-managing-service "computing-unit-managing-service/target/universal/computing-unit-managing-service-*.zip"
+amap_set SVC_UNZIP_DEST computing-unit-managing-service "target/"
+amap_set SVC_HEALTH     computing-unit-managing-service ""
+
+amap_set SVC_TYPE       texera-web jvm
+amap_set SVC_PORT       texera-web 8080
+amap_set SVC_SBT        texera-web WorkflowExecutionService
+amap_set SVC_LAUNCHER   texera-web "target/amber-${TEXERA_VERSION}/bin/texera-web-application"
+amap_set SVC_CWD        texera-web "amber"
+amap_set SVC_ZIP_GLOB   texera-web "amber/target/universal/amber-*.zip"
+amap_set SVC_UNZIP_DEST texera-web "amber/target/"
+amap_set SVC_HEALTH     texera-web "/api/healthcheck"
+
+# computing-unit-master shares the amber dist with texera-web: sbt-native-
+# packager emits both `bin/texera-web-application` and `bin/computing-unit-master`
+# launchers under `amber/target/amber-<VERSION>/`. We register it as a separate
+# service for status/start/stop but leave SVC_SBT / SVC_ZIP_GLOB empty so the
+# build pipeline knows to skip it (the texera-web build path already produces
+# its launcher). Source-dir and canary-jar lookups treat it identically to
+# texera-web — see _svc_src_dirs / svc_src_changed / svc_artifact_mtime.
+amap_set SVC_TYPE       computing-unit-master jvm
+amap_set SVC_PORT       computing-unit-master 8085
+amap_set SVC_SBT        computing-unit-master ""
+amap_set SVC_LAUNCHER   computing-unit-master "target/amber-${TEXERA_VERSION}/bin/computing-unit-master"
+amap_set SVC_CWD        computing-unit-master "amber"
+amap_set SVC_ZIP_GLOB   computing-unit-master ""
+amap_set SVC_UNZIP_DEST computing-unit-master ""
+amap_set SVC_HEALTH     computing-unit-master ""
+
+amap_set SVC_TYPE   agent-service bun
+amap_set SVC_PORT   agent-service 3001
+amap_set SVC_CWD    agent-service "agent-service"
+amap_set SVC_HEALTH agent-service "/api/healthcheck"
+
+amap_set SVC_TYPE   frontend yarn
+amap_set SVC_PORT   frontend 4200
+amap_set SVC_CWD    frontend "frontend"
+amap_set SVC_HEALTH frontend ""
+
+# --------- docker infra config ---------
+DOCKER_PROJECT="texera-local-dev"
+DOCKER_COMPOSE_FILE="$REPO_ROOT/bin/single-node/docker-compose.yml"
+DOCKER_OVERLAY_FILE="$REPO_ROOT/bin/local-dev/docker-compose.override.yml"
+DOCKER_ENV_FILE="$REPO_ROOT/bin/single-node/.env"
+DOCKER_INFRA_SERVICES=(postgres minio minio-init lakefs lakekeeper-migrate lakekeeper lakekeeper-init litellm)
+DOCKER_INFRA_LONGLIVED=(postgres minio lakefs lakekeeper litellm)  # exclude one-shot init jobs
+
+# Build the array of -f flags: base single-node compose + local-dev overlay
+# (the overlay publishes infra ports to the host, which the upstream compose
+# intentionally does not do).
+docker_compose_files() {
+    local args=(-f "$DOCKER_COMPOSE_FILE")
+    [[ -f "$DOCKER_OVERLAY_FILE" ]] && args+=(-f "$DOCKER_OVERLAY_FILE")
+    printf '%s\n' "${args[@]}"
+}
+
+# --------- TUI helpers ---------
+if [[ -t 1 ]] && [[ "${TERM:-}" != "dumb" ]]; then
+    BOLD=$'\e[1m'; DIM=$'\e[2m'
+    RED=$'\e[31m'; GREEN=$'\e[32m'; YELLOW=$'\e[33m'
+    BLUE=$'\e[34m'; MAGENTA=$'\e[35m'; CYAN=$'\e[36m'
+    GRAY=$'\e[90m'; BRIGHT=$'\e[97m'
+    RESET=$'\e[0m'
+else
+    BOLD="" DIM="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" GRAY="" BRIGHT="" RESET=""
+fi
+
+TUI_WIDTH=$(tput cols 2>/dev/null || echo 80)
+[[ -z "$TUI_WIDTH" || "$TUI_WIDTH" -lt 60 ]] && TUI_WIDTH=80
+(( TUI_WIDTH > 100 )) && TUI_WIDTH=100   # cap for readability
+
+# Symbols
+SYM_RUN="●"; SYM_STOP="○"; SYM_WARN="⚠"; SYM_OK="✓"; SYM_ERR="✗"
+SYM_SECT="▸"; SYM_LIST="•"; SYM_PROG="→"
+
+tui_hline() {
+    local ch="${1:-─}" w="${2:-$TUI_WIDTH}"
+    printf "${ch}%.0s" $(seq 1 "$w")
+}
+
+tui_trunc() {
+    local s="$1" n="$2"
+    if (( ${#s} > n )); then
+        printf "%s…" "${s:0:$((n-1))}"
+    else
+        printf "%s" "$s"
+    fi
+}
+
+tui_banner() {
+    local title="$1" subtitle="${2:-}"
+    local w=$TUI_WIDTH
+    # Row layout: │ + 2 spaces + content + 2 spaces + │ = w  →  inner = w - 6
+    local inner=$((w - 6))
+    title="$(tui_trunc "$title" "$inner")"
+    subtitle="$(tui_trunc "$subtitle" "$inner")"
+    printf "${BLUE}╭"; tui_hline "─" $((w-2)); printf "╮${RESET}\n"
+    printf "${BLUE}│${RESET}  ${BOLD}${BRIGHT}%-*s${RESET}  ${BLUE}│${RESET}\n" "$inner" "$title"
+    if [[ -n "$subtitle" ]]; then
+        printf "${BLUE}│${RESET}  ${DIM}%-*s${RESET}  ${BLUE}│${RESET}\n" "$inner" "$subtitle"
+    fi
+    printf "${BLUE}╰"; tui_hline "─" $((w-2)); printf "╯${RESET}\n"
+}
+
+tui_section() {
+    printf "\n${BOLD}${MAGENTA}${SYM_SECT}${RESET} ${BOLD}%s${RESET}\n" "$1"
+}
+
+tui_ok()    { printf "  ${GREEN}${SYM_OK}${RESET}  %s\n" "$*"; }
+tui_err()   { printf "  ${RED}${SYM_ERR}${RESET}  %s\n" "$*"; }
+tui_warn()  { printf "  ${YELLOW}${SYM_WARN}${RESET}  %s\n" "$*"; }
+tui_info()  { printf "  ${CYAN}${SYM_LIST}${RESET}  %s\n" "$*"; }
+tui_step()  { printf "  ${DIM}${SYM_PROG}${RESET}  ${DIM}%s${RESET}\n" "$*"; }
+tui_skip()  { printf "  ${GRAY}${SYM_STOP}${RESET}  ${GRAY}%s${RESET}\n" "$*"; }
+
+tui_state_symbol() {
+    case "$1" in
+        running)              printf "${GREEN}${SYM_RUN}${RESET}" ;;
+        starting)             printf "${YELLOW}${SYM_WARN}${RESET}" ;;
+        unhealthy|failed)     printf "${RED}${SYM_ERR}${RESET}" ;;
+        partial:*|external:*) printf "${YELLOW}${SYM_WARN}${RESET}" ;;
+        exited)               printf "${GRAY}${SYM_OK}${RESET}" ;;
+        *)                    printf "${GRAY}${SYM_STOP}${RESET}" ;;
+    esac
+}
+
+tui_state_color() {
+    case "$1" in
+        running)              echo "$GREEN" ;;
+        starting)             echo "$YELLOW" ;;
+        unhealthy|failed)     echo "$RED" ;;
+        partial:*|external:*) echo "$YELLOW" ;;
+        exited)               echo "$GRAY" ;;
+        *)                    echo "$GRAY" ;;
+    esac
+}
+
+# Show a spinner next to $msg while $pid runs. Caller is responsible for
+# `wait $pid` afterwards to capture exit code.
+tui_spinner() {
+    local pid="$1" msg="$2"
+    if [[ ! -t 1 ]]; then
+        printf "  ${BLUE}${SYM_PROG}${RESET}  ${DIM}%s (no-TTY, no spinner)${RESET}\n" "$msg"
+        return
+    fi
+    # Use an array (vs a single multibyte string + byte indexing) because
+    # bash's `${str:i:1}` is byte-wise — each braille glyph is 3 UTF-8
+    # bytes, so a byte index would print broken half-chars.
+    local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
+    local n=${#frames[@]}
+    local i=0
+    local start_ts=$SECONDS
+    printf "\e[?25l"   # hide cursor
+    while kill -0 "$pid" 2>/dev/null; do
+        local elapsed=$((SECONDS - start_ts))
+        local frame="${frames[i % n]}"
+        printf "\r  ${BLUE}%s${RESET}  ${DIM}%s${RESET} ${GRAY}(%ds)${RESET}     " \
+            "$frame" "$msg" "$elapsed"
+        sleep 0.1
+        i=$((i+1))
+    done
+    printf "\r%-${TUI_WIDTH}s\r" " "
+    printf "\e[?25h"   # show cursor
+}
+
+# Run a command in the background with output captured to $log, show spinner,
+# return command's exit code.
+tui_run_with_spinner() {
+    local log="$1" msg="$2"
+    shift 2
+    "$@" >"$log" 2>&1 &
+    local pid=$!
+    tui_spinner "$pid" "$msg"
+    wait "$pid"
+}
+
+# In-place panel that polls each non-skipped service's port and redraws the
+# whole panel until all are healthy or timed out. Sets a trap so Ctrl-C
+# restores the cursor.
+tui_wait_panel() {
+    local svcs=()
+    for svc in "${SERVICES[@]}"; do
+        is_skipped "$svc" && continue
+        svcs+=("$svc")
+    done
+    local n=${#svcs[@]}
+    (( n == 0 )) && return 0
+
+    local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
+    local n_frames=${#frames[@]}
+    local start_ts=$SECONDS
+    # JVM + docker services bind their port within ~10-30s; 90s leaves slack
+    # for cold-cache machines. The frontend's `ng serve` does a full Angular
+    # compile before listening — on a fresh checkout that's 90-180s easily,
+    # so give yarn-typed services 5 minutes. bun is in between.
+    local timeout_default=90
+    local timeout_yarn=300
+    local timeout_bun=120
+    local frame_idx=0
+    local first_render=true
+    local n_done=0
+    local n_failed=0
+    local svc="" i=0 state="" state_color="" state_sym="" port_str="" elapsed=0 spinner_frame=""
+
+    if [[ ! -t 1 ]]; then
+        # Non-TTY: redrawing would just spam lines. Poll each service to
+        # completion (or per-service timeout) and print one line per
+        # transition. Crucially we WAIT for docker containers to leave
+        # `starting`/`unhealthy` rather than treating an in-flight state as
+        # a failure — the previous one-shot check exited rc=1 within ~20s
+        # of `up` if e.g. lakefs hadn't reached `running` yet, which is its
+        # normal cold-start state.
+        local n_done=0 n_failed=0
+        local svc_timeout=0 waited=0 final_state=""
+        for svc in "${svcs[@]}"; do
+            svc_timeout=$timeout_default
+            case "$(amap_get SVC_TYPE "$svc")" in
+                yarn) svc_timeout=$timeout_yarn ;;
+                bun)  svc_timeout=$timeout_bun  ;;
+            esac
+            waited=0
+            final_state=""
+            while (( waited < svc_timeout )); do
+                if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+                    case "$(docker_svc_state "$svc")" in
+                        running|exited)        final_state="ok";    break ;;
+                        unhealthy|failed)      final_state="bad";   break ;;
+                        # starting / created / restarting / paused / "" → keep waiting
+                    esac
+                else
+                    [[ -n "$(listen_pid_for_port "$(amap_get SVC_PORT "$svc")")" ]] && { final_state="ok"; break; }
+                fi
+                sleep 1
+                waited=$((waited+1))
+            done
+            case "$final_state" in
+                ok)
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_OK" "$svc" "$(amap_get SVC_PORT "$svc")" "healthy"
+                    n_done=$((n_done+1)) ;;
+                bad)
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_ERR" "$svc" "$(amap_get SVC_PORT "$svc")" "unhealthy"
+                    n_failed=$((n_failed+1)) ;;
+                *)  # timed out without ever reaching a terminal state
+                    printf "  %s  %-32s :%-6s  %s\n" "$SYM_ERR" "$svc" "$(amap_get SVC_PORT "$svc")" "timeout (${waited}s)"
+                    n_failed=$((n_failed+1)) ;;
+            esac
+        done
+        return $((n_failed > 0))
+    fi
+
+    printf "\e[?25l"   # hide cursor
+    trap 'printf "\e[?25h"' EXIT INT TERM
+
+    while true; do
+        elapsed=$((SECONDS - start_ts))
+        n_done=0
+        n_failed=0
+
+        if ! $first_render && [[ -t 1 ]]; then
+            printf "\e[${n}A"   # move cursor to top of panel
+        fi
+        first_render=false
+
+        spinner_frame="${frames[frame_idx % n_frames]}"
+
+        for svc in "${svcs[@]}"; do
+            state_color="" state_sym=""
+            # Per-service wait budget — yarn (ng serve cold compile) gets the
+            # most slack, bun a moderate amount, everything else the default.
+            local svc_timeout=$timeout_default
+            case "$(amap_get SVC_TYPE "$svc")" in
+                yarn) svc_timeout=$timeout_yarn ;;
+                bun)  svc_timeout=$timeout_bun  ;;
+            esac
+            if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+                local dstate=""
+                dstate=$(docker_svc_state "$svc")
+                case "$dstate" in
+                    running|exited)
+                        state="$dstate"
+                        state_color="$GREEN"; state_sym="${GREEN}${SYM_OK}${RESET}"
+                        n_done=$((n_done+1)) ;;
+                    starting)
+                        state="starting (${elapsed}s)"
+                        state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}" ;;
+                    unhealthy|failed)
+                        state="$dstate"
+                        state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                        n_failed=$((n_failed+1)) ;;
+                    *)
+                        if (( elapsed >= svc_timeout )); then
+                            state="timeout"
+                            state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                            n_failed=$((n_failed+1))
+                        else
+                            state="${dstate} (${elapsed}s)"
+                            state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}"
+                        fi ;;
+                esac
+                port_str=":$(amap_get SVC_PORT "$svc")"
+            else
+                if [[ -n "$(listen_pid_for_port "$(amap_get SVC_PORT "$svc")")" ]]; then
+                    state="healthy"
+                    state_color="$GREEN"; state_sym="${GREEN}${SYM_OK}${RESET}"
+                    n_done=$((n_done+1))
+                elif (( elapsed >= svc_timeout )); then
+                    state="timeout — see bin/local-dev.sh logs $svc"
+                    state_color="$RED"; state_sym="${RED}${SYM_ERR}${RESET}"
+                    n_failed=$((n_failed+1))
+                else
+                    state="starting (${elapsed}s)"
+                    state_color="$YELLOW"; state_sym="${YELLOW}${spinner_frame}${RESET}"
+                fi
+                port_str=":$(amap_get SVC_PORT "$svc")"
+            fi
+
+            [[ -t 1 ]] && printf "\e[2K"
+            printf "  %s  %-32s ${DIM}%-7s${RESET}  ${state_color}%s${RESET}\n" \
+                "$state_sym" "$svc" "$port_str" "$state"
+        done
+
+        if (( n_done + n_failed == n )); then
+            break
+        fi
+
+        frame_idx=$((frame_idx + 1))
+        sleep 0.2
+    done
+
+    if [[ -t 1 ]]; then
+        printf "\e[?25h"
+        trap - EXIT INT TERM
+    fi
+
+    return $((n_failed > 0))
+}
+
+# --------- toolchain install hints ---------
+# Print install instructions for a missing toolchain. Used by both startup
+# detection failures and runtime "command not found" surfaces. Keeps the
+# guidance in one place so every failure mode looks the same.
+_install_hint() {
+    local tool="$1"
+    case "$tool" in
+        java)
+            printf "  ${BOLD}install JDK 17:${RESET}\n"
+            printf "    macOS:   brew install openjdk@17\n"
+            printf "    Linux:   apt install openjdk-17-jdk    ${DIM}# or yum/dnf equivalent${RESET}\n"
+            printf "    SDKMAN:  sdk install java 17.0.13-tem\n"
+            printf "  or set JAVA_HOME=/path/to/jdk-17 explicitly\n"
+            ;;
+        python)
+            printf "  ${BOLD}install Python 3.10+ and the TUI deps:${RESET}\n"
+            printf "    macOS:   brew install python@3.12\n"
+            printf "    Linux:   apt install python3 python3-pip\n"
+            printf "    then:    python3 -m pip install -r %s/amber/dev-requirements.txt\n" "$REPO_ROOT"
+            printf "  or set TEXERA_PYTHON=/path/to/python explicitly (must have textual installed)\n"
+            ;;
+        node)
+            printf "  ${BOLD}install Node 20+ (needed for frontend & agent-service):${RESET}\n"
+            printf "    macOS:   brew install node\n"
+            printf "    nvm:     nvm install --lts && nvm use --lts\n"
+            printf "    fnm:     fnm install --lts\n"
+            printf "    volta:   volta install node\n"
+            ;;
+        yarn)
+            printf "  ${BOLD}install yarn (needed for the frontend):${RESET}\n"
+            printf "    macOS:   brew install yarn\n"
+            printf "    npm:     npm install -g yarn\n"
+            printf "    corepack: corepack enable\n"
+            ;;
+        bun)
+            printf "  ${BOLD}install bun (needed for agent-service):${RESET}\n"
+            printf "    macOS:   brew install oven-sh/bun/bun\n"
+            printf "    curl:    curl -fsSL https://bun.sh/install | bash\n"
+            ;;
+        sbt)
+            printf "  ${BOLD}install sbt (needed to build the JVM services):${RESET}\n"
+            printf "    macOS:   brew install sbt\n"
+            printf "    Linux:   see https://www.scala-sbt.org/download.html\n"
+            ;;
+        docker)
+            printf "  ${BOLD}install Docker (needed for postgres/minio/lakefs/lakekeeper/litellm):${RESET}\n"
+            printf "    macOS:   download Docker Desktop from https://docker.com/products/docker-desktop\n"
+            printf "    Linux:   apt install docker.io docker-compose-plugin\n"
+            ;;
+        *)
+            printf "  ${DIM}no install hint for: %s${RESET}\n" "$tool"
+            ;;
+    esac
+}
+
+# Inspect the user's Node/yarn/bun setup and print what we actually find,
+# so "yarn not found" reads as "you have node 18 but no yarn" instead of
+# the generic install hint. Called from start_one's frontend/agent paths.
+_diagnose_node() {
+    printf "\n  ${BOLD}node environment:${RESET}\n"
+    for tool in node npm yarn bun corepack; do
+        local p=""
+        p=$(command -v "$tool" 2>/dev/null) || true
+        if [[ -n "$p" ]]; then
+            local v=""
+            v=$("$tool" --version 2>&1 | head -1) || v="(no --version)"
+            printf "    ${GREEN}✓${RESET} %-8s → %s  ${DIM}(%s)${RESET}\n" "$tool" "$p" "$v"
+        else
+            printf "    ${RED}✗${RESET} %-8s ${DIM}not on PATH${RESET}\n" "$tool"
+        fi
+    done
+    printf "\n  ${BOLD}version manager:${RESET}\n"
+    if [[ -n "${NVM_DIR:-}" && -s "${NVM_DIR}/nvm.sh" ]]; then
+        printf "    nvm  → ${DIM}%s${RESET}\n" "$NVM_DIR"
+    elif command -v fnm >/dev/null 2>&1; then
+        printf "    fnm  → ${DIM}%s${RESET}\n" "$(command -v fnm)"
+    elif [[ -s "$HOME/.volta/load.sh" ]]; then
+        printf "    volta → ${DIM}%s${RESET}\n" "$HOME/.volta"
+    else
+        printf "    ${DIM}none detected (using whatever \`node\` is on PATH)${RESET}\n"
+    fi
+    printf "\n"
+}
+
+# --------- helpers ---------
+listen_pid_for_port() {
+    # || true so pipefail doesn't kill us when nothing is listening
+    lsof -nP -iTCP:"$1" -sTCP:LISTEN -t 2>/dev/null | head -1 || true
+}
+
+# Returns the count of long-lived infra services currently running under our project.
+infra_running_count() {
+    docker compose -p "$DOCKER_PROJECT" ps --services --filter status=running 2>/dev/null | grep -cxE "$(IFS=\|; echo "${DOCKER_INFRA_LONGLIVED[*]}")" || true
+}
+
+# Returns one of: stopped | running | partial:N | external — aggregate view
+# across all infra containers, used by infra_up/infra_down and the wait panel.
+infra_state() {
+    local running=""
+    running=$(infra_running_count)
+    if [[ "$running" -eq ${#DOCKER_INFRA_LONGLIVED[@]} ]]; then
+        echo "running"
+    elif [[ "$running" -gt 0 ]]; then
+        echo "partial:$running"
+    else
+        local taken=0
+        for port in 5432 9000 8000 8181 4000; do
+            [[ -n "$(listen_pid_for_port "$port")" ]] && taken=$((taken+1))
+        done
+        if [[ "$taken" -gt 0 ]]; then
+            echo "external:$taken/5"
+        else
+            echo "stopped"
+        fi
+    fi
+}
+
+# Cached snapshot of `docker compose ps -a`. Refreshed at most once per second
+# (5 docker services × per-row ~200 ms `docker ps` call would otherwise tank
+# the render).
+_docker_states_cache=""
+_docker_states_cache_ts=-1
+
+_refresh_docker_states_cache() {
+    if (( _docker_states_cache_ts < 0 || SECONDS - _docker_states_cache_ts >= 1 )); then
+        _docker_states_cache=$(docker compose -p "$DOCKER_PROJECT" ps -a \
+            --format '{{.Service}}|{{.State}}|{{.Status}}' 2>/dev/null)
+        _docker_states_cache_ts=$SECONDS
+    fi
+}
+
+# Per-service state for any of postgres/minio/lakefs/lakekeeper/litellm.
+# Returns one of: running | starting | unhealthy | exited | failed | stopped
+docker_svc_state() {
+    local svc="$1"
+    _refresh_docker_states_cache
+    local line=""
+    line=$(printf '%s\n' "$_docker_states_cache" | grep "^${svc}|" | head -1 || true)
+    if [[ -z "$line" ]]; then
+        echo "stopped"
+        return
+    fi
+    local rest="${line#*|}"
+    local dstate="${rest%%|*}"     # NB: not `status` — zsh reserves $status
+    local dstatus="${rest#*|}"
+    case "$dstate" in
+        running)
+            if [[ "$dstatus" == *'(healthy)'* ]]; then echo "running"
+            elif [[ "$dstatus" == *'(health: starting)'* ]]; then echo "starting"
+            elif [[ "$dstatus" == *'(unhealthy)'* ]]; then echo "unhealthy"
+            else echo "running"
+            fi ;;
+        exited)
+            if [[ "$dstatus" == 'Exited (0)'* ]]; then echo "exited"
+            else echo "failed"
+            fi ;;
+        created|restarting|paused|removing) echo "starting" ;;
+        *) echo "stopped" ;;
+    esac
+}
+
+infra_up() {
+    # Resolve the host LAN IP now (lazy) — both the docker compose stack
+    # (lakekeeper-init reads STORAGE_S3_ENDPOINT) and the host JVMs about
+    # to start need it pointing at a host-reachable MinIO.
+    _require_host_lan_ip
+    if [[ "$(infra_state)" == external:* ]]; then
+        tui_err "infra: ports already taken by non-script containers"
+        printf "  ${DIM}Likely an old project (e.g. \`texera-dev\`) is running. Stop it first:${RESET}\n"
+        printf "  ${DIM}  docker compose -p texera-dev down${RESET}\n"
+        return 1
+    fi
+    local files=($(docker_compose_files))
+    tui_step "infra: docker compose up -d  ${DIM}(in-place TTY progress)${RESET}"
+    # No stdout redirect → docker compose detects TTY and renders an in-place
+    # progress panel that overwrites itself instead of appending event lines.
+    # --progress=tty forces it even if stdout looks like a pipe.
+    docker compose --progress auto -p "$DOCKER_PROJECT" --env-file "$DOCKER_ENV_FILE" "${files[@]}" \
+        up -d "${DOCKER_INFRA_SERVICES[@]}"
+    tui_ok "infra: 5 containers up"
+}
+
+infra_down() {
+    tui_step "infra: docker compose -p $DOCKER_PROJECT down  ${DIM}(in-place TTY progress)${RESET}"
+    docker compose --progress auto -p "$DOCKER_PROJECT" down || true
+    tui_ok "infra: stopped"
+}
+
+# Ensure the texera_db schema exists in the postgres container. The compose
+# file mounts sql/*.sql to /docker-entrypoint-initdb.d, but Postgres only
+# runs those on first init (empty data dir). If the volume was carried over
+# from an older texera version (e.g. before the `feedback` table was added)
+# the schema will be missing relations that current code references, the
+# jOOQ codegen produces an incomplete Tables.java, and sbt compile fails on
+# `not found: value FEEDBACK`. Probe for a canonical table and re-run
+# texera_ddl.sql if it's absent.
+infra_ensure_db_schema() {
+    local pg="texera-postgres"
+    # Wait briefly for postgres to be ready — `up -d` returned but the
+    # container may still be running its own init sequence.
+    local i=0
+    while (( i < 30 )); do
+        if docker exec "$pg" pg_isready -U texera -d texera_db -q 2>/dev/null; then
+            break
+        fi
+        sleep 1
+        i=$((i+1))
+    done
+    if (( i >= 30 )); then
+        tui_warn "postgres: not ready after 30s -- skipping schema check"
+        return 0
+    fi
+    # `feedback` is one of the newer tables; if it exists we assume the
+    # whole schema is current. (texera_ddl.sql is idempotent with
+    # CREATE TABLE IF NOT EXISTS, so re-applying it is safe even if some
+    # tables already exist, but skipping the copy + exec is faster.)
+    local has_feedback=""
+    has_feedback=$(docker exec "$pg" psql -U texera -d texera_db -tAc \
+        "SELECT 1 FROM pg_tables WHERE schemaname='texera_db' AND tablename='feedback'" \
+        2>/dev/null || true)
+    if [[ "$has_feedback" == "1" ]]; then
+        tui_skip "postgres: schema already current"
+        return 0
+    fi
+    tui_step "postgres: applying sql/texera_ddl.sql (one-time bootstrap)"
+    local ddl="$REPO_ROOT/sql/texera_ddl.sql"
+    if [[ ! -f "$ddl" ]]; then
+        tui_warn "postgres: $ddl not found -- skipping (jOOQ codegen may fail)"
+        return 0
+    fi
+    docker cp "$ddl" "$pg":/tmp/texera_ddl.sql >/dev/null
+    if docker exec -u postgres "$pg" psql -U texera -f /tmp/texera_ddl.sql >/dev/null 2>&1; then
+        tui_ok "postgres: schema bootstrapped"
+    else
+        tui_warn "postgres: ddl exec returned non-zero (check container logs)"
+    fi
+}
+
+svc_running_pid() {
+    listen_pid_for_port "$(amap_get SVC_PORT "$1")"
+}
+
+# Compact-format a duration in seconds:
+#   "—" for <0, "12s", "5m 23s", "2h 14m", "3d 4h"
+_format_uptime() {
+    local s="${1:-0}"
+    if (( s < 0 ));     then printf "—"; return; fi
+    if (( s < 60 ));    then printf "%ds" "$s"; return; fi
+    if (( s < 3600 ));  then printf "%dm %ds" $((s/60)) $((s%60)); return; fi
+    if (( s < 86400 )); then printf "%dh %dm" $((s/3600)) $(((s%3600)/60)); return; fi
+    printf "%dd %dh" $((s/86400)) $(((s%86400)/3600))
+}
+
+# Translate ps -o etime output (`[[DD-]hh:]mm:ss`) to whole seconds.
+_etime_to_seconds() {
+    local et="$1"
+    # bash quirk: in `local a=$x b=$a`, the right-hand `$a` resolves
+    # against the *outer* scope (before this `local` declares either).
+    # Putting `rest` on its own line ensures it sees the fresh `et`.
+    local rest="$et" days=0 h=0 m=0 s=0
+    if [[ "$rest" == *-* ]]; then
+        days="${rest%%-*}"
+        rest="${rest#*-}"
+    fi
+    # `IFS=: read -ra` reliably splits on `:` without the local-IFS-vs-
+    # array-literal trap.
+    local parts=()
+    IFS=: read -ra parts <<< "$rest"
+    case "${#parts[@]}" in
+        3) h=${parts[0]}; m=${parts[1]}; s=${parts[2]} ;;
+        2) m=${parts[0]}; s=${parts[1]} ;;
+        *) s=${parts[0]} ;;
+    esac
+    # Force base-10 so "08" / "09" don't blow up under bash's octal default.
+    printf '%d' "$((10#${days:-0}*86400 + 10#${h:-0}*3600 + 10#${m:-0}*60 + 10#${s:-0}))"
+}
+
+# Translate a number of bytes to a 4-char-ish human string ("85M", "1.2G").
+_format_bytes() {
+    local b="${1:-0}"
+    if (( b < 1024 ));         then printf "%dB"   "$b"; return; fi
+    if (( b < 1048576 ));      then printf "%dK"   $((b/1024)); return; fi
+    if (( b < 1073741824 ));   then printf "%dM"   $((b/1048576)); return; fi
+    # GB → 1 decimal place
+    local g_int=$((b / 1073741824)) g_frac=$(( (b % 1073741824) * 10 / 1073741824 ))
+    printf "%d.%dG" "$g_int" "$g_frac"
+}
+
+# Compact "8.2%" formatter from a string like "0.50" or "8.2".
+_format_pct() {
+    local p="${1:-0}"
+    # Strip optional trailing %, normalise weird inputs
+    p="${p%%%}"
+    [[ -z "$p" || "$p" == "-" ]] && { printf "—"; return; }
+    # Round to 1 decimal place using awk to avoid bash's lack of float math
+    printf '%s%%' "$(awk -v v="$p" 'BEGIN { printf "%.1f", v }' 2>/dev/null)"
+}
+
+# Container name for a docker-typed service. Most use `texera-<svc>`, but
+# `litellm` ships unprefixed in upstream's compose.
+_docker_container_for() {
+    case "$1" in
+        litellm) printf "litellm" ;;
+        *)       printf "texera-%s" "$1" ;;
+    esac
+}
+
+# Uptime for a service. Native: `ps -o etime` (POSIX, works on mac+linux).
+# Docker: parse the container's ISO-8601 .State.StartedAt against `date -u`.
+# Echoes "—" when not running.
+svc_uptime() {
+    local svc="$1"
+    if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+        local container="" since=""
+        container=$(_docker_container_for "$svc")
+        since=$(docker inspect -f '{{.State.StartedAt}}' "$container" 2>/dev/null) || { printf "—"; return; }
+        [[ -z "$since" || "$since" == "0001-01-01T00:00:00Z" ]] && { printf "—"; return; }
+        local now=0 started=0
+        now=$(date -u +%s 2>/dev/null) || { printf "—"; return; }
+        # macOS `date -j` parses ISO without fractional seconds — trim them.
+        started=$(date -u -j -f "%Y-%m-%dT%H:%M:%S" "${since%%.*}" +%s 2>/dev/null) || {
+            # GNU date fallback
+            started=$(date -u -d "${since%%.*}" +%s 2>/dev/null) || { printf "—"; return; }
+        }
+        local elapsed=$((now - started))
+        (( elapsed < 0 )) && elapsed=0
+        _format_uptime "$elapsed"
+        return
+    fi
+    local pid=""
+    pid=$(svc_running_pid "$svc") || true
+    [[ -z "$pid" ]] && { printf "—"; return; }
+    local et=""
+    et=$(ps -p "$pid" -o etime= 2>/dev/null | tr -d ' ')
+    [[ -z "$et" ]] && { printf "—"; return; }
+    _format_uptime "$(_etime_to_seconds "$et")"
+}
+
+# CPU% + RSS for a running native process. Returns "cpu%|rss_bytes".
+# Cheap enough (<5ms) that we can call it per service per tick.
+svc_proc_cpu_mem() {
+    local pid=""
+    pid=$(svc_running_pid "$1") || true
+    [[ -z "$pid" ]] && { printf "—|—"; return; }
+    local cpu="" rss=""
+    # macOS ps emits RSS in KB. Linux's `ps -o rss=` is also KB.
+    read -r cpu rss <<< "$(ps -p "$pid" -o pcpu=,rss= 2>/dev/null | tr -s ' ')"
+    [[ -z "$cpu" || -z "$rss" ]] && { printf "—|—"; return; }
+    printf "%s|%s" "$(_format_pct "$cpu")" "$(_format_bytes $((rss * 1024)))"
+}
+
+# Bulk docker stats — one slow `docker stats --no-stream` call returns CPU
+# + memory for every running container. Callers can grep their service out
+# of the result instead of paying the 1-2 second cost N times. Format:
+#   <container>|<cpu%>|<used-bytes>
+_docker_stats_snapshot() {
+    docker stats --no-stream --format '{{.Name}}|{{.CPUPerc}}|{{.MemUsage}}' 2>/dev/null \
+        | while IFS='|' read -r name cpu memu; do
+            # MemUsage is like "85.2MiB / 1.95GiB" — keep only the first
+            # half and translate IEC units to bytes.
+            local used="${memu%% *}"   # "85.2MiB"
+            local val="${used%[A-Za-z]*}"
+            local unit="${used##*[0-9.]}"
+            local bytes=0
+            case "$unit" in
+                KB|KiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1024 }') ;;
+                MB|MiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1048576 }') ;;
+                GB|GiB) bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v * 1073741824 }') ;;
+                *)      bytes=$(awk -v v="$val" 'BEGIN { printf "%d", v }') ;;
+            esac
+            printf "%s|%s|%s\n" "$name" "$(_format_pct "${cpu%%%}")" "$(_format_bytes "$bytes")"
+        done
+}
+
+svc_artifact_mtime() {
+    local svc="$1" type=""
+    type=$(amap_get SVC_TYPE "$svc")
+    case "$type" in
+        jvm)
+            local launcher="$(amap_get SVC_CWD "$svc")/$(amap_get SVC_LAUNCHER "$svc")"
+            launcher="${launcher#./}"
+            local jar_dir=""
+            jar_dir="$(dirname "$(dirname "$launcher")")/lib"
+            if [[ -d "$jar_dir" ]]; then
+                # `shopt -s nullglob` localised in a subshell so an
+                # unmatched glob yields no words instead of the literal
+                # pattern. Capture into a string then split into an array.
+                local globbed=""
+                globbed=$(shopt -s nullglob; \
+                    printf '%s\n' "$jar_dir"/org.apache.texera."${svc}"-*.jar)
+                local main_jars=()
+                while IFS= read -r _f; do
+                    [[ -n "$_f" ]] && main_jars+=("$_f")
+                done <<< "$globbed"
+                if [[ ${#main_jars[@]} -eq 0 && ( "$svc" == "texera-web" || "$svc" == "computing-unit-master" ) ]]; then
+                    globbed=$(shopt -s nullglob; \
+                        printf '%s\n' "$jar_dir"/org.apache.texera.amber-*.jar)
+                    while IFS= read -r _f; do
+                        [[ -n "$_f" ]] && main_jars+=("$_f")
+                    done <<< "$globbed"
+                fi
+                if [[ ${#main_jars[@]} -gt 0 ]]; then
+                    stat -f "%Sm" -t "%Y-%m-%d %H:%M" "${main_jars[0]}"
+                    return
+                fi
+            fi
+            echo "—"
+            ;;
+        bun)    stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$(amap_get SVC_CWD "$svc")/bun.lock" 2>/dev/null || echo "—" ;;
+        yarn)   stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$(amap_get SVC_CWD "$svc")/yarn.lock" 2>/dev/null || echo "—" ;;
+        docker) echo "—" ;;
+    esac
+}
+
+is_skipped() {
+    [[ ",${SKIP_LIST:-}," == *",$1,"* ]]
+}
+
+wait_for_port() {
+    local port="$1" timeout="${2:-90}" i=0
+    while (( i < timeout )); do
+        [[ -n "$(listen_pid_for_port "$port")" ]] && return 0
+        sleep 1
+        i=$((i+1))
+    done
+    return 1
+}
+
+# Write a transitional phase for $svc so the TUI dashboard can render it
+# in the STATE column with animated dots. Cleared by phase_clear or after
+# 90s (TUI side stale check).
+phase_set() {
+    local svc="$1" phase="$2"
+    printf '%s\t%s\n' "$phase" "$(date +%s)" > "$PHASE_DIR/$svc" 2>/dev/null || true
+}
+phase_clear() {
+    local svc="$1"
+    rm -f "$PHASE_DIR/$svc" 2>/dev/null || true
+}
+
+stop_one() {
+    local svc="$1"
+    if [[ "$(amap_get SVC_TYPE "$svc")" == "docker" ]]; then
+        phase_set "$svc" stopping
+        tui_step "$svc: docker compose stop $svc"
+        docker compose -p "$DOCKER_PROJECT" stop "$svc" >/dev/null 2>&1 || true
+        phase_clear "$svc"
+        tui_ok "$svc: stopped"
+        return
+    fi
+    local pid=""
+    pid=$(svc_running_pid "$svc")
+    if [[ -z "$pid" ]]; then
+        tui_skip "$svc: already stopped"
+        return 0
+    fi
+    phase_set "$svc" stopping
+    tui_step "$svc: stopping PID $pid"
+    kill "$pid" 2>/dev/null || true
+    local i=0
+    while (( i < 30 )) && kill -0 "$pid" 2>/dev/null; do
+        sleep 0.5
+        i=$((i+1))
+    done
+    if kill -0 "$pid" 2>/dev/null; then
+        tui_warn "$svc: SIGKILL $pid"
+        kill -9 "$pid" 2>/dev/null || true
+    fi
+    phase_clear "$svc"
+    tui_ok "$svc: stopped"
+}
+
+start_one() {
+    local svc="$1"
+    local type=""
+    type=$(amap_get SVC_TYPE "$svc")
+    # JVMs and docker services need STORAGE_S3_ENDPOINT exported before
+    # launch (JVM clients dial MinIO; lakekeeper bakes the URL into the
+    # warehouse storage profile). yarn/bun watch services don't.
+    if [[ "$type" == "jvm" || "$type" == "docker" ]]; then
+        _require_host_lan_ip
+    fi
+    if [[ "$type" == "docker" ]]; then
+        local dstate=""
+        dstate=$(docker_svc_state "$svc")
+        if [[ "$dstate" == "running" ]]; then
+            tui_ok "$svc: already running"
+            return 0
+        fi
+        phase_set "$svc" starting
+        tui_step "$svc: docker compose up -d $svc"
+        local files=()
+        while read -r f; do files+=("$f"); done < <(docker_compose_files | tr ' ' '\n')
+        docker compose --progress auto -p "$DOCKER_PROJECT" --env-file "$DOCKER_ENV_FILE" \
+            "${files[@]}" up -d "$svc" >/dev/null 2>&1
+        # Don't clear the phase yet — docker `up -d` returns before the
+        # container is healthy. The TUI's docker_state poller will flip
+        # the row to "running" once the container reports healthy; the
+        # stale-after-90s rule covers cleanup if that never happens.
+        tui_ok "$svc: started"
+        return
+    fi
+    if [[ -n "$(svc_running_pid "$svc")" ]]; then
+        tui_ok "$svc: already running ${DIM}(PID $(svc_running_pid "$svc"))${RESET}"
+        return 0
+    fi
+    local cwd="" log="$LOG_DIR/$svc.log"
+    cwd=$(amap_get SVC_CWD "$svc")
+    phase_set "$svc" starting
+    tui_step "$svc: starting ${DIM}(log: $log)${RESET}"
+    case "$type" in
+        jvm)
+            local launcher=""
+            launcher=$(amap_get SVC_LAUNCHER "$svc")
+            if [[ ! -x "$cwd/$launcher" ]]; then
+                phase_clear "$svc"
+                tui_err "$svc: launcher missing at $cwd/$launcher -- run \`bin/local-dev.sh up\` to build first"
+                return 1
+            fi
+            ( cd "$cwd" && nohup "./$launcher" >"$log" 2>&1 </dev/null & )
+            ;;
+        bun)
+            if ! command -v bun >/dev/null 2>&1; then
+                tui_err "$svc: \`bun\` not found on PATH"
+                _diagnose_node
+                _install_hint bun
+                return 1
+            fi
+            ( cd "$cwd" && nohup bun run dev >"$log" 2>&1 </dev/null & )
+            ;;
+        yarn)
+            if ! command -v yarn >/dev/null 2>&1; then
+                tui_err "$svc: \`yarn\` not found on PATH"
+                _diagnose_node
+                if ! command -v node >/dev/null 2>&1; then
+                    _install_hint node
+                else
+                    _install_hint yarn
+                fi
+                return 1
+            fi
+            ( cd "$cwd" && nohup yarn start >"$log" 2>&1 </dev/null & )
+            ;;
+    esac
+}
+
+build_one_jvm() {
+    local svc="$1" proj=""
+    proj=$(amap_get SVC_SBT "$svc")
+    local log="$LOG_DIR/sbt-${svc}.log"
+    # Empty SVC_SBT means this service rides another service's dist (e.g.
+    # computing-unit-master shares amber's). Nothing to build directly — the
+    # launcher is produced when its sibling builds. Stamp `svc` so the dirty
+    # indicator can clear if amber/src actually matches.
+    if [[ -z "$proj" ]]; then
+        tui_skip "$svc: no own sbt project (built with its sibling)"
+        svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc" 2>/dev/null || true
+        return 0
+    fi
+    phase_set "$svc" building
+    if tui_run_with_spinner "$log" "sbt $proj/dist  ${DIM}(log: $log)${RESET}" \
+        sbt -no-colors "$proj/dist"; then
+        local zip_glob="" unzip_dest=""
+        zip_glob=$(amap_get SVC_ZIP_GLOB "$svc")
+        unzip_dest=$(amap_get SVC_UNZIP_DEST "$svc")
+        tui_step "unzip ${zip_glob} → ${unzip_dest}"
+        # shellcheck disable=SC2086
+        unzip -oq ${zip_glob} -d "${unzip_dest}"
+        # Stamp = SHA-1 of the source we just built from. Clears the `*` and
+        # lets us tell content-vs-mtime apart on the next dirty check.
+        svc_source_hash "$svc" > "$BUILD_STAMP_DIR/$svc"
+        tui_ok "$svc: build done"
+        # Don't clear the phase yet — the caller (cmd_update_one) will
+        # transition us through stop_one/start_one which overwrite it.
+        # If something else is the caller, the TUI's "phase cleared once
+        # poller sees running" rule covers us.

Review Comment:
   Deleted in 6088c54a2.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org