Repository navigation
fix: batch status recovery snapshots at bounded intervals - #26735
1aifanatic wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe persistence interval changes from a 250 ms trailing-edge debounce to a fixed five-second interval that is not reset during continued activity. Tests check that the latest status is saved at the interval boundary, that later updates are saved on a subsequent interval, and that shutdown saves pending status and clears scheduled timers. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Status snapshots are batched into five-second windows while shutdown still flushes pending state. Abrupt termination may lose one pending window, as described for this change; no actionable merge-blocking risk is established by the supplied evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing as not planned. This reduces writes by extending the recovery deadline from 250 ms to five seconds, so an isolated completion/prompt/authority update can remain undurable twenty times longer. Normal shutdown flushing does not preserve crash recovery. We require behavior-preserving performance improvements, so this intended durability trade-off fails the bar. The underlying write-amplification observation remains valid. |
ELI5
Frequent status updates no longer rewrite the entire restart-recovery file after every short pause. Orca saves the latest snapshot at most once per five-second window during normal activity, and still saves immediately when shutting down.
What Changed
Keep the first scheduled write deadline instead of resetting a 250 ms timer on each event. The five-second window batches updates without letting continuous activity postpone the snapshot indefinitely. Serialization, atomic replacement and identical-snapshot suppression stay in the existing persistence path.
Why
Restart recovery does not need a disk write for each status event. A bounded timer fixes the write amplification without introducing a journal, changing the file format, or adding asynchronous-write/shutdown races. Live status notifications are still immediate.
Linked Issue
Fixes #26720
Visual Proof
N/A — background recovery-file scheduling only; no visual or interaction change.
Testing
Windows, Node 24.21.0, ORCA_BACKGROUND_LAUNCH=1: 82 tests pass across nine persistence, hydration and hook-control suites. The new regression fails before the change. It sends real HTTP hook events every 500 ms, verifies no intermediate snapshot replacement, checks that the latest state is persisted at five seconds, and checks a subsequent window. Shutdown coverage verifies the pending state is written and the timer is cancelled.
Command:
node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts --maxWorkers=2 src/main/agent-hooks/server-last-status src/main/agent-hooks/server-status-persist-scheduling.test.ts src/main/agent-hooks/managed-agent-hook-controls.test.ts.Formatting and
pnpm run check:code-quality:changedpass. Full lint/typecheck/test/build are not verified locally: the native Windows build toolchain is missing and full typechecking exceeded available resources during earlier validation. CI and native macOS/Linux coverage remain outstanding.AI Disclosure
GPT-6 was used to investigate, implement, test and review this change.
Review
The timer remains owned by each execution-host server instance and uses platform-neutral timers. Local and remote status producers still write through the same store; clients and wire formats are unchanged. No integration-specific logic, UI changes, Git-worktree assumptions, dependencies, or additional periodic wakeups. Identical snapshots still skip disk I/O, and atomic writes and existing file permissions remain intact. Unexpected termination can lose up to one pending five-second window; normal shutdown flushes immediately.
Agent skill upstream boundary
Notes
The five-second interval bounds the scheduled delay while the event loop is responsive. Synchronous snapshot writes remain; this change reduces their frequency.
Author
X: @1aifanatic
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)