Skip to content

refactor(gpu): comlink split-port for worker control plane (wave X1) - #205

Open
josstei wants to merge 71 commits into
mainfrom
wave/x1-comlink-split
Open

refactor(gpu): comlink split-port for worker control plane (wave X1)#205
josstei wants to merge 71 commits into
mainfrom
wave/x1-comlink-split

Conversation

@josstei

@josstei josstei commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Comlink split-port: the worker control plane (init/resize/preset/brightness/capture/release/destroy) now rides a dedicated MessagePort via comlink, while the frame path stays byte-untouched on the raw worker channel. Catalog row #1 of the 2026-07-05 cycle-2 catalog; spike-evidenced (CRITERION: PASS, controller-reproduced).

Numbers

  • Net src LOC: −419 (+320/−739)
  • Golden hash afa9ed05 held pre/post (golden byte-test, driver-call parity)
  • Timing: 255.1ms vs 263.6ms budget (0.97×)
  • Unit suite: 165 files / 2,033 tests green; full typecheck green; dev:smoke green
  • src/platform/gpu/application/video-session.ts diff vs main: empty (byte-unchanged)
  • e2e 90/91; fullscreen-exit-regression fails identically on pre-wave control trees under current machine load (documented flake class, PR test(e2e): fix fullscreen-exit reveal-race flake (main-vs-renderer sync) #204 family; wave structurally cannot affect e2e under --disable-gpu) — control evidence in wave records.

Test-count arithmetic

2,030 baseline → 2,033: +4 golden/timing/split-port adds, +1 stats-content, −1 fixtures sendCommand case, −1 net service/protocol prunes with coverage-parity (setBrightness/setPreset covered strictly stronger by split-port end-to-end).

Disclosure

Commit 86efa1e landed with a ONE-TIME owner-approved pre-commit bypass (2026-07-06) — lint-staged's vitest-related lane ran the 16 legacy tests that Tasks 3–4 subsequently migrated; all behavioral gates (typecheck:app, golden parity, timing, census, build, dev:smoke) were green at bypass time; commitlint validated post-hoc.

Accepted post-port notes

  • RELEASED/DESTROYED/CAPTURE_REQUESTED client callbacks are frozen-surface but never fire (zero src consumers).
  • Same-canvas double-init after a dead control port now throws rather than returning false (no live path — canvas-expiry machinery recreates the canvas).
  • Timing test is a measurement fixture (budget enforced at wave gates).

Adoption conditions satisfied

  • Frame-error signal restored (+ covering test)
  • Plane-based transferable rule documented in protocol JSDoc
  • 16-test migration complete
  • Init-timeout on control-port wait

josstei added 30 commits July 6, 2026 01:18
baseline hash=afa9ed05; timing baseline 251.078ms, budget 263.632ms
…ssagePort

frame path untouched; golden hash afa9ed05 held; net src -411 LOC pre-collateral; 16 legacy tests migrate in Tasks 3-4

testkit sendCommand removed as typecheck:app collateral (full mock rewrite in Task 3); pre-commit bypassed ONE TIME by owner approval 2026-07-06 (vitest-related lane runs the 16 accepted-legacy tests; typecheck:app/golden/timing/census/build/dev:smoke all green)
… dead validation tests

service.test.ts: 7 envelope-dispatch cases -> 5 rewritten onto the comlink
WorkerControlApi + 2 deleted (setBrightness/setPreset, redundant with
split-port.test.ts's driver.record coverage) + 1 added (stats-content case
asserting fps/frameTime/gpuTime/uploadTime), net -1.

protocol.test.ts: 3 cases -> 1 rewritten onto the surviving FRAME/STATS
factory + 2 deleted (isValidWorkerMessage/isValidWorkerResponse, both
removed by the port) + 1 added (guard coverage for the 7 surviving
discriminants), net -1.

service.ts: maybePostStats dropped uploadTime from the STATS payload during
the comlink port (consumed by video-session.ts and streaming-render.service.ts).
Re-add it; widen the local WorkerRendererPipeline.getStats type to
RenderStats & { uploadTime?: number } since RenderStats itself never
declared the field (pre-port this lived on a wrapper type the port
collapsed away).

2035 -> 2033 tests. Full suite and typecheck green.
Move UIController responsibilities to their owning services and add the shared PlatformBootstrap base for main/renderer lifecycle handling.

Validated locally:
- npm run typecheck
- npm run lint
- npm run lint:dead-code
- npm run test:run
- npm run dev:smoke
- npm run build:vite
- npx playwright test tests/e2e/app-launch.spec.js tests/e2e/notes-panel.spec.js tests/e2e/streaming-smoke.spec.js --project=electron
Mirror BaseOrchestrator's declared event handler subscription in BaseService and remove manual bindEventHandlers calls from renderer services.

Validated locally:
- npm run typecheck
- npx vitest run tests/unit/platform/core/service.base.test.ts tests/unit/renderer/infrastructure/services/settings/settings-cinematic-mode.service.test.ts tests/unit/renderer/infrastructure/services/settings/settings-fullscreen.service.test.ts tests/unit/renderer/presentation/bridges/ui-event.bridge.test.ts tests/unit/renderer/presentation/bridges/capture-ui.bridge.test.ts tests/unit/renderer/presentation/bridges/transcode-ui.bridge.test.ts
- npm run lint
- npm run lint:dead-code
- npm run test:run
- npm run dev:smoke
josstei added 30 commits July 12, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant