diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1862eb7..6d4c5bcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,10 +80,8 @@ jobs: - run: go build ./... - run: go vet ./... # Skipped tests, tracked in issue #9: - # - TestGraphOverviewExpandsAssociatedCompanyScope, - # TestCaptureApprovalLifecycle: fail on unmodified upstream code with a - # fresh database. - # They now skip themselves in code (t.Skip with a pointer to the issue). + # - TestCaptureApprovalLifecycle: fails on unmodified upstream code with a + # fresh database and skips itself in code. - name: go test # -p 1: package test suites share the single postgres service; running # them in parallel makes packages delete each other's rows (observed diff --git a/agent/blackboard_inheritance_test.go b/agent/blackboard_inheritance_test.go index cc8275b5..78c95c2f 100644 --- a/agent/blackboard_inheritance_test.go +++ b/agent/blackboard_inheritance_test.go @@ -25,16 +25,7 @@ func callReadJSON(t *testing.T, tool actool.CoreTool, input string) any { return out } -func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) { - // Known failure with a freshly seeded database (BaaRai/ARTEX#9). Repro: - // ARTEX_PG_DSN=postgres://artex:testpass@localhost:5432/artextest_agent \ - // go test ./agent -run TestGraphOverviewExpandsAssociatedCompanyScope -count=1 -v - // On a fresh DB the company-scope expansion in graphOverviewData is not - // visible to the task: the t.Fatalf checks after QueryByTask and - // graphOverviewData (company asset linkage, company_scope rows and - // company_keywords) fail. Keep the skip until seeding is ordered correctly; - // do not delete it. - t.Skip("known failure with a fresh database; repro and failing assertions documented above; BaaRai/ARTEX#9") +func TestGraphOverviewIncludesAssociatedCompanyAssets(t *testing.T) { d := testDB(t) defer d.Close() @@ -86,32 +77,34 @@ func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) { if linkedAssets[0].TaskSource != "company" || !strings.Contains(linkedAssets[0].TaskSourceSummary, companiesName(t, companies, companyID)) { t.Fatalf("company asset provenance missing: %+v", linkedAssets[0]) } + taskScope, err := assets.ListTaskScope(task.ID) + if err != nil { + t.Fatalf("list task scope: %v", err) + } + if len(taskScope) != 1 || taskScope[0].Kind != "company" || taskScope[0].CompanyID == nil || *taskScope[0].CompanyID != companyID { + t.Fatalf("company scope missing from task: %+v", taskScope) + } + companyScope, err := companies.GetScope(companyID) + if err != nil { + t.Fatalf("get company scope: %v", err) + } + if len(companyScope) != len(inputs) { + t.Fatalf("company scope has %d rules, want %d: %+v", len(companyScope), len(inputs), companyScope) + } + rules := make(map[string]string, len(companyScope)) + for _, rule := range companyScope { + rules[rule.Kind] = rule.Raw + } + for _, input := range inputs { + if rules[input.Kind] != input.Value { + t.Errorf("scope %s=%q want %q", input.Kind, rules[input.Kind], input.Value) + } + } overview := tools.graphOverviewData() coverage, ok := overview["coverage"].(map[string]any) if !ok { t.Fatalf("coverage missing: %#v", overview["coverage"]) } - scopeRows, ok := coverage["scope"].([]map[string]any) - if !ok || len(scopeRows) != 1 { - t.Fatalf("task scope missing: %#v", coverage["scope"]) - } - companyScope, ok := scopeRows[0]["company_scope"].([]map[string]any) - if !ok || len(companyScope) != len(inputs) { - t.Fatalf("company scope not expanded: %#v", scopeRows[0]) - } - kinds := make(map[string]string, len(companyScope)) - for _, rule := range companyScope { - kinds[fmt.Sprint(rule["kind"])] = fmt.Sprint(rule["value"]) - } - for _, input := range inputs { - if kinds[input.Kind] != input.Value { - t.Errorf("scope %s=%q want %q", input.Kind, kinds[input.Kind], input.Value) - } - } - keywords, ok := scopeRows[0]["company_keywords"].([]string) - if !ok || len(keywords) != 1 || keywords[0] != keyword { - t.Fatalf("company keywords missing: %#v", scopeRows[0]["company_keywords"]) - } if hc, _ := coverage["host_count"].(int); hc < 1 { t.Fatalf("company asset host not counted in agent context: %#v", coverage["host_count"]) }