Repository navigation
Heartbeat: do not wake the orchestrator on an idle floor - #30
Merged
Merged
Conversation
added 2 commits
September 28, 2026 10:56
beat() lived entirely inside index.ts, which imports Electron and cannot be exercised outside the main process. Pull the actual decision — and the tasks.json 'doing' count it will soon depend on — into heartbeatPolicy.ts (node builtins only) so both can be unit tested directly, following the same pattern already used for the breaker and worker-wake watchdog. doingTaskCount() is deliberately fail-open toward "has doing cards" on any read failure (missing file, corrupt JSON, wrong shape) rather than toward zero, since it will gate whether a quiet floor is left alone.
Until now every beat re-engaged god on any quiet floor, regardless of whether there was work in flight — a floor that finished its work hours ago gets re-engaged on the same cadence as one mid-stall. Gate that case on tasks.json: a quiet floor with at least one 'doing' card may be a stall worth a look; a quiet floor with nothing doing has nothing for god to review. Real inbox mail still always re-engages regardless of this gate. Reversible without a rebuild via the new suppressWhenIdle flag on the heartbeat mission (config.json), default true. A suppressed beat logs a heartbeat-suppressed event (reason + counts) instead of silently doing nothing, and re-arms on the normal cadence rather than the back-off a real re-engage takes.
🚫 This PR is missing its before/after evidenceEvery pull request here has to show its work. Screenshots or a short screen recording, before the change and after it.
How to fix it: edit the description, keep the A bug fix with no visible surface still needs it: show the failing behaviour, then the same steps passing. A terminal recording is fine. Genuinely nothing to show — a CI tweak, a typo, a dependency bump? A maintainer can apply the |
aaroncoville
pushed a commit
that referenced
this pull request
Sep 28, 2026
No conflicts. index.ts carries both the codex hook-trust wiring and the extracted heartbeat re-engage policy.
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.
Stops the floor heartbeat from waking the orchestrator when there is nothing to review.
Today a beat re-engages the orchestrator whenever the floor has been quiet for
quietThresholdMs, even with no unread mail and no work in flight. Measured over one idle morning that was 23 consecutive no-op wakes, each re-reading a large context for no action.Decision extracted.
src/main/heartbeatPolicy.tsholds the pureshouldReengage()rule (Electron-free, likebreaker.tsandworkerWake.ts): actionable inbox mail always re-engages; an active floor never does; a quiet floor re-engages unlesssuppressWhenIdleis on andtasks.jsonhas no card indoing. A quiet floor with work in flight may be a stall and still wakes the orchestrator.Fail toward waking.
doingTaskCount()treats a missing root, missing file, corrupt JSON or a non-arraytasksfield as "at least one doing card". Only a present, valid, empty array is a trusted zero. The ledger is read only when it can change the outcome.Reversible without a rebuild. New
ScheduledMission.suppressWhenIdle(defaulttrue, baked onto the heartbeat mission);falserestores the previous behaviour. A suppressed beat appends aheartbeat-suppressedevent tolog.jsonland re-arms on the normal cadence, with no back-off.Verification:
test/heartbeat-policy.test.cjs, 11 cases written red-first, covering all four decision directions and the fail-open contract; typecheck clean; full suite 1450 pass with the failing set identical by name to the base commit (sandbox-bound tests). Takes effect on the next app restart.