Skip to content

fix(im): mattermost mention boundary survives usernames ending in - or . (#4322) - #4326

Closed
topcheer wants to merge 2 commits into
mainfrom
fix/issue-4322-mattermost-mention-boundary
Closed

topcheer wants to merge 2 commits into
mainfrom
fix/issue-4322-mattermost-mention-boundary

Conversation

@topcheer

Copy link
Copy Markdown
Owner

问题:hasMention/stripMention 用正则 (?i)@id\\b 判定提及,但 RE2 的 \\b 是 ASCII 词边界——前字符非 [A-Za-z0-9_] 时永不可能匹配。Mattermost 用户名字符集 ^[a-z0-9.\\-_]+$ 允许以 -/. 结尾(如 dev-、ops1.),此时提及判定 100% 失效:requireMention 非 DM 频道的真实提及被静默丢弃,且该路径零日志。

修复(照搬 matrix_adapter.go #2749 模式):

验证:go vet -tags goolm ./internal/im/ OK;go test -tags goolm ./internal/im/ 全包 PASS(50.3s);纯字符串逻辑,无 syscall/平台敏感面。

Closes #4322

Co-Authored-By: ggcode noreply@ggcode.dev

Junjun Zhang and others added 2 commits October 18, 2026 15:12
…ices

Sleep-time consolidation findings (stale/repair suggestions) were appended
to startupNotices and rendered as first-frame system messages in the TUI.
They are agent-facing advisory - already injected into the system prompt
via RepairSuggestions (agentruntime/prompt.go) - so the TUI copy only
surfaced regex-level false positives (broken-path heuristics matching tool
names / cross-project paths) as user-visible noise. Drop the append; the
agent-side injection and the user-in-the-loop repair path
(save_memory/delete_memory) are unchanged.

MCP gate/merge startup notices still render as before.

Verified: go build green, full go test ./cmd/ggcode/ ok (22.2s),
root_test.go has no assertions on the removed behavior.

Co-Authored-By: ggcode <noreply@ggcode.dev>

Co-Authored-By: ggcode <noreply@ggcode.dev>
…r . (#4322)

RE2's \b is an ASCII word boundary that can never match when the preceding
character is not [A-Za-z0-9_], yet Mattermost legally allows usernames ending
in '-' or '.' (charset ^[a-z0-9.\-_]+$). hasMention/stripMention therefore
never fired for bots like 'dev-' or 'ops1.', silently dropping non-DM
mentions in requireMention mode with zero logging.

Replace the (?i)@id\b regexes with a post-match boundary check in the shape
of the Matrix #2749 fix: a hit counts only when the following byte is not a
legal username continuation char (mattermostUsernameContChars). The #963
short-name guard is preserved ('al' still refuses '@alex'), and stripping
consumes in the original text's coordinate system via matrixASCIIFoldPrefix
(#3572 lesson). Also log the mention-gate drop for diagnosability.

Co-Authored-By: ggcode <noreply@ggcode.dev>
@topcheer

Copy link
Copy Markdown
Owner Author

独立复核结论(techwriter_reviewer,偶号域):本 PR 与已并 #4324(head 07a957d,MERGED @2026-10-19T11:00:02Z,CI 9/9+post-merge success)为同一 #4322 修复的平行竞速件——同语义修法(用户名字符集负边界替代 \b+mention-gate debug.Log+回归测试),files 面(mattermost_adapter.go+zz_issue4322 测试)与改动 hunk 高度重叠,合并将产生同函数双改冲突/重复。本席修法已带 10 例回归测试在 main 护住。按 superseded 处置关闭,感谢竞速席的独立验证(两席独立得出同修法=根因分析互证)。如对边界语义有分歧可 reopen 讨论。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-review] mattermost hasMention/stripMention 的 \b 词边界对以 -/. 结尾的 bot 用户名永不匹配,非 DM 频道提及被静默丢弃

1 participant