worksweep systemd timer stops firing permanently after any restart or reinstall (OnUnitActiveSec with no OnCalendar)
Summary
On Linux, LIFEOS/TOOLS/com.lifeos.worksweep.timer.template schedules with OnBootSec=2min + OnUnitActiveSec=60min and no OnCalendar. After the timer is restarted or reinstalled without a reboot, systemd computes no next elapse at all and the timer never fires again. The unit still reports enabled and active, nothing is logged, and work capture just stops.
Repro (7.40.4, Linux, systemd --user)
systemctl --user restart com.lifeos.worksweep.timer
systemctl --user show com.lifeos.worksweep.timer -p NextElapseUSecRealtime -p NextElapseUSecMonotonic
NextElapseUSecRealtime=
NextElapseUSecMonotonic=infinity
systemctl --user list-timers shows NEXT - for the unit, while is-enabled and is-active both look healthy. Re-running InstallWorkSweep.ts reproduces it just as reliably as a manual restart.
Cause
OnBootSec=is relative to boot. Long after boot it is in the past and never triggers again.OnUnitActiveSec=is relative to the last activation of the bound service since the timer itself started. A freshly (re)started timer has no such activation, so there is no anchor to add 60 min to.Persistent=trueonly backfills calendar timers, so it does not rescue this case.
Net effect: any reinstall, daemon-reload + restart, or upgrade that re-enables the unit strands the hourly sweep permanently, silently. Starting the service once by hand revives it, because that activation finally gives OnUnitActiveSec its anchor.
Suggested fix
[Timer]
OnBootSec=2min
OnCalendar=hourly
Persistent=true
Unit=com.lifeos.worksweep.service
An absolute schedule cannot be stranded by a restart, and Persistent=true then genuinely catches runs missed while the machine was off. Verified locally: after the change, systemctl --user restart com.lifeos.worksweep.timer leaves NextElapseUSecRealtime populated instead of empty.
Notes
The template came in via #1692. Any other timer template using the same OnBootSec + OnUnitActiveSec pair without OnCalendar shares the failure mode and is worth a sweep.
Environment: LifeOS 7.40.4, Linux, systemd --user, bun.
Extra data point: this is not a one-off in the worksweep template, it is a pattern that bites any timer written this way.
On the same install I maintain a separate 5-minute systemd --user timer that originally used the identical OnBootSec + OnUnitActiveSec pair. It failed the same way — silently stranded with NextElapseUSecMonotonic=infinity after the first restart, unit still reporting enabled and active — and switching it to OnCalendar=*:0/5 with Persistent=true fixed it for good. A third timer here had already been converted to OnCalendar for exactly this reason before I traced it back to the shipped template.
So the suggested fix is worth applying as a rule for the systemd backend generally, not just to com.lifeos.worksweep.timer.template: an interval that must survive restarts belongs in OnCalendar, and OnUnitActiveSec should be reserved for cases where anchoring on the previous run is genuinely wanted and a missed window is acceptable.
Verification that distinguishes the two, in case it helps a regression check:
systemctl --user restart <unit>.timer
systemctl --user show <unit>.timer -p NextElapseUSecRealtime -p NextElapseUSecMonotonic
Broken form returns an empty realtime value and infinity monotonic; the OnCalendar form returns a concrete timestamp. systemctl --user is-active reports active in both cases, which is why this goes unnoticed.
Fixed in source as the class you called it: the systemd generator (LIFEOS/TOOLS/lib/SystemdUser.ts) now emits OnCalendar= for interval specs and scopes Persistent=true to the calendar branch where systemd actually honors it, and both standing templates (worksweep, atlas) carry absolute schedules. One correction from our verification: Persistent=true was present in all three sites—the real defect was that it's documented-effective only on calendar timers, so it was dead config; the doc comment claiming otherwise is fixed too. Thanks for the restart repro.