You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more
PR #4741 Review: refactor(rivetkit-core): remove prevent_sleep field and deprecate set_prevent_sleep to no-op
Overview
This PR removes the prevent_sleep field from rivetkit-core's ActorContextInner and converts set_prevent_sleep / prevent_sleep into deprecated no-ops, while retaining the NAPI surface for bridge compatibility. The intent is to replace the old pull-style flag with keep_awake (RAII guard) and wait_until (future-scoped hold).
Critical: AgentOS regression
The agentOS layer (agent-os/actor/index.ts, process.ts, shell.ts, session.ts) still calls syncPreventSleep(c) → c.setPreventSleep(shouldPrevent) to hold the actor awake while a subprocess or shell session is running. After this change, those calls go through the NAPI bridge into a no-op. AgentOS actors running on the native (NAPI) path can now sleep prematurely while a process is still alive. This is a behavioral regression that needs to be fixed before or alongside this change.
Tests will pass vacuously or fail
actor-sleep.test.ts lines 596–691 test three concrete scenarios: that preventSleep blocks auto-sleep until cleared, delays shutdown, and can be restored on wake. All three rely on setPreventSleep actually preventing sleep. Against the NAPI driver these tests now exercise a no-op and either:
pass vacuously (the actor was already sleeping for another reason), or
fail because the expected sleep-blocking behavior is gone.
These tests should be removed, skipped for the native driver, or replaced with equivalent keep_awake / wait_until tests before this ships.
TypeScript pure path and NAPI path now diverge
The pure-TypeScript actor instance (actor/instance/mod.ts) retains the full preventSleep state machine — #preventSleep, #waitForPreventSleepClear, CanSleep.PreventSleep, etc. The NAPI path converts those calls to no-ops. Callers currently cannot tell which runtime they're on, so the same actor code exhibits different sleep behavior depending on the driver. The PR should either:
stub out the TS side too (marking it deprecated and always returning false), or
document the intentional split and note that the TS path will be updated in a follow-up.
Minor: #[allow(deprecated)] without an explanatory comment
The #[allow(deprecated)] suppression in rivetkit-napi/src/actor_context.rs is correct, but a one-line comment explaining why ("NAPI bridge retains this surface for TS callers still using setPreventSleep") would make the intent clearer to future readers.
Positive notes
The removal of prevent_sleep_notify and the PreventSleep variant from CanSleep is clean; no dead branches left.
Propagating #[deprecated] through both rivetkit-core and the thin rivetkit (Rust) wrapper with #[allow(deprecated)] in the forwarders is the correct pattern.
Keeping the NAPI surface as a no-op rather than removing it avoids a hard break in downstream TS code that may still call setPreventSleep.
Summary
The core cleanup is well-motivated, but the PR has a behavioral regression in agentOS and leaves tests that now exercise a no-op. The asymmetry between the TS-pure and NAPI paths also needs to be called out explicitly (in the PR description at minimum). Recommend resolving the agentOS syncPreventSleep calls and the affected test suite before marking ready for review.
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
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.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: