文件与行号
internal/agent/unverified_claim.go:253-272(commandFailed),消费点 hasVerificationCommands:241
问题描述
commandFailed 用命令首 token("go test"→"go")作为 anchor,对 runStats.Errors 做无词边界子串匹配(strings.Contains)。任何同时含 anchor 子串和 fail/error 字样的错误行都会把一条成功的验证命令误判为失败,导致 hasVerificationCommands 豁免失效,detector 对已验证的声明误发提醒。
同文件 #407/#437 两个历史修复已确立词边界匹配为本项目标准(detectSuccessClaims / claimContainsWord),#1521 case D 后加的 commandFailed 是遗漏。
触发场景(已复现验证)
- cargo/go 交叉:CommandsRun=["cargo build --release", "go test ./..."],Errors=["run_command: cargo build failed: error[E0308]..."] —— "cargo" 含子串 "go" → 成功的 go test 被 continue
- .go 路径污染(Go 仓库几乎必中):Errors=["edit_file: failed to match old_text in internal/agent/foo.go"](runStats.Errors 来自任何工具 IsError 结果,agent.go:3864-3866,非命令专用)+ 成功的 go test —— ".go" 含 "go" + "failed" → 同样误判
复现测试两个用例均按预期失败(断言正确行为,现行代码不通过)。
预期 vs 实际
严重程度
low(若无门控则为 medium):
- 整个 detector 挂在 claimsSupervision 门控下,默认 false(opt-in)
- advisory 非阻塞(注入一条提醒消息,每 run 最多 1 次)
- 已验证的 agent 通常简短重申即过,无功能损害
修复建议
anchor 匹配改用同文件既有词边界 helper:strings.Contains(el, anchor) → claimContainsWord(el, anchor),一并消除 cargo→go 与 .go→go 两类污染。可把复核中的两个复现用例转为持久化回归测试(zz_issue_test.go)。
文件与行号
internal/agent/unverified_claim.go:253-272(commandFailed),消费点 hasVerificationCommands:241
问题描述
commandFailed 用命令首 token("go test"→"go")作为 anchor,对 runStats.Errors 做无词边界子串匹配(strings.Contains)。任何同时含 anchor 子串和 fail/error 字样的错误行都会把一条成功的验证命令误判为失败,导致 hasVerificationCommands 豁免失效,detector 对已验证的声明误发提醒。
同文件 #407/#437 两个历史修复已确立词边界匹配为本项目标准(detectSuccessClaims / claimContainsWord),#1521 case D 后加的 commandFailed 是遗漏。
触发场景(已复现验证)
复现测试两个用例均按预期失败(断言正确行为,现行代码不通过)。
预期 vs 实际
严重程度
low(若无门控则为 medium):
修复建议
anchor 匹配改用同文件既有词边界 helper:strings.Contains(el, anchor) → claimContainsWord(el, anchor),一并消除 cargo→go 与 .go→go 两类污染。可把复核中的两个复现用例转为持久化回归测试(zz_issue_test.go)。