Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

fix(pulse): deriver agent has one 03:00 trigger and RunAtLoad=false — never runs on a machine that is off overnight

Open xmasyx opened this issue 4 months ago • 2 comments

Summary

The learning-deriver launchd agent has exactly one trigger — a 03:00 calendar slot — and RunAtLoad explicitly disabled. On any machine that is powered off overnight (i.e. most laptops), that slot is unreachable and the deriver never runs at all. Nothing reports this: the job is loaded, the plist is valid, and the work simply never happens.

Root cause

LIFEOS/PULSE/com.lifeos.deriver.plist:

<key>StartCalendarInterval</key>
<dict>
    <key>Hour</key><integer>3</integer>
    …
</dict>
<key>RunAtLoad</key>
<false/>

launchd catches up a missed StartCalendarInterval after sleep → wake, but not after a cold boot. A laptop shut down at night therefore skips the slot entirely, every night, with no compensating trigger.

Proposed fix

Add a second trigger and make the job idempotent so the two cannot double-run:

<key>ProgramArguments</key>
<array>
    …
    <string>--once-daily</string>
</array>

<!-- Two triggers, both idempotent via --once-daily:
     1. StartCalendarInterval 03:00 — fires on nights the machine stays on.
     2. RunAtLoad — fires at login/boot, the ONLY reachable trigger when the machine is
        powered OFF overnight (launchd does not catch up a missed calendar slot after a
        cold boot, only after sleep→wake). -->
<key>RunAtLoad</key>
<true/>

with a once-per-day guard in the deriver itself, keyed on the local date so a timezone change cannot skip or repeat a day:

const DERIVER_LASTRUN_FILE = path.join(MEMORY_DIR, "OBSERVABILITY", "deriver-lastrun.date");
// --once-daily: run at most once per calendar day no matter how many logins happen.

RunAtLoad alone would be wrong — it would re-run on every login. The guard is what makes the second trigger safe.

Running locally since 2026-07-14. Happy to open a PR.

xmasyx avatar Jul 25 '26 21:07 xmasyx

Cross-reference: this is a specific, still-shipping instance of #1513 ("Pulse cron scheduler and launchd LaunchAgents don't catch up missed nightly jobs"), which is closed.

I checked the v7.1.1 release tarball before filing: LIFEOS/PULSE/com.lifeos.deriver.plist still ships StartCalendarInterval at 03:00 with RunAtLoad set to <false/>, so whatever landed for #1513 did not reach this agent. Filing separately rather than reopening because the fix here is local to one plist plus a once-daily guard in the deriver, but happy to have it folded into #1513 if that is the better home for it.

xmasyx avatar Jul 25 '26 21:07 xmasyx

Thanks @xmasyx — this is already fixed in the current source: RunAtLoad=true with a once-daily local-date guard, as you proposed. Closing; it'll be in the next release.

danielmiessler avatar Aug 06 '26 05:08 danielmiessler