feat(work): accept task evaluation evidence callbacks
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var ErrGraphDispatchBinding = errors.New("graph node dispatch binding is missing")
|
||||
var ErrTaskEvaluationCallbackMismatch = errors.New("task evaluation callback does not match graph node")
|
||||
|
||||
type GraphScheduleRequest struct {
|
||||
Graph work.WorkGraph `json:"graph"`
|
||||
@@ -42,6 +43,31 @@ type GraphSynthesisRequest struct {
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
func CompleteTaskEvaluationNode(ctx context.Context, graphStore ports.GraphStore, evidenceSink ports.TaskEvaluationSink, request work.TaskEvaluationEvidenceCallback) (work.WorkGraph, error) {
|
||||
if evidenceSink == nil || request.GraphID == "" || request.Revision < 1 || request.NodeID == "" || !request.Succeeded {
|
||||
return work.WorkGraph{}, ErrTaskEvaluationCallbackMismatch
|
||||
}
|
||||
graph, err := graphStore.LoadWorkGraph(ctx, request.GraphID, request.Revision)
|
||||
if err != nil {
|
||||
return work.WorkGraph{}, err
|
||||
}
|
||||
matched := false
|
||||
for _, node := range graph.Nodes {
|
||||
if node.ID != request.NodeID {
|
||||
continue
|
||||
}
|
||||
matched = node.Purpose == work.GraphNodePurposeTaskEvaluation && node.TaskProfileID == request.Evaluation.ProfileID && node.BindingID == request.Evaluation.BindingID
|
||||
break
|
||||
}
|
||||
if !matched || request.Evaluation.BindingRevision < 1 || request.Evaluation.CapabilityID == "" {
|
||||
return work.WorkGraph{}, ErrTaskEvaluationCallbackMismatch
|
||||
}
|
||||
if err := evidenceSink.SaveTaskEvaluation(ctx, request.Evaluation); err != nil {
|
||||
return work.WorkGraph{}, err
|
||||
}
|
||||
return CompleteGraphNode(ctx, graphStore, request.GraphID, request.Revision, request.NodeID, true)
|
||||
}
|
||||
|
||||
func SynthesizeGraph(ctx context.Context, store ports.GraphResultStore, request GraphSynthesisRequest) (work.ConflictSet, work.GraphSynthesisCandidate, error) {
|
||||
conflict, synthesis, err := domain.BuildVerifiedGraphSynthesis(request.Conflict, request.Candidates, request.SelectedCandidate, request.VerifierRunID, request.VerifierIdentity, request.EvidenceRefs, request.Summary, request.Verified)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user