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

Method requireForceRunRate

internal/task/force_ops.go:432–459  ·  view source on GitHub ↗
(actor ActorContext, taskID string)

Source from the content-addressed store, hash-verified

430}
431
432func (m *Service) requireForceRunRate(actor ActorContext, taskID string) error {
433 if actor.Actor.Kind.Normalize() != ActorKindAgentSession {
434 return nil
435 }
436 now := m.now().UTC()
437 if m.forceRateLimiter.allow(actor.Actor, taskID, now, m.forceRecovery.RateLimitPerMinute) {
438 return nil
439 }
440 return forceRunDiagnosticError(
441 diagnosticcontract.CodeForceOpRateLimited,
442 "Force operation rate limit exceeded",
443 fmt.Sprintf(
444 "Actor %s exceeded %d force operations per minute for task %s.",
445 actor.Actor.Ref,
446 m.forceRecovery.RateLimitPerMinute,
447 taskID,
448 ),
449 diagnosticcontract.SeverityWarn,
450 "agh task inspect "+taskID,
451 map[string]any{
452 "actor_kind": string(actor.Actor.Kind.Normalize()),
453 "actor_id": actor.Actor.Ref,
454 taskEvidenceIDKey: taskID,
455 "limit": m.forceRecovery.RateLimitPerMinute,
456 },
457 ErrForceOpRateLimited,
458 )
459}
460
461func (m *Service) invalidateForceRunInputs(ctx context.Context, previous Run) (int64, int, error) {
462 sessionID := strings.TrimSpace(previous.SessionID)

Callers 6

ForceReleaseRunMethod · 0.95
ForceFailRunMethod · 0.95
RetryRunMethod · 0.95
RecoverRunMethod · 0.95
PauseTaskMethod · 0.95
ResumeTaskMethod · 0.95

Calls 4

forceRunDiagnosticErrorFunction · 0.85
allowMethod · 0.80
NormalizeMethod · 0.45
nowMethod · 0.45

Tested by

no test coverage detected