@serfab/cadre-core 1.23.0 → 1.24.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 (313) hide show
  1. package/README.md +216 -294
  2. package/dist/arachnode-stub.d.ts +12 -4
  3. package/dist/arachnode-stub.js +15 -8
  4. package/dist/arachnode-stub.js.map +1 -1
  5. package/dist/cadre-invite-protocol.js +5 -4
  6. package/dist/cadre-invite-protocol.js.map +1 -1
  7. package/dist/cadre-node.d.ts +145 -44
  8. package/dist/cadre-node.js +239 -79
  9. package/dist/cadre-node.js.map +1 -1
  10. package/dist/control-authorization.d.ts +14 -2
  11. package/dist/control-authorization.js +8 -3
  12. package/dist/control-authorization.js.map +1 -1
  13. package/dist/control-cohort.d.ts +27 -13
  14. package/dist/control-cohort.js +21 -14
  15. package/dist/control-cohort.js.map +1 -1
  16. package/dist/control-database.d.ts +18 -16
  17. package/dist/control-database.js +57 -22
  18. package/dist/control-database.js.map +1 -1
  19. package/dist/control-protocol-guard.d.ts +1 -1
  20. package/dist/control-protocol-guard.js +7 -3
  21. package/dist/control-protocol-guard.js.map +1 -1
  22. package/dist/control-read-retry.d.ts +49 -11
  23. package/dist/control-read-retry.js +56 -15
  24. package/dist/control-read-retry.js.map +1 -1
  25. package/dist/control-retry.d.ts +32 -3
  26. package/dist/control-retry.js +35 -4
  27. package/dist/control-retry.js.map +1 -1
  28. package/dist/control-schema-version.d.ts +5 -5
  29. package/dist/control-schema-version.js +5 -5
  30. package/dist/control-schema-version.js.map +1 -1
  31. package/dist/control-schema.d.ts +5 -5
  32. package/dist/control-schema.js +1032 -1011
  33. package/dist/control-schema.js.map +1 -1
  34. package/dist/control-write-retry.d.ts +54 -65
  35. package/dist/control-write-retry.js +134 -158
  36. package/dist/control-write-retry.js.map +1 -1
  37. package/dist/delegate-admission.d.ts +1 -1
  38. package/dist/delegate-admission.js +1 -1
  39. package/dist/edge-node/config.d.ts +4 -3
  40. package/dist/edge-node/config.js +11 -9
  41. package/dist/edge-node/config.js.map +1 -1
  42. package/dist/edge-node/dissolve.d.ts +4 -4
  43. package/dist/edge-node/dissolve.js +4 -4
  44. package/dist/edge-node/edge-join.d.ts +1 -1
  45. package/dist/edge-node/edge-join.js +1 -1
  46. package/dist/edge-node/edge-node.js +2 -2
  47. package/dist/edge-node/edge-node.js.map +1 -1
  48. package/dist/edge-node/index.d.ts +1 -0
  49. package/dist/edge-node/index.js +1 -0
  50. package/dist/edge-node/index.js.map +1 -1
  51. package/dist/edge-node/join-credential.d.ts +1 -1
  52. package/dist/edge-node/join-credential.js +1 -1
  53. package/dist/edge-node/lazy-raw-storage.js +12 -0
  54. package/dist/edge-node/lazy-raw-storage.js.map +1 -1
  55. package/dist/edge-node/listen-addrs.d.ts +21 -0
  56. package/dist/edge-node/listen-addrs.js +25 -0
  57. package/dist/edge-node/listen-addrs.js.map +1 -0
  58. package/dist/edge-node/owner-grant.d.ts +1 -1
  59. package/dist/edge-node/owner-grant.js +1 -1
  60. package/dist/edge-node/platform.d.ts +5 -4
  61. package/dist/edge-node/platform.js.map +1 -1
  62. package/dist/edge-node/strand-move.d.ts +1 -1
  63. package/dist/edge-node/strand-move.js +1 -1
  64. package/dist/edge-node/strands.js +27 -11
  65. package/dist/edge-node/strands.js.map +1 -1
  66. package/dist/index.d.ts +7 -5
  67. package/dist/index.js +18 -7
  68. package/dist/index.js.map +1 -1
  69. package/dist/invitation-bootstrap.d.ts +28 -5
  70. package/dist/invitation-bootstrap.js +41 -8
  71. package/dist/invitation-bootstrap.js.map +1 -1
  72. package/dist/link-budget.d.ts +53 -4
  73. package/dist/link-budget.js +58 -5
  74. package/dist/link-budget.js.map +1 -1
  75. package/dist/machine-removal.d.ts +2 -2
  76. package/dist/machine-removal.js +4 -3
  77. package/dist/machine-removal.js.map +1 -1
  78. package/dist/membership-connection-gater.d.ts +2 -2
  79. package/dist/membership-connection-gater.js +2 -2
  80. package/dist/membership-view.d.ts +2 -2
  81. package/dist/membership-view.js +2 -2
  82. package/dist/node-claim-payload.d.ts +15 -7
  83. package/dist/node-claim-payload.js +25 -9
  84. package/dist/node-claim-payload.js.map +1 -1
  85. package/dist/node-class.d.ts +36 -0
  86. package/dist/node-class.js +26 -0
  87. package/dist/node-class.js.map +1 -0
  88. package/dist/node-default-transports.d.ts +50 -3
  89. package/dist/node-default-transports.js +48 -3
  90. package/dist/node-default-transports.js.map +1 -1
  91. package/dist/node-roles.d.ts +118 -0
  92. package/dist/node-roles.js +142 -0
  93. package/dist/node-roles.js.map +1 -0
  94. package/dist/node-transports.d.ts +6 -2
  95. package/dist/node-transports.js +39 -7
  96. package/dist/node-transports.js.map +1 -1
  97. package/dist/owner-anchor-sync.js +1 -1
  98. package/dist/owner-key-export.js +1 -1
  99. package/dist/owner-key-flows.d.ts +1 -1
  100. package/dist/owner-key-store.js +1 -1
  101. package/dist/owner-signer.js +1 -1
  102. package/dist/peer-authorization.d.ts +3 -1
  103. package/dist/peer-authorization.js +3 -1
  104. package/dist/peer-authorization.js.map +1 -1
  105. package/dist/peer-dial.d.ts +74 -10
  106. package/dist/peer-dial.js +89 -17
  107. package/dist/peer-dial.js.map +1 -1
  108. package/dist/peer-join-backfill.js +4 -4
  109. package/dist/peer-join-backfill.js.map +1 -1
  110. package/dist/peer-record.d.ts +34 -9
  111. package/dist/peer-record.js +66 -13
  112. package/dist/peer-record.js.map +1 -1
  113. package/dist/pending-join-runner.d.ts +1 -1
  114. package/dist/pending-join-runner.js +1 -1
  115. package/dist/provider/client.d.ts +6 -5
  116. package/dist/provider/client.js +3 -3
  117. package/dist/provider/client.js.map +1 -1
  118. package/dist/provider/descriptor.d.ts +1 -1
  119. package/dist/provider/descriptor.js +1 -1
  120. package/dist/provider/oauth.d.ts +1 -1
  121. package/dist/provider/oauth.js +1 -1
  122. package/dist/provider/rent-node.d.ts +4 -3
  123. package/dist/provider/rent-node.js +3 -3
  124. package/dist/provider/rent-node.js.map +1 -1
  125. package/dist/relay-addrs.d.ts +62 -7
  126. package/dist/relay-addrs.js +74 -11
  127. package/dist/relay-addrs.js.map +1 -1
  128. package/dist/relay-reservation.d.ts +1 -1
  129. package/dist/relay-reservation.js +1 -1
  130. package/dist/relay-server.d.ts +6 -5
  131. package/dist/relay-server.js +5 -5
  132. package/dist/relay-server.js.map +1 -1
  133. package/dist/schema-verification.d.ts +13 -10
  134. package/dist/schema-verification.js +32 -24
  135. package/dist/schema-verification.js.map +1 -1
  136. package/dist/sealed-party-key.js +1 -1
  137. package/dist/seed-bootstrap.d.ts +4 -3
  138. package/dist/seed-bootstrap.js +6 -7
  139. package/dist/seed-bootstrap.js.map +1 -1
  140. package/dist/strand-addr-protocol.d.ts +8 -6
  141. package/dist/strand-addr-protocol.js +12 -10
  142. package/dist/strand-addr-protocol.js.map +1 -1
  143. package/dist/strand-app-schema-report.d.ts +16 -2
  144. package/dist/strand-app-schema-report.js +15 -0
  145. package/dist/strand-app-schema-report.js.map +1 -1
  146. package/dist/strand-cohort.d.ts +1 -4
  147. package/dist/strand-cohort.js.map +1 -1
  148. package/dist/strand-commit-durability.d.ts +1 -1
  149. package/dist/strand-database.d.ts +13 -6
  150. package/dist/strand-database.js +17 -9
  151. package/dist/strand-database.js.map +1 -1
  152. package/dist/strand-first-sync-gate.d.ts +3 -2
  153. package/dist/strand-first-sync-gate.js +3 -2
  154. package/dist/strand-first-sync-gate.js.map +1 -1
  155. package/dist/strand-formation-deadlines.d.ts +2 -2
  156. package/dist/strand-formation-deadlines.js +2 -2
  157. package/dist/strand-formation-protocol.d.ts +1 -1
  158. package/dist/strand-formation-protocol.js +51 -16
  159. package/dist/strand-formation-protocol.js.map +1 -1
  160. package/dist/strand-instance-manager.d.ts +67 -33
  161. package/dist/strand-instance-manager.js +164 -55
  162. package/dist/strand-instance-manager.js.map +1 -1
  163. package/dist/strand-membership-reconciler.d.ts +8 -3
  164. package/dist/strand-membership-reconciler.js +8 -3
  165. package/dist/strand-membership-reconciler.js.map +1 -1
  166. package/dist/strand-membership-writer.d.ts +2 -2
  167. package/dist/strand-membership-writer.js +41 -39
  168. package/dist/strand-membership-writer.js.map +1 -1
  169. package/dist/strand-move.js +1 -1
  170. package/dist/strand-network-config.d.ts +15 -5
  171. package/dist/strand-network-config.js +7 -6
  172. package/dist/strand-network-config.js.map +1 -1
  173. package/dist/strand-party-key-rotation.d.ts +7 -3
  174. package/dist/strand-party-key-rotation.js +7 -3
  175. package/dist/strand-party-key-rotation.js.map +1 -1
  176. package/dist/strand-party-machines.d.ts +19 -8
  177. package/dist/strand-party-machines.js +26 -11
  178. package/dist/strand-party-machines.js.map +1 -1
  179. package/dist/strand-party-peers.d.ts +36 -14
  180. package/dist/strand-party-peers.js +24 -15
  181. package/dist/strand-party-peers.js.map +1 -1
  182. package/dist/strand-peer-redial.d.ts +1 -1
  183. package/dist/strand-peer-redial.js +1 -1
  184. package/dist/strand-reactivity.d.ts +20 -17
  185. package/dist/strand-reactivity.js +31 -18
  186. package/dist/strand-reactivity.js.map +1 -1
  187. package/dist/strand-revocation-enforcer.d.ts +3 -3
  188. package/dist/strand-revocation-enforcer.js +3 -3
  189. package/dist/strand-wake-protocol.d.ts +19 -7
  190. package/dist/strand-wake-protocol.js +22 -10
  191. package/dist/strand-wake-protocol.js.map +1 -1
  192. package/dist/strand-watcher.d.ts +1 -1
  193. package/dist/strand-watcher.js +1 -1
  194. package/dist/table-change-watch.js +1 -1
  195. package/dist/types.d.ts +116 -55
  196. package/dist/types.js.map +1 -1
  197. package/dist/webrtc-upgrade.d.ts +254 -0
  198. package/dist/webrtc-upgrade.js +355 -0
  199. package/dist/webrtc-upgrade.js.map +1 -0
  200. package/package.json +9 -9
  201. package/src/announce-addrs.ts +93 -93
  202. package/src/arachnode-stub.ts +18 -10
  203. package/src/bootstrap-peer-store-file.ts +44 -44
  204. package/src/bootstrap-peer-store.ts +214 -214
  205. package/src/cadre-invite-protocol.ts +741 -740
  206. package/src/cadre-node.ts +12462 -12280
  207. package/src/claim-proof.ts +147 -147
  208. package/src/control-authorization.ts +290 -276
  209. package/src/control-cohort.ts +223 -204
  210. package/src/control-database.ts +72 -28
  211. package/src/control-formation-recorder.ts +359 -359
  212. package/src/control-protocol-guard.ts +370 -366
  213. package/src/control-read-retry.ts +222 -180
  214. package/src/control-retry.ts +36 -4
  215. package/src/control-schema-version.ts +301 -301
  216. package/src/control-schema.ts +1108 -1087
  217. package/src/control-write-retry.ts +639 -669
  218. package/src/delegate-admission.ts +351 -351
  219. package/src/describe-thrown.ts +60 -60
  220. package/src/ed25519-key.ts +185 -185
  221. package/src/edge-node/config.ts +13 -10
  222. package/src/edge-node/dissolve.ts +252 -252
  223. package/src/edge-node/edge-join.ts +320 -320
  224. package/src/edge-node/edge-node.ts +1095 -1095
  225. package/src/edge-node/index.ts +60 -59
  226. package/src/edge-node/join-credential.ts +16 -16
  227. package/src/edge-node/lazy-raw-storage.ts +194 -178
  228. package/src/edge-node/listen-addrs.ts +26 -0
  229. package/src/edge-node/node-local.ts +84 -84
  230. package/src/edge-node/options.ts +195 -195
  231. package/src/edge-node/owner-grant.ts +63 -63
  232. package/src/edge-node/platform.ts +5 -4
  233. package/src/edge-node/strand-move.ts +266 -266
  234. package/src/edge-node/strands.ts +27 -12
  235. package/src/enrolled-machine-store-file.ts +43 -43
  236. package/src/enrolled-machine-store.ts +280 -280
  237. package/src/fetch-impl.ts +23 -23
  238. package/src/file-durable-slot.ts +64 -64
  239. package/src/file-safe-name.ts +32 -32
  240. package/src/formation-approval.ts +604 -604
  241. package/src/formation-token.ts +63 -63
  242. package/src/fs-atomic.ts +92 -92
  243. package/src/index.ts +987 -957
  244. package/src/invitation-bootstrap.ts +152 -118
  245. package/src/joined-strand-store.ts +553 -553
  246. package/src/key-store-file.ts +142 -142
  247. package/src/link-budget.ts +61 -5
  248. package/src/machine-removal.ts +211 -210
  249. package/src/member-redemption.ts +643 -643
  250. package/src/membership-connection-gater.ts +650 -650
  251. package/src/membership-view.ts +147 -147
  252. package/src/node-claim-payload.ts +34 -12
  253. package/src/node-class.ts +47 -0
  254. package/src/node-default-transports.ts +65 -3
  255. package/src/node-roles.ts +220 -0
  256. package/src/node-transports.ts +86 -49
  257. package/src/owner-anchor-sync.ts +172 -172
  258. package/src/owner-grant-protocol.ts +547 -547
  259. package/src/owner-key-export.ts +348 -348
  260. package/src/owner-key-flows.ts +109 -109
  261. package/src/owner-key-store.ts +1 -1
  262. package/src/owner-keys.ts +179 -179
  263. package/src/owner-signer.ts +92 -92
  264. package/src/peer-addr-book.ts +252 -252
  265. package/src/peer-authorization.ts +584 -582
  266. package/src/peer-dial.ts +698 -605
  267. package/src/peer-join-backfill.ts +961 -961
  268. package/src/peer-record.ts +71 -16
  269. package/src/pending-join-runner.ts +798 -798
  270. package/src/primary-lan-address.ts +47 -47
  271. package/src/provider/client.ts +327 -326
  272. package/src/provider/descriptor.ts +129 -129
  273. package/src/provider/index.ts +59 -59
  274. package/src/provider/oauth.ts +285 -285
  275. package/src/provider/rent-node.ts +276 -275
  276. package/src/relay-addrs.ts +90 -12
  277. package/src/relay-reservation.ts +1 -1
  278. package/src/relay-server.ts +99 -98
  279. package/src/schema-verification.ts +38 -23
  280. package/src/sealed-party-key.ts +190 -190
  281. package/src/seed-bootstrap.ts +8 -11
  282. package/src/seed-trust-policy.ts +353 -353
  283. package/src/self-address-update.ts +19 -19
  284. package/src/strand-addr-protocol.ts +17 -14
  285. package/src/strand-app-schema-report.ts +147 -122
  286. package/src/strand-cohort.ts +1 -5
  287. package/src/strand-commit-durability.ts +165 -165
  288. package/src/strand-database.ts +522 -510
  289. package/src/strand-first-sync-gate.ts +3 -2
  290. package/src/strand-formation-deadlines.ts +227 -227
  291. package/src/strand-formation-manager.ts +731 -731
  292. package/src/strand-formation-protocol.ts +1174 -1138
  293. package/src/strand-fret-addrs.ts +179 -179
  294. package/src/strand-instance-manager.ts +188 -63
  295. package/src/strand-membership-reconciler.ts +1315 -1310
  296. package/src/strand-membership-writer.ts +2152 -2150
  297. package/src/strand-move.ts +1 -1
  298. package/src/strand-network-config.ts +16 -6
  299. package/src/strand-offline.ts +178 -178
  300. package/src/strand-party-key-rotation.ts +440 -436
  301. package/src/strand-party-machines.ts +308 -293
  302. package/src/strand-party-peers.ts +151 -129
  303. package/src/strand-peer-redial.ts +1 -1
  304. package/src/strand-reactivity.ts +36 -19
  305. package/src/strand-revocation-enforcer.ts +758 -758
  306. package/src/strand-wake-protocol.ts +406 -394
  307. package/src/strand-watcher.ts +1 -1
  308. package/src/table-change-watch.ts +285 -285
  309. package/src/timed-step.ts +28 -28
  310. package/src/timeout-scheduler.ts +29 -29
  311. package/src/trusted-owner-store.ts +242 -242
  312. package/src/types.ts +3182 -3121
  313. package/src/webrtc-upgrade.ts +439 -0
