Skip to content

feat(vulnerabilities): filter and sort team v0s workload overviews - #652

Merged
rbjornstad merged 2 commits into
mainfrom
feat/v0s-team-workload-overview
Nov 25, 2026
Merged

rbjornstad merged 2 commits into
mainfrom
feat/v0s-team-workload-overview

Conversation

@rbjornstad

Copy link
Copy Markdown
Contributor

Summary

  • Share environment and existing AND-label selection between team finding summaries and workload lists. Counts cover the complete filtered selection; coverage includes missing/incomplete scans and is independent of finding predicates.
  • Extend TeamWorkloadsFilter.vulnerabilityFilter and add five VULNERABILITY_UNIQUE_* order fields. Sort on the same filtered unique-severity aggregates returned per workload, before pagination.
  • Keep incomplete scans first in both directions, with ascending name/environment/type ties. Bind versioned live-offset cursors to normalized selection and ordering; preserve existing workload pagination.
  • Batch-load selected team aggregates and reuse the row cache: O(selected workload count), without enumerating findings. No nais/v0s change or client upgrade is required.
  • Preserve existing v13s semantics. CVE pages, suppressions, assessment writes and rollout changes remain out of scope.

The migration contract and shared-filter query example describe counting, filtering, coverage and cursor semantics.

Validation

  • Focused unit tests and GraphQL integration tests cover combined environment/label selection, incomplete coverage, unique-versus-finding counts, tied workloads across page boundaries, cache reuse and changed cursor filters.
  • Full Go/integration/race suite and the separate apiclient module tests passed with CGO_ENABLED=0; focused tests were rerun after final generation.
  • Build, standalone full generation, Go/Lua formatting and direct Prettier checks passed. Post-commit regeneration leaves the worktree clean.
  • Local task-wrapper limitations: mise run fmt ::: generate fails on the existing pnpm SQLite-store error; mise run test is blocked by the yq installation certificate error before alert tests. Equivalent Go checks and standalone generation were run; alert tests were not verified locally.
  • No new live-v0s backend conformance test was performed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Same-name applications and jobs can collide in overview caching and workload counting, causing incorrect scan status, image-based ordering, and pending coverage totals.

2 open issues
6 files not reviewed
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
  • internal/graph/gengql/teams.generated.go: Generated file
  • internal/graph/gengql/v0s.generated.go: Generated file
  • internal/graph/gengql/workloads.generated.go: Generated file
What changed in this PR

Adds v0s-based filtering and severity ordering to team workload views in Nais API, sharing workload selection with vulnerability summaries while retaining legacy v13s behavior.

Changes:

  • Shares environment and label selection across team findings, summaries, and workload lists.
  • Adds five unique-severity sort fields, batch-loaded counts, and selection-bound pagination cursors.
  • Adds tests, fixtures, generated GraphQL bindings, and migration guidance.
File Description
README.md Documents selection and sorting behavior.
internal/​workload/​models.go Adds finding filters and unique-severity order fields.
internal/​v0s/​workload_order.go Implements sorting and selection-bound cursors.
internal/​v0s/​workload_order_test.go Tests ordering, cache reuse, and pagination.
internal/​v0s/​summary.go Accepts explicit selection totals for coverage.
internal/​v0s/​summary_test.go Tests missing-image and empty selections.
internal/​v0s/​queries.go Adds explicit workload selection for findings.
internal/​v0s/​overview.go Adds batch overview loading.
internal/​v0s/​models.go Aliases shared filter types.
internal/​v0s/​filter/​models.go Extracts reusable filters and enums.
internal/​integration/​v0s.go Adds overview backend fixtures.
internal/​graph/​workloads.resolvers.go Integrates unique-severity sorting and pagination.
internal/​graph/​workloads.go Extracts shared team workload selection.
internal/​graph/​v0s.resolvers.go Applies workload selection to team findings.
internal/​graph/​schema/​workloads.graphqls Exposes finding filters and sort fields.
internal/​graph/​schema/​v0s.graphqls Adds team finding workload selection.
internal/​graph/​gengql/​workloads.generated.go Regenerates workload filter parsing.
internal/​graph/​gengql/​v0s.generated.go Regenerates shared filter bindings.
internal/​graph/​gengql/​teams.generated.go Regenerates team resolver bindings.
internal/​graph/​gengql/​schema.generated.go Updates root query filter bindings.
internal/​graph/​gengql/​root_.generated.go Updates embedded schema and complexity bindings.
internal/​graph/​gengql/​jobs.generated.go Updates job filter bindings.
internal/​graph/​gengql/​applications.generated.go Updates application filter bindings.
integration_tests/​v0s_workload_overview.lua Tests shared selection, coverage, sorting, and cursors.
integration_tests/​k8s_resources/​v0s_overview/​staging/​v0s-overview/​resources.yaml Adds cross-environment selection fixture.
integration_tests/​k8s_resources/​v0s_overview/​dev/​v0s-overview/​resources.yaml Adds label and scan-state fixtures.
docs/​v0s_console_migration.md Updates migration semantics and query examples.

