@hydranium/protocol 1.0.0-next.32 → 1.0.0-next.321

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/README.md +44 -83
  2. package/lib/abstract-logger.d.ts +5 -0
  3. package/lib/abstract-logger.d.ts.map +1 -1
  4. package/lib/abstract-logger.js +7 -0
  5. package/lib/abstract-logger.js.map +1 -1
  6. package/lib/client/data-connection.d.ts +302 -0
  7. package/lib/client/data-connection.d.ts.map +1 -0
  8. package/lib/client/data-connection.js +533 -0
  9. package/lib/client/data-connection.js.map +1 -0
  10. package/lib/client/data-events.d.ts +17 -1
  11. package/lib/client/data-events.d.ts.map +1 -1
  12. package/lib/client/data-events.js +25 -0
  13. package/lib/client/data-events.js.map +1 -1
  14. package/lib/client/data-port.d.ts +34 -24
  15. package/lib/client/data-port.d.ts.map +1 -1
  16. package/lib/client/data-session.d.ts +657 -89
  17. package/lib/client/data-session.d.ts.map +1 -1
  18. package/lib/client/data-session.js +1113 -115
  19. package/lib/client/data-session.js.map +1 -1
  20. package/lib/client/index.d.ts +15 -9
  21. package/lib/client/index.d.ts.map +1 -1
  22. package/lib/client/index.js +15 -9
  23. package/lib/client/index.js.map +1 -1
  24. package/lib/client/message-relay.d.ts +4 -4
  25. package/lib/client/message-relay.js +4 -4
  26. package/lib/client/message-relay.js.map +1 -1
  27. package/lib/client/post-message-transport.d.ts +64 -3
  28. package/lib/client/post-message-transport.d.ts.map +1 -1
  29. package/lib/client/post-message-transport.js +175 -1
  30. package/lib/client/post-message-transport.js.map +1 -1
  31. package/lib/client/rpc-connection.d.ts +157 -0
  32. package/lib/client/rpc-connection.d.ts.map +1 -0
  33. package/lib/client/rpc-connection.js +214 -0
  34. package/lib/client/rpc-connection.js.map +1 -0
  35. package/lib/client/worker-handshake.d.ts +86 -0
  36. package/lib/client/worker-handshake.d.ts.map +1 -0
  37. package/lib/client/worker-handshake.js +51 -0
  38. package/lib/client/worker-handshake.js.map +1 -0
  39. package/lib/client-ids.d.ts +45 -0
  40. package/lib/client-ids.d.ts.map +1 -0
  41. package/lib/client-ids.js +48 -0
  42. package/lib/client-ids.js.map +1 -0
  43. package/lib/clock.d.ts +50 -10
  44. package/lib/clock.d.ts.map +1 -1
  45. package/lib/clock.js +36 -1
  46. package/lib/clock.js.map +1 -1
  47. package/lib/console-logger.d.ts +23 -0
  48. package/lib/console-logger.d.ts.map +1 -0
  49. package/lib/console-logger.js +39 -0
  50. package/lib/console-logger.js.map +1 -0
  51. package/lib/data/data-protocol-methods.d.ts +4 -4
  52. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  53. package/lib/data/data-protocol-methods.js +13 -1
  54. package/lib/data/data-protocol-methods.js.map +1 -1
  55. package/lib/data/data-server-protocol.d.ts +165 -48
  56. package/lib/data/data-server-protocol.d.ts.map +1 -1
  57. package/lib/data/events.d.ts +137 -21
  58. package/lib/data/events.d.ts.map +1 -1
  59. package/lib/data/requests.d.ts +71 -11
  60. package/lib/data/requests.d.ts.map +1 -1
  61. package/lib/debouncer.d.ts +3 -3
  62. package/lib/debouncer.d.ts.map +1 -1
  63. package/lib/debouncer.js +6 -9
  64. package/lib/debouncer.js.map +1 -1
  65. package/lib/errors.d.ts +183 -30
  66. package/lib/errors.d.ts.map +1 -1
  67. package/lib/errors.js +268 -32
  68. package/lib/errors.js.map +1 -1
  69. package/lib/glsp-request-model-args.d.ts +16 -0
  70. package/lib/glsp-request-model-args.d.ts.map +1 -0
  71. package/lib/glsp-request-model-args.js +19 -0
  72. package/lib/glsp-request-model-args.js.map +1 -0
  73. package/lib/glsp-save-model-actions.d.ts +50 -0
  74. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  75. package/lib/glsp-save-model-actions.js +28 -0
  76. package/lib/glsp-save-model-actions.js.map +1 -0
  77. package/lib/index.d.ts +8 -0
  78. package/lib/index.d.ts.map +1 -1
  79. package/lib/index.js +8 -0
  80. package/lib/index.js.map +1 -1
  81. package/lib/latency-collector.d.ts +8 -4
  82. package/lib/latency-collector.d.ts.map +1 -1
  83. package/lib/latency-collector.js.map +1 -1
  84. package/lib/logger.d.ts +38 -7
  85. package/lib/logger.d.ts.map +1 -1
  86. package/lib/logger.js +42 -4
  87. package/lib/logger.js.map +1 -1
  88. package/lib/messages/index.d.ts +4 -2
  89. package/lib/messages/index.d.ts.map +1 -1
  90. package/lib/messages/index.js +15 -4
  91. package/lib/messages/index.js.map +1 -1
  92. package/lib/messages/primitives.d.ts +59 -4
  93. package/lib/messages/primitives.d.ts.map +1 -1
  94. package/lib/messages/primitives.js +97 -4
  95. package/lib/messages/primitives.js.map +1 -1
  96. package/lib/model-server.d.ts +60 -13
  97. package/lib/model-server.d.ts.map +1 -1
  98. package/lib/model-server.js +4 -2
  99. package/lib/model-server.js.map +1 -1
  100. package/lib/model-service/base-version.d.ts +67 -0
  101. package/lib/model-service/base-version.d.ts.map +1 -0
  102. package/lib/model-service/base-version.js +44 -0
  103. package/lib/model-service/base-version.js.map +1 -0
  104. package/lib/model-service/index.d.ts +1 -1
  105. package/lib/model-service/index.d.ts.map +1 -1
  106. package/lib/model-service/index.js +4 -5
  107. package/lib/model-service/index.js.map +1 -1
  108. package/lib/model-service/reference-candidate.d.ts +5 -3
  109. package/lib/model-service/reference-candidate.d.ts.map +1 -1
  110. package/lib/node/index.d.ts +10 -0
  111. package/lib/node/index.d.ts.map +1 -0
  112. package/lib/node/index.js +29 -0
  113. package/lib/node/index.js.map +1 -0
  114. package/lib/node/process-memory.d.ts +66 -0
  115. package/lib/node/process-memory.d.ts.map +1 -0
  116. package/lib/node/process-memory.js +291 -0
  117. package/lib/node/process-memory.js.map +1 -0
  118. package/lib/noop-logger.d.ts.map +1 -1
  119. package/lib/noop-logger.js.map +1 -1
  120. package/lib/observable-value.js.map +1 -1
  121. package/lib/patch-merge.d.ts +63 -35
  122. package/lib/patch-merge.d.ts.map +1 -1
  123. package/lib/patch-merge.js +171 -25
  124. package/lib/patch-merge.js.map +1 -1
  125. package/lib/profile-session.d.ts +8 -4
  126. package/lib/profile-session.d.ts.map +1 -1
  127. package/lib/profile-session.js.map +1 -1
  128. package/lib/project.d.ts +4 -1
  129. package/lib/project.d.ts.map +1 -1
  130. package/lib/project.js.map +1 -1
  131. package/lib/random-uuid.d.ts +14 -0
  132. package/lib/random-uuid.d.ts.map +1 -0
  133. package/lib/random-uuid.js +24 -0
  134. package/lib/random-uuid.js.map +1 -0
  135. package/lib/reconcile-write.d.ts +67 -0
  136. package/lib/reconcile-write.d.ts.map +1 -0
  137. package/lib/reconcile-write.js +69 -0
  138. package/lib/reconcile-write.js.map +1 -0
  139. package/lib/rpc/bind-rpc-methods.d.ts +6 -2
  140. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  141. package/lib/rpc/bind-rpc-methods.js +17 -7
  142. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  143. package/lib/rpc/create-rpc-proxy.d.ts +3 -0
  144. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  145. package/lib/rpc/create-rpc-proxy.js +6 -1
  146. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  147. package/lib/rpc/index.d.ts +1 -0
  148. package/lib/rpc/index.d.ts.map +1 -1
  149. package/lib/rpc/index.js +1 -0
  150. package/lib/rpc/index.js.map +1 -1
  151. package/lib/rpc/send-by-method-name.d.ts +76 -0
  152. package/lib/rpc/send-by-method-name.d.ts.map +1 -0
  153. package/lib/rpc/send-by-method-name.js +120 -0
  154. package/lib/rpc/send-by-method-name.js.map +1 -0
  155. package/lib/rpc/wire-prefix.js.map +1 -1
  156. package/lib/save-text-document.d.ts +40 -0
  157. package/lib/save-text-document.d.ts.map +1 -0
  158. package/lib/save-text-document.js +34 -0
  159. package/lib/save-text-document.js.map +1 -0
  160. package/lib/testing/catalogue-audit.d.ts +1 -1
  161. package/lib/testing/catalogue-audit.js +1 -1
  162. package/lib/testing/catalogue-audit.js.map +1 -1
  163. package/lib/testing/data-doubles.d.ts +41 -12
  164. package/lib/testing/data-doubles.d.ts.map +1 -1
  165. package/lib/testing/data-doubles.js +56 -8
  166. package/lib/testing/data-doubles.js.map +1 -1
  167. package/lib/testing/fake-clock.d.ts +17 -2
  168. package/lib/testing/fake-clock.d.ts.map +1 -1
  169. package/lib/testing/fake-clock.js +61 -46
  170. package/lib/testing/fake-clock.js.map +1 -1
  171. package/lib/testing/index.d.ts +1 -0
  172. package/lib/testing/index.d.ts.map +1 -1
  173. package/lib/testing/index.js +4 -3
  174. package/lib/testing/index.js.map +1 -1
  175. package/lib/testing/node/duplex-connection.d.ts.map +1 -1
  176. package/lib/testing/node/duplex-connection.js +3 -2
  177. package/lib/testing/node/duplex-connection.js.map +1 -1
  178. package/lib/testing/node/duplex-stream.js.map +1 -1
  179. package/lib/testing/node/index.d.ts +1 -0
  180. package/lib/testing/node/index.d.ts.map +1 -1
  181. package/lib/testing/node/index.js +2 -2
  182. package/lib/testing/node/index.js.map +1 -1
  183. package/lib/testing/node/message-port-pair.d.ts +25 -0
  184. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  185. package/lib/testing/node/message-port-pair.js +26 -0
  186. package/lib/testing/node/message-port-pair.js.map +1 -0
  187. package/lib/testing/transfer-node-builder.d.ts +81 -0
  188. package/lib/testing/transfer-node-builder.d.ts.map +1 -0
  189. package/lib/testing/transfer-node-builder.js +47 -0
  190. package/lib/testing/transfer-node-builder.js.map +1 -0
  191. package/lib/testing/wait-for.d.ts +9 -3
  192. package/lib/testing/wait-for.d.ts.map +1 -1
  193. package/lib/testing/wait-for.js +57 -11
  194. package/lib/testing/wait-for.js.map +1 -1
  195. package/lib/tracer.d.ts.map +1 -1
  196. package/lib/tracer.js +5 -9
  197. package/lib/tracer.js.map +1 -1
  198. package/lib/transfer-diagnostic.js.map +1 -1
  199. package/lib/transfer-document.d.ts +95 -32
  200. package/lib/transfer-document.d.ts.map +1 -1
  201. package/lib/transfer-document.js +17 -9
  202. package/lib/transfer-document.js.map +1 -1
  203. package/lib/transfer-element.d.ts +4 -4
  204. package/lib/types.d.ts +32 -0
  205. package/lib/types.d.ts.map +1 -0
  206. package/lib/{model-service/args.js → types.js} +2 -2
  207. package/lib/types.js.map +1 -0
  208. package/lib/uri.d.ts.map +1 -1
  209. package/lib/uri.js.map +1 -1
  210. package/lib/util.d.ts +8 -2
  211. package/lib/util.d.ts.map +1 -1
  212. package/lib/util.js +32 -4
  213. package/lib/util.js.map +1 -1
  214. package/package.json +24 -40
  215. package/src/abstract-logger.ts +8 -0
  216. package/src/client/data-connection.ts +653 -0
  217. package/src/client/data-events.ts +37 -1
  218. package/src/client/data-port.ts +36 -25
  219. package/src/client/data-session.ts +1427 -137
  220. package/src/client/index.ts +15 -9
  221. package/src/client/message-relay.ts +4 -4
  222. package/src/client/post-message-transport.ts +219 -4
  223. package/src/client/rpc-connection.ts +281 -0
  224. package/src/client/worker-handshake.ts +113 -0
  225. package/src/client-ids.ts +49 -0
  226. package/src/clock.ts +68 -10
  227. package/src/console-logger.ts +39 -0
  228. package/src/data/data-protocol-methods.ts +14 -4
  229. package/src/data/data-server-protocol.ts +192 -48
  230. package/src/data/events.ts +143 -21
  231. package/src/data/requests.ts +77 -11
  232. package/src/debouncer.ts +7 -10
  233. package/src/errors.ts +326 -40
  234. package/src/glsp-request-model-args.ts +16 -0
  235. package/src/glsp-save-model-actions.ts +59 -0
  236. package/src/index.ts +8 -0
  237. package/src/latency-collector.ts +8 -3
  238. package/src/logger.ts +44 -8
  239. package/src/messages/index.ts +4 -2
  240. package/src/messages/primitives.ts +129 -5
  241. package/src/model-server.ts +64 -19
  242. package/src/model-service/base-version.ts +75 -0
  243. package/src/model-service/index.ts +4 -5
  244. package/src/model-service/reference-candidate.ts +5 -3
  245. package/src/node/index.ts +14 -0
  246. package/src/node/process-memory.ts +299 -0
  247. package/src/patch-merge.ts +230 -45
  248. package/src/profile-session.ts +9 -4
  249. package/src/project.ts +4 -1
  250. package/src/random-uuid.ts +21 -0
  251. package/src/reconcile-write.ts +128 -0
  252. package/src/rpc/README.md +6 -6
  253. package/src/rpc/bind-rpc-methods.ts +18 -8
  254. package/src/rpc/create-rpc-proxy.ts +6 -1
  255. package/src/rpc/index.ts +1 -0
  256. package/src/rpc/send-by-method-name.ts +140 -0
  257. package/src/save-text-document.ts +39 -0
  258. package/src/testing/catalogue-audit.ts +1 -1
  259. package/src/testing/data-doubles.ts +141 -19
  260. package/src/testing/fake-clock.ts +76 -48
  261. package/src/testing/index.ts +4 -3
  262. package/src/testing/node/duplex-connection.ts +3 -2
  263. package/src/testing/node/index.ts +2 -2
  264. package/src/testing/node/message-port-pair.ts +40 -0
  265. package/src/testing/transfer-node-builder.ts +107 -0
  266. package/src/testing/wait-for.ts +61 -13
  267. package/src/tracer.ts +5 -9
  268. package/src/transfer-document.ts +115 -34
  269. package/src/transfer-element.ts +4 -4
  270. package/src/types.ts +30 -0
  271. package/src/util.ts +33 -6
  272. package/lib/model-service/args.d.ts +0 -64
  273. package/lib/model-service/args.d.ts.map +0 -1
  274. package/lib/model-service/args.js.map +0 -1
  275. package/src/model-service/args.ts +0 -67
