Repository navigation
Fix legacy worker recovery snapshot timing for rollback safety - #25413
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The recovery persistence change appears sound. Two new tests check the returned dispatch-ID set with a length assertion, which a Set cannot satisfy, so the test suite fails until they check size instead. Fixing those assertions is a quick change before merge. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change preserves existing access controls and host ownership while reducing redundant snapshots. The reviewed recovery and rollback paths show no material security risk introduced or worsened by this PR. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fd031c58-a828-41c3-baa3-29366d524f7b
📥 Commits
Reviewing files that changed from the base of the PR and between f873aaa and abe9cbca22a1eabf045565c0f2302e9db2be1d42.
📒 Files selected for processing (2)
src/main/runtime/runtime-legacy-worker-terminal-recovery-persistence.test.tssrc/main/runtime/runtime-legacy-worker-terminal-recovery-persistence.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — the code change is correct and reduces work; one documentation-accuracy note below.
Reviewed changes
- Per-host snapshot moved out of the candidate loop (
src/main/runtime/runtime-legacy-worker-terminal-recovery-persistence.ts:71) —stagedis now filled once per host after all candidates are processed, instead of deep-cloning the whole session after every worker. This dropsstructuredClonefrom O(candidates) to two per host. - New snapshot-budget and rollback tests (
src/main/runtime/runtime-legacy-worker-terminal-recovery-persistence.test.ts) — pin the clone count per host, exercise rollback while a durable write is in flight, and cover empty / unroutable / no-op-edit batches.
ℹ️ Nitpicks
- The PR title/body describe this as a rollback-safety fix, but the pre-change code was already safe:
staged[host]was overwritten on every candidate for that host, so it always ended as that host's final state, giving rollback an identical input. I ran the new test file against the base (f873aaa) implementation and the rollback test passes there unchanged — only thestructuredClone-count assertions fail. Consider reframing the change as the snapshot-budget optimization it actually is (and adjusting the "intermediate snapshots" language) so the history is accurate.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Rollback requires the final stored state after processing all workers, not intermediate snapshots after each candidate. This bounds the snapshot count and preserves concurrent edits during the durable write.
abe9cbc to
3e521e4
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the two commits on the branch since the prior pullfrog review: the branch was rebased onto a newer main (e02adc5) and a follow-up commit corrected the returned-set assertions in the new snapshot-budget tests. The production change is unchanged from the prior review.
- Rebased onto
main(e02adc5) — the.tssnapshot-timing change and test file carry over byte-for-byte from the previously reviewed revision. - Corrected returned-set assertions in the snapshot-budget tests —
persistreturns aReadonlySet<string>, so the previoustoHaveLength(12)/toHaveLength(10)checks could never pass; they now assert.sizeis12/10, consistent with the other assertions in the file. This addresses the CodeRabbit thread at test line 135. The file passes locally (7 tests).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
* test: add legacy worker recovery persistence snapshot budget tests Rollback requires the final stored state after processing all workers, not intermediate snapshots after each candidate. This bounds the snapshot count and preserves concurrent edits during the durable write. * fix test * clean up code (cherry picked from commit d19e064)

Problem
When persisting legacy worker terminal recovery state, snapshots were captured too early (inside the worker loop after each update). If the durable write failed, rollback could lose edits made during that write because it was using intermediate snapshots instead of the final state.
Solution
Move snapshot capture to after all workers are processed. This ensures rollback always restores the complete final state, preventing data loss when writes fail while edits are in flight.
Added comprehensive tests covering:
Testing
runtime-legacy-worker-terminal-recovery-persistence.test.tsChecklist