fix(scoring): truncate per-repo grace_period_hours to int for upstream parity - #1326
Merged
JSONbored merged 6 commits intoJun 26, 2026
Conversation
…m parity (JSONbored#1320) Upstream resolve_time_decay coerces only grace_period_hours to an integer (grace_period_hours=int(pick(...))) while the curve params stay floats. A repo may legally configure a fractional grace (upstream validates 0..168), so the un-truncated TS value left a PR aged between trunc(grace) and grace looking fresh in the preview while it was already decaying upstream. Wrap the resolved grace in Math.trunc to match, and pin the truncation + boundary-decay behavior with a regression test.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1326 +/- ##
=======================================
Coverage 95.42% 95.42%
=======================================
Files 193 193
Lines 21026 21026
Branches 7614 7614
=======================================
Hits 20064 20064
Misses 383 383
Partials 579 579
🚀 New features to boost your workflow:
|
This was referenced Jun 26, 2026
Closed
12 tasks
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
Fixes #1320.
resolveTimeDecay(src/scoring/preview.ts) advertises that it "Mirrors upstream'sresolve_time_decay", but it did not reproduce upstream's integer coercion of the grace period. Upstream coerces onlygrace_period_hoursto an integer while the three curve params stay floats:Upstream's range check permits
0 <= grace_period_hours <= 168, so a maintainer may legally configure a fractional grace (e.g.13.9), which upstream truncates to13. The TS port passed the raw float through, so a PR aged betweentrunc(grace)andgrace(e.g. 13.5h with grace13.9) was reported as fresh (multiplier1.0) in the preview while the validator already applies decay — silently over-stating the score. Same class of parity drift as #806/#807/#808/#812.The fix wraps the resolved grace in
Math.trunc(truncate-toward-zero, the literal translation of Pythonint()); it is a no-op on the already-integer default12, so no existing fixture changes. A regression test pins both the truncation and the boundary-decay behavior.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; the one changedsrc/**line (Math.trunc(...)) introduces no new branch and is exercised by the time-decay suite; the new regression test covers both the truncation and the boundary-decay path.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:cigate locally; all checks green.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.This is a backend scoring-logic change with no UI/API surface impact, so the UI Evidence section is omitted.
Notes
resolveTimeDecay; no schema, OpenAPI, wrangler, or migration impact.