Skip to content

perf: warn when stale ENDED sessions accumulate#746

Open
peyton-alt wants to merge 5 commits intomainfrom
perf/warn-stale-ended-sessions
Open

perf: warn when stale ENDED sessions accumulate#746
peyton-alt wants to merge 5 commits intomainfrom
perf/warn-stale-ended-sessions

Conversation

@peyton-alt
Copy link
Contributor

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

Summary

When ENDED sessions still have uncondensed checkpoint data, PostCommit has
to keep processing them on every commit. This PR adds a user-facing warning
when those stale sessions accumulate, and points users to entire doctor,
which can condense them and restore normal commit performance.

What changed

  • detect stale ENDED sessions that are still both:
    • expensive for PostCommit
    • actionable via entire doctor
  • emit a rate-limited stderr warning when 3 or more such sessions remain
  • store a sentinel file under .git/entire-sessions/ so the warning only
    appears at most once per 24 hours
  • point the warning to entire doctor instead of entire clean --force
  • suppress false-positive warnings for sessions that the current PostCommit
    already condensed and cleaned up
    Stale ENDED sessions with shadow-branch state create avoidable PostCommit
    work on every user commit. The CLI should surface that degradation before it
    piles up, but only when the sessions are still actually fixable and still
    present after the current commit finishes processing.

Testing

  • go test ./cmd/entire/cli/strategy

Notes

  • user-facing behavior change is limited to a stderr warning after commit
  • warning only appears when at least 3 stale ENDED sessions remain
  • no checkpoint format changes

Copilot AI review requested due to automatic review settings March 21, 2026 00:40
Copy link
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

This PR adds detection of “stale” ENDED sessions (ENDED but not FullyCondensed) and emits a rate-limited warning to help users clean them up and avoid repeated PostCommit processing overhead.

Changes:

  • Added countStaleEndedSessions helper to identify non-fully-condensed ENDED sessions.
  • Added rate-limited warning logic (24h sentinel in .git/entire-sessions/) advising entire clean --force once stale sessions exceed a threshold.
  • Added unit tests for stale-session counting and the warning rate-limit behavior.

Reviewed changes

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

File Description
cmd/entire/cli/strategy/manual_commit_session.go Adds helper to count stale ENDED sessions.
cmd/entire/cli/strategy/manual_commit_hooks.go Implements warning + sentinel gating and triggers it during PostCommit.
cmd/entire/cli/strategy/phase_postcommit_test.go Adds tests for counting stale sessions and rate-limited warning behavior.

peyton-alt and others added 5 commits March 23, 2026 18:54
Add detection and rate-limited warning for non-FullyCondensed ENDED
sessions that incur PostCommit processing cost on every commit.

When >= 3 stale sessions are found, emit a stderr warning pointing
users to 'entire clean --force'. Warning is rate-limited to once per
24h via a sentinel file in .git/entire-sessions/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 7841b7892888
entire doctor handles ENDED sessions with uncondensed checkpoint data
(condenses them to entire/checkpoints/v1). entire clean only removes
orphaned sessions with no shadow branch, which wouldn't help here.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: cf6c460dff65
- Replace os.Stderr mutation with injectable stderrWriter package var
- Add comment explaining intentional shadow branch re-check in
  isWarnableStaleEndedSession (PostCommit deletes branches mid-execution)
- Replace map with slice in test for deterministic iteration order
- Extract testTranscript constant to fix goconst lint
- Add t.Chdir warning comments to non-parallel tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: d924cd6bb74b
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@peyton-alt peyton-alt force-pushed the perf/warn-stale-ended-sessions branch from f9f7f80 to e52ce3f Compare March 24, 2026 01:54
@peyton-alt peyton-alt marked this pull request as ready for review March 24, 2026 01:57
@peyton-alt peyton-alt requested a review from a team as a code owner March 24, 2026 01:57
@peyton-alt peyton-alt enabled auto-merge (rebase) March 24, 2026 01:57
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