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,67 +0,0 @@
1
- import { Door, WardKey, type Behind, type Choice, type Invitation, type Payload } from '../quo/index.ts';
2
- import type { Carrier, Clock, Entropy, Rows } from '../contract/index.ts';
3
- import { type Answer, type BeingClass, type BeingLike, type JsonObject } from '../being/index.ts';
4
- import { Partition, type BeingRow } from './partition.ts';
5
- import { type Inside } from './stance.ts';
6
- import { Ward } from './ward.ts';
7
- export interface Classes {
8
- classOf(kind: string, registry?: string): BeingClass | undefined;
9
- }
10
- export type HouseParts = {
11
- readonly seed: Uint8Array | string;
12
- readonly memory: Rows;
13
- readonly classes: Classes;
14
- readonly entropy: Entropy;
15
- readonly clock: Clock;
16
- readonly carrier: Carrier;
17
- readonly ward: WardClass;
18
- readonly carries?: Readonly<Record<string, unknown>>;
19
- readonly dock?: Invitation;
20
- readonly routes?: Routes;
21
- readonly stands?: boolean;
22
- };
23
- export interface Routes {
24
- reach(): readonly string[];
25
- learn(ward: string, at: readonly string[]): Promise<void>;
26
- }
27
- export type WardClass = {
28
- readonly genesis: string;
29
- readonly contract: string;
30
- fits(C: BeingClass): boolean;
31
- readonly fallback?: BeingClass;
32
- };
33
- export declare const DOCK = "dock";
34
- export interface Lender {
35
- offer(contract: string): Promise<Invitation | null>;
36
- withdraw(contract: string, heir: string): Promise<void>;
37
- }
38
- type Birth = 'booted' | 'key taken' | 'no such class' | 'threw at birth';
39
- export declare class House implements Behind, Inside {
40
- #private;
41
- readonly key: WardKey;
42
- readonly partition: Partition;
43
- readonly door: Door;
44
- readonly clock: Clock;
45
- private constructor();
46
- static unpack(parts: HouseParts): Promise<House>;
47
- standWard(): Promise<void>;
48
- stand(key: string): 'booted' | 'stands' | 'no such being' | 'no such class' | 'threw at birth';
49
- make(key: string, className: string): Promise<Birth>;
50
- get pk(): string;
51
- get draw(): import("../quo/keys.ts").Draw;
52
- get ward(): Ward;
53
- get fault(): string | null;
54
- being(key: string): BeingLike | undefined;
55
- renew(): void;
56
- root(method?: string, args?: JsonObject): Promise<Answer>;
57
- get zero(): boolean;
58
- answer(heir: string | null, p: Payload): Promise<Choice>;
59
- send(pk: string, bytes: Uint8Array): Promise<Uint8Array | null>;
60
- offer(contract: string): Promise<Invitation | null>;
61
- retract(contract: string, heir: string): Promise<void>;
62
- reach(): readonly string[];
63
- learn(ward: string, at: readonly string[]): Promise<void>;
64
- live(key: string, row: BeingRow): boolean;
65
- boot(maker: string, className: string, key: string, id?: string): Promise<string | null>;
66
- }
67
- export {};
@@ -1,473 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // The house: the plumbing behind Quo's door. It keeps Quo's ward, its seed
3
- // and keys, one door, one partition and its head, and the beings behind the
4
- // door. It unpacks from its seed, its memory and the classes it resolves
5
- // kinds through, and stands what is behind its door for `quo/`. It brings
6
- // no being to life on its own: whoever unpacks it stands its ward. In the
7
- // box ward the dock stands each faculty, and it stands from then on. In
8
- // every other ward a being is born from her row when an ask reaches her,
9
- // once for every ask in flight on her, and is dropped when the last one
10
- // ends: her cells, occupants and standings are her ward's rows, kept by
11
- // the ward's memory, so nothing of her lives between asks. No author sees
12
- // or extends it.
13
- import { readValue, writeValue } from '../crypto/index.js';
14
- import { Door, readInvitation, WardKey } from '../quo/index.js';
15
- import { digest, Faculty, isSilence, isWord, OWNER, ownKind, silence, WARD, word } from '../being/index.js';
16
- import { Partition, PartitionRelations } from './partition.js';
17
- import { DEPTH, HouseStance } from './stance.js';
18
- import { Ward } from './ward.js';
19
- // The standing every hosted ward holds on the dock.
20
- export const DOCK = 'dock';
21
- const lends = (being) => typeof being.offer === 'function';
22
- class RootStance extends HouseStance {
23
- steward;
24
- constructor(inside, row, steward, carries) {
25
- super(inside, WARD, row, carries);
26
- this.steward = steward;
27
- }
28
- }
29
- export class House {
30
- key;
31
- partition;
32
- door;
33
- clock;
34
- #parts;
35
- #residents = new Map();
36
- #visits = new Map();
37
- #birthing = new Set();
38
- #fault = null;
39
- constructor(parts, key) {
40
- this.#parts = parts;
41
- this.key = key;
42
- this.clock = parts.clock;
43
- this.partition = new Partition(parts.memory);
44
- this.door = new Door(key, new PartitionRelations(this.partition), this, parts.entropy.drawer);
45
- }
46
- // The house of a seed and its memory, its ward's row written with the
47
- // genesis kind where the row is new. No being stands yet.
48
- static async unpack(parts) {
49
- const ward = new House(parts, await WardKey.from(parts.seed));
50
- if (!ward.partition.being(WARD)) {
51
- ward.partition.beings[WARD] = { class: ward.#class.genesis, cells: {}, occupants: {}, standings: {} };
52
- ward.partition.told(WARD);
53
- ward.partition.toldHead();
54
- }
55
- return ward;
56
- }
57
- // The ward, of the class her row's kind resolves. A ward class that does
58
- // not resolve or fits no ward here stands the fallback, with why, or the
59
- // ward does not stand and this throws. The ward stands once.
60
- async standWard() {
61
- if (this.#residents.has(WARD))
62
- return;
63
- const own = this.partition.being(WARD);
64
- const stance = new RootStance(this, own, this.#steward, this.#parts.carries ?? {});
65
- const found = this.#wardOf(own.class, own.registry);
66
- let being;
67
- if (typeof found === 'string')
68
- this.#fault = found;
69
- else {
70
- try {
71
- being = new found(stance);
72
- }
73
- catch (e) {
74
- this.#fault = `${own.class} threw at birth: ${e instanceof Error ? e.message : String(e)}`;
75
- }
76
- }
77
- if (!being) {
78
- const { fallback } = this.#class;
79
- if (!fallback)
80
- throw new Error(this.#fault);
81
- being = new fallback(stance);
82
- }
83
- this.#residents.set(WARD, { being, row: own, stance });
84
- // The standing on the dock is kept at once: its heir is spent, so a
85
- // restart before the ward's first keep would find no way back.
86
- const { dock } = this.#parts;
87
- if (dock && !Object.hasOwn(own.standings, DOCK) && (await stance.standings.take(DOCK, dock)) !== null && !(await this.partition.kept())) {
88
- throw new Error('the standing on the dock was not kept');
89
- }
90
- }
91
- // One being of a house whose beings stand, from her row, where she does
92
- // not stand yet: a class nothing resolves, or one that throws, leaves her
93
- // absent and her row as it stands. In any other house no being stands.
94
- stand(key) {
95
- if (this.#residents.has(key))
96
- return 'stands';
97
- const row = key === WARD || !this.#parts.stands ? undefined : this.partition.being(key);
98
- if (!row)
99
- return 'no such being';
100
- const C = this.#classOf(row);
101
- if (!C)
102
- return 'no such class';
103
- return this.#bear(key, row, C) ? 'booted' : 'threw at birth';
104
- }
105
- // A being of a kind the core ships, written and stood where her key holds
106
- // none: how the harbor stands the catalogue on empty memory, before any
107
- // ward being stands to boot her.
108
- make(key, className) {
109
- return this.#make(key, className);
110
- }
111
- #classOf(row) {
112
- return this.#parts.classes.classOf(row.class, row.registry);
113
- }
114
- get pk() {
115
- return this.key.pk;
116
- }
117
- get draw() {
118
- return this.#parts.entropy.drawer;
119
- }
120
- get ward() {
121
- return this.#residents.get(WARD).being;
122
- }
123
- // Why the ward stands the fallback and not her row's class, or null.
124
- get fault() {
125
- return this.#fault;
126
- }
127
- get #class() {
128
- return this.#parts.ward;
129
- }
130
- // The class of a ward kind, or why none may be this house's ward.
131
- #wardOf(kind, registry) {
132
- const C = this.#parts.classes.classOf(kind, registry);
133
- if (!C)
134
- return `no class of kind ${kind} runs`;
135
- return this.#class.fits(C) ? C : `${kind} is no ${this.#class.contract}`;
136
- }
137
- // The ward born again of her row's class where it resolves now and is
138
- // not the class she stands as, on the stance she holds.
139
- #wardAnew() {
140
- const resident = this.#residents.get(WARD);
141
- if (!resident)
142
- return;
143
- const found = this.#wardOf(resident.row.class, resident.row.registry);
144
- if (typeof found === 'string') {
145
- if (ownKind(resident.being.constructor) !== resident.row.class)
146
- this.#fault = found;
147
- return;
148
- }
149
- if (resident.being.constructor === found)
150
- return;
151
- try {
152
- resident.being = new found(resident.stance);
153
- this.#fault = null;
154
- }
155
- catch (e) {
156
- this.#fault = `${resident.row.class} threw at birth: ${e instanceof Error ? e.message : String(e)}`;
157
- }
158
- }
159
- // The being standing under a key, for the harbor's own faculties.
160
- being(key) {
161
- return this.#residents.get(key)?.being;
162
- }
163
- // Every standing being whose kind now resolves to another class, born
164
- // again of it on the stance she holds, so her relations and their lanes
165
- // stay hers. A new class that throws at birth leaves her as she was. The
166
- // ward is one of them. A being born for an ask needs none of this: the
167
- // next ask that reaches her is born of the class that runs then.
168
- renew() {
169
- this.#wardAnew();
170
- for (const [key, resident] of this.#residents) {
171
- if (key === WARD)
172
- continue;
173
- const C = this.#classOf(resident.row);
174
- if (!C || resident.being.constructor === C)
175
- continue;
176
- try {
177
- resident.being = new C(resident.stance);
178
- }
179
- catch {
180
- continue;
181
- }
182
- }
183
- }
184
- // The unsealed ask: the ward, asked by whoever holds this house.
185
- // It reaches every being of the house through the ward, so every
186
- // row is put back where the memory refuses.
187
- async root(method, args = {}) {
188
- return this.#kept(Object.keys(this.partition.beings), () => this.#answer(WARD, { id: OWNER }, method, args));
189
- }
190
- // An answer, kept. Where the memory refuses, what the beings wrote is put
191
- // back and the answer is silence. What their relations stand on is not
192
- // put back: a relation's keys move only as far as its standing follows.
193
- async #kept(keys, work) {
194
- const before = keys.flatMap((key) => {
195
- const row = this.partition.being(key);
196
- return row ? [[key, row.cells, JSON.stringify(row.cells)]] : [];
197
- });
198
- const out = await work();
199
- if (await this.partition.kept())
200
- return out;
201
- for (const [key, cells, was] of before) {
202
- if (JSON.stringify(cells) === was)
203
- continue;
204
- for (const k of Object.keys(cells))
205
- delete cells[k];
206
- for (const [k, v] of Object.entries(JSON.parse(was)))
207
- Object.defineProperty(cells, k, { value: v, enumerable: true, writable: true, configurable: true });
208
- this.partition.told(key);
209
- }
210
- return silence;
211
- }
212
- // Behind: the zero head reaches the public being, an heir the being that
213
- // invited it.
214
- get zero() {
215
- const key = this.partition.head.public;
216
- return key !== null && this.#reachable(key);
217
- }
218
- // Whether an ask reaches the being under a key: she stands, or she is
219
- // born for it, her class resolving.
220
- #reachable(key) {
221
- if (this.#residents.has(key))
222
- return true;
223
- const row = key === WARD || this.#parts.stands ? undefined : this.partition.being(key);
224
- return row !== undefined && this.#classOf(row) !== undefined;
225
- }
226
- async answer(heir, p) {
227
- const bound = heir === null ? undefined : this.partition.head.bind[heir];
228
- const key = heir === null ? this.partition.head.public : bound?.being;
229
- const asker = bound ? { id: bound.id } : {};
230
- const args = p.args === undefined ? {} : readValue(p.args, DEPTH + 1);
231
- if (key === null || key === undefined || typeof args !== 'object' || args === null || Array.isArray(args))
232
- return { silence: true };
233
- let seen = null;
234
- const out = await this.#kept([key], () => this.#with(key, silence, async (being) => {
235
- const reply = await this.#reply(being, asker, p.method, args);
236
- if (p.method !== undefined && !isSilence(reply) && !isWord(reply) && being.describe)
237
- seen = await digest(being.describe(asker));
238
- return reply;
239
- }));
240
- const object = isSilence(out) || isWord(out) ? undefined : writeValue(out, DEPTH);
241
- return object === undefined ? { silence: true } : { object, seen };
242
- }
243
- // Every path that reaches a being's answer. A throw, a word out of her,
244
- // or nothing at all is silence.
245
- #answer(key, asker, method, args) {
246
- return this.#with(key, silence, (being) => this.#reply(being, asker, method, args));
247
- }
248
- async #reply(being, asker, method, args) {
249
- let out;
250
- try {
251
- out = await being.answer(asker, method, args);
252
- }
253
- catch {
254
- return silence;
255
- }
256
- return out === undefined || isWord(out) ? silence : out;
257
- }
258
- // The being under a key for the length of `work`: the one that stands,
259
- // or, in a house whose beings do not stand, one born from her row for
260
- // it, the same one for every ask in flight on her, so her relations keep
261
- // one lane each, dropped when the last ends. A being nothing resolves, or
262
- // one that throws at birth, is none.
263
- async #with(key, none, work) {
264
- const standing = this.#residents.get(key);
265
- if (standing)
266
- return work(standing.being);
267
- const visit = this.#visit(key);
268
- if (!visit)
269
- return none;
270
- try {
271
- return await work(visit.being);
272
- }
273
- finally {
274
- visit.asks -= 1;
275
- if (visit.asks === 0 && this.#visits.get(key) === visit)
276
- this.#visits.delete(key);
277
- }
278
- }
279
- #visit(key) {
280
- const held = this.#visits.get(key);
281
- if (held) {
282
- held.asks += 1;
283
- return held;
284
- }
285
- const row = key === WARD || this.#parts.stands ? undefined : this.partition.being(key);
286
- const C = row && this.#classOf(row);
287
- if (!row || !C)
288
- return undefined;
289
- const stance = new HouseStance(this, key, row, this.#parts.carries ?? {});
290
- try {
291
- const visit = { being: new C(stance), row, stance, asks: 1 };
292
- this.#visits.set(key, visit);
293
- return visit;
294
- }
295
- catch {
296
- return undefined;
297
- }
298
- }
299
- // The stance a being of this house acts on: hers where she stands or is
300
- // in flight, else one made on her row for what her ward does with it.
301
- #stanceOf(key) {
302
- const held = this.#residents.get(key) ?? this.#visits.get(key);
303
- if (held)
304
- return held.stance;
305
- const row = key === WARD ? undefined : this.partition.being(key);
306
- return row ? new HouseStance(this, key, row, this.#parts.carries ?? {}) : undefined;
307
- }
308
- // Inside: what every stance of this ward stands on.
309
- // One path through a door for every ask, this ward's own included.
310
- async send(pk, bytes) {
311
- if (pk === this.pk)
312
- return (await this.door.arrive(bytes)).bytes;
313
- return this.#parts.carrier.carry(pk, bytes);
314
- }
315
- // A lend: the ward lends herself, as the dock does, or asks the dock
316
- // through her standing.
317
- async offer(contract) {
318
- const own = this.#residents.get(WARD);
319
- if (lends(own.being))
320
- return own.being.offer(contract);
321
- const out = await own.stance.standings.get(DOCK)?.ask('lend', { contract });
322
- return readInvitation(out?.invitation);
323
- }
324
- async retract(contract, heir) {
325
- const own = this.#residents.get(WARD);
326
- if (lends(own.being))
327
- return own.being.withdraw(contract, heir);
328
- await own.stance.standings.get(DOCK)?.ask('retract', { contract, heir });
329
- }
330
- reach() {
331
- return this.#parts.routes?.reach() ?? [];
332
- }
333
- learn(ward, at) {
334
- return this.#parts.routes?.learn(ward, at) ?? Promise.resolve();
335
- }
336
- // A stance speaks for a being while her row is the one her ward keeps.
337
- live(key, row) {
338
- return this.partition.being(key) === row;
339
- }
340
- // A being boots another of this ward. With an id, the new being invites
341
- // her maker under the maker's key, and the maker takes it under id; a
342
- // relation that could not be made unmakes the new being.
343
- async boot(maker, className, key, id) {
344
- if ((await this.#make(key, className)) !== 'booted')
345
- return null;
346
- if (id === undefined)
347
- return key;
348
- const invitation = await this.#stanceOf(key).occupants.invite(maker);
349
- const taken = invitation ? await this.#stanceOf(maker)?.standings.take(id, invitation) : null;
350
- if (taken)
351
- return key;
352
- this.#unboot(key);
353
- return null;
354
- }
355
- // A new row and her first birth, which writes her cells' defaults: she
356
- // stands from then on in a house whose beings stand, and is dropped at
357
- // once in any other, to be born again for the asks that reach her.
358
- async #make(key, className, registry) {
359
- if (key === '' || key === WARD || this.partition.being(key) || this.#birthing.has(key))
360
- return 'key taken';
361
- // A house whose beings stand, the box, holds faculties alone, and every
362
- // other house holds beings that are no faculty. A ward is no being of
363
- // any house.
364
- const C = this.#parts.classes.classOf(className, registry);
365
- if (!C || Ward.fulfils(C) || Faculty.fulfils(C) !== (this.#parts.stands === true))
366
- return 'no such class';
367
- this.#birthing.add(key);
368
- try {
369
- const row = { class: className, ...(registry === undefined ? {} : { registry }), cells: {}, occupants: {}, standings: {} };
370
- this.partition.beings[key] = row;
371
- if (!(this.#parts.stands ? this.#bear(key, row, C) : this.#born(key, row, C) !== undefined)) {
372
- delete this.partition.beings[key];
373
- return 'threw at birth';
374
- }
375
- this.partition.told(key);
376
- return 'booted';
377
- }
378
- finally {
379
- this.#birthing.delete(key);
380
- }
381
- }
382
- #born(key, row, C) {
383
- try {
384
- return new C(new HouseStance(this, key, row, this.#parts.carries ?? {}));
385
- }
386
- catch {
387
- return undefined;
388
- }
389
- }
390
- #bear(key, row, C) {
391
- const stance = new HouseStance(this, key, row, this.#parts.carries ?? {});
392
- try {
393
- this.#residents.set(key, { being: new C(stance), row, stance });
394
- return true;
395
- }
396
- catch {
397
- this.#residents.delete(key);
398
- return false;
399
- }
400
- }
401
- #unboot(key) {
402
- const row = key === WARD ? undefined : this.partition.being(key);
403
- if (!row)
404
- return false;
405
- for (const { heir } of Object.values(row.occupants)) {
406
- this.door.remove(heir);
407
- delete this.partition.head.bind[heir];
408
- }
409
- if (this.partition.head.public === key)
410
- this.partition.head.public = null;
411
- delete this.partition.beings[key];
412
- this.#residents.delete(key);
413
- this.partition.toldHead();
414
- this.partition.told(key);
415
- return true;
416
- }
417
- // What the ward asks of her house.
418
- #steward = {
419
- pk: () => this.pk,
420
- classOf: (name, registry) => this.#parts.classes.classOf(name, registry),
421
- beings: () => {
422
- const out = {};
423
- // A being is absent where no ask would reach her: in a house whose
424
- // beings stand, one that does not stand; in any other, one whose
425
- // class does not resolve.
426
- for (const [key, row] of Object.entries(this.partition.beings)) {
427
- if (key !== WARD)
428
- out[key] = { class: row.class, ...(row.registry === undefined ? {} : { registry: row.registry }), public: this.partition.head.public === key, absent: !this.#reachable(key) };
429
- }
430
- return out;
431
- },
432
- boot: (key, className, registry) => this.#make(key, className, registry),
433
- stand: (key) => this.stand(key),
434
- unboot: (key) => this.#unboot(key),
435
- publish: (key) => {
436
- if (key !== null && (key === WARD || !this.partition.being(key)))
437
- return false;
438
- this.partition.head.public = key;
439
- this.partition.toldHead();
440
- return true;
441
- },
442
- invite: (being, id, notes) => {
443
- const stance = being === WARD || !this.#reachable(being) ? undefined : this.#stanceOf(being);
444
- return stance ? stance.occupants.invite(id, notes) : Promise.resolve(null);
445
- },
446
- ask: (being, method, args) => {
447
- const key = being ?? this.partition.head.public;
448
- if (key === null || key === WARD)
449
- return Promise.resolve(word('unreached'));
450
- return this.#answer(key, being === null ? {} : { id: OWNER }, method, args);
451
- },
452
- become: (kind, registry) => {
453
- const found = this.#wardOf(kind, registry);
454
- if (typeof found === 'string')
455
- return found;
456
- const resident = this.#residents.get(WARD);
457
- try {
458
- resident.being = new found(resident.stance);
459
- }
460
- catch {
461
- return `${kind} threw at birth`;
462
- }
463
- resident.row.class = kind;
464
- if (registry === undefined)
465
- delete resident.row.registry;
466
- else
467
- resident.row.registry = registry;
468
- this.partition.told(WARD);
469
- this.#fault = null;
470
- return null;
471
- },
472
- };
473
- }
@@ -1,5 +0,0 @@
1
- export { allow, CEILING, DEFAULT } from './allowance.ts';
2
- export { HEAD_ROW, Partition, type BeingRow, type Head, type StandingRow } from './partition.ts';
3
- export { DEPTH } from './stance.ts';
4
- export { DOCK, House, type Classes, type HouseParts, type Lender, type Routes, type WardClass } from './house.ts';
5
- export { HELD, ownerAsk, pilots, rootAsk, Ward, type Steward, type WardStance } from './ward.ts';
@@ -1,7 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // The ward and its house: the partition, the stances, the ward, and the house.
3
- export { allow, CEILING, DEFAULT } from './allowance.js';
4
- export { HEAD_ROW, Partition } from './partition.js';
5
- export { DEPTH } from './stance.js';
6
- export { DOCK, House } from './house.js';
7
- export { HELD, ownerAsk, pilots, rootAsk, Ward } from './ward.js';
@@ -1,50 +0,0 @@
1
- import type { Lock } from '../crypto/index.ts';
2
- import { type HeirRecord, type Invitation, type KeptLock, type Relations, type StandingState } from '../quo/index.ts';
3
- import type { Rows } from '../contract/index.ts';
4
- import type { JsonObject } from '../being/index.ts';
5
- export declare const HEAD_ROW = "";
6
- export type Head = {
7
- lock?: KeptLock;
8
- heirs: Record<string, HeirRecord>;
9
- gone: string[];
10
- bind: Record<string, {
11
- being: string;
12
- id: string;
13
- }>;
14
- public: string | null;
15
- };
16
- export type StandingRow = {
17
- invitation: Invitation;
18
- state: StandingState;
19
- seen: string | null;
20
- };
21
- export type BeingRow = {
22
- class: string;
23
- registry?: string;
24
- cells: JsonObject;
25
- occupants: Record<string, {
26
- heir: string;
27
- notes: JsonObject;
28
- }>;
29
- standings: Record<string, StandingRow>;
30
- };
31
- export declare class Partition {
32
- readonly memory: Rows;
33
- constructor(memory: Rows);
34
- get head(): Head;
35
- get beings(): Record<string, BeingRow>;
36
- being(key: string): BeingRow | undefined;
37
- told(key: string): void;
38
- toldHead(): void;
39
- kept(): Promise<boolean>;
40
- }
41
- export declare class PartitionRelations implements Relations {
42
- #private;
43
- constructor(partition: Partition);
44
- lock(): Lock | undefined;
45
- setLock(lock: Lock): void;
46
- get(heir: string): HeirRecord | undefined;
47
- set(heir: string, record: HeirRecord): void;
48
- delete(heir: string): void;
49
- kept(): Promise<boolean>;
50
- }
@@ -1,66 +0,0 @@
1
- import { GONE, keptLock, lockOf } from '../quo/index.js';
2
- export const HEAD_ROW = '';
3
- export class Partition {
4
- memory;
5
- constructor(memory) {
6
- this.memory = memory;
7
- const rows = memory.rows;
8
- rows.ward ??= { heirs: {}, gone: [], bind: {}, public: null };
9
- rows.beings ??= {};
10
- }
11
- get head() {
12
- return this.memory.rows.ward;
13
- }
14
- get beings() {
15
- return this.memory.rows.beings;
16
- }
17
- being(key) {
18
- return Object.hasOwn(this.beings, key) ? this.beings[key] : undefined;
19
- }
20
- told(key) {
21
- this.memory.told(key);
22
- }
23
- toldHead() {
24
- this.memory.told(HEAD_ROW);
25
- }
26
- kept() {
27
- return this.memory.kept().catch(() => false);
28
- }
29
- }
30
- // The door's memory, written into the head.
31
- export class PartitionRelations {
32
- #partition;
33
- constructor(partition) {
34
- this.#partition = partition;
35
- }
36
- get #head() {
37
- return this.#partition.head;
38
- }
39
- lock() {
40
- return lockOf(this.#head.lock);
41
- }
42
- setLock(lock) {
43
- this.#head.lock = keptLock(lock);
44
- this.#partition.toldHead();
45
- }
46
- get(heir) {
47
- return Object.hasOwn(this.#head.heirs, heir) ? this.#head.heirs[heir] : undefined;
48
- }
49
- set(heir, record) {
50
- const head = this.#head;
51
- head.heirs[heir] = record;
52
- if (record.state === 'kept') {
53
- head.gone.push(heir);
54
- while (head.gone.length > GONE)
55
- delete head.heirs[head.gone.shift()];
56
- }
57
- this.#partition.toldHead();
58
- }
59
- delete(heir) {
60
- delete this.#head.heirs[heir];
61
- this.#partition.toldHead();
62
- }
63
- kept() {
64
- return this.#partition.kept();
65
- }
66
- }