fix(heartbeat): type wake scheduling intent#76086
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. A focused unit path can seed the cooldown helper or runner with five recent run starts, call the cron/system Next step before merge Security Review findings
Review detailsBest possible solution: Keep the typed cooldown design, but classify explicit operator wake-now requests as Do we have a high-confidence way to reproduce the issue? Yes. A focused unit path can seed the cooldown helper or runner with five recent run starts, call the cron/system Is this the best way to solve the issue? No. Centralized typed wake intent is the right direction, but using Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 6a54aac4892c. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: deba2340f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const requestHeartbeatNow: PluginRuntime["system"]["requestHeartbeatNow"] = (opts) => | ||
| requestHeartbeat({ | ||
| source: opts?.source ?? "other", | ||
| intent: opts?.intent ?? "event", |
There was a problem hiding this comment.
Preserve immediate semantics for requestHeartbeatNow alias
The deprecated runtime.system.requestHeartbeatNow() compatibility shim now defaults to intent: "event", which makes legacy callers defer behind nextDueMs instead of waking promptly. Before this change, requestHeartbeatNow effectively bypassed interval gating for non-interval reasons, so plugins relying on the old API to surface system events quickly will now be delayed until the next heartbeat tick unless they were updated to pass intent explicitly. For a deprecated compatibility alias, this is a behavior regression that can silently break existing plugins.
Useful? React with 👍 / 👎.
| state.deps.enqueueSystemEvent(text); | ||
| if (opts.mode === "now") { | ||
| state.deps.requestHeartbeatNow({ reason: "wake" }); | ||
| state.deps.requestHeartbeat({ source: "manual", intent: "immediate", reason: "wake" }); |
There was a problem hiding this comment.
Classify manual wake-now requests as manual intent
wake(..., { mode: "now" }) is the explicit operator-triggered wake path, but it is tagged as intent: "immediate" instead of "manual". In the new cooldown policy, only manual is fully exempt from deferral, while immediate can still be dropped by the flood guard. This means repeated user-issued wake-now commands can be suppressed under burst conditions, which contradicts the intended non-deferred manual path.
Useful? React with 👍 / 👎.
Co-authored-by: Jordan Baker <jbb@scryent.com>
|
Landed in Maintainer fixups:
Proof:
|
Summary
source/intentwake requests.runtime.system.requestHeartbeatNow()alias while adding the structured API.Credits
Co-authored-by: Jordan Baker jbb@scryent.com
Test plan
pnpm test src/infra/heartbeat-reason.test.ts src/infra/heartbeat-cooldown.test.ts src/infra/heartbeat-wake.test.ts src/infra/heartbeat-runner.scheduler.test.ts src/cron/service.main-job-passes-heartbeat-target-last.test.ts src/cron/service/timer.test.ts src/gateway/server-cron.test.ts src/plugins/runtime/index.test.tsgit diff --check origin/main..HEADReplaces #75439.
Closes #64016.
Refs #17797, #75436.