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-merge): keep read-only upstreams out of the merge queue (#799)
Aurora Capital07d89c29c1e7
diff --git a/claude-ops/bin/ops-merge-scan b/claude-ops/bin/ops-merge-scanindex 3109e805..b70fc334 100755--- a/claude-ops/bin/ops-merge-scan+++ b/claude-ops/bin/ops-merge-scan@@ -12,8 +12,21 @@ OPS_PLUGIN_ROOT_FALLBACK="$PLUGIN_DIR" . "${PLUGIN_DIR}/lib/registry-path.sh". "${PLUGIN_DIR}/lib/registry-resolve.sh"PREFS="${OPS_DATA_DIR}/preferences.json"-# Optional: scope to a single repo-FILTER_REPO="${1:-}"+# Optional: scope to a single repo. Accepts a bare slug or --repo <slug>, because+# the skill documents the flag form while this script only ever read $1 — passing+# --repo used to set FILTER_REPO to the literal string "--repo" and scan a repo+# named that, which found nothing and looked like "no open PRs".+FILTER_REPO=""+case "${1:-}" in+ --repo) FILTER_REPO="${2:-}" ;;+ --repo=*) FILTER_REPO="${1#--repo=}" ;;+ -*) echo "{\"error\":\"unknown flag ${1}\",\"prs\":[]}" && exit 1 ;;+ *) FILTER_REPO="${1:-}" ;;+esac++if [ -n "$FILTER_REPO" ] && ! printf '%s' "$FILTER_REPO" | grep -qE '^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$'; then+ echo "{\"error\":\"not an owner/name slug: ${FILTER_REPO}\",\"prs\":[]}" && exit 1+fiif [ ! -f "$REGISTRY" ]; thenecho '{"error":"registry.json not found","prs":[]}' && exit 1@@ -31,6 +44,53 @@ elseREPOS=$(ops_registry_repos "$REGISTRY")fi+# Drop repos we cannot push to.+#+# The registry lists every project cloned locally, which includes upstreams we+# only ever read: a fork's parent, a dependency we patched once, a public repo+# we filed one issue against. Those surface open PRs from unrelated contributors,+# and a merge queue that lists them invites merging someone else's work into a+# project that is not ours. On 2026-08-15 a scan returned 57 such PRs across four+# upstream repos alongside 8 real ones.+#+# `.permissions.push` is true only for a member or collaborator, which is exactly+# the line we want.+#+# The gate is fail-closed: only an explicit `true` keeps a repo. A lookup that+# errors, returns null, or reports false is dropped. Fail-open was tempting so a+# network blip could not hide your own PRs, but this list feeds a queue whose next+# step is `gh pr merge`, and "we could not tell" must never resolve to "merge it".+# A blip costs you a rerun; the other way costs someone else's repo.+#+# --repo is NOT exempt. It used to be, which meant `--repo someone/else` walked+# straight past the check.+#+# OPS_MERGE_INCLUDE_EXTERNAL takes a single slug, not a boolean, so authorising one+# upstream for one run cannot silently re-open the whole registry.+ALLOW_EXTERNAL="${OPS_MERGE_INCLUDE_EXTERNAL:-}"+[ "$ALLOW_EXTERNAL" = "1" ] && ALLOW_EXTERNAL="" # legacy boolean is not an allowlist++KEPT=""+SKIPPED=""+for repo in $REPOS; do+ if [ -n "$ALLOW_EXTERNAL" ] && [ "$repo" = "$ALLOW_EXTERNAL" ]; then+ KEPT="$KEPT $repo"+ echo "ops-merge: including $repo by explicit OPS_MERGE_INCLUDE_EXTERNAL" >&2+ continue+ fi+ PERM=$(gh api "repos/$repo" --jq '.permissions.push' 2>/dev/null || echo "error")+ case "$PERM" in+ true) KEPT="$KEPT $repo" ;;+ *) SKIPPED="$SKIPPED $repo($PERM)" ;;+ esac+done+REPOS="$KEPT"+[ -n "$SKIPPED" ] && echo "ops-merge: skipped, no confirmed push access:$SKIPPED" >&2++if [ -z "$(printf '%s' "$REPOS" | tr -d ' ')" ]; then+ echo '{"prs":[],"note":"no repos with confirmed push access"}' && exit 0+fi+# Approved PR author logins (owner + bots). Configured in preferences.json# under .merge_authors (array of GitHub logins, e.g. "you", "dependabot[bot]").# Empty / missing → keep all authors (legacy behavior).diff --git a/claude-ops/skills/ops-merge/SKILL.md b/claude-ops/skills/ops-merge/SKILL.mdindex 0218949a..6b240396 100644--- a/claude-ops/skills/ops-merge/SKILL.md+++ b/claude-ops/skills/ops-merge/SKILL.md@@ -487,6 +487,18 @@ During this command's execution, invoke the following superpower skills at the s- **NEVER trust a fixer's claim of merge success.** Always verify via `gh pr view --json state,mergedAt,mergeCommit` before marking complete. See Phase 5 verification protocol.- **NEVER let a fixer call `gh pr merge`.** Merge is orchestrator-only. Fixers push, orchestrator verifies the push, orchestrator merges, orchestrator verifies the merge.+- **NEVER merge, or open a PR against, a repo the owner is not a member of.** The registry lists every locally cloned project, so a fork's upstream (`facebookresearch/*`, someone else's OSS) appears in the queue carrying open PRs from unrelated contributors. Those are read-only. Contributing upstream is a deliberate act the owner asks for, one PR at a time, never a pipeline sweep.++ **Check push access immediately before every `gh pr create`, `gh pr merge`, and `git push` — in every phase (0 salvage, 2 merge, 5 verified-merge, 6 main sync):**++ ```bash+ PERM=$(gh api "repos/$REPO" --jq '.permissions.push' 2>/dev/null || echo error)+ [ "$PERM" = "true" ] || { echo "refusing: no confirmed push access to $REPO ($PERM)"; exit 1; }+ ```++ **Fail closed.** Only a literal `true` proceeds. `false`, `null`, a network error, a renamed repo, or an empty response all refuse. The scan filtering the queue is not sufficient on its own: the queue can be stale, hand-edited, or passed in by an operator, and the step after it is a merge. Re-check at the point of action, not once at the start.++ `OPS_MERGE_INCLUDE_EXTERNAL=<owner/name>` authorises exactly one repo for one run, and only when the owner asked. It is a slug, never a boolean — a global on/off would re-open the whole registry to a pipeline whose next call is `gh pr merge`.- **NEVER force-push to main/master**- **NEVER merge with red CI** — fix root cause first- **NEVER bypass review on PRs touching auth, payments, PII, or secrets** — these require `security-reviewer` subagent audit before merge