# Per-app write measurements Host: Mac15,10, 14 cores, macOS 15.7.7 (24G720), Apple Swift 6.2.4, arm64, release optimization. Original measurements below use `7025815`, after merging main `9a32e2f`. The continuation results are recorded separately. The host is shared. Instructions are the primary evidence; wall times are diagnostics, not a quiet-host guarantee. ```sh SWIFT_DETERMINISTIC_HASHING=1 PARCEL_WRITE_BENCH=1 mise exec -- swift test -c release --no-parallel \ --filter 'WriteMotionBenchmarks|AXWriteBenchmarks|WriteSchedulingBenchmarks|FocusMotionBenchmarks' ``` The shared instruction harness was not on main when this package was built. `WriteBenchmarkMeasurement` is test-only: it reads `thread_selfcounts`, rejects failed, zero, or non-increasing counters and zero work checksums, and reports the minimum of 15 samples. Async cases report **main-thread** instructions. `MotionBatchMainActorOverhead` uses an empty executor job; `SettleReconcileCost` uses a fake native backend. No counter code ships in Parcel. The shared harness is now merged. New display-lead and reconciliation-filter comparisons use its validated counters and 15-batch median instruction counts; those are separate from the original minimum-count measurements below. ## Measured changes Original baselines were captured before editing the relevant production paths. Retained-path comparisons run the former operation against the same fake in the current binary; they are labeled separately because compiler inlining can change instruction counts. Numbers are per workload, not per individual AX call. | Workload | Before instructions | After instructions | Behavioral result | | --- | ---: | ---: | --- | | CoalescerProMotionJitter, 600 synthetic ticks | 5,430,943 original | 6,465,485 | 301 → 600 dispatches | | AXWriteFastPathCalls | 1,968 original | 1,286 | 11 → 1 AX calls, excluding lookup | | EnhancedUIToggleCount, guard/frame component, 24 frames | 28,470 original | 3,597 | 48 → 2 EnhancedUI toggles | | AppWriteBatch/20 | 544,564 original | 116,830 | 450 → 101 AX calls; 20 → 1 executor jobs | | EchoReadsDuringGlide, 500 events over 50 windows | 11,023,600 retained path | 121,707 | 0 AX reads while moving | | EchoReadsDuringGlide/final, 500 queued echoes | 699,678 retained matching | 683,176 | 1,000 → 0 AX attribute reads | | AnimationTick200, schedule + 24 tick/coalesce/complete rounds | 39,479,396 original | 31,182,157 | stable ordering and app-grouped pending work | | AnimationSchedule200, schedule + retarget | 2,740,660 original | 2,480,286 | no per-window sorted membership lookup | | PerWindowRateContinuity | 137 original | 70 | 8.4 ms: 30 → 119.05 fps | | NeighbourPhaseDivergence, adjacent shrink/grow replay | 150,269 original | 36,662 | peak intersection 10,000 → 0 pt² | | NeighbourPhaseDivergence, modeled arrival error | 100,783 retained sampling | 99,987 | 193 → 0 pt at arrival with known latency | | MotionBatchMainActorOverhead, 50-window layout | 1,037,700 retained 20-job path | 453,523 | p50 0.322 → 0.026 ms; p99 0.788 → 0.027 ms | | SettleReconcileCost, 5 apps × 6 windows | 707,743 existing full refresh | 193,498 | 30 → 0 fact snapshots; 1 window-list read | | FocusBorderObservedBurst / FocusBorderSharedPlanBurst | 135,070 retained static placement | 400,003 | one shared-curve install, not observed-frame chasing | The jitter fix does nearly twice as much useful work. Total instructions rise, but instructions per delivered frame fall from 18,043 to 10,776. The current binary's retained fast-path baseline is 1,317 instructions; the older 1,968 figure is the original capture. Neither fake models real IPC latency. The reduced AX call count is the important result. The EnhancedUI comparison isolates the frame/guard component. The new whole-burst coordinator costs 133,687 instructions for 24 frames, including ownership checks and receipts. Do not compare that number directly with the old frame-only helper or hide its bookkeeping cost. The focus border change is a correctness trade-off, not a CPU reduction. Main's reused static layers made the old placement path cheaper; the shared curve costs more once per transition, then runs on the render server. ## Findings and contracts - **H1 / L2:** interval-relative rounding tolerance; actual display-link rate, including 60/120/144/165 Hz tests; maximum screen rate requested while moving. No AX display link runs for an instant/outline-only transition. - **H2 / H3 / M1 / OS write #4:** cached window IDs and assistive-technology state; one owner-thread batch; one position setter on intermediate frames; verified final geometry; one per-app EnhancedUI guard. Cancellation, destruction, errors, AT activation, and shutdown restore the guard. Shutdown interrupts later windows in an already-running batch. - **H4:** no intermediate echo reads. Recent post-final candidates avoid AX reads and expire after 500 ms. Processing a notification while the pointer is down clears its candidates. Post-final candidates request coalesced window-list reconciliation so an application-origin frame change is not lost. - **H5:** metrics schema 2 measures per-window cost, not batch/main-actor delay. Rates vary continuously. When capacity is insufficient, focused and farther- moving windows keep motion; the remaining windows snap individually. - **M2:** sample at the later of the display deadline and dispatch clock plus measured median batch latency, without adding display lead twice. A falling estimate cannot rewind an already-dispatched sample. Predicted final writes retain the curve until receipt so retargeting can inherit its position and velocity. - **M4:** publish the exact focused plan and verified readbacks as snapshot metadata, without mutating unrecorded reducer state. Border, content mask, and outline share the clock and final growth step. Native-read failure gating and main's reusable layers remain intact. - **L1:** ordered active IDs, constant-time membership, pending frames grouped by app, retained buffer capacity, ring-buffer durations, and constant components bypassing curve math. Already-verified target geometry does not start another plan when no active/queued motion or live/final resize needs completion. - **L3:** shrink each axis before movement; grow it only at the final frame. Final size-position-size correction remains available for edge clamping. - **OS settle M2:** utility-priority, cancellable frame reconciliation uses one window-list snapshot and no AX facts. `FrameChangeOrigin.reconciled` bypasses transaction-only echo suppression for verified differing geometry; identical readback geometry still does no work. General activity reconciliation remains available separately. ## API handoff - `AppThread.writeFrames`, `performWindow`, generation-aware `cancelFrameWrites`, and `shutdownRestoringFrameWrites`. An ongoing receipt's `actual` is absent; only actual readbacks are observations. - `EngineFrameWrite.isFinal`; `EngineWriteReceipt.writtenWindowCount` and owner job duration; world cancellation, frame reconciliation, and awaited cleanup. - `EngineDisplayLink.frameRate`; per-app display rates in `FrameCoalescer`; `Animator.contains` / `plan(for:)`; batch resampling and animation eligibility. - `EngineSnapshot.focusedMotionPlan` and `readbackFrames`. Consumers must not replace an active plan with a stale observation. Confirmed frame callbacks still serve ordinary highlights, not only privacy overlays. Trace names: `motion.tick`, `motion.dispatch`, `motion.batch`, `ax.write` (`calls`, `perWindowMs`, `final`), `ax.read.frame`, `ax.enhancedUI.toggle`, and `world.reconcile.axCalls`, gated by `PARCEL_TRACE=1`. ## Earlier validation and limits - SwiftPM debug/release builds, parallel/serial test runs (2,884 tests), full lint, naming/formatting checks, and all 19 shell suites passed in the pinned tool environment. A broken shared hook-tool cache was left untouched; validation used a worktree-local copy of the same MIT-licensed version, 2.2.2. - Native bundle compilation needed one compatibility fix: remove the redundant `ConciseMagicFile` flag, already enabled by Swift 6. The package-settings shell regression now checks this. No Package.swift change was needed for this task. - Accessibility preflight passed: `build/Parcel.app` has its grant. The two new live scenarios did **not** run: required preflight refused the locked/inactive desktop. It asks for an unlocked, active console session before `make e2e`. FixtureApp scenarios cover eight-window batches, retargeting, second settles, final readbacks, motion disable, and focus decoration cleanup. - Known-latency arrival error is not continuous on-screen separation. A window held for 20 ms cannot guarantee a ≤4 pt gap against a 2 ms neighbour at arbitrary velocity. General crossing/swapping paths also cannot guarantee zero intersection merely from resize ordering. Those absolute promises are not claimed by the replay results. - The 200-window tick benchmark reports a whole 24-tick workload. It does not establish the report's <0.1 ms single-tick p99 budget on a quiet host. Live AX latency, hardware dispatch traces, and per-frame border offset remain unverified. - The veil/outline transition design is unchanged, as requested. No Screen Recording, foreign-window capture, or SIP-dependent call was used. ## 2026-10-31 continuation The unfinished bundle-settings check and both motion changes were retained with regressions. Confirmed targets skip redundant plans without consuming the first changed live-resize sample. Display deadlines no longer add clock lead twice. Post-final candidates request frame-only reconciliation. Fresh AX frame reads also carry `FrameChangeOrigin.reconciled`, so a longer slow-app echo window cannot hide a genuine change after the candidate expires. Cached metadata refreshes keep their existing unknown-origin contract. Matching geometry still produces no work. Follow-up for the event path: a cached metadata refresh can advance native `knownFrames` even when the engine drops its unknown-origin frame as an echo; that observation needs acknowledgement or fresh provenance. The shared benchmark fixtures now implement batched writes and display rates. Native test writes update both AX and window-server readback sources; completely failed jobs preserve errors and leave their written count unknown, never zero. The write harness reuses main's instruction-counter declaration rather than introducing a conflicting C signature. No hand-written Package.swift change was needed beyond merging main. The scoped write-path changes are implemented; cached metadata acknowledgement remains a follow-up. The proof limits for M2, M4, L1, and L3 above remain: modeled arrivals are not continuous on-screen separation, and whole-workload timings do not establish a single-tick p99 budget. Live AX, display-cadence, and border-offset checks were not run; another engineer owns the screen. The added application-origin drift scenario is opt-in and skips with the other live scenarios. The veil design remains a follow-up. The pinned setup passed. On merged main `dc273c6`, both full Swift test modes passed **3,197 tests in 304 suites**, and all **28 shell suites** passed. Live e2e was disabled for every run. The fresh-provenance regression suite passed 45 tests. Debug and release builds, full lint (including names and strict formatting), and all 21 selected release benchmark tests passed at `54d722e`. ### Refreshed instruction evidence These retained-path comparisons use the same final binary. Minimum counts retain the old sampling method; the shared cases use 15-batch medians. The canonical counter's validation adds endpoint overhead to minimum-count samples, especially tiny workloads, so do not compare those raw counts with the original helper's small-operation numbers above. Async counts cover the main thread, not real AX. | Workload | Before instructions | After instructions | Proof | | --- | ---: | ---: | --- | | AXWriteFastPathCalls, minimum | 5,244 | 5,107 | 11 → 1 AX calls | | EnhancedUIToggleCount, guard component, minimum | 28,108 | 7,419 | 48 → 2 toggles | | AppWriteBatch/20, minimum | 552,610 | 111,735 | 450 → 101 calls; 20 → 1 jobs | | EchoReadsDuringGlide, minimum | 11,052,937 | 137,873 | 0 intermediate AX reads | | EchoReadsDuringGlide/final, minimum | 703,857 | 687,355 | 1,000 → 0 attribute reads | | NeighbourPhaseDivergence/arrival, minimum | 104,962 | 104,166 | modeled arrival error 193 → 0 pt | | NeighbourPhaseDivergence/display-lead, shared median | 409,893 | 412,815 | modeled future-deadline error 66 → 0 pt | | MotionBatchMainActorOverhead, main-thread minimum | 1,123,912 | 539,723 | p50 0.267 → 0.026 ms | | SettleReconcileCost, main-thread minimum | 790,663 | 276,324 | 30 → 0 fact snapshots; one list read | | SettleReconcileCost/echo-filter, shared median | 5,175 | 2,764 | genuine drift discarded 1 → 0 | | FocusBorderObservedBurst / FocusBorderSharedPlanBurst, minimum | 139,599 | 399,644 | shared curve, not a CPU reduction | The confirmed-target benchmark uses two release builds, not a retained formula: former guard **233,759,069** → final guard **216,409,189** median instructions (**7.4% lower**), with **200 → 0 plans**. It includes engine setup and a planning pass over 200 verified frames, not just `Animator.schedule`. Other refreshed minima: jitter **6,507,053** instructions for 600/600 dispatches; 24-tick animation workload **31,334,716**; schedule/retarget **2,637,229**. Their original-before captures remain in the first table. The display-lead case retains both formulas and real planner sampling; the production regression covers its wiring, not physical presentation latency. No +3% baseline gate or quiet-host time guarantee is claimed: no compatible checked-in baseline was available, and this host is shared. Logs and JUnit files are under `build/validation-continue/`. | Finding | Outcome / remaining evidence | | --- | --- | | H1, L2 | Fixed in code; synthetic jitter/rate proof passes. Hardware cadence traces deferred. | | H2, H3, M1, OS write #4 | Fixed in code; cache, batch, guard and call-count proofs pass. Live AX costs deferred. | | H4, OS settle M2 | Write-side suppression and fresh/settle provenance fixed. Cached metadata acknowledgement remains for the event path. | | H5 | Fixed in code; continuous rates and per-window budgets pass. Eight-window live scenario not run. | | M2 | Dispatch prediction fixed; modeled-arrival proof only, not a continuous ≤4 pt separation guarantee. | | M4 | Shared curve/readback wiring fixed; physical ≤2 pt p95 offset unverified. | | L1 | Ordering, grouping, ring buffer and verified-target skip fixed; single-tick/schedule p99 budgets unverified. | | L3 | Axis-wise resize ordering fixed; zero overlap proved for the selected replay, not arbitrary crossings. | | Veil design | Deferred as requested. |