nx_shelf_life.nx
buildroot/runtime/nx_shelf_life.nx
about
nx_shelf_life.nx -- FOOD-SCIENCE SUITE / SHELF-LIFE rung. Accelerated
shelf-life testing (ASLT) via the Q10 model, plus a cold-chain breach
accumulator that tracks the FRACTION of shelf life a product consumes
across its real temperature history -- so "best by" reflects how the
food was actually stored, not a fixed date.
Q10 = ratio by which the quality-loss RATE changes per 10 C. Shelf life
scales as Q10^(-dT/10): 10 C warmer -> life / Q10; 10 C colder -> life x
Q10. INTEGER-EXACT at decade steps (same powers-of-integer trick as the
preservation z-value).
THE exceed: a printed date assumes one storage temperature forever. This
computes life at any decade temperature AND accumulates consumed life
across segments, so a cold-chain breach shortens the remaining date by
construction (fraction consumed >= 1.000 -> expired).
===== THE DECADE-ONLY GAP, NOW CLOSED ============================
sl_at_temp returns -1 for any temperature difference that is not a
multiple of 10 C. That was documented as an honest gap, but it made the
organ unable to answer the question the whole category rests on: ICH
stability compares 25 C with 40 C, a FIFTEEN degree gap. The organ
refused the one comparison that matters commercially.
sl_at_temp_frac closes it by moving into decade-log space, where a
fractional power is just a multiplication:
Q10^(-dT/10) = 10^(-dT*log10(Q10)/10)
Both halves already existed in nx_pow10 (this suite's own shared numeric
rung), so this is a CHANGE OF VARIABLE, not a second model.
ADDITIVE, per the API-stability rule: sl_at_temp is untouched and every
existing caller and test is unaffected. Where both are defined the new
path DELEGATES to the exact integer one -- an interpolated logarithm is
never better than exact repeated multiplication. sl_scale_frac_q3 is
exposed separately so the gate can compare the interpolated path against
the exact one head-on; testing only the dispatcher would pass vacuously
at decade steps by measuring the exact path twice.
grounded: q10_accelerated_shelf_life_testing + arrhenius_food_quality_kinetics
genealogy_id: aslt_q10_model + nishi_food_science_suite
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_pow10.nx
imported by: nx_labsci_svc.nxnx_shelf_life_test.nx
structs
| none |
consts
| 44 | const K_MAGIC_1000000: i64 = 1000000 |
functions
| 47 | func sl_q10_pow(q10: i64, steps: i64) -> i64 |
| 62 | func sl_at_temp(sl_ref_days: i64, tref_c: i64, q10: i64, t_c: i64) -> i64 |
| 78 | func sl_scale_frac_q3(q10_q3: i64, delta_c: i64) -> i64 |
| 88 | func sl_at_temp_frac(sl_ref_days: i64, tref_c: i64, q10_q3: i64, t_c: i64) -> i64 |
| 107 | func sl_life_consumed_milli(days: i64, sl_days: i64) -> i64 called by 1: main |
| 113 | func sl_is_expired(consumed_milli: i64) -> i64 called by 1: main |
| 119 | func sl_remaining_milli(consumed_milli: i64) -> i64 called by 1: main |