fix: enqueue graph join after fan-in #117
@@ -106,6 +106,12 @@ func CompleteGraphNode(ctx context.Context, store ports.GraphStore, graphID stri
|
||||
for _, candidate := range ready {
|
||||
if graph.Nodes[i].ID == candidate && graph.Nodes[i].State == work.GraphNodeBlocked {
|
||||
graph.Nodes[i].State = work.GraphNodeReady
|
||||
if graph.Nodes[i].DispatchID == "" {
|
||||
return work.WorkGraph{}, ErrGraphDispatchBinding
|
||||
}
|
||||
if err := store.EnqueueDispatch(ctx, work.AgentDispatchQueueItem{DispatchID: graph.Nodes[i].DispatchID, State: work.AgentDispatchQueued, AvailableAtUnixMillis: time.Now().UnixMilli(), UpdatedAtUnixMillis: time.Now().UnixMilli()}); err != nil {
|
||||
return work.WorkGraph{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ func TestGraphRuntimeSchedulesFanOutAndCompletesFanIn(t *testing.T) {
|
||||
if _, err := application.CompleteGraphNode(context.Background(), store, "g", 3, "b", true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(store.queued) != 3 || store.queued[2] != "d-join" {
|
||||
t.Fatalf("fan-in dispatch was not enqueued: %v", store.queued)
|
||||
}
|
||||
completed, err := application.CompleteGraphNode(context.Background(), store, "g", 4, "join", true)
|
||||
if err != nil || completed.State != work.GraphCompleted {
|
||||
t.Fatalf("completed=%+v err=%v", completed, err)
|
||||
|
||||
Reference in New Issue
Block a user