feat(runtime): unified Automation replaces session-internal CronJob (#643 by @hqhq1025, adopted with review fixes) - #656
Merged
Conversation
…643 by @hqhq1025) — adopted with review fixes F1-F3+F5 Adopts PR #643 (unified Automation: heartbeat + cron, single tool) onto current main as a squash, preserving main's ToolCardBody dispatch and the #647 tool-activity refactors, with the maintainer's review fixes: - F1 (HIGH, automation-scheduler.ts): the busy-session defer budget is a ~45min wall-clock window (DEFER_WINDOW_MS, equivalent to the old wakeup-scheduler's 5s→5min exponential backoff), replacing the ~120s 24-retry cap. A transient busy window no longer terminally expires a `once` automation — skipFire only runs when the window is exhausted. - F2 (HIGH, automation-can-fire.ts): 'waiting_for_user' joins HEARTBEAT_IDLE_STATUSES (#639 decision — the wakeup's home scenario is starting a turn in place of the user); the desktop canfire test now pins the new set instead of the opposite. - F3 (MEDIUM, automation-state.ts): computeJitter ported verbatim from the old wakeup-scheduler and wired into computeNextFire — recurring (interval/cron) re-schedules get up to 10% delay jitter capped at 15min, one-shot fires landing on :00/:30 get up to 90s early jitter, computed on the actual fire timestamp. Mirrored the old jitter unit tests and added wiring coverage; AutomationManagerDeps gains an injectable `random`. - F5 (MEDIUM, packages/ui/tool-activity.tsx): AutomationResultPreview card (created/deleted/listed, localized) replaces the deleted CronJobResultPreview inside the shared ToolCardBody dispatch, plus a new desktop contract test binding the runtime tool's real output strings to the rendered card. - LOW: MAX_TERMINAL_KEPT 5 → 50 (old wakeup history cap) and the model-facing list now surfaces deferred fire attempts (deferredFireCount), mirroring the old CronList fire_attempts. - Fix: the CLI scheduler tick timer is unref()ed — the PR's always-on 5s tick kept the Node event loop alive, hanging any bootstrap consumer that exits without close() (this hung the CLI test suite indefinitely). Also allow-listed the PR's CLI persistence warnings in check-console. Original feature authored by @hqhq1025 in #643.
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.
Adoption of #643 — the unified Automation primitive by @hqhq1025 — with the four review fixes applied, per the maintainer review on that PR.
Design pivot accepted
The unified Automation is a genuine superset of the #639 WakeupScheduler where it matters: durable
automations.jsonpersistence (fail-loud, shared-store-safe), cross-restart and cross-session cron (fires into a fresh session after the creator is archived), first-class once/interval/cron kinds, and a stronger cron parser. The author's test discipline is excellent (~2400 lines, behavioral, incl. a mutation-verify suite).Review fixes applied on top (they reverted #639 decisions)
onceautomation. (automation-scheduler.ts)waiting_for_useris back in the heartbeat idle set — the wakeup's home scenario per feat(runtime): session-internal CronJob scheduling (#545 + review fixes) #639; the test that pinned the opposite is re-pinned. (automation-can-fire.ts)AutomationResultPreviewcards replace the deleted CronJob preview instead of raw-JSON fallback; contract test drives the real tool output through the real renderer. (tool-activity.tsx)listoutput exposes deferred-fire counts.unref()ed in runtime-bootstrap.Verification
Supersedes #643; the model-facing tool renames CronCreate/CronDelete/CronList → a single
Automationtool (breaking for prompts/skills referencing old names — flagged in the PR body for release notes).