Skip to content

Fix multi-session attribution summary loss#813

Open
peyton-alt wants to merge 4 commits intomainfrom
fix/attribution-multi-session-summary-loss
Open

Fix multi-session attribution summary loss#813
peyton-alt wants to merge 4 commits intomainfrom
fix/attribution-multi-session-summary-loss

Conversation

@peyton-alt
Copy link
Copy Markdown
Contributor

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

Fix multi-session attribution summary loss

When multiple agent sessions contribute to the same checkpoint (same base commit), per-session
InitialAttribution data was being lost during condensation — the root CheckpointSummary only reflected
the latest session's attribution, not the aggregate across all sessions.

This PR fixes the problem with three changes:

  1. Combined attribution on CheckpointSummary
  • Adds a combined_attribution field to CheckpointSummary that holds the summed attribution across all
    sessions in a checkpoint
  • After all sessions are condensed in PostCommit, updateCombinedAttributionForCheckpoint reads each
    session's InitialAttribution, aggregates the line counts (agent lines, human added/modified/removed,
    total committed), and writes the result back to the root metadata
  • Existing combined_attribution is preserved when the summary is rewritten by subsequent session
    condensations
  1. Lightweight ReadSessionMetadata path
  • Adds GitStore.ReadSessionMetadata() that reads only metadata.json for a given session index — no
    transcript or prompt blobs
  • Used by the aggregation logic to avoid expensive full-content reads when only attribution data is
    needed
  1. Diagnostic prompt_attributions persistence
  • Persists raw per-prompt attribution diagnostics (PromptAttributions) as JSON in each session's
    metadata.json
  • Wired through both v1 and v2 committed checkpoint writers
  • Enables root-cause analysis of attribution bugs by showing exactly which prompt recorded which "user"
    lines

Note

Medium Risk
Updates checkpoint metadata schema and post-commit behavior to persist new diagnostic attribution data and to mutate root checkpoint metadata after writes; errors could affect checkpoint history or attribution reporting for existing multi-session checkpoints.

Overview
Fixes multi-session attribution loss by introducing a root-level combined_attribution field on CheckpointSummary and updating it after all sessions are condensed.

Adds a cheap ReadSessionMetadata path plus UpdateCheckpointSummary to recompute/sum per-session initial_attribution and persist the aggregate without rewriting session content; root summary writes now preserve any existing combined_attribution instead of dropping it.

Also persists raw per-prompt attribution diagnostics by JSON-encoding PromptAttributions into session metadata.json (prompt_attributions), and wires this through both v1 and v2 committed checkpoint writers. Includes a regression test covering multi-session combined attribution persistence.

Written by Cursor Bugbot for commit 44bde7b. Configure here.

Copilot AI review requested due to automatic review settings March 31, 2026 02:31
Copy link
Copy Markdown
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

Fixes loss of attribution summary information when a single checkpoint is associated with multiple sessions, and adds diagnostic persistence for prompt-level attribution inputs.

Changes:

  • Adds a post-commit step to compute and persist a combined (multi-session) attribution value at the checkpoint root.
  • Persists raw per-prompt attribution data into session metadata for debugging attribution issues.
  • Preserves any previously-written combined_attribution when rewriting the root checkpoint summary.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/entire/cli/strategy/manual_commit_hooks.go Updates PostCommit to compute/store combined attribution for multi-session checkpoints.
cmd/entire/cli/strategy/manual_commit_condensation.go Serializes prompt attribution details into WriteCommittedOptions for persistence.
cmd/entire/cli/checkpoint/v2_committed.go Writes prompt_attributions into v2 session committed metadata.
cmd/entire/cli/checkpoint/committed.go Writes prompt_attributions, preserves combined_attribution in root summary, and adds an update method to patch root metadata after sessions are written.
cmd/entire/cli/checkpoint/checkpoint.go Extends committed metadata schemas/options with prompt_attributions and root combined_attribution.

peyton-alt and others added 3 commits March 30, 2026 20:39
Wrap errors returned from checkpoint.GitStore methods (ReadCommitted,
UpdateCheckpointSummary) with fmt.Errorf to satisfy the wrapcheck linter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…multi-session test

Fixes all 4 issues from Copilot and Cursor Bugbot review:

1. Fix misplaced doc comment — marshalPromptAttributions and
   buildSessionMetrics now have their own correctly positioned doc
   comments
2. Log warning on marshal failure in marshalPromptAttributions
   instead of silently returning nil
3. Add ReadSessionMetadata to GitStore — lightweight method that reads
   only session metadata.json (no transcript/prompt blobs). Used by
   updateCombinedAttributionForCheckpoint to avoid expensive reads
4. Add TestUpdateCombinedAttribution_MultiSession verifying
   combined_attribution is computed and persisted across 2 sessions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@peyton-alt
Copy link
Copy Markdown
Contributor Author

@BugBot review

Copy link
Copy Markdown

@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 peyton-alt marked this pull request as ready for review April 1, 2026 05:03
@peyton-alt peyton-alt requested a review from a team as a code owner April 1, 2026 05:03
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