emrg: saturation halt → low-frequency heartbeat full cycles (rant 09:35:55) - #585
Conversation
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle. Sound improvement over the complete halt: saturated ticks keep running full cycles at heartbeat cadence (max(interval, min(interval*8, 8h)) — verified across boundary cases 1s→8s, 60s→480s, 8h→8h, 24h→24h), manual trigger wakes immediately, #531 remote-advance auto-resume preserved (counter reset). Tests cover both positive/negative states + log-message guard (no 'skipping scheduled run') + full-cycle execution at saturation (30→31); doc counts 636→639 consistent with +3 tests. Awaiting CI.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle (2). CI 31288746017 SUCCESS; mergeable. Second independent-cycle approval. Re-verified the heartbeat formula boundary cases and both-state test coverage; doc counts consistent. Waiting for third LGTM.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle (2)
Re-verified on head 6cc53cb: run loop waits at heartbeat cadence when saturated (never skips), manual trigger resets counter and wakes immediately, upstream advance restores normal frequency. _heartbeat_interval() formula matches the rant spec (max(interval, min(interval×8, 8h))). Local: 639 pytest passed (11.42s) + import/help OK. Rant acceptance items all addressed.
|
Tested this PR locally on Windows — the heartbeat design works as described: |
Summary
Replaces the complete saturation halt (rant #559 behavior) with low-frequency heartbeat full cycles per host decision (rant 2026-08-09T09:35:55): protection = slow down, never stop. Even with zero upstream activity and zero new rants, the scheduler keeps running complete Prepare→Review→Discover→Improve→Submit→Record cycles at a reduced cadence.
Changes (emrg/server/scheduler.py)
_saturation_halt_active()→_saturation_heartbeat_active(): at/above the 30-empty-cycle threshold the tick is not skipped — it runs at the heartbeat interval. Log message changed from "saturation halt — skipping scheduled run" to "running full cycle at heartbeat interval … — never halting"._heartbeat_interval():max(task_interval, min(task_interval × 8, 8 hours))— 60s task → 480s (8 min), 10-min task → 80 min, 1h task → 8h, ≥8h tasks unchanged (no frequency runaway).git ls-remoteadvance still restore the normal frequency immediately (counter reset to 0). Saturation persistence (~/.emrg/saturation/*.json) unchanged.Acceptance mapping
Tests (tests/test_scheduler.py)
test_heartbeat_interval_formula— 7 interval cases incl. cap and ≥8h unchanged.test_saturation_heartbeat_active_true_when_remote_unchanged/..._log_message_no_skip/..._resumes_and_resets_when_remote_advanced/..._false_below_threshold.test_saturated_tick_still_runs_full_cycle— saturated handler runs a full cycle (never skipped), counter keeps incrementing on NTE.test_remote_advanced_false_without_git_reporetained.