refactor: address rust-code-reviewer findings (pass 2) - #20
Merged
Conversation
- wisp-audiokit: swap std::sync::mpsc for crossbeam-channel so the
Sender shared via raw user_data is Sync. The Swift side may invoke
on_result / on_log thunks from different threads concurrently; with
std mpsc that formed overlapping &Sender references (UB). Also expose
Session::recv_timeout.
- wisp-storage migrations: use Connection::unchecked_transaction so a
panic mid-step doesn't leak an open transaction, and turn the u32
overflow case into a statically-asserted unreachable so we can't
silently skip a migration step.
- wisp-audiokit-sys: drop the non-macOS stub module entirely; the
wrapper crate already cfg-gates every call site to macOS, so the
stubs were dead code that forced callers to write unnecessary
unsafe {}.
- session_runner: replace try_recv + sleep(20ms) with
Session::recv_timeout(20ms) so events are forwarded immediately
instead of waiting up to a tick.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`crossbeam_channel::Receiver<T>` is `Sync` (unlike `mpsc::Receiver`), so the old "Receiver is `Send` but `!Sync`" justification no longer matched the truth — `Session` is `!Sync` because of its `NonNull<…>` field, not its receiver. Rewrite the SAFETY comment accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pranc1ngpegasus
force-pushed
the
chore/rust-code-review-pass
branch
from
May 28, 2026 14:07
c74c7a1 to
08bb48d
Compare
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
rust-code-reviewerを 3 周。最終パスは "No actionable findings." で締め。std::sync::mpsc::Senderは!Syncのため、Swift 側がon_result/on_logを別スレッドから同時に呼ぶと&Senderがレースして UB。crossbeam-channelに差し替えてSyncを獲得。ついでにSession::recv_timeoutを露出。BEGIN/COMMITをConnection::unchecked_transactionに置き換え、パニック時のトランザクションリーク経路を消した。u32オーバーフロー時のcontinueもconst _: () = assert!(…)+unreachable!に変えてサイレントスキップを防止。cfg(target_os = "macos")ゲートしているのでスタブは死コード兼unsafe強要源だった。try_recv + sleep(20ms)をSession::recv_timeout(20ms)に変更。イベントは即時、Stop の最悪待ち時間は据え置き 20ms。SessionのSAFETYコメントが事実誤認になっていた箇所を訂正。Test plan
cargo check --all-targets --workspacecargo clippy --all-targets --workspace -- -D warningscargo test --workspace(全 30 件パス)wisp-desktopを起動し録音→停止のフローを目視確認🤖 Generated with Claude Code