[object Object]

← back to Designerwallcoverings

tk11732 PJ showroom rollback: mirror tk11307's two load-bearing guards (code review)

09ce7d6e828e7bb0afa0e434a282c15f8d937412 · 2026-09-17 10:23:11 -0700 · Steve Abrams

The 'identical doctrine' sibling was missing both guards tk11307 documents as necessary:
(1) resolveBaseline now skips restore maps whose source_list != this run's TARGET_FILE (the data/
dir could be shared across showroom lines), and (2) toRemove/preserved now hard-intersect with the
current targetGids so a stray/legacy baseline row can never tagsRemove outside this line. Latent
today (own data/ dir + hardcoded TARGET_FILE) but the divergence made the doctrine claim false.
Second-model review (grok-4.5): no regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XqefKZFeg2E4pEzpR4xpkv

Files touched

Diff

commit 09ce7d6e828e7bb0afa0e434a282c15f8d937412
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Sep 17 10:23:11 2026 -0700

    tk11732 PJ showroom rollback: mirror tk11307's two load-bearing guards (code review)
    
    The 'identical doctrine' sibling was missing both guards tk11307 documents as necessary:
    (1) resolveBaseline now skips restore maps whose source_list != this run's TARGET_FILE (the data/
    dir could be shared across showroom lines), and (2) toRemove/preserved now hard-intersect with the
    current targetGids so a stray/legacy baseline row can never tagsRemove outside this line. Latent
    today (own data/ dir + hardcoded TARGET_FILE) but the divergence made the doctrine claim false.
    Second-model review (grok-4.5): no regressions.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01XqefKZFeg2E4pEzpR4xpkv
---
 .../tk11732-pj-showroom-tag/apply-pj-showroomonly.mjs    | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/scripts/tk11732-pj-showroom-tag/apply-pj-showroomonly.mjs b/scripts/tk11732-pj-showroom-tag/apply-pj-showroomonly.mjs
index d810a73..1d27560 100644
--- a/scripts/tk11732-pj-showroom-tag/apply-pj-showroomonly.mjs
+++ b/scripts/tk11732-pj-showroom-tag/apply-pj-showroomonly.mjs
@@ -123,6 +123,15 @@ function resolveBaseline(explicitMap) {
     let map;
     try { map = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { continue; }
     if (!Array.isArray(map.rows)) continue;
+    // Only merge maps written for THIS run's target-list source. The data/ dir COULD be shared
+    // across showroom lines, so without this filter a rollback would fold in another line's baseline
+    // and strip its tag too (mirrors tk11307's source_id_list guard; this line's key is `source_list`).
+    // Skipped only when an explicit --map was given; a legacy map lacking source_list is kept (the
+    // rollback call site also hard-intersects with the current target set as a second guard).
+    if (!explicitMap && map.source_list && map.source_list !== TARGET_FILE) {
+      used.push({ file: path.basename(file), rows: map.rows.length, contributed: 0, skipped: 'other-source' });
+      continue;
+    }
     let contributed = 0;
     for (const r of map.rows) {
       if (!r || !r.gid) continue;
@@ -177,8 +186,11 @@ async function doVerify(targets) {
                         : `  reconstructing baseline from ${used.length} restore map(s), earliest-wins:`);
     for (const u of used) console.log(`    ${u.file}  rows=${u.rows}  contributed=${u.contributed}`);
     const rows = [...baseline.values()];
-    const toRemove = rows.filter(r => r.present_in_store && r.had_tag === false).map(r => r.gid);
-    const preserved = rows.filter(r => r.had_tag === true).length;
+    // Second guard (mirrors tk11307): hard-intersect with the CURRENT target set so a stray baseline
+    // row (e.g. a legacy map with no source_list) can NEVER tagsRemove a product outside this line.
+    const targetGids = new Set(targets.map(t => t.gid));
+    const toRemove = rows.filter(r => r.present_in_store && r.had_tag === false && targetGids.has(r.gid)).map(r => r.gid);
+    const preserved = rows.filter(r => r.had_tag === true && targetGids.has(r.gid)).length;
     console.log(`  will tagsRemove '${TAG}' from ${toRemove.length} products (preserving ${preserved} that had it before).`);
     if (toRemove.length === 0) {
       const live = await doVerify(targets);

← dd1ed81 maya-romanoff logo-hero: a failed reorder is a PARTIAL, not  ·  back to Designerwallcoverings  ·  auto-data-snapshot: 2026-09-17T10:27:03 (1 data files) — scr e0981b7 →