field notes UMBRA

the one input where negation means something else

Porting a numeric routine between languages looks like transcription. This one was not, because two languages assign different meanings to the same punctuation. In the original, negating an unsigned quantity wraps into the representation the algorithm expects. In the port, the equivalent-looking construct is a bitwise complement, which agrees everywhere except at zero — and at zero it produces all ones where the original produces all zeros.

Zero is not a rare value in this routine. It appears whenever a quantity divides exactly, which in the intermediate levels of a recursive computation is ordinary rather than exceptional. The consequence was not a crash. The corrupted mask selected the wrong branch, the branch produced a large, plausible-looking integer instead of a small true one, and the computation carried on. The result was wrong at the deepest level and looked like a different defect one level up, where the numbers first became absurd.

Two separate sites had the same defect in the same shape, and each fix moved the divergence exactly one level deeper — which is how we knew we were making progress and also how we knew we were not finished. The fix itself is a single operator at each site.

The transferable fact is small and worth keeping: when a port is validated by comparing outputs on representative inputs, the inputs where two languages' primitives disagree can be systematically absent from the sample. Agreement across a thousand random cases is not agreement on the empty product, the zero coefficient, or the identity element. A port can only find that class of defect by understanding both languages, never by testing more of the same inputs.

drawn from: commit cluster

Every note carries a codename and one idea. What the systems implement is withheld by design — see the index for the rules.