Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.
Shell agent-teamsai-agentai-automationanthropicautonomous-agentawsbusiness-operationsclaudeclaude-codeclaude-code-plugindevopsecommerceinbox-zeroklaviyomarketingmcpmorning-briefingpr-automationshopifyterminal
fix(ops-update): refuse silent downgrades; fail-closed clone and tag checks
Viktor Didkovskyi707f101d2450
diff --git a/claude-ops/CHANGELOG.md b/claude-ops/CHANGELOG.mdindex aa591a35..096e2a92 100644--- a/claude-ops/CHANGELOG.md+++ b/claude-ops/CHANGELOG.md@@ -10,6 +10,19 @@a conflict. The zone is resolved from `$OPS_TZ`, then `timezone` in`preferences.json`, then the system zone. All-day events are passed throughunconverted so they cannot be dragged onto an adjacent day.+- `ops-update` can no longer downgrade the plugin by accident. On 2026-09-11+ the local marketplace clone sat at 3.10.13 with a dirty tree while v3.10.15+ was published; `claude plugin marketplace update` reported success without+ moving it, the stale-clone guard returned "not stale" because a git call+ failed inside it (fail-open), and the run pruned the installed 3.10.14 and+ 3.10.15 caches, then printed "3.10.15 → 3.10.13 ✓ upgrade complete".+ Three guards now stand in the way: the clone check is fail-closed (an+ unverifiable clone aborts; new `--offline` turns that into a warning), the+ catalogue version is cross-checked against the newest remote `vX.Y.Z` tag,+ and a target that sorts below the installed version is refused — also with+ `--to` — unless the new `--allow-downgrade` flag is given. Step 5 never+ prunes a cache newer than the target without that flag and lists what it+ kept. Guard: `tests/test-ops-update-downgrade-guard.sh` (15 cases).## [3.10.17] - 2026-09-13diff --git a/claude-ops/bin/ops-update b/claude-ops/bin/ops-updateindex 92689d67..213a5751 100755--- a/claude-ops/bin/ops-update+++ b/claude-ops/bin/ops-update@@ -7,7 +7,13 @@# 1. Refresh the marketplace catalogue clone (claude plugin marketplace update)# — runs for real even under --dry-run: it is a read-only pull of the# public catalogue, and step 2 needs it current to report accurately.+# — then PROVES the clone is at its remote tip and that the catalogue's+# version is not behind the newest remote tag. Either check that cannot+# run (fetch/ls-remote failed) aborts, unless --offline.# 2. Resolve the target version from the refreshed marketplace.json+# — refuses to move to a LOWER version than the one installed unless+# --allow-downgrade is given (2026-09-11: a stale catalogue at 3.10.13+# silently pruned the installed 3.10.15 and printed "upgrade complete").# 3. Update the installed plugin (claude plugin update ops@ops-marketplace)# — with a force-reinstall fallback for the known Claude Code bug where# `plugin update` reports "already at latest" while the cache stays stale@@ -28,12 +34,17 @@# A session restart (or /reload-plugins) is required for the new version to load.## Usage:-# ops-update [--dry-run] [--force] [--to X.Y.Z] [--no-prune] [--no-patches]-# [--no-rewrite] [--no-localsync] [--no-companions] [--no-clisync]+# ops-update [--dry-run] [--force] [--to X.Y.Z] [--allow-downgrade] [--offline]+# [--no-prune] [--no-patches] [--no-rewrite] [--no-localsync]+# [--no-companions] [--no-clisync]## --dry-run show everything that would happen; change nothing# --force force-reinstall even if the CLI says "already at latest" (bug #61954)# --to X.Y.Z target a specific version instead of the marketplace's newest+# --allow-downgrade permit a target LOWER than the installed version, and let+# step 5 prune caches newer than the target (default: refuse)+# --offline if the remote cannot be reached (fetch / ls-remote fail),+# warn and continue instead of aborting (default: abort)# --no-prune keep old cache versions# --no-patches skip the cache-patch reapply step# --no-rewrite skip the stale-version-path rewrite step@@ -56,18 +67,21 @@ DATA_DIR="${CLAUDE_PLUGIN_DATA_DIR:-$PLUGINS_DIR/data/ops-${MARKETPLACE}}"THIS_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"DRY=0; FORCE=0; PRUNE=1; PATCHES=1; REWRITE=1; LOCALSYNC=1; COMPANIONS=1; CLISYNC=1; TARGET=""+ALLOW_DOWNGRADE=0; OFFLINE=0while [[ $# -gt 0 ]]; docase "$1" in--dry-run) DRY=1; shift ;;--force) FORCE=1; shift ;;- --to) TARGET="$2"; shift 2 ;;+ --to|--target) TARGET="$2"; shift 2 ;;+ --allow-downgrade) ALLOW_DOWNGRADE=1; shift ;;+ --offline) OFFLINE=1; shift ;;--no-prune) PRUNE=0; shift ;;--no-patches) PATCHES=0; shift ;;--no-rewrite) REWRITE=0; shift ;;--no-localsync) LOCALSYNC=0; shift ;;--no-companions) COMPANIONS=0; shift ;;--no-clisync) CLISYNC=0; shift ;;- -h|--help) sed -n '2,42p' "$0"; exit 0 ;;+ -h|--help) sed -n '2,/^# Public repo/p' "$0" | sed '$d'; exit 0 ;;*) echo "ops-update: unknown arg '$1'" >&2; exit 2 ;;esacdone@@ -120,13 +134,43 @@ elsefi# Verify the clone is actually at its remote tip, whatever the CLI claimed.+#+# FAIL-CLOSED. Until 2026-09-11 every failure below `return 1`-ed, which reads+# as "not stale": a fetch that could not reach origin, a detached HEAD, or a+# missing tracking ref all let the run continue against whatever the clone+# happened to hold. That is how a clone parked at 3.10.13 with a dirty tree+# passed this guard while v3.10.15 was on the remote, and the run then pruned+# the installed 3.10.15 as an "upgrade". A check that cannot run must abort,+# not vouch. `--offline` is the only way to turn an unreachable remote into a+# warning, and it still cannot silence a proven-stale clone.+mkt_guard_fail() {+ # $1 = what could not be verified+ if [[ "$OFFLINE" -eq 1 ]]; then+ warn "--offline: could not verify $1 — continuing on the local catalogue UNVERIFIED"+ return 0+ fi+ err "could not verify $1"+ say " clone: $MKT_CLONE"+ say " fix: restore network access and re-run, or pass --offline to accept"+ say " the local catalogue unverified (a downgrade is still refused)."+ err "refusing to continue: a catalogue that cannot be checked is not a catalogue"+ exit 1+}++# Exit 0 = stale, 1 = at tip. Any failure to *determine* that exits the run+# (or warns under --offline), so a return of 1 always means "proven current".mkt_clone_is_stale() {local branch remote_sha local_sha- git -C "$MKT_CLONE" fetch -q origin >/dev/null 2>&1 || return 1- branch="$(git -C "$MKT_CLONE" rev-parse --abbrev-ref HEAD 2>/dev/null)" || return 1- [[ -n "$branch" && "$branch" != HEAD ]] || return 1- remote_sha="$(git -C "$MKT_CLONE" rev-parse "origin/$branch" 2>/dev/null)" || return 1- local_sha="$(git -C "$MKT_CLONE" rev-parse HEAD 2>/dev/null)" || return 1+ git -C "$MKT_CLONE" fetch -q origin >/dev/null 2>&1 \+ || { mkt_guard_fail "the marketplace clone against its remote (git fetch origin failed)"; return 1; }+ branch="$(git -C "$MKT_CLONE" rev-parse --abbrev-ref HEAD 2>/dev/null)" \+ || { mkt_guard_fail "the clone's current branch (git rev-parse HEAD failed)"; return 1; }+ [[ -n "$branch" && "$branch" != HEAD ]] \+ || { mkt_guard_fail "the clone's branch (HEAD is detached, no tracking branch to compare)"; return 1; }+ remote_sha="$(git -C "$MKT_CLONE" rev-parse "origin/$branch" 2>/dev/null)" \+ || { mkt_guard_fail "the remote tip origin/$branch (git rev-parse failed)"; return 1; }+ local_sha="$(git -C "$MKT_CLONE" rev-parse HEAD 2>/dev/null)" \+ || { mkt_guard_fail "the clone's HEAD (git rev-parse failed)"; return 1; }[[ "$local_sha" != "$remote_sha" ]]}@@ -152,6 +196,39 @@ if [[ "$MKT_HEAD_BEFORE" != "$(git -C "$MKT_CLONE" rev-parse HEAD 2>/dev/null)"ok "catalogue advanced to $(git -C "$MKT_CLONE" log --oneline -1 2>/dev/null)"fi+# Second, independent proof: the newest release tag on the remote must not be+# ahead of what the catalogue says. The tip check above compares SHAs on one+# branch; this compares versions, so a clone that is "at tip" of the wrong+# branch, or a catalogue commit that never bumped marketplace.json, is caught+# too. Same fail-closed rule: no tag list, no run (unless --offline).+CAT_VER="$(jq -r --arg n "$PLUGIN" '.plugins[]|select(.name==$n).version' "$MKT_JSON" 2>/dev/null || true)"+REMOTE_TAG_VER=""; TAGS_OK=1+if REMOTE_TAGS="$(git -C "$MKT_CLONE" ls-remote --tags --refs origin 'v[0-9]*' 2>/dev/null)"; then+ REMOTE_TAG_VER="$(printf '%s\n' "$REMOTE_TAGS" | sed -E 's#.*refs/tags/v##' \+ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true)"+else+ TAGS_OK=0+fi+if [[ "$TAGS_OK" -eq 0 ]]; then+ mkt_guard_fail "the remote's release tags (git ls-remote --tags origin failed)"+elif [[ -z "$REMOTE_TAG_VER" ]]; then+ say " ${c_dim}remote has no vX.Y.Z tags — tag cross-check has nothing to compare${c_rst}"+elif [[ "$CAT_VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \+ && [[ "$CAT_VER" != "$REMOTE_TAG_VER" ]] \+ && [[ "$(printf '%s\n' "$CAT_VER" "$REMOTE_TAG_VER" | sort -V | head -1)" == "$CAT_VER" ]]; then+ err "catalogue behind remote tag v$REMOTE_TAG_VER (catalogue says $CAT_VER)"+ say " clone: $MKT_CLONE"+ say " at: $(git -C "$MKT_CLONE" log --oneline -1 2>/dev/null)"+ say " fix: the clone is not on the commit that published v$REMOTE_TAG_VER."+ say " Clean its tree, fast-forward it to origin's default branch, re-run."+ err "refusing to continue against a STALE CATALOGUE — every version below would be wrong"+ exit 1+elif [[ "$CAT_VER" == "$REMOTE_TAG_VER" ]]; then+ ok "catalogue $CAT_VER matches newest remote tag v$REMOTE_TAG_VER"+else+ say " ${c_dim}catalogue $CAT_VER is ahead of newest remote tag v$REMOTE_TAG_VER (release not tagged yet)${c_rst}"+fi+# ── 2. Resolve target version ──────────────────────────────────────────────step "2/11 Resolve target version"if [[ -n "$TARGET" ]]; then@@ -165,6 +242,25 @@ if [[ "$CUR" == "$NEW" && "$FORCE" -eq 0 ]]; thenwarn "already on $NEW. Use --force to re-materialise the cache (bug #61954 stale-cache guard)."fi+# Downgrade guard. "Upgrade" must never mean "go backwards". If the resolved+# target sorts below what is installed, stop here — before step 3 materialises+# it and step 5 deletes the newer caches. Applies to --to as well: an explicit+# target is still not an explicit downgrade; that needs --allow-downgrade.+semver_lt() { [[ "$1" != "$2" && "$(printf '%s\n' "$1" "$2" | sort -V | head -1)" == "$1" ]]; }+if [[ "$CUR" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && semver_lt "$NEW" "$CUR"; then+ if [[ "$ALLOW_DOWNGRADE" -eq 1 ]]; then+ warn "DOWNGRADE $CUR → $NEW permitted by --allow-downgrade"+ else+ err "refusing to DOWNGRADE $CUR → $NEW"+ say " installed: $CUR"+ say " target: $NEW ($([[ -n "$TARGET" ]] && echo '--to' || echo "from $MKT_JSON"))"+ say " hint: if the catalogue is right and the older version is wanted,"+ say " re-run with: ops-update --to $NEW --allow-downgrade"+ say " otherwise the catalogue is stale — fix the clone and re-run."+ exit 1+ fi+fi+# ── 3. Update the installed plugin ─────────────────────────────────────────step "3/11 Update installed plugin → $NEW"if [[ "$DRY" -eq 1 ]]; then@@ -201,15 +297,22 @@ step "5/11 Prune old cache versions"if [[ "$PRUNE" -eq 0 ]]; thensay " ${c_dim}(skipped: --no-prune)${c_rst}"else- pruned=0+ pruned=0; kept_newer=""for d in "$CACHE_ROOT"/*/; do[[ -d "$d" ]] || continuev="$(basename "$d")"[[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || continue[[ "$v" == "$NEW" ]] && continue+ # Never delete a cache NEWER than the target. Pruning only ever means+ # "remove what was superseded"; a version above $NEW was not superseded+ # by it. Only an explicit --allow-downgrade may take newer caches out.+ if semver_lt "$NEW" "$v" && [[ "$ALLOW_DOWNGRADE" -eq 0 ]]; then+ kept_newer="$kept_newer $v"; continue+ firun "rm -rf \"$d\""ok "pruned cache $v"; pruned=$((pruned+1))done+ [[ -n "$kept_newer" ]] && warn "kept cache(s) newer than $NEW:${kept_newer} (pass --allow-downgrade to prune them)"[[ "$pruned" -eq 0 ]] && say " ${c_dim}no old cache versions to prune${c_rst}"fidiff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.shindex 9ebb0635..8f6344d3 100755--- a/claude-ops/tests/run-all.sh+++ b/claude-ops/tests/run-all.sh@@ -41,6 +41,7 @@ run_suite "$TESTS_DIR/test-gog-account.sh"run_suite "$TESTS_DIR/test-ops-ci.sh"run_suite "$TESTS_DIR/test-ops-speedup.sh"run_suite "$TESTS_DIR/test-ops-update-stale-clone.sh"+run_suite "$TESTS_DIR/test-ops-update-downgrade-guard.sh"run_suite "$TESTS_DIR/test-ops-status.sh"run_suite "$TESTS_DIR/test-pid-performance-monitor.sh"run_suite "$TESTS_DIR/test-run-pressure-monitor-if-needed.sh"diff --git a/claude-ops/tests/test-ops-update-downgrade-guard.sh b/claude-ops/tests/test-ops-update-downgrade-guard.shnew file mode 100755index 00000000..72a4eecc--- /dev/null+++ b/claude-ops/tests/test-ops-update-downgrade-guard.sh@@ -0,0 +1,209 @@+#!/usr/bin/env bash+# Contract tests for bin/ops-update's downgrade guards.+#+# Regression (2026-09-11): the local marketplace clone sat on the commit for+# 3.10.13 with a dirty worktree while the remote had v3.10.15. `claude plugin+# marketplace update` reported success without moving it, the stale-clone guard+# returned "not stale" because one of its git calls failed (fail-open), step 2+# resolved 3.10.13, step 5 pruned the installed 3.10.14 and 3.10.15 caches, and+# the summary printed "3.10.15 → 3.10.13 ... ✓ upgrade complete". A downgrade+# dressed as an upgrade.+#+# Three guards now stand in the way, each tested here:+# 1. the clone check is fail-CLOSED (an unverifiable clone aborts; --offline warns)+# 2. the catalogue version may not be behind the newest remote tag+# 3. the target may not sort below the installed version (--allow-downgrade overrides)+#+# Throwaway git repos and a stubbed `claude` on PATH; nothing touches a real+# install. Public plugin: no real host paths or personal data.+set -euo pipefail++ROOT="$(cd "$(dirname "$0")/.." && pwd)"+BIN="$ROOT/bin/ops-update"+PASS=0+FAIL=0++pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }+fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }++echo "== ops-update downgrade guards =="++if ! command -v git >/dev/null 2>&1 || ! command -v jq >/dev/null 2>&1; then+ echo " SKIP: git and jq are both required"+ echo "test-ops-update-downgrade-guard.sh: 0 passed, 0 failed (skipped)"+ exit 0+fi++tmpdir=$(mktemp -d)+trap 'rm -rf "$tmpdir"' EXIT++git_quiet() { git -c init.defaultBranch=main -c [email protected] -c user.name=t "$@" >/dev/null 2>&1; }++# Fixture: a "remote" whose main says $catalogue_ver, tagged with each of+# $tags (comma-separated, may be empty), and a clone of it at main's tip laid+# out under $CLAUDE_CONFIG_DIR exactly as ops-update resolves it. Installed+# cache dirs are $caches (comma-separated).+make_fixture() {+ local base="$1" catalogue_ver="$2" tags="$3" caches="$4"+ local remote="$base/remote" clone="$base/cfg/plugins/marketplaces/ops-marketplace"+ local cache_root="$base/cfg/plugins/cache/ops-marketplace/ops"+ mkdir -p "$remote" "$base/cfg/plugins/marketplaces" "$base/home" "$cache_root"+ local c; for c in ${caches//,/ }; do mkdir -p "$cache_root/$c"; done+ git_quiet init "$remote"+ mkdir -p "$remote/.claude-plugin"+ printf '{"plugins":[{"name":"ops","version":"%s"}]}\n' "$catalogue_ver" >"$remote/.claude-plugin/marketplace.json"+ git_quiet -C "$remote" add -A+ git_quiet -C "$remote" commit -m "v$catalogue_ver"+ local t; for t in ${tags//,/ }; do git_quiet -C "$remote" tag "$t"; done+ git_quiet clone "$remote" "$clone"+ echo "$clone"+}++make_stub_path() {+ local base="$1"+ mkdir -p "$base/stubbin"+ cat >"$base/stubbin/claude" <<'STUB'+#!/usr/bin/env bash+if [ "${1:-}" = "plugin" ] && [ "${2:-}" = "marketplace" ] && [ "${3:-}" = "update" ]; then+ echo "Successfully updated marketplace: ${4:-}"+ exit 0+fi+exit 0+STUB+ chmod +x "$base/stubbin/claude"+ echo "$base/stubbin"+}++# Runs ops-update; output lands in $OUT, exit code in $RC. (Not a $(...)+# capture: that would run in a subshell and lose $RC.)+RC=0; OUT=""+run_update() {+ local base="$1"; shift+ local stub; stub="$(make_stub_path "$base")"+ set +e+ env HOME="$base/home" NO_COLOR=1 TERM=dumb \+ PATH="$stub:$PATH" \+ CLAUDE_CONFIG_DIR="$base/cfg" \+ bash "$BIN" "$@" >"$tmpdir/out.txt" 2>&1+ RC=$?+ set -e+ OUT="$(cat "$tmpdir/out.txt")"+}++# ── 1. Catalogue behind the newest remote tag → refuse, even with the clone at tip.+b1="$tmpdir/tag-behind"+make_fixture "$b1" 3.10.13 "v3.10.13,v3.10.15" 3.10.13 >/dev/null+run_update "$b1" --dry-run; out1="$OUT"+if [ "$RC" -ne 0 ]; then+ pass "catalogue behind remote tag exits non-zero"+else+ fail "catalogue behind remote tag exits non-zero (rc=$RC)"+fi+if grep -qF "catalogue behind remote tag v3.10.15 (catalogue says 3.10.13)" <<<"$out1"; then+ pass "names the remote tag and the catalogue version"+else+ fail "names the remote tag and the catalogue version (got: $(head -c 400 <<<"$out1"))"+fi+if grep -qE "target version:" <<<"$out1"; then+ fail "must not reach target resolution behind a stale catalogue"+else+ pass "does not reach target resolution behind a stale catalogue"+fi++# ── 2. Catalogue equal to the newest tag → passes the tag check.+b2="$tmpdir/tag-equal"+make_fixture "$b2" 3.10.15 "v3.10.14,v3.10.15" 3.10.15 >/dev/null+run_update "$b2" --dry-run; out2="$OUT"+if grep -qF "catalogue 3.10.15 matches newest remote tag v3.10.15" <<<"$out2"; then+ pass "catalogue equal to the newest tag passes the tag check"+else+ fail "catalogue equal to the newest tag passes the tag check (got: $(head -c 400 <<<"$out2"))"+fi++# ── 3. Installed 3.10.15, catalogue 3.10.13 (tags consistent) → DOWNGRADE refused.+b3="$tmpdir/downgrade"+make_fixture "$b3" 3.10.13 "v3.10.13" 3.10.14,3.10.15 >/dev/null+run_update "$b3" --dry-run; out3="$OUT"+if [ "$RC" -ne 0 ] && grep -qF "refusing to DOWNGRADE 3.10.15 → 3.10.13" <<<"$out3"; then+ pass "installed 3.10.15 with catalogue 3.10.13 is refused as a DOWNGRADE"+else+ fail "installed 3.10.15 with catalogue 3.10.13 is refused as a DOWNGRADE (rc=$RC, got: $(head -c 400 <<<"$out3"))"+fi+if grep -qF -- "--to 3.10.13 --allow-downgrade" <<<"$out3"; then+ pass "hint names the explicit override"+else+ fail "hint names the explicit override (got: $(head -c 400 <<<"$out3"))"+fi+if grep -qE "pruned cache 3\.10\.1[45]" <<<"$out3"; then+ fail "must not reach the prune step on a refused downgrade"+else+ pass "does not reach the prune step on a refused downgrade"+fi++# ── 4. --to below installed, without --allow-downgrade → still refused.+run_update "$b3" --dry-run --to 3.10.13; out4="$OUT"+if [ "$RC" -ne 0 ] && grep -qF "refusing to DOWNGRADE 3.10.15 → 3.10.13" <<<"$out4"; then+ pass "--to below the installed version is refused without --allow-downgrade"+else+ fail "--to below the installed version is refused without --allow-downgrade (rc=$RC)"+fi++# ── 5. --to below installed WITH --allow-downgrade, --dry-run → proceeds, exits 0.+run_update "$b3" --dry-run --to 3.10.13 --allow-downgrade; out5="$OUT"+if [ "$RC" -eq 0 ]; then+ pass "--to 3.10.13 --allow-downgrade --dry-run exits 0"+else+ fail "--to 3.10.13 --allow-downgrade --dry-run exits 0 (rc=$RC, got: $(tail -c 400 <<<"$out5"))"+fi+if grep -qF "DOWNGRADE 3.10.15 → 3.10.13 permitted by --allow-downgrade" <<<"$out5"; then+ pass "an allowed downgrade is announced as one"+else+ fail "an allowed downgrade is announced as one (got: $(head -c 400 <<<"$out5"))"+fi+if grep -qE "\[dry-run\] rm -rf .*3\.10\.15" <<<"$out5"; then+ pass "with --allow-downgrade the newer cache would be pruned"+else+ fail "with --allow-downgrade the newer cache would be pruned (got: $(grep -n prune <<<"$out5" | head -3))"+fi++# ── 6. Same version installed and in catalogue → not a downgrade, exits 0.+b6="$tmpdir/same"+make_fixture "$b6" 3.10.15 "v3.10.15" 3.10.15 >/dev/null+run_update "$b6" --dry-run; out6="$OUT"+if [ "$RC" -eq 0 ] && ! grep -qF "DOWNGRADE" <<<"$out6"; then+ pass "same version is not treated as a downgrade"+else+ fail "same version is not treated as a downgrade (rc=$RC, got: $(head -c 400 <<<"$out6"))"+fi++# ── 7. Remote unreachable → fail-CLOSED; --offline warns and continues.+b7="$tmpdir/offline"+make_fixture "$b7" 3.10.15 "v3.10.15" 3.10.15 >/dev/null+rm -rf "$b7/remote"+run_update "$b7" --dry-run; out7="$OUT"+if [ "$RC" -ne 0 ] && grep -qF "could not verify the marketplace clone against its remote" <<<"$out7"; then+ pass "an unreachable remote aborts the run (fail-closed)"+else+ fail "an unreachable remote aborts the run (rc=$RC, got: $(head -c 400 <<<"$out7"))"+fi+run_update "$b7" --dry-run --offline; out7b="$OUT"+if [ "$RC" -eq 0 ] && grep -qF -- "--offline: could not verify" <<<"$out7b" && grep -qE "target version: *3\.10\.15" <<<"$out7b"; then+ pass "--offline turns the unreachable remote into a warning and continues"+else+ fail "--offline turns the unreachable remote into a warning and continues (rc=$RC, got: $(head -c 400 <<<"$out7b"))"+fi++# ── 8. --offline does not license a downgrade.+b8="$tmpdir/offline-downgrade"+make_fixture "$b8" 3.10.13 "v3.10.13" 3.10.15 >/dev/null+rm -rf "$b8/remote"+run_update "$b8" --dry-run --offline; out8="$OUT"+if [ "$RC" -ne 0 ] && grep -qF "refusing to DOWNGRADE 3.10.15 → 3.10.13" <<<"$out8"; then+ pass "--offline still refuses a downgrade"+else+ fail "--offline still refuses a downgrade (rc=$RC, got: $(head -c 400 <<<"$out8"))"+fi++echo ""+echo "test-ops-update-downgrade-guard.sh: $PASS passed, $FAIL failed"+[ "$FAIL" -eq 0 ]