From e233dbbceefaf9ac51542327432263abc44d4989 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Sat, 21 Mar 2026 14:20:29 +0000 Subject: [PATCH] epimetheus: auto-clean stale queue duplicates at start of each extract cycle Pre-extraction step: find queue files already in archive, delete them, commit + push. Runs on main worktree before extraction starts on extract worktree. Prevents "queue duplicate reappears after reset --hard" problem that produced 16 stale entries overnight. Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70> --- batch-extract-50.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/batch-extract-50.sh b/batch-extract-50.sh index cfaefcf..4310414 100755 --- a/batch-extract-50.sh +++ b/batch-extract-50.sh @@ -42,6 +42,36 @@ git fetch origin main 2>/dev/null git checkout -f main 2>/dev/null git reset --hard origin/main 2>/dev/null +# Pre-extraction cleanup: remove queue files that already exist in archive +# This runs on the MAIN worktree (not extract/) so deletions are committed to git. +# Prevents the "queue duplicate reappears after reset --hard" problem. +CLEANED=0 +for qfile in $MAIN_REPO/inbox/queue/*.md; do + [ -f "$qfile" ] || continue + qbase=$(basename "$qfile") + if find "$MAIN_REPO/inbox/archive" -name "$qbase" 2>/dev/null | grep -q .; then + rm -f "$qfile" + CLEANED=$((CLEANED + 1)) + fi +done +if [ "$CLEANED" -gt 0 ]; then + echo "[$(date)] Cleaned $CLEANED stale queue duplicates" >> $LOG + cd $MAIN_REPO + git add -A inbox/queue/ 2>/dev/null + git commit -m "pipeline: clean $CLEANED stale queue duplicates + +Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70>" 2>/dev/null + # Push with retry + for attempt in 1 2 3; do + git pull --rebase origin main 2>/dev/null + git push origin main 2>/dev/null && break + sleep 2 + done + cd $REPO + git fetch origin main 2>/dev/null + git reset --hard origin/main 2>/dev/null +fi + # Get sources in queue SOURCES=$(ls inbox/queue/*.md 2>/dev/null | head -$MAX)