Skip to content

Support eager state whitelist - #259

Closed
slinkydeveloper wants to merge 1 commit into
mainfrom
preload-state
Closed

slinkydeveloper wants to merge 1 commit into
mainfrom
preload-state

Conversation

@slinkydeveloper

Copy link
Copy Markdown
Contributor

Port of restatedev/sdk-typescript#798 to the Python SDK.

Changes

  • New state_preload option on VirtualObject/Workflow constructors and on their handler decorators:
    • True: preload all state (default server behavior)
    • False: preload nothing (lazy state)
    • ["key1", "key2"]: preload only the listed keys eagerly (requires restate-server >= 1.8)
  • enable_lazy_state is kept but deprecated. Setting both options raises a ValueError.
  • Discovery manifest: new eagerStateKeysWhitelist field on services and handlers, resolved from state_preload with the same semantics as the TypeScript SDK (list is copied, empty list means fully lazy, stateless services never advertise state options).
  • Endpoint manifest v5 negotiation. The whitelist is rejected when the negotiated manifest version is < 5; enableLazyState alone keeps working on v3/v4.
  • Fixed two stray $ in discovery error messages.
  • README compatibility table updated with Restate 1.8.

Tests

New unit tests in tests/discovery.py covering all option mappings, the mutual-exclusion error, workflow and stateless-service cases, v4 rejection and v5 JSON output.

🤖 Generated with Claude Code

Port of restatedev/sdk-typescript#798.

Add the `state_preload` option on VirtualObject/Workflow constructors and
handler decorators, accepting True (preload all), False (preload nothing)
or a list of state keys to preload eagerly. The list form is advertised
through the new `eagerStateKeysWhitelist` manifest field, which requires
endpoint manifest v5 (restate-server >= 1.8).

`enable_lazy_state` is kept but deprecated; setting both raises ValueError.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the full port of the eager state whitelist (state_preload) from sdk-typescript#798. The manifest mapping matches the TypeScript resolveStatePreload one for one. tests/discovery.py passes (10 tests), and ruff, pyright and mypy are clean on the changed files.

  • New state_preload option: added to the VirtualObject/Workflow constructors and their handler decorators, threaded through make_handler and Handler. The positional make_handler call sites in object.py and service.py were updated in the right order.
  • Deprecation of enable_lazy_state: check_state_preload_options raises ValueError when both options are set, both at service level and handler level.
  • Manifest resolution: resolve_state_preload maps True/False/list to enableLazyState + eagerStateKeysWhitelist. The list is copied, an empty list means fully lazy, and stateless services advertise neither field.
  • Manifest v5 negotiation: send_discovery prefers v5. compute_discovery_json rejects any whitelist when the negotiated version is ≤ 4, and enableLazyState alone keeps working on v3/v4. The stray $ in two error messages is fixed.
  • README: added a Restate 1.8 compatibility row and a note scoping the list form to ≥ 1.8.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Test Results

  8 files  ±0    8 suites  ±0   3m 50s ⏱️ -30s
 71 tests ±0   71 ✅ ±0  0 💤 ±0  0 ❌ ±0 
322 runs  ±0  322 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 08791a0. ± Comparison against base commit 670c823.

@slinkydeveloper
slinkydeveloper deleted the preload-state branch November 4, 2026 15:20
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant