@amalgm/shell 0.1.164-preview.36072132286 → 0.1.164-preview.36809057014

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 (475) hide show
  1. package/PURPOSE.md +642 -128
  2. package/README.md +10 -8
  3. package/dist/accepted-tail.d.ts +26 -0
  4. package/dist/accepted-tail.js +37 -0
  5. package/dist/accepted-tail.js.map +1 -0
  6. package/dist/agent-execution.d.ts +16 -1
  7. package/dist/agent-execution.js +13 -5
  8. package/dist/agent-execution.js.map +1 -1
  9. package/dist/apply-cleanup.d.ts +28 -0
  10. package/dist/apply-cleanup.js +166 -0
  11. package/dist/apply-cleanup.js.map +1 -0
  12. package/dist/apply-recovery.d.ts +47 -0
  13. package/dist/apply-recovery.js +99 -0
  14. package/dist/apply-recovery.js.map +1 -0
  15. package/dist/apply-rows.d.ts +72 -0
  16. package/dist/apply-rows.js +150 -0
  17. package/dist/apply-rows.js.map +1 -0
  18. package/dist/apply-saves.d.ts +85 -0
  19. package/dist/apply-saves.js +238 -0
  20. package/dist/apply-saves.js.map +1 -0
  21. package/dist/boot.js +2 -1
  22. package/dist/boot.js.map +1 -1
  23. package/dist/capture-work.d.ts +8 -0
  24. package/dist/capture-work.js +67 -0
  25. package/dist/capture-work.js.map +1 -0
  26. package/dist/cargo-group.d.ts +45 -0
  27. package/dist/cargo-group.js +88 -0
  28. package/dist/cargo-group.js.map +1 -0
  29. package/dist/channel-session.d.ts +4 -2
  30. package/dist/channel-session.js +4 -3
  31. package/dist/channel-session.js.map +1 -1
  32. package/dist/chat-composition.d.ts +2 -0
  33. package/dist/chat-composition.js +1 -0
  34. package/dist/chat-composition.js.map +1 -1
  35. package/dist/cli.js +20 -1
  36. package/dist/cli.js.map +1 -1
  37. package/dist/construct-apply-host.d.ts +4 -2
  38. package/dist/construct-apply-host.js +8 -3
  39. package/dist/construct-apply-host.js.map +1 -1
  40. package/dist/construct-door.js +1 -1
  41. package/dist/construct-door.js.map +1 -1
  42. package/dist/construct-ledger.d.ts +6 -1
  43. package/dist/construct-ledger.js +21 -33
  44. package/dist/construct-ledger.js.map +1 -1
  45. package/dist/content-cache-collection.d.ts +18 -0
  46. package/dist/content-cache-collection.js +99 -0
  47. package/dist/content-cache-collection.js.map +1 -0
  48. package/dist/content-cache-host.d.ts +83 -17
  49. package/dist/content-cache-host.js +335 -95
  50. package/dist/content-cache-host.js.map +1 -1
  51. package/dist/content-cache-namespace.d.ts +59 -0
  52. package/dist/content-cache-namespace.js +210 -0
  53. package/dist/content-cache-namespace.js.map +1 -0
  54. package/dist/content-cache-ownership.d.ts +13 -0
  55. package/dist/content-cache-ownership.js +75 -0
  56. package/dist/content-cache-ownership.js.map +1 -0
  57. package/dist/content-cache-retention.d.ts +23 -0
  58. package/dist/content-cache-retention.js +195 -0
  59. package/dist/content-cache-retention.js.map +1 -0
  60. package/dist/content-capture-pool.d.ts +287 -0
  61. package/dist/content-capture-pool.js +461 -0
  62. package/dist/content-capture-pool.js.map +1 -0
  63. package/dist/content-capture-worker.d.ts +8 -0
  64. package/dist/content-capture-worker.js +109 -0
  65. package/dist/content-capture-worker.js.map +1 -0
  66. package/dist/content-clock.d.ts +42 -0
  67. package/dist/content-clock.js +166 -0
  68. package/dist/content-clock.js.map +1 -0
  69. package/dist/content-direct.d.ts +2 -0
  70. package/dist/content-direct.js +12 -0
  71. package/dist/content-direct.js.map +1 -1
  72. package/dist/content-failure.d.ts +18 -0
  73. package/dist/content-failure.js +38 -0
  74. package/dist/content-failure.js.map +1 -0
  75. package/dist/content-stream-thread.d.ts +60 -0
  76. package/dist/content-stream-thread.js +95 -0
  77. package/dist/content-stream-thread.js.map +1 -0
  78. package/dist/content-stream-worker.d.ts +7 -0
  79. package/dist/content-stream-worker.js +52 -0
  80. package/dist/content-stream-worker.js.map +1 -0
  81. package/dist/declaration-absorption.d.ts +37 -0
  82. package/dist/declaration-absorption.js +119 -0
  83. package/dist/declaration-absorption.js.map +1 -0
  84. package/dist/declaration-chain.d.ts +36 -0
  85. package/dist/declaration-chain.js +96 -0
  86. package/dist/declaration-chain.js.map +1 -0
  87. package/dist/declaration-commit.d.ts +31 -0
  88. package/dist/declaration-commit.js +49 -0
  89. package/dist/declaration-commit.js.map +1 -0
  90. package/dist/declaration-hold.d.ts +22 -0
  91. package/dist/declaration-hold.js +24 -0
  92. package/dist/declaration-hold.js.map +1 -0
  93. package/dist/declaration-journal.d.ts +62 -0
  94. package/dist/declaration-journal.js +99 -0
  95. package/dist/declaration-journal.js.map +1 -0
  96. package/dist/declaration-save.d.ts +31 -0
  97. package/dist/declaration-save.js +134 -0
  98. package/dist/declaration-save.js.map +1 -0
  99. package/dist/detection/accepted-result.d.ts +19 -1
  100. package/dist/detection/accepted-result.js +36 -5
  101. package/dist/detection/accepted-result.js.map +1 -1
  102. package/dist/detection/admission-save.d.ts +55 -0
  103. package/dist/detection/admission-save.js +48 -0
  104. package/dist/detection/admission-save.js.map +1 -0
  105. package/dist/detection/admission-units.d.ts +66 -0
  106. package/dist/detection/admission-units.js +322 -0
  107. package/dist/detection/admission-units.js.map +1 -0
  108. package/dist/detection/alias-discovery.d.ts +12 -0
  109. package/dist/detection/alias-discovery.js +80 -0
  110. package/dist/detection/alias-discovery.js.map +1 -0
  111. package/dist/detection/alias-examination.d.ts +30 -0
  112. package/dist/detection/alias-examination.js +49 -0
  113. package/dist/detection/alias-examination.js.map +1 -0
  114. package/dist/detection/apply-ownership.d.ts +81 -0
  115. package/dist/detection/apply-ownership.js +232 -0
  116. package/dist/detection/apply-ownership.js.map +1 -0
  117. package/dist/detection/basis-advanced.d.ts +11 -0
  118. package/dist/detection/basis-advanced.js +26 -0
  119. package/dist/detection/basis-advanced.js.map +1 -0
  120. package/dist/detection/capture-outcome.d.ts +16 -0
  121. package/dist/detection/capture-outcome.js +92 -0
  122. package/dist/detection/capture-outcome.js.map +1 -0
  123. package/dist/detection/container-membership.d.ts +32 -0
  124. package/dist/detection/container-membership.js +49 -0
  125. package/dist/detection/container-membership.js.map +1 -0
  126. package/dist/detection/detect-cancelled.d.ts +6 -0
  127. package/dist/detection/detect-cancelled.js +10 -0
  128. package/dist/detection/detect-cancelled.js.map +1 -0
  129. package/dist/detection/directory-proof.d.ts +47 -0
  130. package/dist/detection/directory-proof.js +77 -0
  131. package/dist/detection/directory-proof.js.map +1 -0
  132. package/dist/detection/disposition-rows.d.ts +18 -0
  133. package/dist/detection/disposition-rows.js +29 -0
  134. package/dist/detection/disposition-rows.js.map +1 -0
  135. package/dist/detection/dispositions.d.ts +130 -0
  136. package/dist/detection/dispositions.js +248 -0
  137. package/dist/detection/dispositions.js.map +1 -0
  138. package/dist/detection/git-notice.d.ts +88 -0
  139. package/dist/detection/git-notice.js +444 -0
  140. package/dist/detection/git-notice.js.map +1 -0
  141. package/dist/detection/ground-proof.d.ts +130 -0
  142. package/dist/detection/ground-proof.js +274 -0
  143. package/dist/detection/ground-proof.js.map +1 -0
  144. package/dist/detection/ground-reader.d.ts +29 -0
  145. package/dist/detection/ground-reader.js +102 -0
  146. package/dist/detection/ground-reader.js.map +1 -0
  147. package/dist/detection/held-territory.d.ts +51 -0
  148. package/dist/detection/held-territory.js +205 -0
  149. package/dist/detection/held-territory.js.map +1 -0
  150. package/dist/detection/identity-discovery.d.ts +45 -0
  151. package/dist/detection/identity-discovery.js +287 -0
  152. package/dist/detection/identity-discovery.js.map +1 -0
  153. package/dist/detection/maintenance-sweep.d.ts +108 -0
  154. package/dist/detection/maintenance-sweep.js +325 -0
  155. package/dist/detection/maintenance-sweep.js.map +1 -0
  156. package/dist/detection/name-reach.d.ts +12 -0
  157. package/dist/detection/name-reach.js +28 -0
  158. package/dist/detection/name-reach.js.map +1 -0
  159. package/dist/detection/notebook-basis.d.ts +5 -7
  160. package/dist/detection/notebook-basis.js +6 -7
  161. package/dist/detection/notebook-basis.js.map +1 -1
  162. package/dist/detection/owed-selection.d.ts +51 -0
  163. package/dist/detection/owed-selection.js +169 -0
  164. package/dist/detection/owed-selection.js.map +1 -0
  165. package/dist/detection/portable.d.ts +34 -34
  166. package/dist/detection/portable.js +67 -93
  167. package/dist/detection/portable.js.map +1 -1
  168. package/dist/detection/reconciliation-coverage.d.ts +7 -0
  169. package/dist/detection/reconciliation-coverage.js +16 -0
  170. package/dist/detection/reconciliation-coverage.js.map +1 -0
  171. package/dist/detection/repository-publication.d.ts +20 -0
  172. package/dist/detection/repository-publication.js +79 -0
  173. package/dist/detection/repository-publication.js.map +1 -0
  174. package/dist/detection/repository-routes.d.ts +43 -0
  175. package/dist/detection/repository-routes.js +97 -0
  176. package/dist/detection/repository-routes.js.map +1 -0
  177. package/dist/detection/root-examination.d.ts +94 -0
  178. package/dist/detection/root-examination.js +523 -0
  179. package/dist/detection/root-examination.js.map +1 -0
  180. package/dist/detection/runtime.d.ts +131 -64
  181. package/dist/detection/runtime.js +808 -1103
  182. package/dist/detection/runtime.js.map +1 -1
  183. package/dist/detection/scoped-identity-port.d.ts +34 -0
  184. package/dist/detection/scoped-identity-port.js +81 -0
  185. package/dist/detection/scoped-identity-port.js.map +1 -0
  186. package/dist/detection/seal-law.d.ts +66 -0
  187. package/dist/detection/seal-law.js +116 -0
  188. package/dist/detection/seal-law.js.map +1 -0
  189. package/dist/detection/sharing-policy.d.ts +11 -0
  190. package/dist/detection/sharing-policy.js +32 -0
  191. package/dist/detection/sharing-policy.js.map +1 -0
  192. package/dist/detection/thread-database.d.ts +4 -0
  193. package/dist/detection/thread-database.js +30 -0
  194. package/dist/detection/thread-database.js.map +1 -0
  195. package/dist/detection/unreadable.d.ts +11 -0
  196. package/dist/detection/unreadable.js +9 -0
  197. package/dist/detection/unreadable.js.map +1 -0
  198. package/dist/detection/verified-content.d.ts +6 -0
  199. package/dist/detection/verified-content.js +12 -0
  200. package/dist/detection/verified-content.js.map +1 -0
  201. package/dist/detection/walk-law.d.ts +34 -0
  202. package/dist/detection/walk-law.js +55 -0
  203. package/dist/detection/walk-law.js.map +1 -0
  204. package/dist/development/fly-guest.js +2 -1
  205. package/dist/development/fly-guest.js.map +1 -1
  206. package/dist/entity-apply-host.d.ts +29 -13
  207. package/dist/entity-apply-host.js +1426 -461
  208. package/dist/entity-apply-host.js.map +1 -1
  209. package/dist/entity-apply-store.d.ts +77 -30
  210. package/dist/entity-apply-store.js +221 -516
  211. package/dist/entity-apply-store.js.map +1 -1
  212. package/dist/entity-record-observability.js +2 -0
  213. package/dist/entity-record-observability.js.map +1 -1
  214. package/dist/entity-record-saves.d.ts +20 -0
  215. package/dist/entity-record-saves.js +91 -0
  216. package/dist/entity-record-saves.js.map +1 -0
  217. package/dist/entity-record-store.d.ts +15 -7
  218. package/dist/entity-record-store.js +57 -117
  219. package/dist/entity-record-store.js.map +1 -1
  220. package/dist/files-register-host.d.ts +22 -3
  221. package/dist/files-register-host.js +70 -31
  222. package/dist/files-register-host.js.map +1 -1
  223. package/dist/filesystem.js +3 -2
  224. package/dist/filesystem.js.map +1 -1
  225. package/dist/git-binding.d.ts +65 -0
  226. package/dist/git-binding.js +220 -0
  227. package/dist/git-binding.js.map +1 -0
  228. package/dist/git-capture.d.ts +39 -0
  229. package/dist/git-capture.js +86 -0
  230. package/dist/git-capture.js.map +1 -0
  231. package/dist/git-card.d.ts +12 -0
  232. package/dist/git-card.js +123 -0
  233. package/dist/git-card.js.map +1 -0
  234. package/dist/git-checkpoint-construction.d.ts +41 -0
  235. package/dist/git-checkpoint-construction.js +96 -0
  236. package/dist/git-checkpoint-construction.js.map +1 -0
  237. package/dist/git-checkpoint-preparation.d.ts +37 -0
  238. package/dist/git-checkpoint-preparation.js +145 -0
  239. package/dist/git-checkpoint-preparation.js.map +1 -0
  240. package/dist/git-command.d.ts +61 -8
  241. package/dist/git-command.js +217 -63
  242. package/dist/git-command.js.map +1 -1
  243. package/dist/git-configuration.d.ts +40 -0
  244. package/dist/git-configuration.js +217 -0
  245. package/dist/git-configuration.js.map +1 -0
  246. package/dist/git-evidence.d.ts +61 -0
  247. package/dist/git-evidence.js +181 -0
  248. package/dist/git-evidence.js.map +1 -0
  249. package/dist/git-index-entries.d.ts +15 -0
  250. package/dist/git-index-entries.js +44 -0
  251. package/dist/git-index-entries.js.map +1 -0
  252. package/dist/git-index-format.d.ts +35 -0
  253. package/dist/git-index-format.js +293 -0
  254. package/dist/git-index-format.js.map +1 -0
  255. package/dist/git-index-witness.d.ts +33 -0
  256. package/dist/git-index-witness.js +69 -0
  257. package/dist/git-index-witness.js.map +1 -0
  258. package/dist/git-literal-host.d.ts +82 -0
  259. package/dist/git-literal-host.js +172 -0
  260. package/dist/git-literal-host.js.map +1 -0
  261. package/dist/git-literal-read.d.ts +88 -0
  262. package/dist/git-literal-read.js +170 -0
  263. package/dist/git-literal-read.js.map +1 -0
  264. package/dist/git-literal-replay.d.ts +33 -0
  265. package/dist/git-literal-replay.js +268 -0
  266. package/dist/git-literal-replay.js.map +1 -0
  267. package/dist/git-native-file.d.ts +42 -0
  268. package/dist/git-native-file.js +145 -0
  269. package/dist/git-native-file.js.map +1 -0
  270. package/dist/git-native-index.d.ts +21 -0
  271. package/dist/git-native-index.js +44 -0
  272. package/dist/git-native-index.js.map +1 -0
  273. package/dist/git-operation-host.d.ts +48 -0
  274. package/dist/git-operation-host.js +127 -0
  275. package/dist/git-operation-host.js.map +1 -0
  276. package/dist/git-private-index.d.ts +11 -0
  277. package/dist/git-private-index.js +42 -0
  278. package/dist/git-private-index.js.map +1 -0
  279. package/dist/git-private-repository.d.ts +4 -0
  280. package/dist/git-private-repository.js +69 -0
  281. package/dist/git-private-repository.js.map +1 -0
  282. package/dist/git-private-view.d.ts +39 -0
  283. package/dist/git-private-view.js +162 -0
  284. package/dist/git-private-view.js.map +1 -0
  285. package/dist/git-ref-store.d.ts +12 -0
  286. package/dist/git-ref-store.js +68 -0
  287. package/dist/git-ref-store.js.map +1 -0
  288. package/dist/git-registration-host.d.ts +20 -30
  289. package/dist/git-registration-host.js +86 -249
  290. package/dist/git-registration-host.js.map +1 -1
  291. package/dist/git-repository-host.d.ts +148 -22
  292. package/dist/git-repository-host.js +633 -650
  293. package/dist/git-repository-host.js.map +1 -1
  294. package/dist/git-worktree-host.d.ts +2 -0
  295. package/dist/git-worktree-host.js +16 -0
  296. package/dist/git-worktree-host.js.map +1 -0
  297. package/dist/graph-publication.d.ts +75 -0
  298. package/dist/graph-publication.js +203 -0
  299. package/dist/graph-publication.js.map +1 -0
  300. package/dist/ground-basis.d.ts +242 -0
  301. package/dist/ground-basis.js +1023 -0
  302. package/dist/ground-basis.js.map +1 -0
  303. package/dist/ground-checkpoint-worker.d.ts +1 -0
  304. package/dist/ground-checkpoint-worker.js +84 -0
  305. package/dist/ground-checkpoint-worker.js.map +1 -0
  306. package/dist/ground-checkpoints.d.ts +16 -0
  307. package/dist/ground-checkpoints.js +45 -0
  308. package/dist/ground-checkpoints.js.map +1 -0
  309. package/dist/ground-coordination.d.ts +107 -3
  310. package/dist/ground-coordination.js +249 -24
  311. package/dist/ground-coordination.js.map +1 -1
  312. package/dist/ground-database.d.ts +42 -0
  313. package/dist/ground-database.js +290 -0
  314. package/dist/ground-database.js.map +1 -0
  315. package/dist/ground-differences.d.ts +23 -0
  316. package/dist/ground-differences.js +47 -0
  317. package/dist/ground-differences.js.map +1 -0
  318. package/dist/ground-holders.d.ts +4 -0
  319. package/dist/ground-holders.js +15 -0
  320. package/dist/ground-holders.js.map +1 -0
  321. package/dist/ground-initialization-worker.d.ts +1 -0
  322. package/dist/ground-initialization-worker.js +20 -0
  323. package/dist/ground-initialization-worker.js.map +1 -0
  324. package/dist/ground-initialization.d.ts +35 -0
  325. package/dist/ground-initialization.js +102 -0
  326. package/dist/ground-initialization.js.map +1 -0
  327. package/dist/ground-install-saves.d.ts +63 -0
  328. package/dist/ground-install-saves.js +139 -0
  329. package/dist/ground-install-saves.js.map +1 -0
  330. package/dist/ground-inventory-schema.d.ts +18 -0
  331. package/dist/ground-inventory-schema.js +168 -0
  332. package/dist/ground-inventory-schema.js.map +1 -0
  333. package/dist/ground-profile.d.ts +7 -0
  334. package/dist/ground-profile.js +52 -0
  335. package/dist/ground-profile.js.map +1 -0
  336. package/dist/ground-root-index.d.ts +2 -1
  337. package/dist/ground-root-index.js +16 -14
  338. package/dist/ground-root-index.js.map +1 -1
  339. package/dist/ground-row.d.ts +62 -0
  340. package/dist/ground-row.js +70 -0
  341. package/dist/ground-row.js.map +1 -0
  342. package/dist/ground-save-ops.d.ts +44 -0
  343. package/dist/ground-save-ops.js +41 -0
  344. package/dist/ground-save-ops.js.map +1 -0
  345. package/dist/ground-saver-worker.d.ts +1 -0
  346. package/dist/ground-saver-worker.js +156 -0
  347. package/dist/ground-saver-worker.js.map +1 -0
  348. package/dist/ground-saver.d.ts +75 -0
  349. package/dist/ground-saver.js +216 -0
  350. package/dist/ground-saver.js.map +1 -0
  351. package/dist/ground-store.d.ts +84 -0
  352. package/dist/ground-store.js +473 -0
  353. package/dist/ground-store.js.map +1 -0
  354. package/dist/ground-territory.d.ts +130 -0
  355. package/dist/ground-territory.js +511 -0
  356. package/dist/ground-territory.js.map +1 -0
  357. package/dist/index.d.ts +1 -1
  358. package/dist/index.js.map +1 -1
  359. package/dist/installation/ownership.d.ts +0 -2
  360. package/dist/installation/ownership.js +3 -15
  361. package/dist/installation/ownership.js.map +1 -1
  362. package/dist/machine-host.d.ts +3 -2
  363. package/dist/machine-host.js +28 -16
  364. package/dist/machine-host.js.map +1 -1
  365. package/dist/materialized-graph.d.ts +7 -7
  366. package/dist/materialized-graph.js +11 -23
  367. package/dist/materialized-graph.js.map +1 -1
  368. package/dist/module-thread.d.ts +9 -0
  369. package/dist/module-thread.js +10 -0
  370. package/dist/module-thread.js.map +1 -0
  371. package/dist/native/fsevents-stream.node +0 -0
  372. package/dist/physical-path-witness.d.ts +64 -0
  373. package/dist/physical-path-witness.js +168 -0
  374. package/dist/physical-path-witness.js.map +1 -0
  375. package/dist/register-upload-fusion.d.ts +5 -4
  376. package/dist/register-upload-fusion.js +9 -6
  377. package/dist/register-upload-fusion.js.map +1 -1
  378. package/dist/registry-graph.d.ts +3 -2
  379. package/dist/registry-graph.js +9 -6
  380. package/dist/registry-graph.js.map +1 -1
  381. package/dist/registry-page-cache.d.ts +5 -2
  382. package/dist/registry-page-cache.js.map +1 -1
  383. package/dist/repository-identity-steps.d.ts +5 -0
  384. package/dist/repository-identity-steps.js +33 -0
  385. package/dist/repository-identity-steps.js.map +1 -0
  386. package/dist/runtime-node-flags.d.ts +10 -0
  387. package/dist/runtime-node-flags.js +11 -0
  388. package/dist/runtime-node-flags.js.map +1 -0
  389. package/dist/service/adapter.d.ts +1 -1
  390. package/dist/service/adapter.js +1 -1
  391. package/dist/service/adapter.js.map +1 -1
  392. package/dist/service/cli.js +16 -20
  393. package/dist/service/cli.js.map +1 -1
  394. package/dist/service/control.d.ts +2 -2
  395. package/dist/service/keepalive.d.ts +4 -11
  396. package/dist/service/keepalive.js +65 -118
  397. package/dist/service/keepalive.js.map +1 -1
  398. package/dist/service/policy.d.ts +36 -0
  399. package/dist/service/policy.js +25 -0
  400. package/dist/service/policy.js.map +1 -0
  401. package/dist/service/portable.d.ts +1 -1
  402. package/dist/service/portable.js +1 -1
  403. package/dist/service/portable.js.map +1 -1
  404. package/dist/service/recovery.d.ts +10 -9
  405. package/dist/service/recovery.js +29 -19
  406. package/dist/service/recovery.js.map +1 -1
  407. package/dist/service/windows-action.d.ts +5 -3
  408. package/dist/service/windows-action.js +6 -9
  409. package/dist/service/windows-action.js.map +1 -1
  410. package/dist/service/windows-task.js +5 -5
  411. package/dist/service/windows-task.js.map +1 -1
  412. package/dist/sharing-admission.d.ts +17 -0
  413. package/dist/sharing-admission.js +128 -0
  414. package/dist/sharing-admission.js.map +1 -0
  415. package/dist/snapshot-delivery-baseline.d.ts +12 -3
  416. package/dist/snapshot-delivery-baseline.js +41 -42
  417. package/dist/snapshot-delivery-baseline.js.map +1 -1
  418. package/dist/source-proof.d.ts +36 -0
  419. package/dist/source-proof.js +70 -0
  420. package/dist/source-proof.js.map +1 -0
  421. package/dist/source-signature.d.ts +56 -0
  422. package/dist/source-signature.js +56 -0
  423. package/dist/source-signature.js.map +1 -0
  424. package/dist/source-witness.d.ts +15 -0
  425. package/dist/source-witness.js +29 -0
  426. package/dist/source-witness.js.map +1 -0
  427. package/dist/sqlite-durability.d.ts +31 -0
  428. package/dist/sqlite-durability.js +28 -0
  429. package/dist/sqlite-durability.js.map +1 -0
  430. package/dist/sqlite.d.ts +8 -2
  431. package/dist/sqlite.js +27 -4
  432. package/dist/sqlite.js.map +1 -1
  433. package/dist/sync-address.d.ts +19 -0
  434. package/dist/sync-address.js +52 -0
  435. package/dist/sync-address.js.map +1 -0
  436. package/dist/sync-setting.d.ts +15 -0
  437. package/dist/sync-setting.js +13 -0
  438. package/dist/sync-setting.js.map +1 -1
  439. package/dist/turns.d.ts +42 -0
  440. package/dist/turns.js +112 -0
  441. package/dist/turns.js.map +1 -0
  442. package/dist/updates/bootstrap.d.ts +53 -7
  443. package/dist/updates/bootstrap.js +224 -137
  444. package/dist/updates/bootstrap.js.map +1 -1
  445. package/dist/updates/controller.d.ts +8 -0
  446. package/dist/updates/controller.js +27 -3
  447. package/dist/updates/controller.js.map +1 -1
  448. package/dist/updates/store.d.ts +3 -0
  449. package/dist/updates/store.js +12 -0
  450. package/dist/updates/store.js.map +1 -1
  451. package/dist/user-ground-host.d.ts +364 -69
  452. package/dist/user-ground-host.js +5231 -3366
  453. package/dist/user-ground-host.js.map +1 -1
  454. package/dist/watching/fsevents.d.ts +52 -1
  455. package/dist/watching/fsevents.js +60 -25
  456. package/dist/watching/fsevents.js.map +1 -1
  457. package/dist/watching/host.d.ts +129 -5
  458. package/dist/watching/host.js +433 -80
  459. package/dist/watching/host.js.map +1 -1
  460. package/dist/watching/index.d.ts +1 -1
  461. package/dist/wire-binary.d.ts +3 -2
  462. package/dist/wire-binary.js +10 -8
  463. package/dist/wire-binary.js.map +1 -1
  464. package/dist/wire-client.d.ts +3 -4
  465. package/dist/wire-client.js +18 -44
  466. package/dist/wire-client.js.map +1 -1
  467. package/dist/wire-outbox.d.ts +34 -0
  468. package/dist/wire-outbox.js +127 -0
  469. package/dist/wire-outbox.js.map +1 -0
  470. package/dist/workspace-host.d.ts +4 -0
  471. package/dist/workspace-host.js +12 -1
  472. package/dist/workspace-host.js.map +1 -1
  473. package/examinations/fixtures/private-wire-authority.js +133 -10
  474. package/npm-shrinkwrap.json +43 -56
  475. package/package.json +26 -13
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Register's enclosing law. W's ground may enclose workspaces this machine
3
+ * already materializes. Each one the authority holds as its own root is
4
+ * absorbed: its accepted subtree joins W's head with every identity kept,
5
+ * and its root leaves the head in the same commit. Only its root record
6
+ * changes: it is re-placed where W's walk found it, under its parentUUID
7
+ * and name there, and a `workspace`, which only a root can be, becomes a
8
+ * `folder`.
9
+ *
10
+ * Absorbed ground rides as each inventory already holds it. The head
11
+ * carries its accepted records, and sharing (B) keeps its own rows
12
+ * (declaration-save.ts), so local work there, including an identity the walk
13
+ * found moved out of it, stays owed to ordinary Detect. Only identities an
14
+ * inventory lacks enter from the walk.
15
+ */
16
+ import { canonicalVersion, eachStep, refusal, } from "@amalgm/live";
17
+ import { pathWithin } from "./files-register-host.js";
18
+ import { acceptedResultRootResolver, acceptedRoot, deriveContainerVersionsSteps, } from "./graph-publication.js";
19
+ import { eachInTurns, finishStepsInTurns } from "./turns.js";
20
+ /** The bound workspaces W's ground encloses. */
21
+ export function enclosedWorkspaces(bindings, workspaceId, directory) {
22
+ return bindings.filter((binding) => binding.workspaceId !== workspaceId && pathWithin(directory, binding.directory));
23
+ }
24
+ /** The root AV holds this identity in, or null when AV never accepted it. */
25
+ export async function acceptedHolder(view, uuid) {
26
+ const tailed = view.tail.results.find((result) => result.uuid === uuid);
27
+ if (tailed)
28
+ return acceptedResultRootResolver(view.tail.results, view.located)(tailed);
29
+ return view.head.graph.locate(uuid);
30
+ }
31
+ /** The enclosed workspaces W absorbs on this view. One held inside another
32
+ * enclosed workspace rides with it. Anything else refuses: ground whose own
33
+ * declaration the authority has not accepted, or that it holds inside a root
34
+ * this machine does not enclose, would move identities W never observed. */
35
+ export async function absorbedRoots(view, workspaceId, enclosed, held) {
36
+ const enclosedIds = new Set(enclosed.map((entry) => entry.workspaceId));
37
+ const absorbed = [];
38
+ for (const { workspaceId: inner, directory } of enclosed) {
39
+ const refused = (why) => refusal(`files register refuses workspace ${workspaceId}: `
40
+ + `the workspace ${inner} it encloses at ${directory} ${why}`);
41
+ if (held.has(inner))
42
+ throw refused("still awaits its own registration; register it again first");
43
+ const holder = await acceptedHolder(view, inner);
44
+ if (holder === null)
45
+ throw refused("was never accepted");
46
+ if (holder !== inner) {
47
+ if (enclosedIds.has(holder))
48
+ continue;
49
+ throw refused(`is accepted inside root ${holder}, which this workspace does not enclose`);
50
+ }
51
+ const tailed = view.tail.results.find((result) => result.uuid === inner);
52
+ const status = (tailed ?? await view.head.graph.rootRecord(inner)).status;
53
+ if (status !== "active")
54
+ throw refused(`is ${status} in the accepted graph`);
55
+ absorbed.push(inner);
56
+ }
57
+ return absorbed;
58
+ }
59
+ /** An absorbed root's own record, re-placed where W's walk found it. */
60
+ export function placeAbsorbedRoot(record, placement, sha256Hex) {
61
+ const type = record.type === "workspace" ? "folder" : record.type;
62
+ const placed = { ...record, type, parentUUID: placement.parentUUID, name: placement.name };
63
+ return { ...placed, version: canonicalVersion(placed, sha256Hex) };
64
+ }
65
+ /** D's records for W: the walk outside absorbed ground, minus identities AV
66
+ * already holds there, plus each absorbed root exactly as AV holds it with
67
+ * its root re-placed. Container versions derive from D's own membership. */
68
+ export async function absorbingDeclaration(view, workspaceId, walked, absorbed, sha256Hex) {
69
+ if (absorbed.length === 0)
70
+ return walked;
71
+ const walkedById = new Map();
72
+ await eachInTurns(walked, (record) => { walkedById.set(record.uuid, record); });
73
+ const accepted = new Map();
74
+ for (const root of absorbed) {
75
+ const placement = walkedById.get(root);
76
+ if (!placement) {
77
+ throw refusal(`files register refuses workspace ${workspaceId}: its enrollment policy leaves out `
78
+ + `the workspace ${root} it encloses, so that workspace has no place in its graph`);
79
+ }
80
+ await eachInTurns((await acceptedRoot(view, root, sha256Hex)).values(), (record) => {
81
+ accepted.set(record.uuid, record.uuid === root ? placeAbsorbedRoot(record, placement, sha256Hex) : record);
82
+ });
83
+ }
84
+ const inside = await finishStepsInTurns(absorbedGroundSteps(walked, absorbed));
85
+ const records = [];
86
+ await eachInTurns(walked, (record) => {
87
+ if (!inside.has(record.uuid) && !accepted.has(record.uuid))
88
+ records.push(record);
89
+ });
90
+ await eachInTurns(accepted.values(), (record) => { records.push(record); });
91
+ return finishStepsInTurns(deriveContainerVersionsSteps(records, sha256Hex));
92
+ }
93
+ /** Every walked identity inside an absorbed root, the root included. */
94
+ function* absorbedGroundSteps(walked, absorbed) {
95
+ const children = new Map();
96
+ yield* eachStep(walked, ({ uuid, parentUUID }) => {
97
+ if (parentUUID === null)
98
+ return;
99
+ const siblings = children.get(parentUUID);
100
+ if (siblings)
101
+ siblings.push(uuid);
102
+ else
103
+ children.set(parentUUID, [uuid]);
104
+ });
105
+ const inside = new Set();
106
+ const pending = [...absorbed];
107
+ function* reached() {
108
+ for (let uuid = pending.pop(); uuid !== undefined; uuid = pending.pop())
109
+ yield uuid;
110
+ }
111
+ yield* eachStep(reached(), (uuid) => {
112
+ if (inside.has(uuid))
113
+ return;
114
+ inside.add(uuid);
115
+ pending.push(...children.get(uuid) ?? []);
116
+ });
117
+ return inside;
118
+ }
119
+ //# sourceMappingURL=declaration-absorption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-absorption.js","sourceRoot":"","sources":["../src/declaration-absorption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,OAAO,GAKR,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,4BAA4B,GAE7B,MAAM,wBAAwB,CAAC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AAQ,CAAC,CAAC,OAAO;QACf,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,KAAK,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;YAAE,MAAM,IAAI,CAAC;IACtF,CAAC;IACD,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;QAClC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QAC7B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type Database from "better-sqlite3";
2
+ import { type CloudEntityRecord, type Sha256Hex } from "@amalgm/live";
3
+ import { type ContentBoundary } from "./content-clock.js";
4
+ import type { GroundRow } from "./ground-row.js";
5
+ export interface DeclarationChain {
6
+ /** The core records D declares: the reference, and its folder when the
7
+ * accepted view lacks it. */
8
+ readonly records: readonly CloudEntityRecord[];
9
+ /** Rows for the chain's two addresses, reference first, as observed when
10
+ * derived. */
11
+ readonly chained: readonly GroundRow[];
12
+ /** What local ground named at each chained address when derived. */
13
+ readonly named: readonly (string | null)[];
14
+ /** B rows for exactly the declared records. */
15
+ readonly shared: readonly GroundRow[];
16
+ /** The containers whose membership the chain decides: its folder, then
17
+ * the core root. */
18
+ readonly containers: readonly string[];
19
+ }
20
+ /** Derive W's chain in core ground. `accepted` is AV's core root. */
21
+ export declare function deriveDeclarationChain(input: {
22
+ readonly database: Database.Database;
23
+ readonly resourceId: string;
24
+ readonly userRoot: string;
25
+ readonly bindingDir: string;
26
+ readonly coreRootId: string;
27
+ readonly workspaceId: string;
28
+ readonly accepted: ReadonlyMap<string, CloudEntityRecord>;
29
+ /** The core root's content clock, stamped before this read. */
30
+ readonly clock: ContentBoundary | null;
31
+ /** The UUID minted for an address no row names; see `addressMinter`. */
32
+ readonly mint: (relativePath: string) => string;
33
+ readonly sha256Hex: Sha256Hex;
34
+ }): DeclarationChain;
35
+ /** One UUID per address, however often the chain is derived again. */
36
+ export declare function addressMinter(mint: () => string): (relativePath: string) => string;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The core records one Register declaration adds beside its root W: W's
3
+ * managed reference, and the `workspaces` folder that holds it while the
4
+ * accepted view lacks that folder.
5
+ *
6
+ * Identity follows local ground: sharing (B) first, then observation (O), so
7
+ * repeating a declaration names the same UUIDs. A folder no local row names
8
+ * adopts the accepted folder in its slot, and only then is a UUID minted, once
9
+ * per address for the whole Register.
10
+ * Both are read from the rendered reference itself: a reference that is gone
11
+ * ends the declaration, because D would name ground this machine no longer
12
+ * holds.
13
+ *
14
+ * Core Detect keeps observing the same ground while Register works. The chain
15
+ * is derived on the main thread; the only facts it read that can move before
16
+ * its commit are what local ground names at its two addresses. The commit
17
+ * reads those again on the saver thread and never writes a chain whose
18
+ * identities moved.
19
+ */
20
+ import { lstatSync } from "node:fs";
21
+ import { basename, join } from "node:path";
22
+ import { canonicalVersion, membershipHash, refusal } from "@amalgm/live";
23
+ import { leafBoundary } from "./content-clock.js";
24
+ import { namedAt } from "./declaration-save.js";
25
+ import { findReference } from "./files-register-host.js";
26
+ import { sourceFingerprint } from "./source-signature.js";
27
+ const WORKSPACES = "workspaces";
28
+ /** Derive W's chain in core ground. `accepted` is AV's core root. */
29
+ export function deriveDeclarationChain(input) {
30
+ const { database, resourceId, userRoot, coreRootId, workspaceId, accepted, sha256Hex } = input;
31
+ const folderPath = join(userRoot, WORKSPACES);
32
+ const referencePath = findReference(folderPath, input.bindingDir, workspaceId);
33
+ if (referencePath === null) {
34
+ throw refusal(`workspace ${workspaceId} has no reference in ${folderPath}; run files register again`);
35
+ }
36
+ const name = basename(referencePath);
37
+ const referenceRelative = `${WORKSPACES}/${name}`;
38
+ const named = [referenceRelative, WORKSPACES].map(relativePath => namedAt(database, resourceId, coreRootId, relativePath));
39
+ const acceptedFolder = [...accepted.values()].find(record => record.parentUUID === coreRootId
40
+ && record.name === WORKSPACES && record.type === "folder" && record.status === "active");
41
+ const folderId = named[1] ?? acceptedFolder?.uuid ?? input.mint(WORKSPACES);
42
+ const acceptedAsFolder = accepted.get(folderId);
43
+ if (acceptedAsFolder && (acceptedAsFolder.status !== "active" || acceptedAsFolder.type !== "folder")) {
44
+ throw refusal(`${folderPath} is ${acceptedAsFolder.status} ${acceptedAsFolder.type} ${folderId} in the accepted graph`);
45
+ }
46
+ const reference = canonical({
47
+ uuid: named[0] ?? input.mint(referenceRelative),
48
+ type: "reference", parentUUID: folderId, name, payloadVersion: workspaceId,
49
+ }, sha256Hex);
50
+ const folder = canonical({
51
+ uuid: folderId, type: "folder", parentUUID: coreRootId, name: WORKSPACES,
52
+ payloadVersion: membershipHash([{ uuid: reference.uuid, name }], sha256Hex),
53
+ }, sha256Hex);
54
+ const row = (record, relativePath, absolutePath) => {
55
+ const stats = lstatSync(absolutePath, { bigint: true });
56
+ return {
57
+ resourceId, rootUUID: coreRootId, uuid: record.uuid, type: record.type,
58
+ parentUUID: record.parentUUID, name: record.name, status: "active", version: record.version,
59
+ payloadVersion: record.payloadVersion, transportVersion: null, relativePath, absolutePath,
60
+ contentVerifiedNs: record.type === "reference" ? leafBoundary(input.clock, stats) : null,
61
+ ...sourceFingerprint(stats),
62
+ };
63
+ };
64
+ const chained = [row(reference, referenceRelative, referencePath), row(folder, WORKSPACES, folderPath)];
65
+ const declaresFolder = acceptedAsFolder === undefined;
66
+ return {
67
+ records: declaresFolder ? [reference, folder] : [reference],
68
+ chained,
69
+ named,
70
+ shared: declaresFolder ? chained : [chained[0]],
71
+ containers: [folderId, coreRootId],
72
+ };
73
+ }
74
+ /** One UUID per address, however often the chain is derived again. */
75
+ export function addressMinter(mint) {
76
+ const minted = new Map();
77
+ return (relativePath) => {
78
+ let uuid = minted.get(relativePath);
79
+ if (uuid === undefined)
80
+ minted.set(relativePath, uuid = mint());
81
+ return uuid;
82
+ };
83
+ }
84
+ function canonical(fields, sha256Hex) {
85
+ const derived = fields.type === "folder";
86
+ return {
87
+ ...fields,
88
+ status: "active",
89
+ // A folder's payload is its membership, which never travels.
90
+ payloadVersion: derived ? null : fields.payloadVersion,
91
+ fileMode: null,
92
+ transportVersion: null,
93
+ version: canonicalVersion({ ...fields, status: "active" }, sha256Hex),
94
+ };
95
+ }
96
+ //# sourceMappingURL=declaration-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-chain.js","sourceRoot":"","sources":["../src/declaration-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAA0C,MAAM,cAAc,CAAC;AAEjH,OAAO,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,UAAU,GAAG,YAAY,CAAC;AAkBhC,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,KAatC;IACC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC/F,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE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,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { DeclarationChain } from "./declaration-chain.js";
2
+ import type { DeclarationJournalEntry } from "./declaration-journal.js";
3
+ import type { RepositorySealCandidate } from "./detection/seal-law.js";
4
+ import type { RepositoryObservationPair } from "./git-repository-host.js";
5
+ import type { GroundRow } from "./ground-row.js";
6
+ import type { SourceProof } from "./source-proof.js";
7
+ /** Core ground moved the chain after D was derived. */
8
+ export declare class DeclarationChainMoved extends Error {
9
+ constructor();
10
+ }
11
+ /** W's walk: rows in its own root, admitted only while its witnesses close. */
12
+ export interface DeclarationWalk {
13
+ /** Its semantic phase has already answered. */
14
+ readonly source: SourceProof;
15
+ readonly repositoryObservations: readonly RepositoryObservationPair[];
16
+ readonly observed: readonly GroundRow[];
17
+ readonly selected: readonly GroundRow[];
18
+ /** Repository seals, installed only with the rows they describe. */
19
+ readonly seals: readonly RepositorySealCandidate[];
20
+ }
21
+ export declare function commitDeclaration(file: string, input: {
22
+ readonly resourceId: string;
23
+ readonly coreRootId: string;
24
+ readonly walk: DeclarationWalk | null;
25
+ /** The enclosed roots D absorbs. */
26
+ readonly absorbed: readonly string[];
27
+ /** Every bound root W's ground encloses. */
28
+ readonly enclosed: readonly string[];
29
+ readonly chain: DeclarationChain;
30
+ readonly journal: DeclarationJournalEntry;
31
+ }): Promise<void>;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Admit one Register declaration D beside its journal row, and nothing else.
3
+ *
4
+ * Register admits D and the bookkeeping needed to install D: W's observation
5
+ * (O) and selection (B) exactly as its walk captured them, sharing's own rows
6
+ * of any ground W absorbs, W's chain in core, and the container versions
7
+ * those change in each inventory. Every other observation stays owed to
8
+ * ordinary Detect.
9
+ *
10
+ * The walk's witnesses are judged on a content thread and its admission runs
11
+ * here as the save posts, so W stands exactly as captured: Register holds W's
12
+ * ground, and saves commit in post order. The save (declaration-save.ts)
13
+ * reads the chain's addresses again on the saver thread, and a chain whose
14
+ * identities moved since D was derived commits nothing: the caller derives
15
+ * again. A re-fold after the authority moved commits no walk. W's rows
16
+ * already stand, and local work in W after its walk becomes ordinary Records
17
+ * once the declaration is accepted.
18
+ */
19
+ import { closePhysicallyOffThread } from "./content-capture-pool.js";
20
+ import { save } from "./ground-saver.js";
21
+ /** Core ground moved the chain after D was derived. */
22
+ export class DeclarationChainMoved extends Error {
23
+ constructor() {
24
+ super("the declaration's core chain moved after its publication was derived");
25
+ this.name = "DeclarationChainMoved";
26
+ }
27
+ }
28
+ export async function commitDeclaration(file, input) {
29
+ const { walk } = input;
30
+ if (walk)
31
+ await closePhysicallyOffThread(walk.source, "complete");
32
+ const { value } = await save(file, "register.declare", {
33
+ resourceId: input.resourceId,
34
+ coreRootId: input.coreRootId,
35
+ walk: walk && {
36
+ repositoryObservations: walk.repositoryObservations.map(({ proof: _proof, ...pair }) => pair),
37
+ observed: walk.observed,
38
+ selected: walk.selected,
39
+ seals: walk.seals,
40
+ },
41
+ absorbed: input.absorbed,
42
+ enclosed: input.enclosed,
43
+ chain: input.chain,
44
+ journal: input.journal,
45
+ });
46
+ if (value === "moved")
47
+ throw new DeclarationChainMoved();
48
+ }
49
+ //# sourceMappingURL=declaration-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-commit.js","sourceRoot":"","sources":["../src/declaration-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAMrE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,uDAAuD;AACvD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C;QACE,KAAK,CAAC,sEAAsE,CAAC,CAAC;QAC9E,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAaD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAUrD;IACC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,IAAI,IAAI;QAAE,MAAM,wBAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE;QACrD,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,IAAI,EAAE,IAAI,IAAI;YACZ,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YAC7F,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;QACD,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;IACH,IAAI,KAAK,KAAK,OAAO;QAAE,MAAM,IAAI,qBAAqB,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A Register declaration holds its root back from ordinary Detect until the
3
+ * authority has accepted it. A bound root is held while a publication row
4
+ * owns its declaration, or while sharing (B) has never recorded the root:
5
+ * then the declaration exists only as a local binding that no Register has
6
+ * committed yet.
7
+ *
8
+ * Held ground is observed, never selected. Its reference in core stays out of
9
+ * Send, and its own root admits no Record, so ordinary Detect can never
10
+ * publish a declaration piecemeal before the graph head that introduces it.
11
+ * The publication outcome wakes the ground it held.
12
+ */
13
+ import type Database from "better-sqlite3";
14
+ /** A Watch pass could not conclude because these roots are held: the
15
+ * publication outcome, never a timer, wakes them. */
16
+ export declare class DeclarationHeld extends Error {
17
+ readonly roots: readonly string[];
18
+ constructor(roots: readonly string[]);
19
+ }
20
+ /** The held subset of these bound roots, read on the caller's connection so
21
+ * it joins whatever read transaction the caller is in. */
22
+ export declare function heldDeclarations(database: Database.Database, bindings: Iterable<string>): Set<string>;
@@ -0,0 +1,24 @@
1
+ import { cachedStatement } from "./sqlite.js";
2
+ /** A Watch pass could not conclude because these roots are held: the
3
+ * publication outcome, never a timer, wakes them. */
4
+ export class DeclarationHeld extends Error {
5
+ roots;
6
+ constructor(roots) {
7
+ super(`${roots.join(", ")} held by a Register declaration awaiting the authority`);
8
+ this.roots = roots;
9
+ this.name = "DeclarationHeld";
10
+ }
11
+ }
12
+ /** The held subset of these bound roots, read on the caller's connection so
13
+ * it joins whatever read transaction the caller is in. */
14
+ export function heldDeclarations(database, bindings) {
15
+ const journaled = cachedStatement(database, "SELECT 1 FROM snapshot_publications WHERE declaration_root = ? LIMIT 1").pluck();
16
+ const shared = cachedStatement(database, "SELECT 1 FROM detection_notebook WHERE uuid = ?").pluck();
17
+ const held = new Set();
18
+ for (const root of bindings) {
19
+ if (journaled.get(root) !== undefined || shared.get(root) === undefined)
20
+ held.add(root);
21
+ }
22
+ return held;
23
+ }
24
+ //# sourceMappingURL=declaration-hold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-hold.js","sourceRoot":"","sources":["../src/declaration-hold.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;qDACqD;AACrD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACnB;IAArB,YAAqB,KAAwB;QAC3C,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;QADhE,UAAK,GAAL,KAAK,CAAmB;QAE3C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;0DAC0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,QAA2B,EAAE,QAA0B;IACtF,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,EACxC,wEAAwE,CAAC,CAAC,KAAK,EAAE,CAAC;IACpF,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,iDAAiD,CAAC,CAAC,KAAK,EAAE,CAAC;IACpG,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The Register declaration journal: one durable row per graph-head commit that
3
+ * introduces a workspace declaration D.
4
+ *
5
+ * Register is the only graph-head publisher, and every row it journals owns
6
+ * exactly one declaration, named by its root W. The row carries the small
7
+ * facts the authority must be told, the canonical operation bytes that submit
8
+ * as-is, and the pages the head newly names. D is never stored twice: its
9
+ * records are read back from those pages.
10
+ *
11
+ * pending: intended, retried under the same mutation id until the authority
12
+ * answers. Once submitted, its outcome may exist only at the authority, so
13
+ * nothing may supersede it.
14
+ * rejected: the authority conclusively refused this mutation. It is never
15
+ * replayed; the next Register re-folds its D onto the current accepted view
16
+ * under a new mutation id.
17
+ *
18
+ * While any row names W, W's ground is held from ordinary Detect. Every write
19
+ * here runs on the ground file's saver thread (ground-save-ops.ts).
20
+ */
21
+ import type Database from "better-sqlite3";
22
+ /** One immutable graph page exactly as it must be sealed. */
23
+ export interface JournaledGraphPage {
24
+ readonly sha256: string;
25
+ readonly bytes: Buffer;
26
+ }
27
+ export interface DeclarationJournalEntry {
28
+ readonly mutationId: string;
29
+ readonly resourceId: string;
30
+ /** W: the root whose declaration this row owns. */
31
+ readonly declarationRoot: string;
32
+ /** The core records D adds beside W: its reference and any ancestor the
33
+ * accepted view lacked. */
34
+ readonly declaredIds: readonly string[];
35
+ readonly authorityEpoch: number;
36
+ readonly baseVersion: number;
37
+ readonly snapshotChecksum: string;
38
+ /** N: the complete accepted prefix this publication folded. */
39
+ readonly deliveryWatermark: number;
40
+ readonly operationKind: string;
41
+ readonly replacementRootIds: readonly string[];
42
+ /** Canonical operation bytes — stableJson of the head commit. */
43
+ readonly operationBlob: Buffer;
44
+ /** Pages the committed head did not already name. */
45
+ readonly pages: readonly JournaledGraphPage[];
46
+ readonly status: "pending" | "rejected";
47
+ /** True once a submit attempt was durably declared for this row. */
48
+ readonly submitted: boolean;
49
+ }
50
+ export declare function readDeclarationJournal(database: Database.Database): DeclarationJournalEntry[];
51
+ /** Journal one declaration publication, superseding that declaration's
52
+ * earlier rows. Runs inside the caller's transaction, so the row lands with
53
+ * whatever the caller commits beside it. A submitted pending row for the same
54
+ * declaration may already be accepted, so it refuses supersession. */
55
+ export declare function journalDeclaration(database: Database.Database, entry: DeclarationJournalEntry): void;
56
+ /** Durably declare a submit attempt before the first frame leaves. From this
57
+ * moment the outcome may exist only at the authority. */
58
+ export declare function markDeclarationSubmitted(database: Database.Database, mutationId: string): void;
59
+ /** The authority conclusively refused this exact mutation. */
60
+ export declare function markDeclarationRejected(database: Database.Database, mutationId: string): void;
61
+ /** The authority accepted it: the declaration no longer holds its ground. */
62
+ export declare function clearDeclaration(database: Database.Database, mutationId: string): void;
@@ -0,0 +1,99 @@
1
+ import { GRAPH_HEAD_OPERATION_KIND, stableJson } from "@amalgm/live";
2
+ export function readDeclarationJournal(database) {
3
+ const pagesByMutation = new Map();
4
+ for (const page of database.prepare(`
5
+ SELECT mutation_id AS mutationId, sha256, bytes
6
+ FROM snapshot_publication_pages ORDER BY mutation_id, page_index
7
+ `).iterate()) {
8
+ const carried = pagesByMutation.get(page.mutationId) ?? [];
9
+ carried.push({ sha256: page.sha256, bytes: page.bytes });
10
+ pagesByMutation.set(page.mutationId, carried);
11
+ }
12
+ return database.prepare(`
13
+ SELECT mutation_id AS mutationId, resource_id AS resourceId,
14
+ declaration_root AS declarationRoot, meta_json AS metaJson,
15
+ operation_blob AS operationBlob, status, submitted_at AS submittedAt
16
+ FROM snapshot_publications ORDER BY sequence
17
+ `).all().map((row) => {
18
+ const meta = JSON.parse(row.metaJson);
19
+ // A row that names no exact replacement or declaration is damage, never a
20
+ // skippable row: dropping it could supersede a submitted mutation whose
21
+ // outcome exists only at the authority.
22
+ const deliveryWatermark = Number(meta.deliveryWatermark);
23
+ if (meta.operationKind !== GRAPH_HEAD_OPERATION_KIND
24
+ || !Array.isArray(meta.replacementRootIds) || !meta.replacementRootIds.includes(row.declarationRoot)
25
+ || !Array.isArray(meta.declaredIds)
26
+ || !Number.isSafeInteger(deliveryWatermark) || deliveryWatermark < 0) {
27
+ throw new Error(`declaration publication ${row.mutationId} is not an exact graph-head declaration`);
28
+ }
29
+ return {
30
+ mutationId: row.mutationId,
31
+ resourceId: row.resourceId,
32
+ declarationRoot: row.declarationRoot,
33
+ declaredIds: meta.declaredIds.map(String),
34
+ authorityEpoch: Number(meta.authorityEpoch),
35
+ baseVersion: Number(meta.baseVersion),
36
+ snapshotChecksum: String(meta.snapshotChecksum),
37
+ deliveryWatermark,
38
+ operationKind: meta.operationKind,
39
+ replacementRootIds: meta.replacementRootIds.map(String),
40
+ operationBlob: row.operationBlob,
41
+ pages: pagesByMutation.get(row.mutationId) ?? [],
42
+ status: row.status === "rejected" ? "rejected" : "pending",
43
+ submitted: row.submittedAt !== null,
44
+ };
45
+ });
46
+ }
47
+ /** Journal one declaration publication, superseding that declaration's
48
+ * earlier rows. Runs inside the caller's transaction, so the row lands with
49
+ * whatever the caller commits beside it. A submitted pending row for the same
50
+ * declaration may already be accepted, so it refuses supersession. */
51
+ export function journalDeclaration(database, entry) {
52
+ if (!database.inTransaction)
53
+ throw new Error("a declaration journals inside its caller's transaction");
54
+ if (database.prepare(`
55
+ SELECT 1 FROM snapshot_publications
56
+ WHERE declaration_root = ? AND status = 'pending' AND submitted_at IS NOT NULL LIMIT 1
57
+ `).get(entry.declarationRoot) !== undefined) {
58
+ throw new Error(`declaration ${entry.declarationRoot} has a submitted publication whose outcome is unknown`);
59
+ }
60
+ database.prepare(`
61
+ DELETE FROM snapshot_publication_pages WHERE mutation_id IN (
62
+ SELECT mutation_id FROM snapshot_publications WHERE declaration_root = ?)
63
+ `).run(entry.declarationRoot);
64
+ database.prepare("DELETE FROM snapshot_publications WHERE declaration_root = ?").run(entry.declarationRoot);
65
+ database.prepare(`
66
+ INSERT INTO snapshot_publications(
67
+ mutation_id, resource_id, declaration_root, meta_json, operation_blob, created_at
68
+ ) VALUES (?, ?, ?, ?, ?, ?)
69
+ `).run(entry.mutationId, entry.resourceId, entry.declarationRoot, stableJson({
70
+ declaredIds: entry.declaredIds,
71
+ authorityEpoch: entry.authorityEpoch,
72
+ baseVersion: entry.baseVersion,
73
+ snapshotChecksum: entry.snapshotChecksum,
74
+ deliveryWatermark: entry.deliveryWatermark,
75
+ operationKind: entry.operationKind,
76
+ replacementRootIds: entry.replacementRootIds,
77
+ }), entry.operationBlob, Date.now());
78
+ const insertPage = database.prepare(`
79
+ INSERT INTO snapshot_publication_pages(mutation_id, page_index, sha256, bytes) VALUES (?, ?, ?, ?)
80
+ `);
81
+ entry.pages.forEach((page, index) => insertPage.run(entry.mutationId, index, page.sha256, page.bytes));
82
+ }
83
+ /** Durably declare a submit attempt before the first frame leaves. From this
84
+ * moment the outcome may exist only at the authority. */
85
+ export function markDeclarationSubmitted(database, mutationId) {
86
+ database.prepare("UPDATE snapshot_publications SET submitted_at = ? WHERE mutation_id = ?")
87
+ .run(Date.now(), mutationId);
88
+ }
89
+ /** The authority conclusively refused this exact mutation. */
90
+ export function markDeclarationRejected(database, mutationId) {
91
+ database.prepare("UPDATE snapshot_publications SET status = 'rejected' WHERE mutation_id = ?")
92
+ .run(mutationId);
93
+ }
94
+ /** The authority accepted it: the declaration no longer holds its ground. */
95
+ export function clearDeclaration(database, mutationId) {
96
+ database.prepare("DELETE FROM snapshot_publication_pages WHERE mutation_id = ?").run(mutationId);
97
+ database.prepare("DELETE FROM snapshot_publications WHERE mutation_id = ?").run(mutationId);
98
+ }
99
+ //# sourceMappingURL=declaration-journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration-journal.js","sourceRoot":"","sources":["../src/declaration-journal.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA0CrE,MAAM,UAAU,sBAAsB,CAAC,QAA2B;IAChE,MAAM,eAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;IAChE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC;;;GAGnC,CAAC,CAAC,OAAO,EAAqE,EAAE,CAAC;QAChF,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACzD,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,OAAQ,QAAQ,CAAC,OAAO,CAAC;;;;;GAKxB,CAAC,CAAC,GAAG,EAQH,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAgD,CAAC;QACrF,0EAA0E;QAC1E,wEAAwE;QACxE,wCAAwC;QACxC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzD,IAAI,IAAI,CAAC,aAAa,KAAK,yBAAyB;eAC/C,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CA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kB;IACtF,QAAQ,CAAC,OAAO,CAAC,yEAAyE,CAAC;SACxF,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;AACjC,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,uBAAuB,CAAC,QAA2B,EAAE,UAAkB;IACrF,QAAQ,CAAC,OAAO,CAAC,4EAA4E,CAAC;SAC3F,GAAG,CAAC,UAAU,CAAC,CAAC;AACrB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,QAA2B,EAAE,UAAkB;IAC9E,QAAQ,CAAC,OAAO,CAAC,8DAA8D,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACjG,QAAQ,CAAC,OAAO,CAAC,yDAAyD,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type Database from "better-sqlite3";
2
+ import type { DeclarationChain } from "./declaration-chain.js";
3
+ import { type DeclarationJournalEntry } from "./declaration-journal.js";
4
+ import { type RepositorySealCandidate } from "./detection/seal-law.js";
5
+ import type { RepositoryObservationPair } from "./git-repository-host.js";
6
+ import { type GroundRow } from "./ground-row.js";
7
+ /** One declaration as data. */
8
+ export interface DeclarationSave {
9
+ readonly resourceId: string;
10
+ readonly coreRootId: string;
11
+ /** W's walk, or null for a re-fold whose walk already stands. */
12
+ readonly walk: {
13
+ readonly repositoryObservations: readonly Omit<RepositoryObservationPair, "proof">[];
14
+ readonly observed: readonly GroundRow[];
15
+ readonly selected: readonly GroundRow[];
16
+ readonly seals: readonly RepositorySealCandidate[];
17
+ } | null;
18
+ /** The enclosed roots W absorbs. */
19
+ readonly absorbed: readonly string[];
20
+ /** Every bound root W's ground encloses; its rows join W's root. */
21
+ readonly enclosed: readonly string[];
22
+ readonly chain: DeclarationChain;
23
+ readonly journal: DeclarationJournalEntry;
24
+ }
25
+ /** The UUID local ground names at one core address: B first, then O. */
26
+ export declare function namedAt(database: Database.Database, resourceId: string, coreRootId: string, relativePath: string): string | null;
27
+ /** `register.declare`: nothing when an address moved. O rows already held
28
+ * under the chain's identities stand as observed, and rows at its addresses
29
+ * under other identities are displaced: sharing names the identity, and
30
+ * observation re-derives the rest on its next pass. */
31
+ export declare function saveDeclaration(database: Database.Database, input: DeclarationSave): "committed" | "moved";