Skip to content

fix(signals): detect the Explosive spike from the last 90 days - #131

Open
MikeSoroka wants to merge 1 commit into
Younesfdj:masterfrom
MikeSoroka:fix/style-recent-spike
Open

MikeSoroka wants to merge 1 commit into
Younesfdj:masterfrom
MikeSoroka:fix/style-recent-spike

Conversation

@MikeSoroka

Copy link
Copy Markdown

Fixes #130

Problem

The Explosive style ("a recent burst well above your usual pace") is triggered by recent_spike, which compared the last 365 days of contributions against lifetime / active_years. That window is too coarse, and it misfires both ways:

  • Fresh bursts are missed. A few busy weeks get averaged across the whole year and rarely clear the threshold, so the profile reads as Measured ("light recent activity").
  • Finished bursts linger. A burst 9–11 months ago still counts as "recent", so a profile with no current activity can show Explosive.
  • The baseline is skewed. active_years comes from owned-repo created/pushed years, not contribution years (see Active years are undercounted for organization contributions #90), so the lifetime average can be far too low or too high.

Fix

recent_spike is now computed by isRecentSpike() in lib/github/signals.ts from the daily contribution calendar. That calendar was already fetched (only to count active days), so this costs no extra API calls.

A profile spikes when its last 90 days are:

  • at least 30 contributions (so a few commits after a quiet spell don't count), and
  • more than 2× the usual pace for 90 days.

"Usual pace" is the higher of:

  • the rate over the rest of the last year, and
  • the lifetime rate per active past year (completed years with any contributions, from the per-year breakdown).

Taking the higher of the two means getting back to a normal level after a quiet stretch doesn't count as a burst.

Changes

  • lib/github/client.ts: RawPayload gains recentDaily: number[] (the calendar flattened, oldest first)
  • lib/github/signals.ts: new exported isRecentSpike(); replaces the one-line formula
  • scripts/distribution-runner.ts: builds recentDaily the same way, so the distribution sampling scores like production
  • tests/signals.test.ts: 6 new tests: fresh burst, finished burst, steady pace, getting back to the lifetime pace, tiny counts, wiring through signalsFromPayload

Notes

Testing

  • npm run lint: no errors (existing warnings only, none in touched files)
  • npm test: 305/305 pass
  • npm run build: succeeds
  • Checked against a real profile locally: 93 contributions in the last 90 days vs. a usual pace of ~21, so it spikes (it was Measured before)

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.

Style label misreads recent activity: Explosive with no recent activity, Measured despite a recent burst

1 participant