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: outbound-guard installed-copy drift + ops-inbox-scan silent crash on trailing flag (#936)
Aurora Capitalb0c6035ac404
diff --git a/claude-ops/bin/ops-inbox-scan b/claude-ops/bin/ops-inbox-scanindex 5c706291..531d77cf 100755--- a/claude-ops/bin/ops-inbox-scan+++ b/claude-ops/bin/ops-inbox-scan@@ -68,23 +68,36 @@ AUTO_PEERS=1while [ $# -gt 0 ]; docase "$1" in- --whatsapp-only) DO_EMAIL=0 ;;- --email-only) DO_WA=0 ;;- --days) DAYS="${2:-7}"; shift ;;- --email-query) EMAIL_QUERY="${2:-in:inbox}"; shift ;;- --email-max) EMAIL_MAX="${2:-400}"; shift ;;- --gmail-account) GMAIL_ACCOUNT="${2:-}"; shift ;;- --wa-store) WA_STORE_OVERRIDE="${2:-}"; shift ;;- --bridge-port) BRIDGE_PORT_OVERRIDE="${2:-}"; shift ;;- --all-accounts) ALL_ACCOUNTS=1 ;;- --peer-store) PEER_STORES="${PEER_STORES}${PEER_STORES:+:}${2:-}"; shift ;;- --no-peer-stores) AUTO_PEERS=0 ;;- --pretty) PRETTY=1 ;;+ --whatsapp-only) DO_EMAIL=0; shift ;;+ --email-only) DO_WA=0; shift ;;+ --days)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --days requires a value" >&2; exit 2; }+ DAYS="$2"; shift 2 ;;+ --email-query)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --email-query requires a value" >&2; exit 2; }+ EMAIL_QUERY="$2"; shift 2 ;;+ --email-max)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --email-max requires a value" >&2; exit 2; }+ EMAIL_MAX="$2"; shift 2 ;;+ --gmail-account)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --gmail-account requires a value" >&2; exit 2; }+ GMAIL_ACCOUNT="$2"; shift 2 ;;+ --wa-store)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --wa-store requires a value" >&2; exit 2; }+ WA_STORE_OVERRIDE="$2"; shift 2 ;;+ --bridge-port)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --bridge-port requires a value" >&2; exit 2; }+ BRIDGE_PORT_OVERRIDE="$2"; shift 2 ;;+ --all-accounts) ALL_ACCOUNTS=1; shift ;;+ --peer-store)+ [ $# -ge 2 ] || { echo "ops-inbox-scan: --peer-store requires a value" >&2; exit 2; }+ PEER_STORES="${PEER_STORES}${PEER_STORES:+:}$2"; shift 2 ;;+ --no-peer-stores) AUTO_PEERS=0; shift ;;+ --pretty) PRETTY=1; shift ;;-h|--help)grep '^#' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;*) echo "ops-inbox-scan: unknown arg: $1" >&2; exit 2 ;;esac- shiftdone# ------------------------------------------------- every agent-enabled acct ----diff --git a/claude-ops/scripts/outbound-guard/outbound_guard.py b/claude-ops/scripts/outbound-guard/outbound_guard.pyindex 298dd835..a213a45d 100644--- a/claude-ops/scripts/outbound-guard/outbound_guard.py+++ b/claude-ops/scripts/outbound-guard/outbound_guard.py@@ -16,9 +16,12 @@ content. When a second guard sees a fingerprint already recorded withinSPENT_WINDOW_SEC, that is the same message, already paid for. It passes and nothing isdeducted. One message costs exactly one unit no matter how many layers it crosses.-The Node twin lives at ../outbound-guard.mjs (and, when installed, at-~/.claude/mcp-proxy/outbound-guard.mjs). It reads and writes this same file with the-same rules, and the test suite asserts both sides agree on the fingerprint.+The Node twin lives at ../outbound-guard.mjs. `sync-installed-copy.sh` mirrors it,+verbatim and on every session start, to ~/.claude/mcp-proxy/outbound-guard.mjs so the+MCP proxy always runs the current schema instead of a copy frozen at whatever this+file looked like when someone last installed it by hand. Both copies read and write+this same file with the same rules, and the test suite asserts both sides agree on+the fingerprint."""from __future__ import annotationsdiff --git a/claude-ops/scripts/outbound-guard/sync-installed-copy.sh b/claude-ops/scripts/outbound-guard/sync-installed-copy.shnew file mode 100755index 00000000..481639d9--- /dev/null+++ b/claude-ops/scripts/outbound-guard/sync-installed-copy.sh@@ -0,0 +1,37 @@+#!/usr/bin/env bash+# Keep the installed Node twin of the outbound guard current with the repo copy.+#+# outbound_guard.py documents that the Node side "lives at ../outbound-guard.mjs+# (and, when installed, at ~/.claude/mcp-proxy/outbound-guard.mjs)" and that it+# "reads and writes this same file with the same rules". Nothing enforced that:+# there was no install step and no refresh step, so a machine either had no+# installed copy at all, or — worse — had one copied in once and never touched+# again. Every later change to outbound-guard.mjs (a new field on the state file,+# a rule change) would silently NOT reach the installed copy, so the two+# "identical" implementations the README promises would drift onto different+# schemas without either side failing loudly.+#+# This script makes the installed copy a straight, idempotent mirror of the repo+# source. It only ever OVERWRITES the installed file with the current repo+# content — there is no partial-merge logic to drift, so re-running it is always+# safe and always converges to whatever ships in this checkout.+set -euo pipefail++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+SRC="$HERE/outbound-guard.mjs"+DEST_DIR="${HOME}/.claude/mcp-proxy"+DEST="$DEST_DIR/outbound-guard.mjs"++if [ ! -f "$SRC" ]; then+ echo "sync-installed-copy: source missing at $SRC" >&2+ exit 1+fi++mkdir -p "$DEST_DIR"+# Copy-then-rename: never leaves a half-written file at $DEST for a proxy+# process to read mid-write.+tmp="$DEST.tmp.$$"+cp "$SRC" "$tmp"+mv "$tmp" "$DEST"++echo "outbound-guard: synced installed copy -> $DEST"diff --git a/claude-ops/scripts/setup.sh b/claude-ops/scripts/setup.shindex 5657047f..73507a74 100755--- a/claude-ops/scripts/setup.sh+++ b/claude-ops/scripts/setup.sh@@ -45,6 +45,15 @@ if [ -f "$PLUGIN_ROOT/package.json" ] && command -v node &>/dev/null; thenfifi+# ─── Keep the installed outbound-guard Node twin current ───────────+# outbound_guard.py documents an installed copy at ~/.claude/mcp-proxy/outbound-guard.mjs+# that shares its state file and rules. Without a refresh step that copy silently drifts+# onto an old schema every time outbound-guard.mjs changes in the repo. Re-run on every+# session start; the sync script is an idempotent overwrite so this is always safe.+if [ -f "$PLUGIN_ROOT/scripts/outbound-guard/sync-installed-copy.sh" ]; then+ bash "$PLUGIN_ROOT/scripts/outbound-guard/sync-installed-copy.sh" >/dev/null 2>&1 || true+fi+# ─── Report only problems ───────────────────────────────────────────if [ ${#INSTALLED[@]} -gt 0 ]; thenecho " ops: auto-installed ${INSTALLED[*]}"diff --git a/claude-ops/tests/outbound-guard/run.sh b/claude-ops/tests/outbound-guard/run.shindex 0bc80a0e..5746a563 100755--- a/claude-ops/tests/outbound-guard/run.sh+++ b/claude-ops/tests/outbound-guard/run.sh@@ -29,7 +29,8 @@ for suite in \"$HERE/test-shared-guard.sh" \"$HERE/test-hook-matrix.py" \"$HERE/test-false-positives.py" \- "$HERE/test-broken-alias.py"; do+ "$HERE/test-broken-alias.py" \+ "$HERE/test-installed-copy-sync.sh"; doname="$(basename "$suite")"if [ ! -f "$suite" ]; thendiff --git a/claude-ops/tests/outbound-guard/test-installed-copy-sync.sh b/claude-ops/tests/outbound-guard/test-installed-copy-sync.shnew file mode 100755index 00000000..645290df--- /dev/null+++ b/claude-ops/tests/outbound-guard/test-installed-copy-sync.sh@@ -0,0 +1,53 @@+#!/usr/bin/env bash+# Defect: outbound_guard.py's docstring claims the Node twin is "installed at+# ~/.claude/mcp-proxy/outbound-guard.mjs" and "reads and writes this same file with+# the same rules" as the repo copy. Nothing in the repo ever creates or refreshes that+# installed copy, so on a real machine the claim is either false (no file at all) or,+# worse, true-but-stale: a copy installed once and never updated again drifts onto an+# outdated schema every time outbound-guard.mjs changes in the repo, silently+# disagreeing with outbound_guard.py about state-file shape.+#+# This test proves scripts/outbound-guard/sync-installed-copy.sh keeps that installed+# copy byte-identical to the repo source, including refreshing a copy that was already+# there under an old (stale) schema.+#+# Run: bash claude-ops/tests/outbound-guard/test-installed-copy-sync.sh+set -u+HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+SRC="$(cd "$HERE/../../scripts/outbound-guard" && pwd)"+SYNC="$SRC/sync-installed-copy.sh"+MJS="$SRC/outbound-guard.mjs"++fail=0+chk(){ if [ "$2" = "$3" ]; then echo " ok $1"; else echo " FAIL $1: got '$2', expected '$3'"; fail=$((fail+1)); fi; }++TMPHOME="$(mktemp -d)"+trap 'rm -rf "$TMPHOME"' EXIT++echo "1. sync script exists and is executable"+if [ -x "$SYNC" ]; then echo " ok sync script present"; else echo " FAIL sync script missing at $SYNC"; fail=$((fail+1)); fi++echo "2. fresh install: no installed copy yet -> sync creates one matching the repo"+HOME="$TMPHOME" bash "$SYNC" >/dev/null 2>&1+INSTALLED="$TMPHOME/.claude/mcp-proxy/outbound-guard.mjs"+if [ -f "$INSTALLED" ]; then echo " ok installed copy created"; else echo " FAIL installed copy not created at $INSTALLED"; fail=$((fail+1)); fi+if diff -q "$MJS" "$INSTALLED" >/dev/null 2>&1; then+ echo " ok installed copy byte-identical to repo"+else+ echo " FAIL installed copy differs from repo source"+ fail=$((fail+1))+fi++echo "3. stale copy: an old schema on disk must be refreshed, not left alone"+echo "// old, pre-consolidation schema — must NOT survive a sync" > "$INSTALLED"+HOME="$TMPHOME" bash "$SYNC" >/dev/null 2>&1+if diff -q "$MJS" "$INSTALLED" >/dev/null 2>&1; then+ echo " ok stale installed copy refreshed to current schema"+else+ echo " FAIL stale installed copy was NOT refreshed (still on old schema)"+ fail=$((fail+1))+fi++echo+[ "$fail" -eq 0 ] && echo "ALL GOOD" || echo "$fail FAIL"+exit $faildiff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.shindex f59ec325..81b72861 100755--- a/claude-ops/tests/run-all.sh+++ b/claude-ops/tests/run-all.sh@@ -65,6 +65,7 @@ run_suite "$TESTS_DIR/test-agent-teams.sh"run_suite "$TESTS_DIR/test-pocket-env-broker.sh"run_suite "$TESTS_DIR/test-ops-pocket-notify.sh"run_suite "$TESTS_DIR/test-ops-inbox-zero.sh"+run_suite "$TESTS_DIR/test-ops-inbox-scan-arg-parse.sh"run_suite "$TESTS_DIR/test-ops-wa-accounts.sh"run_suite "$TESTS_DIR/test-ops-daemon-manager.sh"run_suite "$TESTS_DIR/test-ops-package.sh"diff --git a/claude-ops/tests/test-ops-inbox-scan-arg-parse.sh b/claude-ops/tests/test-ops-inbox-scan-arg-parse.shnew file mode 100755index 00000000..fce0eb14--- /dev/null+++ b/claude-ops/tests/test-ops-inbox-scan-arg-parse.sh@@ -0,0 +1,71 @@+#!/usr/bin/env bash+# Regressietest voor het echte defect: ops-inbox-scan stierf onder `set -euo pipefail`+# wanneer een waarde-vlag (--days, --email-query, --email-max, --gmail-account,+# --wa-store, --bridge-port, --peer-store) als LAATSTE CLI-argument stond, zonder+# waarde erna.+#+# Oorzaak: de case-tak deed `shift` om de waarde weg te schuiven, en de lus deed+# daarna NOG een `shift` voor de vlag zelf. Als $# na de eerste shift al 0 was,+# faalde de tweede shift ("shift count out of range", exit 1) en `set -e` liet het+# hele script fataal sterven — zonder enige foutmelding op stderr. Dit gebeurde+# lang voordat de embedded Python op regel ~135 draait; die regel was symptoom,+# niet oorzaak.+#+# We isoleren alleen het argument-parse-gedrag (geen echte WhatsApp/Gmail-scan+# nodig): met -h/--help is de rest van het script een no-op zodra de parse-lus+# voltooid is, dus een geslaagde parse eindigt met exit 0 en de help-tekst.+#+# Run: bash claude-ops/tests/test-ops-inbox-scan-arg-parse.sh+set -uo pipefail++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+SCAN="${OPS_INBOX_SCAN:-$HERE/../bin/ops-inbox-scan}"++fail=0+chk() {+ # $1=label $2=actual_exit $3=expected_exit+ if [ "$2" = "$3" ]; then+ echo " ok $1 (exit=$2)"+ else+ echo " FAIL $1: got exit=$2, expected exit=$3"+ fail=$((fail + 1))+ fi+}++echo "1. value-flags as the LAST arg (no value follows) must fail LOUDLY (exit 2), not"+echo " die silently on an internal 'shift count out of range' (exit 1, no stderr)"+for flag in --days --email-query --email-max --gmail-account --wa-store --bridge-port --peer-store; do+ out="$(bash "$SCAN" --whatsapp-only --email-only "$flag" 2>&1)"+ rc=$?+ # --wa-store/--bridge-port additionally require each other, so they may exit 2+ # earlier for a different, already-correct reason; any clean 2 is acceptable.+ chk "'$flag' as the last, valueless arg" "$rc" "2"+ case "$out" in+ *"unbound variable"*|*"shift count out of range"*)+ echo " FAIL $flag: raw shell error leaked to output: $out"+ fail=$((fail + 1))+ ;;+ esac+ case "$out" in+ *"requires a value"*|*"cannot be combined"*) : ;;+ *) echo " FAIL $flag: no explanatory error message (got: $out)"; fail=$((fail + 1)) ;;+ esac+done++echo "2. a genuinely missing value at end of argv must fail LOUDLY, not silently die"+out="$(bash "$SCAN" --days 2>&1)"+rc=$?+chk "'--days' alone (no value, no other args)" "$rc" "2"+case "$out" in+ *"requires a value"*) echo " ok error message names the missing value" ;;+ *) echo " FAIL error message does not explain the missing value: $out"; fail=$((fail + 1)) ;;+esac++echo "3. normal usage still works (no regression on the happy path)"+out="$(bash "$SCAN" --days 3 --help 2>&1)"+rc=$?+chk "'--days 3 --help'" "$rc" "0"++echo+[ "$fail" -eq 0 ] && echo "ALL GOOD" || echo "$fail FAIL"+exit "$fail"