fix(attribution): scope non-agent file enumeration to parent commit#737
Open
peyton-alt wants to merge 5 commits intomainfrom
Open
fix(attribution): scope non-agent file enumeration to parent commit#737peyton-alt wants to merge 5 commits intomainfrom
peyton-alt wants to merge 5 commits intomainfrom
Conversation
Intermediate commits between session start and the attributed commit were inflating total_committed and deflating agent_percentage. The root cause: non-agent file detection used session_base → head as its window, so any file added in an unrelated commit appeared as a human addition. Fix: pass HEAD's first parent tree/hash into CalculateAttributionWithAccumulated and use parent → head for non-agent file diffing. Only files that actually changed in this commit now count toward human additions. Falls back to session-base behaviour for initial commits (no parent). Before/after on a 20-line agent commit with a 50-line unrelated intermediate commit: total_committed: 70 -> 20 human_added: 50 -> 0 agent_percentage: 28.6% -> 100.0% Changes: - CalculateAttributionWithAccumulated: new parentTree/parentCommitHash params - condenseOpts/attributionOpts: carry parent context through post-commit path - PostCommit hook: resolve and thread first-parent tree/hash at commit time - Tests: unit regressions, integration regression, Bug B repro (t.Skip) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes attribution inflation caused by counting non-agent file changes across the entire session window (session base → HEAD) instead of scoping non-agent diffs to the attributed commit (parent → HEAD). This improves total_committed, human_added, and agent_percentage accuracy when intermediate unrelated commits exist.
Changes:
- Thread HEAD first-parent context (tree + hash) through the post-commit condensation path into attribution calculation.
- Update
CalculateAttributionWithAccumulatedto diff non-agent files using parent → head (falling back to session base behavior when no parent exists). - Add unit + integration regressions, plus focused “Bug B” repro candidates (one intentionally skipped).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/strategy/manual_commit_attribution.go | Uses parent→head baseline for non-agent file enumeration/diffing in attribution. |
| cmd/entire/cli/strategy/manual_commit_condensation.go | Extends condense/attribution opts to carry parent tree/hash into attribution. |
| cmd/entire/cli/strategy/manual_commit_hooks.go | Resolves HEAD parent tree and threads parent hash into condensation. |
| cmd/entire/cli/strategy/manual_commit_attribution_test.go | Adds unit tests validating parent-baseline behavior + fallback when parent is nil. |
| cmd/entire/cli/strategy/manual_commit_test.go | Adds Bug B candidate repro tests (one skipped). |
| cmd/entire/cli/integration_test/attribution_test.go | Adds integration regression for intermediate unrelated commit not inflating attribution. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Entire-Checkpoint: e91fd360caef
Contributor
Author
|
@BugBot review |
…computation - Add CombinedAttribution field to CheckpointSummary - Add UpdateCheckpointSummaryOptions and UpdateCheckpointSummary to Store interface - Implement GitStore.UpdateCheckpointSummary (patches root metadata.json in-place) - Add sessionAttrData type and computeCombinedAttribution function - Unit tests for computeCombinedAttribution edge cases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two-pass approach in PostCommit: - Pass 1: collect PromptAttributions per shadow branch before condensation clears them - Pass 2: after all sessions condensed, compute combined attribution for multi-session checkpoints and patch root CheckpointSummary via UpdateCheckpointSummary Single-session checkpoints are unaffected (computeCombinedAttribution returns nil for <2 sessions). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Intermediate commits between session start and the attributed commit were inflating total_committed and deflating agent_percentage. The root cause: non-agent file detection used session_base → head as its window, so any file added in an unrelated commit appeared as a human addition.
Fix: pass HEAD's first parent tree/hash into CalculateAttributionWithAccumulated and use parent → head for non-agent file diffing. Only files that actually changed in this commit now count toward human additions. Falls back to session-base behaviour for initial commits (no parent).
Before/after on a 20-line agent commit with a 50-line unrelated intermediate commit:
total_committed: 70 -> 20
human_added: 50 -> 0
agent_percentage: 28.6% -> 100.0%
Changes:
Note
Medium Risk
Changes attribution baselining logic used during manual-commit condensation, which can affect reported agent/human line counts and percentages across commits. Although it’s metrics-only, it touches core post-commit/condensation paths and adds new git-object resolution fallbacks.
Overview
Fixes manual-commit attribution inflation by scoping non-agent file detection to the attributed commit only (diffing
parent→HEADinstead ofsession base→HEAD), preventing unrelated intermediate commits from counting as human additions.Threads the HEAD first-parent tree/hash through the post-commit and condensation pipeline into
CalculateAttributionWithAccumulated, with best-effort resolution and warnings/fallbacks when parent context can’t be loaded.Adds unit and integration regressions covering the intermediate-commit case, plus a focused (skipped) repro test for an outstanding “0% AI” investigation.
Written by Cursor Bugbot for commit e09d085. Configure here.