From f316f7ec3f522c6aa27d494a9e5f45d50bebfced Mon Sep 17 00:00:00 2001 From: Mikhail Date: Wed, 26 Aug 2026 04:20:15 +0300 Subject: [PATCH] Exclude dates from concrete research identifiers --- cmd/core-runtime/main.go | 16 +++++++++++++--- cmd/core-runtime/main_test.go | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index f2bd2a7..88124d9 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -1883,9 +1883,14 @@ func findingContainsRequestedIdentifier(query string, finding epistemics.Researc } func requestedResearchIdentifiers(query string) []string { - identifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1) - exact := make([]string, 0, len(identifiers)) - for _, identifier := range identifiers { + rawIdentifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1) + identifiers := make([]string, 0, len(rawIdentifiers)) + exact := make([]string, 0, len(rawIdentifiers)) + for _, identifier := range rawIdentifiers { + if researchDateIdentifier(identifier) { + continue + } + identifiers = append(identifiers, identifier) if strings.ContainsAny(identifier, "._-") || strings.IndexFunc(identifier, func(r rune) bool { return r >= '0' && r <= '9' }) >= 0 { exact = append(exact, identifier) } @@ -1896,6 +1901,11 @@ func requestedResearchIdentifiers(query string) []string { return identifiers } +func researchDateIdentifier(value string) bool { + return regexp.MustCompile(`^\d{1,2}[.-]\d{1,2}[.-]\d{2,4}$`).MatchString(value) || + regexp.MustCompile(`^\d{4}[.-]\d{1,2}[.-]\d{1,2}$`).MatchString(value) +} + // nearestFlightRouteTerms retains only the two endpoint-shaped terms from a // structured flight search. It has no city or provider vocabulary: endpoint // relevance is determined from the request itself. diff --git a/cmd/core-runtime/main_test.go b/cmd/core-runtime/main_test.go index 7ce510a..5744fbe 100644 --- a/cmd/core-runtime/main_test.go +++ b/cmd/core-runtime/main_test.go @@ -94,6 +94,13 @@ func TestResearchReplyKeepsFindingContainingConcreteIdentifier(t *testing.T) { } } +func TestResearchIdentifiersExcludeSearchDate(t *testing.T) { + identifiers := requestedResearchIdentifiers("ближайший поезд в Петербург сегодня 26.08.2026") + if len(identifiers) != 0 { + t.Fatalf("search date was treated as a concrete identifier: %#v", identifiers) + } +} + func TestResponseReviewPreservesAttemptedResearchOutcome(t *testing.T) { if reviewMayReplacePlanningReply(false, true, false, "Уточните аэропорт.", "Пока не смог получить проверяемый ответ.") { t.Fatal("review replaced an honest unbacked research outcome")