@serfab/cadre-core 1.8.0 → 1.9.0

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 (59) hide show
  1. package/dist/cadre-node.d.ts +153 -104
  2. package/dist/cadre-node.js +227 -199
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/index.d.ts +2 -4
  5. package/dist/index.js +10 -11
  6. package/dist/index.js.map +1 -1
  7. package/dist/node-local-snapshot.d.ts +6 -4
  8. package/dist/node-local-snapshot.js +7 -3
  9. package/dist/node-local-snapshot.js.map +1 -1
  10. package/dist/peer-join-backfill.d.ts +0 -9
  11. package/dist/peer-join-backfill.js +2 -3
  12. package/dist/peer-join-backfill.js.map +1 -1
  13. package/dist/strand-formation-protocol.d.ts +0 -11
  14. package/dist/strand-formation-protocol.js +3 -4
  15. package/dist/strand-formation-protocol.js.map +1 -1
  16. package/dist/strand-fret-addrs.d.ts +54 -0
  17. package/dist/strand-fret-addrs.js +108 -0
  18. package/dist/strand-fret-addrs.js.map +1 -0
  19. package/dist/strand-instance-manager.d.ts +9 -38
  20. package/dist/strand-instance-manager.js +13 -73
  21. package/dist/strand-instance-manager.js.map +1 -1
  22. package/dist/strand-network-state-file.d.ts +12 -0
  23. package/dist/strand-network-state-file.js +38 -0
  24. package/dist/strand-network-state-file.js.map +1 -0
  25. package/dist/strand-network-state.d.ts +111 -0
  26. package/dist/strand-network-state.js +191 -0
  27. package/dist/strand-network-state.js.map +1 -0
  28. package/dist/types.d.ts +20 -23
  29. package/package.json +11 -10
  30. package/src/cadre-node.ts +238 -205
  31. package/src/index.ts +15 -55
  32. package/src/node-local-snapshot.ts +12 -7
  33. package/src/peer-join-backfill.ts +2 -3
  34. package/src/strand-formation-protocol.ts +3 -4
  35. package/src/strand-fret-addrs.ts +145 -0
  36. package/src/strand-instance-manager.ts +20 -96
  37. package/src/strand-network-state-file.ts +40 -0
  38. package/src/strand-network-state.ts +243 -0
  39. package/src/types.ts +20 -23
  40. package/dist/strand-peer-book-file.d.ts +0 -12
  41. package/dist/strand-peer-book-file.js +0 -37
  42. package/dist/strand-peer-book-file.js.map +0 -1
  43. package/dist/strand-peer-book-protocol.d.ts +0 -168
  44. package/dist/strand-peer-book-protocol.js +0 -356
  45. package/dist/strand-peer-book-protocol.js.map +0 -1
  46. package/dist/strand-peer-book-swap.d.ts +0 -104
  47. package/dist/strand-peer-book-swap.js +0 -284
  48. package/dist/strand-peer-book-swap.js.map +0 -1
  49. package/dist/strand-peer-book.d.ts +0 -159
  50. package/dist/strand-peer-book.js +0 -361
  51. package/dist/strand-peer-book.js.map +0 -1
  52. package/dist/strand-peer-observer.d.ts +0 -88
  53. package/dist/strand-peer-observer.js +0 -180
  54. package/dist/strand-peer-observer.js.map +0 -1
  55. package/src/strand-peer-book-file.ts +0 -39
  56. package/src/strand-peer-book-protocol.ts +0 -466
  57. package/src/strand-peer-book-swap.ts +0 -338
  58. package/src/strand-peer-book.ts +0 -475
  59. package/src/strand-peer-observer.ts +0 -235
package/dist/types.d.ts CHANGED
@@ -11,7 +11,7 @@ import type { SeedTrustPolicy } from './seed-trust-policy.js';
11
11
  import type { KeyStore, KeyId } from './key-store.js';
12
12
  import type { TrustedOwnerStore, TrustSource } from './trusted-owner-store.js';
13
13
  import type { BootstrapPeerStore } from './bootstrap-peer-store.js';
14
- import type { StrandPeerBookStore } from './strand-peer-book.js';
14
+ import type { StrandNetworkStateStore } from './strand-network-state.js';
15
15
  import type { EnrolledMachineStore } from './enrolled-machine-store.js';
16
16
  import type { JoinedStrandStore } from './joined-strand-store.js';
17
17
  import type { PushNotifier } from './push-notifier.js';
@@ -955,32 +955,29 @@ export interface CadreNodeConfig {
955
955
  store?: JoinedStrandStore;
956
956
  };
