Skip to content

feat: mailbox frame delivery + Server.Snapshot() (ADR-002, v0.2.0)#2

Merged
kolkov merged 1 commit into
mainfrom
feat/mailbox-snapshot
May 19, 2026
Merged

feat: mailbox frame delivery + Server.Snapshot() (ADR-002, v0.2.0)#2
kolkov merged 1 commit into
mainfrom
feat/mailbox-snapshot

Conversation

@kolkov
Copy link
Copy Markdown
Contributor

@kolkov kolkov commented May 19, 2026

Summary

Adds per-module mailbox slot and Server.Snapshot() for compositor render tick pattern. Formalizes push-based delivery as first-class alongside existing pull model.

Motivation: @AgentNemo00 (KiGo) uses push-based delivery. Research across 9 production compositors (Wayland, Android, Chrome, Flutter, PipeWire, DWM, macOS, Vulkan, X11) shows the universal pattern is MAILBOX — producers submit whenever ready, compositor samples latest.

Changes

  • Frame.Sequence field (mapped from wire protocol header)
  • Per-module mailbox slot (sync.Mutex + *Frame, NOT channel — ADR-002)
  • readFrameLoop stores every frame in mailbox before firing OnFrame
  • Server.Snapshot() returns latest frame from each module
  • 8 new tests (push, pull, concurrent, backward compat)

What did NOT change

  • Wire protocol (no new message types)
  • Handshake (no mode negotiation — inferred from behavior, Chromium pattern)
  • Client code (no changes)
  • OnFrame callback (still fires on every receipt — backward compatible)

ADR

  • ADR-002: Mailbox Frame Delivery (docs/dev/architecture/)

Test plan

  • go build ./... — PASS
  • go test ./... -count=3 — all pass, no flakes
  • golangci-lint run --timeout=5m — 0 issues
  • CI green (Ubuntu/macOS/Windows)

Add per-module mailbox slot with latest-wins semantics and Snapshot()
method for compositor render-tick polling. Push and pull coexist
naturally -- no mode negotiation, no wire protocol changes.

Changes:
- Frame.Sequence field: maps wire protocol sequence for change detection
- moduleConn.storeLatest/loadLatest: mutex-guarded mailbox slot
- Server.Snapshot(): returns map[uint64]*Frame of latest per-module frames
- readFrameLoop stores every frame in mailbox before OnFrame callback
- 8 new tests: basic, latest-wins, no-frames, multi-module, pull,
  concurrent, backward-compat, headerToFrame sequence mapping
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov kolkov merged commit 735b66e into main May 19, 2026
10 checks passed
@kolkov kolkov deleted the feat/mailbox-snapshot branch May 19, 2026 09:14
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