Conversation
…t data When a prompt is inherited from INITIAL attributions (e.g., from a previous agent session), calculate_and_update_prompt_metrics would unconditionally overwrite total_additions/total_deletions with unwrap_or(0). If no new checkpoints existed for that session, the inherited values were zeroed out, causing total_ai_additions to be under-reported and acceptance rates to exceed 100%. Only update total_additions/total_deletions when checkpoint data actually exists for the session, preserving inherited values otherwise. Closes #1080 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 14, 2026
Merged
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
Fixes two related bugs in
total_additions/total_deletionshandling:total_additionszeroed out bycalculate_and_update_prompt_metricsusingunwrap_or(0)git commit --amendinflatestotal_ai_additionsdue to cumulative totals being re-summed in merge helpers #1098: Duringgit commit --amend, merge helpers summed cumulativetotal_additionsfrom both checkpoint VA and blame VA, causing inflation that doubled with each successive amendRoot Cause
#1080:
calculate_and_update_prompt_metricsunconditionally overwrotetotal_additionsfrom thesession_additionsmap. When a prompt was inherited from INITIAL with no new checkpoints, the session_id wasn't in the map, sounwrap_or(0)zeroed out the inherited value.#1098:
merge_prompts_picking_newestandmerge_attributions_favoring_firstsummedtotal_additionsacross sources. Sincetotal_additionsis cumulative, when the same prompt appeared in both checkpoint VA (with inherited or delta values) and blame VA (with cumulative values), the sum inflated the total.Fix
calculate_and_update_prompt_metrics: Only overwritetotal_additions/total_deletionswhen checkpoint data exists (if let Some)add_inherited_totalsadds the inherited INITIAL base to session deltas, making all prompts carry cumulative valuesmerge_prompts_picking_newestandmerge_attributions_favoring_firstfromsaturating_addtomax, since the highest cumulative value is always the most currentCloses #1080
Closes #1098
Test plan
test_inherited_prompt_preserves_total_additions_when_no_checkpoint_data— inherited prompts preserve values, prompts with checkpoints get updatedtest_empty_session_maps_preserve_existing_totals— empty maps (merge/rebase pattern) preserve valuestest_merge_prompts_does_not_inflate_totals_for_same_prompt— same prompt in both sources doesn't doubletest_merge_prompts_picks_higher_cumulative_total— higher cumulative value wins in mergetest_session_delta_plus_inherited_base_is_cumulative— session delta + inherited base = correct cumulativetest_merge_prompts_picking_newest_uses_max_totals_on_collisionto expect max semanticscargo test— all green)🤖 Generated with Claude Code