Skip to content

fix(scoring): inject server-side time decay into score breakdown paths - #881

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-time-decay-application-in-score-breakdown
Jun 19, 2026
Merged

fix(scoring): inject server-side time decay into score breakdown paths#881
JSONbored merged 1 commit into
mainfrom
codex/fix-time-decay-application-in-score-breakdown

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The new score-breakdown HTTP route and MCP tool built previews using caller-supplied input and omitted the server-gated applyTimeDecay injection, causing aged PRs to be reported without the time-decay multiplier and returning inflated effectiveEstimatedScore values.
  • The intent is to preserve the server-side owner-gated behavior (SCORING_TIME_DECAY_ENABLED) used by existing preview endpoints so breakdowns remain accurate and consistent.

Description

  • Inject applyTimeDecay: isTimeDecayEnabled(c.env) before calling buildScorePreview in the /v1/scoring/explain-breakdown route (src/api/routes.ts).
  • Inject applyTimeDecay: isTimeDecayEnabled(this.env) before calling buildScorePreview in the MCP explainScoreBreakdown tool (src/mcp/server.ts).
  • Add integration coverage to test/integration/api.test.ts that enables SCORING_TIME_DECAY_ENABLED, sends an aged PR input (prAgeHours), and asserts the breakdown's effectiveEstimatedScore matches the preview's decayed estimate, including minimal type assertions to satisfy TypeScript.

Testing

  • Ran type checking with npm run typecheck and it succeeded.
  • Ran the focused integration test with npx vitest run test/integration/api.test.ts -t "serves deterministic signal endpoints" --reporter=verbose and the test passed (1 passed, 36 skipped).
  • Performed git diff --check as part of the workflow and there were no whitespace/format issues.

Codex Task

@ghost

ghost commented Jun 18, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #881 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@ghost ghost added the gittensory:reviewed label Jun 18, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

ghost commented Jun 18, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 3 changed file(s) — two independent AI reviewers.

Changed files: src/api/routes.ts, src/mcp/server.ts, test/integration/api.test.ts

Suggested action: 🛠️ Request changes. (reviewers split: request changes / merge) Address the suggestions below before merging.

Reviewer A · gpt-oss-120b — recommends 🛠️ request changes
The PR adds server‑side injection of the time‑decay flag into scoring previews and breakdowns, and updates tests to verify the behavior when the feature is enabled.

Suggestions

  • Add an import for isTimeDecayEnabled in both src/api/routes.ts and src/mcp/server.ts (e.g., import { isTimeDecayEnabled } from '../scoring/model';).
  • Consider adding a test case where SCORING_TIME_DECAY_ENABLED is unset or false to confirm the flag is not applied.
  • Verify that the buildScorePreview signature accepts the extended input shape (applyTimeDecay?: boolean). If not, update the type definition accordingly.

Worth double-checking

  • Missing import will cause a TypeScript compilation error, breaking the build.
  • If buildScorePreview does not expect the new field, runtime errors could occur.
  • The test assumes the API response includes timeDecayMultiplier; a mismatch would cause false failures.

Reviewer B · mistral-small-3.1-24b-instruct — recommends ✅ merge
This PR injects server-side time decay into the score breakdown paths, ensuring that time decay is applied based on an owner-gated global setting. The changes are well-documented and include necessary tests.

Suggestions

  • Consider adding a comment explaining why the applyTimeDecay field is being added to the input object in both src/api/routes.ts and src/mcp/server.ts.
  • Ensure that the isTimeDecayEnabled function is thoroughly tested, especially edge cases where the environment variable might be unset or have unexpected values.

Worth double-checking

  • Verify that the time decay logic does not introduce any regressions in the scoring model.
  • Check that the new tests cover all possible scenarios, including cases where time decay is disabled.

@JSONbored
JSONbored force-pushed the codex/fix-time-decay-application-in-score-breakdown branch from 31a01a2 to b237381 Compare June 18, 2026 22:22
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.71%. Comparing base (5d9d73a) to head (b237381).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #881   +/-   ##
=======================================
  Coverage   96.71%   96.71%           
=======================================
  Files         108      108           
  Lines       14641    14643    +2     
  Branches     5298     5298           
=======================================
+ Hits        14160    14162    +2     
  Misses        102      102           
  Partials      379      379           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 1ed9df1 into main Jun 19, 2026
20 checks passed
@JSONbored
JSONbored deleted the codex/fix-time-decay-application-in-score-breakdown branch June 19, 2026 05:49
@github-actions github-actions Bot mentioned this pull request Jun 19, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant