Conversation
…nt amend inflation"
| prompt_record.total_additions = *session_additions.get(session_id).unwrap_or(&0); | ||
| prompt_record.total_deletions = *session_deletions.get(session_id).unwrap_or(&0); |
There was a problem hiding this comment.
🔴 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.
| 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; | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
Reverts #1081