package projectinstance_test import ( "context" "testing" "chat-agent-system/internal/projectinstance" ) func TestActiveWorkflowScope_NoLiveInstanceReturnsEmpty(t *testing.T) { store := projectinstance.NewMemoryStore() if err := projectinstance.SeedProjectMeta(store, 99, projectinstance.LifecyclePlanning, "", 1, 0); err != nil { t.Fatalf("seed: %v", err) } svc := projectinstance.NewService(store, projectinstance.TestResolver(), nil, nil) key, tasks, err := svc.ActiveWorkflowScope(context.Background(), 99) if err != nil { t.Fatalf("scope: %v", err) } if key != "" || tasks != nil { t.Fatalf("unactivated project must return empty scope, got key=%q tasks=%v", key, tasks) } } func TestTaskKeyInScope_EmptyAllowsAll(t *testing.T) { if !projectinstance.TaskKeyInScope(nil, "anything") { t.Fatal("nil scope must allow") } if !projectinstance.TaskKeyInScope(map[string]bool{}, "anything") { t.Fatal("empty scope must allow") } } func TestTaskKeyInScope_CanonicalAlias(t *testing.T) { scope := map[string]bool{"bd_research": true, "research": true} if !projectinstance.TaskKeyInScope(scope, "research") { t.Fatal("legacy alias research should be in scope") } if !projectinstance.TaskKeyInScope(scope, "bd_research") { t.Fatal("canonical bd_research should be in scope") } if projectinstance.TaskKeyInScope(scope, "rd_proposal") { t.Fatal("rd_proposal must be out of scope") } }