Skip to content

fix: use authoritative metrics in progression pipeline - #10

Merged
ashishsinghbora merged 1 commit into
mainfrom
fix/progression-metrics
Sep 25, 2026
Merged

ashishsinghbora merged 1 commit into
mainfrom
fix/progression-metrics

Conversation

@ashishsinghbora

Copy link
Copy Markdown
Contributor

Summary

Replaced ad-hoc and incomplete metric evaluation in src/lib/progression/pipeline.ts with a dedicated, authoritative getContributorMetrics(userId, db) function located in src/lib/metrics/contributor-metrics.ts.

Why

Previously, pipeline.ts evaluated progression using hardcoded dummy counts:

issuesResolved: 0,
reviewsCompleted: 0,

This prevented contributors who legitimately resolved issues and completed peer code reviews from ever advancing to Core Contributor status. Furthermore, metric calculation was duplicated between the progression pipeline and dashboard views.

Changes

  • Created authoritative getContributorMetrics(userId, db) in src/lib/metrics/contributor-metrics.ts:
    • Counts only merged contributions on official, approved projects (isOfficial: true, contributionEnabled: true, approvedAt IS NOT NULL).
    • Deduplicates contributions by canonical PR URL.
    • Counts completed claims from issueClaims (status = 'completed').
    • Counts meaningful peer code reviews: excludes self-reviews, excludes dismissed reviews, only counts valid outcomes (approved / changes_requested), and deduplicates multiple review events on the same PR.
  • Updated src/lib/progression/pipeline.ts to consume getContributorMetrics and log verified metric counts into promotion audit records.
  • Updated src/app/dashboard/work/page.tsx to use getContributorMetrics so the contributor workspace displays the exact same authoritative progression metrics.
  • Added comprehensive unit tests in src/lib/metrics/contributor-metrics.test.ts verifying zero counts, contributor promotion, active contributor promotion, core contributor advancement, self-review exclusion, duplicate review deduplication, and unapproved repository rejection.

Tests

  • npm test: 17 passed / 17 test files, 68 / 68 tests passing
  • npx tsc --noEmit: 0 errors
  • npm run lint: 0 errors, 0 warnings
  • npm run build: 19 / 19 routes generated cleanly

Migration

  • None (schema tables already support metric evaluation)

Risk

Low. Refactors metric calculations to an authoritative server-side helper with strict data integrity rules and full test coverage.

Verification

  • Ran vitest unit test suite covering all contributor progression tiers.
  • Verified dashboard work page loads and accurately reflects live progression status.

- Implemented getContributorMetrics in src/lib/metrics/contributor-metrics.ts
- Authoritatively computes merged contributions on official approved projects
- Strictly excludes self-reviews, dismissed reviews, and non-approved repositories
- Deduplicates multiple review events on the same pull request
- Connected getContributorMetrics to progression evaluation pipeline and work dashboard
- Added full unit test coverage for zero metrics, contributor/active/core thresholds, self-review exclusion, and dismissed reviews
@ashishsinghbora
ashishsinghbora merged commit 9f4f460 into main Sep 25, 2026
1 check passed
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