Pulse cron state never clears entries for jobs disabled in PULSE.toml — stale failure metadata in /api/pulse/health
Summary
Releases/v5.0.0/.claude/PAI/PULSE/pulse.ts cron module loads state/state.json at startup and persists job results keyed by job name, but never reconciles against the active PULSE.toml config's enabled flags. When a previously-enabled job is disabled in PULSE.toml, its last failure metadata (lastResult, consecutiveFailures, lastRun) remains in state forever and continues to surface in /api/pulse/health cron output as if the job were still failing.
Repro
# 1. Enable any job that fails (e.g. a job pointing at a script that doesn't exist).
# 2. Wait for ≥1 failure tick. state.json now has:
# { "jobs": { "assistant-tasks": { "lastResult":"error",
# "consecutiveFailures":2,
# "lastRun":"2026-05-06T12:47:..." } } }
# 3. Edit PULSE.toml — set `enabled = false` for that job. Restart Pulse.
# 4. Query health:
curl -s localhost:31337/api/pulse/health \
| jq '.subsystems.cron.jobs[] | select(.name=="assistant-tasks")'
# {
# "name": "assistant-tasks",
# "lastResult": "error", ← still here
# "consecutiveFailures": 2,
# "lastRun": "2026-05-06T12:47:..."
# }
The dashboard renders 1 cron job failing even though no enabled job has failed in days. Looks like an active outage at first glance.
Expected — two reasonable directions
- Prune-on-load — at state load, drop entries whose key isn't in
config.jobs.filter(j => j.enabled).map(j => j.name). State file becomes self-cleaning. - Mark, don't hide — keep the entry but tag it
disabled: trueso the dashboard can render it distinctively (greyed out, "disabled" badge, removed from "failing" count).
Option 1 is the smaller diff and matches what most users expect; option 2 preserves history for users who want to re-enable later.
Suggested fix (Option 1, minimal)
In the state-load path at pulse.ts startup:
// After loading state.json and parsing PULSE.toml:
const enabledJobNames = new Set(
config.jobs.filter(j => j.enabled).map(j => j.name)
)
for (const name of Object.keys(state.jobs)) {
if (!enabledJobNames.has(name)) {
delete state.jobs[name]
}
}
await saveState(state)
Workaround until fixed
systemctl --user stop pai-pulse
STATE=~/.claude/PAI/PULSE/state/state.json
cp "$STATE" "$STATE.pre-clear-$(date -u +%Y%m%dT%H%M%SZ)"
bun -e '
const f = "'"$STATE"'";
const s = JSON.parse(await Bun.file(f).text());
delete s.jobs["assistant-tasks"]; // or whichever job is stale
await Bun.write(f, JSON.stringify(s, null, 2));
'
systemctl --user start pai-pulse
Shell gotcha worth pinning: do NOT use jq '...' "$STATE" > "$STATE" to edit in place — the redirect truncates the file before jq reads it. jq also isn't reliably installed on Linux. The bun -e form above works because Bun does the read before the write.
Environment
- PAI v5.0.0 (current main)
- Ubuntu on WSL2, systemd-user supervisor
Why surface this
Cosmetic but confusing. Disabled-jobs-still-in-state and never-run-jobs-hidden are mirror-image display gaps — together they make the /api/pulse/health cron summary unreliable for "what's actually running" questions, which is the main thing users go there for.
Hey @JElliottMiller, thank you for the PR and the work that went into it.
We're changing how LifeOS ships: from a full ~/.claude directory you run as-is, to a skill installed by an agentic installer that has your own AI integrate the pieces into your setup. That reworks the parts of the codebase this change touches, so it won't apply cleanly to where we're headed.
We're closing it for that reason, not because the idea was wrong. If the need still stands against the new model, we'd love a fresh PR once it lands. Thanks again for contributing.