feat(work): persist task evaluation worker context
This commit is contained in:
@@ -120,7 +120,21 @@ func AdmitAndScheduleTaskEvaluation(ctx context.Context, store ports.GraphStore,
|
||||
if err != nil {
|
||||
return work.WorkGraph{}, nil, err
|
||||
}
|
||||
return AdmitAndSchedule(ctx, store, GraphScheduleRequest{Graph: graph, Intents: request.Intents, Now: request.Now})
|
||||
intents := make([]work.AgentDispatchIntent, len(request.Intents))
|
||||
copy(intents, request.Intents)
|
||||
for i := range intents {
|
||||
for _, node := range graph.Nodes {
|
||||
if node.DispatchID != intents[i].DispatchID {
|
||||
continue
|
||||
}
|
||||
intents[i].SpecialistPurpose = string(node.Purpose)
|
||||
intents[i].TaskEvaluationProfileID = node.TaskProfileID
|
||||
intents[i].TaskEvaluationBindingID = node.BindingID
|
||||
intents[i].TaskEvaluationCaseIDs = append([]string(nil), node.CaseIDs...)
|
||||
break
|
||||
}
|
||||
}
|
||||
return AdmitAndSchedule(ctx, store, GraphScheduleRequest{Graph: graph, Intents: intents, Now: request.Now})
|
||||
}
|
||||
|
||||
func CompleteGraphNode(ctx context.Context, store ports.GraphStore, graphID string, revision int64, nodeID work.GraphNodeID, success bool) (work.WorkGraph, error) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"git.cin.su/m/Assistant/contracts/capability"
|
||||
"git.cin.su/m/Assistant/contracts/work"
|
||||
)
|
||||
|
||||
type taskGraphStore struct {
|
||||
graph work.WorkGraph
|
||||
intents []work.AgentDispatchIntent
|
||||
}
|
||||
|
||||
func (s *taskGraphStore) SaveWorkGraph(_ context.Context, graph work.WorkGraph) error {
|
||||
s.graph = graph
|
||||
return nil
|
||||
}
|
||||
func (s *taskGraphStore) LoadWorkGraph(context.Context, string, int64) (work.WorkGraph, error) {
|
||||
return s.graph, nil
|
||||
}
|
||||
func (s *taskGraphStore) SaveDispatchIntent(_ context.Context, intent work.AgentDispatchIntent) error {
|
||||
s.intents = append(s.intents, intent)
|
||||
return nil
|
||||
}
|
||||
func (s *taskGraphStore) EnqueueDispatch(context.Context, work.AgentDispatchQueueItem) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestAdmitAndScheduleTaskEvaluationCarriesSpecialistContext(t *testing.T) {
|
||||
store := &taskGraphStore{}
|
||||
request := TaskEvaluationScheduleRequest{
|
||||
Plan: work.TaskEvaluationGraphRequest{
|
||||
GraphID: "graph-task", Profile: capability.TaskEvaluationProfile{ID: "profile-general", Revision: 1, CapabilityID: "capability-chat", Stage: capability.TaskEvaluationGeneral, BenchmarkVersion: "general-v1", RequiredCaseIDs: []string{"case-a", "case-b"}, QualityWeightMillis: 600, ReliabilityWeightMillis: 300, LatencyWeightMillis: 100},
|
||||
BindingIDs: []capability.CapabilityBindingID{"binding-a"}, DispatchIDs: []string{"dispatch-a"}, IdempotencyPrefix: "eval", Budget: work.GraphBudget{MaxParallel: 1, MaxAttempts: 2},
|
||||
},
|
||||
Intents: []work.AgentDispatchIntent{{DispatchID: "dispatch-a", IdempotencyKey: "idem-a", DelegationID: "delegation-a", RunID: "run-a", ImplementationID: "impl", ImplementationRevision: 1, SourceRevision: "source", WorktreeID: "tree", VerificationPlanRef: "verify", CreatedAtUnixMillis: 1}},
|
||||
}
|
||||
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) {
|
||||
t.Fatalf("specialist context was not carried into dispatch: %+v", store.intents)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user