diff --git a/docs/tasks/gitea-plane-integration/NEXT-SESSION-PRIORITY.md b/docs/tasks/gitea-plane-integration/NEXT-SESSION-PRIORITY.md new file mode 100644 index 0000000..ec43cd8 --- /dev/null +++ b/docs/tasks/gitea-plane-integration/NEXT-SESSION-PRIORITY.md @@ -0,0 +1,125 @@ +# 🚨 Next Session Priority — Loop Fix & n8n Stabilization + +**Status:** CRITICAL — Do this BEFORE reactivating Plane→Gitea workflow +**Created:** March 18, 2026 +**Created By:** Chronicler #32 +**Prerequisite:** Read workflow-v3.md for full architecture context + +--- + +## Current State (End of Session) + +- ✅ n8n is UP and healthy at https://n8n.firefrostgaming.com +- ✅ Volume correctly mounted at /root/.n8n (permanent, survives restarts) +- ✅ All workflows recovered from database +- ✅ Gitea→Plane outbound workflow ACTIVE and working +- ⚠️ Plane→Gitea return trip workflow DEACTIVATED (caused infinite loop crash) +- ⚠️ Loop fix NOT yet implemented + +--- + +## What Caused the Crash + +The Plane→Gitea workflow posted a comment to Gitea using the API token +(mkrause612). Gitea fired a webhook back to n8n. The Gitea→Plane workflow +picked it up and created a Plane update. Plane fired a webhook back to n8n. +Repeat forever until n8n ran out of workers and crashed. + +--- + +## The Fix (One Node, ~10 Minutes) + +Add a bot filter as the SECOND node in BOTH workflows. + +### In Gitea→Plane workflow, after the webhook node add: + +```javascript +// Bot Filter — prevents loop +// If the action was triggered by our sync bot, stop here +const sender = $json.body.sender?.login || ''; +const BOT_ACCOUNTS = ['mkrause612']; // Add firefrost-sync-bot when created + +if (BOT_ACCOUNTS.includes(sender)) { + return []; // Drop silently — this is our own bot commenting +} + +return $input.all(); +``` + +### In Plane→Gitea workflow, after the webhook node add: + +```javascript +// Bot Filter — prevents loop +// Only process events that came from real humans, not our sync +const actor = $json.body.data?.actor_detail?.display_name || ''; +const actor_email = $json.body.data?.actor_detail?.email || ''; +const BOT_EMAILS = ['claude@firefrostgaming.com', 'noreply@firefrostgaming.com']; + +if (BOT_EMAILS.includes(actor_email)) { + return []; // Drop silently — this is our own bot +} + +return $input.all(); +``` + +--- + +## Recommended: Create a Dedicated Sync Bot Account + +Rather than filtering by mkrause612 (your personal account), create a +dedicated Gitea user for sync operations: + +1. Create Gitea user: `firefrost-sync` +2. Generate API token for that user +3. Use that token in all n8n workflows instead of the ops manual token +4. Filter by `firefrost-sync` in the bot filter nodes + +This cleanly separates your personal actions from bot actions. + +--- + +## n8n Volume — IMPORTANT + +The working database is now at /root/.n8n (NOT /opt/firefrost-codex/volumes/n8n) +The compose file has been updated to reflect this. +Do NOT move the database again — leave it at /root/.n8n + +If n8n ever shows setup screen again: +1. Check docker inspect for mount path +2. Check database.sqlite file size (should be ~160MB+) +3. Check settings table for userManagement.isInstanceOwnerSetUp = true +4. Clear license settings if fingerprint mismatch occurs + +--- + +## Gemini's Unified Workflow — DO NOT IMPORT + +Gemini provided a "Master Unified JSON" — reviewed and rejected for: +- Wrong Plane API endpoint (/work-items/ instead of /issues/) +- Wrong Gitea URL (firefrostgaming.com instead of git.firefrostgaming.com) +- Missing bot comment back to Gitea with Plane link +- Still missing proper loop prevention + +Our existing workflows are correct — just need the bot filter added. + +--- + +## What Michael Wants to Add Next Session + +(Michael to fill in before session closes) + +--- + +## Session Start Checklist for Next Chronicler + +1. Read this file FIRST +2. Confirm n8n is healthy: https://n8n.firefrostgaming.com +3. Confirm Plane→Gitea workflow is INACTIVE +4. Add bot filter to BOTH workflows +5. Create firefrost-sync Gitea bot account +6. Test with a real issue before declaring victory +7. Then tackle Michael's additions + +--- + +**Fire + Frost + Foundation = Where Love Builds Legacy** 💙🔥❄️