← back to Mfr Review Viewer Corruption
candidates: CRITICAL — scope keep/delete/mfr-suggest to own-SKU records (skuMatch); foreign leaks (e.g. Schumacher sharing a number) can no longer be delete-suggested
2326b027d872e71895d3dd14c7d3d3e2f9e67f0e · 2026-08-27 11:12:13 -0700 · Steve Abrams
Files touched
Diff
commit 2326b027d872e71895d3dd14c7d3d3e2f9e67f0e
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Thu Aug 27 11:12:13 2026 -0700
candidates: CRITICAL — scope keep/delete/mfr-suggest to own-SKU records (skuMatch); foreign leaks (e.g. Schumacher sharing a number) can no longer be delete-suggested
---
lib/candidates.mjs | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/lib/candidates.mjs b/lib/candidates.mjs
index 2a86dde..a21d1ab 100644
--- a/lib/candidates.mjs
+++ b/lib/candidates.mjs
@@ -267,19 +267,27 @@ export async function candidatesForSku(dwSku) {
const recs = fm.filemaker || [];
// ---- apply Steve's rule (2026-08-27): DELETE the broken no-sample "masters",
- // KEEP the real sample-order records. A record is DELETE-suggested iff it has NO
- // sample history AND its mfr is just the DW# placeholder — GUARDED so we never
- // delete a SKU to zero: at least one KEEP must remain. A KEEP = a record that
- // either had a client sample ordered OR carries a real (non-placeholder) mfr. ----
+ // KEEP the real sample-order records.
+ //
+ // SKU-SCOPING GUARD (2026-08-27, critical): classify ONLY records that ACTUALLY
+ // belong to this SKU (skuMatch === true — Series+JS Pattern normalizes to this
+ // dw_sku). The candidate OR-find deliberately over-fetches (numeric-tail probes),
+ // so foreign records that merely share a number leak in (e.g. Schumacher SCH|51526
+ // under HSW-51526). Those must NEVER be keep/delete/suggest targets — deleting one
+ // would destroy a DIFFERENT SKU's record. Foreign records stay in the list for
+ // context but are excluded from every decision here.
+ const own = recs.filter((r) => r.skuMatch);
const isKeepWorthy = (r) => r.sampleOrdered || (!r.mfrPlaceholder && /[A-Za-z]/.test(r.noteMfr || r.mfrPattern || ''));
- const keepers = recs.filter(isKeepWorthy);
- // the real mfr to pre-fill: prefer a sample-ordered record's real code, else any real code.
+ const keepers = own.filter(isKeepWorthy);
+ // the correct real mfr to SUGGEST into the field: prefer a sample-ordered own record's
+ // real code, else any own record's real code. Only ever from THIS SKU's own records.
const realSrc = keepers.find((r) => r.sampleOrdered && /[A-Za-z]/.test(r.noteMfr || '')) || keepers.find((r) => /[A-Za-z]/.test(r.noteMfr || ''));
const realMfr = realSrc ? (realSrc.noteMfr || realSrc.mfrPattern || '') : '';
const keepRid = realSrc ? String(realSrc.recordId) : (keepers[0] ? String(keepers[0].recordId) : '');
const canPrune = keepers.length > 0; // guard: only suggest deletes if a keeper survives
for (const r of recs) {
- r.deleteSuggested = canPrune && !r.sampleOrdered && r.mfrPlaceholder && String(r.recordId) !== keepRid;
+ // delete-suggest ONLY an own-SKU, no-sample, placeholder record (never a foreign leak).
+ r.deleteSuggested = canPrune && r.skuMatch && !r.sampleOrdered && r.mfrPlaceholder && String(r.recordId) !== keepRid;
}
return { filemaker: recs, unified: unified || [], fmError: fm.fmError || null,
← c59fa7d auto-data-snapshot: 2026-08-27T10:10:28 (1 data files) — dat
·
back to Mfr Review Viewer Corruption
·
viewer: prominent 'Suggested real mfr → Approve into field' ac96049 →