@@ -10,16 +10,29 @@
10
10
  import type { TransferDiagnostic } from '../transfer-diagnostic';
11
11
  import type { TransferElement } from '../transfer-element';
12
12
  import type { Project } from '../project';
13
- import type { TransferDocument } from '../transfer-document';
13
+ import type { TransferCreatedDocument, TransferDocument, TransferSavedDocument, TransferWatchedDocument } from '../transfer-document';
14
14
  import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
15
15
  import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
16
- import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
17
16
  import type {
17
+ ProjectsChangedEvent,
18
+ TransferDocumentDeletedEvent,
19
+ TransferDocumentDirtyChangedEvent,
20
+ TransferDocumentSavedEvent,
21
+ TransferDocumentsBuiltEvent,
22
+ TransferDocumentUpdatedEvent
23
+ } from './events';
24
+ import type {
25
+ CloseSessionArgs,
26
+ CreateModelDocumentArgs,
27
+ CreateSessionArgs,
18
28
  GetModelDocumentArgs,
19
29
  GetProjectForUriArgs,
30
+ TransferDeleteDocumentArgs,
31
+ TransferPersistDocumentArgs,
20
32
  TransferSaveDocumentArgs,
21
33
  WatchModelDocumentArgs,
22
- TransferUpdateDocumentArgs
34
+ TransferUpdateDocumentArgs,
35
+ TransferUpdateDocumentsArgs
23
36
  } from './requests';
