Skip to content

fix(attribution): scope non-agent file enumeration to parent commit#737

Open
peyton-alt wants to merge 5 commits intomainfrom
fix/attribution-accuracy-cli
Open

fix(attribution): scope non-agent file enumeration to parent commit#737
peyton-alt wants to merge 5 commits intomainfrom
fix/attribution-accuracy-cli

Conversation

@peyton-alt
Copy link
Contributor

@peyton-alt peyton-alt commented Mar 19, 2026

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)

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→HEAD instead of session 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.

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>
Copilot AI review requested due to automatic review settings March 19, 2026 20:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CalculateAttributionWithAccumulated to 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.

peyton-alt and others added 2 commits March 19, 2026 15:25
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: e91fd360caef
@peyton-alt peyton-alt marked this pull request as ready for review March 19, 2026 22:30
@peyton-alt peyton-alt requested a review from a team as a code owner March 19, 2026 22:30
@peyton-alt
Copy link
Contributor Author

@BugBot review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

peyton-alt and others added 2 commits March 19, 2026 17:53
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants