agent: code-atomiser-fix — hotkey supervisor rearchitecture (Race-1, Race-2, TOCTOU)

Fixes three interlocking concurrency leaks in the evdev hotkey listener
flagged by the atomiser full-sweep. Every spawned task is now owned by a
SupervisorHandle that broadcasts cooperative shutdown and joins every
JoinHandle with a 2s per-task timeout on stop(). Per-device attachment is
now insert-before-spawn under one mutex hold, closing the TOCTOU window.
The Tauri command layer now stores the forwarder JoinHandle alongside
the listener so reconfigures join it cleanly instead of leaking one
permanent forwarder per hotkey change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-13 15:21:50 +01:00
parent 9f67ab2d86
commit 1068ad9c7d
7 changed files with 781 additions and 132 deletions

View File

@@ -14,3 +14,9 @@ tracing = "0.1"
evdev = { version = "0.12", features = ["tokio"] }
notify = { version = "7", default-features = false, features = ["macos_fsevent"] }
nix = { version = "0.29", features = ["fs"] }
[dev-dependencies]
# `rt-multi-thread` enables `#[tokio::test(flavor = "multi_thread")]` used by
# the supervisor + listener lifecycle regression tests. Without it the
# concurrency leak coverage cannot exercise real parallelism.
tokio = { version = "1", features = ["rt", "rt-multi-thread", "sync", "macros", "time"] }