24
37
 
25
38
  /**
@@ -40,35 +53,77 @@ import type {
40
53
  */
41
54
  export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
42
55
  /**
43
- * Open a document for an editor session and return its current state.
44
- * Registers `(uri, clientId)` with the multi-client document manager
45
- * (so concurrent editors share one built document) and returns the
46
- * document at the server's configured target phase — the same shape
47
- * {@link getModelDocument} returns, except that `version` is taken from
48
- * the text-document store so the caller's first `baseVersion` write
49
- * cannot self-conflict. Idempotent in registration terms: opening an
50
- * already-open document refreshes the client registration. Note it does
51
- * NOT avoid a rebuild — a second client attaching triggers
52
- * `refreshContent`, which fires a change event, so mounting a form on a
53
- * document already open in a text editor rebuilds it.
56
+ * Register `args.clientId` as a client session owned by this connection.
57
+ * Rejects with a `DuplicateClientIdError` code when the id is live anywhere
58
+ * in the server process, and with a `ReservedClientIdError` code when the
59
+ * framework reserves it.
60
+ *
61
+ * A request carrying a registered id acts as that session: it writes only
62
+ * what the session has open, failing with a `DocumentNotOpenError` code
63
+ * otherwise, and opens nothing implicitly; its open reads the file and takes
64
+ * no `languageId`, `version` or `text` seed. The session ends with
65
+ * {@link closeSession} or when the connection closes, and either closes
66
+ * every document it has open.
54
67
  *
55
- * The default `DataServer` impl delegates to `ModelService.open` then
56
- * reads the built state. Pair with {@link watchModelDocument} to receive
57
- * subsequent build-phase events (open returns a one-shot snapshot;
58
- * later validation diagnostics arrive on the watch channel).
68
+ * A registration carrying the `resumeToken` an earlier registration of the
69
+ * same id carried ends that session first, from any connection, so a client
70
+ * whose connection dropped can register again before the server notices.
71
+ */
72
+ createSession(args: CreateSessionArgs): Promise<void>;
73
+
74
+ /**
75
+ * End a session this connection registered: close every document it has
76
+ * open, drop its watches, and free its id. A no-op for an id this
77
+ * connection did not register.
59
78
  */
