@hydranium/protocol 1.0.0-next.36 → 1.0.0-next.360

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 (297) hide show
  1. package/README.md +44 -83
  2. package/lib/abstract-logger.d.ts +11 -0
  3. package/lib/abstract-logger.d.ts.map +1 -1
  4. package/lib/abstract-logger.js +16 -0
  5. package/lib/abstract-logger.js.map +1 -1
  6. package/lib/client/data-connection.d.ts +303 -0
  7. package/lib/client/data-connection.d.ts.map +1 -0
  8. package/lib/client/data-connection.js +534 -0
  9. package/lib/client/data-connection.js.map +1 -0
  10. package/lib/client/data-events.d.ts +18 -1
  11. package/lib/client/data-events.d.ts.map +1 -1
  12. package/lib/client/data-events.js +26 -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 +691 -89
  17. package/lib/client/data-session.d.ts.map +1 -1
  18. package/lib/client/data-session.js +1155 -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 +6 -4
  25. package/lib/client/message-relay.d.ts.map +1 -1
  26. package/lib/client/message-relay.js +4 -4
  27. package/lib/client/message-relay.js.map +1 -1
  28. package/lib/client/post-message-transport.d.ts +69 -3
  29. package/lib/client/post-message-transport.d.ts.map +1 -1
  30. package/lib/client/post-message-transport.js +175 -1
  31. package/lib/client/post-message-transport.js.map +1 -1
  32. package/lib/client/rpc-connection.d.ts +173 -0
  33. package/lib/client/rpc-connection.d.ts.map +1 -0
  34. package/lib/client/rpc-connection.js +225 -0
  35. package/lib/client/rpc-connection.js.map +1 -0
  36. package/lib/client/worker-handshake.d.ts +90 -0
  37. package/lib/client/worker-handshake.d.ts.map +1 -0
  38. package/lib/client/worker-handshake.js +51 -0
  39. package/lib/client/worker-handshake.js.map +1 -0
  40. package/lib/client-ids.d.ts +45 -0
  41. package/lib/client-ids.d.ts.map +1 -0
  42. package/lib/client-ids.js +48 -0
  43. package/lib/client-ids.js.map +1 -0
  44. package/lib/clock.d.ts +50 -10
  45. package/lib/clock.d.ts.map +1 -1
  46. package/lib/clock.js +36 -1
  47. package/lib/clock.js.map +1 -1
  48. package/lib/console-logger.d.ts +23 -0
  49. package/lib/console-logger.d.ts.map +1 -0
  50. package/lib/console-logger.js +39 -0
  51. package/lib/console-logger.js.map +1 -0
  52. package/lib/data/data-protocol-methods.d.ts +4 -4
  53. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  54. package/lib/data/data-protocol-methods.js +13 -1
  55. package/lib/data/data-protocol-methods.js.map +1 -1
  56. package/lib/data/data-server-protocol.d.ts +171 -48
  57. package/lib/data/data-server-protocol.d.ts.map +1 -1
  58. package/lib/data/events.d.ts +144 -33
  59. package/lib/data/events.d.ts.map +1 -1
  60. package/lib/data/requests.d.ts +76 -11
  61. package/lib/data/requests.d.ts.map +1 -1
  62. package/lib/debouncer.d.ts +7 -4
  63. package/lib/debouncer.d.ts.map +1 -1
  64. package/lib/debouncer.js +10 -10
  65. package/lib/debouncer.js.map +1 -1
  66. package/lib/errors.d.ts +188 -30
  67. package/lib/errors.d.ts.map +1 -1
  68. package/lib/errors.js +269 -32
  69. package/lib/errors.js.map +1 -1
  70. package/lib/format-log-arg.d.ts +33 -0
  71. package/lib/format-log-arg.d.ts.map +1 -0
  72. package/lib/format-log-arg.js +158 -0
  73. package/lib/format-log-arg.js.map +1 -0
  74. package/lib/glsp-edits-settled-actions.d.ts +54 -0
  75. package/lib/glsp-edits-settled-actions.d.ts.map +1 -0
  76. package/lib/glsp-edits-settled-actions.js +28 -0
  77. package/lib/glsp-edits-settled-actions.js.map +1 -0
  78. package/lib/glsp-request-model-args.d.ts +16 -0
  79. package/lib/glsp-request-model-args.d.ts.map +1 -0
  80. package/lib/glsp-request-model-args.js +19 -0
  81. package/lib/glsp-request-model-args.js.map +1 -0
  82. package/lib/glsp-save-model-actions.d.ts +55 -0
  83. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  84. package/lib/glsp-save-model-actions.js +28 -0
  85. package/lib/glsp-save-model-actions.js.map +1 -0
  86. package/lib/index.d.ts +11 -0
  87. package/lib/index.d.ts.map +1 -1
  88. package/lib/index.js +11 -0
  89. package/lib/index.js.map +1 -1
  90. package/lib/latency-collector.d.ts +10 -4
  91. package/lib/latency-collector.d.ts.map +1 -1
  92. package/lib/latency-collector.js +2 -0
  93. package/lib/latency-collector.js.map +1 -1
  94. package/lib/logger.d.ts +38 -7
  95. package/lib/logger.d.ts.map +1 -1
  96. package/lib/logger.js +42 -4
  97. package/lib/logger.js.map +1 -1
  98. package/lib/messages/index.d.ts +4 -2
  99. package/lib/messages/index.d.ts.map +1 -1
  100. package/lib/messages/index.js +15 -4
  101. package/lib/messages/index.js.map +1 -1
  102. package/lib/messages/primitives.d.ts +59 -4
  103. package/lib/messages/primitives.d.ts.map +1 -1
  104. package/lib/messages/primitives.js +97 -4
  105. package/lib/messages/primitives.js.map +1 -1
  106. package/lib/model-server.d.ts +60 -13
  107. package/lib/model-server.d.ts.map +1 -1
  108. package/lib/model-server.js +4 -2
  109. package/lib/model-server.js.map +1 -1
  110. package/lib/model-service/base-version.d.ts +67 -0
  111. package/lib/model-service/base-version.d.ts.map +1 -0
  112. package/lib/model-service/base-version.js +44 -0
  113. package/lib/model-service/base-version.js.map +1 -0
  114. package/lib/model-service/index.d.ts +1 -1
  115. package/lib/model-service/index.d.ts.map +1 -1
  116. package/lib/model-service/index.js +4 -5
  117. package/lib/model-service/index.js.map +1 -1
  118. package/lib/model-service/reference-candidate.d.ts +5 -3
  119. package/lib/model-service/reference-candidate.d.ts.map +1 -1
  120. package/lib/node/index.d.ts +10 -0
  121. package/lib/node/index.d.ts.map +1 -0
  122. package/lib/node/index.js +29 -0
  123. package/lib/node/index.js.map +1 -0
  124. package/lib/node/process-memory.d.ts +66 -0
  125. package/lib/node/process-memory.d.ts.map +1 -0
  126. package/lib/node/process-memory.js +291 -0
  127. package/lib/node/process-memory.js.map +1 -0
  128. package/lib/noop-logger.d.ts.map +1 -1
  129. package/lib/noop-logger.js.map +1 -1
  130. package/lib/observable-value.js.map +1 -1
  131. package/lib/patch-merge.d.ts +63 -35
  132. package/lib/patch-merge.d.ts.map +1 -1
  133. package/lib/patch-merge.js +171 -25
  134. package/lib/patch-merge.js.map +1 -1
  135. package/lib/pending-work-tracker.d.ts +30 -0
  136. package/lib/pending-work-tracker.d.ts.map +1 -0
  137. package/lib/pending-work-tracker.js +47 -0
  138. package/lib/pending-work-tracker.js.map +1 -0
  139. package/lib/profile-session.d.ts +19 -5
  140. package/lib/profile-session.d.ts.map +1 -1
  141. package/lib/profile-session.js +10 -1
  142. package/lib/profile-session.js.map +1 -1
  143. package/lib/profiling.d.ts +15 -2
  144. package/lib/profiling.d.ts.map +1 -1
  145. package/lib/profiling.js.map +1 -1
  146. package/lib/project.d.ts +4 -1
  147. package/lib/project.d.ts.map +1 -1
  148. package/lib/project.js.map +1 -1
  149. package/lib/random-uuid.d.ts +14 -0
  150. package/lib/random-uuid.d.ts.map +1 -0
  151. package/lib/random-uuid.js +24 -0
  152. package/lib/random-uuid.js.map +1 -0
  153. package/lib/reconcile-write.d.ts +70 -0
  154. package/lib/reconcile-write.d.ts.map +1 -0
  155. package/lib/reconcile-write.js +69 -0
  156. package/lib/reconcile-write.js.map +1 -0
  157. package/lib/rpc/bind-rpc-methods.d.ts +6 -2
  158. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  159. package/lib/rpc/bind-rpc-methods.js +17 -7
  160. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  161. package/lib/rpc/create-rpc-proxy.d.ts +3 -0
  162. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  163. package/lib/rpc/create-rpc-proxy.js +6 -1
  164. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  165. package/lib/rpc/index.d.ts +1 -0
  166. package/lib/rpc/index.d.ts.map +1 -1
  167. package/lib/rpc/index.js +1 -0
  168. package/lib/rpc/index.js.map +1 -1
  169. package/lib/rpc/send-by-method-name.d.ts +76 -0
  170. package/lib/rpc/send-by-method-name.d.ts.map +1 -0
  171. package/lib/rpc/send-by-method-name.js +120 -0
  172. package/lib/rpc/send-by-method-name.js.map +1 -0
  173. package/lib/rpc/wire-prefix.js.map +1 -1
  174. package/lib/save-text-document.d.ts +40 -0
  175. package/lib/save-text-document.d.ts.map +1 -0
  176. package/lib/save-text-document.js +34 -0
  177. package/lib/save-text-document.js.map +1 -0
  178. package/lib/testing/catalogue-audit.d.ts +1 -1
  179. package/lib/testing/catalogue-audit.js +1 -1
  180. package/lib/testing/catalogue-audit.js.map +1 -1
  181. package/lib/testing/data-doubles.d.ts +41 -12
  182. package/lib/testing/data-doubles.d.ts.map +1 -1
  183. package/lib/testing/data-doubles.js +56 -8
  184. package/lib/testing/data-doubles.js.map +1 -1
  185. package/lib/testing/fake-clock.d.ts +17 -2
  186. package/lib/testing/fake-clock.d.ts.map +1 -1
  187. package/lib/testing/fake-clock.js +61 -46
  188. package/lib/testing/fake-clock.js.map +1 -1
  189. package/lib/testing/index.d.ts +1 -0
  190. package/lib/testing/index.d.ts.map +1 -1
  191. package/lib/testing/index.js +4 -3
  192. package/lib/testing/index.js.map +1 -1
  193. package/lib/testing/node/duplex-connection.d.ts.map +1 -1
  194. package/lib/testing/node/duplex-connection.js +3 -2
  195. package/lib/testing/node/duplex-connection.js.map +1 -1
  196. package/lib/testing/node/duplex-stream.js.map +1 -1
  197. package/lib/testing/node/index.d.ts +1 -0
  198. package/lib/testing/node/index.d.ts.map +1 -1
  199. package/lib/testing/node/index.js +2 -2
  200. package/lib/testing/node/index.js.map +1 -1
  201. package/lib/testing/node/message-port-pair.d.ts +25 -0
  202. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  203. package/lib/testing/node/message-port-pair.js +26 -0
  204. package/lib/testing/node/message-port-pair.js.map +1 -0
  205. package/lib/testing/transfer-node-builder.d.ts +81 -0
  206. package/lib/testing/transfer-node-builder.d.ts.map +1 -0
  207. package/lib/testing/transfer-node-builder.js +47 -0
  208. package/lib/testing/transfer-node-builder.js.map +1 -0
  209. package/lib/testing/wait-for.d.ts +9 -3
  210. package/lib/testing/wait-for.d.ts.map +1 -1
  211. package/lib/testing/wait-for.js +57 -11
  212. package/lib/testing/wait-for.js.map +1 -1
  213. package/lib/tracer.d.ts.map +1 -1
  214. package/lib/tracer.js +5 -9
  215. package/lib/tracer.js.map +1 -1
  216. package/lib/transfer-diagnostic.js.map +1 -1
  217. package/lib/transfer-document.d.ts +96 -32
  218. package/lib/transfer-document.d.ts.map +1 -1
  219. package/lib/transfer-document.js +17 -9
  220. package/lib/transfer-document.js.map +1 -1
  221. package/lib/transfer-element.d.ts +4 -4
  222. package/lib/types.d.ts +32 -0
  223. package/lib/types.d.ts.map +1 -0
  224. package/lib/{model-service/args.js → types.js} +2 -2
  225. package/lib/types.js.map +1 -0
  226. package/lib/uri.d.ts.map +1 -1
  227. package/lib/uri.js.map +1 -1
  228. package/lib/util.d.ts +8 -2
  229. package/lib/util.d.ts.map +1 -1
  230. package/lib/util.js +32 -4
  231. package/lib/util.js.map +1 -1
  232. package/package.json +24 -40
  233. package/src/abstract-logger.ts +18 -0
  234. package/src/client/data-connection.ts +654 -0
  235. package/src/client/data-events.ts +38 -1
  236. package/src/client/data-port.ts +36 -25
  237. package/src/client/data-session.ts +1476 -137
  238. package/src/client/index.ts +15 -9
  239. package/src/client/message-relay.ts +6 -4
  240. package/src/client/post-message-transport.ts +224 -4
  241. package/src/client/rpc-connection.ts +302 -0
  242. package/src/client/worker-handshake.ts +117 -0
  243. package/src/client-ids.ts +49 -0
  244. package/src/clock.ts +68 -10
  245. package/src/console-logger.ts +39 -0
  246. package/src/data/data-protocol-methods.ts +14 -4
  247. package/src/data/data-server-protocol.ts +198 -48
  248. package/src/data/events.ts +150 -33
  249. package/src/data/requests.ts +82 -11
  250. package/src/debouncer.ts +11 -11
  251. package/src/errors.ts +331 -40
  252. package/src/format-log-arg.ts +176 -0
  253. package/src/glsp-edits-settled-actions.ts +62 -0
  254. package/src/glsp-request-model-args.ts +16 -0
  255. package/src/glsp-save-model-actions.ts +64 -0
  256. package/src/index.ts +11 -0
  257. package/src/latency-collector.ts +10 -3
  258. package/src/logger.ts +44 -8
  259. package/src/messages/index.ts +4 -2
  260. package/src/messages/primitives.ts +129 -5
  261. package/src/model-server.ts +64 -19
  262. package/src/model-service/base-version.ts +75 -0
  263. package/src/model-service/index.ts +4 -5
  264. package/src/model-service/reference-candidate.ts +5 -3
  265. package/src/node/index.ts +14 -0
  266. package/src/node/process-memory.ts +299 -0
  267. package/src/patch-merge.ts +230 -45
  268. package/src/pending-work-tracker.ts +47 -0
  269. package/src/profile-session.ts +20 -5
  270. package/src/profiling.ts +15 -2
  271. package/src/project.ts +4 -1
  272. package/src/random-uuid.ts +21 -0
  273. package/src/reconcile-write.ts +131 -0
  274. package/src/rpc/README.md +6 -6
  275. package/src/rpc/bind-rpc-methods.ts +18 -8
  276. package/src/rpc/create-rpc-proxy.ts +6 -1
  277. package/src/rpc/index.ts +1 -0
  278. package/src/rpc/send-by-method-name.ts +140 -0
  279. package/src/save-text-document.ts +39 -0
  280. package/src/testing/catalogue-audit.ts +1 -1
  281. package/src/testing/data-doubles.ts +141 -19
  282. package/src/testing/fake-clock.ts +76 -48
  283. package/src/testing/index.ts +4 -3
  284. package/src/testing/node/duplex-connection.ts +3 -2
  285. package/src/testing/node/index.ts +2 -2
  286. package/src/testing/node/message-port-pair.ts +40 -0
  287. package/src/testing/transfer-node-builder.ts +107 -0
  288. package/src/testing/wait-for.ts +61 -13
  289. package/src/tracer.ts +5 -9
  290. package/src/transfer-document.ts +116 -34
  291. package/src/transfer-element.ts +4 -4
  292. package/src/types.ts +30 -0
  293. package/src/util.ts +33 -6
  294. package/lib/model-service/args.d.ts +0 -64
  295. package/lib/model-service/args.d.ts.map +0 -1
  296. package/lib/model-service/args.js.map +0 -1
  297. package/src/model-service/args.ts +0 -67
