(t *testing.T)
| 4365 | } |
| 4366 | |
| 4367 | func TestManagerTaskBlockStatusDerivation(t *testing.T) { |
| 4368 | t.Parallel() |
| 4369 | |
| 4370 | t.Run("Should derive blocked when a task holds any open block", func(t *testing.T) { |
| 4371 | t.Parallel() |
| 4372 | |
| 4373 | store := newInMemoryManagerStore() |
| 4374 | manager := newTaskManagerForTest(t, store) |
| 4375 | actor := validActorContext() |
| 4376 | taskRecord, err := manager.CreateTask(context.Background(), CreateTask{ |
| 4377 | Scope: ScopeWorkspace, |
| 4378 | WorkspaceID: "ws-blocked", |
| 4379 | Title: "Blocked by runtime condition", |
| 4380 | }, actor) |
| 4381 | if err != nil { |
| 4382 | t.Fatalf("CreateTask() error = %v", err) |
| 4383 | } |
| 4384 | |
| 4385 | store.blocks[taskRecord.ID] = map[string]TaskBlock{ |
| 4386 | "block-open": { |
| 4387 | ID: "block-open", |
| 4388 | WorkspaceID: taskRecord.WorkspaceID, |
| 4389 | TaskID: taskRecord.ID, |
| 4390 | Kind: BlockKindNeedsInput, |
| 4391 | Reason: "creator input required", |
| 4392 | CreatedBy: ActorIdentity{Kind: ActorKindAgentSession, Ref: "sess-worker"}, |
| 4393 | CreatedAt: time.Date(2026, 4, 14, 14, 55, 0, 0, time.UTC), |
| 4394 | }, |
| 4395 | } |
| 4396 | |
| 4397 | reconciled, err := manager.reconcileTaskCascade(context.Background(), taskRecord.ID) |
| 4398 | if err != nil { |
| 4399 | t.Fatalf("reconcileTaskCascade() error = %v", err) |
| 4400 | } |
| 4401 | if got, want := reconciled.Status, TaskStatusBlocked; got != want { |
| 4402 | t.Fatalf("reconciled.Status = %q, want %q", got, want) |
| 4403 | } |
| 4404 | if got, want := store.tasks[taskRecord.ID].Status, TaskStatusBlocked; got != want { |
| 4405 | t.Fatalf("stored task status = %q, want %q", got, want) |
| 4406 | } |
| 4407 | }) |
| 4408 | |
| 4409 | t.Run( |
| 4410 | "Should treat a block expiring at derivation time as cleared without a sweep", |
| 4411 | func(t *testing.T) { |
| 4412 | t.Parallel() |
| 4413 | |
| 4414 | store := newInMemoryManagerStore() |
| 4415 | manager := newTaskManagerForTest(t, store) |
| 4416 | actor := validActorContext() |
| 4417 | taskRecord, err := manager.CreateTask(context.Background(), CreateTask{ |
| 4418 | Scope: ScopeWorkspace, |
| 4419 | WorkspaceID: "ws-expired", |
| 4420 | Title: "Expired transient block", |
| 4421 | }, actor) |
| 4422 | if err != nil { |
| 4423 | t.Fatalf("CreateTask() error = %v", err) |
| 4424 | } |
nothing calls this directly
no test coverage detected