Skip to content

v0s: skip unused findings pages across GraphQL scopes - #671

Merged
rbjornstad merged 1 commit into
mainfrom
perf/v0s-scoped-finding-pages
Dec 1, 2026
Merged

rbjornstad merged 1 commit into
mainfrom
perf/v0s-scoped-finding-pages

Conversation

@rbjornstad

Copy link
Copy Markdown
Contributor

Summary

Complete #667 without changing the GraphQL contract. One shared field-selection helper now serves Query, Team, TeamEnvironment, Application and Job vulnerabilityFindings.

  • Treat summary, vulnerabilities, affectedWorkloads and __typename as independent of the parent findings page.
  • Keep parent nodes, edges, PageInfo and facets eager. Package facets still require PackageTypeCounts from ListFindings.
  • Preserve authorization, explicit current selectors, workload/image matching, argument/cursor validation, strict/live binding and existing bidirectional pagination. Domain helpers and affectedWorkloads pagination are unchanged.
  • Put the helper alongside existing GraphQL helpers so gqlgen regeneration preserves it.

Console overview queries no longer need a redundant findings page. Global/team CVE details lose only the parent findings call: requested per-workload finding pages remain. The test with one app and one job expects exactly those two calls. CLI summaries requesting facets deliberately keep their findings calls. Parent first:1 was already optional; no CLI or Console migration is needed.

Verification

Executable GraphQL tests cover independent fields and combinations across all five scopes, mixed rows/facets without double loading, aliases, named/inline fragments, variable skip/include, nested app/job findings, invalid parent arguments/bindings, scoped inventory, obsolete images and explicit empty selections.

Passed locally:

  • go test -race ./internal/graph ./internal/v0s/... ./internal/graph/pagination
  • CGO_ENABLED=0 mise run check:staticcheck
  • CGO_ENABLED=0 go test -tags=integration_test ./... (including existing v0s integration tests)
  • Standalone pkg/apiclient tests
  • CGO_ENABLED=0 mise run build
  • Formatting and generation; post-commit generation plus git diff --exit-code is clean

Standard mise run test hits the known local macOS go-m1cpu CGO initializer crash; the complete suite passes with CGO disabled.

Related feedback already resolved / remaining

  • v0s: accept workload overviews without total_count #670 already accepts workload overviews without total_count.
  • database: optimize vulnerability queries and remove workload totals v0s#26 already optimizes INCLUDE totals/probes and removes the workload-total/deprecated WorkloadOrderBy proto remnants.
  • Current schema already documents UNKNOWN first in ASC and last in DESC.
  • Current nais/cli consumes v0s findings, summary and workload overviews. No contract break is introduced here.
  • Tenant deployment status, coordinated Console/API assessment flags, rollback limitations and decisions/communication on legacy Prometheus vulnerability metrics remain cutover responsibilities. Merged source does not prove rollout. Existing migration documentation records these distinctions.

Rollout and measurement

API-only change, no new flag, client/server upgrade or cursor restart. Compare identical global/team overview and CVE detail queries before/after rollout using existing GraphQL timing and ListFindings/ListVulnerabilities counts and cumulative duration. Independent parent selections should contribute zero finding calls; detail queries retain their requested workload pages and facets remain page-dependent. Account for background traffic: aggregate deltas are not traces, and fewer RPCs alone do not prove lower latency.

No new tracing/metrics, SQL changes, larger workload batches, cursor infrastructure, merge or deployment.

Share the field-selection decision across Query, Team, TeamEnvironment, Application and Job, including affectedWorkloads. Preserve required row and facet fetches, current selection and cursor validation without changing the GraphQL contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rbjornstad
rbjornstad requested a review from a team as a code owner December 1, 2026 09:44
@rbjornstad
rbjornstad requested a balanced review from Copilot December 1, 2026 09:45

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 block the extension of selection-based findings-page loading across all five GraphQL scopes.

No open issues 🎉

What changed in this PR

Extends #667’s findings-page optimization across all five GraphQL scopes—Query, Team, TeamEnvironment, Application and Job—without changing the GraphQL contract.

Changes:

  • Uses one shared selection helper to skip parent findings pages when only independent fields are requested.
  • Adds executable GraphQL tests for scoped selections, aliases, directives, nested findings, validation and inventory filtering.
  • Updates documentation with loading rules, rollout measurements and remaining cutover coordination.
File Description
internal/​graph/​v0s.resolvers.go Applies selection-based page loading across all five scopes.
internal/​graph/​v0s.resolvers_test.go Expands regression coverage for skipped and required findings pages.
internal/​graph/​helpers.go Centralizes the findings-page dependency check outside generated resolvers.
docs/​v0s_console_migration.md Documents page dependencies, measurement guidance and cutover responsibilities.

Review effort: Balanced

@rbjornstad
rbjornstad merged commit ca22022 into main Dec 1, 2026
11 checks passed
@rbjornstad
rbjornstad deleted the perf/v0s-scoped-finding-pages branch December 1, 2026 09:54
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.

2 participants