nervur 0.22.0 → 0.22.2-3

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 (398) hide show
  1. package/AUTHORING.md +741 -0
  2. package/KIT-SPEC.md +286 -0
  3. package/LICENSE +1 -1
  4. package/NOTICE +6 -2
  5. package/README.md +97 -424
  6. package/dist/app/app-ground.d.ts +18 -0
  7. package/dist/app/app-ground.js +25 -0
  8. package/dist/app/index.d.ts +2 -0
  9. package/dist/app/index.js +5 -0
  10. package/dist/app/native.d.ts +46 -0
  11. package/dist/app/native.js +101 -0
  12. package/dist/being/being.d.ts +229 -0
  13. package/dist/being/being.js +20 -0
  14. package/dist/being/covers.d.ts +9 -0
  15. package/dist/being/covers.js +21 -0
  16. package/dist/being/index.d.ts +3 -0
  17. package/dist/being/index.js +5 -0
  18. package/dist/being/need.d.ts +49 -0
  19. package/dist/being/need.js +33 -0
  20. package/dist/being/schema.d.ts +100 -0
  21. package/dist/being/schema.js +132 -0
  22. package/dist/being/table.d.ts +42 -0
  23. package/dist/being/table.js +288 -0
  24. package/dist/bench/bench-ground.d.ts +55 -0
  25. package/dist/bench/bench-ground.js +101 -0
  26. package/dist/bench/bench.d.ts +87 -0
  27. package/dist/bench/bench.js +260 -0
  28. package/dist/bench/fake-carry.d.ts +32 -0
  29. package/dist/bench/fake-carry.js +56 -0
  30. package/dist/bench/fake-clock.d.ts +17 -0
  31. package/dist/bench/fake-clock.js +34 -0
  32. package/dist/bench/fake-custody.d.ts +9 -0
  33. package/dist/bench/fake-custody.js +10 -0
  34. package/dist/bench/fake-faculty.d.ts +25 -0
  35. package/dist/bench/fake-faculty.js +48 -0
  36. package/dist/bench/fake-keys.d.ts +5 -0
  37. package/dist/bench/fake-keys.js +9 -0
  38. package/dist/bench/fake-memory.d.ts +14 -0
  39. package/dist/bench/fake-memory.js +46 -0
  40. package/dist/bench/fake-network.d.ts +57 -0
  41. package/dist/bench/fake-network.js +169 -0
  42. package/dist/bench/index.d.ts +11 -0
  43. package/dist/bench/index.js +13 -0
  44. package/dist/bench/seeded.d.ts +11 -0
  45. package/dist/bench/seeded.js +37 -0
  46. package/dist/bench/settle.d.ts +2 -0
  47. package/dist/bench/settle.js +49 -0
  48. package/dist/bench/stewards.d.ts +17 -0
  49. package/dist/bench/stewards.js +20 -0
  50. package/dist/bodies/class-list.d.ts +14 -0
  51. package/dist/bodies/class-list.js +33 -0
  52. package/dist/bodies/joined-carry.d.ts +23 -0
  53. package/dist/bodies/joined-carry.js +42 -0
  54. package/dist/bodies/noble-crypto.d.ts +22 -0
  55. package/dist/bodies/noble-crypto.js +88 -0
  56. package/dist/bodies/seed-keys.d.ts +10 -0
  57. package/dist/bodies/seed-keys.js +42 -0
  58. package/dist/bodies/strict-tools.d.ts +10 -0
  59. package/dist/bodies/strict-tools.js +306 -0
  60. package/dist/bodies/web-carry.d.ts +65 -0
  61. package/dist/bodies/web-carry.js +224 -0
  62. package/dist/bodies/web-clock.d.ts +12 -0
  63. package/dist/bodies/web-clock.js +33 -0
  64. package/dist/browser/browser-ground.d.ts +69 -0
  65. package/dist/browser/browser-ground.js +219 -0
  66. package/dist/browser/index.d.ts +4 -0
  67. package/dist/browser/index.js +7 -0
  68. package/dist/browser/indexeddb-memory.d.ts +17 -0
  69. package/dist/browser/indexeddb-memory.js +97 -0
  70. package/dist/browser/locked-custody.d.ts +25 -0
  71. package/dist/browser/locked-custody.js +89 -0
  72. package/dist/browser/origin-classes.d.ts +7 -0
  73. package/dist/browser/origin-classes.js +31 -0
  74. package/dist/foundation.d.ts +150 -0
  75. package/dist/foundation.js +4 -0
  76. package/dist/ground/ground.d.ts +177 -0
  77. package/dist/ground/ground.js +363 -0
  78. package/dist/house/crossing.d.ts +37 -0
  79. package/dist/house/crossing.js +131 -0
  80. package/dist/house/house.d.ts +80 -0
  81. package/dist/house/house.js +1753 -0
  82. package/dist/house/rows-shape.d.ts +103 -0
  83. package/dist/house/rows-shape.js +12 -0
  84. package/dist/house/rows.d.ts +27 -0
  85. package/dist/house/rows.js +168 -0
  86. package/dist/index.d.ts +29 -1
  87. package/dist/index.js +25 -14
  88. package/dist/node/bridge.d.ts +17 -0
  89. package/dist/node/bridge.js +188 -0
  90. package/dist/node/cli.js +170 -0
  91. package/dist/node/custody.d.ts +20 -0
  92. package/dist/node/custody.js +34 -0
  93. package/dist/node/file-keys.d.ts +7 -0
  94. package/dist/node/file-keys.js +30 -0
  95. package/dist/node/file-memory.d.ts +13 -0
  96. package/dist/node/file-memory.js +91 -0
  97. package/dist/node/folder-classes.d.ts +5 -0
  98. package/dist/node/folder-classes.js +40 -0
  99. package/dist/node/gone.d.ts +2 -0
  100. package/dist/node/gone.js +7 -0
  101. package/dist/node/hand.d.ts +29 -0
  102. package/dist/node/hand.js +85 -0
  103. package/dist/node/held-keys.d.ts +14 -0
  104. package/dist/node/held-keys.js +36 -0
  105. package/dist/node/http.d.ts +11 -0
  106. package/dist/node/http.js +90 -0
  107. package/dist/node/index.d.ts +13 -0
  108. package/dist/node/index.js +15 -0
  109. package/dist/node/keychain-keys.d.ts +10 -0
  110. package/dist/node/keychain-keys.js +51 -0
  111. package/dist/node/ledger-memory.d.ts +17 -0
  112. package/dist/node/ledger-memory.js +151 -0
  113. package/dist/node/lock.d.ts +10 -0
  114. package/dist/node/lock.js +78 -0
  115. package/dist/node/node-ground.d.ts +33 -0
  116. package/dist/node/node-ground.js +147 -0
  117. package/dist/node/notify.d.ts +1 -0
  118. package/dist/node/notify.js +18 -0
  119. package/dist/node/tcp-carry.d.ts +39 -0
  120. package/dist/node/tcp-carry.js +216 -0
  121. package/dist/node/websocket.d.ts +6 -0
  122. package/dist/node/websocket.js +118 -0
  123. package/dist/quo/frame.d.ts +20 -0
  124. package/dist/quo/frame.js +48 -0
  125. package/dist/quo/room.d.ts +154 -0
  126. package/dist/quo/room.js +362 -0
  127. package/dist/serve/index.d.ts +27 -0
  128. package/dist/serve/index.js +55 -0
  129. package/package.json +49 -47
  130. package/dist/browser.d.ts +0 -1
  131. package/dist/browser.js +0 -8
  132. package/dist/cli.js +0 -16
  133. package/dist/core/being/being.d.ts +0 -17
  134. package/dist/core/being/being.js +0 -72
  135. package/dist/core/being/digest.d.ts +0 -3
  136. package/dist/core/being/digest.js +0 -17
  137. package/dist/core/being/faculty.d.ts +0 -10
  138. package/dist/core/being/faculty.js +0 -77
  139. package/dist/core/being/index.d.ts +0 -6
  140. package/dist/core/being/index.js +0 -8
  141. package/dist/core/being/kind.d.ts +0 -6
  142. package/dist/core/being/kind.js +0 -34
  143. package/dist/core/being/types.d.ts +0 -61
  144. package/dist/core/being/types.js +0 -4
  145. package/dist/core/being/words.d.ts +0 -13
  146. package/dist/core/being/words.js +0 -14
  147. package/dist/core/browser/index.d.ts +0 -37
  148. package/dist/core/browser/index.js +0 -196
  149. package/dist/core/browser/worker.d.ts +0 -11
  150. package/dist/core/browser/worker.js +0 -37
  151. package/dist/core/cli/command.d.ts +0 -13
  152. package/dist/core/cli/command.js +0 -330
  153. package/dist/core/cli/edge.d.ts +0 -7
  154. package/dist/core/cli/edge.js +0 -79
  155. package/dist/core/cli/harbor.d.ts +0 -25
  156. package/dist/core/cli/harbor.js +0 -115
  157. package/dist/core/contract/index.d.ts +0 -42
  158. package/dist/core/contract/index.js +0 -34
  159. package/dist/core/contract/link.d.ts +0 -4
  160. package/dist/core/contract/link.js +0 -45
  161. package/dist/core/crypto/aes.d.ts +0 -3
  162. package/dist/core/crypto/aes.js +0 -24
  163. package/dist/core/crypto/bytes.d.ts +0 -6
  164. package/dist/core/crypto/bytes.js +0 -33
  165. package/dist/core/crypto/ed25519.d.ts +0 -3
  166. package/dist/core/crypto/ed25519.js +0 -93
  167. package/dist/core/crypto/hash.d.ts +0 -2
  168. package/dist/core/crypto/hash.js +0 -11
  169. package/dist/core/crypto/index.d.ts +0 -7
  170. package/dist/core/crypto/index.js +0 -10
  171. package/dist/core/crypto/json.d.ts +0 -8
  172. package/dist/core/crypto/json.js +0 -250
  173. package/dist/core/crypto/mlkem.d.ts +0 -12
  174. package/dist/core/crypto/mlkem.js +0 -36
  175. package/dist/core/crypto/subtle.d.ts +0 -3
  176. package/dist/core/crypto/subtle.js +0 -11
  177. package/dist/core/crypto/x25519.d.ts +0 -2
  178. package/dist/core/crypto/x25519.js +0 -24
  179. package/dist/core/edge/index.d.ts +0 -164
  180. package/dist/core/edge/index.js +0 -739
  181. package/dist/core/edge/kit.d.ts +0 -2
  182. package/dist/core/edge/kit.js +0 -2
  183. package/dist/core/folder/index.d.ts +0 -18
  184. package/dist/core/folder/index.js +0 -130
  185. package/dist/core/git/http.d.ts +0 -6
  186. package/dist/core/git/http.js +0 -102
  187. package/dist/core/git/index.d.ts +0 -5
  188. package/dist/core/git/index.js +0 -10
  189. package/dist/core/git/object.d.ts +0 -40
  190. package/dist/core/git/object.js +0 -103
  191. package/dist/core/git/pack.d.ts +0 -9
  192. package/dist/core/git/pack.js +0 -171
  193. package/dist/core/git/store.d.ts +0 -23
  194. package/dist/core/git/store.js +0 -120
  195. package/dist/core/git/zlib.d.ts +0 -6
  196. package/dist/core/git/zlib.js +0 -210
  197. package/dist/core/harbor/carrying.d.ts +0 -51
  198. package/dist/core/harbor/carrying.js +0 -69
  199. package/dist/core/harbor/catalogue.d.ts +0 -33
  200. package/dist/core/harbor/catalogue.js +0 -365
  201. package/dist/core/harbor/dna.d.ts +0 -13
  202. package/dist/core/harbor/dna.js +0 -120
  203. package/dist/core/harbor/dock.d.ts +0 -62
  204. package/dist/core/harbor/dock.js +0 -381
  205. package/dist/core/harbor/harbor.d.ts +0 -16
  206. package/dist/core/harbor/harbor.js +0 -438
  207. package/dist/core/harbor/index.d.ts +0 -11
  208. package/dist/core/harbor/index.js +0 -14
  209. package/dist/core/harbor/memory.d.ts +0 -10
  210. package/dist/core/harbor/memory.js +0 -25
  211. package/dist/core/harbor/package.d.ts +0 -20
  212. package/dist/core/harbor/package.js +0 -172
  213. package/dist/core/harbor/probe.d.ts +0 -22
  214. package/dist/core/harbor/probe.js +0 -15
  215. package/dist/core/harbor/registry.d.ts +0 -15
  216. package/dist/core/harbor/registry.js +0 -110
  217. package/dist/core/harbor/root-line.d.ts +0 -7
  218. package/dist/core/harbor/root-line.js +0 -9
  219. package/dist/core/harbor/terrain.d.ts +0 -25
  220. package/dist/core/harbor/terrain.js +0 -28
  221. package/dist/core/http/index.d.ts +0 -2
  222. package/dist/core/http/index.js +0 -154
  223. package/dist/core/http/websocket.d.ts +0 -29
  224. package/dist/core/http/websocket.js +0 -133
  225. package/dist/core/line/answer.d.ts +0 -8
  226. package/dist/core/line/answer.js +0 -60
  227. package/dist/core/line/frame.d.ts +0 -29
  228. package/dist/core/line/frame.js +0 -77
  229. package/dist/core/line/ground.d.ts +0 -3
  230. package/dist/core/line/ground.js +0 -7
  231. package/dist/core/line/index.d.ts +0 -4
  232. package/dist/core/line/index.js +0 -8
  233. package/dist/core/line/web.d.ts +0 -12
  234. package/dist/core/line/web.js +0 -117
  235. package/dist/core/node/index.d.ts +0 -23
  236. package/dist/core/node/index.js +0 -124
  237. package/dist/core/pointer/bodies.d.ts +0 -31
  238. package/dist/core/pointer/bodies.js +0 -118
  239. package/dist/core/pointer/index.d.ts +0 -2
  240. package/dist/core/pointer/index.js +0 -4
  241. package/dist/core/pointer/world.d.ts +0 -45
  242. package/dist/core/pointer/world.js +0 -106
  243. package/dist/core/proof/contracts.d.ts +0 -19
  244. package/dist/core/proof/contracts.js +0 -116
  245. package/dist/core/proof/expect.d.ts +0 -6
  246. package/dist/core/proof/expect.js +0 -18
  247. package/dist/core/proof/index.d.ts +0 -3
  248. package/dist/core/proof/index.js +0 -14
  249. package/dist/core/proof/law.d.ts +0 -25
  250. package/dist/core/proof/law.js +0 -715
  251. package/dist/core/quo/address.d.ts +0 -19
  252. package/dist/core/quo/address.js +0 -84
  253. package/dist/core/quo/door.d.ts +0 -34
  254. package/dist/core/quo/door.js +0 -174
  255. package/dist/core/quo/index.d.ts +0 -9
  256. package/dist/core/quo/index.js +0 -12
  257. package/dist/core/quo/invitation.d.ts +0 -8
  258. package/dist/core/quo/invitation.js +0 -19
  259. package/dist/core/quo/keys.d.ts +0 -40
  260. package/dist/core/quo/keys.js +0 -79
  261. package/dist/core/quo/payload.d.ts +0 -15
  262. package/dist/core/quo/payload.js +0 -55
  263. package/dist/core/quo/relations.d.ts +0 -40
  264. package/dist/core/quo/relations.js +0 -33
  265. package/dist/core/quo/reply.d.ts +0 -13
  266. package/dist/core/quo/reply.js +0 -35
  267. package/dist/core/quo/seal.d.ts +0 -42
  268. package/dist/core/quo/seal.js +0 -78
  269. package/dist/core/quo/standing.d.ts +0 -39
  270. package/dist/core/quo/standing.js +0 -90
  271. package/dist/core/tcp/index.d.ts +0 -27
  272. package/dist/core/tcp/index.js +0 -209
  273. package/dist/core/ward/allowance.d.ts +0 -14
  274. package/dist/core/ward/allowance.js +0 -32
  275. package/dist/core/ward/cells.d.ts +0 -7
  276. package/dist/core/ward/cells.js +0 -74
  277. package/dist/core/ward/house.d.ts +0 -67
  278. package/dist/core/ward/house.js +0 -473
  279. package/dist/core/ward/index.d.ts +0 -5
  280. package/dist/core/ward/index.js +0 -7
  281. package/dist/core/ward/partition.d.ts +0 -50
  282. package/dist/core/ward/partition.js +0 -66
  283. package/dist/core/ward/stance.d.ts +0 -29
  284. package/dist/core/ward/stance.js +0 -186
  285. package/dist/core/ward/ward.d.ts +0 -44
  286. package/dist/core/ward/ward.js +0 -140
  287. package/dist/core.d.ts +0 -10
  288. package/dist/core.js +0 -19
  289. package/dist/defaults/dock/index.d.ts +0 -4
  290. package/dist/defaults/dock/index.js +0 -11
  291. package/dist/defaults/index.d.ts +0 -5
  292. package/dist/defaults/index.js +0 -10
  293. package/dist/defaults/memory/index.d.ts +0 -12
  294. package/dist/defaults/memory/index.js +0 -39
  295. package/dist/defaults/tcp/index.d.ts +0 -16
  296. package/dist/defaults/tcp/index.js +0 -82
  297. package/dist/defaults/ward/index.d.ts +0 -4
  298. package/dist/defaults/ward/index.js +0 -11
  299. package/dist/defaults/web/index.d.ts +0 -15
  300. package/dist/defaults/web/index.js +0 -90
  301. package/dist/edge.d.ts +0 -1
  302. package/dist/edge.js +0 -9
  303. package/dist/kit.d.ts +0 -4
  304. package/dist/kit.js +0 -12
  305. package/dist/node.d.ts +0 -1
  306. package/dist/node.js +0 -8
  307. package/src/browser.ts +0 -10
  308. package/src/cli.ts +0 -15
  309. package/src/core/being/being.ts +0 -84
  310. package/src/core/being/digest.ts +0 -18
  311. package/src/core/being/faculty.ts +0 -76
  312. package/src/core/being/index.ts +0 -8
  313. package/src/core/being/kind.ts +0 -37
  314. package/src/core/being/types.ts +0 -74
  315. package/src/core/being/words.ts +0 -31
  316. package/src/core/browser/index.ts +0 -219
  317. package/src/core/browser/worker.ts +0 -63
  318. package/src/core/cli/command.ts +0 -311
  319. package/src/core/cli/edge.ts +0 -86
  320. package/src/core/cli/harbor.ts +0 -120
  321. package/src/core/contract/index.ts +0 -82
  322. package/src/core/contract/link.ts +0 -58
  323. package/src/core/crypto/aes.ts +0 -26
  324. package/src/core/crypto/bytes.ts +0 -37
  325. package/src/core/crypto/ed25519.ts +0 -92
  326. package/src/core/crypto/hash.ts +0 -14
  327. package/src/core/crypto/index.ts +0 -10
  328. package/src/core/crypto/json.ts +0 -241
  329. package/src/core/crypto/mlkem.ts +0 -38
  330. package/src/core/crypto/subtle.ts +0 -13
  331. package/src/core/crypto/x25519.ts +0 -23
  332. package/src/core/edge/index.ts +0 -865
  333. package/src/core/folder/index.ts +0 -137
  334. package/src/core/git/http.ts +0 -103
  335. package/src/core/git/index.ts +0 -10
  336. package/src/core/git/object.ts +0 -116
  337. package/src/core/git/pack.ts +0 -147
  338. package/src/core/git/store.ts +0 -122
  339. package/src/core/git/zlib.ts +0 -197
  340. package/src/core/harbor/carrying.ts +0 -124
  341. package/src/core/harbor/catalogue.ts +0 -386
  342. package/src/core/harbor/dna.ts +0 -116
  343. package/src/core/harbor/dock.ts +0 -420
  344. package/src/core/harbor/harbor.ts +0 -433
  345. package/src/core/harbor/index.ts +0 -14
  346. package/src/core/harbor/memory.ts +0 -31
  347. package/src/core/harbor/package.ts +0 -195
  348. package/src/core/harbor/probe.ts +0 -39
  349. package/src/core/harbor/registry.ts +0 -107
  350. package/src/core/harbor/root-line.ts +0 -19
  351. package/src/core/harbor/terrain.ts +0 -54
  352. package/src/core/http/index.ts +0 -147
  353. package/src/core/http/websocket.ts +0 -124
  354. package/src/core/line/answer.ts +0 -60
  355. package/src/core/line/frame.ts +0 -83
  356. package/src/core/line/ground.ts +0 -18
  357. package/src/core/line/index.ts +0 -8
  358. package/src/core/line/web.ts +0 -123
  359. package/src/core/node/index.ts +0 -139
  360. package/src/core/pointer/bodies.ts +0 -122
  361. package/src/core/pointer/index.ts +0 -4
  362. package/src/core/pointer/world.ts +0 -134
  363. package/src/core/proof/contracts.ts +0 -134
  364. package/src/core/proof/expect.ts +0 -25
  365. package/src/core/proof/index.ts +0 -14
  366. package/src/core/proof/law.ts +0 -742
  367. package/src/core/quo/address.ts +0 -87
  368. package/src/core/quo/door.ts +0 -180
  369. package/src/core/quo/index.ts +0 -12
  370. package/src/core/quo/invitation.ts +0 -19
  371. package/src/core/quo/keys.ts +0 -91
  372. package/src/core/quo/payload.ts +0 -61
  373. package/src/core/quo/relations.ts +0 -62
  374. package/src/core/quo/reply.ts +0 -38
  375. package/src/core/quo/seal.ts +0 -101
  376. package/src/core/quo/standing.ts +0 -111
  377. package/src/core/stand/main.ts +0 -20
  378. package/src/core/stand/stand.ts +0 -259
  379. package/src/core/tcp/index.ts +0 -227
  380. package/src/core/ward/allowance.ts +0 -47
  381. package/src/core/ward/cells.ts +0 -77
  382. package/src/core/ward/house.ts +0 -524
  383. package/src/core/ward/index.ts +0 -7
  384. package/src/core/ward/partition.ts +0 -117
  385. package/src/core/ward/stance.ts +0 -207
  386. package/src/core/ward/ward.ts +0 -166
  387. package/src/core.ts +0 -55
  388. package/src/defaults/dock/index.ts +0 -12
  389. package/src/defaults/index.ts +0 -10
  390. package/src/defaults/memory/index.ts +0 -50
  391. package/src/defaults/tcp/index.ts +0 -89
  392. package/src/defaults/ward/index.ts +0 -12
  393. package/src/defaults/web/index.ts +0 -97
  394. package/src/edge.ts +0 -11
  395. package/src/index.ts +0 -18
  396. package/src/kit.ts +0 -15
  397. package/src/node.ts +0 -10
  398. /package/dist/{cli.d.ts → node/cli.d.ts} +0 -0
