fix(vinpin): reject stale-breadcrumb decodes (require SINCOM) + harden matcher
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
A failed ePER VIN lookup ("vehicle not found") whose Cyrillic "не найден" alert
OCRs to garbage ("He HaaeHs") slipped the not-found check; the parser then
grabbed the operator's last-browsed catalog from the breadcrumb
("FIAT » TIPO-EGEA") and false-mapped it to a catalog — NM4131 landed on the
ancient "Tipo 1100-1370-1580 (1987-1993)", plus 2× PANDA. Every genuine decode
carries a SINCOM; the breadcrumb false positives never do.
- parser: isUsableParse now requires a SINCOM (a model alone is not a decode)
- matcher: modelTokens keeps 4-digit engine displacements (1100/1370/1580) —
only 1950-2039 count as years — so ancient catalogs no longer collapse to
["TIPO"] and win the fewest-extra-tokens tiebreak
- matcher: recency tiebreak on equal score — never fall back to an ancient
generation for a bare / year-less model
15 unit tests (parser + matcher) pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -35,4 +35,18 @@ describe("parseVinpinModal", () => {
|
||||
expect(isUsableParse(p)).toBe(false);
|
||||
expect(isUsableParse(parseVinpinModal(null))).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a stale-breadcrumb model with no SINCOM (vehicle-not-found false positive)", () => {
|
||||
// Real garbled OCR of a failed NM4131 decode: the "не найден" alert is
|
||||
// mangled ("He HaaeHs") so it slips the not-found check, and the screen
|
||||
// still shows the operator's last catalog ("FIAT » TIPO - EGEA"). A model
|
||||
// token is present but there is NO SINCOM → must be treated as unusable so
|
||||
// it is not false-mapped onto the ancient "TIPO 1987-1993" catalog.
|
||||
const p = parseVinpinModal(
|
||||
"Fiat Dealer Spare Parts FIAT TIPO - EGBA 500 HYBRID TIPO-EGEA MCA (2020) DOBLO FREEMONT LINEA IDEA To yKasaHHeIM N3paMETpaM 3BTOMOBHMN He HaaeHs",
|
||||
);
|
||||
expect(p.model).not.toBeNull(); // breadcrumb model still extracted…
|
||||
expect(p.sincom).toBeNull(); // …but no SINCOM
|
||||
expect(isUsableParse(p)).toBe(false); // → not a real decode
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user