Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The Formatter Looked Clean. Property Testing Found the Missing Zeroes.

说明与用途

代理补丁删除了格式化器的零填充,单元测试未发现错误。使用模型提取旧代码的不变量并转换为属性测试,发现合同违例并阻止合并。

问题

An agent patch replaced a hand‑written formatter with a shorter version that silently dropped zero‑padding, causing incorrect output for values under ten, but unit tests did not catch it.

结果

The property gate caught a contract violation that unit tests missed, preventing a broken merge and ensuring the formatter’s zero‑padding behavior was preserved.

工作流

  • Check out the old implementation from git.
  • Generate a list of invariants from the old code using a language model.
  • Convert each invariant into a property test (e.g., zero‑padding for hours, minutes, seconds).
  • Run the properties against both old and new implementations using Hypothesis.
  • Block the merge if any property holds on the old version but fails on the new one.

证据

The new formatter silently dropped zero-padding for hours, minutes, and seconds under ten.

来源

Running this produces a clear failure: Falsifying example: test_hours_are_zero_padded(total=5) new_format(5) = '0:0:5' expected hours = '00'

来源

  • 记录日期: 2026-09-05T16:51:02.136Z