Skip to content

perf: force condence ended orphaned ended sessions#599

Draft
peyton-alt wants to merge 1 commit intomainfrom
perf/force-condense-ended-sessions
Draft

perf: force condence ended orphaned ended sessions#599
peyton-alt wants to merge 1 commit intomainfrom
perf/force-condense-ended-sessions

Conversation

@peyton-alt
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 4, 2026 05:23
@cursor
Copy link

cursor bot commented Mar 4, 2026

PR Summary

Cursor Bugbot is generating a summary for commit 091a9a4. Configure here.

Copy link

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

logging.Info(logCtx, "post-commit: force-condensed ended session (no commit overlap)",
slog.String("session_id", state.SessionID),
slog.Int("files_touched", len(state.FilesTouched)),
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force-condensed log emitted even when condensation fails

Low Severity

h.forceCondensed = true and the logging.Info "force-condensed ended session" message execute unconditionally after condenseAndUpdateState, even when condensation fails and h.condensed is false. This produces a misleading info-level log claiming the session was force-condensed, right alongside the warning log from the failed condensation, making debugging harder.

Fix in Cursor Fix in Web

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 addresses a PostCommit performance issue where ENDED sessions with carry-forward FilesTouched but no overlap with later commits could be re-processed indefinitely, causing cumulative per-commit overhead (issue #591). It introduces a “force-condense” path to ensure those sessions get condensed once and then skipped on subsequent commits.

Changes:

  • Add a force-condensation path for ENDED sessions with FilesTouched and new content even when there’s no commit overlap.
  • Update PostCommit phase tests to assert the new force-condense behavior (cleared FilesTouched, reset counters, FullyCondensed set).
  • Add benchmarks to measure PostCommit overhead with accumulated ENDED sessions and verify the “second commit after fix” performance.

Reviewed changes

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

File Description
cmd/entire/cli/strategy/manual_commit_hooks.go Adds forceCondensed flow to condense ENDED sessions without overlap and skip carry-forward.
cmd/entire/cli/strategy/phase_postcommit_test.go Updates test expectations to confirm ENDED sessions are force-condensed and marked FullyCondensed.
cmd/entire/cli/strategy/accumulation_bench_test.go Adds benchmarks and repo/session setup helpers to quantify accumulation overhead and validate the fix.

Comment on lines +652 to +656
h.forceCondensed = true
logging.Info(logCtx, "post-commit: force-condensed ended session (no commit overlap)",
slog.String("session_id", state.SessionID),
slog.Int("files_touched", len(state.FilesTouched)),
)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forceCondensed is set and an Info log is emitted even if condenseAndUpdateState fails (returns false). This can produce misleading logs and can cause the handler state to imply a successful force-condensation when it didn’t happen. Consider only setting forceCondensed / logging when h.condensed is true (and/or log at Warn when condensation fails).

Suggested change
h.forceCondensed = true
logging.Info(logCtx, "post-commit: force-condensed ended session (no commit overlap)",
slog.String("session_id", state.SessionID),
slog.Int("files_touched", len(state.FilesTouched)),
)
if h.condensed {
h.forceCondensed = true
logging.Info(logCtx, "post-commit: force-condensed ended session (no commit overlap)",
slog.String("session_id", state.SessionID),
slog.Int("files_touched", len(state.FilesTouched)),
)
} else {
logging.Warn(logCtx, "post-commit: force-condense failed; session not condensed",
slog.String("session_id", state.SessionID),
slog.Int("files_touched", len(state.FilesTouched)),
)
}

Copilot uses AI. Check for mistakes.
if _, err := wt.Add("second_commit.txt"); err != nil {
b.Fatalf("add: %v", err)
}
cpID, _ := id.Generate()
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id.Generate() returns an error, but it’s being ignored via the blank identifier. The repo’s golangci-lint config enables errcheck with check-blank: true, so this will fail linting. Please handle the error (e.g., b.Fatalf on failure) and only use the generated ID when successful.

Suggested change
cpID, _ := id.Generate()
cpID, err := id.Generate()
if err != nil {
b.Fatalf("generate checkpoint ID: %v", err)
}

Copilot uses AI. Check for mistakes.
}

// Clean up the agent file from worktree (user discarded changes)
os.Remove(agentFileAbs)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.Remove(agentFileAbs) returns an error, but it’s being ignored. With errcheck enabled (including in _test.go), this will fail linting. Please check the error and fail the benchmark setup if the cleanup didn’t succeed (or explicitly ignore with a justified //nolint:errcheck).

Suggested change
os.Remove(agentFileAbs)
if err := os.Remove(agentFileAbs); err != nil && !os.IsNotExist(err) {
b.Fatalf("remove agent file %s: %v", agentFileAbs, err)
}

Copilot uses AI. Check for mistakes.
b.Fatalf("add: %v", err)
}

cpID, _ := id.Generate()
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id.Generate() returns an error, but it’s being ignored via the blank identifier. The repo’s errcheck config flags blank-identifier error ignores even in tests/benchmarks, so this will fail linting. Please handle the error (e.g., b.Fatalf) before building the commit message.

Suggested change
cpID, _ := id.Generate()
cpID, err := id.Generate()
if err != nil {
b.Fatalf("generate checkpoint ID: %v", err)
}

Copilot uses AI. Check for mistakes.
@peyton-alt peyton-alt force-pushed the perf/force-condense-ended-sessions branch from 091a9a4 to 3fc0364 Compare March 4, 2026 05:31
@peyton-alt peyton-alt force-pushed the perf/force-condense-ended-sessions branch from 3fc0364 to 7da585a Compare March 4, 2026 05:40
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