957
957
  /**
958
- * Node-local strand peer book (see `strand-peer-book.ts`): per strand, the strand
959
- * peers this node has met — the other parties' strand transport peers a formation
960
- * carried back, and every strand peer observed on a live connection — with their
961
- * last-known addresses. Read on every launch, hibernation resume and periodic
962
- * address refresh, so a restarted machine dials the peers it was talking to before
963
- * anything else, instead of coming back up alone (gotchoices/sereus#18). Sibling
964
- * of {@link bootstrapPeers} — same NON-replicated, per-party, injected-backend
965
- * shape — and, like it, nothing here is trust-bearing: dial hints only, each
966
- * bound to its peer id. Entries age out after 14 days (`STRAND_PEER_MAX_AGE_MS`,
967
- * overridable per store via `StrandPeerBookOptions.maxAgeMs`).
968
- *
969
- * Absent ⇒ an in-memory store is created at start() (ephemeral: the book dies
970
- * with the process, and a cross-party strand whose only contact was the other
971
- * party does not re-mesh after a restart until a fresh formation). Every
972
- * reference embedder injects a durable backend over the same slot kind as its
973
- * bootstrap-peer store. A new platform needs no new store class: supply a
974
- * `DurableSlot` and inject `PersistentStrandPeerBookStore.open(slot, partyId)`.
975
- */
976
- strandPeers?: {
958
+ * Node-local strand network state (see `strand-network-state.ts`): per strand, the
959
+ * state Optimystic's db-p2p saves for the strand's libp2p node — its FRET routing
960
+ * table, each entry carrying the peer's signed address record. A strand node reads
961
+ * it back when it is built and re-imports the table, so a restarted machine already
962
+ * holds addresses for the strand peers it was talking to (gotchoices/sereus#18).
963
+ * Sibling of {@link bootstrapPeers} — same NON-replicated, per-party,
964
+ * injected-backend shape — and, like it, nothing here is trust-bearing: FRET
965
+ * verifies every record at import.
966
+ *
967
+ * Absent ⇒ an in-memory store is created at start() (ephemeral: a restarted process
968
+ * starts every strand with an empty routing table). Every reference embedder
969
+ * injects a durable backend over the same slot kind as its bootstrap-peer store. A
970
+ * new platform needs no new store class: supply a `DurableSlot` and inject
971
+ * `PersistentStrandNetworkStateStore.open(slot, partyId)`.
972
+ */
973
+ strandNetworkState?: {
977
974
  /**
978
- * Injected store instance — e.g. a `FileStrandPeerBookStore` from the
979
- * Node-only subpath `@serfab/cadre-core/strand-peer-book-file`, persisted in
975
+ * Injected store instance — e.g. a `FileStrandNetworkStateStore` from the
976
+ * Node-only subpath `@serfab/cadre-core/strand-network-state-file`, persisted in
980
977
  * the node's state directory. Its `partyId` must match
981
978
  * `controlNetwork.partyId`; start() fails closed on a mismatch.
982
979
  */
983
- store?: StrandPeerBookStore;
980
+ store?: StrandNetworkStateStore;
984
981
  };
985
982
  /**
986
983
  * Platform push-delivery for suspended mobile peers. When present, the node's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serfab/cadre-core",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "type": "module",
5
5
  "description": "Core library for Sereus cadre nodes - manages control networks and strand participation",
6
6
  "main": "dist/index.js",
@@ -36,9 +36,9 @@
36
36
  "types": "./dist/enrolled-machine-store-file.d.ts",
37
37
  "import": "./dist/enrolled-machine-store-file.js"
38
38
  },
39
- "./strand-peer-book-file": {
40
- "types": "./dist/strand-peer-book-file.d.ts",
41
- "import": "./dist/strand-peer-book-file.js"
39
+ "./strand-network-state-file": {
40
+ "types": "./dist/strand-network-state-file.d.ts",
41
+ "import": "./dist/strand-network-state-file.js"
42
42
  },
43
43
  "./push-node": {
44
44
  "types": "./dist/push-node.d.ts",
@@ -77,7 +77,7 @@
77
77
  "@libp2p/tcp": "^11.0.10",
78
78
  "@libp2p/webrtc": "6.0.14",
79
79
  "@libp2p/websockets": "^10.1.3",
80
- "@optimystic/db-p2p-storage-fs": "^1.8.0",
80
+ "@optimystic/db-p2p-storage-fs": "^1.8.1",
81
81
  "@types/debug": "^4.1.12",
82
82
  "@types/node": "^25.0.10",
83
83
  "@vitest/coverage-v8": "^4.0.17",
@@ -91,13 +91,14 @@
91
91
  "@libp2p/crypto": "^5.1.13",
92
92
  "@libp2p/interface": "^3.1.0",
93
93
  "@libp2p/peer-id": "^6.0.4",
94
+ "@libp2p/peer-record": "^9.0.5",
94
95
  "@multiformats/multiaddr": "^12.5.1",
95
- "@optimystic/db-core": "^1.8.0",
96
- "@optimystic/db-p2p": "^1.8.0",
97
- "@optimystic/quereus-plugin-crypto": "^1.8.0",
98
- "@optimystic/quereus-plugin-optimystic": "^1.8.0",
96
+ "@optimystic/db-core": "^1.8.1",
97
+ "@optimystic/db-p2p": "^1.8.1",
98
+ "@optimystic/quereus-plugin-crypto": "^1.8.1",
99
+ "@optimystic/quereus-plugin-optimystic": "^1.8.1",
99
100
  "@quereus/quereus": "^4.20.0",
100
- "@serfab/quereus-plugin-sereus": "^1.8.0",
101
+ "@serfab/quereus-plugin-sereus": "^1.9.0",
101
102
  "debug": "^4.4.3",
102
103
  "libp2p": "^3.1.3",
103
104
  "uint8arrays": "^5.1.0"