fix(run): always run on schedule; rate-limit only the empty heartbeat - #6
Merged
Conversation
The catch-up gate skipped a whole run when `now - last_successful_run` was under one INTERVAL_DELTA. On a fixed-clock-time schedule each run completes a few seconds after the scheduled instant, so the next same-time fire lands just under the delta and was dropped — the digest fired roughly every other day. Detection now always runs when the native scheduler fires. Real changes are never gated; the delivery ledger keeps them idempotent. Only the empty "nothing notable" heartbeat is rate-limited (`_empty_digest_due`): suppressed when the previous successful run was under half an interval ago, so two fires close together do not double-send it. `--force` overrides; cron always sends. `mark_successful_run` now fires on every run so the window advances even when the heartbeat is suppressed. Co-Authored-By: Penny-One (Batcave) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a fixed-clock-time schedule (e.g. launchd
StartCalendarIntervalat 09:00), the digest fired only about every other day.run_oncegated the whole run on_catch_up_due— a strictnow - last_successful_run >= INTERVAL_DELTA. Each run completes a few seconds after the scheduled instant, so the next same-time fire is always a hair under 24h and the gate skipped it entirely (no detection, no digest, run not marked). The skip left an empty 0-byte log andlast_successful_rununtouched, which is exactly how this was diagnosed on a live install.Fix
_empty_digest_due: the "nothing notable" digest is suppressed when the previous successful run was under half an interval ago, so two fires close together (a manual run plus the scheduled one, or a wake double-fire) don't double-send it.--forceoverrides; cron always sends.mark_successful_runnow fires on every run, so the window advances even when the heartbeat is suppressed.Tests
TDD — the two new behavior tests were watched failing against the gated code first. Replaced the two obsolete catch-up tests with:
test_run_within_interval_still_delivers_changes(the every-other-day fix)test_empty_digest_suppressed_when_last_run_recenttest_empty_digest_sent_after_interval_with_prior_runtest_force_sends_empty_despite_recent_runFull suite: 472 passed; ruff clean. CLAUDE.md invariant updated.
🦇 Generated by Penny-One at Batcave