package/README.md CHANGED
@@ -1,294 +1,216 @@
1
- # @serfab/cadre-core
2
-
3
- Core library for Sereus cadre nodes—the infrastructure that enables parties to manage their personal cluster of nodes participating in distributed strand networks.
4
-
5
- ## Why Sereus Cadre Core?
6
-
7
- In traditional distributed systems, users depend on centralized services to manage their data and identities. **Sereus** inverts this model: each user (or "party") controls their own **cadre**—a personal cluster of nodes ranging from always-on cloud servers to intermittently-connected mobile devices.
8
-
9
- The cadre architecture provides:
10
-
11
- - **Sovereignty**: Your data lives on your nodes, under your control
12
- - **Resilience**: Multiple nodes means no single point of failure
13
- - **Flexibility**: Mix cloud servers, home NAS, laptops, and phones
14
- - **Privacy**: Cryptographic authorization without central servers
15
-
16
- A cadre doesn't exist in isolation. Cadres participate in **strands**—shared data spaces where multiple parties collaborate. When you join a messaging app, your cadre joins that strand. When you share a document, you're creating a strand between your cadre and theirs.
17
-
18
- ## Architecture Overview
19
-
20
- ```
21
- ┌─────────────────────────────────────────────────────────────────────────┐
22
- │ Your Cadre │
23
- │ │
24
- │ ┌────────────────────────────────────────────────────────────────────┐ │
25
- │ │ Control Network │ │
26
- │ │ (Private Optimystic DB for cadre management) │ │
27
- │ │ │ │
28
- │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
29
- │ │ │ Phone │──│ Laptop │──│ Cloud │──│ NAS │ │ │
30
- │ │ │ (edge) │ │ (edge) │ │ (core) │ │ (core) │ │ │
31
- │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
32
- │ └────────────────────────────────────────────────────────────────────┘ │
33
- │ │ │
34
- │ ┌─────────────────────┼─────────────────────┐ │
35
- │ ▼ ▼ ▼ │
36
- │ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
37
- │ │ Strand A │ │ Strand B │ │ Strand C │ │
38
- │ │ (Chat App) │ │ (Shared Docs) │ │ (Photo Backup) │ │
39
- │ └──────────────────┘ └──────────────────┘ └──────────────────┘ │
40
- └─────────────────────────────────────────────────────────────────────────┘
41
- ```
42
-
43
- Each `CadreNode` instance:
44
- 1. **Connects to the control network** - A private Optimystic database shared only by your nodes
45
- 2. **Watches for strand changes** - Automatically detects when you join or leave strands
46
- 3. **Manages strand instances** - Spins up isolated libp2p networks for each strand
47
- 4. **Handles peer enrollment** - Cryptographically authorizes new devices to join your cadre
48
-
49
- ## Installation
50
-
51
- ```bash
52
- npm install @serfab/cadre-core
53
- ```
54
-
55
- ## Quick Start
56
-
57
- ```typescript
58
- import { CadreNode } from '@serfab/cadre-core';
59
- import { FileRawStorage } from '@optimystic/db-p2p-storage-fs';
60
-
61
- const node = new CadreNode({
62
- controlNetwork: {
63
- partyId: 'your-unique-party-id',
64
- bootstrapNodes: ['/ip4/192.168.1.100/tcp/4001/p2p/12D3KooW...']
65
- },
66
- profile: 'storage', // 'storage' for servers, 'transaction' for mobile
67
- storage: {
68
- // Storage provider factory - called once per scope (each strand id, plus this
69
- // party's control database) for per-scope isolation
70
- provider: (scope) => new FileRawStorage(`/data/sereus/${scope}`),
71
- quotaBytes: 10 * 1024 * 1024 * 1024 // 10 GB
72
- }
73
- });
74
-
75
- // Start the node
76
- await node.start();
77
- console.log('Node started with Peer ID:', node.peerId?.toString());
78
-
79
- // Listen for strand events
80
- node.on('strand:started', ({ strandId }) => {
81
- console.log('Joined strand:', strandId);
82
- });
83
-
84
- // Check active strands
85
- for (const [id, strand] of node.getStrands()) {
86
- console.log(`Strand ${id}: ${strand.status}, ${strand.connectedPeers} peers`);
87
- }
88
-
89
- // Graceful shutdown
90
- await node.stop();
91
- ```
92
-
93
- ## Node Profiles
94
-
95
- | Profile | Storage Role | Use Case | Ring Zulu |
96
- |---------|--------------|----------|-----------|
97
- | **transaction** | Arachnode disabled; transaction verification via FRET only | Mobile devices, intermittent connectivity | No |
98
- | **storage** | Ring Zulu + storage rings (storage rings not yet implemented — stub) | Servers, NAS, always-on nodes | Yes |
99
-
100
- Transaction-profile nodes verify transactions via FRET only, with Arachnode disabled. Storage-profile nodes additionally join Ring Zulu and (when implemented) the concentric storage rings.
101
-
102
- > **Note:** The storage-ring subsystem is currently a no-op stub (`arachnode-stub.ts`). See [Node Profiles in `docs/architecture.md`](../../docs/architecture.md#node-profiles) for the full design.
103
-
104
- ## Strand Filtering
105
-
106
- Mobile apps typically shouldn't participate in all strands. Use filters to control participation:
107
-
108
- ```typescript
109
- // Only participate in strands for a specific app
110
- strandFilter: { mode: 'sAppId', sAppId: 'com.example.chat' }
111
-
112
- // Only participate in one specific strand
113
- strandFilter: { mode: 'strandId', strandId: 'strand-abc123' }
114
-
115
- // Control network only, no strand participation
116
- strandFilter: { mode: 'none' }
117
-
118
- // Participate in all strands (default for servers)
119
- strandFilter: { mode: 'all' }
120
- ```
121
-
122
- ## Enrolling New Devices
123
-
124
- Adding a new device to your cadre uses the Seed Bootstrap API:
125
-
126
- ```typescript
127
- // On the new device: generate identity
128
- const enrollment = new EnrollmentService();
129
- const { peerId, privateKey } = await enrollment.createCadrePeer();
130
- // Store privateKey securely, send peerId + multiaddrs to owner
131
-
132
- // On owner device: authorize the new peer and create seed
133
- await node.authorizePeer(newDevicePeerId, newDeviceMultiaddrs);
134
- const seed = await node.createSeed();
135
-
136
- // Deliver seed to new device (via protocol, API, or out-of-band)
137
- await node.deliverSeed(newDeviceMultiaddr, seed);
138
- // Or encode for QR/link: const encoded = node.encodeSeed(seed);
139
-
140
- // On new device: apply seed to join cadre
141
- const result = await newNode.applySeed(seed);
142
- ```
143
-
144
- For a machine whose peer id and addresses you already have, use the helper (`cadre enroll add` runs it on the owner node):
145
-
146
- ```typescript
147
- // One call: authorize + create seed
148
- const { seed, encodedSeed } = await node.addDrone({ dronePeerId, droneMultiaddrs });
149
-
150
- // The new machine starts with it: `cadre start --seed <encodedSeed> --pin-owner-key <owner key>`
151
-
152
- // Await the dial of the drone from the addresses addDrone kept (a drone cannot
153
- // dial a phone); the row insert starts a pass that dials it anyway, about 50 ms
154
- // later, and retries a failed dial after 15 s, 30 s, 60 s, then every 2 minutes
155
- await node.reconcileControlCohort();
156
- ```
157
-
158
- A provider-hosted node is added with `rentNode` instead (below).
159
-
160
- ### Renting a provider node
161
-
162
- An app rents an always-on node from a hosting provider with `rentNode`, which adds the container to this node's cadre by invitation when a member is reachable from anywhere and by claim otherwise ([architecture.md → Renting a node from an app](../../docs/architecture.md#renting-a-node-from-an-app)). Everything it needs loads on React Native and in the browser:
163
-
164
- ```typescript
165
- import { createProviderClient, createTokenSource, fetchProviderDescriptor, rentNode } from '@serfab/cadre-core';
166
-
167
- const descriptor = await fetchProviderDescriptor('https://nodes.acme.example/api/v1/descriptor');
168
- // `stored` comes from the PKCE sign-in (createPkce, authorizationUrl, readAuthorizationRedirect,
169
- // exchangeAuthorizationCode) or from the app's own store; `save` writes each refreshed pair back
170
- const tokens = createTokenSource({ descriptor, clientId: 'my-app', tokens: stored, persist: save });
171
- const client = createProviderClient({ apiBaseUrl: descriptor.apiBaseUrl, tokens });
172
-
173
- const rental = await rentNode(node, client, { onProgress: (step) => console.log(step) });
174
- // rental.join: 'invitation' (the container joins by itself; watch client.getContainer(id).join)
175
- // or 'claim' (the node is in the cadre when rentNode returns, rental.peerId names it).
176
- // Keep rental.containerId: finishRental(node, client, containerId) resumes a rental the app
177
- // was killed in the middle of, and the container is what the provider bills.
178
- ```
179
-
180
- ## API Reference
181
-
182
- ### CadreNode
183
-
184
- The main entry point for cadre participation.
185
-
186
- | Method | Description |
187
- |--------|-------------|
188
- | `start()` | Connect to control network and begin strand participation |
189
- | `stop()` | Gracefully disconnect from all networks |
190
- | `getStrands()` | Get all active strand instances |
191
- | `getStrand(id)` | Get a specific strand instance |
192
- | `foundStrand(config)` | **Create a strand**: publish its `Strand` row and start it locally as founder, in one call that is safe to re-run after an interruption. Returns the instance plus the row it actually runs under — for a closed strand read the membership key from there, since a resumed founding keeps the stored key |
193
- | `addStrand(row)` | Attach only — start a local instance for a row that already exists (the join path; also testing/direct API). Does **not** publish |
194
- | `stopStrand(id)` | Stop a strand on this node only (the shared `Strand` row stays; rediscovered on restart) |
195
- | `publishStrand(id, type?, memberKey?)` | Owner-signed `Strand` row insert — makes the strand visible cadre-wide. Idempotent: a live row with the same `(Type, MemberPrivateKey)` is returned unwritten; different content on the same id throws. Prefer `foundStrand` when creating a strand |
196
- | `unpublishStrand(id)` | Owner-signed party-wide removal — deletes this party's `Strand` row; every node stops the strand. Destroys a closed strand's `MemberPrivateKey` |
197
- | `getEnrollmentService()` | Access peer enrollment API |
198
- | `isOwner()` | Whether this node can act as an owner of its cadre: an owner key is wired for signing (`useOwnerSigner`) and is a live `OwnerKey` row; never the node's identity key. The gate the owner-only flows (`createCadreInvitation`, `createOwnerGrant`, `claimNode`, `rentNode`) share with the apps |
199
- | `invitationReach()` | Where a device could redeem an invitation minted now from, judged on the other members' addresses (`anywhere`, `local-network`, `issuer-only`), without minting one; `rentNode` chooses its join path by it |
200
-
201
- ### Events
202
-
203
- | Event | Payload | Description |
204
- |-------|---------|-------------|
205
- | `control:connected` | - | Connected to control network |
206
- | `control:disconnected` | - | Disconnected from control network |
207
- | `strand:started` | `{ strandId }` | Strand instance started |
208
- | `strand:stopped` | `{ strandId }` | Strand instance stopped |
209
- | `strand:error` | `{ strandId, error }` | Error in strand instance. A failed launch re-emits this on every retry (backing off up to 5 min), so treat it as a repeating signal, not a one-shot. The exception is an `AppSchemaRefusedError` (the app's schema can never apply to the strand's tables): that strand is not retried until the next `addStrand` |
210
- | `strand:commit-durability` | `StrandCommitDurability` | After every commit on a strand's database that wrote something: whether another member already holds it (`heldElsewhere`), whether `strand:commit-held` will say when one does (`followed`), and, on a node offering offline mode, which of the party's machines it did not reach (`awaitedMachines`). Also readable as `instance.database.commitDurability(tx)`; see [strands.md → A commit's durability](../../docs/strands.md#a-commits-durability) |
211
- | `strand:commit-held` | `{ strandId, transactionId }` | A followed commit held only below full replication is now held by every member of its cohort |
212
-
213
- ## Related Documentation
214
-
215
- - **[Cadre Architecture](../../docs/architecture.md)** - Deep dive into the cadre system design
216
- - **[Strand Management](../../docs/strands.md)** - How strands connect multiple cadres
217
- - **[Schema Guide](../../docs/schema-guide.md)** - Optimystic schema definitions
218
-
219
- ## React Native Support
220
-
221
- This package is compatible with React Native. For mobile apps, use the RN-specific storage provider:
222
-
223
- ```typescript
224
- import { CadreNode } from '@serfab/cadre-core';
225
- import { RNRawStorage } from '@optimystic/db-p2p-storage-rn';
226
- import { webSockets } from '@libp2p/websockets';
227
- import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
228
-
229
- const node = new CadreNode({
230
- controlNetwork: {
231
- partyId: 'your-unique-party-id',
232
- bootstrapNodes: ['/dns4/relay.example.com/tcp/443/wss/p2p/12D3KooW...']
233
- },
234
- profile: 'transaction', // Mobile devices typically use transaction profile
235
- strandFilter: { mode: 'sAppId', sAppId: 'com.example.myapp' },
236
- storage: {
237
- // RN storage provider creates per-scope AsyncStorage
238
- provider: (scope) => new RNRawStorage(scope)
239
- },
240
- network: {
241
- // TCP doesn't work in React Native — use WebSocket transport instead
242
- transports: [webSockets(), circuitRelayTransport()],
243
- listenAddrs: [] // RN nodes typically cannot listen
244
- }
245
- });
246
- ```
247
-
248
- ### Storage Provider Pattern
249
-
250
- The `storage.provider` option accepts either:
251
- - **An `IRawStorage` instance** - One store shared by every scope, so it can serve only a single party
252
- - **A factory function** `(scope: string) => IRawStorage` - Creates isolated storage per scope (recommended)
253
-
254
- A **scope key** is what the factory receives. It is the strand id for each strand, and
255
- `controlStorageScope(partyId)` — `control-<lowercase hex of the party id>` — for the control
256
- database, which holds one party's own records and must not be shared between parties. Every
257
- key is opaque and already safe as a file, directory or database name (always within
258
- `[a-z0-9._-]`), and two different keys are two different names even on a filesystem that
259
- ignores case (Windows, macOS): use it verbatim, do not parse it. `isControlStorageScope(scope)`
260
- tells the two kinds apart. The control key holds the charset by lowercase hex encoding; a strand
261
- id holds it by check — `assertStrandScopeKey` runs on every strand launch, so a strand
262
- whose row replicated in from another node with an unusable id (including one with an
263
- uppercase letter) is refused rather than
264
- handed to the factory, and on `publishStrand`, so this node never writes such an id into
265
- the party's control database to begin with.
266
-
267
- Available storage implementations:
268
- | Package | Environment | Description |
269
- |---------|-------------|-------------|
270
- | `@optimystic/db-p2p` | All | `MemoryRawStorage` - In-memory (testing only) |
271
- | `@optimystic/db-p2p-storage-fs` | Node.js | `FileRawStorage` - File system storage |
272
- | `@optimystic/db-p2p-storage-rn` | React Native | `RNRawStorage` - AsyncStorage-based |
273
-
274
- ### React Native Considerations
275
-
276
- 1. **Network Transport**: libp2p's TCP transport doesn't work in RN. Pass `transports: [webSockets(), circuitRelayTransport()]` in the `network` config (see example above).
277
-
278
- 2. **Schema Loading**: The control schema is embedded in the package. Do not set `schemaPath` in React Native.
279
-
280
- 3. **Profile**: Mobile devices should use `profile: 'transaction'` for battery/bandwidth efficiency.
281
-
282
- 4. **Strand Filtering**: Always filter strands on mobile to avoid participating in unnecessary networks.
283
-
284
- ## Related Packages
285
-
286
- - **[@optimystic/db-core](https://github.com/gotchoices/optimystic)** - Distributed database core
287
- - **[@optimystic/db-p2p](https://github.com/gotchoices/optimystic)** - libp2p integration for Optimystic
288
- - **[@optimystic/db-p2p-storage-fs](https://github.com/gotchoices/optimystic)** - File system storage (Node.js)
289
- - **[@optimystic/db-p2p-storage-rn](https://github.com/gotchoices/optimystic)** - AsyncStorage (React Native)
290
-
291
- ## License
292
-
293
- MIT
294
-
1
+ # @serfab/cadre-core
2
+
3
+ The library that runs a Sereus cadre node. A node connects one machine to its party's private control network, starts the strands the party takes part in, and gives the app each strand as a SQL database.
4
+
5
+ In Sereus a **party** is a person or organisation, its **cadre** is the set of machines it runs, and a **strand** is an invitation-only SQL database shared among parties. [Concepts](https://github.com/gotchoices/sereus/blob/master/docs/concepts.md) defines the terms used here, and [Getting started](https://github.com/gotchoices/sereus/blob/master/docs/getting-started.md) walks through a first app with two parties.
6
+
7
+ ## Prerequisites
8
+
9
+ - **An ES module project.** The package ships ES modules only. It runs on Node.js 20.19 or later, in browsers, and in React Native and NativeScript apps.
10
+ - **A block store for the platform.** cadre-core stores data through Optimystic's `IRawStorage` interface and does not bundle a durable implementation; see [Storage provider](#storage-provider).
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @serfab/cadre-core
16
+ ```
17
+
18
+ The [quick start](#quick-start) also imports two packages directly:
19
+
20
+ ```bash
21
+ npm install @optimystic/db-p2p @optimystic/quereus-plugin-crypto
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ This script starts one node for a new party on Node.js, makes it the owner of its cadre, founds a strand, and reads back a row it wrote. It keeps everything in memory, so each run starts a new party.
27
+
28
+ ```ts
29
+ import { CadreNode, InMemoryKeyStore, createOwnerKey, signSchema } from '@serfab/cadre-core';
30
+ import { MemoryRawStorage } from '@optimystic/db-p2p';
31
+ import { generatePrivateKey, getPublicKey } from '@optimystic/quereus-plugin-crypto';
32
+
33
+ // The sApp: an app schema signed by its author. The author's public key is the sApp id.
34
+ const authorKey = generatePrivateKey('ed25519', 'base64url') as string;
35
+ const sApp = {
36
+ version: '1.0.0',
37
+ schemaVersion: 1,
38
+ schema: 'table Note (Id text primary key, Body text not null);',
39
+ };
40
+ const sAppConfig = {
41
+ id: getPublicKey(authorKey, 'ed25519', 'base64url', 'base64url') as string,
42
+ ...sApp,
43
+ signature: signSchema(sApp, authorKey),
44
+ };
45
+
46
+ // One store per scope: one for the control database, one for each strand.
47
+ const stores = new Map<string, MemoryRawStorage>();
48
+ const storeFor = (scope: string): MemoryRawStorage => {
49
+ let store = stores.get(scope);
50
+ if (!store) {
51
+ store = new MemoryRawStorage();
52
+ stores.set(scope, store);
53
+ }
54
+ return store;
55
+ };
56
+
57
+ const keyStore = new InMemoryKeyStore();
58
+ const node = new CadreNode({
59
+ keyStore,
60
+ controlNetwork: { partyId: crypto.randomUUID(), bootstrapNodes: [] },
61
+ nodeClass: 'device',
62
+ storage: { provider: storeFor },
63
+ });
64
+ await node.start();
65
+
66
+ // A new cadre has no owner. Create an owner key, seat it as the first owner, and sign with it.
67
+ const owner = await createOwnerKey(keyStore);
68
+ await node.getControlDatabase()!.ensureOwnerKey(owner.publicKey);
69
+ await node.useOwnerSigner(owner);
70
+
71
+ // Publish the strand to the party and start it here.
72
+ const { instance } = await node.foundStrand({ strandId: 'notes', sAppConfig });
73
+
74
+ // The strand is a Quereus database. App tables are in the App schema.
75
+ const db = instance.database!.getDatabase();
76
+ await db.exec("insert into App.Note (Id, Body) values ('1', 'hello')");
77
+ for await (const row of db.eval('select Body from App.Note')) {
78
+ console.log(row.Body); // hello
79
+ }
80
+
81
+ await node.stop();
82
+ ```
83
+
84
+ Expected output is the line `hello`. Set `DEBUG=sereus:*` to see what the node does on the way.
85
+
86
+ An app on a phone or in a browser does not construct `CadreNode` itself. It calls `createEdgeNode` from `@serfab/cadre-core/edge-node`, which builds the node over the app's key store and storage, creates the owner key on first run, and remembers how to start again. See [The edge node](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#the-edge-node).
87
+
88
+ ## Configuration
89
+
90
+ `new CadreNode(config)` takes a `CadreNodeConfig`, declared in [`src/types.ts`](src/types.ts). [Configuration](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#configuration) describes every option group. The options most embedders set:
91
+
92
+ | Option | Meaning |
93
+ | --- | --- |
94
+ | `controlNetwork.partyId` | The party this node serves. The app mints it once, for example as a UUID, and reuses it on every start. |
95
+ | `controlNetwork.bootstrapNodes` | Multiaddrs of the party's other machines to dial at start. Empty for the first machine. |
96
+ | `nodeClass` | `'device'` or `'server'`; see [Node class and roles](#node-class-and-roles). |
97
+ | `roles` | Per-role overrides of what the class means; see [Node class and roles](#node-class-and-roles). |
98
+ | `strandFilter` | Which of the party's strands this node runs; see [Strand filter](#strand-filter). |
99
+ | `storage.provider` | Where blocks are kept; see [Storage provider](#storage-provider). |
100
+ | `keyStore` | Where the node's identity key and other secrets are kept. With neither this nor `privateKey`, the node gets a new peer id on every start. `InMemoryKeyStore` is for tests; `FileKeyStore` from `@serfab/cadre-core/key-store-file` is the Node.js backend. |
101
+ | `network` | Listen addresses, transports and relays. On Node.js the default listens on TCP. A browser or phone passes WebSocket and circuit-relay transports with `listenAddrs: []`. |
102
+ | `requireSignedSchemas` | Default `true`: an sApp config without a valid author signature is refused. Set `false` only for development. |
103
+
104
+ ### Node class and roles
105
+
106
+ `nodeClass` says what kind of machine this node runs on. `'device'` is a phone, a laptop or a browser tab running an app, connected some of the time. `'server'` is an always-on machine: it also runs a relay server by default and keeps a copy of every strand its `strandFilter` admits, including strands no app on that machine uses. Under either preset a node stores the data of the strands it runs; the `strandCohortMember` role below is what changes that.
107
+
108
+ The class is only the preset for four decisions, the node's **roles**, which `roles` sets one at a time:
109
+
110
+ ```ts
111
+ roles: {
112
+ alwaysOn: true, // declare that this machine stays running and reachable
113
+ overlayTier: 'core', // FRET resource tier: 'edge' or 'core'
114
+ reactivity: 'subscriber', // 'forwarder' may carry other subscribers' change notifications
115
+ strandCohortMember: true, // hold and sign the blocks of the strands this node runs
116
+ }
117
+ ```
118
+
119
+ A role left out takes its preset's value (`device`: `false`, `'edge'`, `'forwarder'`, `true`; `server`: `true`, `'core'`, `'forwarder'`, `true`). A misspelled role name, or a value outside a role's own set, throws. `NODE_ROLE_PRESETS` and `resolveNodeRoles` are exported for a program that wants to show an operator what a config resolves to. See [Node classes](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#node-classes).
120
+
121
+ `strandCohortMember: false` makes the node a **client** of every strand it runs: it reads and writes the strand through the machines that store it, asks `storage.provider` for no per-strand store, and is left out of every cluster, so it is never on the path of another machine's save. It cannot host storage replicas, so `hostUnclaimedStrands` defaults to `false` on it and an explicit `true` throws naming both settings. A client needs a serving machine reachable to open or found a strand. See [A node that holds no strand blocks](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#a-node-that-holds-no-strand-blocks).
122
+
123
+ ### Strand filter
124
+
125
+ `strandFilter` limits which of the party's strands the node runs. An app that should run only its own strands filters by its sApp id.
126
+
127
+ ```ts
128
+ strandFilter: { mode: 'all' } // every strand of the party (the default)
129
+ strandFilter: { mode: 'sAppId', sAppId } // strands of one sApp
130
+ strandFilter: { mode: 'strandId', strandId: 'notes' } // one strand
131
+ strandFilter: { mode: 'none' } // the control network only
132
+ ```
133
+
134
+ `sAppId` is the sApp author's public key in base64url, the same value as `SAppConfig.id`. It is not a reverse-DNS application name. See [Strand filtering](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#strand-filtering).
135
+
136
+ ### Storage provider
137
+
138
+ `storage.provider` is a function from a scope key to an `IRawStorage`. cadre-core calls it once for the control database and once for each strand the node starts.
139
+
140
+ ```ts
141
+ import { FileRawStorage } from '@optimystic/db-p2p-storage-fs';
142
+ import { FileKeyStore } from '@serfab/cadre-core/key-store-file';
143
+
144
+ const node = new CadreNode({
145
+ keyStore: new FileKeyStore('/var/lib/my-app/keys'),
146
+ controlNetwork: { partyId, bootstrapNodes: [] },
147
+ nodeClass: 'server',
148
+ storage: { provider: (scope) => new FileRawStorage(`/var/lib/my-app/data/${scope}`) },
149
+ });
150
+ ```
151
+
152
+ - **The scope key is safe to use as a name.** It is a strand id, or `control-` followed by a hex encoding of the party id. Every key stays within `[a-z0-9._-]`, so it can go straight into a path or a database name. Do not parse it.
153
+ - **Return the same data for the same key.** The provider is called again for a scope after its strand stops or the node restarts, and must return a store over the same durable data.
154
+ - **Keep the control scope per party.** Two parties on one device must get two control stores, which the function form gives them. A single `IRawStorage` instance is also accepted, but it shares one store across every scope and can serve only one party.
155
+ - **Close the stores yourself.** cadre-core never closes what the provider returned.
156
+
157
+ | Package | Class | Platform |
158
+ | --- | --- | --- |
159
+ | `@optimystic/db-p2p` | `MemoryRawStorage` | Any; nothing persists |
160
+ | `@optimystic/db-p2p-storage-fs` | `FileRawStorage` | Node.js |
161
+ | `@optimystic/db-p2p-storage-rn` | `LevelDBRawStorage` | React Native |
162
+ | `@optimystic/db-p2p-storage-ns` | `SqliteRawStorage` | NativeScript |
163
+ | `@optimystic/db-p2p-storage-web` | `IndexedDBRawStorage` | Browsers |
164
+
165
+ See [Storage](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#storage) for the cache cadre-core puts in front of a store and the rules that follow from it.
166
+
167
+ ## What the node keeps, and where
168
+
169
+ cadre-core writes no files of its own. Everything durable goes through an object the embedder supplies:
170
+
171
+ - **Blocks** of the control database and of each strand go to `storage.provider`.
172
+ - **Secrets** go to `keyStore`: the node's identity key, the owner key, and the record of strands joined from other parties.
173
+ - **Node-local state** goes to the stores named in the config (`trustedOwners`, `bootstrapPeers`, `enrolledMachines`, `strandNetworkState`). Each defaults to memory. The file-backed versions are Node.js subpath imports such as `@serfab/cadre-core/trusted-owner-store-file`.
174
+
175
+ A node that keeps these in memory forgets which owner keys it trusts and which machines to dial when the process exits. See [Node-local state](https://github.com/gotchoices/sereus/blob/master/docs/cadre/node.md#node-local-state).
176
+
177
+ ## API map
178
+
179
+ The [cadre-core API guide](https://github.com/gotchoices/sereus/blob/master/docs/api.md) lists every call an app makes, what each one promises and where its mechanism is explained.
180
+
181
+ | Task | Calls | Guide section |
182
+ | --- | --- | --- |
183
+ | Create and run a node | `new CadreNode`, `start`, `stop`, `createEdgeNode` | [Creating a node](https://github.com/gotchoices/sereus/blob/master/docs/api.md#creating-a-node) |
184
+ | Hold and manage owner keys | `createOwnerKey`, `useOwnerSigner`, `isOwner`, `addOwner`, `createOwnerGrant` | [Owner keys](https://github.com/gotchoices/sereus/blob/master/docs/api.md#owner-keys) |
185
+ | Add a machine to the cadre | `createCadreInvitation`, `redeemCadreInvitation`, `claimNode`, `addDrone`, `rentNode` | [Adding a machine](https://github.com/gotchoices/sereus/blob/master/docs/api.md#adding-a-machine) |
186
+ | List and remove machines | `listMachines`, `planMachineRemoval`, `removeMachine` | [Listing and removing machines](https://github.com/gotchoices/sereus/blob/master/docs/api.md#listing-and-removing-machines) |
187
+ | Found a strand | `foundStrand`, `signSchema` | [Founding](https://github.com/gotchoices/sereus/blob/master/docs/api.md#founding) |
188
+ | Invite another party | `createOpenInvitation`, `publishFormationInvite`, `encodeInvitation` | [Inviting another party](https://github.com/gotchoices/sereus/blob/master/docs/api.md#inviting-another-party) |
189
+ | Join a strand | `formStrand`, `requestJoin`, `addStrand`, the `strand:discovered` event | [Joining](https://github.com/gotchoices/sereus/blob/master/docs/api.md#joining) |
190
+ | Read and write | `getStrand`, `instance.database.getDatabase()`, `setStrandOfflineMode` | [The strand's database](https://github.com/gotchoices/sereus/blob/master/docs/api.md#the-strands-database) |
191
+ | Stop or leave a strand | `stopStrand`, `unpublishStrand`, `forgetJoinedStrand` | [Stopping and leaving](https://github.com/gotchoices/sereus/blob/master/docs/api.md#stopping-and-leaving) |
192
+ | Administer a closed strand | `revokeMember`, `addMemberByManager`, `leaveStrand` | [Membership of closed strands](https://github.com/gotchoices/sereus/blob/master/docs/api.md#membership-of-closed-strands) |
193
+ | Approve joins from outside the party | `enrollValidationKey`, `signFormationApproval` | [Formation approval hook](https://github.com/gotchoices/sereus/blob/master/docs/formation-approval-hook.md) |
194
+ | React to changes and failures | `node.on(...)`, the error classes | [Events](https://github.com/gotchoices/sereus/blob/master/docs/api.md#events), [Errors](https://github.com/gotchoices/sereus/blob/master/docs/api.md#errors) |
195
+
196
+ ## Entry points
197
+
198
+ | Import | Use |
199
+ | --- | --- |
200
+ | `@serfab/cadre-core` | Everything that runs on every platform |
201
+ | `@serfab/cadre-core/edge-node` | `createEdgeNode`, for phones and browsers |
202
+ | `@serfab/cadre-core/key-store-file`, `/trusted-owner-store-file`, `/bootstrap-peer-store-file`, `/enrolled-machine-store-file`, `/strand-network-state-file` | File-backed stores, Node.js only |
203
+ | `@serfab/cadre-core/push-node` | FCM and APNs senders, Node.js only |
204
+ | `@serfab/cadre-core/node-default-transports`, `/primary-lan-address` | Node.js transport list and LAN address probe |
205
+
206
+ ## Related documentation
207
+
208
+ - [Architecture](https://github.com/gotchoices/sereus/blob/master/docs/architecture.md): how the control network, strands and nodes fit together.
209
+ - [Writing an app schema](https://github.com/gotchoices/sereus/blob/master/docs/schema-guide.md): how to write the Quereus schema an sApp runs.
210
+ - [Writing to a strand](https://github.com/gotchoices/sereus/blob/master/docs/strands/writes.md): commit durability and offline mode.
211
+ - [Running a node in a React Native app](https://github.com/gotchoices/sereus/blob/master/docs/platforms/react-native.md), [in a NativeScript app](https://github.com/gotchoices/sereus/blob/master/docs/platforms/nativescript.md) and [in a browser](https://github.com/gotchoices/sereus/blob/master/docs/platforms/browser.md).
212
+ - [`@serfab/cadre-cli`](https://github.com/gotchoices/sereus/blob/master/packages/cadre-cli/README.md) runs a node from the command line without writing code.
213
+
214
+ ## License
215
+
216
+ MIT
@@ -1,4 +1,5 @@
1
- import type { NodeProfile, ArachnodeConfig } from './types.js';
1
+ import type { ArachnodeConfig } from './types.js';
2
+ import type { NodeClass } from './node-class.js';
2
3
  /**
3
4
  * Ring configuration for a storage node
4
5
  */
@@ -26,11 +27,11 @@ export interface RingConfig {
26
27
  * This is a stub that will be replaced when arachnode is fully implemented.
27
28
  */
28
29
  export declare class ArachnodeStub {
29
- private readonly profile;
30
+ private readonly nodeClass;
30
31
  private readonly config;
31
32
  private ringConfig?;
32
33
  private running;
33
- constructor(profile: NodeProfile, config: ArachnodeConfig);
34
+ constructor(nodeClass: NodeClass, config: ArachnodeConfig);
34
35
  /**
35
36
  * Start participating in rings
36
37
  */
@@ -56,5 +57,12 @@ export declare class ArachnodeStub {
56
57
  }
57
58
  /**
58
59
  * Create an arachnode instance for a strand
60
+ *
61
+ * NOTE: the node class, not the `alwaysOn` node role every other behaviour now follows
62
+ * (`node-roles.ts`). Nothing in this repo calls this, and the storage rings it hands out are
63
+ * unimplemented (`backlog/later/5-ring-zulu-storage-rings`), so the divergence reaches nobody —
64
+ * but it means a `device` told `roles: { alwaysOn: true }` joins the real Ring Zulu and would
65
+ * still be given no storage ring here. Take `NodeRoles` instead of a class when the rings are
66
+ * built; the signature is exported, so that is a breaking change rather than a rename.
59
67
  */
60
- export declare function createArachnodeStub(profile: NodeProfile, config?: Partial<ArachnodeConfig>): ArachnodeStub;
68
+ export declare function createArachnodeStub(nodeClass: NodeClass, config?: Partial<ArachnodeConfig>): ArachnodeStub;