LearnNewsExamplesServices
Frontmatter
id10577
titleBridge Daemon: Serialize osascript execution to prevent concurrent injection collisions
stateClosed
labels
bugaiarchitecturecore
assignees[]
createdAtMay 1, 2026, 3:07 PM
updatedAtMay 1, 2026, 3:16 PM
githubUrlhttps://github.com/neomjs/neo/issues/10577
authorneo-gemini-3-1-pro
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 1, 2026, 3:16 PM

Bridge Daemon: Serialize osascript execution to prevent concurrent injection collisions

Closedbugaiarchitecturecore
neo-gemini-3-1-pro
neo-gemini-3-1-pro commented on May 1, 2026, 3:07 PM

Context The bridge daemon uses osascript to inject A2A messages into IDEs. When multiple agents have wake events simultaneously, the daemon dispatches all osascript calls concurrently.

The Problem Concurrent osascript calls racing to steal focus and type keystrokes cause a desktop environment collision (the "Electron-Paradox"). Payloads interleave or get injected into the wrong IDE window depending on millisecond-level focus stealing. This leads to cross-tenant data leakage (e.g., Claude receiving Gemini's payload).

The Architectural Reality The ai/scripts/bridge-daemon.mjs script's deliverDigest loops through all matched subscriptions and executes osascript child processes asynchronously without any mutual exclusion.

The Fix Add an asynchronous Promise mutex (deliveryPromise) inside bridge-daemon.mjs to force the deliveries into sequential execution.

Acceptance Criteria

  • deliverDigest uses a global Promise.resolve() chain to serialize AppleScript injection.
  • Concurrent broadcast events no longer cause payload corruption or interleaved typing.

Out of Scope Fixing the intrinsic human "focus switching" problem during sequential execution (e.g., if a human user actively clicks into a different window while osascript is typing).

Origin Session ID Origin Session ID: 7f5dd104-283b-4c52-96d3-8ca4a9e7353e Retrieval Hint: "bridge-daemon serialization mutex"

tobiu closed this issue on May 1, 2026, 3:16 PM
tobiu referenced in commit 35d7b5f - "fix(bridge): enforce sequential osascript delivery (#10577) (#10578) on May 1, 2026, 3:16 PM