[object Object]

← back to Dw Domain Fleet

fleet-heroes: fix spurious exit-1 in deploy mode + dedup by slug (don't re-churn same-site www+repo pairs)

251f90862b097b13b11677dcce654a061ffaa3ec · 2026-06-01 14:26:45 -0700 · Steve Abrams

Files touched

Diff

commit 251f90862b097b13b11677dcce654a061ffaa3ec
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jun 1 14:26:45 2026 -0700

    fleet-heroes: fix spurious exit-1 in deploy mode + dedup by slug (don't re-churn same-site www+repo pairs)
---
 scripts/fleet-heroes.sh | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/scripts/fleet-heroes.sh b/scripts/fleet-heroes.sh
index 246fa2e..b953800 100755
--- a/scripts/fleet-heroes.sh
+++ b/scripts/fleet-heroes.sh
@@ -78,14 +78,22 @@ if [ "$DEPLOY" = 1 ]; then
   node scripts/gen-standalone-heroes.js || { echo "standalone alloc FAILED"; exit 1; }
   # dup-cluster served domains only (skip already-unique + non-served repo twins)
   node -e '
-    const fs=require("fs"),a=require("./data/standalone-hero-allocation.json");
+    const fs=require("fs");
     const rows=fs.readFileSync("data/standalone-hero-paths.tsv","utf8").trim().split("\n").map(l=>l.split("\t"));
-    const byHash={}; rows.forEach(([d,p,h])=>{(byHash[h]=byHash[h]||[]).push(d)});
-    const dup=rows.filter(([d,p,h])=>byHash[h].length>1).map(([d])=>d);
-    const wwwSlugs=new Set(dup.filter(d=>a[d]&&a[d].path.startsWith("/var/www")).map(d=>d.replace(/\.(com|org|net)$/,"")));
-    const served=dup.filter(d=>{const w=a[d]&&a[d].path.startsWith("/var/www");const s=d.replace(/\.(com|org|net)$/,"");return w||!wwwSlugs.has(s);});
-    fs.writeFileSync("/tmp/fh_served.txt",served.join("\n"));
-    console.log("    duplicate served sites needing unique heroes:",served.length);
+    // Collapse to ONE entry per logical site (slug), preferring the /var/www
+    // served copy. Same-site www+repo copies are intentionally identical and must
+    // NOT be treated as cross-site duplicates (that caused needless re-churn).
+    const bySlug={};
+    for (const [d,p,h] of rows) {
+      const slug=d.replace(/\.(com|org|net)$/,"");
+      const isWww=p.startsWith("/var/www");
+      if (!bySlug[slug] || (isWww && !bySlug[slug].p.startsWith("/var/www"))) bySlug[slug]={d,p,h};
+    }
+    const served=Object.values(bySlug);
+    const byHash={}; served.forEach(({h,d})=>{(byHash[h]=byHash[h]||[]).push(d)});
+    const dup=served.filter(({h})=>byHash[h].length>1).map(({d})=>d);   // TRUE cross-site dups only
+    fs.writeFileSync("/tmp/fh_served.txt",dup.join("\n"));
+    console.log("    distinct sites:",served.length,"| duplicate served sites needing unique heroes:",dup.length);
   '
   if [ -s /tmp/fh_served.txt ]; then
     ssh "$HOST" "mkdir -p /root/_hero-fix"
@@ -125,4 +133,7 @@ rm -f "$g" "$s"
 VR
 
 echo "════════ done ($mode) ════════"
-[ "$DEPLOY" = 0 ] && echo "Re-run with --deploy to push changes live. Then backsync prod→Mac2 + commit (see skill)."
+if [ "$DEPLOY" = 0 ]; then
+  echo "Re-run with --deploy to push changes live. Then backsync prod→Mac2 + commit (see skill)."
+fi
+exit 0

← 6c986ea fleet-heroes: open DW fleet registry viewer (:9774) on launc  ·  back to Dw Domain Fleet  ·  Per-site catalog extras overlay (data/extras/<slug>.json) — 7c6386c →