#!/usr/bin/env bash # Janus-35B — does an installed Ollama tag still carry this repo's template? # # Ollama resolves a tag once, at pull or create time, and never re-checks this # repo afterwards. A tag made before a template/system/params change keeps # serving the old one indefinitely: nothing warns you, and `ollama list` shows # the pull date, not which release the tag carries. # # A local `janus` tag here served the 0.9.6 template for two days while this # repo was at 0.9.10, missing 0.9.7's tool-chain render — the only change in # that span to how tool calls are emitted — and 0.9.8's system-block fix, which # affects every request carrying no tools array. # # The static checks here all compare this repo's own files. `make smoke`, # `make smoke-tools` and `make bench` do hit the installed tag, but none of # them compares its template with this repo's. # # Usage: # ./scripts/check_tag_sync.sh # tag `janus`, or $TAG # ./scripts/check_tag_sync.sh # TAG= make check-tag # # Exit 0 in sync, 1 drifted, 2 unusable (no ollama; template missing, empty or # unreadable; tag unreadable). # # Requires: ollama. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" TAG="${1:-${TAG:-janus}}" TEMPLATE="${ROOT}/template" if ! command -v ollama >/dev/null 2>&1; then echo "[!] ollama not found in PATH" >&2; exit 2; fi # One cause per message, as the tag/daemon split above. if [[ ! -e "${TEMPLATE}" ]]; then echo "[!] ${TEMPLATE} does not exist" >&2; exit 2 elif [[ ! -r "${TEMPLATE}" ]]; then echo "[!] ${TEMPLATE} is not readable" >&2; exit 2 elif [[ ! -s "${TEMPLATE}" ]]; then echo "[!] ${TEMPLATE} is empty" >&2; exit 2 fi # Split the assignment from any filter. A direct # HAVE="$(ollama show ... 2>/dev/null | filter)" # aborts under set -e + pipefail when the tag is unreadable, and the emptiness # check below never runs — the footgun check.sh guards. if ! HAVE="$(ollama show --template "${TAG}" 2>/dev/null)"; then # One cause per message: unreachable daemon, absent tag, or a tag that is # present but unreadable. Consult the list rather than assuming. if ! LISTED="$(ollama list 2>/dev/null)"; then echo "[!] cannot reach the Ollama daemon — is \`ollama serve\` running?" >&2 else # `ollama list` prints a bare tag as name:latest. WANTED="${TAG}" [[ "${WANTED}" == *:* ]] || WANTED="${WANTED}:latest" if printf '%s\n' "${LISTED}" | awk 'NR>1{print $1}' | grep -qxF -- "${WANTED}"; then echo "[!] tag '${TAG}' is installed but its template could not be read" >&2 else echo "[!] tag '${TAG}' is not installed" >&2 fi fi exit 2 fi if [[ -z "${HAVE}" ]]; then echo "[!] tag '${TAG}' carries no template" >&2 exit 2 fi # `ollama show --template` emits the template verbatim, with no trailing # newline added, so this compares like for like against the file. if ! WANT="$(cat "${TEMPLATE}")"; then echo "[!] cannot read ${TEMPLATE}" >&2 exit 2 fi if [[ "${HAVE}" == "${WANT}" ]]; then echo "[ ok ] '${TAG}' carries this repo's template" exit 0 fi # Name the refresh for the tag actually given, not a hard-coded one. echo "[!] '${TAG}' has DRIFTED from this repo's template" >&2 if [[ "${TAG}" == hf.co/* ]]; then echo " refresh it: ollama pull ${TAG}" >&2 else echo " rebuild it: ollama create ${TAG} -f Modelfile" >&2 echo " Modelfile's FROM names the bundled Q4_K_M, so that" >&2 echo " swaps any other quant back. If you built another," >&2 echo " re-run that build: TAG=${TAG} ./scripts/build.sh" >&2 fi exit 1