Skip to content

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.

Fix plugin current cache downgrade (#959)

Aurora Capital66256963de45
diff --git a/claude-ops/CHANGELOG.md b/claude-ops/CHANGELOG.md
index 63c46a26..41341257 100644
--- a/claude-ops/CHANGELOG.md
+++ b/claude-ops/CHANGELOG.md
@@ -2,6 +2,12 @@
## Unreleased
+- Fixed `ops-post-update-migrate` so a SessionStart hook from an older cached
+ plugin version cannot rsync its stale tree over a newer `cache/ops/current`.
+
+- Bounded the `ops-speedup` Docker reclaimable-space probe so an unavailable
+ Docker daemon cannot hang diagnostics or the full test suite indefinitely.
+
## [3.10.13] - 2026-09-10
- Removed every hard-coded Claude model id and `model:` frontmatter pin; agents, skills and cron scripts now inherit the session default (env-overridable per script).
diff --git a/claude-ops/bin/ops-post-update-migrate b/claude-ops/bin/ops-post-update-migrate
index e3b0a06b..8ba959cd 100755
--- a/claude-ops/bin/ops-post-update-migrate
+++ b/claude-ops/bin/ops-post-update-migrate
@@ -81,7 +81,8 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null' EXIT
# Always refresh current/ + installPath — must run on every cache materialization,
# including same-version force-reinstalls where the per-version sentinel already exists.
refresh_current_directory() {
- local cache_parent current_dir installed_json root_real current_real
+ local cache_parent current_dir installed_json root_real current_real current_version
+ local refuse_refresh=0
cache_parent="$(dirname "$PLUGIN_ROOT")"
current_dir="$cache_parent/current"
installed_json="$PLUGINS_DIR/installed_plugins.json"
@@ -100,8 +101,35 @@ refresh_current_directory() {
root_real="$(cd "$PLUGIN_ROOT" 2>/dev/null && pwd -P || echo "$PLUGIN_ROOT")"
current_real="$(cd "$current_dir" 2>/dev/null && pwd -P || echo "$current_dir")"
+ # SessionStart also fires in long-lived sessions whose PLUGIN_ROOT still
+ # points at an older version directory. Never let such a session rsync its
+ # stale tree over a newer current/ with --delete. Keep running the metadata
+ # repair below, because installed_plugins.json must still resolve current/.
+ if [[ "$root_real" != "$current_real" && -f "$current_dir/.claude-plugin/plugin.json" ]]; then
+ current_version=$(python3 -c "import json,sys; print(json.load(open(sys.argv[1]))['version'])" \
+ "$current_dir/.claude-plugin/plugin.json" 2>/dev/null || true)
+ if [[ -n "$current_version" && "$VERSION" != "unknown" ]] && \
+ python3 - "$current_version" "$VERSION" <<'PYEOF' 2>/dev/null
+import re, sys
+
+def numeric_version(value):
+ match = re.fullmatch(r"[vV]?(\d+(?:\.\d+)*)", value)
+ return tuple(map(int, match.group(1).split("."))) if match else None
+
+current = numeric_version(sys.argv[1])
+source = numeric_version(sys.argv[2])
+sys.exit(0 if current is not None and source is not None and current > source else 1)
+PYEOF
+ then
+ refuse_refresh=1
+ log " skip: refuse to downgrade current/ from $current_version to $VERSION"
+ fi
+ fi
+
if [[ "$root_real" == "$current_real" ]]; then
log " skip: PLUGIN_ROOT already == current/ ($current_real) — no self-rsync"
+ elif [[ "$refuse_refresh" == "1" ]]; then
+ :
elif command -v rsync >/dev/null 2>&1; then
if rsync -a --delete \
--exclude '.orphaned_at' --exclude '.in_use' \
diff --git a/claude-ops/bin/ops-speedup b/claude-ops/bin/ops-speedup
index 6ac7ef69..6a1b8b4a 100755
--- a/claude-ops/bin/ops-speedup
+++ b/claude-ops/bin/ops-speedup
@@ -174,7 +174,16 @@ to_mb() {
docker_reclaimable_mb() {
command -v docker >/dev/null 2>&1 || { echo 0; return; }
- to_mb "$(docker system df --format '{{.Reclaimable}}' 2>/dev/null | head -1)"
+ local reclaimable
+ if command -v timeout >/dev/null 2>&1; then
+ reclaimable=$(timeout 5 docker system df --format '{{.Reclaimable}}' 2>/dev/null | head -1) || { echo 0; return; }
+ elif command -v gtimeout >/dev/null 2>&1; then
+ reclaimable=$(gtimeout 5 docker system df --format '{{.Reclaimable}}' 2>/dev/null | head -1) || { echo 0; return; }
+ else
+ echo 0
+ return
+ fi
+ to_mb "$reclaimable"
}
json_escape() {
diff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.sh
index 3ff33ee4..9ebb0635 100755
--- a/claude-ops/tests/run-all.sh
+++ b/claude-ops/tests/run-all.sh
@@ -54,6 +54,7 @@ run_suite "$TESTS_DIR/test-claude-invoke.sh"
run_suite "$TESTS_DIR/test-staged-enrollment.sh"
run_suite "$TESTS_DIR/test-coordination-provisioning.sh"
run_suite "$TESTS_DIR/test-post-update-migrate-sentinel.sh"
+run_suite "$TESTS_DIR/test-post-update-migrate-current-guard.sh"
run_suite "$TESTS_DIR/test-migrate-launchctl-domain-isolation.sh"
run_suite "$TESTS_DIR/test-template.sh"
run_suite "$TESTS_DIR/test-claude-md.sh"
diff --git a/claude-ops/tests/test-ops-speedup.sh b/claude-ops/tests/test-ops-speedup.sh
index 5c708f6b..df42a218 100644
--- a/claude-ops/tests/test-ops-speedup.sh
+++ b/claude-ops/tests/test-ops-speedup.sh
@@ -54,6 +54,7 @@ assert_true "has runtime-first health model" grep -q 'runtime-first' "$BIN"
assert_true "CPU hog kill gated by aggressive" grep -q 'Despite the legacy name, default cleanup only demotes hogs' "$BIN"
assert_true "GPU probe uses ioreg without sudo" grep -q 'ioreg -r -d1 -w0 -c IOGPU' "$BIN"
assert_true "long-lived hog threshold is 3 hours" grep -q 'elapsed >= 10800' "$BIN"
+assert_true "Docker reclaimable probe is timeout-bounded" grep -Eq '(g?timeout) [0-9]+ docker system df' "$BIN"
# Drive the shipped process-state classifier through the real binary. A PID that
# appears blocked in only one sample is transient; only the PID blocked in all
diff --git a/claude-ops/tests/test-post-update-migrate-current-guard.sh b/claude-ops/tests/test-post-update-migrate-current-guard.sh
index 2ba37249..45827ec7 100755
--- a/claude-ops/tests/test-post-update-migrate-current-guard.sh
+++ b/claude-ops/tests/test-post-update-migrate-current-guard.sh
@@ -1,10 +1,12 @@
#!/usr/bin/env bash
# Guards refresh_current_directory in bin/ops-post-update-migrate:
# 1. cache-GC bookkeeping (.orphaned_at, .in_use) never rides into current/
-# 2. installed_plugins.json is rewritten atomically, keeping its mode
+# 2. stale sessions cannot downgrade current/, while forward updates still work
+# 3. installed_plugins.json is rewritten atomically, keeping its mode
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+SCRIPT="${SCRIPT:-$ROOT/bin/ops-post-update-migrate}"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
@@ -86,7 +88,7 @@ JSON
CLAUDE_CONFIG_DIR="$config_dir" \
CLAUDE_PLUGIN_DATA_DIR="$data_dir" \
PATH="$path_override" \
- bash "$ROOT/bin/ops-post-update-migrate"
+ bash "$SCRIPT"
# 1. real content copied through
[[ -f "$current_dir/bin/marker-file" ]] ||
@@ -133,7 +135,78 @@ PY
printf 'ok: %s\n' "$label"
}
+run_downgrade_case() {
+ local base="$TMP/refuse-downgrade"
+ local plugin_root="$base/cache/ops-marketplace/ops/2.0.0"
+ local current_dir="$base/cache/ops-marketplace/ops/current"
+ local config_dir="$base/config"
+ local data_dir="$base/data"
+
+ mkdir -p "$plugin_root/.claude-plugin" "$plugin_root/bin" \
+ "$current_dir/.claude-plugin" "$current_dir/bin" \
+ "$config_dir/plugins" "$data_dir/.migrated" "$base/home"
+ printf '{"version":"2.0.0"}\n' >"$plugin_root/.claude-plugin/plugin.json"
+ printf 'older\n' >"$plugin_root/bin/older-marker"
+ printf '{"version":"3.0.0"}\n' >"$current_dir/.claude-plugin/plugin.json"
+ printf 'newer\n' >"$current_dir/bin/newer-marker"
+ touch "$data_dir/.migrated/v2.0.0"
+
+ HOME="$base/home" \
+ CLAUDE_PLUGIN_ROOT="$plugin_root" \
+ CLAUDE_CONFIG_DIR="$config_dir" \
+ CLAUDE_PLUGIN_DATA_DIR="$data_dir" \
+ bash "$SCRIPT"
+
+ [[ -f "$current_dir/bin/newer-marker" ]] ||
+ fail "refuse-downgrade: older plugin root replaced newer current/"
+ [[ ! -e "$current_dir/bin/older-marker" ]] ||
+ fail "refuse-downgrade: older payload was copied into newer current/"
+ [[ "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$current_dir/.claude-plugin/plugin.json")" == "3.0.0" ]] ||
+ fail "refuse-downgrade: current/ version was downgraded"
+
+ printf 'ok: refuse-downgrade\n'
+}
+
+run_forward_update_case() {
+ local base="$TMP/allow-forward-update"
+ local plugin_root="$base/cache/ops-marketplace/ops/3.0.0"
+ local current_dir="$base/cache/ops-marketplace/ops/current"
+ local config_dir="$base/config"
+ local data_dir="$base/data"
+
+ mkdir -p "$plugin_root/.claude-plugin" "$plugin_root/bin" \
+ "$current_dir/.claude-plugin" "$current_dir/bin" \
+ "$config_dir/plugins" "$data_dir/.migrated" "$base/home"
+ printf '{"version":"3.0.0"}\n' >"$plugin_root/.claude-plugin/plugin.json"
+ printf 'newer\n' >"$plugin_root/bin/newer-marker"
+ printf '{"version":"2.0.0"}\n' >"$current_dir/.claude-plugin/plugin.json"
+ # Avoid rsync's size+mtime quick-check treating equal-length fixture files
+ # created in the same second as unchanged.
+ touch -t 203001010000 "$plugin_root/.claude-plugin/plugin.json"
+ printf 'older\n' >"$current_dir/bin/older-marker"
+ touch "$data_dir/.migrated/v3.0.0"
+
+ HOME="$base/home" \
+ CLAUDE_PLUGIN_ROOT="$plugin_root" \
+ CLAUDE_CONFIG_DIR="$config_dir" \
+ CLAUDE_PLUGIN_DATA_DIR="$data_dir" \
+ bash "$SCRIPT"
+
+ [[ -f "$current_dir/bin/newer-marker" ]] ||
+ fail "allow-forward-update: newer plugin root did not refresh current/"
+ [[ ! -e "$current_dir/bin/older-marker" ]] ||
+ fail "allow-forward-update: stale payload survived refresh"
+ local actual_version
+ actual_version="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$current_dir/.claude-plugin/plugin.json")"
+ [[ "$actual_version" == "3.0.0" ]] ||
+ fail "allow-forward-update: current/ version is $actual_version, want 3.0.0"
+
+ printf 'ok: allow-forward-update\n'
+}
+
run_case rsync-path rsync
run_case cp-fallback nossync
+run_downgrade_case
+run_forward_update_case
-printf 'PASS: current/ stays free of cache-GC markers; installed_plugins.json rewritten atomically\n'
+printf 'PASS: current/ stays free of cache-GC markers, blocks downgrades, permits forward updates, and rewrites installed_plugins.json atomically\n'