design: peer-mode §12 invariants and reactive scope-open#12
Open
design: peer-mode §12 invariants and reactive scope-open#12
Conversation
…e failure-mode wording
… default, §12.4/§12.5 wording
… event scopeId for top-level entities
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.
Summary
Two design-doc updates bundled together. Both stem from the same review pass that started as a follow-up to PR #11.
1.
docs/design/reactive-peer-mode.md— §12 additionsSpells out how MQDB and peer modes coexist, and what happens if a client tries to switch between them. The original draft underspecified this; sanity-checking surfaced three invariants worth locking in before any Phase 1 code lands.
Three load-bearing invariants:
syncModeis per-store, boot-time, immutable. Persisted in store metadata; mismatch on subsequent boot throwsModeMismatchErrorwith aclearLocalData()recovery path. Both have explicit contracts in the doc (error fields,clearLocalDataside effects)._version: numberfor MQDB,_hlc: { ts: number; counter: number; nodeId: string }for peer. Independent fields, no runtime polymorphism. Supersedes the earlier "HLC replaces_version" wording in §5.3 / §5.4.syncTopicPrefix(stitch/peer) so cross-mode topic collisions are impossible at the broker.Plus failure-mode table (§12.4), offline-queue interaction (§12.5), and explicit out-of-scope items (§12.6 — no MQDB→peer data migration, no per-scope mode, no CRDT yet).
Consistency fixes in §5.3, §5.4, §6.1, and §11 Phase 1 description bring older sections in line with §12.
2.
docs/design/reactive-scope-open.md— new docReviewing §12 surfaced a sequencing question: stitch's existing server-backed
replaceScopeblocks on N parallel request/reply round-trips insideopenScope(each capped at 10s). Peer mode designs around that by removing the server entirely, but the underlying client architecture would benefit from being reactive end-to-end first.The new doc proposes:
Promise.all([fetchOne, fetchList × N])inopenScopewith a client-publishedhelloand server-emitted per-record events on the existing scope events topic.replaceScopereturns immediately; UI populates as records stream in.bumpScopeVersionbecomes a server-emitted event instead of a per-mutation round-trip (cuts awaited-mutation latency in half).fetchList.§9 of the new doc lays out the relationship to peer mode: both designs converge on the same client shape (one events topic, hello-driven manifest diff, no client-side deadlines). Doing scope-open first means peer mode reuses the streaming infrastructure rather than building a parallel reactive stack.
This is the design-doc landing only. Implementation is gated on agreement with whoever owns the MQDB server.
Supporting material —
docs/design/MQDB-AGENT-BRIEF.md: self-contained brief for whoever picks up the server-side work. Inlines the wire format (topics,ChangeEventschema, MQTT user properties, request/reply envelope, the newhelloandscope-open-errorpayloads), the consolidated server-side checklist fromreactive-scope-open.md§4.4.1, pseudo-code for thehellohandler, and a server-side phasing plan. Designed so the MQDB agent can work straight from this one document without reading stitch's source tree.Test plan
node scripts/verify-changelog.mjsnot relevant (doc-only, no behavior change).reactive-scope-open.md(and the supportingMQDB-AGENT-BRIEF.md) — gates server-protocol negotiation.