@@ -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,29 +41,100 @@ 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
+ }
94
+
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
+ }
50
108
 
51
- /** Persist a document to disk. Wire-side projection of {@link TransferSaveArgs}. */
52
- export type TransferSaveDocumentArgs<TTransfer> = TransferSaveArgs<TTransfer>;
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
+ /**
118
+ * One entry per document: a set naming one twice, by any spellings that
119
+ * share its canonical URI, is refused.
120
+ */
121
+ updates: Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>[];
122
+ }
53
123
 
54
124
  /**
55
125
  * Identifies a per-document watch on the data server. Shared by both
56
126
  * `watchModelDocument` and `unwatchModelDocument` — the `(uri, clientId)`
57
127
  * pair is the watch key, so unwatching names the same watch that was
58
128
  * 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
129
+ * on the document writes (`TransferUpdateDocumentArgs.clientId`,
130
+ * `TransferSaveDocumentArgs.clientId`): it keys the per-`(uri, clientId)`
131
+ * watch bucket so multiple watchers on the same wire stay distinct, AND it lets
62
132
  * each watcher recognise its own echo on inbound `onDocumentUpdated` events
63
133
  * (the wire shape's `sourceClientId` carries the originating mutation's
64
134
  * `clientId`).
65
135
  */
66
136
  export interface WatchModelDocumentArgs {
137
+ /** Any spelling that the document URI policy maps to the document. */
67
138
  uri: string;
68
139
  /** Stable identifier for the watching client. */
69
140
  clientId: string;
package/src/debouncer.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import { type Clock } from './clock';
10
+ import { type Clock, type Stopwatch } from './clock';
11
11
  import { ObservableValue, type MaybeObservableValue } from './observable-value';
12
12
  import { type Disposable } from './util';
13
13
 
@@ -50,11 +50,13 @@ export interface DebouncerOptions {
50
50
  * than a breaking change.
51
51
  */
52
52
  export class Debouncer implements Disposable {
53
+ /** {@link DebouncerOptions.delayMs}, read at each {@link schedule}. An armed timer keeps the delay it was armed with. */
53
54
  protected readonly delay: ObservableValue<number>;
55
+ /** {@link DebouncerOptions.maxWaitMs}, fixed at construction unlike {@link delay}. */
54
56
  protected readonly maxWaitMs?: number;
55
57
  protected timer?: Disposable;
56
- /** Virtual time of the first {@link schedule} of the current pending window; drives {@link DebouncerOptions.maxWaitMs}. */
57
- protected firstScheduledAt?: number;
58
+ /** Running since the first {@link schedule} of the current pending window; drives {@link DebouncerOptions.maxWaitMs}. */
59
+ protected sinceFirstSchedule?: Stopwatch;
58
60
 
59
61
  constructor(
60
62
  protected readonly clock: Clock,
@@ -77,20 +79,17 @@ export class Debouncer implements Disposable {
77
79
  * elapses since the first pending call.
78
80
  */
79
81
  schedule(): void {
80
- const now = this.clock.now();
81
- if (this.firstScheduledAt === undefined) {
82
- this.firstScheduledAt = now;
83
- }
82
+ this.sinceFirstSchedule ??= this.clock.stopwatch();
84
83
  let wait = Math.max(0, this.delay.value);
85
84
  if (this.maxWaitMs !== undefined) {
86
- const untilCeiling = this.firstScheduledAt + this.maxWaitMs - now;
85
+ const untilCeiling = this.maxWaitMs - this.sinceFirstSchedule.elapsedMs;
87
86
  wait = Math.min(wait, Math.max(0, untilCeiling));
88
87
  }
89
88
  this.timer?.dispose();
90
89
  this.timer = this.clock.setTimer(() => this.fire(), wait);
91
90
  }
92
91
 
93
- /** If a fire is pending, run {@link fn} now and clear the window; otherwise a no-op. */
92
+ /** Run {@link fn} now if a fire is pending, clearing the window first, and do nothing otherwise. */
94
93
  flush(): void {
95
94
  if (this.timer !== undefined) {
96
95
  this.fire();
@@ -101,7 +100,7 @@ export class Debouncer implements Disposable {
101
100
  cancel(): void {
102
101
  this.timer?.dispose();
103
102
  this.timer = undefined;
104
- this.firstScheduledAt = undefined;
103
+ this.sinceFirstSchedule = undefined;
105
104
  }
106
105
 
107
106
  /** Cancel any pending fire and release. */
@@ -109,10 +108,11 @@ export class Debouncer implements Disposable {
109
108
  this.cancel();
110
109
  }
111
110
 
111
+ /** Clears the window before it runs {@link fn}, so a {@link schedule} from inside `fn` opens a new one. */
112
112
  protected fire(): void {
113
113
  this.timer?.dispose();
114
114
  this.timer = undefined;
115
- this.firstScheduledAt = undefined;
115
+ this.sinceFirstSchedule = undefined;
116
116
  this.fn();
117
117
  }
118
118
  }
package/src/errors.ts CHANGED
@@ -9,62 +9,106 @@
9
9
 
10
10
  import { ResponseError } from 'vscode-jsonrpc';
11
11
  import { defineMessage, type HydraniumMessageData, messageData } from './messages/primitives';
12
+ import { asModelVersion, type ModelVersion, type TextVersion } from './model-service/base-version';
13
+
14
+ /*
15
+ * Every error here is a typed error: a caller reacts to it, so it has a class,
16
+ * a JSON-RPC code and an `is*` guard, and an English message. A typed error
17
+ * also carries a message identity where the framework can write an end-user
18
+ * sentence that needs no context. A URI may stay in that sentence; a client id
19
+ * or a raw version stays out of it, worded or left to `data`.
20
+ *
21
+ * An error nothing reacts to does not belong here: it stays a plain `Error`, or
22
+ * a named subclass without a code, at its throw site, since a code and a guard
23
+ * are public API that no caller would use.
24
+ */
12
25
 
13
26
  /**
14
- * The catalogue declaration behind {@link ConflictError}'s sentence.
27
+ * The catalogue declaration behind {@link ConflictError}'s sentence. It words
28
+ * the version mismatch rather than stating it: the two numbers mean nothing to
29
+ * an end user, and they stay in {@link ConflictErrorData}.
15
30
  *
16
31
  * Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
17
32
  * marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
18
33
  * That tier only ever works untranslated, which is why it is the last resort
19
34
  * behind the numeric code rather than the primary check.
20
35
  */
21
- export const STALE_BASED_UPDATE = defineMessage(
22
- 'hydranium/protocol/stale-based-update',
23
- 'Stale-based update for {uri}: expected v{expected}, server is at v{actual}'
36
+ export const STALE_BASE_VERSION_UPDATE = defineMessage(
37
+ 'hydranium/protocol/stale-base-version-update',
38
+ 'The edit to {uri} was not applied: it was made to an older version of the document.'
39
+ );
40
+
41
+ /**
42
+ * {@link STALE_BASE_VERSION_UPDATE}'s counterpart for an editor's save the
43
+ * server refused, since the editor's buffer is not the text it holds. Its
44
+ * English keeps the same marker.
45
+ */
46
+ export const STALE_BASE_VERSION_SAVE = defineMessage(
47
+ 'hydranium/protocol/stale-base-version-save',
48
+ 'The save of {uri} was not applied: it was made to an older version of the document.'
24
49
  );
25
50
 
26
51
  /**
27
- * Application-specific JSON-RPC error code for {@link ConflictError}.
28
- * Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
52
+ * Every JSON-RPC error code the framework raises, from any package, keyed by
53
+ * the error it identifies.
54
+ *
55
+ * The framework reserves the block 42000 to 42999 for these, and an adopter's
56
+ * own codes stay outside it: after an RPC a guard matches on the code alone, so
57
+ * an adopter's error carrying one of these reads as the framework's. A new code
58
+ * takes the next unused number in the block, whichever package raises it, and
59
+ * is declared here, where tests hold every code distinct and inside the block.
60
+ * The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
61
+ * to -32000.
62
+ */
63
+ export const HYDRANIUM_ERROR_CODES = {
64
+ conflict: 42001,
65
+ noActiveProfile: 42002,
66
+ referenceSettleTimeout: 42003,
67
+ sessionClosed: 42004,
68
+ documentNotOpen: 42005,
69
+ duplicateClientId: 42006,
70
+ reservedClientId: 42007
71
+ } as const;
72
+
73
+ /**
74
+ * JSON-RPC error code for {@link ConflictError}.
29
75
  *
30
76
  * The code is the load-bearing identifier across realm boundaries —
31
77
  * `code` is a first-class field on the JSON-RPC error envelope and
32
78
  * survives wire reconstruction; the custom `Error` subclass name does
33
79
  * not.
34
80
  */
35
- export const CONFLICT_ERROR_CODE = 1001;
81
+ export const CONFLICT_ERROR_CODE = HYDRANIUM_ERROR_CODES.conflict;
36
82
 
37
- /**
38
- * Structured payload carried in {@link ConflictError.data}, and the only place
39
- * a post-RPC caller can read the version mismatch from.
40
- */
83
+ /** Structured payload carried in {@link ConflictError.data}. */
41
84
  export interface ConflictErrorData extends HydraniumMessageData {
85
+ /**
86
+ * The document whose version moved. A write of several documents names
87
+ * the first stale one in request order, and others may be stale too.
88
+ */
42
89
  readonly uri: string;
43
- /** The based-on version the caller authored against. */
44
- readonly expected: number;
90
+ /** The base version the caller authored against. */
91
+ readonly baseVersion: ModelVersion;
45
92
  /** The server's current text-document version at the time of the throw. */
46
- readonly actual: number;
93
+ readonly actualVersion: TextVersion;
47
94
  }
48
95
 
49
96
  /**
50
- * Thrown by `ModelService.update` / `ModelService.save` when the caller-
51
- * supplied based-on version no longer matches the server's current text-
97
+ * Thrown by a client session's `update` / `save` when the caller-
98
+ * supplied base version no longer matches the server's current text-
52
99
  * document version for the same URI — i.e. the snapshot the caller
53
100
  * authored against has been superseded by an intervening edit.
54
101
  *
55
102
  * Extends vscode-jsonrpc's {@link ResponseError} so the typed
56
103
  * {@link ConflictErrorData} payload rides on the standard JSON-RPC
57
104
  * error envelope (`code`, `message`, `data`) — all three fields are
58
- * preserved by RPC reconstruction. Adopters that catch the error on
59
- * the receiving side of an RPC call read the version mismatch from
60
- * `err.data` (the instance is reconstructed as a generic
61
- * `ResponseError`, so subclass getters / fields do not survive).
105
+ * preserved by RPC reconstruction. `createRpcProxy` revives it into
106
+ * this class on the receiving side; a path that does not leaves a
107
+ * plain `ResponseError`, readable through `err.data` only.
62
108
  *
63
- * Detection is opt-in via the optional `baseVersion` field on
64
- * `TransferUpdateArgs` / `TransferSaveArgs`; callers that omit the field get
65
- * no gating. This mirrors LSP's `OptionalVersionedTextDocumentIdentifier`
66
- * posture, so headless / CLI / batch tooling with no meaningful based-on
67
- * version can opt out explicitly.
109
+ * Detection is driven by the required `baseVersion` field of every write
110
+ * request; a caller with no meaningful base version passes
111
+ * `'any'` and gets no gating.
68
112
  *
69
113
  * Three reasonable adopter recovery strategies:
70
114
  *
@@ -78,38 +122,283 @@ export interface ConflictErrorData extends HydraniumMessageData {
78
122
  * No auto-retry or auto-merge ships by default.
79
123
  */
80
124
  export class ConflictError extends ResponseError<ConflictErrorData> {
81
- constructor(uri: string, expected: number, actual: number) {
82
- const params = { uri, expected, actual };
125
+ /** `message` words what was refused: an edit, or with {@link STALE_BASE_VERSION_SAVE} a save. */
126
+ constructor(
127
+ uri: string,
128
+ baseVersion: ModelVersion,
129
+ actualVersion: TextVersion,
130
+ message: typeof STALE_BASE_VERSION_UPDATE | typeof STALE_BASE_VERSION_SAVE = STALE_BASE_VERSION_UPDATE
131
+ ) {
83
132
  // The identity rides alongside the typed payload rather than replacing
84
- // it: this class's getters and `isConflictError`'s name check are surface
85
- // an adopter may bind, so the payload widens rather than changing shape.
86
- super(CONFLICT_ERROR_CODE, STALE_BASED_UPDATE.format(params), { ...params, ...messageData(STALE_BASED_UPDATE, params) });
133
+ // it: `isConflictError`'s name check is surface an adopter may bind, so
134
+ // adding the identity widens the payload rather than reshaping it.
135
+ super(CONFLICT_ERROR_CODE, message.format({ uri }), {
136
+ uri,
137
+ baseVersion,
138
+ actualVersion,
139
+ ...messageData(message, { uri })
140
+ });
87
141
  this.name = 'ConflictError';
88
142
  // ResponseError's constructor calls `Object.setPrototypeOf(this,
89
143
  // ResponseError.prototype)` to keep its own prototype chain intact across
90
144
  // transpilation targets; that resets us to ResponseError, hiding the
91
145
  // ConflictError-specific getters. Restore the prototype here so
92
- // `err.uri` / `.expected` / `.actual` resolve through this class.
146
+ // `err.uri` / `.baseVersion` / `.actualVersion` resolve through this
147
+ // class.
93
148
  Object.setPrototypeOf(this, ConflictError.prototype);
94
149
  }
95
150
 
151
+ /** The document whose version moved, see {@link ConflictErrorData.uri}. */
96
152
  get uri(): string {
97
153
  return this.data!.uri;
98
154
  }
99
155
 
100
- get expected(): number {
101
- return this.data!.expected;
156
+ /**
157
+ * The base version the caller authored against. Not `expected`, and its
158
+ * sibling not `actual`: a test reporter reads that pair as an assertion
159
+ * failure and reports nothing of the real one.
160
+ */
161
+ get baseVersion(): ModelVersion {
162
+ return this.data!.baseVersion;
163
+ }
164
+
165
+ /** The server's version at the time of the throw. Not `actual`, see {@link baseVersion}. */
166
+ get actualVersion(): TextVersion {
167
+ return this.data!.actualVersion;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
173
+ * and for the same reason: the code survives reconstruction, the class does not.
174
+ */
175
+ export const SESSION_CLOSED_ERROR_CODE = HYDRANIUM_ERROR_CODES.sessionClosed;
176
+ /** JSON-RPC code for {@link DocumentNotOpenError}. */
177
+ export const DOCUMENT_NOT_OPEN_ERROR_CODE = HYDRANIUM_ERROR_CODES.documentNotOpen;
178
+ /** JSON-RPC code for {@link DuplicateClientIdError}. */
179
+ export const DUPLICATE_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.duplicateClientId;
180
+ /** JSON-RPC code for {@link ReservedClientIdError}. */
181
+ export const RESERVED_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.reservedClientId;
182
+
183
+ /**
184
+ * The catalogue declaration behind {@link SessionClosedError}'s default
185
+ * sentence. It names no client id: the sentence can reach an end user, and the
186
+ * id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
187
+ */
188
+ export const SESSION_CLOSED = defineMessage('hydranium/protocol/session-closed', 'The editing session has ended.');
189
+
190
+ /** Structured payload carried in {@link SessionClosedError.data}. */
191
+ export interface SessionClosedErrorData extends HydraniumMessageData {
192
+ readonly clientId: string;
193
+ }
194
+
195
+ /**
196
+ * Thrown by every call on a client session after it ended, and by an open that
197
+ * was still in flight when its session ended: by the server for its sessions,
198
+ * and by a client-side `DataSession` once disposed, so a caller handles both
199
+ * the same way. A caller recognises it with {@link isSessionClosedError}, never
200
+ * by its sentence.
201
+ */
202
+ export class SessionClosedError extends ResponseError<SessionClosedErrorData> {
203
+ /**
204
+ * `message` replaces the default English, for a caller that knows more than
205
+ * that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
206
+ * translating renderer renders the catalogue sentence in its place.
207
+ */
208
+ constructor(clientId: string, message = SESSION_CLOSED.format()) {
209
+ super(SESSION_CLOSED_ERROR_CODE, message, { clientId, ...messageData(SESSION_CLOSED) });
210
+ this.name = 'SessionClosedError';
211
+ // `ResponseError` resets the prototype to its own; see `ConflictError`.
212
+ Object.setPrototypeOf(this, SessionClosedError.prototype);
213
+ }
214
+
215
+ get clientId(): string {
216
+ return this.data!.clientId;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
222
+ * client id stays in {@link DocumentNotOpenErrorData.clientId}.
223
+ */
224
+ export const DOCUMENT_NOT_OPEN = defineMessage(
225
+ 'hydranium/protocol/document-not-open',
226
+ 'The document {uri} is not open in this editing session.'
227
+ );
228
+
229
+ /** Structured payload carried in {@link DocumentNotOpenError.data}. */
230
+ export interface DocumentNotOpenErrorData extends HydraniumMessageData {
231
+ readonly uri: string;
232
+ readonly clientId: string;
233
+ }
234
+
235
+ /**
236
+ * Thrown when a client session writes a document it does not have open.
237
+ *
238
+ * A session writes only what it has open, so this is the answer both to a write
239
+ * that never opened and to one whose open was closed underneath it — by the
240
+ * session itself, or by the document being deleted.
241
+ */
242
+ export class DocumentNotOpenError extends ResponseError<DocumentNotOpenErrorData> {
243
+ constructor(uri: string, clientId: string) {
244
+ super(DOCUMENT_NOT_OPEN_ERROR_CODE, DOCUMENT_NOT_OPEN.format({ uri }), {
245
+ uri,
246
+ clientId,
247
+ ...messageData(DOCUMENT_NOT_OPEN, { uri })
248
+ });
249
+ this.name = 'DocumentNotOpenError';
250
+ Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
251
+ }
252
+
253
+ get uri(): string {
254
+ return this.data!.uri;
102
255
  }
103
256
 
104
- get actual(): number {
105
- return this.data!.actual;
257
+ get clientId(): string {
258
+ return this.data!.clientId;
106
259
  }
107
260
  }
108
261
 
262
+ /**
263
+ * The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
264
+ * The client id stays in {@link DuplicateClientIdErrorData.clientId}.
265
+ */
266
+ export const DUPLICATE_CLIENT_ID = defineMessage(
267
+ 'hydranium/protocol/duplicate-client-id',
268
+ 'Could not start an editing session: its identifier is still in use by another editor.'
269
+ );
270
+
271
+ /** Structured payload carried in {@link DuplicateClientIdError.data}. */
272
+ export interface DuplicateClientIdErrorData extends HydraniumMessageData {
273
+ readonly clientId: string;
274
+ }
275
+
276
+ /**
277
+ * Thrown when a client session is started under an id that is already live in
278
+ * the process. The id frees up once its holder ends or closes its last
279
+ * document, so a caller may retry.
280
+ *
281
+ * Ids are unique process-wide because the id is also the author label on every
282
+ * version and the key a client recognises its own echoes by; two participants
283
+ * sharing one would each take the other's writes for their own.
284
+ */
285
+ export class DuplicateClientIdError extends ResponseError<DuplicateClientIdErrorData> {
286
+ constructor(clientId: string) {
287
+ super(DUPLICATE_CLIENT_ID_ERROR_CODE, DUPLICATE_CLIENT_ID.format(), { clientId, ...messageData(DUPLICATE_CLIENT_ID) });
288
+ this.name = 'DuplicateClientIdError';
289
+ Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
290
+ }
291
+
292
+ get clientId(): string {
293
+ return this.data!.clientId;
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Thrown when a client session is started under an id the framework reserves
299
+ * for one of its own participants. A reserved id never frees up, so a caller
300
+ * that retries on {@link DuplicateClientIdError} stops on this one.
301
+ *
302
+ * It carries no message identity: a host that picks a reserved id has a bug,
303
+ * and no sentence addressed to an end user is true for it.
304
+ */
305
+ export class ReservedClientIdError extends ResponseError<{ readonly clientId: string }> {
306
+ constructor(clientId: string) {
307
+ super(RESERVED_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is reserved for a framework participant`, { clientId });
308
+ this.name = 'ReservedClientIdError';
309
+ Object.setPrototypeOf(this, ReservedClientIdError.prototype);
310
+ }
311
+
312
+ get clientId(): string {
313
+ return this.data!.clientId;
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Rebuilds one typed error from the `data` that crossed the wire, or
319
+ * `undefined` when `data` lacks the fields the class reads.
320
+ */
321
+ type ProtocolErrorReviver = (data: Readonly<Record<string, unknown>>) => ResponseError<unknown> | undefined;
322
+
323
+ /** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
324
+ const PROTOCOL_ERROR_REVIVERS: ReadonlyMap<number, ProtocolErrorReviver> = new Map<number, ProtocolErrorReviver>([
325
+ [
326
+ CONFLICT_ERROR_CODE,
327
+ ({ uri, baseVersion, actualVersion }) =>
328
+ typeof uri === 'string' && typeof baseVersion === 'number' && typeof actualVersion === 'number'
329
+ ? new ConflictError(uri, asModelVersion(baseVersion), actualVersion)
330
+ : undefined
331
+ ],
332
+ [SESSION_CLOSED_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new SessionClosedError(clientId) : undefined)],
333
+ [
334
+ DOCUMENT_NOT_OPEN_ERROR_CODE,
335
+ ({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
336
+ ],
337
+ [DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
338
+ [RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
339
+ ]);
340
+
341
+ /**
342
+ * Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
343
+ * install holds several copies, and `instanceof` recognises only its own. An
344
+ * error that merely carries an integer `code` has no `toJson`, and is not one.
345
+ */
346
+ export function isResponseError(error: unknown): error is ResponseError<unknown> {
347
+ return (
348
+ error instanceof Error && 'code' in error && Number.isInteger(error.code) && 'toJson' in error && typeof error.toJson === 'function'
349
+ );
350
+ }
351
+
352
+ /**
353
+ * `error` as an instance of the typed error class its code names, with its
354
+ * message, data and stack kept, or `error` itself when its code names none or
355
+ * its data lacks the fields that class reads.
356
+ * An RPC reconstructs every rejection as a plain `ResponseError`, which has
357
+ * none of the class getters.
358
+ */
359
+ export function reviveProtocolError(error: unknown): unknown {
360
+ if (!isResponseError(error) || error.data === null || typeof error.data !== 'object') {
361
+ return error;
362
+ }
363
+ const revived = PROTOCOL_ERROR_REVIVERS.get(error.code)?.({ ...error.data });
364
+ if (!revived) {
365
+ return error;
366
+ }
367
+ return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
368
+ }
369
+
370
+ /**
371
+ * Whether `error` is a {@link SessionClosedError}: by name in-process, by code
372
+ * when it arrives as a plain `ResponseError`, through a path that does not
373
+ * {@link reviveProtocolError revive} it.
374
+ */
375
+ export function isSessionClosedError(error: unknown): error is SessionClosedError {
376
+ return hasErrorIdentity(error, 'SessionClosedError', SESSION_CLOSED_ERROR_CODE);
377
+ }
378
+
379
+ /** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
380
+ export function isDocumentNotOpenError(error: unknown): error is DocumentNotOpenError {
381
+ return hasErrorIdentity(error, 'DocumentNotOpenError', DOCUMENT_NOT_OPEN_ERROR_CODE);
382
+ }
383
+
384
+ /** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
385
+ export function isDuplicateClientIdError(error: unknown): error is DuplicateClientIdError {
386
+ return hasErrorIdentity(error, 'DuplicateClientIdError', DUPLICATE_CLIENT_ID_ERROR_CODE);
387
+ }
388
+
389
+ /** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
390
+ export function isReservedClientIdError(error: unknown): error is ReservedClientIdError {
391
+ return hasErrorIdentity(error, 'ReservedClientIdError', RESERVED_CLIENT_ID_ERROR_CODE);
392
+ }
393
+
394
+ function hasErrorIdentity(error: unknown, name: string, code: number): boolean {
395
+ return error instanceof Error && (error.name === name || (error as Partial<ResponseError<unknown>>).code === code);
396
+ }
397
+
109
398
  /** Marker substring present in every {@link ConflictError} message, used by
110
399
  * {@link isConflictError} as a fallback when a transport re-wraps the error
111
400
  * and drops the JSON-RPC code. */
112
- const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
401
+ const CONFLICT_ERROR_MESSAGE_MARKER = ': it was made to an older version of the document';
113
402
 
114
403
  /**
115
404
  * Type guard for {@link ConflictError}. Detection ladder:
@@ -120,11 +409,13 @@ const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
120
409
  * canonical wire-side check; the JSON-RPC `code` field is preserved
121
410
  * across reconstruction, so any adopter catching after an RPC call
122
411
  * hits this branch.
123
- * 3. `error.message.includes('Stale-based update for ')` — fallback
124
- * for transports that re-wrap the message and drop the code (rare).
412
+ * 3. `error.message` contains the marker the English of
413
+ * {@link STALE_BASE_VERSION_UPDATE} and
414
+ * {@link STALE_BASE_VERSION_SAVE} carries — fallback for transports
415
+ * that re-wrap the message and drop the code (rare).
125
416
  *
126
- * `instanceof ConflictError` alone would silently return `false` on the
127
- * reconstructed shape, so callers do not use it.
417
+ * `instanceof ConflictError` alone returns `false` on a rejection that was
418
+ * not {@link reviveProtocolError revived}, so callers do not use it.
128
419
  */
129
420
  export function isConflictError(error: unknown): error is ConflictError {
130
421
  if (!(error instanceof Error)) {