diff --git a/modules/work/application/graph_runtime.go b/modules/work/application/graph_runtime.go index bf617b9..0ef6598 100644 --- a/modules/work/application/graph_runtime.go +++ b/modules/work/application/graph_runtime.go @@ -218,7 +218,11 @@ func AdmitAndScheduleTaskEvaluation(ctx context.Context, store ports.GraphStore, intents[i].TaskEvaluationProfile = &profile } intents[i].TaskEvaluationCases = append([]capability.TaskEvaluationCase(nil), node.TaskCases...) - intents[i].TaskEvaluationExecution = &work.TaskEvaluationDispatchContext{GraphID: graph.ID, GraphRevision: graph.Revision, NodeID: node.ID, BindingRevision: request.Plan.BindingRevision, ActorID: identity.ActorID(request.Plan.ActorID), PrincipalID: identity.PrincipalID(request.Plan.PrincipalID), ScopeID: authority.ScopeID(request.Plan.ScopeID)} + // AdmitAndSchedule increments the draft revision before persisting + // the leased node. The callback must target that scheduled revision; + // using the draft revision would save a completed copy that loses to + // the already-persisted immutable scheduled revision. + intents[i].TaskEvaluationExecution = &work.TaskEvaluationDispatchContext{GraphID: graph.ID, GraphRevision: graph.Revision + 1, NodeID: node.ID, BindingRevision: request.Plan.BindingRevision, ActorID: identity.ActorID(request.Plan.ActorID), PrincipalID: identity.PrincipalID(request.Plan.PrincipalID), ScopeID: authority.ScopeID(request.Plan.ScopeID)} break } } diff --git a/modules/work/application/task_evaluation_dispatch_test.go b/modules/work/application/task_evaluation_dispatch_test.go index 1d51727..ab6d4b8 100644 --- a/modules/work/application/task_evaluation_dispatch_test.go +++ b/modules/work/application/task_evaluation_dispatch_test.go @@ -41,7 +41,7 @@ func TestAdmitAndScheduleTaskEvaluationCarriesSpecialistContext(t *testing.T) { if _, _, err := AdmitAndScheduleTaskEvaluation(context.Background(), store, request); err != nil { t.Fatal(err) } - if len(store.intents) != 1 || store.intents[0].TaskEvaluationProfileID != "profile-general" || store.intents[0].TaskEvaluationBindingID != "binding-a" || len(store.intents[0].TaskEvaluationCaseIDs) != 2 || store.intents[0].SpecialistPurpose != string(work.GraphNodePurposeTaskEvaluation) { + if len(store.intents) != 1 || store.intents[0].TaskEvaluationProfileID != "profile-general" || store.intents[0].TaskEvaluationBindingID != "binding-a" || len(store.intents[0].TaskEvaluationCaseIDs) != 2 || store.intents[0].SpecialistPurpose != string(work.GraphNodePurposeTaskEvaluation) || store.intents[0].TaskEvaluationExecution == nil || store.intents[0].TaskEvaluationExecution.GraphRevision != 2 { t.Fatalf("specialist context was not carried into dispatch: %+v", store.intents) } }