Skip to content

[codex] Add session event attribution recovery - #1654

Merged
svarlamov merged 8 commits into
mainfrom
feat/attr-bootstrap
Jun 25, 2026
Merged

svarlamov merged 8 commits into
mainfrom
feat/attr-bootstrap

Conversation

@svarlamov

Copy link
Copy Markdown
Member

Summary

Adds a session-event mtime attribution recovery solver for commits where AI hook checkpoints were missed. The new solver runs after bash-history recovery and before adjacent-edge extension, then attributes still-unknown committed lines when nearby SessionEvent metric rows can be selected conservatively.

Details

  • queries the metrics DB for SessionEvent rows within a 3 second mtime window
  • ranks candidates by matching repo URL, existing commit session, then unambiguous time-only fallback
  • records recovered checkpoint telemetry with solver metadata and preserves known-human/bashed attributions
  • adds unit and integration coverage plus a design note for the recovery plan

Validation

  • task fmt
  • task lint
  • task test TEST_FILTER=session_event_candidate
  • task test TEST_FILTER=session_event_recovery
  • task test TEST_FILTER=attribution_recovery
  • task test TEST_FILTER=bash_history_recovers
  • task test

@svarlamov
svarlamov marked this pull request as ready for review June 25, 2026 14:13
@svarlamov
svarlamov merged commit 340b2b0 into main Jun 25, 2026
24 checks passed
@svarlamov
svarlamov deleted the feat/attr-bootstrap branch June 25, 2026 15:48
svarlamov added a commit to rajaiswal/git-ai that referenced this pull request Jun 30, 2026
PD-23 / GH git-ai-project#1677: the git-ai daemon could consume 20GB+ RSS during a
`git pull`. On a fast-forward `update-ref`, the daemon calls
`post_commit_from_working_log(Some(old), new)` where `old` is the old
branch tip from *before* the pull. Attribution recovery
(`recovery_committed_hunks`) then ran `diff_added_lines(old, new, None)`
with no pathspec, buffering the entire `git diff -U0 old..new` output
plus one u32 per added line into memory. When the pull fast-forwards
across a large range that is the whole history delta — gigabytes.

This path is new since v1.5.13: the same unbounded diff previously ran
only inside the background-agent block (Devin/Codex-Cloud), never for
ordinary users. `recover_attribution` (default true, added in git-ai-project#1654)
made it run for everyone.

Fix: resolve the finalized commit's immediate first parent and diff
against that instead of the caller's `parent_sha`. The normal commit and
amend paths already pass the immediate parent, so they are unchanged;
only the fast-forward `update-ref` range is capped to a single commit.
This also removes a latent cross-author misattribution (recovery could
attribute remotely-authored pulled lines to the local user on a
timestamp coincidence).

Repro (tests/integration/recovery_diff_memory_repro.rs): over a ~270MB
fast-forward range the full-range diff grows peak RSS ~293MB while the
immediate-parent diff grows ~1MB (275x). Plus a unit regression test
asserting recovery sees only the finalized commit's files.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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