Backport of 'Read top-level dependency ancestors from direct graph edges' into 19.5

What does this MR do and why?

This MR backports !257548 (merged) to 19.5. It is a clean cherry-pick of the default branch commit ab166982, and the diff is identical.

Sbom::PathFinder now reads top-level ancestors from the direct graph edges instead of the transitive rows. The change is behind the dependency_paths_top_level_ancestors_from_direct_edges flag, which is off by default, so this backport changes no behavior on its own. It is the prerequisite for the !257733 (merged) backport, which removes the flag and stops the graph build from writing transitive rows.

This is part of the fix for #593156 (closed) (severity1). On large dependency graphs, Sbom::BuildDependencyGraphWorker jobs run for hours and block other Sidekiq jobs. This affects GitLab Dedicated and self-managed instances. The flag was enabled on GitLab.com for gitlab-org/gitlab on 2026-10-15 and for all projects on 2026-10-20 (#630719).

This is the second of three backports for #593156 (closed). The first is !262206 (merged), which is merged.

Testing

On a GDK sandbox at this branch's head, with RAILS_ENV=test:

Spec Result
path_finder_spec, build_dependency_graph_spec, build_dependency_graph_worker_spec, dependency_paths_resolver_spec, project_security_settings_spec (request), project_security_setting_spec (model) 177 examples, 0 failures, 6 pending

The 6 pending examples are the shared granular token permission examples, which skip themselves.

rubocop on the changed files reports one offense, Lint/RedundantCopDisableDirective on the pluck line in path_finder.rb. The same offense exists on 19-5-stable-ee before this change, and !257733 (merged) removes the line.

Pushed with pre-push hooks skipped (LEFTHOOK=0). The hooks in lefthook.yml compute their file list from git merge-base origin/master HEAD, so on a stable branch they lint every file where 19.5 differs from master. The checks that apply to this change ran on a GDK sandbox instead (see Testing).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required).
  • Ensure the E2E Omnibus GitLab EE pipeline (triggered by thee2e:test-on-omnibus-ee job) has succeeded. If it has failed (or shows warnings), investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Merge request reports

Loading
Loading