MCPcopy Create free account
hub / github.com/compozy/agh / CancelTask

Method CancelTask

internal/task/manager.go:522–556  ·  view source on GitHub ↗

CancelTask propagates manager-owned cancellation through the target task, affected runs, and all non-terminal descendants.

(ctx context.Context, id string, req CancelTask, actor ActorContext)

Source from the content-addressed store, hash-verified

520// CancelTask propagates manager-owned cancellation through the target task,
521// affected runs, and all non-terminal descendants.
522func (m *Service) CancelTask(ctx context.Context, id string, req CancelTask, actor ActorContext) (*Task, error) {
523 if err := requireWriteAuthority(actor); err != nil {
524 return nil, err
525 }
526
527 trimmedID := strings.TrimSpace(id)
528 if trimmedID == "" {
529 return nil, fmt.Errorf("%w: task id is required", ErrValidation)
530 }
531 normalizedReq, err := normalizeCancelTask(req)
532 if err != nil {
533 return nil, err
534 }
535
536 tree, root, err := m.loadCancellationTree(ctx, trimmedID)
537 if err != nil {
538 return nil, err
539 }
540 if err := m.ensureTaskCancelable(ctx, root); err != nil {
541 return nil, err
542 }
543
544 cancelledRoot := root
545 for idx, record := range tree {
546 record, err = m.cancelTaskTreeRecord(ctx, trimmedID, idx, record, normalizedReq, actor)
547 if err != nil {
548 return nil, err
549 }
550 if record.ID == trimmedID {
551 cancelledRoot = record
552 }
553 }
554
555 return &cancelledRoot, nil
556}
557
558func applyTaskPatch(current Task, patch Patch) (Task, []string) {
559 updated := current

Callers

nothing calls this directly

Calls 5

loadCancellationTreeMethod · 0.95
ensureTaskCancelableMethod · 0.95
cancelTaskTreeRecordMethod · 0.95
requireWriteAuthorityFunction · 0.85
normalizeCancelTaskFunction · 0.85

Tested by

no test coverage detected