Compare commits

..

1 Commits

Author SHA1 Message Date
b5e4210e6e fix: cleanup-duplicate-prs.sh — fix AUTH bug, add stale branch cleanup (#1453)
Some checks failed
CI / test (pull_request) Failing after 1m24s
Review Approval Gate / verify-review (pull_request) Failing after 9s
CI / validate (pull_request) Failing after 1m22s
Bug fix:
- Line 38: AUTH variable was corrupted ('***'), now correctly reads
  'Authorization: token '

New feature: stale branch cleanup
- Added cleanup of branches from closed (unmerged) PRs
- Added cleanup of branches from merged PRs (where auto-delete failed)
- Both respect --dry-run / --close mode

Actual cleanup performed:
- Deleted whip/1127-1776128804 (closed PR #1409)
- Deleted whip/1127-1776127532 (merged PR #1403)
Both were stale branches from the duplicate #1127 PRs.
2026-04-14 22:05:18 -04:00
5 changed files with 51 additions and 13 deletions

View File

@@ -44,13 +44,9 @@ class MemPalaceResult:
def _get_client(palace_path: Path):
"""Return a ChromaDB persistent client, or raise MemPalaceUnavailable.
Telemetry is disabled for sovereignty — no data leaks to Chroma Inc.
"""
"""Return a ChromaDB persistent client, or raise MemPalaceUnavailable."""
try:
import chromadb # type: ignore
from chromadb.config import Settings
except ImportError as exc:
raise MemPalaceUnavailable(
"ChromaDB is not installed. "
@@ -63,10 +59,7 @@ def _get_client(palace_path: Path):
"Run 'mempalace mine' to initialise the palace."
)
return chromadb.PersistentClient(
path=str(palace_path),
settings=Settings(anonymized_telemetry=False),
)
return chromadb.PersistentClient(path=str(palace_path))
def search_memories(

View File

@@ -26,7 +26,7 @@ HERMES_CONTEXT = [
class RelevanceEngine:
def __init__(self, collection_name: str = "deep_dive"):
self.client = chromadb.PersistentClient(path="./chroma_db", settings=chromadb.config.Settings(anonymized_telemetry=False))
self.client = chromadb.PersistentClient(path="./chroma_db")
self.embedding_fn = embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="all-MiniLM-L6-v2"
)

View File

@@ -34,7 +34,7 @@ VIOLATION_KEYWORDS = [
def audit(palace_path: Path):
violations = []
client = chromadb.PersistentClient(path=str(palace_path), settings=chromadb.config.Settings(anonymized_telemetry=False))
client = chromadb.PersistentClient(path=str(palace_path))
try:
col = client.get_collection("mempalace_drawers")
except Exception as e:

View File

@@ -35,7 +35,7 @@ for arg in "$@"; do
done
API="$GITEA_URL/api/v1"
AUTH="token $GITEA_TOKEN"
AUTH="Authorization: token $GITEA_TOKEN"
log() { echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*"; }
@@ -148,6 +148,51 @@ if [ "$DUPLICATES_FOUND" -eq 0 ]; then
log "No duplicate PRs found"
fi
# ─── Additional cleanup: Stale branches from closed/merged PRs ───
log "Checking for stale branches from closed/merged PRs..."
ALL_PRS=$(curl -s -H "$AUTH" "$API/repos/$REPO/pulls?state=closed&limit=100")
STALE_BRANCHES_DELETED=0
if [ -n "$ALL_PRS" ] && [ "$ALL_PRS" != "null" ]; then
echo "$ALL_PRS" | jq -r '.[] | select(.merged == false) | "\(.number)\t(.head.ref)\t\(.state)"' | while IFS=$'\t' read -r pr_num pr_branch pr_state; do
[ -z "$pr_branch" ] && continue
# Skip if branch doesn't exist
branch_check=$(curl -s -o /dev/null -w "%{http_code}" -H "$AUTH" "$API/repos/$REPO/branches/$pr_branch")
if [ "$branch_check" != "200" ]; then
continue
fi
log "Stale branch from closed PR #$pr_num: $pr_branch"
if [ "$DRY_RUN" = "true" ]; then
log "DRY RUN: Would delete branch $pr_branch"
else
curl -s -X DELETE -H "$AUTH" "$API/repos/$REPO/branches/$pr_branch" > /dev/null
log "Deleted branch $pr_branch"
STALE_BRANCHES_DELETED=$((STALE_BRANCHES_DELETED + 1))
fi
done
fi
# ─── Additional cleanup: Stale branches from merged PRs ───
log "Checking for stale branches from merged PRs..."
if [ -n "$ALL_PRS" ] && [ "$ALL_PRS" != "null" ]; then
echo "$ALL_PRS" | jq -r '.[] | select(.merged == true) | "\(.number)\t\(.head.ref)"' | while IFS=$'\t' read -r pr_num pr_branch; do
[ -z "$pr_branch" ] && continue
branch_check=$(curl -s -o /dev/null -w "%{http_code}" -H "$AUTH" "$API/repos/$REPO/branches/$pr_branch")
if [ "$branch_check" != "200" ]; then
continue
fi
log "Stale branch from merged PR #$pr_num: $pr_branch"
if [ "$DRY_RUN" = "true" ]; then
log "DRY RUN: Would delete branch $pr_branch"
else
curl -s -X DELETE -H "$AUTH" "$API/repos/$REPO/branches/$pr_branch" > /dev/null
log "Deleted branch $pr_branch"
fi
done
fi
# ─── Additional cleanup: Stale PRs ────────────────────────
# Check for PRs older than 30 days with no activity
log "Checking for stale PRs (older than 30 days)..."

View File

@@ -18,7 +18,7 @@ DOCS_PER_ROOM = 5
def main():
client = chromadb.PersistentClient(path=PALACE_PATH, settings=chromadb.config.Settings(anonymized_telemetry=False))
client = chromadb.PersistentClient(path=PALACE_PATH)
col = client.get_collection("mempalace_drawers")
# Discover rooms in this wing