( ctx context.Context, taskRecord taskpkg.Task, )
| 263 | } |
| 264 | |
| 265 | func (r *taskRoleRuntime) workerTargetForRun( |
| 266 | ctx context.Context, |
| 267 | taskRecord taskpkg.Task, |
| 268 | ) (agentName string, provider string, model string, profile *taskpkg.ExecutionProfile, ok bool, err error) { |
| 269 | if taskRecord.Owner != nil && !taskRecord.Owner.IsZero() { |
| 270 | owner := *taskRecord.Owner |
| 271 | if owner.Kind.Normalize() != taskpkg.OwnerKindPool { |
| 272 | return "", "", "", nil, false, nil |
| 273 | } |
| 274 | return strings.TrimSpace(owner.Ref), "", "", nil, true, nil |
| 275 | } |
| 276 | |
| 277 | loaded, err := r.store.GetExecutionProfile(ctx, taskRecord.ID) |
| 278 | if err != nil { |
| 279 | if errors.Is(err, taskpkg.ErrExecutionProfileNotFound) { |
| 280 | return "", "", "", nil, false, nil |
| 281 | } |
| 282 | return "", "", "", nil, false, err |
| 283 | } |
| 284 | worker := loaded.Worker |
| 285 | if worker.Mode.Normalize() != taskpkg.WorkerModeSelect { |
| 286 | return "", "", "", nil, false, nil |
| 287 | } |
| 288 | // The exact worker name wins; selector lists only provide fallback candidates. |
| 289 | agentName = strings.TrimSpace(worker.AgentName) |
| 290 | if agentName == "" && len(worker.PreferredAgentNames) > 0 { |
| 291 | agentName = strings.TrimSpace(worker.PreferredAgentNames[0]) |
| 292 | } |
| 293 | if agentName == "" && len(worker.AllowedAgentNames) == 1 { |
| 294 | agentName = strings.TrimSpace(worker.AllowedAgentNames[0]) |
| 295 | } |
| 296 | if agentName == "" { |
| 297 | return "", "", "", nil, false, nil |
| 298 | } |
| 299 | return agentName, strings.TrimSpace(worker.Provider), strings.TrimSpace(worker.Model), &loaded, true, nil |
| 300 | } |
| 301 | |
| 302 | func (r *taskRoleRuntime) applyActivationScope(activation *taskRoleActivation, taskID string) error { |
| 303 | switch activation.Scope { |
no test coverage detected