relayburn-sdk: fix three small Rust correctness bugs#351
Conversation
1. watch_loop non-immediate path fired its first periodic tick at 2*interval instead of interval. The loop unconditionally consumed the first interval tick to "skip" an immediate run that the non-immediate branch never produced. Switch to interval_at(now + interval, period) so the first tick lands one interval out in both modes. Add a deterministic regression test using start_paused + tokio::time::advance. 2. now_iso emits ts:NNN.NNN (a sortable lex token), not ISO-8601. Rename to now_lex_token, expand the doc comment to call out the format contract, and update the matching cutoff helper's doc pointer in burn state's prune path. Actual ISO-8601 adoption is tracked in #331. 3. save_cursor_changes lied in its doc — it claimed per-key diffing but the impl is an equality check + full save. Rename to save_cursors_if_changed and rewrite the doc to match. Per-key delta writes deferred to a separate perf PR. Closes #337. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR fixes three correctness bugs from issue ChangesRust Correctness Fixes: Timestamp Format, Cursor Semantics, Watch Loop Timing
Possibly related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Three small correctness fixes flagged in #337.
Fix
watch_loop.rsfirst-tick lag. The non-immediate branch was unconditionally consuming the first interval tick to "skip" an immediate run that branch never produced, so the first periodic tick fired at2 * interval. Switch tointerval_at(now + interval, period)so the first tick lands at~intervalin both modes. Adds a deterministic regression test usingstart_paused+tokio::time::advance.Rename
now_iso→now_lex_token. The function emitsts:NNN.NNN(a sortable lex token), not ISO-8601; the column doc was misleading. Rename + expand doc to call out the format contract; update the matching cutoff helper's pointer inburn stateprune. Pure naming/doc fix; no behavior change. Actual ISO-8601 adoption tracked in Rust refactor: collapse 3 hand-rolled civil-date implementations onto the time crate #331.Rename
save_cursor_changes→save_cursors_if_changed+ fix doc. The doc claimed per-key diffing; the impl is an equality check + full save. Rename and rewrite the doc to match. Per-key delta writes deferred to a separate perf PR.Closes #337.
Test plan
cargo build --workspace --all-targetscleancargo test --workspacepasses (incl. newwatch_loopdeterministic-timing test)cargo clippy --workspace --all-targetsno new warnings🤖 Generated with Claude Code