Skip to content

refactor: address rust-code-reviewer findings (pass 2) - #20

Merged
pranc1ngpegasus merged 3 commits into
mainfrom
chore/rust-code-review-pass
May 28, 2026
Merged

refactor: address rust-code-reviewer findings (pass 2)#20
pranc1ngpegasus merged 3 commits into
mainfrom
chore/rust-code-review-pass

Conversation

@pranc1ngpegasus

Copy link
Copy Markdown
Member

Summary

  • ランしたのは rust-code-reviewer を 3 周。最終パスは "No actionable findings." で締め。
  • 主要な修正:
    • wisp-audiokit (soundness): std::sync::mpsc::Sender!Sync のため、Swift 側が on_result / on_log を別スレッドから同時に呼ぶと &Sender がレースして UB。crossbeam-channel に差し替えて Sync を獲得。ついでに Session::recv_timeout を露出。
    • wisp-storage migrations: 手書きの BEGIN/COMMITConnection::unchecked_transaction に置き換え、パニック時のトランザクションリーク経路を消した。u32 オーバーフロー時の continueconst _: () = assert!(…) + unreachable! に変えてサイレントスキップを防止。
    • wisp-audiokit-sys: 非macOS スタブを削除。ラッパー側が完全に cfg(target_os = "macos") ゲートしているのでスタブは死コード兼 unsafe 強要源だった。
    • session_runner: try_recv + sleep(20ms)Session::recv_timeout(20ms) に変更。イベントは即時、Stop の最悪待ち時間は据え置き 20ms。
    • 上のクロスビーム移行に伴う SessionSAFETY コメントが事実誤認になっていた箇所を訂正。

Test plan

  • cargo check --all-targets --workspace
  • cargo clippy --all-targets --workspace -- -D warnings
  • cargo test --workspace (全 30 件パス)
  • macOS の実機で wisp-desktop を起動し録音→停止のフローを目視確認

🤖 Generated with Claude Code

pranc1ngpegasus and others added 3 commits May 28, 2026 23:06
- 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
pranc1ngpegasus force-pushed the chore/rust-code-review-pass branch from c74c7a1 to 08bb48d Compare May 28, 2026 14:07
@pranc1ngpegasus
pranc1ngpegasus merged commit 22fb388 into main May 28, 2026
2 checks passed
@pranc1ngpegasus
pranc1ngpegasus deleted the chore/rust-code-review-pass branch May 28, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant