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>
This commit is contained in:
parent
d97f68714a
commit
e233dbbcee
1 changed files with 30 additions and 0 deletions
|
|
@ -42,6 +42,36 @@ git fetch origin main 2>/dev/null
|
||||||
git checkout -f main 2>/dev/null
|
git checkout -f main 2>/dev/null
|
||||||
git reset --hard origin/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
|
# Get sources in queue
|
||||||
SOURCES=$(ls inbox/queue/*.md 2>/dev/null | head -$MAX)
|
SOURCES=$(ls inbox/queue/*.md 2>/dev/null | head -$MAX)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue