# Zero-value bug: observed failure, hypothesis and fix

The initial hasStock implementation returned Boolean(value). Running the zero-specific regression before editing produced the intended assertion failure: false was returned where true was required.

The root cause is JavaScript truthiness: zero becomes false, whereas negative numbers, fractions, and a nonempty numeric string become true. A small hypothesis script logged the current function, Boolean(value), and one candidate predicate for each of the six supplied inputs. It asserted that the current result matched truthiness and that the candidate matched the specified domain. That command passed before the function was patched.

The single expression was changed to Number.isInteger(value) && value >= 0. The unchanged six-case contract then passed: 0 and 7 accepted; -1, 1.5, null and string 7 rejected. The before snapshot, original commands and all real logs are retained.

The root-level hypothesis helper now imports the preserved before snapshot so it remains replayable after the patch. Its original pre-patch form, which imported ./stock.mjs in the original workspace, is preserved under snapshots/before/hypothesis.mjs. Replaying from that directory reproduces the original dependency layout.

This controlled exercise supports the stated local diagnosis. It does not establish performance on larger incidents or compare agents with and without the skill.

## Provenance

Pinned source: [obra/superpowers at 8ca22dba9a94f28898bbce59f2537ff4d87c747d](https://github.com/obra/superpowers/blob/8ca22dba9a94f28898bbce59f2537ff4d87c747d/skills/systematic-debugging/SKILL.md). Exact source hashes and references are in sources.json.

Executed on 2026-10-04 by Codex in this conversation using Node.js 24.13.0 and Python 3.12.3 on Linux. The exact model version was not exposed. Original command timestamps and stream hashes are in commands.jsonl. These records do not establish independent human adoption, customer outcomes or a compatibility certification.
