The Chat Rendered a Perfect Diff. sha256sum Did Not Budge
说明与用途
通过哈希验证和显式测试发现,避免了因模型误导性 diff 输出导致的 48 小时调试循环。
问题
Relying on a model’s rendered unified diff can mislead developers into thinking code changes were applied when they were not, causing test failures and wasted debugging time.
结果
Adding a hash‑based gate and explicit test collection checks prevented a 48‑hour debugging loop, ensuring that code changes were truly applied before tests ran.
工作流
- 1. Run pytest locally on the updated clone and observe green output.
- 2. On the remote server, run
git statusandsha256sum src/billing.pyto confirm the file is unchanged. - 3. Run
pytest --collect-only -qto ensure tests are discovered and node IDs are present. - 4. Execute a snapshot script (
snapshot.sh) to hash all relevant files before and after the model’s edit. - 5. Compare the before and after hash files; if unchanged, abort the run.
- 6. If hashes differ and tests are collected, proceed with pytest execution.
- 7. If tests pass, accept the changes; otherwise, investigate further.
证据
I pasted a failing assertion, asked for a fix, and received a confident unified diff against src/billing.py.
When diff printed nothing, I finally understood the weekend in one glance.
- 记录日期: 2026-09-15T22:00:25.358Z