Skip fully-condensed ENDED sessions in PostCommit#556
Conversation
PostCommit iterates all sessions for the worktree, including ENDED sessions that have already been condensed with no remaining carry-forward files. Each session costs ~60ms just to exist in the pipeline (shadow resolve + hasNewContent + state machine + attribution), so 200 settled sessions add ~12s of pure overhead on every commit. Add a `FullyCondensed` flag to session state that gets set when an ENDED session is successfully condensed with no files remaining for carry-forward. PostCommit skips these sessions entirely, reducing steady-state commit overhead from seconds to milliseconds. The sessions still persist for LastCheckpointID reuse (amend trailer restoration). Benchmark results (2nd commit after sessions are condensed): - 100 sessions: 6.4s → 1.6s (3.9x) - 200 sessions: 14.5s → 3.3s (4.5x) - 500 sessions: 46.8s → 8.7s (5.4x) PostCommit specifically: 200 sessions dropped from 12.9s → 1.6s (8x). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 28481f123e69
PR SummaryMedium Risk Overview
Written by Cursor Bugbot for commit f9c6270. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR reduces PostCommit hook overhead by skipping per-session processing for sessions that have already been condensed and have no remaining carry-forward work, while still retaining session state on disk for LastCheckpointID reuse (e.g., amend trailer restoration).
Changes:
- Add
FullyCondensedto persisted session state to mark ENDED sessions with no remaining carry-forward files. - Skip
FullyCondensedsessions during thePostCommitper-session processing loop. - Set
FullyCondensed = trueafter successful condensation when an ENDED session has no remaining files to carry forward.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/entire/cli/strategy/manual_commit_hooks.go | Skips fully-condensed sessions in PostCommit and sets the flag after condensation when appropriate. |
| cmd/entire/cli/session/state.go | Persists the new FullyCondensed flag in session state JSON (backward compatible via omitempty). |
Comments suppressed due to low confidence (3)
cmd/entire/cli/strategy/manual_commit_hooks.go:786
- The skip condition is documented as “fully-condensed ended sessions”, but it currently skips any session with
FullyCondensed == trueregardless of phase. To keep the invariant enforced in code (and avoid accidentally skipping an ACTIVE/IDLE session if state is corrupted or future logic sets the flag earlier), gate thiscontinuewithstate.Phase == session.PhaseEnded(or!state.Phase.IsActive()plusPhaseEndedas appropriate).
// Skip fully-condensed ended sessions — no work remains.
// These sessions only persist for LastCheckpointID (amend trailer reuse).
if state.FullyCondensed {
continue
cmd/entire/cli/strategy/manual_commit_hooks.go:787
- Skipping fully-condensed sessions here also means their shadow branch will never be retried for deletion if cleanup failed in a prior PostCommit run (the only deletion pass is driven by
shadowBranchesToDelete, which is populated during per-session processing). Consider a low-cost best-effort cleanup path for fully-condensed sessions (e.g., check if the shadow ref exists and, if so, schedule it for deletion) so orphanedentire/*branches don’t accumulate after transient failures.
// Skip fully-condensed ended sessions — no work remains.
// These sessions only persist for LastCheckpointID (amend trailer reuse).
if state.FullyCondensed {
continue
}
cmd/entire/cli/strategy/manual_commit_hooks.go:960
- This change introduces new state (
FullyCondensed) that alters PostCommit behavior across invocations, but there doesn’t appear to be coverage asserting (1) the flag is set only when an ENDED session is condensed with no carry-forward files, and (2) subsequent PostCommit runs skip that session. Adding a strategy/phase test around these cases would help prevent regressions (including backward-compat JSON load defaulting the field tofalse).
// Mark ENDED sessions as fully condensed when no carry-forward remains.
// PostCommit will skip these sessions entirely on future commits.
// They persist only for LastCheckpointID (amend trailer restoration).
if handler.condensed && state.Phase == session.PhaseEnded && len(state.FilesTouched) == 0 {
state.FullyCondensed = true
}
ENDED sessions can be reactivated via TurnStart (→ ACTIVE) or SessionStart (→ IDLE). Clear FullyCondensed in ActionClearEndedAt so reactivated sessions are not skipped by PostCommit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: ee02ccfb2489
|
bugbot run |
Summary
FullyCondensedflag to session state, set when an ENDED session is condensed with no remaining carry-forward files. PostCommit skips these sessions entirely on subsequent commits..git/entire-sessions/forLastCheckpointIDreuse (amend trailer restoration) — only the expensive per-session processing is skipped.Changes
session/state.go— AddedFullyCondensed boolfield (backward compatible:omitempty, defaults tofalse)strategy/manual_commit_hooks.go— SkipFullyCondensedsessions in PostCommit loop; set the flag after condensation when ENDED + no carry-forwardBenchmark results (2nd commit after sessions are condensed)
PostCommit specifically: 200 sessions dropped from 12.9s → 1.6s (8x).
Test plan
mise run fmt && mise run lint— cleanmise run test:ci— all unit + integration tests passfully_condensedfield deserialize asfalse(no behavior change)🤖 Generated with Claude Code