@serfab/cadre-core 1.19.0 → 1.19.1

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 (64) hide show
  1. package/dist/cadre-node.d.ts +65 -2
  2. package/dist/cadre-node.js +114 -2
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-read-retry.d.ts +19 -16
  5. package/dist/control-read-retry.js +22 -54
  6. package/dist/control-read-retry.js.map +1 -1
  7. package/dist/control-retry.d.ts +50 -6
  8. package/dist/control-retry.js +53 -6
  9. package/dist/control-retry.js.map +1 -1
  10. package/dist/control-write-retry.d.ts +24 -16
  11. package/dist/control-write-retry.js +58 -30
  12. package/dist/control-write-retry.js.map +1 -1
  13. package/dist/edge-node/config.d.ts +8 -2
  14. package/dist/edge-node/config.js +5 -1
  15. package/dist/edge-node/config.js.map +1 -1
  16. package/dist/edge-node/edge-join.js +2 -0
  17. package/dist/edge-node/edge-join.js.map +1 -1
  18. package/dist/edge-node/edge-node.d.ts +10 -0
  19. package/dist/edge-node/edge-node.js +52 -8
  20. package/dist/edge-node/edge-node.js.map +1 -1
  21. package/dist/edge-node/options.d.ts +11 -2
  22. package/dist/edge-node/options.js +11 -4
  23. package/dist/edge-node/options.js.map +1 -1
  24. package/dist/edge-node/platform.d.ts +15 -3
  25. package/dist/edge-node/strands.js +3 -2
  26. package/dist/edge-node/strands.js.map +1 -1
  27. package/dist/index.d.ts +4 -2
  28. package/dist/index.js +6 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/strand-database.d.ts +56 -0
  31. package/dist/strand-database.js +87 -0
  32. package/dist/strand-database.js.map +1 -1
  33. package/dist/strand-instance-manager.d.ts +67 -2
  34. package/dist/strand-instance-manager.js +105 -4
  35. package/dist/strand-instance-manager.js.map +1 -1
  36. package/dist/strand-membership-reconciler.d.ts +13 -1
  37. package/dist/strand-membership-reconciler.js +18 -7
  38. package/dist/strand-membership-reconciler.js.map +1 -1
  39. package/dist/strand-membership-writer.d.ts +16 -2
  40. package/dist/strand-membership-writer.js +54 -8
  41. package/dist/strand-membership-writer.js.map +1 -1
  42. package/dist/strand-offline.d.ts +131 -0
  43. package/dist/strand-offline.js +142 -0
  44. package/dist/strand-offline.js.map +1 -0
  45. package/dist/types.d.ts +35 -0
  46. package/dist/types.js.map +1 -1
  47. package/package.json +8 -8
  48. package/src/cadre-node.ts +11456 -11329
  49. package/src/control-read-retry.ts +22 -58
  50. package/src/control-retry.ts +54 -6
  51. package/src/control-write-retry.ts +58 -30
  52. package/src/edge-node/config.ts +11 -2
  53. package/src/edge-node/edge-join.ts +1 -0
  54. package/src/edge-node/edge-node.ts +55 -6
  55. package/src/edge-node/options.ts +20 -4
  56. package/src/edge-node/platform.ts +15 -3
  57. package/src/edge-node/strands.ts +3 -2
  58. package/src/index.ts +917 -898
  59. package/src/strand-database.ts +466 -352
  60. package/src/strand-instance-manager.ts +2210 -2092
  61. package/src/strand-membership-reconciler.ts +24 -7
  62. package/src/strand-membership-writer.ts +61 -14
  63. package/src/strand-offline.ts +247 -0
  64. package/src/types.ts +2960 -2926
@@ -4,7 +4,7 @@
4
4
  * for it. Fixed for the app's lifetime.
5
5
  */
6
6
 
7
- import type { IRawStorage, Libp2pTransports, NoiseCryptoInterface } from '@optimystic/db-p2p';
7
+ import type { IKVStore, IRawStorage, Libp2pTransports, NoiseCryptoInterface } from '@optimystic/db-p2p';
8
8
  import type { KeyStore } from '../key-store.js';
9
9
  import type { DurableSlot } from '../node-local-snapshot.js';
10
10
  import type { CadreNodeConfig } from '../types.js';
@@ -123,6 +123,17 @@ export interface EdgeNodeStorage {
123
123
  * strand stops.
124
124
  */
125
125
  rawStorage(scope: string): IRawStorage;
126
+ /**
127
+ * A strand's offline journal (`CadreNodeConfig.strandOffline.journal`), kept in the strand
128
+ * scope's own database beside its blocks: the journal's keys are all under
129
+ * `optimystic-offline/`, a node key-value namespace the platform stores apart from blocks. The
130
+ * same instance for the same scope until {@link close}, which flushes and closes it with the
131
+ * scope's handle; cadre-core asks again on every rebuild of the strand, and a second store over
132
+ * one handle would not see the first one's unflushed writes. {@link destroyScope} closes it too.
133
+ * A rejection fails the strand's build. Absent: no offline mode on this platform
134
+ * (`setStrandOfflineMode` throws `StrandOfflineUnavailableError`).
135
+ */
136
+ offlineJournal?(scope: string): Promise<IKVStore>;
126
137
  /** Delete a scope's storage. No handle on it may be open. Resolves when it is gone or was absent. */
127
138
  destroyScope(scope: string): Promise<void>;
128
139
  /**
@@ -132,8 +143,9 @@ export interface EdgeNodeStorage {
132
143
  */
133
144
  nodeLocal(): NodeLocalKv;
134
145
  /**
135
- * Flush and close the node-local store, then close every handle {@link rawStorage} opened. A
136
- * failure closing one is logged and the rest still close; the call does not reject.
146
+ * Flush and close the node-local store and every {@link offlineJournal}, then close every
147
+ * handle {@link rawStorage} opened. A failure closing one is logged and the rest still close;
148
+ * the call does not reject.
137
149
  */
138
150
  close(): Promise<void>;
139
151
  /**
@@ -40,8 +40,9 @@ export async function attachStrandWhenWritable(
40
40
  * Optimystic's cluster coordinator reports a write that could not gather enough approvals this
41
41
  * way. It is transient right after a node restarts alone: its cohort has not reconnected yet.
42
42
  *
43
- * NOTE: matched on the message because Optimystic throws a plain `Error` here. If it gains a typed
44
- * error, match on that instead — a reworded message would silently stop the retries.
43
+ * NOTE: matched on the message. Optimystic 1.20.0 raises this failure as `PromiseShortfallError` and
44
+ * keeps the sentence unchanged as a contract, so the match holds; moving to the type is the second arm
45
+ * of backlog `debt-control-write-retry-matches-the-shortfall-by-type`.
45
46
  */
46
47
  const SUPER_MAJORITY_FAILURE = /Failed to get super-majority/i;
47
48