60
- openModelDocument(args: OpenModelArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
79
+ closeSession(args: CloseSessionArgs): Promise<void>;
61
80
 
62
81
  /**
63
- * Close an editor session for `(uri, clientId)`. Counterpart to
64
- * {@link openModelDocument}; the underlying document stays built until
65
- * every registered client has closed. The default `DataServer` impl
66
- * delegates to `ModelService.close` and ALSO releases any watch for the
67
- * same `(uri, clientId)` (closing a session frees its own watch — a
68
- * forgotten {@link unwatchModelDocument} would otherwise leak dispatch;
69
- * the implicit unwatch is idempotent). `watchModelDocument` is NOT
70
- * coupled the other way: opening does not force a watch, so a snapshot
71
- * reader can open without streaming.
82
+ * Create a document with `args.text`, open for the session, and return it
83
+ * as {@link openModelDocument} does, with the version the create made in
84
+ * `created`. The answer is read after the create, so it can already hold
85
+ * another client's write or an integrity repair; a write based on
86
+ * `created.version` then conflicts. It reaches disk with the first save.
87
+ * Fails when the file exists or any client has the URI open, and with a
88
+ * `SessionClosedError` code when `args.clientId` is not a session
89
+ * registered on this connection.
90
+ */
91
+ createModelDocument(args: CreateModelDocumentArgs): Promise<TransferCreatedDocument<TTransfer, TDiagnostic>>;
92
+
93
+ /**
94
+ * Write several documents the session has open, all or none: a conflict or
95
+ * a document not open fails the whole set before any text applies.
96
+ * Resolves to the documents in the order given. Only for a session
97
+ * registered on this connection.
98
+ */
99
+ updateModelDocuments(args: TransferUpdateDocumentsArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>[]>;
100
+
101
+ /**
102
+ * Open a document for the client session `clientId` and return its current
103
+ * state. `clientId` must be a session this connection registered with
104
+ * {@link createSession}; any other id fails with the closed-session code,
105
+ * as every document request here does. The document is read from disk
106
+ * unless a client has it open already, so the request carries no
107
+ * `languageId`, `version` or `text` seed. Returns the document at
108
+ * the server's configured target phase, as {@link getModelDocument} does.
109
+ * A repeat open changes nothing.
110
+ *
111
+ * Pair with {@link watchModelDocument} to receive subsequent build-phase
112
+ * events (open returns a one-shot snapshot; later validation diagnostics
113
+ * arrive on the watch channel).
114
+ */
115
+ openModelDocument(args: Pick<OpenModelArgs, 'uri' | 'clientId' | 'options'>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
116
+
117
+ /**
118
+ * Close the session's open of `uri`. Counterpart to
119
+ * {@link openModelDocument}; the document stays open until every client
120
+ * has closed it, and then the server releases it, by default reverting it
121
+ * to disk. The default
122
+ * `DataServer` impl ALSO releases any watch for the same
123
+ * `(uri, clientId)` (a forgotten {@link unwatchModelDocument} would
124
+ * otherwise leak dispatch; the implicit unwatch is idempotent).
125
+ * `watchModelDocument` is NOT coupled the other way: opening does not force
126
+ * a watch, so a snapshot reader can open without streaming.
72
127
  */
73
128
  closeModelDocument(args: CloseModelArgs): Promise<void>;
74
129
 
@@ -81,34 +136,69 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
81
136
  getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
82
137
 
83
138
  /**
84
- * Update a document's content. The response carries the latest built
85
- * state including diagnostics; callers observe convergence via that
86
- * response.
139
+ * Update a document's content as the session `clientId`, which must have
140
+ * it open. The response carries the latest built state including
141
+ * diagnostics; callers observe convergence via that response.
87
142
  */
88
143
  updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
89
144
 
90
145
  /**
91
- * Persist a document to disk. The response is the post-save document
92
- * state (matches the file on disk). Save semantics depend on the
93
- * filesystem-provider wiring; rejection paths surface as awaited
146
+ * Write a document as the session `clientId`, which must have it open, and
147
+ * persist it to disk. The response is the build of the text written, with
148
+ * its version in `persisted`, sent once the language client has answered
149
+ * the push of that text, applied or refused, or a server-side bound on
150
+ * that wait passes; it does not wait again for a push that wait already
151
+ * gave up on and the client has not answered since. Save semantics depend
152
+ * on the filesystem-provider wiring; rejection paths surface as awaited
94
153
  * promise rejections.
95
154
  */
96
- saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
155
+ saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
156
+
157
+ /**
158
+ * Persist the text the server holds for a document the session `clientId`
159
+ * has open, as it is: no update and no serialisation, so another client's
160
+ * unsaved text keeps its formatting. `baseVersion` is checked in the step
161
+ * that takes the text, so text that moved on fails with a `ConflictError`
162
+ * code. The saved event names this session, whoever wrote the text.
163
+ * Answers after the same language-client wait as {@link saveModelDocument},
164
+ * with the document's latest build, read after that wait, so another
165
+ * session's write during it shows; `persisted` carries the version written.
166
+ */
167
+ persistModelDocument(args: TransferPersistDocumentArgs): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
168
+
169
+ /**
170
+ * Delete a document the session `clientId` has open, at once: its file,
171
+ * then the document, as a deletion a file watcher reports removes it. Every
172
+ * session's open of it closes and every client hears
173
+ * {@link DocumentClientProtocol.onDocumentDeleted} naming this session; the
174
+ * session's own watch is released, as {@link closeModelDocument} releases
175
+ * it. `baseVersion` is checked in the step that marks the document for
176
+ * deletion, so text that moved on fails with a `ConflictError` code. A file
177
+ * already gone deletes only the document; a file that cannot be removed
178
+ * fails the call and changes nothing. Resolves once the build that removes
179
+ * the document has run; a read then answers the URI without a model, unless
180
+ * an editor still has it open, whose buffer the document is built from.
181
+ */
182
+ deleteModelDocument(args: TransferDeleteDocumentArgs): Promise<void>;
97
183
 
98
184
  /**
99
185
  * Start watching `(uri, clientId)`. The server starts dispatching
100
186
  * {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
101
187
  * for every build-phase event on `uri`.
102
188
  *
103
- * Returns `Promise<void>` — the bidirectional pattern means the event
104
- * channel is the client interface, not a returned handle. Callers fan
105
- * out a single inbound `onDocumentUpdated` to multiple local listeners
106
- * with their own `Emitter<T>` (matching Theia's pattern). Pair every
107
- * `watchModelDocument` with {@link unwatchModelDocument} when no longer
108
- * needed; the server holds the watch record until the matching unwatch
109
- * lands.
189
+ * Answers with the key the watch's events name the document by, whether
190
+ * a document exists, taken once the watch is in place and the document
191
+ * is loaded as a read loads it, the text held at that moment, and the
192
+ * position of the last update or deletion event sent as of it, so an event
193
+ * the client heard while the watch was in flight tells by its own position
194
+ * whether it is newer than the answer. No handle: the event channel is the
195
+ * client interface. Callers fan out a single inbound `onDocumentUpdated` to
196
+ * multiple local listeners with their own `Emitter<T>` (matching Theia's
197
+ * pattern). Pair every `watchModelDocument` with
198
+ * {@link unwatchModelDocument} when no longer needed; the server holds the
199
+ * watch record until the matching unwatch lands.
110
200
  */
111
- watchModelDocument(args: WatchModelDocumentArgs): Promise<void>;
201
+ watchModelDocument(args: WatchModelDocumentArgs): Promise<TransferWatchedDocument>;
112
202
 
113
203
  /**
114
204
  * Stop watching `(uri, clientId)` previously started by
@@ -194,6 +284,22 @@ export interface DataServerProtocol<
194
284
  >
195
285
  extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {}
196
286
 
287
+ /**
288
+ * The diagnostic shape a server answers with, read back off its own
289
+ * declaration.
290
+ *
291
+ * This is what lets a client tier stay generic over the server alone and still
292
+ * describe what it hands back. Both parameters must be inferred: naming
293
+ * {@link TransferElement} for the transfer instead fails to match while that
294
+ * parameter is still generic, and a default declared against the constraint
295
+ * then stops satisfying it.
296
+ */
297
+ export type DiagnosticOf<TServer> =
298
+ TServer extends DocumentServerProtocol<infer _TTransfer, infer TDiagnostic> ? TDiagnostic : TransferDiagnostic;
299
+
300
+ /** The project shape a server answers with, read back off its own declaration. */
301
+ export type ProjectOf<TServer> = TServer extends ProjectServerProtocol<infer TProject> ? TProject : Project;
302
+
197
303
  /**
198
304
  * Cross-reference / naming slice of the server surface — scope-aware
199
305
  * queries that resolve against the language's reference services. NOT part
@@ -204,11 +310,11 @@ export interface DataServerProtocol<
204
310
  * source/URI (an `ElementSource` with no URI resolves to the sole
205
311
  * registered language; a multi-language workspace overrides).
206
312
  *
207
- * Generic over the transfer root type only — the resolution result
208
- * ({@link ReferenceTarget}) carries the resolved node's encoded subtree;
209
- * candidates and names are diagnostic-free.
313
+ * Not generic over a server's root type: {@link resolveReference} answers with
314
+ * a node a reference names, which is no document root, and candidates and
315
+ * names are diagnostic-free.
210
316
  */
211
- export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
317
+ export interface ReferenceServerProtocol {
212
318
  /**
213
319
  * List the reference candidates reachable for the property named in `ctx`
214
320
  * from its (possibly synthetic) source. Backed by the language's
@@ -221,8 +327,13 @@ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
221
327
  * target's document URI, display fields, and the resolved node's encoded
222
328
  * transfer subtree. Resolves via the language's reference services;
223
329
  * `undefined` when the reference does not resolve.
330
+ *
331
+ * `TElement` is the caller's claim about the target node's type; nothing
332
+ * checks it, so leave it at the default unless the reference names one type.
224
333
  */
225
- resolveReference(ref: ReferenceRequest): Promise<ReferenceTarget<TTransfer> | undefined>;
334
+ resolveReference<TElement extends TransferElement = TransferElement>(
335
+ ref: ReferenceRequest
336
+ ): Promise<ReferenceTarget<TElement> | undefined>;
226
337
 
227
338
  /**
228
339
  * Compute the next free name for a new element of `args.type` based on
@@ -262,6 +373,39 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
262
373
  * codepath, not a subscription codepath).
263
374
  */
264
375
  onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
376
+
377
+ /**
378
+ * Delivered when a subscribed document's text starts or stops differing
379
+ * from its file, as the server last knew it. Gated like
380
+ * {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
381
+ * the documents the server sends. After a reconnect, a `DataSession`
382
+ * delivers here the answer of each document it restored, when that differs
383
+ * from the last this client was told: the flips while the connection was
384
+ * down reached no one.
385
+ */
386
+ onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
387
+
388
+ /**
389
+ * Delivered when a document's backing file was removed. Separate from
390
+ * {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
391
+ * and more strongly: there is no built state to deliver, and the build-phase
392
+ * path cannot report a deletion at all.
393
+ *
394
+ * Ungated, because on a browser host — where the workspace lives behind the
395
+ * head — no other source can observe a file disappearing. Recipients that
396
+ * only care about their own documents filter by URI.
397
+ */
398
+ onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
399
+
400
+ /**
401
+ * Delivered once per build, naming the documents that reached the
402
+ * subscription phase and that
403
+ * nobody on this connection watches — chiefly the ones rebuilt as a cascade
404
+ * from a dependency's change, which no filesystem watcher can see because
405
+ * their own files did not change. The complement of
406
+ * {@link onDocumentUpdated}; carries URIs and no documents.
407
+ */
408
+ onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
265
409
  }
266
410
 
267
411
  /**
@@ -10,30 +10,36 @@
10
10
  import type { TransferDiagnostic } from '../transfer-diagnostic';
11
11
  import type { TransferElement } from '../transfer-element';
12
12
  import type { Project } from '../project';
13
- import type { TransferDocument } from '../transfer-document';
13
+ import type { TextState, TransferDocument } from '../transfer-document';
14
14
 
15
15
  /**
16
16
  * Why an update event fired. Subscribers filter on reason for behaviour
17
17
  * decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
18
18
  *
19
- * - `'changed'` — the URI appeared in `DocumentBuilder.onUpdate`'s
20
- * `changed` list. The framework's underlying primitive is "this URI was
21
- * passed to `documentBuilder.update(changed, deleted)`", which spans
22
- * `didChange` text-document events, `notifyDidChangeTextDocument` calls,
23
- * and any programmatic `documentBuilder.update([uri], [])` invocation.
24
- * The name matches Langium's own `changed` parameter — it's vague-on-
25
- * purpose because the underlying primitive is.
26
- * - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
27
- * build (dependency graph re-derivation), without itself being passed to
28
- * `documentBuilder.update`. The complement of `'changed'`.
19
+ * - `'changed'` — the server's first update event for the document's current
20
+ * version: its content changed since the last one. A write whose build a
21
+ * later write cancelled is still `'changed'` in the build that takes over.
22
+ * - `'rebuilt'` — a later event for a version the server already delivered,
23
+ * whether or not any client watched it then: something the document depends
24
+ * on changed, or the document was built again with the same content. The
25
+ * complement of `'changed'`.
29
26
  * - `'saved'` — emitted by adopters that synthesise a unified update stream
30
27
  * from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
31
28
  * `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
32
29
  * `DataClientProtocol.onDocumentSaved` channel.
33
- * - `'deleted'` — the URI appeared in `DocumentBuilder.onUpdate`'s
34
- * `deleted` list. The backing file was removed.
30
+ *
31
+ * The version rule needs a version the server keeps and builds that validate.
32
+ * For a document no client has opened, or when rebuilds do not validate,
33
+ * `'changed'` means the URI was passed to `DocumentBuilder.update` for this
34
+ * build. A document that a validating build skips is `'changed'` every time.
35
+ *
36
+ * Deletion is deliberately NOT a member. An update event carries a built
37
+ * document, which a deleted one has none of, and the phase-driven path that
38
+ * produces these events never runs for a deleted URI — the builder drops the
39
+ * document before deriving the rebuild set. It travels as
40
+ * {@link TransferDocumentDeletedEvent} on its own channel instead.
35
41
  */
36
- export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved' | 'deleted';
42
+ export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
37
43
 
38
44
  /**
39
45
  * Delivered on the data-server when a document's content (or existence)
@@ -47,9 +53,21 @@ export interface TransferDocumentUpdatedEvent<
47
53
  TDiagnostic extends TransferDiagnostic = TransferDiagnostic
48
54
  > {
49
55
  document: TransferDocument<TTransfer, TDiagnostic>;
50
- /** Stable identifier of the client that triggered the update. */
56
+ /**
57
+ * The client whose write this event echoes: the author of the version on a
58
+ * `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
59
+ * write. A recipient compares it against its own id to recognise its echo.
60
+ * The build that follows a document's release names the release id
61
+ * instead.
62
+ */
51
63
  sourceClientId: string;
52
64
  reason: TransferDocumentUpdateReason;
65
+ /**
66
+ * The position of this event among the update and deletion events the
67
+ * server sent on this connection, which a watch's answer carries as of
68
+ * the moment it was taken: a greater one was sent later.
69
+ */
70
+ sequence: number;
53
71
  }
54
72
 
55
73
  /** Callback shape for `DataClientProtocol.onDocumentUpdated`. */
@@ -60,8 +78,8 @@ export type TransferDocumentUpdatedListener<
60
78
 
61
79
  /**
62
80
  * Delivered on the data-server when a document was persisted to disk via
63
- * `DataServerProtocol.saveModelDocument`. Distinct from
64
- * {@link TransferDocumentUpdatedEvent}: subscribers that only care about
81
+ * `DataServerProtocol.saveModelDocument` or `persistModelDocument`. Distinct
82
+ * from {@link TransferDocumentUpdatedEvent}: subscribers that only care about
65
83
  * persistence (external sync, editor "saved" indicators, dirty-flag
66
84
  * clear) listen for this event family instead of filtering an update
67
85
  * stream for `reason: 'saved'`.
@@ -77,10 +95,11 @@ export interface TransferDocumentSavedEvent<
77
95
  > {
78
96
  document: TransferDocument<TTransfer, TDiagnostic>;
79
97
  /**
80
- * The client whose `saveModelDocument` call produced this. Every subscriber
81
- * receives the event including the originator, which already had the same
82
- * state as the RPC response — compare against your own id to drop the echo
83
- * rather than re-rendering from it.
98
+ * The client whose `saveModelDocument` or `persistModelDocument` call
99
+ * produced this, also when another client wrote the persisted text. Every
100
+ * subscriber receives the event including the originator, which already had
101
+ * the same state as the RPC response — compare against your own id to drop
102
+ * the echo rather than re-rendering from it.
84
103
  */
85
104
  sourceClientId: string;
86
105
  }
@@ -91,6 +110,109 @@ export type TransferDocumentSavedListener<
91
110
  TDiagnostic extends TransferDiagnostic = TransferDiagnostic
92
111
  > = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
93
112
 
113
+ /**
114
+ * Delivered on the data-server when a watched document's text starts or stops
115
+ * differing from its file, as the server last knew the file. The current
116
+ * answer rides on every transfer document the server sends as `text.dirty`;
117
+ * this carries only its changes, so a client that follows it needs no rebuild
118
+ * to learn of a save.
119
+ */
120
+ export interface TransferDocumentDirtyChangedEvent {
121
+ /** Canonical URI, keyed as the subscription is. */
122
+ readonly uri: string;
123
+ /**
124
+ * The text the answer was decided on. It is sent before that text is
125
+ * built, so a `text.version` ahead of the model a client holds means an
126
+ * update at this version or a later one follows. Absent when the document
127
+ * no longer exists, or when the build that follows its release failed.
128
+ */
129
+ readonly text?: TextState;
130
+ }
131
+
132
+ /** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
133
+ export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
134
+
135
+ /**
136
+ * Delivered on the data-server when a document's backing file was removed.
137
+ * Carries no document, and cannot: the state a
138
+ * {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
139
+ * the time anyone can be told. That is also why deletion is not a `reason` on
140
+ * the update stream — `DocumentBuilder.update` drops the document before
141
+ * deriving the rebuild set, so the phase-driven path that produces update
142
+ * events never runs for it.
143
+ *
144
+ * **Delivered for EVERY document, not only watched ones**, unlike
145
+ * `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
146
+ * channels are gated is whether any OTHER source can observe the fact on the
147
+ * least capable host: a browser-hosted client's workspace lives behind the
148
+ * head, so nothing there can see a file disappear, and gating the notification
149
+ * would leave it blind. (A Theia frontend's filesystem watcher would cover it,
150
+ * which is why this is a host argument and not a structure-versus-content one.)
151
+ * A watcher is told about its own document's deletion here too, the update
152
+ * channel being silent for deletions by construction. Filter on {@link uri} if
153
+ * the receiver only cares about documents it opened.
154
+ *
155
+ * A watch survives the deletion, so a file that comes back resumes delivering
156
+ * `onDocumentUpdated` to the same subscribers with no re-subscription. A
157
+ * client that responds by closing its editor releases the watch through
158
+ * `closeModelDocument` as usual, and `deleteModelDocument` releases the
159
+ * deleting session's own.
160
+ */
161
+ export interface TransferDocumentDeletedEvent {
162
+ /** Canonical URI of the removed document, keyed as the subscription is. */
163
+ readonly uri: string;
164
+ /**
165
+ * The session whose `deleteModelDocument` removed the file, so it can tell
166
+ * its own deletion from another's; the unknown-client id for a file
167
+ * removed outside any session, as a file watcher reports one, and for one
168
+ * a `DataConnection` found gone after a reconnect, which no event named.
169
+ */
170
+ readonly sourceClientId: string;
171
+ /**
172
+ * The position of this event among the update and deletion events the
173
+ * server sent on this connection, as on an update; absent on a deletion a
174
+ * `DataConnection` found after a reconnect, which the server never sent.
175
+ */
176
+ readonly sequence?: number;
177
+ }
178
+
179
+ /** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
180
+ export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
181
+
182
+ /**
183
+ * Delivered on the data-server once per build, naming the documents that reached
184
+ * the configured subscription phase (`DataServerOptions.subscriptionPhase`,
185
+ * `Validated` by default) and that NO client on the connection is watching. Not
186
+ * the integrity-settled landmark, which is a different point and a different
187
+ * word in this framework.
188
+ *
189
+ * The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
190
+ * URI: together the two cover every document a build touched. This one exists
191
+ * for the case no source outside the server can observe — a document rebuilt
192
+ * because something it DEPENDS ON changed. Its own file never changed, so a
193
+ * filesystem watcher cannot see it, and it has no subscriber, so the update
194
+ * channel does not report it. A consumer showing data derived from such a
195
+ * document (a tree label, a decorator) would otherwise hold a stale value with
196
+ * nothing to invalidate it.
197
+ *
198
+ * Carries URIs and no documents: a recipient re-reads what it displays, through
199
+ * `getModelDocument` or its own request. That keeps the bandwidth property the
200
+ * per-URI subscription exists for, without gating the message.
201
+ *
202
+ * Not sent when the set is empty, which is the normal case while editing — the
203
+ * document being edited is watched by its own editor and therefore excluded.
204
+ * Workspace initialisation sends nothing either: it does not build to the
205
+ * subscription phase. The largest message a workspace can produce is therefore
206
+ * a whole-workspace rebuild at that phase, which is one message of URIs.
207
+ */
208
+ export interface TransferDocumentsBuiltEvent {
209
+ /** Canonical URIs, keyed as subscriptions are. Never empty. */
210
+ readonly uris: readonly string[];
211
+ }
212
+
213
+ /** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
214
+ export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
215
+
94
216
  /**
95
217
  * Why a project-change event fired. `added` — the project was newly
96
218
  * registered (descriptor discovered); `updated` — the project's
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import type { TransferSaveArgs, TransferUpdateArgs } from '../model-service/args';
10
+ import type { BaseVersion } from '../model-service/base-version';
11
11
 
12
12
  /** Get the current state of a single document. The server returns the latest built version. */
13
13
  export interface GetModelDocumentArgs {
@@ -41,24 +41,90 @@ export interface GetProjectForUriArgs {
41
41
  }
42
42
 
43
43
  /**
44
- * Update a document's content. Wire-side projection of the facade's
45
- * {@link TransferUpdateArgs}; structurally identical so the data-server RPC
46
- * handler can forward straight to the in-process `ModelService.update`
47
- * without an args mapping.
44
+ * Update a document the session `clientId` has open. Generic over `TTransfer`
45
+ * so adopters parameterise the structured shape against their grammar's
46
+ * transfer-model overlay; passing a string is always allowed.
48
47
  */
49
- export type TransferUpdateDocumentArgs<TTransfer> = TransferUpdateArgs<TTransfer>;
48
+ export interface TransferUpdateDocumentArgs<TTransfer> {
49
+ /** Document URI. */
50
+ uri: string;
51
+ /** The id of a live session registered on this connection. */
52
+ clientId: string;
53
+ /** The whole structured model root, or its serialised textual form. */
54
+ model: TTransfer | string;
55
+ /**
56
+ * What this write was authored against. A `ModelVersion` is compared
57
+ * against the server's current text-document version for `uri` and throws
58
+ * `ConflictError` on mismatch; `'any'` writes unconditionally.
59
+ *
60
+ * **Required so that an ungated write is a decision rather than an
61
+ * omission.** An optional gate is indistinguishable from a forgotten one at
62
+ * the call site, and a file of twenty writes hides the one that lost the
63
+ * field. Nothing else here can see that, since the defect is an absence.
64
+ */
65
+ baseVersion: BaseVersion;
66
+ }
67
+
68
+ /** Update a document the session `clientId` has open, then persist it to disk. */
69
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- save names its own args; it adds no field to update's
70
+ export interface TransferSaveDocumentArgs<TTransfer> extends TransferUpdateDocumentArgs<TTransfer> {}
71
+
72
+ /** Persist the text the server holds for a document the session `clientId` has open, without writing a model. */
73
+ export type TransferPersistDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model'>;
74
+
75
+ /** Delete a document the session `clientId` has open: its file, then the document. */
76
+ export type TransferDeleteDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model'>;
77
+
78
+ /** Register a client session on the connection. */
79
+ export interface CreateSessionArgs {
80
+ /** The session's id, minted by the client; unique in the server process while the session is live. */
81
+ clientId: string;
82
+ /** What the participant is; kept as the server session's `label`. */
83
+ label?: string;
84
+ /**
85
+ * A token the client keeps for the session's lifetime. It is no secret: the
86
+ * wire carries no authentication. A later `createSession` for the same id
87
+ * carrying the same token, from any connection, ends the session it names
88
+ * and registers the id afresh, so a client whose connection dropped before
89
+ * the server noticed can register again. Without it the id stays refused
90
+ * until the server notices.
91
+ */
92
+ resumeToken?: string;
93
+ }
50
94
 
51
- /** Persist a document to disk. Wire-side projection of {@link TransferSaveArgs}. */
52
- export type TransferSaveDocumentArgs<TTransfer> = TransferSaveArgs<TTransfer>;
95
+ /** End a client session registered on the connection. */
96
+ export interface CloseSessionArgs {
97
+ clientId: string;
98
+ }
99
+
100
+ /** Create a document that exists nowhere yet, open for the session creating it. */
101
+ export interface CreateModelDocumentArgs {
102
+ uri: string;
103
+ /** The id of a live session registered on this connection. */
104
+ clientId: string;
105
+ /** The document's initial content; it reaches disk with the first save. */
106
+ text: string;
107
+ }
108
+
109
+ /**
110
+ * Write several documents a session has open, all or none. `clientId` is on
111
+ * the set rather than on each update: an id per update would allow a set
112
+ * mixing clients, which the server would have to refuse.
113
+ */
114
+ export interface TransferUpdateDocumentsArgs<TTransfer> {
115
+ /** The id of a live session registered on this connection. */
116
+ clientId: string;
117
+ updates: Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>[];
118
+ }
53
119
 
54
120
  /**
55
121
  * Identifies a per-document watch on the data server. Shared by both
56
122
  * `watchModelDocument` and `unwatchModelDocument` — the `(uri, clientId)`
57
123
  * pair is the watch key, so unwatching names the same watch that was
58
124
  * started. The `clientId` identifies the originator the same way it does
59
- * on facade-side mutations (`TransferUpdateArgs.clientId`,
60
- * `TransferSaveArgs.clientId`): it keys the per-`(uri, clientId)` watch
61
- * bucket so multiple watchers on the same wire stay distinct, AND it lets
125
+ * on the document writes (`TransferUpdateDocumentArgs.clientId`,
126
+ * `TransferSaveDocumentArgs.clientId`): it keys the per-`(uri, clientId)`
127
+ * watch bucket so multiple watchers on the same wire stay distinct, AND it lets
62
128
  * each watcher recognise its own echo on inbound `onDocumentUpdated` events
63
129
  * (the wire shape's `sourceClientId` carries the originating mutation's
64
130
  * `clientId`).