feat: scheduled wakeup primitive for delegates (ScheduleWakeup / WakeupFired)#82
Draft
sanity wants to merge 1 commit into
Draft
feat: scheduled wakeup primitive for delegates (ScheduleWakeup / WakeupFired)#82sanity wants to merge 1 commit into
sanity wants to merge 1 commit into
Conversation
…upFired)
Add two variants to the host<->delegate protocol enums so a delegate can
schedule future execution without a connected UI (key rotation, TTL pruning,
scheduled publication):
- OutboundDelegateMsg::ScheduleWakeup { at: SystemTime, tag: Vec<u8> }
- InboundDelegateMsg::WakeupFired { tag: Vec<u8> }
Both are appended at the end of their enums (bincode variant tag 8), so the
change is wire-compatible for every existing variant: delegate WASM compiled
against an older stdlib keeps deserializing everything it already understood.
New wire-format pin tests freeze the tags. OutboundDelegateMsg stays exhaustive
(deliberately not #[non_exhaustive]) so the host must handle every outbound
variant; the inaccurate doc claiming it was already non_exhaustive is corrected.
Bumps 0.8.2 -> 0.8.3. Host-side implementation lands in freenet-core#3972.
Refs: freenet/freenet-core#3972
[AI-assisted - Claude]
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K8mqiskQracG7CDVLSxDJC
Contributor
Author
|
Host-side consumer: freenet/freenet-core#4666 (issue #3972). This stdlib PR must merge + publish 0.8.3 first (stdlib-first), then the core PR can build. [AI-assisted - Claude] |
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.
Problem
Delegates have no way to schedule future execution. The
OutboundDelegateMsgenum has no
ScheduleWakeup-equivalent variant andInboundDelegateMsghas noWakeupFired, so delegate execution is purely message-driven. dApps that needperiodic background work (key rotation, TTL pruning, scheduled publication) are
forced to push it into a UI/client sync loop, which stops working when the UI is
closed. Driving use case: River private-rooms weekly secret rotation
(freenet/river#228).
Approach
Add the two wire variants the host↔delegate protocol needs:
OutboundDelegateMsg::ScheduleWakeup { at: SystemTime, tag: Vec<u8> }InboundDelegateMsg::WakeupFired { tag: Vec<u8> }Both are appended at the end of their enums (bincode variant tag 8), so the
change is wire-compatible for every existing variant — delegate WASM compiled
against an older stdlib keeps deserializing everything it already understood.
OutboundDelegateMsgis deliberately left not#[non_exhaustive]: thehost must consciously handle every outbound variant, so the compiler should
force an arm for each new one. The inaccurate doc comment on
InboundDelegateMsgthat claimedOutboundDelegateMsgwas already#[non_exhaustive]is corrected.InboundDelegateMsgstays#[non_exhaustive]; unknown inbound variants areforwarded to the delegate WASM unchanged, so
WakeupFiredflows through.FlatBuffers WS path, so no
.fbsschema / generated-code / TypeScript changesare needed.
ScheduleWakeupgets a "reached client serialization - this is abug" arm in the WS encoder mirroring
SendDelegateMessage.Bumps
0.8.2→0.8.3.Testing
New wire-format pin tests freeze the variant tags so a future reorder is caught
loudly:
inbound_wakeup_fired_wire_format_is_stable— full byte layout at tag 8.outbound_schedule_wakeup_wire_format_is_stable— tag 8 + round-trip.Downstream
Host-side implementation is in freenet-core#3972 (opens after this publishes,
per the stdlib-first release policy).
Refs: freenet/freenet-core#3972
[AI-assisted - Claude]