[object Object]

← back to Tk10640 Redirect Prune

TK-10653 Cody fix: measured true replacement hit-rate 13.7% (est ~6.3k recoverable, not ~23k); memo corrected + traffic caveat

0d86603e97012cc75464b8fd99dc0b127ada72e1 · 2026-08-18 00:17:24 -0700 · steve

Files touched

Diff

commit 0d86603e97012cc75464b8fd99dc0b127ada72e1
Author: steve <steve@designerwallcoverings.com>
Date:   Tue Aug 18 00:17:24 2026 -0700

    TK-10653 Cody fix: measured true replacement hit-rate 13.7% (est ~6.3k recoverable, not ~23k); memo corrected + traffic caveat
---
 data/replacement-match-result.json |   8 +
 data/replacement-matches.json      | 331 +++++++++++++++++++++++++++++++++++++
 replacement-matcher.mjs            |  49 ++++++
 3 files changed, 388 insertions(+)

diff --git a/data/replacement-match-result.json b/data/replacement-match-result.json
new file mode 100644
index 0000000..43ca5d0
--- /dev/null
+++ b/data/replacement-match-result.json
@@ -0,0 +1,8 @@
+{
+  "dead_targets_probed": 300,
+  "replacement_HIT": 41,
+  "replacement_NONE": 259,
+  "hit_rate": 0.137,
+  "est_recoverable_of_46444": 6347,
+  "note": "HIT = a live ACTIVE+published product shares the dead target handle prefix (same pattern/colorway family)"
+}
diff --git a/data/replacement-matches.json b/data/replacement-matches.json
new file mode 100644
index 0000000..1531039
--- /dev/null
+++ b/data/replacement-matches.json
@@ -0,0 +1,331 @@
+{
+  "matches": [
+    {
+      "dead_target": "/products/chateau-de-breteauil-wallpaper-ere-44566",
+      "prefix": "chateau-de-breteauil-wallpaper",
+      "replacement": "chateau-de-breteauil-wallpaper-ere-44562"
+    },
+    {
+      "dead_target": "/products/cheetahs-cor-23011",
+      "prefix": "cheetahs",
+      "replacement": "cheetahs-cor-23007"
+    },
+    {
+      "dead_target": "/products/dougherty-drive-embossed-damask-vinyl-wallpaper-rew-6238",
+      "prefix": "dougherty-drive-embossed-damask-vinyl-wallpaper",
+      "replacement": "dougherty-drive-embossed-damask-vinyl-wallpaper-rew-6235"
+    },
+    {
+      "dead_target": "/products/natural-textile-wallpaper-by-ronald-redding-rnr-66154",
+      "prefix": "natural-textile-wallpaper-by-ronald-redding",
+      "replacement": "natural-textile-wallpaper-by-ronald-redding-rnr-66101"
+    },
+    {
+      "dead_target": "/products/pastels-and-florals-paf-61178",
+      "prefix": "pastels-and-florals",
+      "replacement": "pastels-and-florals-paf-61224"
+    },
+    {
+      "dead_target": "/products/kiligano-libra-wallpaper-xg4-66919",
+      "prefix": "kiligano-libra-wallpaper-xg4",
+      "replacement": "kiligano-libra-wallpaper-xg4-66905"
+    },
+    {
+      "dead_target": "/products/regency-rldf-19526",
+      "prefix": "regency",
+      "replacement": "regency-ropes-multi-gold-on-white-dwqc-600184"
+    },
+    {
+      "dead_target": "/products/classic-1940-s-retro-clover-leaf-floral-wallcovering-vin-1080",
+      "prefix": "classic-1940-s-retro-clover-leaf-floral-wallcovering",
+      "replacement": "classic-1940-s-retro-clover-leaf-floral-wallcovering-vin-1080-1"
+    },
+    {
+      "dead_target": "/products/sudbury-type-ii-vinyl-wallcovering-xqe-48449",
+      "prefix": "sudbury-type-ii-vinyl-wallcovering",
+      "replacement": "sudbury-type-ii-vinyl-wallcovering-xqe-48447"
+    },
+    {
+      "dead_target": "/products/birds-in-paradise-wallpaper-ele-42514",
+      "prefix": "birds-in-paradise-wallpaper",
+      "replacement": "birds-in-paradise-wallpaper-ele-42511"
+    },
+    {
+      "dead_target": "/products/yves-goriga-durable-vinyl-dur-72459",
+      "prefix": "yves-goriga-durable-vinyl",
+      "replacement": "yves-goriga-durable-vinyl-dur-72460"
+    },
+    {
+      "dead_target": "/products/rodolpho-regular-rushcloth-grs-9018",
+      "prefix": "rodolpho-regular-rushcloth",
+      "replacement": "rodolpho-regular-rushcloth-grs-9030"
+    },
+    {
+      "dead_target": "/products/bravo-with-surface-stick-3m-self-adhesive-sur-21516",
+      "prefix": "bravo-with-surface-stick-3m-self-adhesive",
+      "replacement": "bravo-with-surface-stick-3m-self-adhesive-sur-21514"
+    },
+    {
+      "dead_target": "/products/allie-blockprint-rldf-19209",
+      "prefix": "allie-blockprint",
+      "replacement": "allie-blockprint-chambray"
+    },
+    {
+      "dead_target": "/products/santiago-with-surface-stick-self-adhesive-sur-21969",
+      "prefix": "santiago-with-surface-stick-self-adhesive",
+      "replacement": "santiago-with-surface-stick-self-adhesive-sur-21865"
+    },
+    {
+      "dead_target": "/products/palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22229",
+      "prefix": "palerma-with-surface-stick-faux-wood-grain-self-adhesive",
+      "replacement": "palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22048"
+    },
+    {
+      "dead_target": "/products/palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22076",
+      "prefix": "palerma-with-surface-stick-faux-wood-grain-self-adhesive",
+      "replacement": "palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22048"
+    },
+    {
+      "dead_target": "/products/corby-specialty-wallcovering-xkt-47531",
+      "prefix": "corby-specialty-wallcovering",
+      "replacement": "corby-specialty-wallcovering-xkt-47530"
+    },
+    {
+      "dead_target": "/products/hollywood-glamour-sequin-glitter-glm-51319",
+      "prefix": "hollywood-glamour-sequin-glitter",
+      "replacement": "hollywood-glamour-sequin-glitter-copper-gold"
+    },
+    {
+      "dead_target": "/products/santiago-prt-74084",
+      "prefix": "santiago",
+      "replacement": "santiago-with-surface-stick-self-adhesive-sur-21865"
+    },
+    {
+      "dead_target": "/products/palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22202",
+      "prefix": "palerma-with-surface-stick-faux-wood-grain-self-adhesive",
+      "replacement": "palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22048"
+    },
+    {
+      "dead_target": "/products/ashfield-floral-rldw-19952",
+      "prefix": "ashfield-floral",
+      "replacement": "ashfield-floral-delft"
+    },
+    {
+      "dead_target": "/products/taiki-paper-weave-raffia-xqa-33717",
+      "prefix": "taiki-paper-weave-raffia",
+      "replacement": "taiki-paper-weave-raffia-xqa-33716"
+    },
+    {
+      "dead_target": "/products/place-de-concorde-wallpaper-ere-44538",
+      "prefix": "place-de-concorde-wallpaper",
+      "replacement": "place-de-concorde-wallpaper-ere-44528"
+    },
+    {
+      "dead_target": "/products/escado-natural-wallpaper-by-phillipe-romano-edd-54604",
+      "prefix": "escado-natural-wallpaper-by-phillipe-romano",
+      "replacement": "escado-natural-wallpaper-by-phillipe-romano-edd-54572"
+    },
+    {
+      "dead_target": "/products/elegante-with-surface-stick-faux-fine-wood-self-adhesive-sur-21580",
+      "prefix": "elegante-with-surface-stick-faux-fine-wood-self-adhesive",
+      "replacement": "elegante-with-surface-stick-faux-fine-wood-self-adhesive-sur-21556"
+    },
+    {
+      "dead_target": "/products/saint-de-gavoy-wallpaper-ere-44613",
+      "prefix": "saint-de-gavoy-wallpaper",
+      "replacement": "saint-de-gavoy-wallpaper-ere-44609"
+    },
+    {
+      "dead_target": "/products/sneak-preview-claridge-house-new-10031",
+      "prefix": "sneak-preview-claridge-house",
+      "replacement": "sneak-preview-claridge-house-new-10043"
+    },
+    {
+      "dead_target": "/products/malibu-coast-prints-woy-54768",
+      "prefix": "malibu-coast-prints",
+      "replacement": "malibu-coast-prints-woy-54756"
+    },
+    {
+      "dead_target": "/products/sneak-preview-claridge-house-new-10022",
+      "prefix": "sneak-preview-claridge-house",
+      "replacement": "sneak-preview-claridge-house-new-10043"
+    },
+    {
+      "dead_target": "/products/pastel-paraisos-palm-leaves-cor-23312",
+      "prefix": "pastel-paraisos-palm-leaves",
+      "replacement": "pastel-paraisos-palm-leaves-cor-23309"
+    },
+    {
+      "dead_target": "/products/a-night-of-romance-pattern-design-lab-dig-1904",
+      "prefix": "a-night-of-romance-pattern-design-lab",
+      "replacement": "a-night-of-romance-pattern-design-lab-dig-1904-1"
+    },
+    {
+      "dead_target": "/products/yula-with-surface-stick-self-adhesive-sur-22015",
+      "prefix": "yula-with-surface-stick-self-adhesive",
+      "replacement": "yula-with-surface-stick-self-adhesive-sur-22011"
+    },
+    {
+      "dead_target": "/products/pastels-and-florals-paf-61203",
+      "prefix": "pastels-and-florals",
+      "replacement": "pastels-and-florals-paf-61224"
+    },
+    {
+      "dead_target": "/products/elegante-with-surface-stick-faux-fine-wood-self-adhesive-sur-21695",
+      "prefix": "elegante-with-surface-stick-faux-fine-wood-self-adhesive",
+      "replacement": "elegante-with-surface-stick-faux-fine-wood-self-adhesive-sur-21556"
+    },
+    {
+      "dead_target": "/products/sneak-preview-claridge-house-new-10049",
+      "prefix": "sneak-preview-claridge-house",
+      "replacement": "sneak-preview-claridge-house-new-10043"
+    },
+    {
+      "dead_target": "/products/new-blue-mesa-stripe-rldf-19251",
+      "prefix": "new-blue-mesa-stripe",
+      "replacement": "new-blue-mesa-stripe-clay"
+    },
+    {
+      "dead_target": "/products/natural-textile-wallpaper-by-ronald-redding-rnr-66118",
+      "prefix": "natural-textile-wallpaper-by-ronald-redding",
+      "replacement": "natural-textile-wallpaper-by-ronald-redding-rnr-66101"
+    },
+    {
+      "dead_target": "/products/palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22237",
+      "prefix": "palerma-with-surface-stick-faux-wood-grain-self-adhesive",
+      "replacement": "palerma-with-surface-stick-faux-wood-grain-self-adhesive-sur-22048"
+    },
+    {
+      "dead_target": "/products/pastels-and-florals-paf-61194",
+      "prefix": "pastels-and-florals",
+      "replacement": "pastels-and-florals-paf-61224"
+    },
+    {
+      "dead_target": "/products/dw-vintage-1960s-collection-dig-93022",
+      "prefix": "dw-vintage-1960s-collection",
+      "replacement": "dw-vintage-1960s-collection-dig-93114-1"
+    }
+  ],
+  "misses": [
+    {
+      "target": "/products/trapani-damask-cut-velvet-prf-21542",
+      "prefix": "trapani-damask-cut-velvet"
+    },
+    {
+      "target": "/products/weldo-bay-wood-pulp-walls-xrc-33986",
+      "prefix": "weldo-bay-wood-pulp-walls"
+    },
+    {
+      "target": "/products/boxing-hares-stone-gold-bga-47944",
+      "prefix": "boxing-hares-stone-gold"
+    },
+    {
+      "target": "/products/ellery-stripe-sky-blue-on-white-anna-french",
+      "prefix": "ellery-stripe-sky-blue-on-white-anna-french"
+    },
+    {
+      "target": "/products/honey-comb-scales-texture-rop-73657",
+      "prefix": "honey-comb-scales-texture"
+    },
+    {
+      "target": "/products/akiko-classic-grasscloth-shades-of-warm-and-gold-grs-7412",
+      "prefix": "akiko-classic-grasscloth-shades-of-warm-and-gold"
+    },
+    {
+      "target": "/products/candy-hearts-stars-wallpaper-by-retro-walls-rtr-37264",
+      "prefix": "candy-hearts-stars-wallpaper-by-retro-walls"
+    },
+    {
+      "target": "/products/austin-charcoal-plaid-wallpaper-cca-82961",
+      "prefix": "austin-charcoal-plaid-wallpaper"
+    },
+    {
+      "target": "/products/clevedon-type-ii-vinyl-wallcovering-xkr-47522",
+      "prefix": "clevedon-type-ii-vinyl-wallcovering"
+    },
+    {
+      "target": "/products/saint-veran-leather-lea-saint-veran-leather",
+      "prefix": "saint-veran-leather-lea-saint-veran-leather"
+    },
+    {
+      "target": "/products/colombier-stripe-rldf-18923",
+      "prefix": "colombier-stripe"
+    },
+    {
+      "target": "/products/kiyosato-textile-walls-txt-33525",
+      "prefix": "kiyosato-textile-walls"
+    },
+    {
+      "target": "/products/whimsical-bloom-wallpaper-elg-57543",
+      "prefix": "whimsical-bloom-wallpaper"
+    },
+    {
+      "target": "/products/tahlia-ocean-stucco-texture-wallpaper-cca-83025",
+      "prefix": "tahlia-ocean-stucco-texture-wallpaper"
+    },
+    {
+      "target": "/products/1890-s-pink-scroll-flock-wallpaper-flk-0643",
+      "prefix": "1890-s-pink-scroll-flock-wallpaper"
+    },
+    {
+      "target": "/products/collection-chesapeak-by-ralph-lauren-ralph-74619",
+      "prefix": "collection-chesapeak-by-ralph-lauren"
+    },
+    {
+      "target": "/products/et-cie-virginia-bay-panel-16-panel-199416",
+      "prefix": "et-cie-virginia-bay-panel-16"
+    },
+    {
+      "target": "/products/anjelique-braid-trim-wine-gold-sch-101212",
+      "prefix": "anjelique-braid-trim-wine-gold"
+    },
+    {
+      "target": "/products/shin-white-golden-scroll-texture-wallpaper-cca-83271",
+      "prefix": "shin-white-golden-scroll-texture-wallpaper"
+    },
+    {
+      "target": "/products/uckfield-type-ii-vinyl-wallcovering-xqs-48594",
+      "prefix": "uckfield-type-ii-vinyl-wallcovering"
+    },
+    {
+      "target": "/products/riva-navy-anna-french",
+      "prefix": "riva-navy-anna-french"
+    },
+    {
+      "target": "/products/digital-print-on-smooth-vinyl-printed-for-juicy-couture-custom-004",
+      "prefix": "digital-print-on-smooth-vinyl-printed-for-juicy-couture"
+    },
+    {
+      "target": "/products/pleated-panels-fabric-walls-fwa-72763photo3",
+      "prefix": "pleated-panels-fabric-walls-fwa-72763photo3"
+    },
+    {
+      "target": "/products/piza-pussy-willows-rop-73612",
+      "prefix": "piza-pussy-willows"
+    },
+    {
+      "target": "/products/bella-antonio-for-107b",
+      "prefix": "bella-antonio-for-107b"
+    },
+    {
+      "target": "/products/chain-link-trelli-lattice-wallpaper-scw-32809",
+      "prefix": "chain-link-trelli-lattice-wallpaper"
+    },
+    {
+      "target": "/products/la-roma-pietro-real-silk-silk-33888",
+      "prefix": "la-roma-pietro-real-silk"
+    },
+    {
+      "target": "/products/takao-weave-grey-anna-french",
+      "prefix": "takao-weave-grey-anna-french"
+    },
+    {
+      "target": "/products/anime-wallcovering-aqua-sch-101210",
+      "prefix": "anime-wallcovering-aqua"
+    },
+    {
+      "target": "/products/salt-marsh-rldf-18783",
+      "prefix": "salt-marsh"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/replacement-matcher.mjs b/replacement-matcher.mjs
new file mode 100644
index 0000000..2a05c9a
--- /dev/null
+++ b/replacement-matcher.mjs
@@ -0,0 +1,49 @@
+// TK-10653 — READ-ONLY replacement matcher (Cody FIX): for a random sample of DEAD redirect
+// targets, find whether a live ACTIVE+published replacement exists by HANDLE-PREFIX match
+// (strip the trailing SKU token -<alpha>-<digits>, e.g. aged-wood-walls-cor-23087 -> prefix
+// "aged-wood-walls"; a live handle starting "aged-wood-walls-" = HIGH-confidence replacement).
+// Reports true hit rate: HIGH / NONE per dead target. No writes.
+import { readFileSync, writeFileSync } from 'node:fs';
+const txt=readFileSync(`${process.env.HOME}/Projects/secrets-manager/.env`,'utf8');
+const env={}; for(const l of txt.split('\n')){const m=l.match(/^([A-Z0-9_]+)=(.*)$/); if(m) env[m[1]]=m[2].replace(/^["']|["']$/g,'');}
+const STORE=env.SHOPIFY_STORE_DOMAIN, TOKEN=env.SHOPIFY_FULL_ACCESS_TOKEN, API='2024-10';
+const sleep=ms=>new Promise(r=>setTimeout(r,ms));
+async function gql(q,v={}){for(let a=0;a<10;a++){try{const res=await fetch(`https://${STORE}/admin/api/${API}/graphql.json`,{method:'POST',headers:{'Content-Type':'application/json','X-Shopify-Access-Token':TOKEN},body:JSON.stringify({query:q,variables:v})});const tx=await res.text();let j;try{j=JSON.parse(tx);}catch{await sleep(1500*(a+1));continue;}if(j.errors){if(/THROTTLED/i.test(JSON.stringify(j.errors))){await sleep(1500*(a+1));continue;}throw new Error(JSON.stringify(j.errors));}return j.data;}catch(e){if(a<9){await sleep(1500*(a+1));continue;}throw e;}}}
+const norm=s=>(s||'').split('?')[0].split('#')[0];
+// build the FULL dead-target candidate list: unique product targets whose product is not active+published
+// (reuse: sample from unique-product-targets, but re-verify dead + match). We take a random sample.
+const N=Number((process.argv.find(a=>a.startsWith('--n='))||'').split('=')[1]||300);
+let targets=readFileSync('data/unique-product-targets.txt','utf8').trim().split('\n');
+for(let i=targets.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[targets[i],targets[j]]=[targets[j],targets[i]];}
+// strip trailing SKU token: -<letters/mixed>-<digits> OR -<digits> at end; keep pattern prefix
+function prefixOf(handle){
+  let h=handle;
+  h=h.replace(/-[a-z]{2,6}-\d{3,6}$/i,'');   // -cor-23087, -lec-5011, -str-54865
+  h=h.replace(/-\d{3,6}$/,'');                 // trailing -74621
+  h=h.replace(/-[a-z0-9]+-\1$/i,'');           // duplicated tail like -rl-floral-066-rl-floral-066 (best effort)
+  return h;
+}
+let dead=0, hit=0, none=0, live=0; const matches=[], misses=[];
+let probed=0;
+for(const t of targets){
+  if(probed>=N) break;
+  const h=t.replace(/^\/products\//,'').split('?')[0].split('#')[0];
+  const d=await gql(`query($h:String!){productByHandle(handle:$h){status onlineStoreUrl}}`,{h});
+  const p=d.productByHandle;
+  if(p&&p.status==='ACTIVE'&&p.onlineStoreUrl){ live++; continue; } // not dead, skip (we only rate dead targets)
+  dead++; probed;
+  const pref=prefixOf(h);
+  if(pref.length<4){ none++; misses.push({target:t,prefix:pref,reason:'prefix-too-short'}); probed++; continue; }
+  // find a live ACTIVE published product whose handle starts with the same pattern prefix
+  const r=await gql(`query($q:String!){products(first:5, query:$q){ nodes{ handle status } } }`,{q:`handle:${pref}* AND status:active`});
+  const cands=(r.products?.nodes||[]).filter(n=>n.status==='ACTIVE'&&n.handle!==h&&n.handle.startsWith(pref));
+  if(cands.length){ hit++; if(matches.length<50) matches.push({dead_target:t,prefix:pref,replacement:cands[0].handle}); }
+  else { none++; if(misses.length<50) misses.push({target:t,prefix:pref}); }
+  probed++;
+  if(probed%75===0) process.stderr.write(`  dead probed ${probed}: replacement HIT=${hit} NONE=${none}\n`);
+}
+writeFileSync('data/replacement-matches.json', JSON.stringify({matches,misses:misses.slice(0,30)},null,2));
+console.log(JSON.stringify({dead_targets_probed:dead, replacement_HIT:hit, replacement_NONE:none,
+  hit_rate:dead?+(hit/dead).toFixed(3):0,
+  est_recoverable_of_46444:Math.round((dead?hit/dead:0)*46444),
+  note:'HIT = a live ACTIVE+published product shares the dead target handle prefix (same pattern/colorway family)'},null,2));

← b383ec7 TK-10653: broken-redirect scan — ~46k legacy redirects fire  ·  back to Tk10640 Redirect Prune  ·  TK-10653: full both-ends scan (47,296 broken exact), remedia 4e246b7 →