Skip to content

修复 kanban 原子更新后的二次写回风险并减少冗余 I/O#12

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-code-bugs-and-optimize-performance
Draft

修复 kanban 原子更新后的二次写回风险并减少冗余 I/O#12
Copilot wants to merge 3 commits intomainfrom
copilot/fix-code-bugs-and-optimize-performance

Conversation

Copy link

Copilot AI commented Mar 3, 2026

变更描述

针对“全面检查 bug 与性能优化”,本次聚焦 scripts/kanban_update.py 的高影响点:修复原子更新后再次读写同一文件带来的并发覆盖风险,并消除每次状态变更的冗余磁盘 I/O。改动保持行为兼容,仅调整刷新触发路径并补充回归测试。

  • 问题点(并发安全 + 性能)

    • atomic_json_update(...) 后执行 save(load()),引入一次额外读写。
    • 二次写回绕开原子更新语义,在并发场景可能覆盖其他进程刚写入的数据。
  • 代码调整(最小改动)

    • save(tasks) 替换为 trigger_refresh():仅异步触发 REFRESH_SCRIPT,不再重写 tasks_source.json
    • 所有命令路径中的 save(load()) 统一替换为 trigger_refresh()
    • 移除 atomic_json_write 未使用导入,补充 trigger_refresh() 文档字符串。
  • 回归保障

    • 新增测试 test_state_update_does_not_reload_file_again
      • 验证 cmd_state 不会触发二次 atomic_json_read
      • 验证刷新进程仍被触发一次。
# before
atomic_json_update(TASKS_FILE, modifier, [])
save(load())  # trigger refresh

# after
atomic_json_update(TASKS_FILE, modifier, [])
trigger_refresh()

变更类型

  • Bug 修复
  • 新功能
  • 重构 / 代码优化
  • 文档更新
  • CI / 工程配置

检查清单

  • 代码已通过 python3 -m py_compile 检查
  • 已在本地测试运行 run_loop.sh
  • 涉及看板的变更已在浏览器中验证
  • 更新了相关文档(如适用)

关联 Issue


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 3, 2026 15:08
Co-authored-by: cft0808 <41196455+cft0808@users.noreply.github.com>
Co-authored-by: cft0808 <41196455+cft0808@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code bugs and optimize performance 修复 kanban 原子更新后的二次写回风险并减少冗余 I/O Mar 3, 2026
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.

2 participants