Compare commits
1 Commits
fix/1480-d
...
fix/1143
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1931911eca |
@@ -1,50 +0,0 @@
|
||||
# Duplicate PR Prevention
|
||||
|
||||
## The Problem
|
||||
|
||||
Issue #1128 documented a cleanup of duplicate PRs. Agents then created
|
||||
4+ duplicate PRs *for issue #1128 itself*. The irony was not lost on anyone.
|
||||
|
||||
See: #1449, #1460, #1474, #1480.
|
||||
|
||||
## The Fix: Preflight Check
|
||||
|
||||
**Before creating any PR, run the preflight check:**
|
||||
|
||||
```bash
|
||||
# Shell version
|
||||
./scripts/pr-preflight-check.sh <issue_number>
|
||||
|
||||
# Python version
|
||||
python3 scripts/pr_preflight_check.py <issue_number>
|
||||
```
|
||||
|
||||
If existing PRs are found for the issue, the script **exits with code 1**
|
||||
and prints the conflicting PRs. DO NOT proceed to create a new PR.
|
||||
|
||||
## Agent Workflow
|
||||
|
||||
```
|
||||
1. Read issue
|
||||
2. Clone repo
|
||||
3. Implement fix
|
||||
4. Commit
|
||||
5. >>> RUN pr_preflight_check.py <issue_number> <<<
|
||||
6. If exit 0: safe to push and create PR
|
||||
7. If exit 1: STOP — review existing PRs first
|
||||
8. Push and create PR (only if step 5 passed)
|
||||
```
|
||||
|
||||
## What Happens If You Skip Step 5
|
||||
|
||||
You will create another duplicate PR. The cleanup script will find it.
|
||||
Someone will close it. You will have wasted compute and created noise.
|
||||
|
||||
## Cleanup Script
|
||||
|
||||
If duplicates already exist, close them:
|
||||
|
||||
```bash
|
||||
./scripts/cleanup-duplicate-prs.sh --dry-run # preview
|
||||
./scripts/cleanup-duplicate-prs.sh --close # actually close
|
||||
```
|
||||
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"generated": "2026-04-06",
|
||||
"refs": ["#836", "#204", "#195", "#196"],
|
||||
"refs": [
|
||||
"#836",
|
||||
"#204",
|
||||
"#195",
|
||||
"#196"
|
||||
],
|
||||
"description": "Canonical fleet routing table. Evaluated agents, routing verdicts, and dispatch rules for the Timmy Foundation task harness.",
|
||||
|
||||
"agents": [
|
||||
{
|
||||
"id": 27,
|
||||
@@ -46,12 +50,14 @@
|
||||
"location": "Bag End, The Shire (VPS)",
|
||||
"description": "Ollama on VPS. Speaks when spoken to. Prefers quiet. Not for delegated work.",
|
||||
"primary_role": "on-request-queries",
|
||||
"routing_verdict": "ROUTE TO: background monitoring, status checks, low-priority Q&A. Only on-request — do not delegate autonomously.",
|
||||
"routing_verdict": "ROUTE TO: background monitoring, status checks, low-priority Q&A. Only on-request \u2014 do not delegate autonomously.",
|
||||
"active": true,
|
||||
"do_not_route": false,
|
||||
"created": "2026-04-02",
|
||||
"repo_count": 1,
|
||||
"repos": ["bilbobagginshire/bilbo-adventures"]
|
||||
"repos": [
|
||||
"bilbobagginshire/bilbo-adventures"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
@@ -60,7 +66,7 @@
|
||||
"model": "codex",
|
||||
"tier": "prepaid",
|
||||
"location": "The Harness",
|
||||
"description": "OpenClaw bridge. Protocol adapter layer — not a personality. Infrastructure, not a destination.",
|
||||
"description": "OpenClaw bridge. Protocol adapter layer \u2014 not a personality. Infrastructure, not a destination.",
|
||||
"primary_role": "protocol-bridge",
|
||||
"routing_verdict": "DO NOT ROUTE directly. claw-code is the bridge to external Codex agents, not an endpoint. Remove from routing cascade.",
|
||||
"active": true,
|
||||
@@ -79,7 +85,7 @@
|
||||
"location": "Below the Surface",
|
||||
"description": "Infrastructure, deployments, bedrock services. Needs model assignment before activation.",
|
||||
"primary_role": "devops",
|
||||
"routing_verdict": "DO NOT ROUTE — no model assigned yet. Activate after Epic #196 (Local Model Fleet) assigns a model.",
|
||||
"routing_verdict": "DO NOT ROUTE \u2014 no model assigned yet. Activate after Epic #196 (Local Model Fleet) assigns a model.",
|
||||
"active": false,
|
||||
"do_not_route": true,
|
||||
"do_not_route_reason": "No model assigned. Blocked on Epic #196.",
|
||||
@@ -97,13 +103,15 @@
|
||||
"location": "The Archive",
|
||||
"description": "Original prototype. Museum piece. Preserved for historical reference only.",
|
||||
"primary_role": "inactive",
|
||||
"routing_verdict": "DO NOT ROUTE — retired from active duty. Preserved only.",
|
||||
"routing_verdict": "DO NOT ROUTE \u2014 retired from active duty. Preserved only.",
|
||||
"active": false,
|
||||
"do_not_route": true,
|
||||
"do_not_route_reason": "Retired prototype. Historical preservation only.",
|
||||
"created": "2026-03-31",
|
||||
"repo_count": 1,
|
||||
"repos": ["allegro-primus/first-steps"]
|
||||
"repos": [
|
||||
"allegro-primus/first-steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
@@ -120,7 +128,10 @@
|
||||
"gap": "Agent description is empty in Gitea profile. Needs enrichment.",
|
||||
"created": "2026-03-14",
|
||||
"repo_count": 2,
|
||||
"repos": ["kimi/the-nexus-fork", "kimi/Timmy-time-dashboard"]
|
||||
"repos": [
|
||||
"kimi/the-nexus-fork",
|
||||
"kimi/Timmy-time-dashboard"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
@@ -148,10 +159,10 @@
|
||||
"id": 19,
|
||||
"name": "ezra",
|
||||
"gitea_user": "ezra",
|
||||
"model": "claude",
|
||||
"model": "kimi-coding/kimi-k2.5",
|
||||
"tier": "prepaid",
|
||||
"location": "Hermes VPS",
|
||||
"description": "Archivist. Claude-Hermes wizard. 9 repos owned — most in the fleet. Handles complex multi-file and cross-repo work.",
|
||||
"description": "Archivist. Research and triage wizard. 9 repos owned \u2014 most in the fleet. Handles complex multi-file and cross-repo work.",
|
||||
"primary_role": "documentation",
|
||||
"routing_verdict": "ROUTE TO: docs, specs, architecture, complex multi-file work. Escalate here when breadth and precision both matter.",
|
||||
"active": true,
|
||||
@@ -176,7 +187,7 @@
|
||||
"gitea_user": "bezalel",
|
||||
"model": "groq",
|
||||
"tier": "free",
|
||||
"location": "TestBed VPS — The Forge",
|
||||
"location": "TestBed VPS \u2014 The Forge",
|
||||
"description": "Builder, debugger, testbed wizard. Groq-powered, free tier. Strong on PR review and CI.",
|
||||
"primary_role": "code-review",
|
||||
"routing_verdict": "ROUTE TO: PR review, test writing, debugging, CI fixes.",
|
||||
@@ -184,29 +195,39 @@
|
||||
"do_not_route": false,
|
||||
"created": "2026-03-29",
|
||||
"repo_count": 1,
|
||||
"repos": ["bezalel/forge-log"]
|
||||
"repos": [
|
||||
"bezalel/forge-log"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
"routing_cascade": {
|
||||
"description": "Cost-optimized routing cascade — cheapest capable agent first, escalate on complexity.",
|
||||
"description": "Cost-optimized routing cascade \u2014 cheapest capable agent first, escalate on complexity.",
|
||||
"tiers": [
|
||||
{
|
||||
"tier": 1,
|
||||
"label": "Free",
|
||||
"agents": ["fenrir", "bezalel", "carnice"],
|
||||
"agents": [
|
||||
"fenrir",
|
||||
"bezalel",
|
||||
"carnice"
|
||||
],
|
||||
"use_for": "Issue triage, code review, local code generation. Default lane for most tasks."
|
||||
},
|
||||
{
|
||||
"tier": 2,
|
||||
"label": "Cheap",
|
||||
"agents": ["kimi", "allegro"],
|
||||
"use_for": "Small scoped edits (kimi ≤3 files), triage decisions and routing (allegro)."
|
||||
"agents": [
|
||||
"kimi",
|
||||
"allegro"
|
||||
],
|
||||
"use_for": "Small scoped edits (kimi \u22643 files), triage decisions and routing (allegro)."
|
||||
},
|
||||
{
|
||||
"tier": 3,
|
||||
"label": "Premium / Escalate",
|
||||
"agents": ["ezra"],
|
||||
"agents": [
|
||||
"ezra"
|
||||
],
|
||||
"use_for": "Complex multi-file work, docs, architecture. Escalate only."
|
||||
}
|
||||
],
|
||||
@@ -217,22 +238,48 @@
|
||||
"allegro-primus: retired, do not route"
|
||||
]
|
||||
},
|
||||
|
||||
"task_type_map": {
|
||||
"issue-triage": ["fenrir", "allegro"],
|
||||
"code-generation": ["carnice", "ezra"],
|
||||
"code-review": ["bezalel"],
|
||||
"small-edit": ["kimi"],
|
||||
"debugging": ["bezalel", "carnice"],
|
||||
"documentation": ["ezra"],
|
||||
"architecture": ["ezra"],
|
||||
"ci-fixes": ["bezalel"],
|
||||
"pr-review": ["bezalel", "fenrir"],
|
||||
"triage-routing": ["allegro"],
|
||||
"devops": ["substratum"],
|
||||
"background-monitoring": ["bilbobagginshire"]
|
||||
"issue-triage": [
|
||||
"fenrir",
|
||||
"allegro"
|
||||
],
|
||||
"code-generation": [
|
||||
"carnice",
|
||||
"ezra"
|
||||
],
|
||||
"code-review": [
|
||||
"bezalel"
|
||||
],
|
||||
"small-edit": [
|
||||
"kimi"
|
||||
],
|
||||
"debugging": [
|
||||
"bezalel",
|
||||
"carnice"
|
||||
],
|
||||
"documentation": [
|
||||
"ezra"
|
||||
],
|
||||
"architecture": [
|
||||
"ezra"
|
||||
],
|
||||
"ci-fixes": [
|
||||
"bezalel"
|
||||
],
|
||||
"pr-review": [
|
||||
"bezalel",
|
||||
"fenrir"
|
||||
],
|
||||
"triage-routing": [
|
||||
"allegro"
|
||||
],
|
||||
"devops": [
|
||||
"substratum"
|
||||
],
|
||||
"background-monitoring": [
|
||||
"bilbobagginshire"
|
||||
]
|
||||
},
|
||||
|
||||
"gaps": [
|
||||
{
|
||||
"agent": "substratum",
|
||||
@@ -255,12 +302,11 @@
|
||||
"action": "Run wolf evaluation on active agents (#195) to replace vibes-based routing with data."
|
||||
}
|
||||
],
|
||||
|
||||
"next_actions": [
|
||||
"Assign model to substratum — Epic #196",
|
||||
"Run wolf evaluation on active agents — Issue #195",
|
||||
"Remove claw-code from routing cascade — it is infrastructure, not a destination",
|
||||
"Assign model to substratum \u2014 Epic #196",
|
||||
"Run wolf evaluation on active agents \u2014 Issue #195",
|
||||
"Remove claw-code from routing cascade \u2014 it is infrastructure, not a destination",
|
||||
"Enrich kimi's Gitea profile description",
|
||||
"Wire fleet-routing.json into workforce-manager.py — Epic #204"
|
||||
"Wire fleet-routing.json into workforce-manager.py \u2014 Epic #204"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
## Role
|
||||
|
||||
Dedicated reasoning and architecture wizard. Claude-native.
|
||||
Dedicated research and triage wizard. Kimi-native.
|
||||
|
||||
## Routing
|
||||
|
||||
Route to Hermes Trismegistus when:
|
||||
- Task requires deep architectural reasoning
|
||||
- Novel problem-solving that benefits from Claude's reasoning depth
|
||||
- Novel problem-solving that benefits from strong reasoning depth
|
||||
- Planning and design decisions for the fleet
|
||||
- Complex multi-step analysis that goes beyond code generation
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
}
|
||||
},
|
||||
"agents_present": [
|
||||
"claude"
|
||||
"ezra"
|
||||
],
|
||||
"interaction_ready": true
|
||||
},
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# pr-preflight-check.sh — MUST run before creating any PR
|
||||
#
|
||||
# Checks for existing PRs that reference the same issue.
|
||||
# Refuses to proceed if duplicates exist.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/pr-preflight-check.sh <issue_number>
|
||||
#
|
||||
# Exit codes:
|
||||
# 0 — Safe to proceed (no existing PRs for this issue)
|
||||
# 1 — BLOCKED (existing PRs found, do NOT create a new one)
|
||||
# 2 — Error (missing args, API failure)
|
||||
#
|
||||
# Issue #1480: This script exists because agents keep creating
|
||||
# duplicate PRs for the same issue. Running this before `git push`
|
||||
# or `curl ... /pulls` prevents the problem.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
set -euo pipefail
|
||||
|
||||
ISSUE_NUM="${1:-}"
|
||||
if [ -z "$ISSUE_NUM" ]; then
|
||||
echo "Usage: $0 <issue_number>"
|
||||
echo "Example: $0 1128"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
GITEA_URL="${GITEA_URL:-https://forge.alexanderwhitestone.com}"
|
||||
GITEA_TOKEN="${GITEA_TOKEN:?Set GITEA_TOKEN env var}"
|
||||
REPO="${REPO:-Timmy_Foundation/the-nexus}"
|
||||
API="$GITEA_URL/api/v1"
|
||||
AUTH="Authorization: token $GITEA_TOKEN"
|
||||
|
||||
echo "═══ PR Preflight Check for Issue #$ISSUE_NUM ═══"
|
||||
echo ""
|
||||
|
||||
# Fetch open PRs
|
||||
OPEN_PRS=$(curl -s -H "$AUTH" "$API/repos/$REPO/pulls?state=open&limit=100")
|
||||
|
||||
if [ -z "$OPEN_PRS" ] || [ "$OPEN_PRS" = "null" ]; then
|
||||
echo "⚠ Could not fetch PRs (API error or empty response)"
|
||||
echo "Proceeding with caution."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find PRs referencing this issue
|
||||
MATCHES=$(echo "$OPEN_PRS" | jq -r ".[] | select(.title | test(\"#$ISSUE_NUM\"; \"i\") or .body // \"\" | test(\"#$ISSUE_NUM\"; \"i\")) | \" PR #\\(.number): \\(.title) [\\(.head.ref)] (\\(.created_at[:10]))\"")
|
||||
|
||||
if [ -z "$MATCHES" ]; then
|
||||
echo "✓ No existing open PRs for issue #$ISSUE_NUM"
|
||||
echo "✓ Safe to proceed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "✗ BLOCKED — Found existing open PRs for issue #$ISSUE_NUM:"
|
||||
echo ""
|
||||
echo "$MATCHES"
|
||||
echo ""
|
||||
echo "═══════════════════════════════════════════════"
|
||||
echo "DO NOT CREATE A NEW PR."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " 1. Review and merge an existing PR"
|
||||
echo " 2. Close duplicates first: ./scripts/cleanup-duplicate-prs.sh --close"
|
||||
echo " 3. Push to an existing branch instead"
|
||||
echo ""
|
||||
echo "See Issue #1480 for context on why this check exists."
|
||||
echo "═══════════════════════════════════════════════"
|
||||
exit 1
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
pr_preflight_check.py — Prevent duplicate PR creation.
|
||||
|
||||
Call before creating any PR:
|
||||
python3 scripts/pr_preflight_check.py 1128
|
||||
|
||||
Returns exit code 0 if safe, 1 if blocked.
|
||||
Designed for agent workflows — agents MUST call this before `curl ... /pulls`.
|
||||
|
||||
Issue #1480: The duplicate PR problem.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
|
||||
def check_existing_prs(issue_num: int, repo: str = None, token: str = None) -> dict:
|
||||
"""Check for existing open PRs referencing an issue.
|
||||
|
||||
Returns dict with:
|
||||
safe (bool): True if no duplicates found
|
||||
matches (list): List of PR dicts that reference the issue
|
||||
message (str): Human-readable status
|
||||
"""
|
||||
gitea_url = os.environ.get("GITEA_URL", "https://forge.alexanderwhitestone.com")
|
||||
token = token or os.environ.get("GITEA_TOKEN", "")
|
||||
repo = repo or os.environ.get("REPO", "Timmy_Foundation/the-nexus")
|
||||
|
||||
if not token:
|
||||
token_path = os.path.expanduser("~/.config/gitea/token")
|
||||
if os.path.exists(token_path):
|
||||
token = open(token_path).read().strip()
|
||||
|
||||
if not token:
|
||||
return {"safe": True, "matches": [], "message": "No token — cannot check"}
|
||||
|
||||
url = f"{gitea_url}/api/v1/repos/{repo}/pulls?state=open&limit=100"
|
||||
req = urllib.request.Request(url, headers={"Authorization": f"token {token}"})
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
prs = json.loads(resp.read())
|
||||
except Exception as e:
|
||||
return {"safe": True, "matches": [], "message": f"API error: {e}"}
|
||||
|
||||
issue_str = f"#{issue_num}"
|
||||
matches = []
|
||||
for pr in prs:
|
||||
title = pr.get("title", "")
|
||||
body = pr.get("body") or ""
|
||||
if issue_str in title or issue_str in body:
|
||||
matches.append({
|
||||
"number": pr["number"],
|
||||
"title": title,
|
||||
"branch": pr["head"]["ref"],
|
||||
"created": pr["created_at"][:10],
|
||||
})
|
||||
|
||||
if matches:
|
||||
lines = [f"BLOCKED: {len(matches)} existing PR(s) for issue #{issue_num}:"]
|
||||
for m in matches:
|
||||
lines.append(f" PR #{m['number']}: {m['title']} [{m['branch']}] ({m['created']})")
|
||||
lines.append("")
|
||||
lines.append("DO NOT CREATE A NEW PR. Review existing ones first.")
|
||||
return {"safe": False, "matches": matches, "message": "\n".join(lines)}
|
||||
|
||||
return {"safe": True, "matches": [], "message": f"✓ Safe: no open PRs for #{issue_num}"}
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: pr_preflight_check.py <issue_number> [repo]")
|
||||
print("Example: pr_preflight_check.py 1128")
|
||||
print(" pr_preflight_check.py 1339 Timmy_Foundation/the-nexus")
|
||||
sys.exit(2)
|
||||
|
||||
issue_num = int(sys.argv[1])
|
||||
repo = sys.argv[2] if len(sys.argv) > 2 else None
|
||||
|
||||
result = check_existing_prs(issue_num, repo)
|
||||
print(result["message"])
|
||||
|
||||
if not result["safe"]:
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user