score design
This page derives the properties of the scoring model in
src/score/impact_factor.mbt and
explains why it has this shape. The score API lists the
functions; the metrics design explains where the signals come
from.
Design goal
The score must order the packages of a registry snapshot by how much the ecosystem relies on them, from signals that the public registry index provides. It must be cheap, deterministic and explainable: a reader of a package page should be able to see why one package outranks another, and the same signals must give the same score on every MoonBit backend.
The model borrows its vocabulary from bibliometrics. A dependency is a citation: a deliberate decision by another author to build on this work. The journal impact factor counts citations, discounts self-citations and reports a journal’s place within its field by quartile; the score does the same with dependents, dependents of the same owner, and grades.
Mathematical background
Signals
For a package at time the metrics package measures:
| Symbol | Meaning |
|---|---|
| external dependents: packages of other owners whose latest release depends on | |
| dependents of the same owner | |
| , | the dependents among and whose dependency first appeared in the 180 days before |
| downloads reported by mooncakes.io | |
| whole days since the latest release ( when unknown) |
The score
With the self-dependent weight , write
The score is
where the release-recency multiplier is the continuous, piecewise linear function
with negative treated as . score_breakdown returns , ,
and , so that exactly as computed.
A logarithmic index
Because , the bracket is the logarithm of a weighted product:
The product is a Cobb–Douglas index of the shifted counts and the weights are its elasticities. Two consequences follow.
Doubling adds a constant. Since , doubling adds points whatever was: going from 10 to 21 dependents is worth as much as going from 1000 to 2001.
Diminishing returns. One more external dependent adds
points (by ), so the marginal value of a dependent falls like , and inflating any one count buys little: multiplying by ten adds exactly points.
Same-owner dependents
A same-owner dependent counts of an external one, inside the logarithm. An owner who publishes packages that all depend on adds points instead of ; for large the difference tends to
the value of two doublings. Splitting a project into many packages therefore
cannot replace adoption by other people: in the registry snapshot of
11 June 2026, 738 of the 1548 dependency edges of version 0.1 (48 %)
connected packages of one owner, and the package with the most dependents
after moonbitlang/x and moonbitlang/async had only same-owner
dependents.
Grades
Let be the scores of the packages of the registry. The competition position of package is
so equal scores share a position, and the share of packages that score strictly higher is . The grade is
Without ties exactly packages are S; ties at a
boundary all take the better grade, because counts only strictly higher
scores. In the snapshot of 9 October 2026 () the grades split
.
Momentum
The metrics package evaluates the signals a second time as they were days earlier, from the releases and dependency declarations published by then, giving , or nothing when the package had no release yet. With the change and the threshold
the label is
The two bounds of cover each other’s blind spot. The absolute bound
stops small packages from changing label on noise: a package that goes from
one download to three gains points times
, a ratio of but a change near the bound. The relative bound
stops large packages from changing label on a small fraction: at
, a change of points is . The ratio
is stored as score_growth_ratio_30d, with for a
package whose earlier score was and that grew, and otherwise.
Ageing alone never changes the label. Over days the multiplier falls by at most , a relative change of at most , below the bound. The step function of version 0.1 fell by up to in one day and made every package crossing , or days look like it was declining.
A logarithm that is the same everywhere
ln ports the FreeBSD msun e_log.c: with
, then with
where is a degree-7 polynomial in fitted by Remez, and is added in two parts ( with a short significand, so that is exact, and the correction ). It uses only IEEE 754 additions, multiplications, divisions and bit manipulation, which every backend rounds the same way, so the result has the same bits on js, wasm, wasm-gc and native. On inputs (all integers up to and a geometric sweep from to ) the three tested backends agreed bit for bit, and results () differed from the correctly rounded value, each by one unit in the last place, matching fdlibm’s documented bound of ulp.
Design decisions
Dependents of the latest release
Problem. Version 0.1 counted every package that had ever declared a dependency on in any release. A package that replaced a dependency kept crediting the old one forever.
Choice. Only the latest non-yanked release counts. In the snapshot of
9 October 2026, myfreess/sqlite3 lost 11 dependents that moved to
moonbit-community/sqlite3; the first now shows as Cooling and the second
as Rising, which is what happened. Yanked releases neither count as the
latest release nor contribute dependencies, because their authors withdrew
them.
Discount, not exclusion, of the same owner
Problem. Same-owner dependents are often real reuse (a parser used by the author’s formatter), but they are also free to create.
Options. Count them fully (version 0.1); exclude them, like the impact factor without self-citations; count distinct owners only; discount them.
Choice. A discount of . Excluding them would make an author’s own toolkit of tightly coupled packages look unused; counting only distinct owners would erase the difference between one package and fifty from the same external owner. The package page reports , and the number of distinct external owners so that a reader can apply a stricter rule.
Relative grades
Problem. Version 0.1 graded by fixed thresholds on (, ,
, ). The thresholds were chosen for one registry size; as the
registry and the download counts grew, S stopped meaning “exceptional”
and the share of each grade drifted with every snapshot.
Choice. Shares of the registry, like journal quartiles. A grade now
answers the reader’s question, “how does this package compare with the rest
of the registry?”, and keeps its meaning as the registry grows. The score
itself stays absolute: it does not depend on other packages, so it can be
compared across snapshots, while positions and grades are relative. Shares
of , , , and grow towards the bottom because the
bottom of the registry is dense with packages that nobody uses yet; packages
with no signal at all are always D.
A continuous multiplier
Problem. The step multiplier of version 0.1 moved a score by up to overnight when a package crossed a step, which the momentum then reported as a decline.
Choice. The same bounds, and , joined linearly between and days. The bounds keep the earlier guarantees: the multiplier changes a score by at most , the freshest and the oldest package with the same signals differ by the factor , and an unused package stays at .
Momentum from the past signals, not from a stored score
Problem. Comparing with the score computed 30 days ago would need a history of scores, and any change to the model would make the comparison meaningless.
Choice. Recompute the score of 30 days ago with the current model from
the releases published by then. Version 0.1 did this for dependents but used
for the downloads of 30 days ago, so the whole download term counted as
growth and almost every popular package was Rising. The index builder now
keeps a short history of download counts; until a count from about 30 days
ago exists, the current count stands in for it and downloads add no change.
Weights
The weights are unchanged from version 0.1. Dependents weigh most because a dependency is a deliberate decision; downloads weigh least because they also count automated builds and are missing for packages the builder could not look up; recent dependents are counted on top of all dependents, a bonus for current adoption rather than a separate population. They are editorial choices of this project, not fitted parameters.
Correctness / invariants
- Monotonicity. For fixed , is non-decreasing in , , , and , and strictly increasing in each while the others are fixed, because is strictly increasing, the weights are positive and . is non-increasing in .
- Range. , with exactly when . Counts
are
Int, so and . - Breakdown consistency.
compute_scoreis computed fromscore_breakdown, so the parts on a package page add up to the score exactly as stored. - Positions.
rank_positionssorts once () and assigns equal positions to equal scores;NaNsorts last. Positions are and for every package with the best score. - Labels are total. Every function returns one of its labels for every
input;
NaNscores areDandStable. - Snapshot consistency.
score_populationderives every field of aScoreSnapshotfrom the same two scores, soscore_growth_30d == score - score_30d_agoexactly.
Alternatives rejected
- PageRank-style centrality would reward being depended on by important packages, but it needs an iterative solver and a damping parameter and cannot be explained in a table on a package page.
- Transitive dependents count one downstream package through every path and favour low-level packages more than the logarithm can correct.
- Quantile scores instead of quantile grades would change a package’s score whenever other packages appear; only the grade is relative.
- Learning the weights would need a labelled ranking that does not exist.
Boundaries
- The score measures reliance inside one registry snapshot. It does not measure quality, correctness, security or maintenance effort.
- The package takes the signals as given; the metrics design defines them.
- Grades and positions depend on the population passed to
score_population; scores do not. lnis reproducible across backends, but the native backend compiled by a C compiler that contractsa*b+cinto fused multiply-adds (GCC by default on targets with FMA) can still differ in the last bit; Luna-Flow tracks this as a toolchain issue.