Review effort: Balanced

Comment thread internal/v0s/overview.go Resolved
Comment thread internal/v0s/queries.go Resolved
rbjornstad and others added 2 commits November 25, 2026 13:11
Share environment and label selection across team findings, summaries and workload lists. Sort workloads by filtered unique-severity aggregates before pagination, keeping incomplete scans first and binding cursors to the selection and ordering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep application and job overview cache entries separate and reconcile each selected workload against its own image. Deduplicate backend selectors independently while counting coverage for every selected API workload identity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rbjornstad
rbjornstad force-pushed the feat/v0s-team-workload-overview branch from bcedde2 to 004caec Compare November 25, 2026 12:11
@rbjornstad
rbjornstad requested a balanced review from Copilot November 25, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the shared workload selection and unique-severity sorting changes.

No open issues 🎉

2 resolved since last review
6 files not reviewed
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
  • internal/graph/gengql/teams.generated.go: Generated file
  • internal/graph/gengql/v0s.generated.go: Generated file
  • internal/graph/gengql/workloads.generated.go: Generated file

Review effort: Balanced

@rbjornstad
rbjornstad requested a balanced review from Copilot November 25, 2026 12:20
@rbjornstad
rbjornstad enabled auto-merge (squash) November 25, 2026 12:22
@rbjornstad
rbjornstad merged commit 819da9c into main Nov 25, 2026
16 checks passed
@rbjornstad
rbjornstad deleted the feat/v0s-team-workload-overview branch November 25, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Same-name applications and jobs are conflated, producing incorrect per-workload summary counts and resolving findings to workloads outside the requested filter.

2 open issues
6 files not reviewed
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
  • internal/graph/gengql/teams.generated.go: Generated file
  • internal/graph/gengql/v0s.generated.go: Generated file
  • internal/graph/gengql/workloads.generated.go: Generated file

Review effort: Balanced

if err := v0s.ValidateWorkloadFilter(workloadFilter); err != nil {
return nil, err
}
return v0s.FindingsForWorkloads(ctx, scope, selectTeamWorkloads(ctx, obj.Slug, workloadFilter), filter, first, after, orderBy)
Comment thread internal/v0s/summary.go
Comment on lines +50 to +51
if selected != nil {
coverageCounts, err = selectedWorkloadCoverage(selected, current)
rbjornstad added a commit to nais/console-frontend that referenced this pull request Nov 25, 2026
* vulnerabilities: migrate overviews and workload health to v0s

Use v0s for tenant and team summaries and app/job vulnerability health when enabled. Keep team filters consistent across counts and rows, and distinguish incomplete scans from scanned workloads with zero findings.

Uses the GraphQL contract from nais/api#652. Keep legacy views as the default until rollout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* vulnerabilities: address v0s overview review feedback

Distinguish empty pages from empty selections, describe the CISA-only v0s counts accurately, and use type-specific health queries for apps and jobs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* vulnerabilities: fix v0s workload health loading state

Derive readiness from the active vulnerability source. With v0s enabled, unfetched legacy stores must not keep app and job health cards loading.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants