You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(engine): delegate opportunityFreshnessFactor to its pure mirror with an injected clock (#8011) (#8039)
opportunityFreshnessFactor hand-reimplemented pickIssueTimestamp/issueAgeDays/
isParseableIssueTimestamp instead of delegating to computeOpportunityFreshness
(./opportunity-freshness.js), which already carries the identical
round4/clamp/exp(-age/20) formula -- the exact duplicated-arithmetic setup whose
drift #7529 had to fix for its sibling opportunityCompetitionFactor. Worse, the
duplicated issueAgeDays read a bare Date.now(), so buildRepoRewardRisk's
freshness output was not deterministic the way the rest of the module claims.
Delegate to the mirror (same treatment #7529 gave the competition factor) and
thread an injectable nowMs clock through buildRepoRewardRisk /
buildContributorRewardRiskStrategy, defaulting to Date.now() only at the
buildRepoRewardRisk call boundary -- never inside the pure calculators. Output
is arithmetically identical for finite inputs. The now-redundant duplicated
helpers are removed; their surviving copies stay covered through
opportunity-freshness.ts's own internals tests.
Tests: the existing parity suite now injects the same clock on both sides
(exact equality, not wall-clock proximity) and a new determinism test pins
same-inputs + same-clock to the same factor and to the concrete
round4(exp(-2/20)) = 0.9048 value.
0 commit comments