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}, Cases: []capability.TaskEvaluationCase{{CaseID: "case-a", Prompt: "one", EvidenceArtifactRef: "artifact-a"}, {CaseID: "case-b", Prompt: "two", EvidenceArtifactRef: "artifact-b"}}, 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) } }