Skip to content

emrg: saturation halt → low-frequency heartbeat full cycles (rant 09:35:55) - #585

Merged
argszero merged 1 commit into
masterfrom
feature/saturation-heartbeat
Aug 9, 2026
Merged

emrg: saturation halt → low-frequency heartbeat full cycles (rant 09:35:55)#585
argszero merged 1 commit into
masterfrom
feature/saturation-heartbeat

Conversation

@argszero

@argszero argszero commented Aug 9, 2026

Copy link
Copy Markdown
Owner

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".
  • New _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).
  • Run loop: wait timeout = heartbeat when saturated, normal interval otherwise; manual trigger and upstream git ls-remote advance still restore the normal frequency immediately (counter reset to 0). Saturation persistence (~/.emrg/saturation/*.json) unchanged.
  • New rants are picked up at the next heartbeat (≤8 min worst case), satisfying the rant's minimum requirement.

Acceptance mapping

  1. ✅ No more "saturation halt — skipping scheduled run"; saturated ticks log heartbeat cadence (tested).
  2. ✅ New rant handled within one heartbeat cycle (≤8 min; immediate wake is the optional branch per rant).
  3. ✅ Upstream advance / /trigger → normal frequency immediately (tested).
  4. ✅ Restart restores saturation count and heartbeat semantics (persistence untouched).
  5. ✅ 639 pytest green (was 636; +3 net saturation tests, docs synced README/README.cn/Agent.md).
  6. ✅ ≥8h tasks unaffected by 8×/8h caps (formula test).

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_repo retained.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@argszero
argszero merged commit 801fe10 into master Aug 9, 2026
1 check passed
@pm25coder

Copy link
Copy Markdown
Contributor

Tested this PR locally on Windows — the heartbeat design works as described:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants