feat: add rank packages function (CM-1310)#4310
Merged
Merged
Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds sonatype_popularity_score as a 4th cumulative-coverage signal to the production rank_packages() ranking function via a new migration. It is step 3 of 3 in wiring Sonatype's popularity score (a substitute for the missing raw Maven download counts) into package criticality scoring, so industry-critical Maven packages that are under-represented as dependency targets in the graph are no longer missed.
Changes:
- New migration
V1783123201__rank_packages_sonatype_signal.sqlperformingCREATE OR REPLACE FUNCTION rank_packages(...). - Adds the per-row
COALESCE(sonatype_popularity_score, 0)value plus its per-ecosystemSUM(...) OVER (PARTITION BY ecosystem)total in thebaseCTE. - Adds a
('sonatype_popularity', ...)tuple to thewalkedunpivot; the existing zero-totalWHEREguard leaves ecosystems without Sonatype data (npm/pypi) unchanged.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feeds
sonatype_popularity_scoreintorank_packages()as a 4th signal, so the Sonatype popularity score actually drives criticality.Sonatype could not deliver raw monthly Maven download counts, so instead they provide a popularity score derived from their SCA telemetry — normalized 0–100 per ecosystem, tiered P0–P3. Until now Maven criticality relied only on
dependent_countandtransitive_dependent_count, so industry-critical Maven packages that are under-represented as dependency targets in our graph were missed. This signal is the substitute for the missing downloads data.This is step 3 of 3:
sonatype_*columns onpackages.sonatype_popularity_scoreintorank_packages()as a 4th signal.Changes
New migration
V1783123201__rank_packages_sonatype_signal.sql—CREATE OR REPLACE FUNCTION rank_packages(...)adding one signal. Only 3 lines change versus the previous definition:baseCTE — the per-row valueCOALESCE(sonatype_popularity_score, 0)and the per-ecosystem totalSUM(...) OVER (PARTITION BY ecosystem).VALUESunpivot — one extra tuple('sonatype_popularity', ...).Everything downstream (
walked,combined,final, theUPDATE) is signal-agnostic, so no other change is needed. No hard-coded signal count, no per-ecosystem branch, no divisor to update.Type of change
JIRA ticket
CM-1310
Note
Medium Risk
Replaces the production ranking function and can shift
impact,is_critical, and ranks for Maven (and any ecosystem with Sonatype scores);BOOL_ORcriticality can only add critical packages, not remove them.Overview
rank_packages()now includessonatype_popularity_scoreas a fourth cumulative-coverage signal alongside downloads and dependency counts, via migrationV1783123201__rank_packages_sonatype_signal.sql.The
baseCTE adds per-rowCOALESCE(sonatype_popularity_score, 0)and an ecosystem-level sum; thewalkedunpivot gains a('sonatype_popularity', …)row. Signals with zero ecosystem total are still skipped, so ecosystems without Sonatype data keep the same effective signal set as before.impact,is_critical,rank_in_ecosystem, spotlight overrides, andlast_synced_atstamping are unchanged in structure—only the averaged signal set can grow where Sonatype totals are non-zero (notably Maven as a downloads substitute).Reviewed by Cursor Bugbot for commit f68b946. Bugbot is set up for automated code reviews on this repo. Configure here.