# Verify a repair against the requirement

Original LockedIn Labs practice · edition 2026-10-30.1 · 40 planned minutes.
Use Node.js 24 in a new folder with the paired `fde-quantity-regression.test.mjs`.
There is no package install, AI account, network call or existing-project edit.
The fixture is deliberately broken; an initial failing test is expected.

## Contract Q1 — agree the expected result before editing

For supplied inputs that are nonnegative integers, preserve the quantity,
including zero. Only `null` and `undefined` mean missing. The display function
does not validate arbitrary input. Do not infer support for strings, fractions,
NaN or negative quantities from these four examples.

| Input | Expected output | What this check protects |
| --- | --- | --- |
| `0` | `0` | A present zero is not missing |
| `7` | `7` | The legitimate positive case stays useful |
| `null` | `"missing"` | Explicit missing input |
| `undefined` | `"missing"` | Absent input |

## 1. Predict, then reproduce the defect — 8 minutes

Keep the original file separate. Read the function and four assertions before
running. `||` substitutes its right operand for a falsy left value, including
zero. Predict each test, then run:

```sh
node --version
node --test --test-reporter=tap fde-quantity-regression.test.mjs
```

The original has four tests: three pass and the zero assertion fails. Actual is
`"missing"`, expected is `0`. The command exits 1. A missing import or unavailable
runtime is a setup failure, not this observed behavior. Keep the exact file,
runtime, command, test names, output and exit status in your own record.

My prediction and reason:

My actual run / unrun setup and help:

## 2. Repair behavior while preserving the question — 10 minutes

Make `quantity-repaired.test.mjs` as a separate copy. Change only
`return quantity || "missing";` to `return quantity ?? "missing";` or an equivalent
explicit null/undefined check. Keep every assertion unchanged.

```sh
node --test --test-reporter=tap quantity-repaired.test.mjs
```

All four supplied checks should pass, with exit 0. Explain why this preserves
zero and positive values while retaining missing behavior. Run the unchanged
original again to show the same regression still detects its defect. Keeping
assertions fixed makes this comparison informative; four examples do not prove
every possible input or the quality of a larger application.

Changed line and why it satisfies Q1:

Original/repaired commands, observed results and any assistance:

## 3. Challenge two green claims — 10 minutes

**Selection:** run the original, unchanged file with a narrower command:

```sh
node --test --test-reporter=tap --test-name-pattern="positive" fde-quantity-regression.test.mjs
```

The selected positive test passes. The zero test was not exercised. Inspect the
selected names; do not infer execution from a skip count or a green process.

**Weaker assertion:** make a fresh original copy named
`quantity-weak.test.mjs`. Replace each strict equality assertion with a not-null
check on the same actual result: `assert.notEqual(actual, null)` in the zero test,
and `assert.notEqual(displayQuantity(input), null)` for the other original inputs.
Keep the zero observation line. Run it explicitly. All four weak checks pass while zero still returns
`"missing"`. The requirement did not change; the question did. Retain this copy
as a misleading green example, not a repair.

For contrast, a function that always returns `"missing"` passes both missing
examples but fails the positive and zero checks. Useful work belongs in the
regression set beside boundary cases.

Exact selected names and the unanswered question:

Weak assertion, observed zero result and why its pass is insufficient:

## 4. Receive the work and change the contract — 12 minutes

Give a colleague the original, repaired copy, Q1 and your commands. Ask them to
run the relevant assertion and locate the behavioral change without you taking
over. Keep their own account separately. Record the action, file, help and any
missing step; solo work is self-review. A supplied result is not their own run.

**Q2 — changed requirement:** a signed-off hypothetical change now permits negative
integer quantities for backorders. Before executing, add an independent example
such as `-3 → -3`. Compare it against the original and repaired implementations.
Both may satisfy this new example: passing the transfer case alone cannot detect
the original zero defect. Keep the earlier zero regression too. This is a
fictional requirement decision, not permission to change a real inventory system.

Explain why neither `??` nor these examples validate arbitrary types. Ask the
actual requirement owner about strings, fractions and limits before inventing a
validation policy. Keep the receiver's next action and that unresolved question.

Receiver's actual action / unobserved work and assistance:

My Q2 prediction, added assertion, results and remaining question:

This record describes local practice. No deployment, production access,
independent assessment, qualification or client placement is created.

Primary references checked 30 October 2026:
[Node.js 24 test runner](https://nodejs.org/docs/latest-v24.x/api/test.html) and
[JavaScript nullish coalescing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing).
