FA-65661 / Ecological population dynamics / Open access
Insect degree-day accumulation with horizontal cutoff: emergence threshold · case 01
Emergence is predicted one day late when the target is hit exactly.
ROOT CAUSE
The threshold comparison is strict.
VERIFIED REPAIR
Restore the emergence threshold rule: `total >= target`.
Unsuccessful approach: Rounding the total before comparing triggers emergence early.
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=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 = [[('control: 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]),
('control: 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: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], 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),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: 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),
('control: 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]),
('regression: 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: 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 |
| control: 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], 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 thresholds | None | None | Passed |
| regression: near-miss rounding | [[9.6, 9.6], None] | [[9.6, 9.6], None] | Passed |
SHA-256 / 68b76ad19eb07dd7aed346bca09579c13c3f43ab50e6dbee9c831dc857d83b35
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 round(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 = [[('control: 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]),
('control: 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: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], 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),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: 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),
('control: 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]),
('regression: 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: 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 |
| control: 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 thresholds | None | None | Passed |
| regression: near-miss rounding | [[9.6, 9.6], 1] | [[9.6, 9.6], None] | Failed |
SHA-256 / 52e9c364eb4e69e738ed38e804ad9d851c78e2b4f60ec6c1e3611edd4a80ecd6
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 = [[('control: 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]),
('control: 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: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], 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),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: hot spell above cutoff', ([20, 22, 25], [34, 38, 40], 10, 30, 30), [[15.0, 31.0, 48.5], 2]),
('regression: exact target', ([10, 10, 10], [20, 20, 20], 10, 30, 10), [[5.0, 10.0, 15.0], 2]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: frost then warm', ([-5, 2, 11, 14], [6, 16, 25, 29], 10, 30, 15), [[0.0, 3.0, 11.0, 22.5], 4])],
[('control: 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]),
('control: 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]),
('regression: near-miss rounding', ([10, 10], [29.2, 10], 10, 30, 10), [[9.6, 9.6], None]),
('control: 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),
('control: 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]),
('regression: 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: 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 |
| control: 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 thresholds | None | None | Passed |
| regression: near-miss rounding | [[9.6, 9.6], None] | [[9.6, 9.6], None] | Passed |
SHA-256 / f54ece6c3641f11114845d9d8e66c7df730363a30f48fda6a979945eafb95451
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.007553+00:00.
Case digest / d873d675c337f62534b499ed462c3e2b4823e14b5e0b447f613daa4090d2b7c9