feat(work): schedule bounded additional evaluations

This commit is contained in:
m
2026-08-23 23:37:56 +03:00
parent fb6b5e9677
commit 1b4284592b
4 changed files with 90 additions and 2 deletions
+33
View File
@@ -29,6 +29,19 @@ type TaskEvaluationScheduleRequest struct {
Now int64 `json:"now_unix_millis"`
}
// TaskEvaluationExpansionScheduleRequest carries a typed expansion decision
// from Capability to Work. Capability owns the decision and test-case
// construction; Work owns durable graph lineage, persistence and dispatch.
type TaskEvaluationExpansionScheduleRequest struct {
Profile capability.TaskEvaluationProfile
Cases []capability.TaskEvaluationCase
ParentGraphState work.GraphState
TriggerEvidenceRef string
Plan work.TaskEvaluationGraphRequest
Intents []work.AgentDispatchIntent
Now int64
}
type GraphCompleteRequest struct {
GraphID string `json:"graph_id"`
Revision int64 `json:"revision"`
@@ -229,6 +242,26 @@ func AdmitAndScheduleTaskEvaluation(ctx context.Context, store ports.GraphStore,
return AdmitAndSchedule(ctx, store, GraphScheduleRequest{Graph: graph, Intents: intents, Now: request.Now})
}
// ScheduleAdditionalTaskEvaluation is the runtime hand-off for the
// "general-first, additional-when-unresolved" policy. Capability decides
// whether to expand and supplies the bounded cases; this function never
// invents cases or chooses a model, and only persists/enqueues the new graph.
func ScheduleAdditionalTaskEvaluation(ctx context.Context, store ports.GraphStore, request TaskEvaluationExpansionScheduleRequest) (work.WorkGraph, []work.GraphNodeID, error) {
if request.Profile.Stage != capability.TaskEvaluationAdditional || request.Profile.ParentProfileID == "" || request.TriggerEvidenceRef == "" || len(request.Cases) == 0 {
return work.WorkGraph{}, nil, errors.New("additional task evaluation lineage is incomplete")
}
plan := request.Plan
plan.Profile = request.Profile
plan.Cases = append([]capability.TaskEvaluationCase(nil), request.Cases...)
plan.ParentGraphState = request.ParentGraphState
plan.TriggerEvidenceRef = request.TriggerEvidenceRef
graph, ready, err := AdmitAndScheduleTaskEvaluation(ctx, store, TaskEvaluationScheduleRequest{Plan: plan, Intents: request.Intents, Now: request.Now})
if err != nil {
return work.WorkGraph{}, nil, err
}
return graph, ready, nil
}
func CompleteGraphNode(ctx context.Context, store ports.GraphStore, graphID string, revision int64, nodeID work.GraphNodeID, success bool) (work.WorkGraph, error) {
graph, err := store.LoadWorkGraph(ctx, graphID, revision)
if err != nil {