fix(onboarding): 接入写入幂等——内容不变不重写,Codex 托管块不再累积空行 #25

Merged
lanrtop merged 2 commits from fix/onboarding-idempotent-writes into master 2026-10-02 12:06:29 +08:00

2 Commits

Author SHA1 Message Date
lanrtop
019d81c60e fix(onboarding): 审查修复——JSON 按语义比较,CI workflow 与生成文件同内容不重写
All checks were successful
Push & PR Check / check (pull_request) Successful in 1m3s
对抗审查(9 个 agent,2 条成立):
- settings.json / context.json 改为按 JSON 语义比较:Claude Code 改写后键序与末尾换行不同,
  按文本比较仍会让每次注入整文件重排
- plan_cicd_workflow 忽略行尾判 noop:原按字节比较,autocrlf 检出的同内容 workflow 会被判 update,
  并请用户确认一次无变化的写入;apply 与 generate_workflow 只在内容变化时落盘
- 同类遗漏统一改用 write_if_content_changed:agent_infra 生成文件(未变时报 skipped)、notes-archive 回填
- lib.rs 抽出 same_text_ignoring_eol,与 write_if_content_changed 共用同一比较规则

验证:cargo test 245 passed / 5 ignored(新增 JSON 语义与 CI CRLF 回归断言)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:51:33 +09:00
lanrtop
d098905f28 fix(onboarding): 接入写入幂等——内容不变不重写,Codex 托管块不再累积空行
enterprise 未提交改动归属梳理发现两处炼境侧缺陷:
- Codex 托管块自带结尾换行,又原样保留 END 之后的换行,每次注入多一个空行(enterprise 已累积 16 行)
- sync_blueprint_rules 与注入在内容不变时也用 LF 重写文件:子项目开 core.autocrlf,CRLF 检出的
  同内容文件被 git status 误报为改动,修改时间也被刷新,干扰改动归属判断

修复:
- lib.rs 新增 write_if_content_changed(忽略行尾比较,内容不变不写)
- sync_blueprint_rules 的 CONVENTIONS 与 AGENTS/CLAUDE 托管块、context.json、.claude/settings.json、
  Codex 托管块统一改用它;托管块未变时返回 unchanged
- Codex 托管块写入吸收 END 之后的空行,块外后续内容以一个空行分隔
- 蓝图记 P3b(本修复)、P10(接入包升级前检测块外未提交改动,待做),P9 补可行性实测记录

验证:cargo test 246 passed;实测 enterprise 注入后 .codex/config.toml 末尾空行 16→0,
再次注入四个托管文件修改时间均不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:35:18 +09:00