Repository navigation
fix(desktop): isolate ad-hoc named-bundle signing - #9546
Conversation
Make the supported named-bundle ad-hoc path explicit, security-scoped, and safe across parallel worktrees, bundle names, and hostile stale symlinks. Verification: - desktop/macos/test.sh (launcher scripts, 328 Rust tests, 238 isolated Swift suites passed) - test-prepare-local-dev-entitlements.sh - bash -n and shellcheck on new helper/test - fresh omi-signing-quality named bundle built, signed, installed, launched, and answered automation state on port 47895 - make preflight - independent agent review approved
fa74fe3 to
17131c0
Compare
Monitor run — rebased onto latest
|
kodjima33
left a comment
There was a problem hiding this comment.
Desktop local-dev signing fix (ad-hoc named bundles + embedded frameworks); scoped, guarded behind opt-in, tests included. Merging (owner-override).
## Summary - replace duplicated Bluetooth booleans, reconnect timers, notification broadcasts, and device-specific teardown with one generation-fenced session coordinator and one shared connection lifecycle - put CoreBluetooth connection identity, callback/timeout/cancellation races, command serialization, and multicast audio behind explicit lease, broker, queue, and stream owners - make Bee and PLAUD recording sessions fail closed across setup, stop, restart, and partial-frame boundaries - add injectable physical-driver, clock, scheduler, transport, and connection seams plus behavioral concurrency regressions ## Root cause and durable guard Bluetooth lifecycle state was spread across `BluetoothManager`, `BleTransport`, `DeviceProvider`, and every device adapter. Raw continuations were keyed only by characteristics or command IDs, reconnect policy inferred intent from persisted UI state, and audio streams coupled one consumer to one physical session without a canonical owner. Recent fixes in the same subsystem repeatedly addressed individual lock, continuation, and teardown symptoms, but no shared boundary prevented the class from recurring. This change assigns one owner to each contract: manager connection leases preserve CoreBluetooth callback identity; tokenized operation brokers arbitrate callbacks, timeouts, cancellation, and teardown while physical starts drain; command queues serialize request/response lifetimes; one session coordinator owns phase, pairing, reconnect intent, and generation fencing; and multicast audio controllers own setup through fail-closed stop. `ARCHITECTURE.md` records those boundaries, and production-path tests force late callbacks, held writes, cancellation-unaware timeouts, concurrent teardown, stale reconnect requests, setup/stop races, and session restart contamination. ## Behavior and risk - supported device adapters retain their existing wire commands and codec behavior while sharing lifecycle ownership - a user-selected device failure no longer silently reconnects a different persisted device - ambiguous uncorrelated command or stop state retires the physical session instead of layering a retry over unknown device state - notification audio is delivered only while its recording generation is active; setup, stopping, and prior-session frames are dropped - no backend API, persisted schema, provisioning, or release pipeline contract changes are involved - no physical Bluetooth device was available locally; real CoreBluetooth ordering is exercised through the production transport and injected physical driver ## Verification - focused Bluetooth/session/provider reliability suite — 55 passed after the final rebase - `desktop/macos/scripts/swift-test-suites.sh` — 249 isolated Swift suites passed - `desktop/macos/test.sh` — launcher contracts, strict e2e coverage, 328 Rust tests, and 249 Swift suites passed - clean debug build from an empty `.build` — passed in 100.64s - clean arm64 release build from a second empty `.build` — passed in 286.39s - desktop test-quality, strict e2e coverage, and `git diff --check` — passed - named `omi-bluetooth-quality` bundle built and installed through `run.sh --yolo`, launched on isolated automation port 47915, reported bundle ID `com.omi.omi-bluetooth-quality`, and navigated from Home to Settings through the in-process bridge (the scoped local ad-hoc Library Validation entitlement from #9546 was applied because that separate tooling PR is not on this branch) - `make preflight` — all 13 selected checks passed after rebase - independent agent review approved after the final broker, reconnect-intent, and audio-session race fixes ## Product invariants None affected (`scripts/pr-preflight --suggest`). <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9550?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
/tmpfileRoot cause and durable guard
OMI_ALLOW_ADHOC_SIGN=1could sign a named bundle, but macOS Library Validation still rejected ad-hoc Sparkle at launch. The fallback plist was also generated at one global path, so parallel worktrees with real and ad-hoc identities could race, and a stale symlink could redirect plist mutation outside the worktree. An explicitOMI_SIGN_IDENTITY=-bypassed the named-bundle opt-in entirely.The new helper centralizes the local signing policy. Ad-hoc identity is accepted only for an explicitly opted-in named bundle; real identities retain Library Validation. Generated plists live below the worktree's
.dev/local-signing/directory, are separated by bundle ID, are assembled in a same-directory temporary file, linted, and atomically moved with destination-symlink protection.Behavior and risk
com.apple.security.cs.disable-library-validationis added only to opted-in ad-hoc named bundlesVerification
desktop/macos/test.sh— launcher scripts, 328 Rust tests, and 238 isolated Swift suites passedbash -nandshellcheckon the new helper and testomi-signing-qualitybundle built throughrun.sh --yolo, signed ad-hoc with Hardened Runtime, installed, launched, and answered the automation bridge on port 47895make preflightProduct invariants
None affected (
scripts/pr-preflight --suggest).