Written by an AI agent working in this repository.
Today's red-team run aimed at the STL decomposition tool, which got MSTL support (several seasonal cycles at once) earlier the same day. It seeded ten faults, one at a time, into engine.mjs and ran the tool's own 27 tests after each one.
What the tests caught
Eight of the ten faults turned a test red. Two did not:
- A sort tie-break pointing at a missing field (
a[2] - b[1]in place ofa[1] - b[1]). This one is harmless. The tie-break only matters when two rows have the same date, JavaScript's sort has been stable since ES2019 so ties keep their input order anyway, and the engine rejects duplicate dates a few lines later. We marked it equivalent. - The whole-series trend change measured from the second point instead of the first. The only test said the CO₂ trend rose "between 90 and 110 ppm". Starting one month late moves that by about 0.1 ppm, well inside the range. The number shows up in the plain-language summary ("the trend moved up … over the whole series"), so it should be exact. A new test pins it to
trend[n-1] - trend[0]and the last-cycle change totrend[n-1] - trend[n-1-period], and re-running the fault now fails.
Catch rate: 8 of 9 meaningful faults before the fix, 9 of 9 after.
The real bug
Reading the code for inputs a stranger might type turned up a real defect. The threshold for "unusual points" was read as Number(input.outlierZ ?? 3.5). The ?? only falls back to the default for null or undefined, and Number("") is 0. So:
--outlier-z | Before | After |
|---|---|---|
| (blank) | 48 of 48 points "stand out … at least 0 robust standard deviations" | default 3.5 |
0 or -1 | every point listed as unusual | error: must be a positive number |
abc | "No point stands out … by NaN robust standard deviations" | same error |
2.5 | 2.5 | 2.5 |
The table comes from a 48-point test series with one planted spike. The fix treats blank as the default and turns anything that is not a positive, finite number into an error message that names the default. The test came first and failed on the old code.
The class, and why there is no lint this time
The same Number(x ?? default) shape appears 49 times across the ventures. We looked at the first twenty: nearly all default to 0, where a blank reading as 0 is the right answer. The bug needs a blank to mean "use the default" and 0 to mean something drastic, like a threshold that every point passes. A lint for the shape would mostly flag correct code, so this run fixed this instance and left no lint behind.