Skip to content

[business-logic] strategy_fixation mutation set drifted from the #154 canonical superset — batch_replace/lsp_rename/file_ops/multi_file_write edits invisible to the detector (its most typical trigger scenario) #737

Description

@topcheer

Component

internal/agent/strategy_fixation.go:220-227(strategyFixationIsMutation)+ internal/agent/verify_hint.go:355-400(sfExtractMutationPaths)——#154 canonical 同步要求的漂移缺口

Bug

双缺口导致 4 个变异工具完全逃过 strategy fixation 追踪:

缺口 1(集合漂移):verify_hint.go 的 sourceMutatingTools(#153/#154)是 canonical 9 工具超集,注释明言 "All per-purpose gates must be derived from or kept in sync with this superset"。但 strategyFixationIsMutation 只列 5 工具——缺 multi_file_write/batch_replace/lsp_rename/file_ops。git 考古:fixation(efcd240c)早于 canonical 超集(105b7d49)——canonical 定义后未回填同步。同步断言 assertEditToolMapsInSync 只盖 fileEditingTools/reverifyEditTools,不含此集合。

缺口 2(提取形态):sfExtractMutationPaths 的 files[] 解析仅支持 []map 形态(multi_file_edit/multi_file_write)——batch_replace 的 files 是 []string(schema 实读)解析静默空;file_ops 的 operations[].source/destination 完全不解析。即使修集合,提取器也需同步修。

触发场景(agent 行为序列)

batch_replace("OldFunc","NewFunc",files=["a.go","b.go","c.go"])  # build fail
batch_replace(同上重试)  # build fail
batch_replace(同上重试)  # build fail
预期: [strategy-fixation] Edited a.go 3 times with 3 failures...
实际: 零警告——mutation 集不含 batch_replace,recordEdit 从未被调用
lsp_rename 重试风暴同理(workspace edits 代理形态)

讽刺点:批量 codemod 重试恰是 fixation 行为的典型形态,最该检测的工具零追踪。

预期 vs 实际

  • 预期:canonical 超集内全部 9 工具的变异都被 recordEdit。
  • 实际:5/9 覆盖,4 工具(含最高 churn 的 batch_replace)纯 FN。

危害方向

纯漏报(不误报);advisory 检测器失效面扩大;违反 #154 注释的 canonical 同步要求(与 #733 家族同型:姊妹集合漏改)。

修复建议

  1. strategyFixationIsMutation 改为 return sourceMutatingTools[toolName](消除重复定义,永久防漂移)
  2. sfExtractMutationPaths 补解析:batch_replace 的 files []string + file_ops 的 operations[].source/destination
  3. assertEditToolMapsInSync 补 strategyFixationIsMutation 覆盖检查

严重程度

medium — FN 方向 + advisory;但 batch_replace 是 fixation 最典型触发场景,检测器对其完全失明

独立复核

sa-24 独立复核确认(五环:canonical 注释/集合现状/断言盲区/时间线漂移/提取形态);关键证据均经主 agent 亲读交叉验证(两集合实读、agent.go 消费链、batch_replace schema、git 时间线亲验)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions