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
{{ message }}
Repository navigation
Type-check RPC Start params from endpoint signatures #514
RPC endpoint argument contracts are only partially represented today.
@tractor.context records the endpoint's inspect.Signature, but a
dialog's pld_spec does not cover Start arguments and the captured
signature is not yet used to derive a typed Start message contract.
Caller-facing APIs also cannot consistently preserve the endpoint's full
positional, keyword-only, defaulted, and variadic signature for static
checking.
PR #481 moved to_actor.run() toward this model with TypeVarTuple and
local inspect.Signature.bind() validation. PR #484 established functools.partial() as the way to bind target keyword arguments without
colliding with actor-runtime options. The remaining work is to carry that
contract through the RPC protocol instead of treating it as a local
one-shot special case.
Goal
Derive an RPC endpoint's Start parameter contract from its callable
signature and annotations, preserving that signature at the caller where
Python's typing machinery permits it.
The intended direction is:
use ParamSpec, Concatenate, PEP 695 type parameters, or the nearest
workable equivalent to preserve caller-facing endpoint signatures;
validate arguments sender-side before transmitting Start when the
callable and its signature are locally available;
validate against the same contract at endpoint dispatch so dynamically
addressed or remote-only targets remain safe;
report argument-contract failures consistently without starting an
invalid RPC task;
generate or associate the corresponding typed Start message schema
rather than adding a second unrelated validation model.
Design questions
Which APIs can retain a useful ParamSpec: to_actor.run(), Portal.run(), Portal.open_context(), and/or @tractor.context?
How should the injected Context parameter be removed from the
caller-facing signature?
How should defaults, keyword-only parameters, *args, **kwargs, and functools.partial() targets map onto Start fields?
What signature metadata, if any, must cross the wire for targets named by NamespacePath or string rather than supplied as local callables?
Should mismatches use local TypeError, MsgTypeError, or a dedicated
protocol error at each validation boundary?
How do we avoid redundant encode/decode work while retaining useful
sender-side failures for control messages?
Acceptance direction
Static typing preserves valid endpoint calls and rejects representative
invalid positional and keyword argument combinations.
Locally known invalid arguments fail before a Start message is sent.
Endpoint dispatch checks remote-only or dynamically resolved targets
before scheduling their RPC task.
Local and remote failure behavior is documented and covered for both
one-shot and context endpoints.
Problem
RPC endpoint argument contracts are only partially represented today.
@tractor.contextrecords the endpoint'sinspect.Signature, but adialog's
pld_specdoes not coverStartarguments and the capturedsignature is not yet used to derive a typed
Startmessage contract.Caller-facing APIs also cannot consistently preserve the endpoint's full
positional, keyword-only, defaulted, and variadic signature for static
checking.
PR #481 moved
to_actor.run()toward this model withTypeVarTupleandlocal
inspect.Signature.bind()validation. PR #484 establishedfunctools.partial()as the way to bind target keyword arguments withoutcolliding with actor-runtime options. The remaining work is to carry that
contract through the RPC protocol instead of treating it as a local
one-shot special case.
Goal
Derive an RPC endpoint's
Startparameter contract from its callablesignature and annotations, preserving that signature at the caller where
Python's typing machinery permits it.
The intended direction is:
ParamSpec,Concatenate, PEP 695 type parameters, or the nearestworkable equivalent to preserve caller-facing endpoint signatures;
Startwhen thecallable and its signature are locally available;
addressed or remote-only targets remain safe;
invalid RPC task;
Startmessage schemarather than adding a second unrelated validation model.
Design questions
ParamSpec:to_actor.run(),Portal.run(),Portal.open_context(), and/or@tractor.context?Contextparameter be removed from thecaller-facing signature?
*args,**kwargs, andfunctools.partial()targets map ontoStartfields?NamespacePathor string rather than supplied as local callables?TypeError,MsgTypeError, or a dedicatedprotocol error at each validation boundary?
sender-side failures for control messages?
Acceptance direction
invalid positional and keyword argument combinations.
Startmessage is sent.before scheduling their RPC task.
one-shot and context endpoints.
to_actor.run()andfunctools.partial()behavior from Addtractor.to_actorone-shot task API subpkg #481 andDrop
run_in_actor()+ the ria reap-cluster #484 remains supported.Related work
Context.open_stream()(probably withmsgspec.Structsubtype(s)) 😎 #365 tracks deriving typed IPC contracts from callable annotations andcontains the broader
ParamSpecresearch.tractor.to_actorone-shot task API subpkg #481 introduced linked one-shot contexts,TypeVarTuple, and localsignature binding.
run_in_actor()+ the ria reap-cluster #484 established partial-bound target keyword arguments.Existing implementation notes live around
tractor._context.context(),tractor.msg.Start, andtractor.to_actor.run().