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(post-update-migrate): keep current/.in_use, only clear the orphan marker (#757)
Aurora Capitalb2bc475e4ea9
diff --git a/claude-ops/bin/ops-post-update-migrate b/claude-ops/bin/ops-post-update-migrateindex 53daf2e0..4086e359 100755--- a/claude-ops/bin/ops-post-update-migrate+++ b/claude-ops/bin/ops-post-update-migrate@@ -77,18 +77,25 @@ refresh_current_directory() {fifi- # Never let the cache-GC bookkeeping of a version dir ride into current/.+ # Never let a version dir's orphan marker ride into current/.# Claude Code marks a version dir it no longer recognises with .orphaned_at# and deletes it once that marker ages past the grace period, skipping only- # dirs still listed as an installPath. If a stale (already-aged) marker is- # copied into current/ and installPath later moves off current/ — a plugin- # reinstall, or the marketplace remove+add that ops-update performs — the- # grace period is already spent, so current/ is deleted on the next sweep- # while live sessions still resolve CLAUDE_PLUGIN_ROOT through it. The- # copied .in_use PIDs belong to the version dir and are dead, so they do- # not hold it open either. cp -rp has no exclude, so clear both here.+ # dirs still listed as an installPath. A copied marker is already aged, so+ # if installPath later moves off current/ — a plugin reinstall, or the+ # marketplace remove+add that ops-update performs — the grace period is+ # already spent and current/ is deleted on the next sweep while live+ # sessions still resolve CLAUDE_PLUGIN_ROOT through it. cp -rp has no+ # exclude, so clear it here too, and clear any earlier leak.rm -f "$current_dir/.orphaned_at" 2>/dev/null || true- rm -rf "$current_dir/.in_use" 2>/dev/null || true++ # current/.in_use is deliberately left alone. Every session that resolves+ # current/ as its plugin root registers its own live PID there, and that+ # registry is what stops the sweeper deleting current/ out from under them+ # if installPath ever moves off it. Removing it would drop exactly the+ # protection this function exists to preserve. Excluding it from the rsync+ # above already stops the version dir's PIDs from replacing the live ones;+ # under the cp fallback they merely get added, and the sweeper prunes dead+ # entries itself.if [[ -f "$installed_json" ]]; thenif python3 - "$installed_json" "$current_dir" <<'PYEOF' 2>/dev/nulldiff --git a/claude-ops/tests/test-post-update-migrate-current-guard.sh b/claude-ops/tests/test-post-update-migrate-current-guard.shindex 6141b6b4..2ba37249 100755--- a/claude-ops/tests/test-post-update-migrate-current-guard.sh+++ b/claude-ops/tests/test-post-update-migrate-current-guard.sh@@ -39,6 +39,12 @@ run_case() {# Pre-existing leak in current/, to prove we clean up as well as prevent.printf '1000000000000\n' >"$current_dir/.orphaned_at"+ # A live session that resolved current/ as its plugin root and registered+ # itself there. This registry is what stops the sweeper deleting current/+ # out from under it, so the refresh must not drop it.+ mkdir -p "$current_dir/.in_use"+ printf '{"pid":%s}\n' "$$" >"$current_dir/.in_use/$$"+cat >"$installed" <<JSON{"plugins": {@@ -89,8 +95,14 @@ JSON# 2. GC bookkeeping must not be present in current/[[ ! -e "$current_dir/.orphaned_at" ]] ||fail "$label: .orphaned_at leaked into current/ — cache GC would delete the live plugin root"- [[ ! -e "$current_dir/.in_use" ]] ||- fail "$label: stale .in_use leaked into current/"+ [[ -f "$current_dir/.in_use/$$" ]] ||+ fail "$label: dropped the live .in_use registration in current/ — the sweeper could then delete it under a running session"+ # rsync excludes .in_use outright. cp -rp has no exclude, so it merges the+ # version dir's dead PIDs in; harmless, the sweeper prunes those itself.+ if [[ "$mode" == "rsync" ]]; then+ [[ ! -e "$current_dir/.in_use/999999" ]] ||+ fail "$label: version dir's stale .in_use PID was copied into current/"+ fi# 3. installPath repointed, other plugins untouched, mode preservedpython3 - "$installed" "$current_dir" <<'PY' || fail "$label: installed_plugins.json assertions failed"