Move the persisted-rewrite baseline into agent.Session / 将 rewrite 持久化基线内聚进 Session#6125
Merged
SivanCola merged 5 commits intoJul 6, 2026
Conversation
added 4 commits
July 7, 2026 01:17
The caller inferred what recovery did from path and session-pointer comparisons; the depth-cap baseline bug hid in exactly that inference. Declare the outcome (adopted / force-saved / forked / dropped) at the site that performs it, and let replaceSessionAfterCancel log when its cancel cleanup was dropped instead of silently discarding the result.
The controller kept savedRewriteVersion as external bookkeeping about the executor's session object, so every SetSession had to be paired with a manual baseline reset and snapshot() had to guess whether recovery had swapped the object — the guess that broke depth-cap force-saves (esengine#6120). Store persistedRewriteVersion on the Session itself: save paths advance it with the rewriteVersion captured in the same lock window as the message snapshot (a compaction landing mid-save stays unpersisted, and a slower save cannot roll it backwards), clones carry it, and swapped sessions take their baseline with them. snapshotRewriteDecision and both mark helpers plus their seven call-site pairings collapse into Session.NeedsRewriteSave. Behavior fix folded in: installing a clone that still holds an unpersisted rewrite no longer stamps it persisted-by-construction; the next snapshot correctly runs as an owned rewrite.
Co-authored-by: SivanCola <[email protected]>
This was referenced Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
savedRewriteVersionas external bookkeeping about the executor's session object: everySetSessionneeded a hand-paired baseline reset (7 call sites), andsnapshot()had to guess whether conflict recovery had swapped the object — the guess behind the Fix session conflict diagnostics and depth-cap baseline / 修复会话冲突诊断与深度上限基线 #6120 depth-cap bug.persistedRewriteVersionon theSessionitself. Save paths advance it with the rewriteVersion captured in the same lock window as the message snapshot, so a compaction landing mid-save stays unpersisted and a slower save can never roll the baseline backwards. Clones carry it; swapped sessions take their baseline with them.snapshotRewriteDecision+ both mark helpers + the 7 pairings collapse intoSession.NeedsRewriteSave(). The depth-cap force save now re-anchors the baseline in the agent layer like any other full save — the Fix session conflict diagnostics and depth-cap baseline / 修复会话冲突诊断与深度上限基线 #6120 misclassification becomes structurally impossible.Stacked on #6124 (which is stacked on #6120); review the top commit only. Part of the #6027 convergence work.
Tests
go test ./internal/agent ./internal/control ./internal/cli ./internal/serve ./internal/acp ./internal/doctorgo test -race ./internal/agent ./internal/control(cd desktop && go test ./...)— includes the Fix session conflict diagnostics and depth-cap baseline / 修复会话冲突诊断与深度上限基线 #6120 effort-switch regressiongolangci-lint run(clean)