From 41d3a4a9037f714d74bab514ba9a50706c27ada7 Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 6 Aug 2026 02:27:54 +0400 Subject: [PATCH] router: sweep dead double-loop and drifted anaphora comment (V-581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit narrativeQueryBuild reimplemented the "any token in list" check the package already has as hasTok; use it instead of a nested loop. AnaphoraResolver's doc comments described a stale return shape (a key/value pair) and an incomplete pronoun list (missing the "that" and "mine" classes the switch already handled) — fixed the comments to match the code, no behaviour change. Co-Authored-By: Claude Opus 5 --- internal/router/slots.go | 12 ++++++++---- internal/router/stage0.go | 17 ++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/router/slots.go b/internal/router/slots.go index cd87081..15e8f02 100644 --- a/internal/router/slots.go +++ b/internal/router/slots.go @@ -438,18 +438,22 @@ func parseDurationValue(s string) (string, bool) { } // AnaphoraResolver resolves pronouns like "это", "он", "она" to the prior -// turn's key entity. Returns a (key, value) pair the prior fact carried, -// or ("", "", false) when no pronoun is detected. +// turn's key entity. Returns the matched pronoun's class as ref, or +// ("", false) when no pronoun is detected — the caller cross-references ref +// against the prior turn's own slots, this type holds no state of its own. type AnaphoraResolver struct{} // Resolve checks if text contains an anaphoric reference to a prior turn's // entity. For MVP this handles the common Russian pronouns: -// - "это" / "этого" / "этому" / "этим" / "этом" → "this" (most common) +// - "это" / "этого" / "этому" / "этим" / "этом" / "эти" / "эта" → "this" +// (most common) // - "он" / "его" / "ему" / "ним" → "he/it", masc // - "она" / "её" / "ей" / "ней" → "she/it", fem // - "оно" → "it", neuter +// - "тот" / "та" / "то" / "те" → "that" +// - "мой" and its declined forms → "mine" // -// Returns the matching pronoun type for cross-referencing with prior slots. +// Returns the matching pronoun class for cross-referencing with prior slots. func (AnaphoraResolver) Resolve(text string) (ref string, ok bool) { s := strings.ToLower(strings.TrimSpace(text)) toks := strings.Fields(s) diff --git a/internal/router/stage0.go b/internal/router/stage0.go index fe0cb0a..8faa4f0 100644 --- a/internal/router/stage0.go +++ b/internal/router/stage0.go @@ -292,16 +292,15 @@ func narrativeQueryBuild(m []string) (Decision, bool) { if chatNarrativeTopics.MatchString(m[0]) { return Decision{}, false } - for _, t := range planTokens(topic) { - for _, v := range captureVerbs { - if t == v { - return Decision{}, false - } + toks := planTokens(topic) + for _, v := range captureVerbs { + if hasTok(toks, v) { + return Decision{}, false } - for _, v := range entertainmentNouns { - if t == v { - return Decision{}, false - } + } + for _, v := range entertainmentNouns { + if hasTok(toks, v) { + return Decision{}, false } } return Decision{