Skip to content

fix(review): avoid review effort boundary undercounts - #4139

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-review-effort-band-issue
Jul 8, 2026
Merged

fix(review): avoid review effort boundary undercounts#4139
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-review-effort-band-issue

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Persisted review-effort minutes are stored rounded, and the prior bandFromMinutes reconstructed effort as minutes / MINUTES_PER_EFFORT, which can map rounded boundary minutes down into the previous complexity band.
  • This produced undercounted maintainer avgBand values when folding persisted minutes into aggregates, affecting analytics accuracy (non-security, correctness only).

Description

  • Update bandFromMinutes to treat a persisted rounded minutes value as representing any effort up to minutes + 0.5, computing maxRepresentedEffort = (Math.max(0, minutes) + 0.5) / MINUTES_PER_EFFORT and returning bandForEffort(maxRepresentedEffort).
  • Add regression unit tests to test/unit/review-effort.test.ts and test/unit/stats.test.ts that assert boundary-rounded minutes map to the higher possible band and that aggregates reflect that.
  • Preserve existing estimateReviewEffort behavior and total minutes folding; this change only adjusts band reconstruction from persisted minutes.

Testing

  • Ran targeted unit tests with npx vitest run test/unit/review-effort.test.ts test/unit/stats.test.ts --pool=forks, and both test files passed (43 tests).
  • Ran static typecheck with npm run typecheck and verified git diff --check, both succeeded locally.
  • Attempted full coverage with npm run test:coverage, but coverage remapping failed during generation with TypeError: jsTokens is not a function, so an unsharded coverage report could not be completed in this environment despite the targeted tests passing.
  • npm audit --audit-level=moderate could not complete due to the registry returning 403 Forbidden from the audit endpoint in this environment.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.68%. Comparing base (470d5fe) to head (bdc3644).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4139   +/-   ##
=======================================
  Coverage   93.68%   93.68%           
=======================================
  Files         384      384           
  Lines       36007    36008    +1     
  Branches    13213    13213           
=======================================
+ Hits        33733    33734    +1     
  Misses       1618     1618           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/review-effort.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 8, 2026
@loopover-orb

loopover-orb Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-08 07:35:13 UTC

3 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This correctly fixes a real reconstruction bug: bandFromMinutes previously treated persisted minutes as an exact `effort/0.5` value, discarding the fact that Math.round collapses a whole range of efforts into one minutes integer. The new `(minutes+0.5)/MINUTES_PER_EFFORT` formula recovers the true supremum of that range — algebraically this is `2*minutes+1`, which is always odd and therefore never lands exactly on a BAND_MAX boundary (10/40/120/300), so there's no boundary-equality ambiguity introduced by treating an exclusive supremum as an inclusive bound. I traced the math by hand for all four new regression cases (5→2, 20→3, 60→4, 150→5) and the aggregate case ([5,20,60,150]→avgBand 4, total 235) and both check out, and CI is green on the exact commit.

Nits — 2 non-blocking
  • src/review/review-effort.ts:51 — the `+ 0.5` is derived from `MINUTES_PER_EFFORT` being the rounding granularity; a one-line comment spelling out the derivation (`round(effort*k)` inverse => `effort < (minutes+0.5)/k`) would save the next reader from re-deriving it, as flagged by static analysis.
  • Consider exporting the derivation as a tiny named constant or comment (e.g. `ROUNDING_UNCERTAINTY = 0.5`) instead of the bare literal in bandFromMinutes, purely for readability — not required given the existing inline comment already explains intent.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 52 registered-repo PR(s), 43 merged, 496 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 52 PR(s), 496 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 52 PR(s), 496 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 8, 2026
@JSONbored
JSONbored merged commit aec10e3 into main Jul 8, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-review-effort-band-issue branch July 8, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant