From 12da40496ed79b4ed60fe8089d6bed5024882628 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 20 Jan 2026 21:26:36 +0100 Subject: [PATCH] Don't match wrong company when no temporal match exists When no company in search results existed at the claimed employment start date, return no match instead of falling back to wrong company. This prevents matching "UK MATTEL LTD" (2025) when the CV claims employment in 2006-2013 and the real "MATTEL U.K. LIMITED" (1980) isn't in the search results. Result: Company shows as "Unverified" instead of wrongly verified with multiple "Employment Before Company Existed" flags. Co-Authored-By: Claude Opus 4.5 --- .../Services/CompanyVerifierService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TrueCV.Infrastructure/Services/CompanyVerifierService.cs b/src/TrueCV.Infrastructure/Services/CompanyVerifierService.cs index 7201887..766b7b5 100644 --- a/src/TrueCV.Infrastructure/Services/CompanyVerifierService.cs +++ b/src/TrueCV.Infrastructure/Services/CompanyVerifierService.cs @@ -617,11 +617,15 @@ public sealed class CompanyVerifierService : ICompanyVerifierService _logger.LogDebug("Selected: {Title} ({Number})", existedAtStartDate[0].Item.Title, existedAtStartDate[0].Item.CompanyNumber); return existedAtStartDate[0]; } + + // No companies existed at the claimed start date - don't match a wrong company + _logger.LogDebug("No companies found that existed at claimed start date {StartDate}, returning no match", claimedStartDate.Value); + return null; } - // Fall back to highest score if no temporal match + // No start date provided - just use highest score var fallback = matches.OrderByDescending(m => m.Score).First(); - _logger.LogDebug("Falling back to highest score: {Title} ({Number})", fallback.Item.Title, fallback.Item.CompanyNumber); + _logger.LogDebug("No start date filter, using highest score: {Title} ({Number})", fallback.Item.Title, fallback.Item.CompanyNumber); return fallback; }