← back to Designerwallcoverings
wm-reprice: guard applied.csv against clobber by a zero-write run (TK-11814)
526f5cc2bbe951b5954d15bffda0749558e259f6 · 2026-09-17 11:14:12 -0700 · Steve Abrams
A concurrent/duplicate APPLY run that drift-skips everything wrote a
header-only applied.csv, destroying a prior run's reversal record. Observed
live on the morrisco batch (run1 wrote:3, run2 drift-skip:3 clobbered the
record; recovered from restore-map). Now only rewrite applied.csv when
wrote>0, so the undo trail self-protects.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011WJBZbEV1wuUcnB8g5Qqg3
Files touched
M scripts/wm-reprice/reprice.mjs
Diff
commit 526f5cc2bbe951b5954d15bffda0749558e259f6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Thu Sep 17 11:14:12 2026 -0700
wm-reprice: guard applied.csv against clobber by a zero-write run (TK-11814)
A concurrent/duplicate APPLY run that drift-skips everything wrote a
header-only applied.csv, destroying a prior run's reversal record. Observed
live on the morrisco batch (run1 wrote:3, run2 drift-skip:3 clobbered the
record; recovered from restore-map). Now only rewrite applied.csv when
wrote>0, so the undo trail self-protects.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011WJBZbEV1wuUcnB8g5Qqg3
---
scripts/wm-reprice/reprice.mjs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/wm-reprice/reprice.mjs b/scripts/wm-reprice/reprice.mjs
index e063a31..0ee157d 100644
--- a/scripts/wm-reprice/reprice.mjs
+++ b/scripts/wm-reprice/reprice.mjs
@@ -81,7 +81,17 @@ async function resolve(sku) {
if (u) { wrote++; applied.push(`${pv.id},${u.sku},${u.live},${pv.price}`); }
});
}
- fs.writeFileSync(DIR + `applied${SUF}.csv`, applied.join('\n'));
+ // CLOBBER GUARD (TK-11814): applied.csv is the reversal record. If THIS run wrote nothing
+ // (everything drift-skipped — e.g. a duplicate/concurrent run after the prices already
+ // landed), do NOT overwrite a prior run's applied.csv with a header-only file: that would
+ // silently destroy the undo trail for writes another run really made. Only rewrite when we
+ // have rows. (Observed live: two concurrent APPLY runs; run2 drift-skipped all 3 and
+ // clobbered run1's record — recovered from restore-map, but the file should self-protect.)
+ if (wrote > 0) {
+ fs.writeFileSync(DIR + `applied${SUF}.csv`, applied.join('\n'));
+ } else {
+ console.log(`(wrote 0 this run — leaving existing applied${SUF}.csv untouched so a prior run's reversal record survives)`);
+ }
console.log(`\n=== APPLIED === wrote:${wrote} drift-skip:${drift} err:${err}`);
console.log('reversal: restore-map.csv holds every old price. applied.csv = what changed.');
})();
← e0981b7 auto-data-snapshot: 2026-09-17T10:27:03 (1 data files) — scr
·
back to Designerwallcoverings
·
auto-data-snapshot: 2026-09-17T11:32:24 (2 data files) — ass 2c99b22 →