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

Method RetryTaskRun

internal/task/manager_test.go:1458–1505  ·  view source on GitHub ↗
(
	_ context.Context,
	retry RetryRunMutation,
)

Source from the content-addressed store, hash-verified

1456}
1457
1458func (s *inMemoryManagerStore) RetryTaskRun(
1459 _ context.Context,
1460 retry RetryRunMutation,
1461) (RetryRunResult, error) {
1462 source, ok := s.runs[strings.TrimSpace(retry.SourceRunID)]
1463 if !ok {
1464 return RetryRunResult{}, ErrTaskRunNotFound
1465 }
1466 if source.Status.Normalize() != TaskRunStatusFailed {
1467 return RetryRunResult{}, ErrInvalidStatusTransition
1468 }
1469 for _, run := range s.runs {
1470 if strings.TrimSpace(run.PreviousRunID) == source.ID {
1471 return RetryRunResult{}, ErrInvalidStatusTransition
1472 }
1473 }
1474 taskRecord, ok := s.tasks[source.TaskID]
1475 if !ok {
1476 return RetryRunResult{}, ErrTaskNotFound
1477 }
1478 attempt := 1
1479 for _, run := range s.runs {
1480 if run.TaskID == source.TaskID && run.Attempt >= attempt {
1481 attempt = run.Attempt + 1
1482 }
1483 }
1484 if attempt > taskRecord.MaxAttempts {
1485 return RetryRunResult{}, ErrInvalidStatusTransition
1486 }
1487 queuedAt := retry.QueuedAt.UTC()
1488 if queuedAt.IsZero() {
1489 queuedAt = time.Now().UTC()
1490 }
1491 run := Run{
1492 ID: strings.TrimSpace(retry.NewRunID),
1493 TaskID: source.TaskID,
1494 Status: TaskRunStatusQueued,
1495 Attempt: attempt,
1496 PreviousRunID: source.ID,
1497 Origin: retry.Origin,
1498 NetworkChannel: source.NetworkChannel,
1499 CoordinationChannelID: source.CoordinationChannelID,
1500 Metadata: cloneRawJSON(retry.Metadata),
1501 QueuedAt: queuedAt,
1502 }
1503 s.runs[run.ID] = cloneTaskRun(run)
1504 return RetryRunResult{PreviousRun: cloneTaskRun(source), Run: cloneTaskRun(run)}, nil
1505}
1506
1507func (s *inMemoryManagerStore) RecoverTaskRun(
1508 _ context.Context,

Callers

nothing calls this directly

Calls 5

cloneTaskRunFunction · 0.85
cloneRawJSONFunction · 0.70
NormalizeMethod · 0.45
IsZeroMethod · 0.45
NowMethod · 0.45

Tested by

no test coverage detected