Repository navigation
fix(platform): attribution gap could exceed 100% on narrow windows - #279
Merged
Merged
Conversation
The engine omits commit_origin_distribution for a repo with zero AI/bot-classified commits in-window (has_non_human gate) — a separate condition from attribution_gap's own independent >=3-flagged-commits threshold, so an all-human repo can still trip the attribution-gap heuristic. computeAIvsHuman summed flagged_commits from every repo with attribution_gap into the numerator, but only summed dist.HUMAN from repos that also had commit_origin_distribution into the denominator — an all-human repo contributed to the former without ever reaching the latter. Surfaced on the dashboard as "174 of 142 human commits" (123%) on a 7-day window, where a short lookback makes an all-human commit burst that still trips the heuristic far more likely than on 30/90 days. Falls back to attribution_gap.total_human_commits for a repo's human count when commit_origin_distribution is absent, so every repo contributing to the numerator also contributes to the denominator. Clamps flaggedPct to 100 as defense in depth for any gate interaction not yet found. Added a regression test reproducing the aggregate effect across two all-human repos (not a per-repo invariant violation — flagged_commits <= total_human_commits always holds within one repo's own numbers). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The previous fallback added an all-human repo's total_human_commits to totalHuman, which also feeds commitShare — so the org Human/AI split shifted depending on whether the attribution-gap heuristic happened to fire. Track the gap denominator in its own gapHuman counter instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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
Reported from the live dashboard: the Attribution Gap card showed 123% ("174 of 142 human commits") with the window filter set to 7 days.
Root cause
The engine omits
commit_origin_distributionfor a repo with zero AI/bot-classified commits in-window (thehas_non_humangate) — a separate condition fromattribution_gap's own independent>=3-flagged-commits threshold. An all-human repo can still trip the attribution-gap heuristic (a burst of human commits satisfying the velocity signals) while never emittingcommit_origin_distributionat all.computeAIvsHumansummedflagged_commitsfrom every repo withattribution_gapinto the numerator, but only summeddist.HUMANfrom repos that also hadcommit_origin_distributioninto the denominator. An all-human repo contributed to the former without ever reaching the latter — not a per-repo invariant violation (flagged_commits <= total_human_commitsalways holds within one repo's own numbers, confirmed against the engine), but an aggregate effect across repos.A narrow 7-day window makes this far more likely than 30/90 days: it's common for a repo to have zero AI-attributed commits in a short window while still having a dense burst of human commits (a crunch/sprint) that satisfies the heuristic.
Fix
platform/lib/queries/org-summary.ts,computeAIvsHuman: falls back toattribution_gap.total_human_commitsfor a repo's human count whencommit_origin_distributionis absent, so every repo contributing to the numerator also contributes to the denominator. ClampedflaggedPctto 100 as defense in depth for any gate interaction not yet found.Added a regression test reproducing the aggregate effect across two all-human repos.
Test plan
npx tsc --noEmit— cleannpx vitest run— 402 passed (1 new)npm run build— not re-run for this change (pure aggregation logic, no new route/page surface)🤖 Generated with Claude Code