Skip to content

Revert "fix: preserve total_additions for inherited prompts and prevent amend inflation"#1106

Merged
svarlamov merged 1 commit intomainfrom
revert-1081-fix/total-additions-reset-inherited-prompts
Apr 14, 2026
Merged

Revert "fix: preserve total_additions for inherited prompts and prevent amend inflation"#1106
svarlamov merged 1 commit intomainfrom
revert-1081-fix/total-additions-reset-inherited-prompts

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Apr 14, 2026

Reverts #1081


Open with Devin

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +1917 to +1918
prompt_record.total_additions = *session_additions.get(session_id).unwrap_or(&0);
prompt_record.total_deletions = *session_deletions.get(session_id).unwrap_or(&0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Inherited prompt total_additions/total_deletions zeroed out when no checkpoint data exists

The change from conditional updates (if let Some(...)) to unconditional unwrap_or(&0) at lines 1917-1918 causes total_additions and total_deletions to be silently zeroed out for any prompt that doesn't have an entry in the session_additions/session_deletions maps.

This affects three call sites that pass real session data: from_just_working_log (virtual_attribution.rs:462), from_working_log_snapshot (virtual_attribution.rs:611), and from_persisted_working_log (virtual_attribution.rs:768). In all three, prompts inherited from INITIAL attributions (e.g., from a previous agent session) are loaded into prompts at e.g. virtual_attribution.rs:334-338, but session_additions is only populated from checkpoints (virtual_attribution.rs:400-403). An inherited prompt with no new checkpoint won't have an entry in session_additions, so its existing total_additions value (carried from the previous session) gets overwritten with 0.

The two merge/rebase call sites are unaffected

The call sites in rebase_authorship.rs:4560 and virtual_attribution.rs:2076 pass empty HashMaps but save totals before the call and restore them afterward, so they're safe. The data loss only affects the three working-log construction paths.

The deleted regression test test_inherited_prompt_preserves_total_additions_when_no_checkpoint_data (originally added for issue #1080) specifically verified this scenario and would fail with the new code.

Suggested change
prompt_record.total_additions = *session_additions.get(session_id).unwrap_or(&0);
prompt_record.total_deletions = *session_deletions.get(session_id).unwrap_or(&0);
if let Some(&additions) = session_additions.get(session_id) {
prompt_record.total_additions = additions;
}
if let Some(&deletions) = session_deletions.get(session_id) {
prompt_record.total_deletions = deletions;
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@svarlamov svarlamov merged commit 96a2266 into main Apr 14, 2026
25 of 26 checks passed
@svarlamov svarlamov deleted the revert-1081-fix/total-additions-reset-inherited-prompts branch April 14, 2026 19:55
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.

1 participant