OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Go import paths cause Portuguese directory summaries / Go 导入路径导致葡萄牙语目录摘要

Open viafcccy opened this issue 3 months ago • 0 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

English Go directories can receive Portuguese summaries even when their source contains no Portuguese prose. Extracted code skeletons retain bare import paths such as github.com/example/client. The shared language detector counts the domain fragment com as a Portuguese stopword and passes the resulting pt value into the overview-generation prompt.

Observed during repository ingestion and reproduced with a synthetic fixture. The deterministic failure does not require an LLM.

中文 导入 Go 仓库后,部分目录会生成葡萄牙语摘要,即使源码中没有葡萄牙语说明。提取的代码骨架保留了 github.com/example/client 这类不带协议前缀的 import 路径;共用语言检测器把域名中的 com 当成葡萄牙语常用词计分,随后把 pt 写入目录摘要生成 Prompt。

该问题在实际仓库导入中被观察到,并已通过合成样例复现;确定性的语言误判本身不依赖 LLM。

Steps to Reproduce

English

  1. Use OpenViking v0.4.16 without output_language_override, with an English fallback.
  2. Run the minimal Python example below. It models a Go skeleton with six synthetic import paths; no Go dependencies or private source are needed.
  3. Observe pt despite the absence of Portuguese prose.
  4. Pass the same skeleton as the client.go file summary to SemanticProcessor._generate_overview. The prompt requests Output Language: pt; a real-model replay generated Portuguese.

中文

  1. 使用 OpenViking v0.4.16,不设置 output_language_override,默认语言为英语。
  2. 运行下方最小 Python 示例。它构造了包含六条合成 import 路径的 Go 骨架,不需要实际 Go 依赖或内部源码。
  3. 观察返回值为 pt,尽管输入中没有葡萄牙语说明。
  4. 将该骨架作为 client.go 的文件摘要传入 SemanticProcessor._generate_overview,Prompt 会要求 Output Language: pt;真实模型回放也生成了葡萄牙语。

Expected Behavior

English Bare import/domain paths should not contribute natural-language evidence. This code-only fixture should use English. Genuine Portuguese prose and explicit language overrides should still work, and original import paths should remain available to the summarization model.

中文 import/域名路径不应作为自然语言判断依据。这个纯代码样例应使用英语,同时保留真正的葡萄牙语识别和显式语言配置;原始路径仍应完整提供给摘要模型。

Actual Behavior

English The six .com imports produce six Portuguese stopword hits and zero English hits. With at least 20 Latin tokens, the fixture satisfies strong_latin: score >= 6 and a lead of at least 4 over English. Repeated occurrences of one machine token are treated as strong language evidence. The overview prompt then instructs the model to write and translate the source summaries into Portuguese.

中文 六条 .com import 产生六次葡萄牙语命中,英语命中为零。样例还包含至少 20 个拉丁词元,因此满足 strong_latin 条件:分数至少为 6,且比英语至少高 4 分。同一机器片段的重复出现被当成了强语言证据,最终 Prompt 明确要求模型用葡萄牙语生成并改写摘要。

Minimal Reproducible Example

from openviking.session.memory.utils.language import _detect_language_from_text

imports = "\n".join(
    f'"github.com/example/module{index}"' for index in range(6)
)
skeleton = "package client\nimport (\n" + imports + "\n)\nfunc NewClient()"

print(_detect_language_from_text(skeleton, fallback_language="en"))
# Actual / 实际: pt
# Expected / 预期: en

Error Logs

No exception is raised / 没有异常或堆栈报错。
Before fix / 修复前: detected_language=pt; Output Language: pt
After filtering bare paths / 过滤裸域名路径后: detected_language=en; Output Language: en

OpenViking Version

v0.4.16 Docker; affected detector also verified / 同时核验于 main: 02f5c464199f121fadf4b9c0fb82cfcf8ba91ca1

Python Version

3.13 (Linux container / Linux 容器)

Operating System

Linux

Model Backend

Other

Additional Context

English Root cause: the noise filter in openviking/session/memory/utils/language.py excludes http://, https://, and viking://, but not bare domain paths. _detect_latin_language then tokenizes and scores every repeated com occurrence.

Execution path: _generate_text_summary returns a code skeleton; _generate_overview detects language from file summaries and child abstracts; semantic.overview_generation receives that language.

A focused fix is prepared in the existing noise filter. It removes bare domain paths only from language detection, not from LLM input. Four regression cases cover code-only input, Chinese prose, genuine Portuguese prose, and an explicit override. All 138 selected tests pass; real-model replay with the synthetic fixture changes from Portuguese to English. The full repository suite was not run: validation targets the shared filter's semantic, memory-prompt, media, and configuration consumers.

Related: #2288 concerns hash-like identifier noise; this is a distinct bare-domain/import-path trigger, not a duplicate hash fix. Model replay used a backend configured as gpt-5.4; the deterministic reproduction is backend-independent.

中文 根因:openviking/session/memory/utils/language.py 的去噪过滤器会排除带 http://、https://、viking:// 的 URI,但遗漏了裸域名路径;随后 _detect_latin_language 对每次出现的 com 都计分。

实际调用链:_generate_text_summary 返回代码骨架,_generate_overview 根据文件摘要与子目录摘要检测语言,再把结果传给 semantic.overview_generation。

已在现有去噪函数中准备最小修复,仅从语言检测输入中排除裸域名路径,不改动 LLM 读取的内容。四组回归覆盖纯代码、中文说明、真实葡萄牙语说明和显式语言配置;138 个相关测试全部通过,合成样例的真实模型回放由葡萄牙语恢复为英语。未跑全仓测试;验证范围覆盖共用过滤器相关的语义摘要、记忆 Prompt、媒体和配置流程。

关联 #2288 处理的是哈希标识噪声,本问题是不同的裸域名/import 路径触发条件,不包含其哈希过滤改动。模型回放使用配置为 gpt-5.4 的后端,但最小确定性复现不依赖模型。

Investigation and implementation were AI-assisted; the reporter discussed the root cause and fix approach. No private source or credentials are included. 排查和实现由 AI 辅助完成,报告者参与了根因及修复思路讨论;不包含内部源码或凭证。

viafcccy avatar Aug 31 '26 13:08 viafcccy