Skip to content

feat: scheduled wakeup primitive for delegates (ScheduleWakeup / WakeupFired)#82

Draft
sanity wants to merge 1 commit into
mainfrom
feat/delegate-scheduled-wakeup
Draft

feat: scheduled wakeup primitive for delegates (ScheduleWakeup / WakeupFired)#82
sanity wants to merge 1 commit into
mainfrom
feat/delegate-scheduled-wakeup

Conversation

@sanity

@sanity sanity commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Delegates have no way to schedule future execution. The OutboundDelegateMsg
enum has no ScheduleWakeup-equivalent variant and InboundDelegateMsg has no
WakeupFired, so delegate execution is purely message-driven. dApps that need
periodic 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.

  • OutboundDelegateMsg is deliberately left not #[non_exhaustive]: the
    host must consciously handle every outbound variant, so the compiler should
    force an arm for each new one. The inaccurate doc comment on
    InboundDelegateMsg that claimed OutboundDelegateMsg was already
    #[non_exhaustive] is corrected.
  • InboundDelegateMsg stays #[non_exhaustive]; unknown inbound variants are
    forwarded to the delegate WASM unchanged, so WakeupFired flows through.
  • These variants travel only on the bincode host↔delegate FFI path, not the
    FlatBuffers WS path, so no .fbs schema / generated-code / TypeScript changes
    are needed. ScheduleWakeup gets a "reached client serialization - this is a
    bug" arm in the WS encoder mirroring SendDelegateMessage.

Bumps 0.8.20.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]

…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
@sanity

sanity commented Jul 2, 2026

Copy link
Copy Markdown
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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant