Use declared types for transfer serialization - #1878
Draft
tconley1428 wants to merge 4 commits into
Draft
tconley1428 wants to merge 4 commits into
tconley1428 wants to merge 4 commits into
Conversation
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.
Select transfer type converters from declared argument and result types during serialization. When a hint is absent, or the declared type has no registered converter, skip transfer conversion. The runtime type is never used for selection. The hint only selects the converter: conversion still calls the existing
to_transfer_type(value)method.Carry hints through workflow and activity calls, signals, queries, updates, update-with-start, continue-as-new, schedules, and Nexus calls. Generated System Nexus calls obtain their input hints from registered operation definitions for now; temporalio/nexgen#194 tracks generating operation objects instead. Add
encode_with_type_hintsandto_payloads_with_type_hints, which scope hints in a privateContextVarand invoke existingencode(values)/to_payloads(values)overrides with the original sequence unchanged. PreserveRawValuepassthrough.Bind hints to the original sequence so unrelated nested conversions cannot use them. Hide the context before invoking transfer and inner payload converters, restore it in
finally, and expire it for child tasks that outlive the originating call. Custom overrides must forward the original sequence to retain hints; rebuilt sequences receive no transfer conversion unless hints are supplied again.Validation:
poe formatandpoe lintpassed, including Pyright, mypy, basedpyright, and docstyle.poe test -s -n 4 tests/test_serialization_type_hints.py tests/test_converter.py tests/test_serialization_context.py tests/nexus/test_temporal_system_nexus.py tests/worker/test_interceptor.py tests/worker/test_update_with_start.py tests/contrib/pydantic/test_pydantic.py tests/test_extstore.py.New tests cover declared/runtime disagreement, absence of hints or registered converters, generic selection, old-signature overrides, sequence identity, nested and concurrent serialization, error/cancellation cleanup, context expiration in child tasks, raw payloads, and end-to-end input/result conversion.