@@ -24,27 +24,27 @@ type Engine interface {
2424 context.Context ,
2525 ComponentRef ,
2626 func (MutableContext ) (RootComponent , error ),
27- func (MutableContext , Component ) error ,
27+ func (MutableContext , Component , * Registry ) error ,
2828 ... TransitionOption ,
2929 ) (EngineUpdateWithStartExecutionResult , error )
3030
3131 UpdateComponent (
3232 context.Context ,
3333 ComponentRef ,
34- func (MutableContext , Component ) error ,
34+ func (MutableContext , Component , * Registry ) error ,
3535 ... TransitionOption ,
3636 ) ([]byte , error )
3737 ReadComponent (
3838 context.Context ,
3939 ComponentRef ,
40- func (Context , Component ) error ,
40+ func (Context , Component , * Registry ) error ,
4141 ... TransitionOption ,
4242 ) error
4343
4444 PollComponent (
4545 context.Context ,
4646 ComponentRef ,
47- func (Context , Component ) (bool , error ),
47+ func (Context , Component , * Registry ) (bool , error ),
4848 ... TransitionOption ,
4949 ) ([]byte , error )
5050
@@ -65,6 +65,25 @@ type DeleteExecutionRequest struct {
6565 TerminateComponentRequest
6666}
6767
68+ // ConsistencyLevel controls how strictly a [ComponentRef] is validated
69+ // against the current execution state. Ordered from strongest to loosest.
70+ type ConsistencyLevel int
71+
72+ const (
73+ // ConsistencyLevelExecution is the default. Validates [ComponentRef.executionLastUpdateVT].
74+ ConsistencyLevelExecution ConsistencyLevel = iota
75+ // ConsistencyLevelComponent validates only [ComponentRef.componentInitialVT].
76+ // Use when the token may have been generated before a failover changed the
77+ // execution-level VT, but the component itself is still valid on the current branch.
78+ ConsistencyLevelComponent
79+ // ConsistencyLevelBusinessID skips all [VersionedTransition] checks and matches
80+ // by [ComponentRef.componentPath] only. Falls back to the latest open run if the
81+ // referenced [ComponentRef.RunID] points to a closed execution.
82+ // Use when the original run may have been reset: the operation should target the
83+ // same component in the new run, matched by path and deduplicated by request ID.
84+ ConsistencyLevelBusinessID
85+ )
86+
6887type BusinessIDReusePolicy int
6988
7089const (
@@ -82,10 +101,11 @@ const (
82101)
83102
84103type TransitionOptions struct {
85- ReusePolicy BusinessIDReusePolicy
86- ConflictPolicy BusinessIDConflictPolicy
87- RequestID string
88- Speculative bool
104+ ReusePolicy BusinessIDReusePolicy
105+ ConflictPolicy BusinessIDConflictPolicy
106+ RequestID string
107+ Speculative bool
108+ ConsistencyLevel ConsistencyLevel
89109}
90110
91111type TransitionOption func (* TransitionOptions )
@@ -172,6 +192,16 @@ func WithRequestID(
172192 }
173193}
174194
195+ // WithConsistencyLevel sets the consistency level used when resolving a component reference.
196+ // See [ConsistencyLevel] for details on each level.
197+ func WithConsistencyLevel (
198+ level ConsistencyLevel ,
199+ ) TransitionOption {
200+ return func (opts * TransitionOptions ) {
201+ opts .ConsistencyLevel = level
202+ }
203+ }
204+
175205// Not needed for V1
176206// func WithEagerLoading(
177207// paths []ComponentPath,
@@ -255,7 +285,7 @@ func UpdateWithStartExecution[C RootComponent, I any, O any](
255285 c , err = startFn (mutableContext , input )
256286 return c , err
257287 },
258- func (mutableContext MutableContext , c Component ) (retErr error ) {
288+ func (mutableContext MutableContext , c Component , _ * Registry ) (retErr error ) {
259289 defer log .CapturePanic (mutableContext .Logger (), & retErr )
260290
261291 var err error
@@ -306,7 +336,7 @@ func UpdateComponent[C any, R []byte | ComponentRef, I any, O any](
306336 newSerializedRef , err := engineFromContext (ctx ).UpdateComponent (
307337 ctx ,
308338 ref ,
309- func (mutableContext MutableContext , c Component ) (retErr error ) {
339+ func (mutableContext MutableContext , c Component , _ * Registry ) (retErr error ) {
310340 defer log .CapturePanic (mutableContext .Logger (), & retErr )
311341
312342 var err error
@@ -345,7 +375,7 @@ func ReadComponent[C any, R []byte | ComponentRef, I any, O any](
345375 err = engineFromContext (ctx ).ReadComponent (
346376 ctx ,
347377 ref ,
348- func (chasmContext Context , c Component ) (retErr error ) {
378+ func (chasmContext Context , c Component , _ * Registry ) (retErr error ) {
349379 defer log .CapturePanic (chasmContext .Logger (), & retErr )
350380
351381 var err error
@@ -386,7 +416,7 @@ func PollComponent[C any, R []byte | ComponentRef, I any, O any](
386416 newSerializedRef , err := engineFromContext (ctx ).PollComponent (
387417 ctx ,
388418 ref ,
389- func (chasmContext Context , c Component ) (_ bool , retErr error ) {
419+ func (chasmContext Context , c Component , _ * Registry ) (_ bool , retErr error ) {
390420 defer log .CapturePanic (chasmContext .Logger (), & retErr )
391421
392422 out , satisfied , err := monotonicPredicate (
0 commit comments