# Native event repair The event path keeps apps independent. Preparation is an optimization, never a reason to drop a Space command. Only verified native Space mapping and system conflicts can keep a display suspended indefinitely. | Finding | Resolution | |---|---| | H1 | Merged local main's app-quit fix before starting. | | H2 | Prepare before mouse-down, skip busy/unresponsive apps, and stop waiting after 100 ms. Report write/readback/deadline failures per window and reconcile after the command. | | H3 | Retain created facts and queue their owner while a Space command is active, including failed commands. | | M1 | Merge cached per-window callback changes into an in-flight enumeration. Motion does not invalidate visibility reads. A changed Space has a separate stale outcome, not a false success. | | M2 | Read the single window-server visibility fact before speculation; off-screen windows wait for owner reconciliation. | | M3 | Reserve a consumed workspace target until its window is admitted or destroyed, including across suspension and republishing. | | M4 | Probe only unresponsive apps on their owning thread, with backoff. Recovery drains queued work and cancels probes. New permission and other failures are surfaced. | | M5 | Remove unavailable/unresponsive apps from transition waits; release app-caused display suspension after 300 ms. Unverified native mapping stays gated. | | M6 | Queue dirty motion markers and read geometry at delivery/acknowledgement. Measure burst and paced consumption with the same eager/deferred fake and explicit frame-read counters. | | M7 | Background callback focus is recorded but cannot publish focus or cancel the frontmost app's activation read. | | M8 | Track configuration begins per display, cap a missing completion at 500 ms, and debounce wake/screen activity by 200 ms. | | M9 | Batch scalar facts only. Child/tab arrays retain the count guard; incomplete scans remain unknown rather than proving absence. Real AX errors propagate. | | L1 | Reuse placement targets when only frame observations change; update classification independently. | | L2 | Flush motion before that window's lifecycle event, preserve user origin, and track outstanding acknowledgements across the barrier. | | L3 | Include the dragged window when computing destination tiles, without writing the dragged window during preparation. | | L4 | Owners explicitly stop display observation. Opaque callback tokens are fenced through synchronized context lookup; removal errors surface without a dangling pointer. | | L5 | Startup enumeration never speculates. Only actual creation callbacks may consume a placement target. | | L6 | The benchmark uses callback placement and the frame writer before engine admission. A compiled opt-in fixture test checks one placement: at most one resize and its separate position write. It was not run live. | | L7 | Assert final focus/frame delivery rather than mailbox slots or exact focus-call ordering. The native benchmark uses one fake and rejects incompatible workload/host/policy reports. | ## Public API - `AppThreadCreatedWindow.isOnScreen` is required at initialization. - `WindowFactsReader.gatherCreatedWindow` requires the visibility fact. - `WindowServer.isOnScreen(windowID:)` checks one window and throws on failed reads. - `Displays.stop()` explicitly ends observation and can throw a removal error. A stopped instance is terminal; the engine creates a fresh one on restart. ## Boundaries The 100 ms preparation deadline bounds the command's wait, not an operating-system AX call already executing. Cancellation skips remaining batch requests; the active request can finish its AX operations and cleanup on its app thread. It cannot block the mouse pickup, another app, or the display suspension deadline. No live e2e, Screen Recording, host quietness certification, or performance baseline publication was performed. Synthetic backend counts are not native IPC latencies or measured actor hops. See [the measured results](RESULTS.md) for the workload versions, instruction counts, and gate outcomes. ## Validation - Production and test builds passed without warnings. - `mise run test` passed three times: 3,328 tests in 304 suites each. - Full `swift test` passed: 3,590 tests in 339 suites, with live scenarios skipped. - Full lint, naming, strict formatting, and all 29 shell regression suites passed. The first shell run reached its ten-minute limit; the remaining suites were resumed successfully with a longer bound. - All eight native version-3 instruction gates passed. Five interleaved common-core A/B rounds passed all 43 gated cases; one additional case was reporting-only. - The initial native version-2 repeat failed six gates on the same executable. Completion-driven waits replaced its variable polling workload; the gate was not relaxed, and both failed and passing reports are retained in `RESULTS.md`. The full test gate also found four inherited waits missing from `idle-waits.json`. Their activity ownership and bounds were inspected and documented without edits to the app/fixture modules. The only UI change is explicit display-observer cleanup in Settings; no package dependency or build-setting change was needed.