feat(presence): typed awareness on the presence frame (lync 0.4.0) - #8
Merged
Conversation
Build the LIVE-SHARED awareness half on lync's existing ephemeral
presence frame, per the pinned presence contract. The relay stays a
stateless fanout — untouched — and nothing presence-related is ever
written to disk.
- sync-protocol: replace opaque `data?: unknown` with the typed
LyncPresence schema (clock + state{actor,via?,focus?,typing?}) and a
per-connection `client` id on the frame — the LWW key, distinct from
the durable `actor`. decodeFrame validates + canonicalizes it (drops
unknown extras, rejects poisoned clocks) so a bad payload never
reaches the awareness clock.
- presence-awareness: a client-side per-participant state machine —
apply-iff-clock-strictly-greater (LWW per participant, no CRDT),
heard-from lastSeen refresh, ~15s self-rebroadcast heartbeat, ~30s
TTL local removal, state=null immediate leave, and an
{added,updated,removed} callback keyed by clientId.
- synced-store: onPresence / presence() now carry (root, client,
LyncPresence).
Tests (retire the untested-primitive gap — only a codec roundtrip
existed before):
- presence-schema-lock: pins the exact wire shape (the seam textile
builds to).
- presence-awareness unit: LWW, immediate leave, TTL sweep, heartbeat
liveness + recovery, and start()/stop() over real fake-clocked timers.
- presence-awareness integration: real relay + two real synced stores —
typed presence A->B, silent-A TTL removal, null-leave immediate
removal, and an assertion the relay wrote NOTHING to disk.
Bump 0.3.0 -> 0.4.0 (additive minor). Do not publish.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Builds the LIVE-SHARED awareness half of the loom on lync's existing ephemeral presence frame, per the pinned presence contract. lync's durable loss-free sync was already proven; this adds who is here right now, where their attention is, and are they typing — without ever persisting it.
The relay stays a stateless fanout —
relay.tsis untouched. Nothing presence-related is written to disk.Contract (pinned)
LyncPresencecarried ONLY on the{t:"presence"}frame, NEVER stored:The frame also carries a per-connection
clientid — the LWW key, distinct fromactor(one human may run several clients). This is the seam a co-author (textile) builds to; it is pinned bytest/presence-schema-lock.test.ts.Changes
LyncPresence+clientonPresenceFrame;decodeFramevalidates and canonicalizes (drops unknown extras, rejects non-integer/negative clocks) so a bad payload never poisons the awareness clock.lastSeenrefresh, ~15s self-rebroadcast heartbeat, ~30s TTL local removal,state=nullimmediate leave,{added,updated,removed}callback keyed byclientId, and real-timerstart()/stop().onPresence/presence()now carry(root, client, LyncPresence).Tests (retire the untested-primitive gap — only a codec roundtrip existed before)
presence-schema-lock— pins the exact wire shape.presence-awarenessunit — LWW, immediate leave, TTL sweep, heartbeat liveness + TTL-recovery, andstart()/stop()over fake-clocked real timers.presence-awareness.integration— real relay + two real synced stores: typed presence A→B, silent-A TTL removal, null-leave immediate removal, and an assertion the relay wrote nothing to disk (readdirbefore == after; no<root>.lync).Full suite: 123 passed (111 baseline + 12 new).
Version 0.3.0 → 0.4.0 (additive minor). Not published (owner's 2FA). Do not merge.