@@ -1,420 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // The dock: the contract of the box ward's ward. Beside the root's asks of
3
- // every ward, she opens faculties, hosts wards, and lends each contract a
4
- // faculty fulfils to the wards she hosts. The core names no class of it:
5
- // the terrain hands the harbor the one that stands at genesis. She is born
6
- // of her stance alone, which carries her harbor as `ground`.
7
- //
8
- // She stands once the harbor has booted: its seed, its memory, the
9
- // catalogue and every registry the catalogue resolves stand, and her class
10
- // resolved through the registry her row names. The harbor hands her the
11
- // door and is done; from there everything is an ask. Her `stand` is the
12
- // second level, hers alone, asked by whoever holds the harbor or pilots
13
- // it: every other faculty of the box, each once the registry it names
14
- // stands, registries first, then memory faculties, then the rest; then
15
- // every hosted ward, her house unpacked and her ward stood. A being of a
16
- // hosted ward stands nowhere: she is born for the asks that reach her. It
17
- // answers what stood, or silence where everything already stands. A
18
- // faculty names its class and its registry, and keeps its cells in the box
19
- // ward. A hosted ward names its class, its registry and the memory that
20
- // keeps it.
21
- //
22
- // stand every faculty and hosted ward that does
23
- // not stand yet, stood
24
- // open { key, class, a faculty stands in the box ward, her class
25
- // registry? } resolved through the registry faculty named
26
- // or the catalogue, and the dock holds a
27
- // standing on her under her key
28
- // host { ward, seed?, a hosted ward stands under the seed named,
29
- // memory?, class?, or a drawn one, of the ward class named or
30
- // registry? } the default one, resolved with every class
31
- // of the ward through the registry faculty
32
- // named or the catalogue, holding a standing
33
- // on the dock; the dock keeps its name, its
34
- // seed, its registry and the memory faculty
35
- // that keeps its place, or none for the root
36
- // memory
37
- // move { ward, memory } a hosted ward's place carried whole to
38
- // another keeper, a memory faculty's key or
39
- // null for the root memory, and forgotten
40
- // where it was
41
- // lend { contract } asked by a hosted ward: an offer from a
42
- // faculty that fulfils the contract
43
- // retract { contract, heir } an offer that was not taken
44
- // route { ward, at } where a ward pk is reached, addresses in the
45
- // order they are tried, or null to forget
46
- // it; the dock keeps it and the harbor hands
47
- // it to its carrier
48
- // hold { name, invitation, a far being held as the ward's `hold`
49
- // at? } holds it, its ward routed at the address
50
- // named first
51
- // reach { at } where this harbor is reached, the
52
- // addresses every invitation it gives carries
53
- // heard a push heard, told to every carrier faculty,
54
- // so one that collects for this harbor
55
- // collects
56
- //
57
- // Her census adds, for whoever pilots, what her cells keep, each hosted
58
- // ward by name with its keeper and registry but never its seed, the routes
59
- // and the reach; what did not stand; and every address the harbor's
60
- // carriers listen at.
61
- //
62
- // A take of an invitation that carries `at` teaches the dock that ward's
63
- // route, where the root set none.
64
- import { Faculty, ships, WARD, type Asker, type AskSpec, type BeingClass, type Blueprint, type Invitation, type JsonObject, type Stance } from '../being/index.ts';
65
- import { Catalogue, CATALOGUE } from './catalogue.ts';
66
- import { MEMORY, MemoryFaculty } from './memory.ts';
67
- import { registers } from './registry.ts';
68
- import { readAt, readInvitation } from '../quo/index.ts';
69
- import { ownerAsk, pilots, rootAsk, Ward, type Lender, type WardStance } from '../ward/index.ts';
70
-
71
- // What the dock asks of her harbor: a ward standing, and the seed, as hex,
72
- // it stands under.
73
- export interface Hosting {
74
- host(name: string, invitation: Invitation, seed?: string, memory?: string, kind?: string, registry?: string): Promise<string | null>;
75
- // A hosted ward the dock's cells name, standing: its house unpacked and
76
- // its ward stood where they are not. Whether it stood now; one that does
77
- // not stand fails alone, and the census names it.
78
- stand(hosted: Hosted): Promise<boolean>;
79
- // A standing ward's place, carried to another keeper and standing from
80
- // there: null, or why not. Where it was stays until `release`.
81
- move(name: string, seed: string, from: string | undefined, to: string | undefined): Promise<string | null>;
82
- // A ward's place, forgotten by the keeper named.
83
- release(name: string, memory: string | undefined): Promise<void>;
84
- // Whether the harbor's carrier took the route.
85
- route(pk: string, at: readonly string[] | null): boolean;
86
- // A route the dock keeps, handed to the carrier as the harbor stands:
87
- // where no carrier dials it, the census names it.
88
- reached(pk: string, at: readonly string[]): void;
89
- // Whether the box ward's partition was kept.
90
- keep(): Promise<boolean>;
91
- // What did not stand when the harbor opened.
92
- failures(): Failures;
93
- // Whether the harbor lives only as long as a screen.
94
- readonly foreground: boolean;
95
- // Every place of the memory the dock does not name, gone.
96
- sweep(): Promise<string[]>;
97
- // A faculty just opened, woken where it wakes; one stood as the harbor
98
- // stands, woken where the harbor's carriers wake; and one about to go,
99
- // put to sleep.
100
- awaken(key: string): Promise<void>;
101
- rouse(key: string): Promise<void>;
102
- lull(key: string): Promise<void>;
103
- // Every address the harbor's carriers listen at now.
104
- listening(): string[];
105
- // A push heard, told to every carrier faculty.
106
- heard(): Promise<void>;
107
- }
108
-
109
- // One hosted ward, as the dock's cells keep it, with the key of the memory
110
- // faculty that keeps its place where the root memory does not, and of the
111
- // registry faculty its classes resolve through where the catalogue does
112
- // not.
113
- export type Hosted = { ward: string; seed: string; memory?: string; registry?: string };
114
-
115
- // Each hosted ward that did not unpack and each route the carrier did not
116
- // take, with the reason, by name and by ward pk.
117
- export type Failures = { wards: Record<string, string>; routes: Record<string, string> };
118
-
119
- export const BOX = 'box';
120
- const text = (v: unknown): v is string => typeof v === 'string';
121
- // A list of addresses, each a URI with a scheme, and at least one.
122
- const addresses = (v: unknown): v is string[] => Array.isArray(v) && v.length > 0 && readAt(v).length === v.length;
123
- const hosted: AskSpec['for'] = (_: Asker, notes: JsonObject | undefined) => notes?.hosted === true;
124
-
125
- // The box ward's stance: a ward's, and the harbor she docks.
126
- export type DockStance = WardStance & { readonly ground: Hosting };
127
-
128
- // Whether a class is the catalogue's, which stands under `catalogue` alone.
129
- const catalogues = (C: unknown): boolean => C === Catalogue || (typeof C === 'function' && C.prototype instanceof Catalogue);
130
-
131
- // Whether a class may be a hosted ward's: a ward, and no dock.
132
- export const hostable = (C: unknown): boolean => Ward.fulfils(C) && !Dock.fulfils(C);
133
-
134
- export abstract class Dock extends Ward implements Lender {
135
- static override readonly kind: string = 'org.nervur.dock';
136
- static {
137
- ships(this);
138
- }
139
- static override cells: JsonObject = { hosted: [], routes: {}, reach: [] };
140
- static override asks: Record<string, AskSpec> = {
141
- ...Ward.asks,
142
- stand: ownerAsk('every faculty and hosted ward that does not stand yet, stood; silence where everything stands'),
143
- open: ownerAsk('a faculty of this harbor', { required: ['key', 'class'] }),
144
- host: ownerAsk('a ward this harbor hosts, kept by the root memory or by the memory faculty named', { required: ['ward'] }),
145
- move: ownerAsk('a hosted ward carried to a memory faculty, or to the root memory with null', { required: ['ward', 'memory'] }),
146
- hold: ownerAsk('an owner invitation on a far being, held under a name from now on, at the address named', { required: ['name', 'invitation'] }),
147
- route: ownerAsk('where a ward is reached, addresses in order, or null', { required: ['ward', 'at'] }),
148
- reach: ownerAsk('where this harbor is reached, the addresses every invitation carries', { required: ['at'] }),
149
- sweep: rootAsk('every place of the memory this harbor does not name, gone'),
150
- heard: ownerAsk('a push heard, told to every carrier, so one that collects for this harbor collects'),
151
- lend: { description: 'an offer from a faculty fulfilling a contract', input: { type: 'object', required: ['contract'] }, for: hosted },
152
- retract: { description: 'an offer that was not taken', input: { type: 'object', required: ['contract', 'heir'] }, for: hosted },
153
- };
154
-
155
- readonly #hosting: Hosting;
156
-
157
- constructor(stance: Stance) {
158
- super(stance);
159
- this.#hosting = (stance as DockStance).ground;
160
- }
161
-
162
- // The second level: every faculty of the box that does not stand yet,
163
- // each once the registry she names stands, registries first, then
164
- // memory faculties, then the rest; every route handed to the carrier;
165
- // then every hosted ward and her ward. Asked once the harbor boots, and
166
- // again whenever the code that runs moves, so it stands only what does
167
- // not stand yet, and answers silence where everything already stands.
168
- async stand(): Promise<JsonObject | undefined> {
169
- const stood = [...(await this.#standFaculties(registers)), ...(await this.#standFaculties((C) => C.prototype instanceof MemoryFaculty)), ...(await this.#standFaculties(() => true))];
170
- for (const [pk, at] of Object.entries(this.routes)) this.#hosting.reached(pk, at);
171
- const wards: string[] = [];
172
- for (const row of this.hosted) if (await this.#hosting.stand(row)) wards.push(row.ward);
173
- return stood.length + wards.length > 0 ? { stood, wards } : undefined;
174
- }
175
-
176
- // The absent faculties whose class resolves now and fits, stood, again
177
- // and again while one more stands, since a registry stood makes the
178
- // classes named through it resolve.
179
- async #standFaculties(fits: (C: BeingClass) => boolean): Promise<string[]> {
180
- const stood: string[] = [];
181
- for (let more = true; more; ) {
182
- more = false;
183
- for (const [key, being] of Object.entries(this.steward.beings())) {
184
- const C = being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
185
- if (!C || !fits(C) || this.steward.stand(key) !== 'booted') continue;
186
- more = true;
187
- stood.push(key);
188
- await this.#hosting.rouse(key);
189
- }
190
- }
191
- return stood;
192
- }
193
-
194
- // The census adds what did not stand, for whoever pilots, and whether
195
- // the harbor lives only as long as a screen.
196
- override describe(asker: Asker): Blueprint {
197
- const blueprint = super.describe(asker);
198
- if (!pilots(asker, this.notes(asker))) return blueprint;
199
- const notes = blueprint.notes as JsonObject;
200
- notes.wards = Object.fromEntries(this.hosted.map(({ ward, memory, registry }) => [ward, { ...(memory === undefined ? {} : { memory }), ...(registry === undefined ? {} : { registry }) }]));
201
- notes.routes = this.routes;
202
- notes.reach = this.addresses;
203
- notes.failed = this.#hosting.failures();
204
- notes.listening = this.#hosting.listening();
205
- if (this.#hosting.foreground) notes.foreground = true;
206
- return blueprint;
207
- }
208
-
209
- async heard(): Promise<JsonObject> {
210
- await this.#hosting.heard();
211
- return { heard: true };
212
- }
213
-
214
- get hosted(): Hosted[] {
215
- return (this.cells.hosted as Hosted[]).map(({ ward, seed, memory, registry }) => ({
216
- ward,
217
- seed,
218
- ...(memory === undefined ? {} : { memory }),
219
- ...(registry === undefined ? {} : { registry }),
220
- }));
221
- }
222
-
223
- // Whether a key names a memory faculty the dock opened.
224
- #memory(key: unknown): key is string {
225
- return text(key) && this.#fulfilling(MEMORY).includes(key);
226
- }
227
-
228
- // The registry an ask names: none for the catalogue, the key of a
229
- // registry faculty standing in the box, or no registry at all.
230
- #registry(named: unknown): { registry: string | undefined } | null {
231
- if (named === undefined || named === null || named === CATALOGUE) return { registry: undefined };
232
- if (!text(named)) return null;
233
- const being = this.steward.beings()[named];
234
- const C = being && !being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
235
- return registers(C) ? { registry: named } : null;
236
- }
237
-
238
- get routes(): Record<string, string[]> {
239
- return Object.fromEntries(Object.entries(this.cells.routes as Record<string, string[]>).map(([pk, at]) => [pk, [...at]]));
240
- }
241
-
242
- // Where this harbor is reached, in the order a caller tries it.
243
- get addresses(): string[] {
244
- return [...(this.cells.reach as string[])];
245
- }
246
-
247
- route(args: JsonObject): JsonObject {
248
- const { ward } = args;
249
- const at = typeof args.at === 'string' ? [args.at] : args.at;
250
- if (!text(ward) || (at !== null && !addresses(at)) || !this.#hosting.route(ward, at)) return { error: 'not routed' };
251
- const routes = this.cells.routes as Record<string, string[]>;
252
- if (at === null) delete routes[ward];
253
- else routes[ward] = [...at];
254
- return { routed: ward };
255
- }
256
-
257
- reach(args: JsonObject): JsonObject {
258
- if (!addresses(args.at)) return { error: 'at is a list of addresses' };
259
- this.cells.reach = [...args.at];
260
- return { reach: [...args.at] };
261
- }
262
-
263
- // A far ward held at the address named is routed there first, so the
264
- // take reaches it where its invitation says nothing.
265
- override async hold(args: JsonObject): Promise<JsonObject> {
266
- if (args.at !== undefined) {
267
- if (!addresses([args.at])) return { error: 'at is an address' };
268
- const ward = readInvitation(args.invitation)?.ward;
269
- if (ward === undefined) return { error: 'no invitation' };
270
- const routed = this.route({ ward, at: [args.at] });
271
- if (routed.error !== undefined) return routed;
272
- }
273
- return super.hold(args);
274
- }
275
-
276
- // A route learned from an invitation's `at`, where the root set none,
277
- // and where the carrier dials one of its addresses.
278
- async learn(ward: string, at: readonly string[]): Promise<void> {
279
- const routes = this.cells.routes as Record<string, string[]>;
280
- if (Object.hasOwn(routes, ward) || !this.#hosting.route(ward, at)) return;
281
- routes[ward] = [...at];
282
- await this.#hosting.keep();
283
- }
284
-
285
- // The dock born again of a class, resolved through the catalogue or a
286
- // registry the catalogue stands, since she stands before any other.
287
- override become(args: JsonObject): JsonObject {
288
- if (!text(args.class)) return { error: 'class is text' };
289
- const through = this.#registry(args.registry);
290
- if (through === null) return { error: 'no such registry faculty' };
291
- const { registry } = through;
292
- if (registry !== undefined && this.steward.beings()[registry]!.registry !== undefined) return { error: 'the dock stands through the catalogue or a registry it stands' };
293
- const refused = this.steward.become(args.class, registry);
294
- return refused === null ? { became: args.class } : { error: refused };
295
- }
296
-
297
- // The box ward holds faculties alone, and a faculty stands by `open`,
298
- // which takes a standing on her.
299
- override boot(): Promise<JsonObject> {
300
- return Promise.resolve({ error: 'a faculty is opened, and nothing else stands in the box ward' });
301
- }
302
-
303
- // A faculty that goes stops listening first, and a memory faculty
304
- // keeping a ward's place does not go.
305
- override async unboot(args: JsonObject): Promise<JsonObject> {
306
- if (this.hosted.some((h) => h.memory !== undefined && h.memory === args.being)) return { error: 'a ward is kept by this memory faculty' };
307
- if (typeof args.being === 'string') await this.#hosting.lull(args.being);
308
- return super.unboot(args);
309
- }
310
-
311
- // A faculty of any class the registry named resolves: a kit faculty
312
- // resolves only where this ground ships it. The catalogue is the core's,
313
- // and no ask opens one.
314
- async open(args: JsonObject): Promise<JsonObject> {
315
- if (!text(args.key) || !text(args.class)) return { error: 'key and class are text' };
316
- const through = this.#registry(args.registry);
317
- if (through === null) return { error: 'no such registry faculty' };
318
- const { registry } = through;
319
- const C = this.steward.classOf(args.class, registry);
320
- if (!Faculty.fulfils(C) || catalogues(C)) return { error: 'no such faculty' };
321
- if ((await this.steward.boot(args.key, args.class, registry)) !== 'booted') return { error: 'not opened' };
322
- const invitation = await this.steward.invite(args.key, WARD, {});
323
- if (invitation === null || (await this.stance.standings.take(args.key, invitation)) === null) {
324
- this.steward.unboot(args.key);
325
- return { error: 'not opened' };
326
- }
327
- await this.#hosting.awaken(args.key);
328
- return { opened: args.key };
329
- }
330
-
331
- async sweep(): Promise<JsonObject> {
332
- return { swept: await this.#hosting.sweep() };
333
- }
334
-
335
- async host(args: JsonObject): Promise<JsonObject> {
336
- const name = args.ward;
337
- if (!text(name)) return { error: 'ward is text' };
338
- if (name === BOX) return { error: 'box is the box ward' };
339
- if (this.hosted.some((h) => h.ward === name)) return { error: `${name} is hosted already` };
340
- if (args.seed !== undefined && !text(args.seed)) return { error: 'seed is text' };
341
- const memory = args.memory ?? undefined;
342
- if (memory !== undefined && !this.#memory(memory)) return { error: 'no such memory faculty' };
343
- const through = this.#registry(args.registry);
344
- if (through === null) return { error: 'no such registry faculty' };
345
- const { registry } = through;
346
- const kind = args.class ?? undefined;
347
- if (kind !== undefined && (!text(kind) || !hostable(this.steward.classOf(kind, registry)))) return { error: 'no such ward class' };
348
- const invitation = await this.stance.occupants.invite(name, { hosted: true });
349
- if (invitation === null) return { error: 'not hosted' };
350
- const seed = await this.#hosting.host(name, invitation, args.seed, memory, kind, registry);
351
- if (seed === null) {
352
- this.stance.occupants.remove(name);
353
- return { error: 'not hosted' };
354
- }
355
- (this.cells.hosted as Hosted[]).push({ ward: name, seed, ...(memory === undefined ? {} : { memory }), ...(registry === undefined ? {} : { registry }) });
356
- return { hosted: name };
357
- }
358
-
359
- // The place is written where it goes before the dock's cells say so, and
360
- // forgotten where it was only once they are kept, so a cut at any step
361
- // leaves the ward whole under the keeper the cells name.
362
- async move(args: JsonObject): Promise<JsonObject> {
363
- const rows = this.cells.hosted as Hosted[];
364
- const row = rows.find((h) => h.ward === args.ward);
365
- if (!row) return { error: 'no such ward' };
366
- const to = args.memory ?? undefined;
367
- if (to !== undefined && !this.#memory(to)) return { error: 'no such memory faculty' };
368
- const from = row.memory;
369
- if (from === to) return { error: `${row.ward} is kept there already` };
370
- const refused = await this.#hosting.move(row.ward, row.seed, from, to);
371
- if (refused !== null) return { error: refused };
372
- const set = (memory: string | undefined): void => {
373
- if (memory === undefined) delete row.memory;
374
- else row.memory = memory;
375
- };
376
- set(to);
377
- if (!(await this.#hosting.keep())) {
378
- set(from);
379
- await this.#hosting.move(row.ward, row.seed, to, from);
380
- return { error: 'not kept' };
381
- }
382
- await this.#hosting.release(row.ward, from);
383
- return { moved: row.ward, memory: to ?? null };
384
- }
385
-
386
- async lend(args: JsonObject): Promise<JsonObject> {
387
- if (!text(args.contract)) return { error: 'contract is text' };
388
- const invitation = await this.offer(args.contract);
389
- return invitation ? { invitation } : { error: 'nothing lent' };
390
- }
391
-
392
- async retract(args: JsonObject): Promise<JsonObject> {
393
- if (!text(args.contract) || !text(args.heir)) return { error: 'contract and heir are text' };
394
- await this.withdraw(args.contract, args.heir);
395
- return { retracted: args.heir };
396
- }
397
-
398
- // Lender: the first standing faculty that fulfils the contract offers.
399
- async offer(contract: string): Promise<Invitation | null> {
400
- for (const key of this.#fulfilling(contract)) {
401
- const out = await this.stance.standings.get(key)?.ask('offer');
402
- const invitation = readInvitation((out as { invitation?: unknown } | undefined)?.invitation);
403
- if (invitation) return invitation;
404
- }
405
- return null;
406
- }
407
-
408
- async withdraw(contract: string, heir: string): Promise<void> {
409
- for (const key of this.#fulfilling(contract)) await this.stance.standings.get(key)?.ask('retract', { heir });
410
- }
411
-
412
- #fulfilling(contract: string): string[] {
413
- const beings = this.steward.beings();
414
- return this.stance.standings.ids().filter((key) => {
415
- const being = beings[key];
416
- const C = being && !being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
417
- return Faculty.fulfils(C) && Faculty.contracts(C).includes(contract);
418
- });
419
- }
420
- }