FAILURE MAP
← Case archive

FA-65666 / Ecological population dynamics / Open access

Insect degree-day accumulation with horizontal cutoff: day numbering · case 01

Emergence days are reported zero-based.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Days are enumerated from zero.

VERIFIED REPAIR

Restore the day numbering rule: `start=1)`.

Unsuccessful approach: Counting the appended list plus one reports the following day.

Case contract

Daily max is capped at upper; daily min is raised to base and capped at upper; DD = max(0, mean - base); emergence day is the first 1-based day with cumulative DD >= target; return [cumulative rounded 2, day or None]; None when upper <= base.

Why this case matters

Population projections set harvest quotas, conservation status and pest-control timing; a wrong update order, boundary or rate conversion silently changes management advice.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(tmins, tmaxs, base, upper, target):
    if upper <= base:
        return None
    total = 0.0
    cum = []
    day_hit = None
    for d, (lo, hi) in enumerate(zip(tmins, tmaxs), start=0):
        hi_c = min(hi, upper)
        lo_c = min(max(lo, base), upper)
        dd = max(0.0, (hi_c + lo_c) / 2 - base)
        total += dd
        cum.append(round(total, 2))
        if day_hit is None and total >= target:
            day_hit = d
    return [cum, day_hit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4])],
 [('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: spring warming codling moth[[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 4][[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]Failed
regression: hot spell above cutoff[[15.0, 31.0, 48.5], 1][[15.0, 31.0, 48.5], 2]Failed
control: cold days below base[[0.0, 0.0, 0.0], None][[0.0, 0.0, 0.0], None]Passed
regression: exact target[[5.0, 10.0, 15.0], 1][[5.0, 10.0, 15.0], 2]Failed
control: never emerges[[1.0, 2.5], None][[1.0, 2.5], None]Passed
control: invalid thresholdsNoneNonePassed
regression: warm nights[[11.0, 23.0, 37.5, 52.5], 3][[11.0, 23.0, 37.5, 52.5], 4]Failed

SHA-256 / 2085b5395263df105b882c1df329cb5cd68928f2a57ce5828ca092493302dff8

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(tmins, tmaxs, base, upper, target):
    if upper <= base:
        return None
    total = 0.0
    cum = []
    day_hit = None
    for d, (lo, hi) in enumerate(zip(tmins, tmaxs), start=1):
        hi_c = min(hi, upper)
        lo_c = min(max(lo, base), upper)
        dd = max(0.0, (hi_c + lo_c) / 2 - base)
        total += dd
        cum.append(round(total, 2))
        if day_hit is None and total >= target:
            day_hit = len(cum) + 1
    return [cum, day_hit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4])],
 [('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: spring warming codling moth[[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 6][[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]Failed
regression: hot spell above cutoff[[15.0, 31.0, 48.5], 3][[15.0, 31.0, 48.5], 2]Failed
control: cold days below base[[0.0, 0.0, 0.0], None][[0.0, 0.0, 0.0], None]Passed
regression: exact target[[5.0, 10.0, 15.0], 3][[5.0, 10.0, 15.0], 2]Failed
control: never emerges[[1.0, 2.5], None][[1.0, 2.5], None]Passed
control: invalid thresholdsNoneNonePassed
regression: warm nights[[11.0, 23.0, 37.5, 52.5], 5][[11.0, 23.0, 37.5, 52.5], 4]Failed

SHA-256 / db517f7c4b9e1dd77eda92217c450363c455596e5dcf4bd5f90815da312573c6

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(tmins, tmaxs, base, upper, target):
    if upper <= base:
        return None
    total = 0.0
    cum = []
    day_hit = None
    for d, (lo, hi) in enumerate(zip(tmins, tmaxs), start=1):
        hi_c = min(hi, upper)
        lo_c = min(max(lo, base), upper)
        dd = max(0.0, (hi_c + lo_c) / 2 - base)
        total += dd
        cum.append(round(total, 2))
        if day_hit is None and total >= target:
            day_hit = d
    return [cum, day_hit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4])],
 [('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('regression: spring warming codling moth',
   ([4, 6, 8, 10, 12, 14], [15, 18, 20, 24, 26, 30], 10, 31, 20),
   [[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]),
  ('regression: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
  ('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: frost then warm',
   ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15),
   [[0.0, 3.0, 11.0, 22.5], 4])],
 [('control: cold days below base', ([-2, 0, 3], [5, 8, 9], 10, 30, 1), [[0.0, 0.0, 0.0], None]),
  ('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
  ('control: never emerges', ([5, 6], [12, 13], 10, 30, 50), [[1.0, 2.5], None]),
  ('control: invalid thresholds', ([5], [15], 20, 20, 5), None),
  ('regression: warm nights',
   ([18, 19, 21, 22], [28, 29, 33, 35], 12, 32, 40),
   [[11.0, 23.0, 37.5, 52.5], 4]),
  ('control: no days', ([], [], 10, 30, 5), [[], None]),
  ('control: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: spring warming codling moth[[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5][[2.5, 6.5, 11.5, 18.5, 27.5, 39.5], 5]Passed
regression: hot spell above cutoff[[15.0, 31.0, 48.5], 2][[15.0, 31.0, 48.5], 2]Passed
control: cold days below base[[0.0, 0.0, 0.0], None][[0.0, 0.0, 0.0], None]Passed
regression: exact target[[5.0, 10.0, 15.0], 2][[5.0, 10.0, 15.0], 2]Passed
control: never emerges[[1.0, 2.5], None][[1.0, 2.5], None]Passed
control: invalid thresholdsNoneNonePassed
regression: warm nights[[11.0, 23.0, 37.5, 52.5], 4][[11.0, 23.0, 37.5, 52.5], 4]Passed

SHA-256 / 2fa22b7e73cd77685308e9869b1a5b20b75a9d887fdb48d728f3874afe0a8a60

Verification & scope

Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:36.019119+00:00.

Case digest / 131138d70030224f791dec54aba6b701f52b85e10492e5fec5eb4392135be94b