@amalgm/shell 0.1.164-preview.44185399271 → 0.1.164-preview.44991101539

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 (1032) hide show
  1. package/dist/accepted-fold.js +0 -36
  2. package/dist/accepted-tail.js +0 -3
  3. package/dist/accepted-view.js +0 -1
  4. package/dist/agent-execution.js +0 -2
  5. package/dist/agent-instructions.js +0 -6
  6. package/dist/apply-attempt-memory.js +0 -5
  7. package/dist/apply-control.js +0 -50
  8. package/dist/apply-displaced-tree.js +0 -51
  9. package/dist/apply-durability.js +0 -16
  10. package/dist/apply-enter-build.js +2 -46
  11. package/dist/apply-enter-plan.js +0 -59
  12. package/dist/apply-fingerprint.js +0 -21
  13. package/dist/apply-git-held.js +4 -90
  14. package/dist/apply-git-storage.js +2 -38
  15. package/dist/apply-kept.js +0 -40
  16. package/dist/apply-local-work.js +0 -12
  17. package/dist/apply-map.js +18 -122
  18. package/dist/apply-showing.js +0 -71
  19. package/dist/apply-shown-again.js +0 -22
  20. package/dist/apply-spelling.js +0 -31
  21. package/dist/apply-trash-keep.js +5 -28
  22. package/dist/apply-window-cargo.js +0 -55
  23. package/dist/apply-window-ground.js +9 -71
  24. package/dist/apply-window-host.js +42 -421
  25. package/dist/apply-window-lane.js +0 -73
  26. package/dist/apply-window-line.js +0 -33
  27. package/dist/apply-window-recovery.js +0 -26
  28. package/dist/apply-window-reveal.js +0 -32
  29. package/dist/apply-window-rows.js +0 -53
  30. package/dist/apply-window-saves.js +0 -184
  31. package/dist/apply-window-store.js +0 -61
  32. package/dist/apply-window-verify.js +0 -42
  33. package/dist/authority-binding.js +0 -28
  34. package/dist/authorization/device-key.js +0 -1
  35. package/dist/authorization/index.js +0 -2
  36. package/dist/authorization/issuer.js +0 -1
  37. package/dist/authorization/key-store.js +0 -1
  38. package/dist/authorization/native-keyring.js +0 -1
  39. package/dist/authorization/recovery-client.js +0 -2
  40. package/dist/authorization/recovery-host.js +0 -1
  41. package/dist/authorization/recovery.js +0 -3
  42. package/dist/authorization/registration-http.js +0 -2
  43. package/dist/authorization/secret-process.js +0 -2
  44. package/dist/authorization/setup-http.js +0 -1
  45. package/dist/automations-cli-host.js +0 -2
  46. package/dist/background-error.js +0 -5
  47. package/dist/baseline-content.js +0 -3
  48. package/dist/billing/cli.js +266 -0
  49. package/dist/billing/mount.js +33 -0
  50. package/dist/billing/tools.js +138 -0
  51. package/dist/boot-identity.js +0 -12
  52. package/dist/browser-host.js +0 -15
  53. package/dist/builtin-agents.js +0 -8
  54. package/dist/capture-work.js +0 -9
  55. package/dist/captured-rows.js +4 -6
  56. package/dist/cargo-group.js +0 -48
  57. package/dist/cargo-journal.js +0 -36
  58. package/dist/channel-session.js +0 -9
  59. package/dist/chat-composition.js +0 -4
  60. package/dist/chat-host.js +0 -4
  61. package/dist/chat-toolbox.js +0 -2
  62. package/dist/chat-tools.js +0 -3
  63. package/dist/cli-arguments.js +17 -3
  64. package/dist/cli-commands.js +272 -0
  65. package/dist/cli.js +36 -72
  66. package/dist/construct-apply-host.js +0 -24
  67. package/dist/construct-door.js +3 -15
  68. package/dist/construct-ledger.js +3 -21
  69. package/dist/construct-products.js +0 -7
  70. package/dist/content-cache-collection.js +1 -27
  71. package/dist/content-cache-fences.js +0 -30
  72. package/dist/content-cache-host.js +0 -216
  73. package/dist/content-cache-index.js +0 -24
  74. package/dist/content-cache-namespace.js +0 -52
  75. package/dist/content-cache-partials.js +0 -23
  76. package/dist/content-cache-retention.js +1 -53
  77. package/dist/content-capture-pool.js +6 -134
  78. package/dist/content-capture-worker.js +4 -14
  79. package/dist/content-clock.js +1 -177
  80. package/dist/content-direct.js +0 -39
  81. package/dist/content-failure.js +0 -8
  82. package/dist/content-qualification.js +0 -56
  83. package/dist/content-wire-codec.js +0 -8
  84. package/dist/credentials-host.js +0 -2
  85. package/dist/derived-relocation.js +0 -27
  86. package/dist/detection/accepted-result.js +0 -14
  87. package/dist/detection/admission-save.js +0 -10
  88. package/dist/detection/admission-units.js +3 -93
  89. package/dist/detection/alias-discovery.js +0 -19
  90. package/dist/detection/alias-examination.js +0 -22
  91. package/dist/detection/apply-ownership.js +4 -52
  92. package/dist/detection/basis-advanced.js +0 -11
  93. package/dist/detection/cached-replay.js +0 -20
  94. package/dist/detection/capture-outcome.js +0 -20
  95. package/dist/detection/container-membership.js +0 -19
  96. package/dist/detection/detect-cancelled.js +0 -3
  97. package/dist/detection/directory-proof.js +0 -20
  98. package/dist/detection/dispositions.js +0 -29
  99. package/dist/detection/examinations.js +0 -32
  100. package/dist/detection/ground-proof.js +20 -130
  101. package/dist/detection/ground-reader.js +0 -9
  102. package/dist/detection/identity-discovery.js +15 -60
  103. package/dist/detection/maintenance-sweep.js +1 -73
  104. package/dist/detection/notebook-basis.js +1 -5
  105. package/dist/detection/owed-examinations.js +0 -4
  106. package/dist/detection/owed-selection.js +14 -40
  107. package/dist/detection/policy-owed.js +165 -26
  108. package/dist/detection/racy-close.js +46 -0
  109. package/dist/detection/reconciliation-coverage.js +0 -4
  110. package/dist/detection/repository-state.js +6 -56
  111. package/dist/detection/reveal-save.js +0 -2
  112. package/dist/detection/root-examination.js +32 -105
  113. package/dist/detection/root-walk.js +98 -295
  114. package/dist/detection/runtime.js +57 -153
  115. package/dist/detection/scope-frame.js +1 -37
  116. package/dist/detection/scoped-identity-port.js +0 -21
  117. package/dist/detection/sealed-folders.js +57 -0
  118. package/dist/detection/skip-policy.js +185 -0
  119. package/dist/detection/spelled-lookup.js +0 -19
  120. package/dist/detection/storage-holder.js +60 -0
  121. package/dist/detection/thread-database.js +0 -9
  122. package/dist/detection/unread-content.js +0 -13
  123. package/dist/detection/unreadable.js +0 -3
  124. package/dist/detection/walk-law.js +0 -20
  125. package/dist/detection/walked-roots.js +0 -6
  126. package/dist/detection/withheld.js +0 -46
  127. package/dist/development/fly-guest.js +0 -3
  128. package/dist/development/fly.js +2 -11
  129. package/dist/development/profile.js +0 -8
  130. package/dist/drive/cloud-files/asks.js +5 -48
  131. package/dist/drive/cloud-files/binding.js +0 -14
  132. package/dist/drive/cloud-files/contents.js +14 -57
  133. package/dist/drive/cloud-files/door.js +5 -45
  134. package/dist/drive/cloud-files/paths.js +4 -37
  135. package/dist/drive/cloud-files/populated.js +0 -14
  136. package/dist/drive/cloud-files/reconcile.js +18 -97
  137. package/dist/drive/cloud-files/sync-root.js +7 -21
  138. package/dist/drive/cloud-files/turns.js +0 -25
  139. package/dist/drive/cloud-files/writes.js +19 -122
  140. package/dist/drive/computer.js +0 -19
  141. package/dist/drive/fuse-opens.js +0 -31
  142. package/dist/drive/fuse.js +23 -43
  143. package/dist/drive/kept.js +32 -80
  144. package/dist/drive/kernel.js +12 -24
  145. package/dist/drive/layout.js +31 -20
  146. package/dist/drive/mount.js +53 -125
  147. package/dist/drive/mountpoint.js +0 -19
  148. package/dist/drive/names.js +17 -0
  149. package/dist/drive/nfs/apple-double.js +4 -29
  150. package/dist/drive/nfs/attributes.js +3 -19
  151. package/dist/drive/nfs/handles.js +0 -37
  152. package/dist/drive/nfs/mount3.js +0 -4
  153. package/dist/drive/nfs/nfs3.js +4 -65
  154. package/dist/drive/nfs/rpc.js +0 -19
  155. package/dist/drive/nfs/server.js +0 -14
  156. package/dist/drive/nfs/xdr.js +0 -15
  157. package/dist/drive/nfs.js +34 -90
  158. package/dist/drive/operations.js +46 -120
  159. package/dist/drive/shelf.js +0 -12
  160. package/dist/drive-maps.js +54 -0
  161. package/dist/drive-program/client.js +128 -0
  162. package/dist/drive-program/ports.js +49 -0
  163. package/dist/drive-program/program.js +82 -0
  164. package/dist/drive-program/protocol.js +2 -0
  165. package/dist/durability-barrier.js +0 -60
  166. package/dist/entity-access-wire.js +0 -9
  167. package/dist/entity-channel-holdings.js +0 -17
  168. package/dist/entity-grant-watch.js +0 -8
  169. package/dist/entity-record-observability.js +0 -4
  170. package/dist/entity-record-saves.js +0 -23
  171. package/dist/entity-record-store.js +0 -51
  172. package/dist/error-facts.js +1 -3
  173. package/dist/faults/drain.js +2 -32
  174. package/dist/faults/queue.js +0 -22
  175. package/dist/faults/show.js +0 -6
  176. package/dist/file-time.js +21 -0
  177. package/dist/files-browser-host.js +15 -7
  178. package/dist/files-mcp-host.js +0 -6
  179. package/dist/files-observability.js +0 -1
  180. package/dist/files-program/client.js +90 -320
  181. package/dist/files-program/journeys.js +0 -4
  182. package/dist/files-program/program.js +67 -162
  183. package/dist/files-program/protocol.js +0 -5
  184. package/dist/files-register-host.js +8 -56
  185. package/dist/files-trace.js +0 -39
  186. package/dist/files-watch-host.js +226 -0
  187. package/dist/filesystem.js +0 -39
  188. package/dist/flush.js +0 -37
  189. package/dist/forward.js +0 -8
  190. package/dist/gateway.js +0 -9
  191. package/dist/git/ground-owners.js +0 -11
  192. package/dist/git/held-package.js +0 -43
  193. package/dist/git/home.js +79 -67
  194. package/dist/git/marker.js +0 -9
  195. package/dist/git/named-objects.js +0 -32
  196. package/dist/git/objects.js +0 -23
  197. package/dist/git/play.js +0 -42
  198. package/dist/git/quarantine.js +0 -47
  199. package/dist/git/rail.js +55 -286
  200. package/dist/git/read-state.js +8 -70
  201. package/dist/git/repository.js +0 -43
  202. package/dist/git/write-files.js +16 -84
  203. package/dist/git-binding.js +58 -80
  204. package/dist/git-cat-file.js +0 -18
  205. package/dist/git-command.js +1 -71
  206. package/dist/git-index-entries.js +0 -5
  207. package/dist/git-index-format.js +0 -71
  208. package/dist/git-install-lines.js +0 -2
  209. package/dist/git-launcher-process.js +0 -19
  210. package/dist/git-launcher.js +1 -33
  211. package/dist/git-proven-blobs.js +48 -0
  212. package/dist/graph-heads.js +0 -14
  213. package/dist/ground-basis.js +1 -183
  214. package/dist/ground-checkpoint-worker.js +0 -26
  215. package/dist/ground-checkpoints.js +0 -14
  216. package/dist/ground-contract.js +1 -43
  217. package/dist/ground-coordination.js +0 -82
  218. package/dist/ground-database.js +0 -88
  219. package/dist/ground-differences.js +0 -6
  220. package/dist/ground-holders.js +0 -8
  221. package/dist/ground-initialization-worker.js +0 -7
  222. package/dist/ground-initialization.js +0 -19
  223. package/dist/ground-install-saves.js +0 -15
  224. package/dist/ground-inventory-schema.js +3 -142
  225. package/dist/ground-marks.js +0 -16
  226. package/dist/ground-places.js +33 -0
  227. package/dist/ground-profile.js +0 -77
  228. package/dist/ground-reads.js +0 -58
  229. package/dist/ground-relations.js +0 -43
  230. package/dist/ground-root-index.js +0 -7
  231. package/dist/ground-row.js +5 -29
  232. package/dist/ground-save-ops.js +0 -14
  233. package/dist/ground-saver-worker.js +3 -56
  234. package/dist/ground-saver.js +0 -52
  235. package/dist/ground-store.js +10 -144
  236. package/dist/held-ground.js +60 -0
  237. package/dist/index.js +0 -1
  238. package/dist/initial-publication.js +0 -7
  239. package/dist/install-from-git.js +42 -0
  240. package/dist/installation/environment.js +8 -2
  241. package/dist/installation/lease.js +0 -3
  242. package/dist/installation/ownership.js +0 -13
  243. package/dist/installation/selection.js +0 -2
  244. package/dist/keychain/cli-io.js +0 -7
  245. package/dist/keychain/cli.js +0 -9
  246. package/dist/keychain/host.js +0 -7
  247. package/dist/keychain/http-mount.js +0 -10
  248. package/dist/keychain/key-wire.js +0 -8
  249. package/dist/keychain/presence-mac.js +0 -7
  250. package/dist/keychain/presence.js +0 -7
  251. package/dist/keychain/rail.js +0 -7
  252. package/dist/keychain/secret-apply.js +0 -11
  253. package/dist/keychain/shelf-from-ledger.js +0 -7
  254. package/dist/keychain/use-log.js +0 -6
  255. package/dist/keychain/vault-file.js +0 -7
  256. package/dist/line-judge.js +0 -41
  257. package/dist/line-loops.js +0 -3
  258. package/dist/link-target.js +0 -38
  259. package/dist/local-host.js +0 -16
  260. package/dist/loop-watch.js +0 -13
  261. package/dist/machine-host.js +36 -123
  262. package/dist/main.js +4 -5
  263. package/dist/materialize-records.js +109 -112
  264. package/dist/materialized-graph.js +0 -1
  265. package/dist/module-thread.js +0 -8
  266. package/dist/mount.js +0 -7
  267. package/dist/native/cloud-files.node +0 -0
  268. package/dist/native/windows-fs.node +0 -0
  269. package/dist/official-mcp-host.js +0 -2
  270. package/dist/on-demand-roots.js +0 -4
  271. package/dist/open-standing.js +0 -36
  272. package/dist/own-folders.js +56 -0
  273. package/dist/own-results.js +0 -31
  274. package/dist/package-pages.js +0 -13
  275. package/dist/patient-flush.js +0 -16
  276. package/dist/physical-path-witness.js +0 -28
  277. package/dist/placement-owed.js +0 -8
  278. package/dist/placement-tidy.js +0 -68
  279. package/dist/platform-product-host.js +0 -3
  280. package/dist/platform-tools.js +0 -3
  281. package/dist/process-lifecycle.js +0 -7
  282. package/dist/product-cli.js +0 -10
  283. package/dist/pty-host.js +0 -22
  284. package/dist/received-state.js +0 -46
  285. package/dist/reference-placement.js +0 -30
  286. package/dist/registry-graph.js +0 -89
  287. package/dist/registry-page-cache.js +4 -12
  288. package/dist/release-catalog.js +0 -3
  289. package/dist/root-install.js +2 -36
  290. package/dist/runtime-activity.js +0 -14
  291. package/dist/runtime-argv.js +0 -8
  292. package/dist/runtime-command-host.js +0 -17
  293. package/dist/runtime-node-flags.js +0 -10
  294. package/dist/runtime-wire-host.js +0 -4
  295. package/dist/service/adapter.js +0 -6
  296. package/dist/service/cli.js +12 -46
  297. package/dist/service/control.js +0 -3
  298. package/dist/service/index.js +0 -4
  299. package/dist/service/keepalive.js +2 -21
  300. package/dist/service/launchd.js +0 -8
  301. package/dist/service/owner.js +0 -1
  302. package/dist/service/policy.js +0 -7
  303. package/dist/service/portable.js +0 -8
  304. package/dist/service/recovery.js +0 -9
  305. package/dist/service/registration.js +0 -29
  306. package/dist/service/systemd-unit.js +0 -4
  307. package/dist/service/systemd.js +0 -9
  308. package/dist/service/windows-action.js +0 -12
  309. package/dist/service/windows-task.js +0 -10
  310. package/dist/service/windows.js +0 -4
  311. package/dist/sha256.js +0 -2
  312. package/dist/sharing-admission.js +0 -16
  313. package/dist/sharing-host.js +0 -7
  314. package/dist/sharing-mcp-host.js +0 -6
  315. package/dist/snapshot-delivery-baseline.js +0 -29
  316. package/dist/socket-marking.js +0 -9
  317. package/dist/source-proof.js +0 -29
  318. package/dist/source-signature.js +4 -93
  319. package/dist/source-witness.js +0 -6
  320. package/dist/sqlite-durability.js +0 -12
  321. package/dist/sqlite.js +0 -10
  322. package/dist/state-host.js +0 -2
  323. package/dist/state-store.js +1 -4
  324. package/dist/supervised-program/child.js +136 -0
  325. package/dist/supervised-program/messages.js +1 -0
  326. package/dist/supervised-program/parent.js +249 -0
  327. package/dist/sync-address.js +0 -16
  328. package/dist/sync-cli.js +0 -9
  329. package/dist/sync-setting.js +0 -5
  330. package/dist/tool-mcp-client.js +0 -2
  331. package/dist/toolbox-host.js +0 -2
  332. package/dist/transfer-instrumentation.js +0 -21
  333. package/dist/turns.js +0 -41
  334. package/dist/updates/artifacts.js +0 -56
  335. package/dist/updates/bootstrap.js +0 -53
  336. package/dist/updates/controller.js +1 -25
  337. package/dist/updates/isolated-command-lifetime.js +0 -13
  338. package/dist/updates/locked-packages.js +0 -5
  339. package/dist/updates/store.js +0 -11
  340. package/dist/updates/trust.js +0 -6
  341. package/dist/user-ground-host.js +162 -1501
  342. package/dist/watching/fsevents.js +3 -41
  343. package/dist/watching/git-storage.js +0 -24
  344. package/dist/watching/host.js +65 -275
  345. package/dist/watching/index.js +1 -2
  346. package/dist/watching/inotify.js +0 -31
  347. package/dist/windows-fs.js +0 -5
  348. package/dist/windows-owner-only.js +0 -17
  349. package/dist/wire-binary.js +0 -4
  350. package/dist/wire-client.js +0 -42
  351. package/dist/wire-join.js +0 -11
  352. package/dist/wire-outbox.js +0 -29
  353. package/dist/wire-request-scope.js +0 -3
  354. package/dist/wire-socket-relay.js +0 -53
  355. package/dist/workspace-add-intent.js +2 -11
  356. package/dist/workspace-add-staging.js +4 -99
  357. package/dist/workspace-host.js +0 -5
  358. package/dist/workspace-store.js +0 -6
  359. package/examinations/fixtures/private-wire-authority.js +14 -10
  360. package/examinations/native-service.mjs +1 -1
  361. package/examinations/runtime-upgrade.native-test.mjs +11 -8
  362. package/npm-shrinkwrap.json +14 -14
  363. package/package.json +8 -17
  364. package/PURPOSE.md +0 -1956
  365. package/dist/accepted-fold.d.ts +0 -51
  366. package/dist/accepted-fold.js.map +0 -1
  367. package/dist/accepted-tail.d.ts +0 -36
  368. package/dist/accepted-tail.js.map +0 -1
  369. package/dist/accepted-view.d.ts +0 -27
  370. package/dist/accepted-view.js.map +0 -1
  371. package/dist/agent-execution.d.ts +0 -83
  372. package/dist/agent-execution.js.map +0 -1
  373. package/dist/agent-instructions.d.ts +0 -7
  374. package/dist/agent-instructions.js.map +0 -1
  375. package/dist/apply-attempt-memory.d.ts +0 -13
  376. package/dist/apply-attempt-memory.js.map +0 -1
  377. package/dist/apply-control.d.ts +0 -85
  378. package/dist/apply-control.js.map +0 -1
  379. package/dist/apply-displaced-tree.d.ts +0 -63
  380. package/dist/apply-displaced-tree.js.map +0 -1
  381. package/dist/apply-durability.d.ts +0 -33
  382. package/dist/apply-durability.js.map +0 -1
  383. package/dist/apply-enter-build.d.ts +0 -91
  384. package/dist/apply-enter-build.js.map +0 -1
  385. package/dist/apply-enter-plan.d.ts +0 -79
  386. package/dist/apply-enter-plan.js.map +0 -1
  387. package/dist/apply-fingerprint.d.ts +0 -39
  388. package/dist/apply-fingerprint.js.map +0 -1
  389. package/dist/apply-git-held.d.ts +0 -29
  390. package/dist/apply-git-held.js.map +0 -1
  391. package/dist/apply-git-storage.d.ts +0 -38
  392. package/dist/apply-git-storage.js.map +0 -1
  393. package/dist/apply-kept.d.ts +0 -42
  394. package/dist/apply-kept.js.map +0 -1
  395. package/dist/apply-local-work.d.ts +0 -41
  396. package/dist/apply-local-work.js.map +0 -1
  397. package/dist/apply-map.d.ts +0 -116
  398. package/dist/apply-map.js.map +0 -1
  399. package/dist/apply-showing.d.ts +0 -104
  400. package/dist/apply-showing.js.map +0 -1
  401. package/dist/apply-shown-again.d.ts +0 -28
  402. package/dist/apply-shown-again.js.map +0 -1
  403. package/dist/apply-spelling.d.ts +0 -35
  404. package/dist/apply-spelling.js.map +0 -1
  405. package/dist/apply-trash-keep.d.ts +0 -96
  406. package/dist/apply-trash-keep.js.map +0 -1
  407. package/dist/apply-window-cargo.d.ts +0 -54
  408. package/dist/apply-window-cargo.js.map +0 -1
  409. package/dist/apply-window-ground.d.ts +0 -130
  410. package/dist/apply-window-ground.js.map +0 -1
  411. package/dist/apply-window-host.d.ts +0 -136
  412. package/dist/apply-window-host.js.map +0 -1
  413. package/dist/apply-window-lane.d.ts +0 -30
  414. package/dist/apply-window-lane.js.map +0 -1
  415. package/dist/apply-window-line.d.ts +0 -31
  416. package/dist/apply-window-line.js.map +0 -1
  417. package/dist/apply-window-recovery.d.ts +0 -5
  418. package/dist/apply-window-recovery.js.map +0 -1
  419. package/dist/apply-window-reveal.d.ts +0 -22
  420. package/dist/apply-window-reveal.js.map +0 -1
  421. package/dist/apply-window-rows.d.ts +0 -144
  422. package/dist/apply-window-rows.js.map +0 -1
  423. package/dist/apply-window-saves.d.ts +0 -224
  424. package/dist/apply-window-saves.js.map +0 -1
  425. package/dist/apply-window-store.d.ts +0 -126
  426. package/dist/apply-window-store.js.map +0 -1
  427. package/dist/apply-window-verify.d.ts +0 -65
  428. package/dist/apply-window-verify.js.map +0 -1
  429. package/dist/authority-binding.d.ts +0 -9
  430. package/dist/authority-binding.js.map +0 -1
  431. package/dist/authorization/device-key.d.ts +0 -19
  432. package/dist/authorization/device-key.js.map +0 -1
  433. package/dist/authorization/index.d.ts +0 -65
  434. package/dist/authorization/index.js.map +0 -1
  435. package/dist/authorization/issuer.d.ts +0 -11
  436. package/dist/authorization/issuer.js.map +0 -1
  437. package/dist/authorization/key-store.d.ts +0 -16
  438. package/dist/authorization/key-store.js.map +0 -1
  439. package/dist/authorization/native-keyring.d.ts +0 -8
  440. package/dist/authorization/native-keyring.js.map +0 -1
  441. package/dist/authorization/recovery-client.d.ts +0 -19
  442. package/dist/authorization/recovery-client.js.map +0 -1
  443. package/dist/authorization/recovery-host.d.ts +0 -30
  444. package/dist/authorization/recovery-host.js.map +0 -1
  445. package/dist/authorization/recovery.d.ts +0 -13
  446. package/dist/authorization/recovery.js.map +0 -1
  447. package/dist/authorization/registration-http.d.ts +0 -5
  448. package/dist/authorization/registration-http.js.map +0 -1
  449. package/dist/authorization/secret-process.d.ts +0 -2
  450. package/dist/authorization/secret-process.js.map +0 -1
  451. package/dist/authorization/setup-http.d.ts +0 -5
  452. package/dist/authorization/setup-http.js.map +0 -1
  453. package/dist/automations-cli-host.d.ts +0 -4
  454. package/dist/automations-cli-host.js.map +0 -1
  455. package/dist/background-error.d.ts +0 -4
  456. package/dist/background-error.js.map +0 -1
  457. package/dist/baseline-content.d.ts +0 -12
  458. package/dist/baseline-content.js.map +0 -1
  459. package/dist/boot-identity.d.ts +0 -1
  460. package/dist/boot-identity.js.map +0 -1
  461. package/dist/browser-host.d.ts +0 -30
  462. package/dist/browser-host.js.map +0 -1
  463. package/dist/builtin-agents.d.ts +0 -8
  464. package/dist/builtin-agents.js.map +0 -1
  465. package/dist/capture-work.d.ts +0 -8
  466. package/dist/capture-work.js.map +0 -1
  467. package/dist/captured-rows.d.ts +0 -33
  468. package/dist/captured-rows.js.map +0 -1
  469. package/dist/cargo-group.d.ts +0 -59
  470. package/dist/cargo-group.js.map +0 -1
  471. package/dist/cargo-journal.d.ts +0 -45
  472. package/dist/cargo-journal.js.map +0 -1
  473. package/dist/channel-session.d.ts +0 -60
  474. package/dist/channel-session.js.map +0 -1
  475. package/dist/chat-composition.d.ts +0 -30
  476. package/dist/chat-composition.js.map +0 -1
  477. package/dist/chat-host.d.ts +0 -30
  478. package/dist/chat-host.js.map +0 -1
  479. package/dist/chat-toolbox.d.ts +0 -10
  480. package/dist/chat-toolbox.js.map +0 -1
  481. package/dist/chat-tools.d.ts +0 -23
  482. package/dist/chat-tools.js.map +0 -1
  483. package/dist/cli-arguments.d.ts +0 -8
  484. package/dist/cli-arguments.js.map +0 -1
  485. package/dist/cli.d.ts +0 -10
  486. package/dist/cli.js.map +0 -1
  487. package/dist/construct-apply-host.d.ts +0 -64
  488. package/dist/construct-apply-host.js.map +0 -1
  489. package/dist/construct-door.d.ts +0 -39
  490. package/dist/construct-door.js.map +0 -1
  491. package/dist/construct-ledger.d.ts +0 -33
  492. package/dist/construct-ledger.js.map +0 -1
  493. package/dist/construct-products.d.ts +0 -22
  494. package/dist/construct-products.js.map +0 -1
  495. package/dist/content-cache-collection.d.ts +0 -25
  496. package/dist/content-cache-collection.js.map +0 -1
  497. package/dist/content-cache-fences.d.ts +0 -27
  498. package/dist/content-cache-fences.js.map +0 -1
  499. package/dist/content-cache-host.d.ts +0 -269
  500. package/dist/content-cache-host.js.map +0 -1
  501. package/dist/content-cache-index.d.ts +0 -59
  502. package/dist/content-cache-index.js.map +0 -1
  503. package/dist/content-cache-namespace.d.ts +0 -53
  504. package/dist/content-cache-namespace.js.map +0 -1
  505. package/dist/content-cache-partials.d.ts +0 -37
  506. package/dist/content-cache-partials.js.map +0 -1
  507. package/dist/content-cache-retention.d.ts +0 -38
  508. package/dist/content-cache-retention.js.map +0 -1
  509. package/dist/content-capture-pool.d.ts +0 -274
  510. package/dist/content-capture-pool.js.map +0 -1
  511. package/dist/content-capture-worker.d.ts +0 -7
  512. package/dist/content-capture-worker.js.map +0 -1
  513. package/dist/content-clock.d.ts +0 -68
  514. package/dist/content-clock.js.map +0 -1
  515. package/dist/content-direct.d.ts +0 -56
  516. package/dist/content-direct.js.map +0 -1
  517. package/dist/content-failure.d.ts +0 -18
  518. package/dist/content-failure.js.map +0 -1
  519. package/dist/content-qualification.d.ts +0 -72
  520. package/dist/content-qualification.js.map +0 -1
  521. package/dist/content-wire-codec.d.ts +0 -13
  522. package/dist/content-wire-codec.js.map +0 -1
  523. package/dist/credentials-host.d.ts +0 -5
  524. package/dist/credentials-host.js.map +0 -1
  525. package/dist/derived-relocation.d.ts +0 -31
  526. package/dist/derived-relocation.js.map +0 -1
  527. package/dist/detection/accepted-result.d.ts +0 -31
  528. package/dist/detection/accepted-result.js.map +0 -1
  529. package/dist/detection/admission-save.d.ts +0 -66
  530. package/dist/detection/admission-save.js.map +0 -1
  531. package/dist/detection/admission-units.d.ts +0 -78
  532. package/dist/detection/admission-units.js.map +0 -1
  533. package/dist/detection/alias-discovery.d.ts +0 -12
  534. package/dist/detection/alias-discovery.js.map +0 -1
  535. package/dist/detection/alias-examination.d.ts +0 -33
  536. package/dist/detection/alias-examination.js.map +0 -1
  537. package/dist/detection/apply-ownership.d.ts +0 -107
  538. package/dist/detection/apply-ownership.js.map +0 -1
  539. package/dist/detection/basis-advanced.d.ts +0 -15
  540. package/dist/detection/basis-advanced.js.map +0 -1
  541. package/dist/detection/cached-replay.d.ts +0 -38
  542. package/dist/detection/cached-replay.js.map +0 -1
  543. package/dist/detection/capture-outcome.d.ts +0 -16
  544. package/dist/detection/capture-outcome.js.map +0 -1
  545. package/dist/detection/container-membership.d.ts +0 -20
  546. package/dist/detection/container-membership.js.map +0 -1
  547. package/dist/detection/detect-cancelled.d.ts +0 -6
  548. package/dist/detection/detect-cancelled.js.map +0 -1
  549. package/dist/detection/directory-proof.d.ts +0 -47
  550. package/dist/detection/directory-proof.js.map +0 -1
  551. package/dist/detection/dispositions.d.ts +0 -107
  552. package/dist/detection/dispositions.js.map +0 -1
  553. package/dist/detection/examinations.d.ts +0 -33
  554. package/dist/detection/examinations.js.map +0 -1
  555. package/dist/detection/ground-proof.d.ts +0 -154
  556. package/dist/detection/ground-proof.js.map +0 -1
  557. package/dist/detection/ground-reader.d.ts +0 -29
  558. package/dist/detection/ground-reader.js.map +0 -1
  559. package/dist/detection/identity-discovery.d.ts +0 -45
  560. package/dist/detection/identity-discovery.js.map +0 -1
  561. package/dist/detection/maintenance-sweep.d.ts +0 -111
  562. package/dist/detection/maintenance-sweep.js.map +0 -1
  563. package/dist/detection/notebook-basis.d.ts +0 -24
  564. package/dist/detection/notebook-basis.js.map +0 -1
  565. package/dist/detection/owed-examinations.d.ts +0 -22
  566. package/dist/detection/owed-examinations.js.map +0 -1
  567. package/dist/detection/owed-selection.d.ts +0 -54
  568. package/dist/detection/owed-selection.js.map +0 -1
  569. package/dist/detection/policy-owed.d.ts +0 -17
  570. package/dist/detection/policy-owed.js.map +0 -1
  571. package/dist/detection/reconciliation-coverage.d.ts +0 -7
  572. package/dist/detection/reconciliation-coverage.js.map +0 -1
  573. package/dist/detection/repository-state.d.ts +0 -44
  574. package/dist/detection/repository-state.js.map +0 -1
  575. package/dist/detection/reveal-save.d.ts +0 -17
  576. package/dist/detection/reveal-save.js.map +0 -1
  577. package/dist/detection/root-examination.d.ts +0 -106
  578. package/dist/detection/root-examination.js.map +0 -1
  579. package/dist/detection/root-walk.d.ts +0 -191
  580. package/dist/detection/root-walk.js.map +0 -1
  581. package/dist/detection/runtime.d.ts +0 -144
  582. package/dist/detection/runtime.js.map +0 -1
  583. package/dist/detection/scope-frame.d.ts +0 -82
  584. package/dist/detection/scope-frame.js.map +0 -1
  585. package/dist/detection/scoped-identity-port.d.ts +0 -35
  586. package/dist/detection/scoped-identity-port.js.map +0 -1
  587. package/dist/detection/sharing-policy.d.ts +0 -19
  588. package/dist/detection/sharing-policy.js +0 -39
  589. package/dist/detection/sharing-policy.js.map +0 -1
  590. package/dist/detection/spelled-lookup.d.ts +0 -20
  591. package/dist/detection/spelled-lookup.js.map +0 -1
  592. package/dist/detection/thread-database.d.ts +0 -4
  593. package/dist/detection/thread-database.js.map +0 -1
  594. package/dist/detection/unread-content.d.ts +0 -20
  595. package/dist/detection/unread-content.js.map +0 -1
  596. package/dist/detection/unreadable.d.ts +0 -11
  597. package/dist/detection/unreadable.js.map +0 -1
  598. package/dist/detection/walk-law.d.ts +0 -25
  599. package/dist/detection/walk-law.js.map +0 -1
  600. package/dist/detection/walked-roots.d.ts +0 -17
  601. package/dist/detection/walked-roots.js.map +0 -1
  602. package/dist/detection/withheld.d.ts +0 -100
  603. package/dist/detection/withheld.js.map +0 -1
  604. package/dist/development/fly-guest.d.ts +0 -21
  605. package/dist/development/fly-guest.js.map +0 -1
  606. package/dist/development/fly.d.ts +0 -13
  607. package/dist/development/fly.js.map +0 -1
  608. package/dist/development/profile.d.ts +0 -34
  609. package/dist/development/profile.js.map +0 -1
  610. package/dist/drive/cloud-files/asks.d.ts +0 -7
  611. package/dist/drive/cloud-files/asks.js.map +0 -1
  612. package/dist/drive/cloud-files/binding.d.ts +0 -111
  613. package/dist/drive/cloud-files/binding.js.map +0 -1
  614. package/dist/drive/cloud-files/contents.d.ts +0 -82
  615. package/dist/drive/cloud-files/contents.js.map +0 -1
  616. package/dist/drive/cloud-files/door.d.ts +0 -11
  617. package/dist/drive/cloud-files/door.js.map +0 -1
  618. package/dist/drive/cloud-files/paths.d.ts +0 -42
  619. package/dist/drive/cloud-files/paths.js.map +0 -1
  620. package/dist/drive/cloud-files/populated.d.ts +0 -15
  621. package/dist/drive/cloud-files/populated.js.map +0 -1
  622. package/dist/drive/cloud-files/reconcile.d.ts +0 -17
  623. package/dist/drive/cloud-files/reconcile.js.map +0 -1
  624. package/dist/drive/cloud-files/sync-root.d.ts +0 -34
  625. package/dist/drive/cloud-files/sync-root.js.map +0 -1
  626. package/dist/drive/cloud-files/turns.d.ts +0 -9
  627. package/dist/drive/cloud-files/turns.js.map +0 -1
  628. package/dist/drive/cloud-files/writes.d.ts +0 -27
  629. package/dist/drive/cloud-files/writes.js.map +0 -1
  630. package/dist/drive/computer.d.ts +0 -19
  631. package/dist/drive/computer.js.map +0 -1
  632. package/dist/drive/fuse-opens.d.ts +0 -32
  633. package/dist/drive/fuse-opens.js.map +0 -1
  634. package/dist/drive/fuse.d.ts +0 -36
  635. package/dist/drive/fuse.js.map +0 -1
  636. package/dist/drive/kept.d.ts +0 -78
  637. package/dist/drive/kept.js.map +0 -1
  638. package/dist/drive/kernel.d.ts +0 -17
  639. package/dist/drive/kernel.js.map +0 -1
  640. package/dist/drive/layout.d.ts +0 -18
  641. package/dist/drive/layout.js.map +0 -1
  642. package/dist/drive/mount.d.ts +0 -107
  643. package/dist/drive/mount.js.map +0 -1
  644. package/dist/drive/mountpoint.d.ts +0 -14
  645. package/dist/drive/mountpoint.js.map +0 -1
  646. package/dist/drive/nfs/apple-double.d.ts +0 -6
  647. package/dist/drive/nfs/apple-double.js.map +0 -1
  648. package/dist/drive/nfs/attributes.d.ts +0 -64
  649. package/dist/drive/nfs/attributes.js.map +0 -1
  650. package/dist/drive/nfs/handles.d.ts +0 -44
  651. package/dist/drive/nfs/handles.js.map +0 -1
  652. package/dist/drive/nfs/mount3.d.ts +0 -16
  653. package/dist/drive/nfs/mount3.js.map +0 -1
  654. package/dist/drive/nfs/nfs3.d.ts +0 -27
  655. package/dist/drive/nfs/nfs3.js.map +0 -1
  656. package/dist/drive/nfs/rpc.d.ts +0 -66
  657. package/dist/drive/nfs/rpc.js.map +0 -1
  658. package/dist/drive/nfs/server.d.ts +0 -30
  659. package/dist/drive/nfs/server.js.map +0 -1
  660. package/dist/drive/nfs/xdr.d.ts +0 -44
  661. package/dist/drive/nfs/xdr.js.map +0 -1
  662. package/dist/drive/nfs.d.ts +0 -58
  663. package/dist/drive/nfs.js.map +0 -1
  664. package/dist/drive/operations.d.ts +0 -180
  665. package/dist/drive/operations.js.map +0 -1
  666. package/dist/drive/shelf.d.ts +0 -9
  667. package/dist/drive/shelf.js.map +0 -1
  668. package/dist/durability-barrier.d.ts +0 -66
  669. package/dist/durability-barrier.js.map +0 -1
  670. package/dist/entity-access-wire.d.ts +0 -33
  671. package/dist/entity-access-wire.js.map +0 -1
  672. package/dist/entity-channel-holdings.d.ts +0 -26
  673. package/dist/entity-channel-holdings.js.map +0 -1
  674. package/dist/entity-grant-watch.d.ts +0 -9
  675. package/dist/entity-grant-watch.js.map +0 -1
  676. package/dist/entity-record-observability.d.ts +0 -13
  677. package/dist/entity-record-observability.js.map +0 -1
  678. package/dist/entity-record-saves.d.ts +0 -47
  679. package/dist/entity-record-saves.js.map +0 -1
  680. package/dist/entity-record-store.d.ts +0 -60
  681. package/dist/entity-record-store.js.map +0 -1
  682. package/dist/error-facts.d.ts +0 -24
  683. package/dist/error-facts.js.map +0 -1
  684. package/dist/faults/drain.d.ts +0 -27
  685. package/dist/faults/drain.js.map +0 -1
  686. package/dist/faults/queue.d.ts +0 -46
  687. package/dist/faults/queue.js.map +0 -1
  688. package/dist/faults/show.d.ts +0 -7
  689. package/dist/faults/show.js.map +0 -1
  690. package/dist/files-browser-host.d.ts +0 -9
  691. package/dist/files-browser-host.js.map +0 -1
  692. package/dist/files-mcp-host.d.ts +0 -58
  693. package/dist/files-mcp-host.js.map +0 -1
  694. package/dist/files-observability.d.ts +0 -29
  695. package/dist/files-observability.js.map +0 -1
  696. package/dist/files-program/client.d.ts +0 -136
  697. package/dist/files-program/client.js.map +0 -1
  698. package/dist/files-program/journeys.d.ts +0 -15
  699. package/dist/files-program/journeys.js.map +0 -1
  700. package/dist/files-program/program.d.ts +0 -1
  701. package/dist/files-program/program.js.map +0 -1
  702. package/dist/files-program/protocol.d.ts +0 -180
  703. package/dist/files-program/protocol.js.map +0 -1
  704. package/dist/files-register-host.d.ts +0 -70
  705. package/dist/files-register-host.js.map +0 -1
  706. package/dist/files-trace.d.ts +0 -61
  707. package/dist/files-trace.js.map +0 -1
  708. package/dist/filesystem.d.ts +0 -38
  709. package/dist/filesystem.js.map +0 -1
  710. package/dist/flush.d.ts +0 -19
  711. package/dist/flush.js.map +0 -1
  712. package/dist/forward.d.ts +0 -11
  713. package/dist/forward.js.map +0 -1
  714. package/dist/gateway.d.ts +0 -38
  715. package/dist/gateway.js.map +0 -1
  716. package/dist/git/ground-owners.d.ts +0 -15
  717. package/dist/git/ground-owners.js.map +0 -1
  718. package/dist/git/held-package.d.ts +0 -67
  719. package/dist/git/held-package.js.map +0 -1
  720. package/dist/git/home.d.ts +0 -59
  721. package/dist/git/home.js.map +0 -1
  722. package/dist/git/marker.d.ts +0 -21
  723. package/dist/git/marker.js.map +0 -1
  724. package/dist/git/named-objects.d.ts +0 -24
  725. package/dist/git/named-objects.js.map +0 -1
  726. package/dist/git/objects.d.ts +0 -30
  727. package/dist/git/objects.js.map +0 -1
  728. package/dist/git/play.d.ts +0 -30
  729. package/dist/git/play.js.map +0 -1
  730. package/dist/git/quarantine.d.ts +0 -48
  731. package/dist/git/quarantine.js.map +0 -1
  732. package/dist/git/rail.d.ts +0 -206
  733. package/dist/git/rail.js.map +0 -1
  734. package/dist/git/read-state.d.ts +0 -49
  735. package/dist/git/read-state.js.map +0 -1
  736. package/dist/git/repository.d.ts +0 -62
  737. package/dist/git/repository.js.map +0 -1
  738. package/dist/git/write-files.d.ts +0 -29
  739. package/dist/git/write-files.js.map +0 -1
  740. package/dist/git-binding.d.ts +0 -53
  741. package/dist/git-binding.js.map +0 -1
  742. package/dist/git-cat-file.d.ts +0 -28
  743. package/dist/git-cat-file.js.map +0 -1
  744. package/dist/git-command.d.ts +0 -96
  745. package/dist/git-command.js.map +0 -1
  746. package/dist/git-index-entries.d.ts +0 -16
  747. package/dist/git-index-entries.js.map +0 -1
  748. package/dist/git-index-format.d.ts +0 -52
  749. package/dist/git-index-format.js.map +0 -1
  750. package/dist/git-install-lines.d.ts +0 -12
  751. package/dist/git-install-lines.js.map +0 -1
  752. package/dist/git-launcher-process.d.ts +0 -1
  753. package/dist/git-launcher-process.js.map +0 -1
  754. package/dist/git-launcher.d.ts +0 -70
  755. package/dist/git-launcher.js.map +0 -1
  756. package/dist/graph-heads.d.ts +0 -71
  757. package/dist/graph-heads.js.map +0 -1
  758. package/dist/ground-basis.d.ts +0 -278
  759. package/dist/ground-basis.js.map +0 -1
  760. package/dist/ground-checkpoint-worker.d.ts +0 -1
  761. package/dist/ground-checkpoint-worker.js.map +0 -1
  762. package/dist/ground-checkpoints.d.ts +0 -16
  763. package/dist/ground-checkpoints.js.map +0 -1
  764. package/dist/ground-contract.d.ts +0 -11
  765. package/dist/ground-contract.js.map +0 -1
  766. package/dist/ground-coordination.d.ts +0 -140
  767. package/dist/ground-coordination.js.map +0 -1
  768. package/dist/ground-database.d.ts +0 -40
  769. package/dist/ground-database.js.map +0 -1
  770. package/dist/ground-differences.d.ts +0 -24
  771. package/dist/ground-differences.js.map +0 -1
  772. package/dist/ground-holders.d.ts +0 -4
  773. package/dist/ground-holders.js.map +0 -1
  774. package/dist/ground-initialization-worker.d.ts +0 -1
  775. package/dist/ground-initialization-worker.js.map +0 -1
  776. package/dist/ground-initialization.d.ts +0 -38
  777. package/dist/ground-initialization.js.map +0 -1
  778. package/dist/ground-install-saves.d.ts +0 -104
  779. package/dist/ground-install-saves.js.map +0 -1
  780. package/dist/ground-inventory-schema.d.ts +0 -58
  781. package/dist/ground-inventory-schema.js.map +0 -1
  782. package/dist/ground-marks.d.ts +0 -49
  783. package/dist/ground-marks.js.map +0 -1
  784. package/dist/ground-profile.d.ts +0 -14
  785. package/dist/ground-profile.js.map +0 -1
  786. package/dist/ground-reads.d.ts +0 -86
  787. package/dist/ground-reads.js.map +0 -1
  788. package/dist/ground-relations.d.ts +0 -57
  789. package/dist/ground-relations.js.map +0 -1
  790. package/dist/ground-root-index.d.ts +0 -14
  791. package/dist/ground-root-index.js.map +0 -1
  792. package/dist/ground-row.d.ts +0 -78
  793. package/dist/ground-row.js.map +0 -1
  794. package/dist/ground-save-ops.d.ts +0 -62
  795. package/dist/ground-save-ops.js.map +0 -1
  796. package/dist/ground-saver-worker.d.ts +0 -1
  797. package/dist/ground-saver-worker.js.map +0 -1
  798. package/dist/ground-saver.d.ts +0 -103
  799. package/dist/ground-saver.js.map +0 -1
  800. package/dist/ground-store.d.ts +0 -125
  801. package/dist/ground-store.js.map +0 -1
  802. package/dist/index.d.ts +0 -22
  803. package/dist/index.js.map +0 -1
  804. package/dist/initial-publication.d.ts +0 -42
  805. package/dist/initial-publication.js.map +0 -1
  806. package/dist/installation/environment.d.ts +0 -31
  807. package/dist/installation/environment.js.map +0 -1
  808. package/dist/installation/lease.d.ts +0 -6
  809. package/dist/installation/lease.js.map +0 -1
  810. package/dist/installation/ownership.d.ts +0 -30
  811. package/dist/installation/ownership.js.map +0 -1
  812. package/dist/installation/selection.d.ts +0 -8
  813. package/dist/installation/selection.js.map +0 -1
  814. package/dist/keychain/cli-io.d.ts +0 -8
  815. package/dist/keychain/cli-io.js.map +0 -1
  816. package/dist/keychain/cli.d.ts +0 -12
  817. package/dist/keychain/cli.js.map +0 -1
  818. package/dist/keychain/host.d.ts +0 -28
  819. package/dist/keychain/host.js.map +0 -1
  820. package/dist/keychain/http-mount.d.ts +0 -16
  821. package/dist/keychain/http-mount.js.map +0 -1
  822. package/dist/keychain/key-wire.d.ts +0 -12
  823. package/dist/keychain/key-wire.js.map +0 -1
  824. package/dist/keychain/presence-mac.d.ts +0 -8
  825. package/dist/keychain/presence-mac.js.map +0 -1
  826. package/dist/keychain/presence.d.ts +0 -9
  827. package/dist/keychain/presence.js.map +0 -1
  828. package/dist/keychain/rail.d.ts +0 -19
  829. package/dist/keychain/rail.js.map +0 -1
  830. package/dist/keychain/secret-apply.d.ts +0 -22
  831. package/dist/keychain/secret-apply.js.map +0 -1
  832. package/dist/keychain/shelf-from-ledger.d.ts +0 -15
  833. package/dist/keychain/shelf-from-ledger.js.map +0 -1
  834. package/dist/keychain/use-log.d.ts +0 -7
  835. package/dist/keychain/use-log.js.map +0 -1
  836. package/dist/keychain/vault-file.d.ts +0 -12
  837. package/dist/keychain/vault-file.js.map +0 -1
  838. package/dist/line-judge.d.ts +0 -39
  839. package/dist/line-judge.js.map +0 -1
  840. package/dist/line-loops.d.ts +0 -22
  841. package/dist/line-loops.js.map +0 -1
  842. package/dist/link-target.d.ts +0 -16
  843. package/dist/link-target.js.map +0 -1
  844. package/dist/local-host.d.ts +0 -20
  845. package/dist/local-host.js.map +0 -1
  846. package/dist/loop-watch.d.ts +0 -17
  847. package/dist/loop-watch.js.map +0 -1
  848. package/dist/machine-host.d.ts +0 -249
  849. package/dist/machine-host.js.map +0 -1
  850. package/dist/main.d.ts +0 -2
  851. package/dist/main.js.map +0 -1
  852. package/dist/materialize-records.d.ts +0 -98
  853. package/dist/materialize-records.js.map +0 -1
  854. package/dist/materialized-graph.d.ts +0 -22
  855. package/dist/materialized-graph.js.map +0 -1
  856. package/dist/module-thread.d.ts +0 -9
  857. package/dist/module-thread.js.map +0 -1
  858. package/dist/mount.d.ts +0 -13
  859. package/dist/mount.js.map +0 -1
  860. package/dist/official-mcp-host.d.ts +0 -51
  861. package/dist/official-mcp-host.js.map +0 -1
  862. package/dist/on-demand-roots.d.ts +0 -31
  863. package/dist/on-demand-roots.js.map +0 -1
  864. package/dist/open-standing.d.ts +0 -8
  865. package/dist/open-standing.js.map +0 -1
  866. package/dist/own-results.d.ts +0 -37
  867. package/dist/own-results.js.map +0 -1
  868. package/dist/package-pages.d.ts +0 -41
  869. package/dist/package-pages.js.map +0 -1
  870. package/dist/patient-flush.d.ts +0 -24
  871. package/dist/patient-flush.js.map +0 -1
  872. package/dist/physical-path-witness.d.ts +0 -64
  873. package/dist/physical-path-witness.js.map +0 -1
  874. package/dist/placement-owed.d.ts +0 -28
  875. package/dist/placement-owed.js.map +0 -1
  876. package/dist/placement-tidy.d.ts +0 -57
  877. package/dist/placement-tidy.js.map +0 -1
  878. package/dist/platform-product-host.d.ts +0 -51
  879. package/dist/platform-product-host.js.map +0 -1
  880. package/dist/platform-tools.d.ts +0 -22
  881. package/dist/platform-tools.js.map +0 -1
  882. package/dist/process-lifecycle.d.ts +0 -13
  883. package/dist/process-lifecycle.js.map +0 -1
  884. package/dist/product-cli.d.ts +0 -26
  885. package/dist/product-cli.js.map +0 -1
  886. package/dist/pty-host.d.ts +0 -16
  887. package/dist/pty-host.js.map +0 -1
  888. package/dist/received-state.d.ts +0 -90
  889. package/dist/received-state.js.map +0 -1
  890. package/dist/reference-placement.d.ts +0 -26
  891. package/dist/reference-placement.js.map +0 -1
  892. package/dist/registry-graph.d.ts +0 -112
  893. package/dist/registry-graph.js.map +0 -1
  894. package/dist/registry-page-cache.d.ts +0 -15
  895. package/dist/registry-page-cache.js.map +0 -1
  896. package/dist/release-catalog.d.ts +0 -5
  897. package/dist/release-catalog.js.map +0 -1
  898. package/dist/root-install.d.ts +0 -72
  899. package/dist/root-install.js.map +0 -1
  900. package/dist/runtime-activity.d.ts +0 -20
  901. package/dist/runtime-activity.js.map +0 -1
  902. package/dist/runtime-argv.d.ts +0 -8
  903. package/dist/runtime-argv.js.map +0 -1
  904. package/dist/runtime-command-host.d.ts +0 -46
  905. package/dist/runtime-command-host.js.map +0 -1
  906. package/dist/runtime-node-flags.d.ts +0 -10
  907. package/dist/runtime-node-flags.js.map +0 -1
  908. package/dist/runtime-wire-host.d.ts +0 -17
  909. package/dist/runtime-wire-host.js.map +0 -1
  910. package/dist/service/adapter.d.ts +0 -37
  911. package/dist/service/adapter.js.map +0 -1
  912. package/dist/service/cli.d.ts +0 -8
  913. package/dist/service/cli.js.map +0 -1
  914. package/dist/service/control.d.ts +0 -38
  915. package/dist/service/control.js.map +0 -1
  916. package/dist/service/index.d.ts +0 -9
  917. package/dist/service/index.js.map +0 -1
  918. package/dist/service/keepalive.d.ts +0 -11
  919. package/dist/service/keepalive.js.map +0 -1
  920. package/dist/service/launchd.d.ts +0 -9
  921. package/dist/service/launchd.js.map +0 -1
  922. package/dist/service/owner.d.ts +0 -4
  923. package/dist/service/owner.js.map +0 -1
  924. package/dist/service/policy.d.ts +0 -36
  925. package/dist/service/policy.js.map +0 -1
  926. package/dist/service/portable.d.ts +0 -10
  927. package/dist/service/portable.js.map +0 -1
  928. package/dist/service/recovery.d.ts +0 -28
  929. package/dist/service/recovery.js.map +0 -1
  930. package/dist/service/registration.d.ts +0 -84
  931. package/dist/service/registration.js.map +0 -1
  932. package/dist/service/systemd-unit.d.ts +0 -7
  933. package/dist/service/systemd-unit.js.map +0 -1
  934. package/dist/service/systemd.d.ts +0 -5
  935. package/dist/service/systemd.js.map +0 -1
  936. package/dist/service/windows-action.d.ts +0 -18
  937. package/dist/service/windows-action.js.map +0 -1
  938. package/dist/service/windows-task.d.ts +0 -15
  939. package/dist/service/windows-task.js.map +0 -1
  940. package/dist/service/windows.d.ts +0 -2
  941. package/dist/service/windows.js.map +0 -1
  942. package/dist/sha256.d.ts +0 -1
  943. package/dist/sha256.js.map +0 -1
  944. package/dist/sharing-admission.d.ts +0 -22
  945. package/dist/sharing-admission.js.map +0 -1
  946. package/dist/sharing-host.d.ts +0 -14
  947. package/dist/sharing-host.js.map +0 -1
  948. package/dist/sharing-mcp-host.d.ts +0 -23
  949. package/dist/sharing-mcp-host.js.map +0 -1
  950. package/dist/snapshot-delivery-baseline.d.ts +0 -31
  951. package/dist/snapshot-delivery-baseline.js.map +0 -1
  952. package/dist/socket-marking.d.ts +0 -9
  953. package/dist/socket-marking.js.map +0 -1
  954. package/dist/source-proof.d.ts +0 -23
  955. package/dist/source-proof.js.map +0 -1
  956. package/dist/source-signature.d.ts +0 -157
  957. package/dist/source-signature.js.map +0 -1
  958. package/dist/source-witness.d.ts +0 -9
  959. package/dist/source-witness.js.map +0 -1
  960. package/dist/sqlite-durability.d.ts +0 -32
  961. package/dist/sqlite-durability.js.map +0 -1
  962. package/dist/sqlite.d.ts +0 -10
  963. package/dist/sqlite.js.map +0 -1
  964. package/dist/state-host.d.ts +0 -4
  965. package/dist/state-host.js.map +0 -1
  966. package/dist/state-store.d.ts +0 -15
  967. package/dist/state-store.js.map +0 -1
  968. package/dist/sync-address.d.ts +0 -16
  969. package/dist/sync-address.js.map +0 -1
  970. package/dist/sync-cli.d.ts +0 -7
  971. package/dist/sync-cli.js.map +0 -1
  972. package/dist/sync-setting.d.ts +0 -43
  973. package/dist/sync-setting.js.map +0 -1
  974. package/dist/tool-mcp-client.d.ts +0 -7
  975. package/dist/tool-mcp-client.js.map +0 -1
  976. package/dist/toolbox-host.d.ts +0 -4
  977. package/dist/toolbox-host.js.map +0 -1
  978. package/dist/transfer-instrumentation.d.ts +0 -47
  979. package/dist/transfer-instrumentation.js.map +0 -1
  980. package/dist/turns.d.ts +0 -44
  981. package/dist/turns.js.map +0 -1
  982. package/dist/updates/artifacts.d.ts +0 -66
  983. package/dist/updates/artifacts.js.map +0 -1
  984. package/dist/updates/bootstrap.d.ts +0 -94
  985. package/dist/updates/bootstrap.js.map +0 -1
  986. package/dist/updates/controller.d.ts +0 -78
  987. package/dist/updates/controller.js.map +0 -1
  988. package/dist/updates/isolated-command-lifetime.d.ts +0 -1
  989. package/dist/updates/isolated-command-lifetime.js.map +0 -1
  990. package/dist/updates/locked-packages.d.ts +0 -4
  991. package/dist/updates/locked-packages.js.map +0 -1
  992. package/dist/updates/store.d.ts +0 -47
  993. package/dist/updates/store.js.map +0 -1
  994. package/dist/updates/trust.d.ts +0 -20
  995. package/dist/updates/trust.js.map +0 -1
  996. package/dist/user-ground-host.d.ts +0 -1007
  997. package/dist/user-ground-host.js.map +0 -1
  998. package/dist/watching/fsevents.d.ts +0 -69
  999. package/dist/watching/fsevents.js.map +0 -1
  1000. package/dist/watching/git-storage.d.ts +0 -22
  1001. package/dist/watching/git-storage.js.map +0 -1
  1002. package/dist/watching/host.d.ts +0 -388
  1003. package/dist/watching/host.js.map +0 -1
  1004. package/dist/watching/index.d.ts +0 -3
  1005. package/dist/watching/index.js.map +0 -1
  1006. package/dist/watching/inotify.d.ts +0 -81
  1007. package/dist/watching/inotify.js.map +0 -1
  1008. package/dist/windows-fs.d.ts +0 -12
  1009. package/dist/windows-fs.js.map +0 -1
  1010. package/dist/windows-owner-only.d.ts +0 -6
  1011. package/dist/windows-owner-only.js.map +0 -1
  1012. package/dist/wire-binary.d.ts +0 -9
  1013. package/dist/wire-binary.js.map +0 -1
  1014. package/dist/wire-client.d.ts +0 -86
  1015. package/dist/wire-client.js.map +0 -1
  1016. package/dist/wire-join.d.ts +0 -19
  1017. package/dist/wire-join.js.map +0 -1
  1018. package/dist/wire-outbox.d.ts +0 -37
  1019. package/dist/wire-outbox.js.map +0 -1
  1020. package/dist/wire-request-scope.d.ts +0 -17
  1021. package/dist/wire-request-scope.js.map +0 -1
  1022. package/dist/wire-socket-relay.d.ts +0 -54
  1023. package/dist/wire-socket-relay.js.map +0 -1
  1024. package/dist/workspace-add-intent.d.ts +0 -41
  1025. package/dist/workspace-add-intent.js.map +0 -1
  1026. package/dist/workspace-add-staging.d.ts +0 -192
  1027. package/dist/workspace-add-staging.js.map +0 -1
  1028. package/dist/workspace-host.d.ts +0 -32
  1029. package/dist/workspace-host.js.map +0 -1
  1030. package/dist/workspace-store.d.ts +0 -8
  1031. package/dist/workspace-store.js.map +0 -1
  1032. package/skills/shell/SKILL.md +0 -175
@@ -8,7 +8,7 @@ import { absentTops, admissionUnits } from "./detection/admission-units.js";
8
8
  import { denied } from "./detection/unreadable.js";
9
9
  import { heldParent, unownedCache } from "./content-cache-retention.js";
10
10
  import { collectContentCache } from "./content-cache-collection.js";
11
- import { portableGroundRecord as portableRecord, slashPath, storedWithin } from "./ground-row.js";
11
+ import { GROUND_ROW_PROJECTION, portableGroundRecord as portableRecord, slashPath, storedWithin } from "./ground-row.js";
12
12
  import { groundStore } from "./ground-store.js";
13
13
  import { groundSaveDurability, hearOwedExaminations, save, saved as groundSaved } from "./ground-saver.js";
14
14
  import { GroundDatabaseAway, groundDatabase, groundFile, openGroundConnection, releaseGroundDatabase } from "./ground-database.js";
@@ -17,13 +17,12 @@ import { assertGroundInitialized, initializeGroundDatabase } from "./ground-init
17
17
  import { earlierGroundNotice } from "./ground-contract.js";
18
18
  import { GroundBasisChangedError, readGroundRow, rootRevision } from "./ground-basis.js";
19
19
  import { createHash, randomUUID } from "node:crypto";
20
- import { existsSync, lstatSync, mkdirSync, realpathSync, readFileSync, rmSync, statSync, } from "node:fs";
20
+ import { existsSync, lstatSync, mkdirSync, realpathSync, rmSync, statSync, } from "node:fs";
21
21
  import { open, readFile, rm } from "node:fs/promises";
22
22
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
23
23
  import { setTimeout as sleep } from "node:timers/promises";
24
- import { buildUserManifest, LOCAL_DIR_NAME, USER_IGNORE_FILE_NAME, USER_ROOTS, userLayout, } from "@amalgm/core/identity";
25
- import { CHUNK_BYTES, INLINE_CARGO_MAX_BYTES, ENTITY_CLOUD_CONTRACT, ENTITY_CLOUD_SCHEMA_VERSION, artifactForRecord, computerFolder, FILES_FOLDER, classifyDirectory, classifyRegisteredRoot, createLocalEntityRecord, createEntityRecordAuthorityPort, convergeUserGround, createWeightedGate, parallelForEach, chunkSizes, encodeCargoBody, fetchManifests, isContentParts, layoutManifest, isContentPlacementChangedError, isRefusal, refusal, downloadAll as downloadAllArtifacts, EntityApplyRail, EntityRecordRail, materializableRecordsSteps, suspectScope, CONTENT_REFS_BATCH_OBJECTS, privateEntityResourceId, sameRecords, statedRecords, snapshotFromRecords, stableJson, streamCargo, upload as uploadArtifact, UploadSourceMismatchError, userGroundSelection, findUserGroundRoot, normalizeUserGroundIdentity, DEFAULT_AMALGM_IGNORE, CONTAINERS, packageProposalsSteps, recordPermanentDeletion, Recoveries, Recovering, } from "@amalgm/live";
26
- import { ApplyMap, readDriveTop } from "./apply-map.js";
24
+ import { buildUserManifest, LOCAL_DIR_NAME, USER_ROOTS, userLayout, } from "@amalgm/core/identity";
25
+ import { CHUNK_BYTES, INLINE_CARGO_MAX_BYTES, ENTITY_CLOUD_CONTRACT, ENTITY_CLOUD_SCHEMA_VERSION, artifactForRecord, computerFolder, FILES_FOLDER, classifyDirectory, classifyRegisteredRoot, createLocalEntityRecord, createEntityRecordAuthorityPort, convergeUserGround, createWeightedGate, parallelForEach, chunkSizes, encodeCargoBody, fetchManifests, isContentParts, layoutManifest, isContentPlacementChangedError, isRefusal, refusal, downloadAll as downloadAllArtifacts, EntityApplyRail, EntityRecordRail, materializableRecordsSteps, suspectScope, CONTENT_REFS_BATCH_OBJECTS, privateEntityResourceId, sameRecords, statedRecords, snapshotFromRecords, stableJson, streamCargo, upload as uploadArtifact, UploadSourceMismatchError, userGroundSelection, findUserGroundRoot, normalizeUserGroundIdentity, CONTAINERS, packageProposalsSteps, recordPermanentDeletion, Recoveries, Recovering, } from "@amalgm/live";
27
26
  import { readInitialPublication } from "./initial-publication.js";
28
27
  import { openFileDatabase } from "./sqlite.js";
29
28
  import { atomicWrite, ensurePrivateDir } from "./filesystem.js";
@@ -35,7 +34,7 @@ import { createConstructDoor } from "./construct-door.js";
35
34
  import { EntityRecordSqliteStore } from "./entity-record-store.js";
36
35
  import { observeEntityRecordPorts } from "./entity-record-observability.js";
37
36
  import { createEntityAccessPort } from "./entity-access-wire.js";
38
- import { HeldRemovals, arrivalRecord, recordMode, recordMove, } from "@amalgm/live/drive";
37
+ import { HeldRemovals, arrivalRecord, recordMode, recordMove, recordTime, } from "@amalgm/live/drive";
39
38
  import { followGrantedChannels } from "./entity-channel-holdings.js";
40
39
  import { indexRowsByOutermostRootSteps } from "./ground-root-index.js";
41
40
  import { ContentCacheDownload, persistRecordCargo, hasSealedContent, discardCachedArtifact, readLayoutHint, readLayoutHints, checkedLayoutHint, contentFile, } from "./content-cache-host.js";
@@ -62,18 +61,21 @@ import { sameAttempt, sqliteApplyOwnership } from "./detection/apply-ownership.j
62
61
  import { createFilesRegisterPorts, ensureWorkspaceBinding, materializedWorkspaceBindings, pathExists, pathWithin, workspaceBindings, } from "./files-register-host.js";
63
62
  import { BaseFetching, cachedParent, cachedParentOf, holdsPackage } from "./git/held-package.js";
64
63
  import { marksRepository, observeGitMarker } from "./git/marker.js";
64
+ import { groundGitOwners } from "./git/ground-owners.js";
65
65
  import { gitStorageOwner, repositoryGroundCones } from "./git-binding.js";
66
- import { readSharingPolicy } from "./detection/sharing-policy.js";
67
- import { policyChanged, policyExaminations } from "./detection/policy-owed.js";
66
+ import { readSkipPolicy } from "./detection/skip-policy.js";
67
+ import { policyExaminations, SkipRulesOwed } from "./detection/policy-owed.js";
68
+ import { SealedFolders } from "./detection/sealed-folders.js";
68
69
  import { frameScope, outermostNames } from "./detection/scope-frame.js";
69
70
  import { readWalkedRoots } from "./detection/walked-roots.js";
70
71
  import { RACY_HORIZON_MS, physicalKey, retainSighting } from "./source-signature.js";
71
72
  import { assertQualified, stampContentClock } from "./content-clock.js";
72
73
  import { HeldHeads, ProvenGraphs, ReceivedStateUnavailableError, readReceivedState } from "./received-state.js";
74
+ import { groundPlaces, readComputerFolder, rootDirectory, soleCoreRoot } from "./ground-places.js";
73
75
  import { unitMembers } from "./apply-enter-plan.js";
74
76
  import { shownReferenceTo } from "./apply-showing.js";
75
77
  import { registryGraphFromSnapshot, } from "./registry-graph.js";
76
- import { readVerifiedRegistryPage, writeVerifiedRegistryPage, } from "./registry-page-cache.js";
78
+ import { readVerifiedRegistryPage, registryPagePath, writeVerifiedRegistryPage, } from "./registry-page-cache.js";
77
79
  import { GitStorageDependencies, NodeWatchHost, presentDirectory, } from "./watching/index.js";
78
80
  import { beginGroundWait, GroundCoordinator, GroundEffectCrossedError, GroundFootprintExceededError, PackedPhysicalKeys, PhysicalKeySet } from "./ground-coordination.js";
79
81
  import { physicalPath } from "./sync-address.js";
@@ -94,170 +96,74 @@ import { readRowsOutside, hasGroundRows, hasRootRows, readRootMembers, readRowsR
94
96
  import { workspaceAddCones, workspaceAddStagingPath, workspaceAddSelection, readWorkspaceAddIntent, hasWorkspaceAddIntent, readWorkspaceAddIntents, persistWorkspaceAddIntent, deleteWorkspaceAddIntent } from "./workspace-add-intent.js";
95
97
  import { capturedGroundRow, persistRows } from "./captured-rows.js";
96
98
  import { installGitLines } from "./git-install-lines.js";
99
+ import { seenName, shelfName } from "./drive/names.js";
100
+ import { foldersMet } from "./own-folders.js";
97
101
  import { RootOffDevice, RootUnreachable, RootRecreated, observeRoot } from "./detection/root-walk.js";
98
- /** One cargo segment loads its ground bytes across this many concurrent
99
- * reads. Reading and hashing overlap the wire without letting a
100
- * 256-artifact segment claim hundreds of file descriptors at once. */
101
102
  const CARGO_SEGMENT_LOAD_CONCURRENCY = 8;
102
- /** Storage-object lanes for one download set. Tiny objects use the wide
103
- * request window, while the separate byte budget narrows large chunks so
104
- * request concurrency can never silently become an unbounded memory claim. */
105
- /** Admission is sized to the refs batch law so one planned wave resolves in
106
- * one refs frame and the span planner merges each pack's members into a
107
- * few broad ranged reads. Memory is bounded by the byte laws below, never by
108
- * this count. */
109
103
  const DIRECT_OBJECT_DOWNLOAD_CONCURRENCY = CONTENT_REFS_BATCH_OBJECTS;
110
- /** Independent destination writers. Pack reads are intentionally few, but
111
- * one pack may contain thousands of unrelated files; those files must not
112
- * inherit the pack's request count as their filesystem concurrency. Sixteen
113
- * handles are bounded on a 1 GiB runtime and enough to hide metadata latency
114
- * behind the volume's byte throughput. */
115
104
  const DIRECT_CONTENT_STORE_CONCURRENCY = 16;
116
- // Opening one protected object transiently retains the fetched envelope,
117
- // WebCrypto's ciphertext-with-tag input, and the plaintext. Bound plaintext
118
- // to two full blocks so those three representations stay below 96 MiB even
119
- // on the 1 GiB runtimes used for ordinary Files materialization. Small
120
- // objects still use the full request-concurrency window.
121
105
  const DIRECT_OBJECT_DOWNLOAD_MAX_IN_FLIGHT_BYTES = 2 * CHUNK_BYTES;
122
- /** Fetch lanes running at once (Live EntityApplyRailOptions.laneConcurrency). */
123
106
  const APPLY_FETCH_LANES = 4;
124
- /** Bytes every fetch lane's downloads hold together (Live DownloadOptions
125
- * sharedBytes): two downloads' bound, so however many lanes run they cost no
126
- * more memory than two sets, and a small first open behind large sets waits
127
- * for one batch to land, never for a whole set. */
128
107
  const APPLY_LANE_BYTES = 2 * DIRECT_OBJECT_DOWNLOAD_MAX_IN_FLIGHT_BYTES;
129
- /** Unreadable ground is read again at this bounded interval, or sooner when
130
- * it rings; retrying faster only repeats the same refusal. A lane's repeated
131
- * fault backs off to it as well, doubling from DETECT_RETRY_MS. */
132
108
  const UNREADABLE_RETRY_MS = 20_000;
133
- /** Named rings run at most one attempt per lane kind and root, this many at once. */
134
109
  const NAMED_DETECT_LANES = 4;
135
- /** The root a named or repository lane key serves. */
136
110
  const laneRoot = (lane) => lane.slice(lane.indexOf(":") + 1);
137
111
  const DOWNLOAD_CONTENT_RETRY_ATTEMPTS = 3;
138
- /** How long `enterNow` waits while its unit's chain makes no progress
139
- * before the drive hears `unavailable`: the touch fails honestly, and the
140
- * lane keeps every obligation. A chain still moving is never cut off. */
141
112
  const ENTER_NOW_STALL_MS = 30_000;
142
- /** A failed placement as the drive's placer port reads it (Live's drive
143
- * contract, PlacementFailure): a code, a message, and the unit that did not
144
- * place when it is not the asked one. */
145
113
  const placementFailure = (code, message, failed) => Object.assign(new Error(message), { code }, failed === undefined ? {} : { failed });
146
- /** Shutdown's one network budget, shared by Apply's last chance to release
147
- * ground and Send's last chance to deliver what the final pass recorded. Only
148
- * time spent waiting on the network counts against it. */
149
114
  const SHUTDOWN_NETWORK_BUDGET_MS = 10_000;
150
- /** Where a pooled examination's differences are examined. Every difference
151
- * is a name the folder scan follows, a repository's `.git` included, and the
152
- * root's own object, re-created at its bound address, is read by the folder
153
- * scan. */
154
115
  function rootScope(suspicion, result) {
155
- // A vacant top is an address proved unoccupied whose former object no
156
- // other difference claims: one absence at its top. The differences name
157
- // every new placement outside an arrived container, which the scan walks
158
- // whole, since a name enters a directory only by changing that directory's
159
- // signature, so a claim of anything stored beneath it is observed, and the
160
- // scan names it as a crossing. An unchanged other name of an object is no
161
- // claim: it keeps its own identity, and the absence owes it examination.
162
116
  const arrived = new Set(result.differences.filter(difference => difference.reason !== "absent")
163
117
  .map(difference => difference.physicalKey));
164
118
  const vacant = result.differences.filter(difference => difference.reason === "absent"
165
119
  && !arrived.has(difference.physicalKey)).map(difference => difference.path);
166
120
  return {
167
121
  rootUUID: result.rootUUID, revision: result.revision, suspicion, vacant,
168
- // A root's own address differs only as another object: the folder scan
169
- // reads it, beside the names it follows.
170
122
  rootDiffers: result.differences.some(difference => difference.path === ""),
171
123
  folders: result.differences.filter(difference => difference.path !== "").map(difference => difference.path),
172
- // A proved return: everything beneath it was compared, so the folder scan
173
- // passes through it to what differs there.
174
124
  answered: result.differences.filter(difference => difference.reason === "returned").map(difference => difference.path),
175
125
  };
176
126
  }
177
- /** A flush asked before login converged, or after convergence failed: no
178
- * prefix can be proved, so it never answers as success. */
179
127
  export class GroundNotConverged extends Error {
180
128
  constructor() { super("the user ground has not converged, so flush can prove nothing"); }
181
129
  }
182
- /** The production Files port injected into Core. Portable identity remains in
183
- * Live; this class owns only Node filesystem, SQLite, Watch, and wire effects. */
184
130
  export class UserGroundHost {
185
131
  options;
186
- /** The door for a need Apply turns into a wait rather than a report (Live
187
- * recover.ts): each one this process meets reaches the background report
188
- * once, and from there the fault drain, like every other failure. */
189
132
  recoveries = new Recoveries((opened) => this.options.onBackgroundError?.(opened));
190
133
  wire;
191
134
  ownedWire;
192
135
  operations = new Set();
193
- /** Roots whose pooled scope refused after its snapshot: their next
194
- * complete examination is the main walk, never the same scope again. */
195
136
  walkOwed = new Set();
196
137
  closeTask = null;
197
- /** The cache's evidence connection outlives each download for the whole
198
- * lifetime (content-cache-index.ts). A closing host takes no new lease. */
199
138
  cacheIndex = null;
200
139
  direct;
201
140
  laneBytes = createWeightedGate(APPLY_LANE_BYTES);
202
141
  watchHost;
203
142
  activeIdentity = null;
204
- /** A Watch ring waits for its turn, never a timer (ringDetect). */
205
143
  detectRingQueued = false;
206
- /** Roots standing off their device, with the reason. Every examination
207
- * re-derives the answer, so restart finds each one again. */
208
144
  rootsOffDevice = new Map();
209
- /** Ground that waits alone, by identity: a repository whose disk holds
210
- * what cannot reach a receiver, or a file too large to send. Every pass
211
- * that reads one answers again, so restart finds each anew. */
212
145
  waitingGround = new Map();
213
- /** One fetch per lost repository package, joined by every later ask. */
214
146
  baseFetches = new Map();
215
- /** Lost packages the cloud answered it holds no copy of, until the next
216
- * ask of that repository reads the answer. */
217
147
  lostBases = new Map();
218
- /** The authority this ground follows, bound before convergence reads
219
- * anything (bindGroundAuthority). */
220
148
  authorityId = null;
221
149
  converged = false;
222
- /** keptComputerFolder's answer, once read or chosen. */
223
150
  computer;
224
- /** Cumulative graph-page reads, reported as diffs on the stages that
225
- * materialize roots so the ledger shows what each operation actually read. */
226
151
  graphPageReads = { fetchedPages: 0, fetchedBytes: 0, cachedPages: 0 };
227
- /** Named and repository lanes by lane key: one attempt per lane and root,
228
- * NAMED_DETECT_LANES at once. */
229
152
  namedAttempts = new Map();
230
153
  namedRotation = 0;
231
- /** Lanes that found ground an effect holds, each with the end of its
232
- * wait. They hold no slot; every release makes them look again. */
233
154
  groundWaits = new Map();
234
- /** Waits a release's look has not yet found still held. */
235
155
  groundLook = null;
236
156
  groundLookQueued = false;
237
- /** The one complete-lane attempt. */
238
157
  completeAttempt = null;
239
- /** The ground each running lane examines: one examination per ground. */
240
158
  examinations = new Examinations();
241
- /** Ground reads running in the background (discovery warms, maintenance
242
- * visits): close drains them with the attempts before the ground database
243
- * goes, so none reopens it. */
244
159
  backgroundReads = new Set();
245
- /** Lanes whose last attempt failed. A parked lane holds no slot. */
246
160
  parkedDetect = new Map();
247
- /** Consecutive faults per lane since its last proof. */
248
161
  laneFaults = new Map();
249
- /** Callers proving a finite ticket; every finished attempt wakes them. */
250
162
  detectWaiters = new Set();
251
163
  recordRail = null;
252
- /** Rail rings a Detect commit owes, queued for a later turn so the
253
- * committing task ends before a rail's drain starts. Each stays here until
254
- * it runs; shutdown drains them into its flushes and pause retires them,
255
- * since a ring only wakes durable work. */
256
164
  nextTurns = new Map();
257
165
  stopCacheMaintenance = null;
258
166
  recordStore = null;
259
- /** The drive's removals, held until their burst ends (Live
260
- * drive/held-removals.ts); released before the rail flushes or closes. */
261
167
  heldRemovals = null;
262
168
  entityAccess = null;
263
169
  constructLedger = null;
@@ -265,50 +171,30 @@ export class UserGroundHost {
265
171
  releaseGrantWatch = null;
266
172
  applyRail = null;
267
173
  applyHost = null;
268
- /** Pays the placement notes every notebook writer leaves (placement-tidy.ts). */
269
174
  placementTidy = null;
270
- /** The maps of the roots this computer serves on demand (apply-map.ts),
271
- * each woken when Receive commits, and with the entities a window end or a
272
- * Detect commit admitted. */
273
- driveMaps = new Map();
274
- /** Who hears what the drive's maps list change (onDriveChange). */
275
- driveListeners = new Set();
276
- /** The kept heads the Apply rail proved, through the page reader it reads
277
- * graph pages with, kept while it runs for the drive maps, which hold the
278
- * same graphs a fetch lane reads. */
279
- driveGraphs = null;
280
- /** The kept heads a look at a root's top reads, over the same graphs: a
281
- * root only looked at loads no map (apply-map.ts readDriveTop). */
282
- driveTops = null;
283
- /** Where a root a fetch lane enters stands: the drive's shelf, named by the
284
- * root's UUID, given by the drive's placer (`enterNow`). */
175
+ graphs = null;
176
+ driveWakes = new Set();
285
177
  driveShelf = null;
286
- /** Each root's one install in flight, a fetch lane's Enter or its resume:
287
- * a touch that finds one joins it. */
288
178
  rootInstalls = new Map();
289
179
  detectJobs = 0;
290
- /** This runtime's identity in the disposition ledger. */
291
180
  incarnation = randomUUID();
292
181
  detectLedger = null;
293
182
  namedDetect = null;
294
- /** The grounds Watch was last asked to cover, and the outside Git storage
295
- * their repositories declare beside them. */
183
+ skipRulesOwed = new SkipRulesOwed(folders => {
184
+ this.sealedFolders.clear();
185
+ this.watchHost.resealed(folders);
186
+ });
187
+ skipRulesSeeded = false;
188
+ sealedFolders = new SealedFolders(() => this.policyRoots(), () => groundDatabase(this.databasePath()));
296
189
  watchGrounds = null;
297
190
  gitStorage = null;
298
- /** Roots whose verified reveal is the baseline their first Watch coverage
299
- * owes. The binding that makes a root coverable makes it coverable to every
300
- * caller, so whichever reconcile covers it first spends the baseline. */
301
191
  owedBaselines = new Set();
302
192
  closing = false;
303
- /** Add journeys holding their ground; the maintenance sweep waits them out. */
304
193
  workspaceAdds = 0;
305
- /** The periodic metadata sweep of every Watch root. Its findings are owed
306
- * to the scoped lanes; it never writes. */
307
194
  maintenance = new MaintenanceSweep({
308
195
  owners: () => {
309
196
  const roots = this.watchHost.evidence().roots;
310
197
  const complete = new Set(this.watchHost.pending().filter(({ pending }) => pending.complete).map(({ rootId }) => rootId));
311
- // A nested root takes the complete lane, as in root examination.
312
198
  return roots.filter(root => !roots.some(other => other !== root
313
199
  && (pathWithin(other.directory, root.directory) || pathWithin(root.directory, other.directory))))
314
200
  .map(root => ({ owner: root.rootId, directory: root.directory, owesComplete: complete.has(root.rootId) }));
@@ -319,25 +205,14 @@ export class UserGroundHost {
319
205
  wake: () => this.wakeDetect(),
320
206
  stage: input => this.stage(input),
321
207
  });
322
- /** The maintenance requests each cut captured before its proof read. */
323
208
  maintenanceCoverage = new WeakMap();
324
- /** Examinations this lifetime's saves left owed ring as named suspicion. */
325
209
  owedExaminations = new OwedExaminations(path => this.watchHost.suspect(path));
326
210
  hearingOwed = null;
327
- /** Visible-ground effects coordinate by address cone: Detect passes hold
328
- * the roots they observe, Apply holds its target addresses, Register and
329
- * Add hold the ground they materialize. Unrelated cones never wait. */
330
211
  ground = new GroundCoordinator();
331
212
  boundUserRoot;
332
- /** The directories from the home down to the folder holding this runtime's
333
- * database, each as the object that stood there when it opened. */
334
213
  databaseGround = [];
335
- /** Watch's latest unsettled count and what the activity hook last heard,
336
- * both unset until Watch first reports. */
337
214
  watchUnsettled;
338
215
  saidUnsettled;
339
- /** Apply waits on ground without a deadline; shutdown cancels them just
340
- * before it stops the Apply rail, which resumes from durable intents. */
341
216
  applyWaits = new AbortController();
342
217
  port;
343
218
  constructor(options) {
@@ -354,15 +229,11 @@ export class UserGroundHost {
354
229
  }, this.wire.signal);
355
230
  this.watchHost = new NodeWatchHost({
356
231
  open: options.openWatch,
357
- // Watch establishes the native evidence boundary during convergence.
358
- // Keep every ring in Watch, but do not let Detect consume that evidence
359
- // until Apply has resumed any revealed intent and owns materialization
360
- // truth.
232
+ sealed: directory => this.sealedFolders.sealed(directory),
361
233
  onSignal: () => {
362
234
  if (this.converged)
363
235
  this.ringDetect();
364
236
  },
365
- // Native evidence is built per event only while a trace observes it.
366
237
  ...(options.onFilesStage ? { onEvent: (evidence) => this.stage({
367
238
  primitive: "watch",
368
239
  stage: "native-suspicion",
@@ -402,11 +273,7 @@ export class UserGroundHost {
402
273
  this.converged = false;
403
274
  this.maintenance.stop();
404
275
  this.activeIdentity = normalizeUserGroundIdentity(identity);
405
- // Content threads boot while the ground initializes, so neither
406
- // convergence nor any later edit waits for one.
407
276
  startContentThreads();
408
- // No ground connection exists before its migration and epoch commit
409
- // on the bootstrap thread; the main thread only awaits them.
410
277
  const initialization = await initializeGroundDatabase(this.databasePath());
411
278
  if (initialization.earlierKeptAt !== null)
412
279
  process.stderr.write(earlierGroundNotice(initialization.earlierKeptAt));
@@ -416,7 +283,6 @@ export class UserGroundHost {
416
283
  this.stage({ primitive: "detect", stage: "ground-initialization", status: "completed",
417
284
  durationMs: initialization.readinessMs, measurements: { ...initialization } });
418
285
  await this.bindGroundAuthority(this.activeIdentity);
419
- // Cargo a stop left journaled moves into the cache beside everything.
420
286
  nameCargo(this.databasePath(), this.cacheDir());
421
287
  this.reserveGroundRoots();
422
288
  const local = this.localPort(this.activeIdentity);
@@ -425,10 +291,8 @@ export class UserGroundHost {
425
291
  cloud: this.cloudPort(this.activeIdentity, { kind: "core" }),
426
292
  local,
427
293
  });
428
- // Detect opens first: a resumed Add settles its blind interval
429
- // through Detect before its intent may clear.
430
294
  this.openDetectLedger();
431
- this.namedDetect ??= new NamedDetectRuntime(this.databasePath(), this.cacheDir(), this.bindingDir(), () => this.policyRoots(), ({ durationMs, records, ground }) => {
295
+ this.namedDetect ??= new NamedDetectRuntime(this.databasePath(), this.cacheDir(), this.bindingDir(), () => this.policyRoots(), this.skipRulesOwed, ({ durationMs, records, ground }) => {
432
296
  if (ground)
433
297
  this.stage({ primitive: "record", stage: "ground-write", status: "completed",
434
298
  durationMs, measurements: { lane: "named", ...ground } });
@@ -466,16 +330,10 @@ export class UserGroundHost {
466
330
  deviceId: result.deviceId,
467
331
  localRoot: result.localRoot,
468
332
  cloudHead: result.cloudHead,
469
- // Core's word for a later computer's login is `materialized`, which
470
- // Live keeps for a computer without a drive; a drive computer's
471
- // login says `placed`, since it places only the home's map and the
472
- // runtime's own entries. The word joins Core's own contract next, and
473
- // this translation leaves with it.
474
333
  mode: result.mode === "placed" ? "materialized" : result.mode,
475
334
  watcherRoots: watchHealth.contentHandles,
476
335
  watching: true,
477
336
  };
478
- // An install's lookup started Receive; on any other ground it starts here.
479
337
  if (!this.recordRail)
480
338
  await this.startRecordRail(this.activeIdentity);
481
339
  this.wire.signal.throwIfAborted();
@@ -483,19 +341,12 @@ export class UserGroundHost {
483
341
  this.wire.signal.throwIfAborted();
484
342
  this.converged = true;
485
343
  this.maintenance.start();
486
- // Native rings collected while convergence was establishing Watch
487
- // coverage are ordinary evidence, not a startup exception. They get
488
- // one Detect generation now that Apply recovery is authoritative.
489
344
  if (this.watchHost.hasPending)
490
345
  this.ringDetect();
491
346
  return evidence;
492
347
  }),
493
348
  };
494
349
  }
495
- /** One admitted Files journey; shutdown waits for every writer to settle.
496
- * A journey fences the cached names it trusts until it ends, the first
497
- * login's too: collection may start inside it once the line is first read
498
- * (content-cache-fences.ts). */
499
350
  operation(work) {
500
351
  this.wire.signal.throwIfAborted();
501
352
  const task = Promise.resolve().then(() => {
@@ -508,7 +359,6 @@ export class UserGroundHost {
508
359
  stage(input) {
509
360
  emitFilesStage(this.options.onFilesStage, input);
510
361
  }
511
- /** Whether a counter worth real time on the critical path may be computed. */
512
362
  measuring() {
513
363
  return this.options.filesTraceActive?.()
514
364
  ?? (this.options.onFilesStage !== undefined || this.options.onDetectScan !== undefined);
@@ -534,8 +384,6 @@ export class UserGroundHost {
534
384
  records: evidence.records ?? 0,
535
385
  settled: evidence.settled ?? 0,
536
386
  ...(evidence.recordBytes === undefined ? {} : { recordBytes: evidence.recordBytes }),
537
- // Where the scan actually went. `captureBusyMs / captureMs` is the
538
- // capture pool's occupancy; at ~1 the pool ran one file at a time.
539
387
  walkMs: Math.round(evidence.walkMs ?? 0),
540
388
  gitMs: Math.round(evidence.gitMs ?? 0),
541
389
  captureMs: Math.round(evidence.captureMs ?? 0),
@@ -550,34 +398,15 @@ export class UserGroundHost {
550
398
  databasePath() {
551
399
  return groundFile(this.options.dir);
552
400
  }
553
- /** This machine's ground rows, read from outside the host: a closed host
554
- * holds nothing open, however often it is looked at. */
555
401
  rows() {
556
402
  return readRowsOutside(this.databasePath());
557
403
  }
558
404
  watchHealth() {
559
405
  return this.watchHost.health();
560
406
  }
561
- /** Resolves once what the OS has handed Watch has reached it, already
562
- * counted in `activity.unsettled`. On Linux that is every change made
563
- * before the call. */
564
407
  flushWatch() {
565
408
  return this.watchHost.flush();
566
409
  }
567
- /**
568
- * Place one unit a root on demand lists, at the newest version received
569
- * now, with every unit it needs placed first: its fetch lane (Live
570
- * lane.ts). It answers once every map the drive holds lists the placed
571
- * unit where it stands, so the drive judges it as placed. A rejection is a
572
- * typed placement failure the drive reports to every touch that waited
573
- * (src/drive/): `unavailable` when its chain made no progress for `stall`
574
- * ms, naming the unit it waits on (`failed`), the lane keeping every
575
- * obligation; `refused` when it is nowhere this computer can place it. A
576
- * fault rejects as itself. `rootShelf` names where a workspace root the
577
- * lane enters stands (`enterReferencedRoot`). `emptied` places a file the
578
- * OS emptied before this computer held its bytes: it stands empty, none of
579
- * its bytes fetched, and Detect records it (Live drive/README.md).
580
- */
581
410
  async enterNow(entityId, { stall = ENTER_NOW_STALL_MS, rootShelf, emptied = false } = {}) {
582
411
  if (rootShelf)
583
412
  this.driveShelf = rootShelf;
@@ -586,59 +415,32 @@ export class UserGroundHost {
586
415
  throw placementFailure("unavailable", "Apply is not running on this computer");
587
416
  const answer = await rail.fetch(entityId, { stall, emptied });
588
417
  if (answer.kind === "placed")
589
- return this.refreshDriveMaps([entityId]);
418
+ return;
590
419
  if (answer.kind === "nowhere")
591
420
  throw placementFailure("refused", answer.reason);
592
421
  throw placementFailure("unavailable", `${entityId} made no progress for ${stall} ms: ${answer.reason}`, answer.unit);
593
422
  }
594
- /**
595
- * Remove one unit a root on demand lists that this computer never placed,
596
- * with none of its bytes (Live drive/held-removals.ts): its Trash at the
597
- * version the map lists is held until the burst it belongs to ends, and the
598
- * map lists it no more. False, recording
599
- * nothing, when the home's sharing policy keeps it local, or the map cannot
600
- * say its whole record; the drive then places it and the shelf removes it,
601
- * as Detect records any removal. `rootShelf` names where a root this
602
- * computer never bound would stand, where its policy then stands.
603
- */
604
- async removeListed(unit, { rootShelf }) {
423
+ async removeListed(unit, base, { rootShelf }) {
605
424
  const listed = this.listedChange(unit, [unit], rootShelf);
606
425
  const holds = this.heldRemovals;
607
426
  if (listed === null)
608
- return false;
427
+ return null;
609
428
  if (!holds)
610
429
  throw new Error("the drive needs the entity Record rail running");
611
- await holds.hold({ base: listed.base, authorityId: listed.authorityId, mutationId: randomUUID() }, { root: unit.root, address: unit.address });
612
- await this.listedAgain(unit);
613
- return true;
430
+ await holds.hold({ base, authorityId: listed.authorityId, mutationId: randomUUID() }, { root: unit.root, address: unit.address });
431
+ return [unit.uuid];
614
432
  }
615
- /** Release the drive's held removals when one stands at `place`, so the
616
- * cloud hears that name freed before an act takes it. */
617
433
  async freeListed(place) {
618
434
  await this.heldRemovals?.free(place);
619
435
  }
620
- /**
621
- * Move one file or link a root on demand lists that this computer never
622
- * placed to `to`, a free name of its own root or another, with none of its
623
- * bytes (Live drive/records.ts). Within its root the move is recorded at
624
- * the version the map lists. Into another it arrives there under a fresh
625
- * UUID, naming the content already sealed, a binary its manifest alone
626
- * (`arrivalManifest`), and that arrival is saved with its removal here,
627
- * held (Live drive/held-removals.ts). The maps then list it at `to` and no
628
- * more where it stood. False, recording nothing, when either root's sharing
629
- * policy keeps its address local, or the maps cannot say its whole record;
630
- * the drive then places it and the shelf moves it, as Detect records any
631
- * move. `rootShelf` as for `removeListed`.
632
- */
633
- async moveListed(unit, to, { rootShelf }) {
436
+ async moveListed(unit, to, base, { rootShelf }) {
634
437
  const listed = this.listedChange(unit, [unit, to], rootShelf);
635
438
  if (listed === null)
636
- return false;
637
- const { base, authorityId, ports } = listed;
439
+ return null;
440
+ const { authorityId, ports } = listed;
638
441
  if (to.root === unit.root) {
639
442
  await recordMove({ base, authorityId, mutationId: randomUUID(), parentUUID: to.parentUUID, name: to.name }, ports);
640
- await this.listedAgain(unit);
641
- return true;
443
+ return [unit.uuid];
642
444
  }
643
445
  const holds = this.heldRemovals;
644
446
  if (!holds)
@@ -653,14 +455,10 @@ export class UserGroundHost {
653
455
  manifest: await this.arrivalManifest(base, authorityId),
654
456
  }, ports);
655
457
  if (arrival === null)
656
- return false;
458
+ return null;
657
459
  await holds.hold({ base, authorityId, mutationId: randomUUID() }, { root: unit.root, address: unit.address }, arrival);
658
- await Promise.all([this.listedAgain(unit), this.listedAgain({ root: to.root, uuid: arrival.entityId })]);
659
- return true;
460
+ return [unit.uuid, arrival.entityId];
660
461
  }
661
- /** The manifest a binary's arrival in another root names, with none of its
662
- * blocks: the one its size fixes, this computer's own, or the authority's,
663
- * fetched alone. Null for a text file or link, whose bytes need none. */
664
462
  async arrivalManifest(base, authorityId) {
665
463
  const artifact = base.type === "file.binary" ? artifactForRecord(base) : null;
666
464
  if (artifact === null)
@@ -670,65 +468,41 @@ export class UserGroundHost {
670
468
  ?? (await this.proveContentManifests(authorityId, [artifact]))[0]
671
469
  ?? null;
672
470
  }
673
- /**
674
- * Give one file a root on demand lists that this computer never placed
675
- * the executable posture `fileMode`, with none of its bytes (Live
676
- * drive/records.ts): the change is recorded at the version the map lists,
677
- * and the map lists it with that mode. False, recording nothing, when its
678
- * home's sharing policy keeps it local, or the map cannot say its whole
679
- * record; the drive then places it and the shelf changes its mode, as
680
- * Detect records any change of mode. `rootShelf` as for `removeListed`.
681
- */
682
- async modeListed(unit, fileMode, { rootShelf }) {
471
+ async modeListed(unit, fileMode, base, { rootShelf }) {
683
472
  const listed = this.listedChange(unit, [unit], rootShelf);
684
473
  if (listed === null)
685
- return false;
686
- await recordMode({ base: listed.base, authorityId: listed.authorityId, mutationId: randomUUID(), fileMode }, listed.ports);
687
- await this.listedAgain(unit);
688
- return true;
474
+ return null;
475
+ await recordMode({ base, authorityId: listed.authorityId, mutationId: randomUUID(), fileMode }, listed.ports);
476
+ return [unit.uuid];
689
477
  }
690
- /** A root's map read again for a unit whose change was just recorded, so
691
- * the drive's next judgment finds it where the record leaves it. The record
692
- * is made whatever the read says: a failure is the background's to hear,
693
- * and the next records that arrive read the map again. */
694
- async listedAgain({ root, uuid }) {
695
- await this.driveMaps.get(root)?.refresh([uuid]).catch((error) => this.options.onBackgroundError?.(error));
478
+ async timeListed(unit, mtime, base, { rootShelf }) {
479
+ const listed = this.listedChange(unit, [unit], rootShelf);
480
+ if (listed === null)
481
+ return null;
482
+ await recordTime({ base, authorityId: listed.authorityId, mutationId: randomUUID(), mtime }, listed.ports);
483
+ return [unit.uuid];
696
484
  }
697
- /** Released holds read again in their own roots' maps: each unit is listed
698
- * from the record that now stands for it, its own Trash or, beneath a
699
- * removed folder, the accepted state that folder's Trash takes with it. */
700
485
  listedReleased(held) {
701
- const byRoot = new Map();
702
- for (const { record, place } of held) {
703
- const uuids = byRoot.get(place.root);
704
- if (uuids)
705
- uuids.push(record.entityId);
706
- else
707
- byRoot.set(place.root, [record.entityId]);
708
- }
709
- for (const [root, uuids] of byRoot) {
710
- this.driveMaps.get(root)?.refresh(uuids).catch((error) => this.options.onBackgroundError?.(error));
711
- }
486
+ this.wakeDrive(held.map(({ record }) => record.entityId));
712
487
  }
713
- /** What recording a change of one listed unit needs: the record its map
714
- * lists it at, and the Record rail. Null when the map cannot say that whole
715
- * record, a root of `places` has no map, or the home's sharing policy keeps
716
- * a place local. */
717
488
  listedChange(unit, places, rootShelf) {
718
489
  const authorityId = this.authorityId, store = this.recordStore, rail = this.recordRail;
719
490
  if (!authorityId || !store || !rail)
720
491
  throw new Error("the drive needs the entity Record rail running");
721
- const base = this.driveMaps.get(unit.root)?.listed(unit.uuid) ?? null;
722
- if (!base || !places.every(place => this.driveMaps.has(place.root)))
723
- return null;
724
492
  for (const root of new Set(places.map(place => place.root))) {
725
- const policy = readSharingPolicy(this.userRoot(), this.shelfDirectory(root) ?? rootShelf(root));
726
- const kept = (place) => place.root === root && !policy.includes(place.address.join("/"), CONTAINERS.has(unit.type));
493
+ let policy;
494
+ try {
495
+ policy = readSkipPolicy({ root: this.shelfDirectory(root) ?? rootShelf(root),
496
+ database: groundDatabase(this.databasePath()), rootUUID: root });
497
+ }
498
+ catch {
499
+ return null;
500
+ }
501
+ const kept = (place) => place.root === root && !policy.travels(place.address.join("/"), CONTAINERS.has(unit.type));
727
502
  if (places.some(kept))
728
503
  return null;
729
504
  }
730
505
  return {
731
- base,
732
506
  authorityId,
733
507
  ports: {
734
508
  store: {
@@ -741,130 +515,43 @@ export class UserGroundHost {
741
515
  },
742
516
  };
743
517
  }
744
- /** The runtime said what it runs: a record held on that answer plays now. */
745
518
  productsChanged() {
746
519
  this.applyRail?.capabilityChanged();
747
520
  }
748
- /** Whether Send is paused until the authority rings: refused over the
749
- * person's storage limit. */
750
521
  sendPaused() {
751
522
  return (this.recordRail?.sendPaused ?? null) !== null;
752
523
  }
753
- /** Read-only reasons owned by the running Apply coordinator. */
754
524
  applyWaiting() {
755
525
  return this.applyRail?.waiting() ?? [];
756
526
  }
757
- /** The map of one root this computer serves on demand: its received state
758
- * at the received prefix, each placed entity where it stands, loaded on
759
- * first ask and kept current as records arrive and ground is admitted
760
- * (apply-map.ts). The refresh is awaited so the map answers from the asked
761
- * position; a wake's failure goes to the background-error sink and the
762
- * next wake tries again. Null when this person's accepted graph holds no
763
- * such root: the map loads nothing, so the host keeps no map for it and the
764
- * drive treats the reference that asked as an ordinary entity. */
765
- async driveMap(rootUUID) {
766
- if (!this.authorityId || !this.driveGraphs)
767
- throw new Error("the drive needs the entity Apply rail running");
768
- let map = this.driveMaps.get(rootUUID);
769
- if (!map) {
770
- map = new ApplyMap({
771
- database: groundDatabase(this.databasePath()),
772
- authorityId: this.authorityId,
773
- rootUUID,
774
- graphs: this.driveGraphs,
775
- onChange: (touched) => {
776
- // A listener's fault is the background's to hear: the map advances
777
- // and every other listener hears it.
778
- for (const listener of this.driveListeners) {
779
- try {
780
- listener(touched);
781
- }
782
- catch (error) {
783
- this.options.onBackgroundError?.(error);
784
- }
785
- }
786
- },
787
- });
788
- this.driveMaps.set(rootUUID, map);
789
- }
790
- try {
791
- await map.refresh();
792
- }
793
- catch (error) {
794
- if (map.through === null)
795
- this.driveMaps.delete(rootUUID);
796
- throw error;
797
- }
798
- if (map.size === 0) {
799
- this.driveMaps.delete(rootUUID);
800
- map.drop();
801
- return null;
527
+ onDriveWake(listener) {
528
+ this.driveWakes.add(listener);
529
+ return () => { this.driveWakes.delete(listener); };
530
+ }
531
+ wakeDrive(uuids) {
532
+ for (const listener of this.driveWakes) {
533
+ try {
534
+ listener(uuids);
535
+ }
536
+ catch (error) {
537
+ this.options.onBackgroundError?.(error);
538
+ }
802
539
  }
803
- return map;
804
- }
805
- /** Tells `listener` of each change to what the drive's maps list: the
806
- * entities a map took and the containers they touched, or null when a map
807
- * loaded whole. A door that holds what it listed (the Windows sync root)
808
- * lists those folders again. Returns its unsubscribe. */
809
- onDriveChange(listener) {
810
- this.driveListeners.add(listener);
811
- return () => { this.driveListeners.delete(listener); };
812
- }
813
- /** The top of one root this computer serves on demand, at the received
814
- * prefix, from the root's own record alone (apply-map.ts readDriveTop):
815
- * asked for a root the drive has not entered. Null exactly when `driveMap`
816
- * would be. */
817
- async driveTop(rootUUID) {
818
- if (!this.authorityId || !this.driveTops)
819
- throw new Error("the drive needs the entity Apply rail running");
820
- return readDriveTop({
821
- database: groundDatabase(this.databasePath()),
822
- authorityId: this.authorityId,
823
- rootUUID,
824
- heads: this.driveTops,
825
- });
826
540
  }
827
- /** Records arrived, or these entities' O rows changed: every map reads
828
- * the received prefix again and takes each entity where it stands now. */
829
- wakeDriveMaps(uuids = []) {
830
- void this.refreshDriveMaps(uuids);
831
- }
832
- /** Every map the drive holds read again, as a wake reads it, awaited; a
833
- * read's failure goes to the background-error sink and the next wake
834
- * tries again. */
835
- async refreshDriveMaps(uuids) {
836
- await Promise.all([...this.driveMaps.values()].map((map) => map.refresh(uuids).catch((error) => this.options.onBackgroundError?.(error))));
837
- }
838
- /** What every map lists may have changed at no new position: each loads
839
- * again. */
840
- reloadDriveMaps() {
841
- for (const map of this.driveMaps.values())
842
- map.drop();
843
- this.wakeDriveMaps();
844
- }
845
- closeDriveMaps() {
846
- for (const map of this.driveMaps.values())
847
- map.drop();
848
- this.driveMaps.clear();
849
- this.driveTops?.drop();
850
- this.driveTops = null;
851
- this.driveGraphs = null;
541
+ async graphPage(ref) {
542
+ if (!this.authorityId)
543
+ throw new Error("graph pages need cloud authority");
544
+ return this.readGraphPage(this.authorityId, ref);
852
545
  }
853
546
  wakeObservedApply(observations, observedEntityIds = []) {
854
- // Detect's commits may have noted slots, and its observations end the
855
- // tidy's waits on ground.
856
547
  this.placementTidy?.observed(observations);
857
548
  this.placementTidy?.noted();
858
- this.wakeDriveMaps(observedEntityIds);
549
+ this.wakeDrive(observedEntityIds);
859
550
  if (!this.applyRail || !this.applyHost)
860
551
  return;
861
- // Progress may precede the first parked waiter. Publish committing UUIDs
862
- // unconditionally, including removals with no remaining row to locate.
863
552
  const observed = new Set(observedEntityIds);
864
553
  const capabilities = new Set(observedEntityIds);
865
554
  for (const wait of this.applyRail.waiting()) {
866
- // A resolved local-only removal has no current O/B row left to locate.
867
- // Carry the committing observation's identity through this wake boundary.
868
555
  const affected = [...new Set([
869
556
  ...wait.prerequisite.entityIds.filter(uuid => observed.has(uuid)),
870
557
  ...this.applyHost.observedDependencies(wait.prerequisite.entityIds, observations),
@@ -884,12 +571,6 @@ export class UserGroundHost {
884
571
  this.applyRail.localStateChanged([...observed]);
885
572
  this.applyRail.recordsAvailable();
886
573
  }
887
- /** A Detect dependency is a request, never a hope. It is made in the same
888
- * synchronous step that parks the waiter, which the rail already wakes for
889
- * any examination after its comparison. The named ground is suspected like
890
- * a native ring, so one finite examination follows even when nothing else
891
- * changes; its settlement wakes the waiter, and a no-op examination only
892
- * lets it compare again. It holds no ground its own examination needs. */
893
574
  openDetectLedger() {
894
575
  if (this.detectLedger)
895
576
  return;
@@ -936,15 +617,11 @@ export class UserGroundHost {
936
617
  assertHealthyWatch(watch, workspaceId);
937
618
  return watch;
938
619
  }
939
- /** Add already projects authoritative rows; this proves that the same
940
- * long-lived runtime now owns their healthy ongoing coverage. */
941
620
  addedWorkspaceEvidence(workspaceId) {
942
621
  const watch = this.watchHost.evidence();
943
622
  assertHealthyWatch(watch, workspaceId);
944
623
  return watch;
945
624
  }
946
- /** Host effects for Live-owned Files commands. The shell CLI receives these
947
- * ports but never decides Files behavior itself. */
948
625
  filesCommandPorts() {
949
626
  const identity = this.activeIdentity;
950
627
  if (!identity || !this.converged) {
@@ -952,15 +629,29 @@ export class UserGroundHost {
952
629
  }
953
630
  const userRoot = this.userRoot();
954
631
  const bindingDir = this.bindingDir();
632
+ const ownFolders = this.options.ownFolders;
955
633
  const register = createFilesRegisterPorts({
956
634
  userRoot,
957
635
  bindingDir,
636
+ ownFolders,
958
637
  computerFolder: () => this.computerFolder(identity),
959
638
  reserveWritableRoot: this.options.reserveWritableRoot,
960
639
  findKnownWorkspaceId: ({ absolutePath, physicalKey }) => findKnownEntityId(this.databasePath(), absolutePath, physicalKey),
961
640
  });
962
641
  const add = {
963
642
  sha256Hex,
643
+ inspectDestination: async ({ workspaceId, destinationParent, name }) => {
644
+ const database = this.databasePath();
645
+ const held = readWorkspaceAddIntent(database, workspaceId)?.destinationPath
646
+ ?? readGroundRowsByUUIDs(database, "entities", new Set([workspaceId]))[0]?.absolutePath;
647
+ if (held)
648
+ return { absolutePath: seenName(held), amalgmFolders: [] };
649
+ const parent = folderStanding(resolve(destinationParent));
650
+ if (parent === null)
651
+ throw refusal(`files add refuses ${seenName(resolve(destinationParent))}: it is not a folder`);
652
+ const destination = join(parent, name);
653
+ return { absolutePath: seenName(destination), amalgmFolders: foldersMet(destination, ownFolders) };
654
+ },
964
655
  lookupRegistry: async (workspaceId) => {
965
656
  const started = performance.now();
966
657
  this.stage({
@@ -1025,6 +716,7 @@ export class UserGroundHost {
1025
716
  now: () => this.options.now?.().getTime() ?? Date.now(),
1026
717
  readContent: (artifacts, staged) => this.downloadContentSet(privateEntityResourceId(identity.userId, sha256Hex), this.cacheDir(), artifacts.map((artifact) => ({ artifact })), 10, { journey: "add", workspaceId: input.workspace.uuid }, staged),
1027
718
  durabilityBarrier: this.options.durabilityBarrier ?? platformDurabilityBarrier,
719
+ report: (error) => this.options.onBackgroundError?.(error),
1028
720
  owesBaseline: (rootId) => this.owedBaselines.add(rootId),
1029
721
  onStage: async (stage, measurements) => {
1030
722
  const now = performance.now();
@@ -1044,16 +736,11 @@ export class UserGroundHost {
1044
736
  });
1045
737
  },
1046
738
  });
1047
- // Add changes both disk and the exact SQLite projection. Open the
1048
- // selected root's singular Watch coverage before Detect can observe
1049
- // either side of that transaction; the public cover port below
1050
- // independently proves the same coverage before clearing intent.
1051
739
  this.ensureWatchers(identity);
1052
740
  assertHealthyWatch(this.watchHost.evidence(), input.workspace.uuid);
1053
741
  return installed;
1054
742
  }
1055
743
  finally {
1056
- // A reveal this journey could not cover is no longer a baseline.
1057
744
  this.owedBaselines.delete(input.workspace.uuid);
1058
745
  release();
1059
746
  this.addRecorded();
@@ -1065,9 +752,6 @@ export class UserGroundHost {
1065
752
  primitive: "watch", stage: "add-coverage", status: "started", workspaceId,
1066
753
  });
1067
754
  const pending = hasWorkspaceAddIntent(this.databasePath(), workspaceId);
1068
- // The install that revealed this root consumed its baseline; proving
1069
- // coverage never resupplies one, so a root that left meanwhile owes
1070
- // its catch-up.
1071
755
  const health = this.ensureWatchers(identity);
1072
756
  assertHealthyWatch(this.watchHost.evidence(), workspaceId);
1073
757
  if (pending) {
@@ -1090,12 +774,6 @@ export class UserGroundHost {
1090
774
  };
1091
775
  return { register, add };
1092
776
  }
1093
- /** Resume the same host effect used by the SDK command before readiness.
1094
- * Staged ground has no binding, so recovery cannot race Watch or Detect.
1095
- * Each intent is one workspace's durable responsibility, not the machine's:
1096
- * an intent that cannot be satisfied now is reported and stays durable for
1097
- * the next start, an explicit re-Add or, for a root entered on demand, the
1098
- * next touch, while readiness proceeds. */
1099
777
  async resumeWorkspaceAdds(identity) {
1100
778
  for (const intent of readWorkspaceAddIntents(this.databasePath())) {
1101
779
  try {
@@ -1114,7 +792,6 @@ export class UserGroundHost {
1114
792
  }
1115
793
  }
1116
794
  }
1117
- /** One root's install at a time: an ask while one runs joins it. */
1118
795
  installingRoot(rootUUID, install) {
1119
796
  const running = this.rootInstalls.get(rootUUID);
1120
797
  if (running)
@@ -1126,16 +803,6 @@ export class UserGroundHost {
1126
803
  this.rootInstalls.set(rootUUID, started);
1127
804
  return started;
1128
805
  }
1129
- /**
1130
- * A fetch lane's Enter of a workspace root this computer does not hold
1131
- * (Live lane.ts `root`; apply-window-lane.ts): the root as its own unit,
1132
- * with what it places whatever the unit, at the lane's position P, onto the
1133
- * drive's shelf named by its UUID, where it stays for the life of this
1134
- * computer, marked on demand. It is Add's install: one durable intent whose
1135
- * references are the held one that led there, staged and verified, its rows
1136
- * committed at P, revealed, bound and covered. A touch that finds an intent
1137
- * for the root, this Enter's or an Add's, resumes it instead.
1138
- */
1139
806
  enterReferencedRoot(rootUUID, through) {
1140
807
  return this.installingRoot(rootUUID, async () => {
1141
808
  const identity = this.activeIdentity;
@@ -1146,11 +813,9 @@ export class UserGroundHost {
1146
813
  await this.installPendingRoot(identity, intent);
1147
814
  });
1148
815
  }
1149
- /** The intent of one root's Enter at P, written once nothing stands where
1150
- * it will. */
1151
816
  async beginRootEnter(rootUUID, through) {
1152
817
  const shelf = this.driveShelf;
1153
- const graphs = this.driveGraphs;
818
+ const graphs = this.graphs;
1154
819
  if (!shelf || !graphs || !this.authorityId) {
1155
820
  throw new Error(`${rootUUID} enters only onto the shelf of a drive placing here`);
1156
821
  }
@@ -1178,9 +843,6 @@ export class UserGroundHost {
1178
843
  const root = subtree.find((record) => record.uuid === rootUUID);
1179
844
  if (!root || root.status !== "active")
1180
845
  throw new Error(`${rootUUID} is not active at ${through}`);
1181
- // Only the root has no parent in its own closure, so nothing above it
1182
- // shows: it places its unit (Live placedInRoot), and everything else
1183
- // stays listed.
1184
846
  const closure = await finishStepsInTurns(materializableRecordsSteps(subtree, rootUUID));
1185
847
  const records = unitMembers(closure, root, { place: () => undefined });
1186
848
  assertEnclosesNothingHeld(database, rootUUID, records);
@@ -1201,18 +863,13 @@ export class UserGroundHost {
1201
863
  onDemand: true,
1202
864
  }, (stage) => this.options.onInstallStage?.({ journey: "add", rootId: rootUUID, stage }));
1203
865
  }
1204
- /** One pending intent's install to its end: Files Add's resumed, or a
1205
- * root's Enter. Add's references follow its install; an Enter's reference
1206
- * already stands. */
1207
866
  async installPendingRoot(identity, intent) {
1208
867
  const database = this.databasePath();
1209
868
  const userRoot = this.userRoot();
1210
869
  const bindingDir = this.bindingDir();
1211
- // An Enter writes no reference, so it holds only its own ground.
1212
870
  const release = await this.holdWorkspaceAdd(intent.onDemand
1213
871
  ? [intent.destinationPath, intent.stagingPath]
1214
872
  : [intent.destinationPath, intent.stagingPath, userRoot]);
1215
- // An install that ended while this one waited leaves nothing pending.
1216
873
  if (!hasWorkspaceAddIntent(database, intent.workspaceId)) {
1217
874
  release();
1218
875
  return;
@@ -1221,11 +878,6 @@ export class UserGroundHost {
1221
878
  try {
1222
879
  const stagedAcrossBlindInterval = pathExists(intent.stagingPath);
1223
880
  if (stagedAcrossBlindInterval && hasRootRows(database, intent.resourceId, intent.workspaceId)) {
1224
- // Rows prove that staging was verified before the crash, not that its
1225
- // bytes remained unchanged while no watcher existed. Return this
1226
- // private install to the intent-only stage; the retried install keeps
1227
- // the staged bytes but re-proves every retained chunk against its
1228
- // manifest before anything becomes visible.
1229
881
  await deleteRootRows(database, intent.resourceId, intent.workspaceId);
1230
882
  }
1231
883
  await installWorkspaceIntent({
@@ -1238,6 +890,7 @@ export class UserGroundHost {
1238
890
  now: () => this.options.now?.().getTime() ?? Date.now(),
1239
891
  readContent: (artifacts, staged) => this.downloadContentSet(intent.resourceId, this.cacheDir(), artifacts.map((artifact) => ({ artifact })), 10, { journey: "add", workspaceId: intent.workspaceId }, staged),
1240
892
  durabilityBarrier: this.options.durabilityBarrier ?? platformDurabilityBarrier,
893
+ report: (error) => this.options.onBackgroundError?.(error),
1241
894
  owesBaseline: (rootId) => this.owedBaselines.add(rootId),
1242
895
  onStage: (stage) => this.options.onInstallStage?.({
1243
896
  journey: "add",
@@ -1267,10 +920,6 @@ export class UserGroundHost {
1267
920
  this.addRecorded();
1268
921
  }
1269
922
  if (visibleAcrossBlindInterval) {
1270
- // Ground that was visible while the runtime was absent may have been
1271
- // edited after its verified reveal. It is an ordinary startup blind
1272
- // interval, so Watch must retain complete suspicion and Detect must
1273
- // settle it before the Add responsibility can be cleared.
1274
923
  await this.proveOwed();
1275
924
  }
1276
925
  await this.options.onInstallStage?.({
@@ -1280,13 +929,6 @@ export class UserGroundHost {
1280
929
  });
1281
930
  await deleteWorkspaceAddIntent(database, intent.workspaceId);
1282
931
  }
1283
- /** Register W: the binding and reference already stand (Live's
1284
- * placeWorkspaceReference), so W is inside Amalgm bounds and travels like
1285
- * any other new ground: ordinary Detect packages W's subtree and the
1286
- * reference's new folders, Record admits them, and Send publishes them.
1287
- * Register only waits on that one path: it names W and its reference as
1288
- * suspect, proves that cutoff, flushes Send, and reads the accepted view
1289
- * until it holds W as its own root and core holds W's reference. */
1290
932
  async completeWorkspaceRegistration({ workspaceId, referencePath }) {
1291
933
  const identity = this.activeIdentity;
1292
934
  if (!identity || !this.converged || !this.authorityId) {
@@ -1301,8 +943,6 @@ export class UserGroundHost {
1301
943
  const view = await this.freshAcceptedView(identity, resourceId);
1302
944
  alreadyRegistered = await this.registeredIn(identity, view, workspaceId);
1303
945
  if (alreadyRegistered) {
1304
- // Whatever W or its reference holds beyond the accepted view is
1305
- // ordinary work, syncing through its own Records.
1306
946
  await this.restoreAcceptedCargo(resourceId, view, workspaceId);
1307
947
  cloudHead = view.head.checksum;
1308
948
  }
@@ -1322,8 +962,6 @@ export class UserGroundHost {
1322
962
  }
1323
963
  throw failedDuring("register", "entity registration or cloud publication", error);
1324
964
  }
1325
- // W's accepted root holds every workspace it absorbed, and no proof
1326
- // still runs through their old roots.
1327
965
  retireAbsorbedBindings(file, this.bindingDir());
1328
966
  const { watch } = this.registrationCoverage(identity, workspaceId, "register-final-proof");
1329
967
  return {
@@ -1334,11 +972,6 @@ export class UserGroundHost {
1334
972
  waiting: this.waiting().filter(wait => pathWithin(directory, wait.path)),
1335
973
  };
1336
974
  }
1337
- /** An accepted W publishes nothing, yet its accepted cargo must stand whole
1338
- * at the authority. What the authority lacks ships again from whatever
1339
- * here still holds it exactly: a cache copy, or ground whose row names the
1340
- * accepted payload. The rest was overtaken here or left this machine; the
1341
- * stage names how much, and newer local work syncs as its own Records. */
1342
975
  async restoreAcceptedCargo(resourceId, view, workspaceId) {
1343
976
  const started = performance.now();
1344
977
  this.stage({ primitive: "register", stage: "cargo-closure", status: "started", workspaceId });
@@ -1377,15 +1010,11 @@ export class UserGroundHost {
1377
1010
  measurements: { artifacts: byHash.size, restored: restorable.length, unrestorable: lacking.length - restorable.length },
1378
1011
  });
1379
1012
  }
1380
- /** What waits alone: each repository whose disk holds what cannot reach a
1381
- * receiver, each file too large to send, and each root off its device. */
1382
1013
  waiting() {
1383
1014
  return [...this.waitingGround.values(),
1384
1015
  ...[...this.rootsOffDevice].map(([path, reason]) => ({ path, reason }))]
1385
1016
  .sort((a, b) => a.path.localeCompare(b.path));
1386
1017
  }
1387
- /** Each waiting thing a pass read answers again: it waits, named once, or
1388
- * it travels. */
1389
1018
  answerWaits(answers) {
1390
1019
  for (const [uuid, wait] of answers ?? []) {
1391
1020
  if (wait === null) {
@@ -1400,10 +1029,6 @@ export class UserGroundHost {
1400
1029
  path: wait.path, measurements: { reason: wait.reason } });
1401
1030
  }
1402
1031
  }
1403
- /** Detect, Record and Send through W's ground and its reference: the same
1404
- * scoped proof any other named change takes, then every Record sent. A
1405
- * repository inside W that waits for its files holds only itself; W
1406
- * itself waiting, or off its device, has nothing to register. */
1407
1032
  async publishRegistered(directory, referencePath) {
1408
1033
  this.watchHost.suspect(directory);
1409
1034
  this.watchHost.suspect(referencePath);
@@ -1412,7 +1037,6 @@ export class UserGroundHost {
1412
1037
  if (waits !== undefined)
1413
1038
  throw refusal(`${directory} waits: ${waits.reason}`);
1414
1039
  try {
1415
- // Register gives up on a refusal, never on a failure Send retries.
1416
1040
  await flushPatiently(async () => { await this.recordRail?.flush(); }, {
1417
1041
  wanted: (error) => !this.closing && !(error instanceof GroundDatabaseAway),
1418
1042
  });
@@ -1421,8 +1045,6 @@ export class UserGroundHost {
1421
1045
  throw this.databaseCause(error);
1422
1046
  }
1423
1047
  }
1424
- /** Whether the accepted view holds W as its own active root and core holds
1425
- * W's active reference. */
1426
1048
  async registeredIn(identity, view, workspaceId) {
1427
1049
  if (!await this.acceptedWorkspace(view, workspaceId))
1428
1050
  return false;
@@ -1431,8 +1053,6 @@ export class UserGroundHost {
1431
1053
  return false;
1432
1054
  return (await view.fold.root(coreRootId)).some((record) => record.type === "reference" && record.status === "active" && record.payloadVersion === workspaceId);
1433
1055
  }
1434
- /** Register's Watch evidence: W's ground has one healthy content owner,
1435
- * and the directory Watch covers it at. */
1436
1056
  registrationCoverage(identity, workspaceId, stage) {
1437
1057
  const started = performance.now();
1438
1058
  this.stage({ primitive: "watch", stage, status: "started", workspaceId });
@@ -1457,8 +1077,6 @@ export class UserGroundHost {
1457
1077
  throw failedDuring("register", "Watch coverage", error);
1458
1078
  }
1459
1079
  }
1460
- /** The accepted core root, which must be the core ground this machine
1461
- * holds. */
1462
1080
  async acceptedCoreRoot(identity, view) {
1463
1081
  const accepted = await this.coreRootId(identity, view.head.graph);
1464
1082
  const local = this.localCoreRoots();
@@ -1467,8 +1085,6 @@ export class UserGroundHost {
1467
1085
  }
1468
1086
  return accepted;
1469
1087
  }
1470
- /** Whether AV holds W as its own active root. Anything else AV holds of W
1471
- * refuses: once another root holds W, that root's graph owns its identity. */
1472
1088
  async acceptedWorkspace(view, workspaceId) {
1473
1089
  const held = await view.fold.locate(workspaceId);
1474
1090
  if (held === null)
@@ -1481,29 +1097,17 @@ export class UserGroundHost {
1481
1097
  }
1482
1098
  return true;
1483
1099
  }
1484
- /** One maintenance visit of a Watch root that begins after now, settled
1485
- * once the ordinary lanes discharged what it found: a metadata comparison,
1486
- * never a content reread. */
1487
1100
  requestVisit(rootId) {
1488
1101
  return this.maintenance.requestVisit(rootId);
1489
1102
  }
1490
- /** Each Watch root's maintenance visit receipts now. */
1491
1103
  maintenanceReceipts() {
1492
1104
  return this.maintenance.receipts();
1493
1105
  }
1494
- /** Prove one finite observation boundary in SQLite, immutable content
1495
- * storage, and the official cloud head. Rings received during that proof
1496
- * remain pending and already own their next debounced Detect pass. Roots
1497
- * refused at that boundary are named: their local rows are current, and
1498
- * their last complete result remains the official one. */
1499
1106
  async flush() {
1500
1107
  if (!this.converged || !this.activeIdentity || !this.authorityId)
1501
1108
  throw new GroundNotConverged();
1502
1109
  const identity = this.activeIdentity;
1503
1110
  this.watchHost.suspectAll();
1504
- // The complete suspicion above contains everything known at this cutoff.
1505
- // A later native callback is a later generation; flush never waits for
1506
- // global Watch silence.
1507
1111
  const cutoff = this.watchHost.freeze();
1508
1112
  try {
1509
1113
  await this.proveTicket(cutoff);
@@ -1511,7 +1115,6 @@ export class UserGroundHost {
1511
1115
  finally {
1512
1116
  this.watchHost.release(cutoff);
1513
1117
  }
1514
- // A lane's cause is already judged; the rails read the same database.
1515
1118
  try {
1516
1119
  await this.heldRemovals?.release();
1517
1120
  await this.recordRail?.flush();
@@ -1524,9 +1127,6 @@ export class UserGroundHost {
1524
1127
  this.ensureWatchers(identity);
1525
1128
  return { waiting: this.waiting() };
1526
1129
  }
1527
- /** A database that stands aside with its home is that home's ground away:
1528
- * unavailable, retried on its timer and heard returning by Watch. One whose
1529
- * home stands is a fault, as is a refusal that races the home's return. */
1530
1130
  databaseCause(error) {
1531
1131
  if (!(error instanceof GroundDatabaseAway) || this.databaseStanding())
1532
1132
  return error;
@@ -1535,14 +1135,9 @@ export class UserGroundHost {
1535
1135
  return new DetectUnavailable([{ directory: home,
1536
1136
  reason: `${home}, which holds this runtime's database, is not where it was opened; its ground stays unexamined until it returns` }]);
1537
1137
  }
1538
- /** Every directory from the home down to this database's folder is the
1539
- * object that stood there when the database opened. */
1540
1138
  databaseStanding() {
1541
1139
  return this.databaseGround.every(({ path, key }) => standingKey(path) === key);
1542
1140
  }
1543
- /** Tells the activity hook Watch's unsettled count when what it would hear
1544
- * changed. While the home holding this database is away, what that home
1545
- * owes cannot be told, so it hears null. */
1546
1141
  sayUnsettled() {
1547
1142
  if (!this.options.activity || this.watchUnsettled === undefined)
1548
1143
  return;
@@ -1552,9 +1147,6 @@ export class UserGroundHost {
1552
1147
  this.saidUnsettled = count;
1553
1148
  this.options.activity.unsettled(count);
1554
1149
  }
1555
- /** Prove everything owed now, through its current cutoff. Ground still
1556
- * moving when no retry remains names every root the cutoff left unsettled
1557
- * that no unreadable ground explains. */
1558
1150
  async proveOwed() {
1559
1151
  const cutoff = this.watchHost.freeze();
1560
1152
  try {
@@ -1571,11 +1163,6 @@ export class UserGroundHost {
1571
1163
  this.watchHost.release(cutoff);
1572
1164
  }
1573
1165
  }
1574
- /** Run lanes until everything this ticket scoped at its cutoff is settled.
1575
- * An attempt that covered the ticket and failed fails the caller honestly;
1576
- * attempts on other ground, or frozen before the ticket, never do. A wait
1577
- * (moving or unreadable ground) is never a failure: the ticket
1578
- * answers every wait its lanes parked on together, once none still runs. */
1579
1166
  async proveTicket(ticket) {
1580
1167
  const roots = new Set(ticket.map(({ rootId }) => rootId));
1581
1168
  const waiter = { ticket, failure: null, wake: () => { } };
@@ -1594,11 +1181,6 @@ export class UserGroundHost {
1594
1181
  const woken = new Promise(resolve => { waiter.wake = resolve; });
1595
1182
  this.dispatchDetect(ticket);
1596
1183
  const serving = !!this.completeAttempt || [...this.namedAttempts.keys()].some(lane => roots.has(laneRoot(lane)));
1597
- // A parked lane is this ticket's only while it can settle one of the
1598
- // ticket's open cuts: a root's complete park a cut owing that root's
1599
- // complete proof (a domain cut waits on every root's), a root's named
1600
- // lane a cut still named there. Its park answers by class, never by
1601
- // which lane parked first.
1602
1184
  const open = ticket.filter(cut => !this.watchHost.settled([cut]));
1603
1185
  const complete = new Set(this.watchHost.pending().flatMap(({ rootId, pending }) => pending.complete ? [rootId] : []));
1604
1186
  const ours = (lane) => lane.startsWith("complete:")
@@ -1608,19 +1190,13 @@ export class UserGroundHost {
1608
1190
  const parks = [...this.parkedDetect].flatMap(([lane, park]) => ours(lane) ? [park] : []);
1609
1191
  const failure = parks.find(({ error }) => !waits(error));
1610
1192
  const moving = [...new Set(parks.flatMap(({ error }) => error instanceof DetectResidual ? error.roots : []))].sort();
1611
- // A root this ticket named that is no longer bound cannot be proved
1612
- // until it returns: it is unavailable, never settled.
1613
1193
  const away = this.watchHost.unbound(open).map(({ directory, absent }) => ({ directory,
1614
1194
  reason: absent ? `${directory} is absent; its ground stays unexamined until it returns`
1615
1195
  : `${directory} is no longer bound` }));
1616
1196
  const unavailable = unavailableRoots([...parks.flatMap(({ error }) => unavailableOf(error)), ...away]);
1617
1197
  const idle = !serving && this.namedAttempts.size === 0 && this.groundWaits.size === 0;
1618
- // A fault answers once nothing can run it again; no retry timer hides it.
1619
1198
  if (idle && failure)
1620
1199
  throw failure.error;
1621
- // Only moving or unreadable ground is left: this ticket waits while
1622
- // a retry of its moving lanes stands, and no longer. Unreadable
1623
- // ground waits for access, never for this ticket.
1624
1200
  if (idle && !parks.some(({ error, timer }) => error instanceof DetectResidual && timer)) {
1625
1201
  throw moving.length ? new DetectResidual(moving, unavailable)
1626
1202
  : unavailable.length ? new DetectUnavailable(unavailable)
@@ -1633,26 +1209,18 @@ export class UserGroundHost {
1633
1209
  this.detectWaiters.delete(waiter);
1634
1210
  }
1635
1211
  }
1636
- /** Every attempt and background ground read already running, drained.
1637
- * Outcomes stay with their lanes. */
1638
1212
  async detectDrained() {
1639
1213
  while (this.completeAttempt || this.namedAttempts.size > 0 || this.backgroundReads.size > 0) {
1640
1214
  await Promise.allSettled([...this.namedAttempts.values(), ...(this.completeAttempt ? [this.completeAttempt] : []),
1641
1215
  ...this.backgroundReads]);
1642
1216
  }
1643
1217
  }
1644
- /** One background ground read, held for close until it settles. */
1645
1218
  backgroundRead(read) {
1646
1219
  this.backgroundReads.add(read);
1647
1220
  const drop = () => { this.backgroundReads.delete(read); };
1648
1221
  read.then(drop, drop);
1649
1222
  return read;
1650
1223
  }
1651
- /** Start every lane with owed work and a free slot. Synchronous and
1652
- * idempotent, so every ring, release, retry and finished attempt may call
1653
- * it. A caller proving a ticket passes it: a lane parked on a failure that
1654
- * serves the ticket runs now, because a finite proof observes its own
1655
- * attempt. An owner wait never reruns; unchanged work cannot end it. */
1656
1224
  dispatchDetect(ticket = []) {
1657
1225
  const identity = this.activeIdentity;
1658
1226
  if (!identity || !this.detectLedger || !this.namedDetect || !this.watchHost.continuous())
@@ -1665,22 +1233,15 @@ export class UserGroundHost {
1665
1233
  if (pending.some(({ pending: owed }) => owed.complete))
1666
1234
  this.repairRegistrationGround(identity);
1667
1235
  const boundary = this.watchHost.boundary();
1668
- // The one complete slot never waits on held ground: a held root
1669
- // waits off-slot, as a named lane does, so a long Register or Add
1670
- // never delays another root's proof. Its release dispatches again.
1671
- // A park answers only the root it names, so one root's owner wait
1672
- // or retry never holds another root's proof. A root another lane
1673
- // is examining waits for that lane's end, its ground reserved.
1674
1236
  let effectHeld = false;
1675
1237
  const waiting = [];
1676
1238
  const { cuts, withheld } = this.watchHost.selectComplete((directory, paths) => {
1677
1239
  const footprint = this.cutFootprint(directory, paths);
1678
1240
  if (this.ground.holds(footprint))
1679
1241
  return effectHeld = true;
1680
- const examined = Examinations.examined(directory, footprint);
1681
- if (!this.examinations.busy(examined))
1242
+ if (!this.examinations.busy(footprint))
1682
1243
  return false;
1683
- waiting.push(...examined);
1244
+ waiting.push(...footprint);
1684
1245
  return true;
1685
1246
  }, rootId => this.blocked(`complete:${rootId}`, pending, proving(rootId, false)));
1686
1247
  this.examinations.reserve(waiting);
@@ -1696,24 +1257,17 @@ export class UserGroundHost {
1696
1257
  }
1697
1258
  }
1698
1259
  }
1699
- // Slots rotate across roots, so an early root that keeps ringing cannot
1700
- // hold every slot while a later root waits.
1701
1260
  const first = pending.length ? this.namedRotation++ % pending.length : 0;
1702
1261
  const open = (lane) => !this.namedAttempts.has(lane);
1703
1262
  for (const { rootId, directory, pending: owed } of [...pending.slice(first), ...pending.slice(0, first)]) {
1704
1263
  if (this.namedAttempts.size >= NAMED_DETECT_LANES)
1705
1264
  return;
1706
- // Rings keep dispatching while a root's lanes run: routing waits for
1707
- // a lane that could start.
1708
1265
  const lanes = [["named", `named:${rootId}`], ["repository", `repository:${rootId}`]];
1709
1266
  if (!lanes.some(([, lane]) => open(lane)))
1710
1267
  continue;
1711
- // Maintenance findings are named rings the sweep, not Watch, heard.
1712
1268
  const paths = [...new Set([...owed.paths, ...this.maintenance.owed(rootId)])];
1713
1269
  if (paths.length === 0)
1714
1270
  continue;
1715
- // Leaves and repositories are separate lanes, so a repository's
1716
- // examination never holds a root's ordinary edits behind it.
1717
1271
  const routed = performance.now();
1718
1272
  const routes = this.namedDetect.namedRoutes(directory, paths);
1719
1273
  const routeMs = performance.now() - routed;
@@ -1725,13 +1279,8 @@ export class UserGroundHost {
1725
1279
  continue;
1726
1280
  if (this.blocked(lane, pending, proving(rootId, true)))
1727
1281
  continue;
1728
- // PREPARE: the footprint this lane's proof will read, from the index
1729
- // as it stands. It freezes nothing; the lane activates at a boundary.
1730
- // A name under held ground stays owed while the root's other names
1731
- // proceed, so unrelated ground never waits on that hold.
1732
- // A name on ground another lane examines waits for that lane's end.
1733
1282
  const started = performance.now();
1734
- const examined = (cones) => this.examinations.busy(Examinations.examined(directory, cones));
1283
+ const examined = (cones) => this.examinations.busy(cones);
1735
1284
  const unexamined = examined(routes.footprint(paths))
1736
1285
  ? paths.filter(path => !examined(routes.footprint([path]))) : paths;
1737
1286
  const free = this.ground.holds(routes.footprint(unexamined))
@@ -1745,7 +1294,6 @@ export class UserGroundHost {
1745
1294
  }
1746
1295
  }
1747
1296
  nextTurn(ring) {
1748
- // A ring that faults is reported, never thrown into the loop.
1749
1297
  const run = () => {
1750
1298
  try {
1751
1299
  ring();
@@ -1767,12 +1315,9 @@ export class UserGroundHost {
1767
1315
  for (const ring of rings)
1768
1316
  ring();
1769
1317
  }
1770
- /** What every lane is doing as one starts, so starvation is visible. */
1771
1318
  laneState() {
1772
1319
  return { namedActive: this.namedAttempts.size, groundWaits: this.groundWaits.size, parked: this.parkedDetect.size };
1773
1320
  }
1774
- /** The ground a complete-lane cut reads: its complete root, or what any
1775
- * proof of the names it escalated reads (runtime.ts footprint). */
1776
1321
  cutFootprint(directory, paths) {
1777
1322
  if (paths === null)
1778
1323
  return [directory];
@@ -1780,17 +1325,12 @@ export class UserGroundHost {
1780
1325
  throw new Error("escalated cuts need the named Detect runtime");
1781
1326
  return this.namedDetect.footprint(directory, paths);
1782
1327
  }
1783
- /** A lane found ground held. Its wait lasts until a release's look finds
1784
- * that ground free, so examiners hear one wait, not every look. */
1785
1328
  awaitGround(lane) {
1786
1329
  if (this.groundWaits.has(lane))
1787
1330
  this.groundLook?.delete(lane);
1788
1331
  else
1789
1332
  this.groundWaits.set(lane, beginGroundWait(lane));
1790
1333
  }
1791
- /** An effect released ground. A release rings Detect as a write rings
1792
- * Watch: once per turn, every waiting lane looks again at which ground is
1793
- * free, and a wait the look no longer finds held ends. */
1794
1334
  groundReleased() {
1795
1335
  if (this.groundWaits.size === 0 || this.groundLookQueued)
1796
1336
  return;
@@ -1812,16 +1352,11 @@ export class UserGroundHost {
1812
1352
  waiter.wake();
1813
1353
  });
1814
1354
  }
1815
- /** A lane slot or ground wait ended: lanes restart, then every ticket
1816
- * re-examines. Waking a ticket before its slot is free would find the lane
1817
- * still serving and sleep through the release. */
1818
1355
  laneFreed() {
1819
1356
  this.wakeDetect();
1820
1357
  for (const waiter of this.detectWaiters)
1821
1358
  waiter.wake();
1822
1359
  }
1823
- /** Timers, releases and finished attempts wake lanes; cold journeys and
1824
- * shutdown own their own proofs. */
1825
1360
  wakeDetect() {
1826
1361
  if (!this.closing)
1827
1362
  this.dispatchDetect();
@@ -1834,13 +1369,8 @@ export class UserGroundHost {
1834
1369
  this.unpark(lane);
1835
1370
  return false;
1836
1371
  }
1837
- // Neither moving nor unreadable ground ends by rerunning unchanged
1838
- // work: a new ring or the timer does.
1839
1372
  return !proving || waits(park.error);
1840
1373
  }
1841
- /** What a lane's failure is to the tickets it covered. A basis that
1842
- * advanced while Detect read is truth still arriving, never a fault: its
1843
- * cuts stay pending as moving ground, re-read on the lane's retry. */
1844
1374
  laneCause(caught, cuts) {
1845
1375
  const error = this.databaseCause(caught);
1846
1376
  if (detectionBasisAdvanced(error)) {
@@ -1850,13 +1380,6 @@ export class UserGroundHost {
1850
1380
  }
1851
1381
  park(lane, generations, error) {
1852
1382
  this.unpark(lane);
1853
- // Shutdown's one final pass reads again only a racy listing, whose wait
1854
- // is bounded; other moving ground belongs to the next startup.
1855
- // A refusal is what unchanged ground answers: a ring on it, or a ticket's
1856
- // own proof, asks again; a timer would only repeat the whole read.
1857
- // A fault reruns the same work, so each consecutive one doubles its
1858
- // lane's wait: an unchanged fault costs a pass per interval, never a
1859
- // pass per quarter second. A ring still reruns it at once.
1860
1383
  const retries = !isRefusal(error) && (!this.closing || (error instanceof DetectResidual && error.racy));
1861
1384
  const faults = retries && !(error instanceof DetectUnavailable) && !(error instanceof DetectResidual)
1862
1385
  ? (this.laneFaults.get(lane) ?? 0) + 1 : 0;
@@ -1880,8 +1403,6 @@ export class UserGroundHost {
1880
1403
  for (const lane of [...this.parkedDetect.keys()])
1881
1404
  this.unpark(lane);
1882
1405
  }
1883
- /** A failed attempt answers every ticket its cuts covered; its slot's
1884
- * release wakes them. */
1885
1406
  detectEnded(cuts, failure) {
1886
1407
  if (!failure)
1887
1408
  return;
@@ -1890,9 +1411,6 @@ export class UserGroundHost {
1890
1411
  waiter.failure = failure;
1891
1412
  }
1892
1413
  }
1893
- /** Before convergence reads any replication state, the ground holds only
1894
- * its current authority's (authority-binding.ts). The held connection's
1895
- * first open starts the saver that runs the binding. */
1896
1414
  async bindGroundAuthority(identity) {
1897
1415
  const file = this.databasePath();
1898
1416
  groundDatabase(file);
@@ -1903,14 +1421,10 @@ export class UserGroundHost {
1903
1421
  this.stage({ primitive: "detect", stage: "authority-binding", status: "completed",
1904
1422
  durationMs: performance.now() - started, measurements: { ...retired } });
1905
1423
  }
1906
- /** An Add committed what it verified as Apply history and released its
1907
- * ground: every line reads its head again, and a root it revealed releases
1908
- * a line held on its capability. */
1909
1424
  addRecorded() {
1910
1425
  this.applyRail?.capabilityChanged();
1911
1426
  this.applyRail?.localStateChanged();
1912
- // An Add admits a whole root's rows at once: every map loads again.
1913
- this.reloadDriveMaps();
1427
+ this.wakeDrive(null);
1914
1428
  }
1915
1429
  async startRecordRail(identity) {
1916
1430
  if (!this.authorityId)
@@ -1918,7 +1432,6 @@ export class UserGroundHost {
1918
1432
  if (this.recordRail || this.recordStore)
1919
1433
  throw new Error("entity Record rail already started");
1920
1434
  const recordDatabase = openGroundConnection(this.databasePath());
1921
- // A received package's pages come by identity like any graph page.
1922
1435
  const store = new EntityRecordSqliteStore(recordDatabase, this.cacheDir(), Date.now, (authorityId, ref) => this.readGraphPage(authorityId, ref));
1923
1436
  const ledger = new ConstructLedger(recordDatabase, () => this.options.now?.().getTime() ?? Date.now());
1924
1437
  this.stage({ primitive: "detect", stage: "ground-saver", status: "observed",
@@ -1953,7 +1466,6 @@ export class UserGroundHost {
1953
1466
  store,
1954
1467
  authority: wireAuthority,
1955
1468
  cargo: {
1956
- // Send reads cargo its committed rows own, so it fences nothing.
1957
1469
  ensure: async (record) => lostHere(record, async () => {
1958
1470
  if (record.change.replay.kind === "package") {
1959
1471
  await this.uploadPackage(recordDatabase, record);
@@ -1983,11 +1495,6 @@ export class UserGroundHost {
1983
1495
  const rail = new EntityRecordRail({
1984
1496
  authorityId: this.authorityId,
1985
1497
  store: ports.store,
1986
- // Send and Receive resume from each network answer in a dispatcher
1987
- // turn, taking turns with Detect and Apply instead of stacking on them.
1988
- // Send makes the store durable through every row it offers
1989
- // (durableThrough, ground-saver.ts) before the offer leaves, so the
1990
- // drive holds whatever the authority may accept.
1991
1498
  authority: {
1992
1499
  submit: resumeInTurn((batch) => ports.authority.submit(batch)),
1993
1500
  subscribe: resumeInTurn((input) => ports.authority.subscribe(input)),
@@ -2001,12 +1508,10 @@ export class UserGroundHost {
2001
1508
  schedule,
2002
1509
  onInboxCommitted: () => {
2003
1510
  this.applyRail?.recordsAvailable();
2004
- this.wakeDriveMaps();
1511
+ this.wakeDrive([]);
2005
1512
  },
2006
1513
  onOutboxAccepted: (entityIds) => this.applyRail?.sendAccepted(entityIds),
2007
1514
  ...(this.options.activity ? { onUnsent: this.options.activity.unsent } : {}),
2008
- // A failed Send or Receive attempt keeps its Outbox row or cursor and
2009
- // retries; it is reported so a persistently failing rail is visible.
2010
1515
  onBackgroundError: (error) => this.options.onBackgroundError?.(error),
2011
1516
  });
2012
1517
  this.recordStore = store;
@@ -2023,8 +1528,6 @@ export class UserGroundHost {
2023
1528
  this.heldRemovals = holds;
2024
1529
  this.entityAccess = access;
2025
1530
  this.constructLedger = ledger;
2026
- // The product's one way onto the rails. Live seals the payload beside the
2027
- // outbox row and rings the rail; the ledger remembers what was recorded.
2028
1531
  this.constructDoor = createConstructDoor({
2029
1532
  ledger,
2030
1533
  store,
@@ -2036,12 +1539,12 @@ export class UserGroundHost {
2036
1539
  }
2037
1540
  catch (error) {
2038
1541
  if (this.closing)
2039
- throw error; // shutdown owns the in-flight rail and store
1542
+ throw error;
2040
1543
  const stopping = rail.stop();
2041
1544
  if (this.ownedWire)
2042
1545
  await this.ownedWire.close();
2043
1546
  await stopping;
2044
- await this.stopCacheMaintenance?.(); // it reads through the store's connection
1547
+ await this.stopCacheMaintenance?.();
2045
1548
  store.close();
2046
1549
  this.recordRail = null;
2047
1550
  this.recordStore = null;
@@ -2051,13 +1554,7 @@ export class UserGroundHost {
2051
1554
  this.constructDoor = null;
2052
1555
  throw failedDuring("pipeline", "entity record subscribe", error);
2053
1556
  }
2054
- // Holds a crash left are released before the drive serves, so a name
2055
- // they stand at is heard freed before anything takes it. A failed
2056
- // release is reported; the holds, still known, release on the backoff.
2057
1557
  await holds.release().catch((error) => this.options.onBackgroundError?.(error));
2058
- // The construct channels this user may read join the rail when the
2059
- // grant watch first answers, in the background, so starting asks the
2060
- // authority nothing.
2061
1558
  this.releaseGrantWatch = followGrantedChannels({
2062
1559
  access,
2063
1560
  rail,
@@ -2071,20 +1568,10 @@ export class UserGroundHost {
2071
1568
  throw new Error("entity Apply rail requires cloud authority");
2072
1569
  if (this.applyRail || this.applyHost)
2073
1570
  throw new Error("entity Apply rail already started");
2074
- // Baseline adoption reads and writes every materialized entity represented
2075
- // by the verified notebook. Hold every watched ground cone for that short
2076
- // transaction: an older Detect admission commits before this ticket, and a
2077
- // later one queues behind it and re-checks its collection's basis. Merely
2078
- // awaiting running Detect attempts leaves a gap in which the next
2079
- // generation can become SQLite's writer before adoption begins.
2080
1571
  const startupCones = [...new Set(this.watchHost.pending().map(({ directory }) => directory))];
2081
1572
  const releaseStartupGround = await this.acquireGroundScope(startupCones.length > 0 ? startupCones : [this.userRoot()]);
2082
- // A container Enter reads the authority's state at its own position
2083
- // through the pages Add and login read; a drive map holds the same
2084
- // proven graphs.
2085
1573
  const graphs = new ProvenGraphs(resumeInTurn((ref) => untilAborted(this.applyWaits.signal, () => this.readGraphPage(authorityId, ref))));
2086
- this.driveGraphs = graphs;
2087
- this.driveTops = new HeldHeads(graphs);
1574
+ this.graphs = graphs;
2088
1575
  let host = null;
2089
1576
  try {
2090
1577
  host = new ApplyWindowHost({
@@ -2097,20 +1584,13 @@ export class UserGroundHost {
2097
1584
  ? { constructProduct: this.options.constructProduct }
2098
1585
  : {}),
2099
1586
  ...(this.options.secretFollower ? { secretFollower: this.options.secretFollower } : {}),
2100
- // A root placed on demand lists what would enter until something
2101
- // opens it; the mark is the one its placement wrote, login's or a
2102
- // fetch lane's Enter (on-demand-roots.ts). The home is the core root
2103
- // standing at the user root.
2104
1587
  onDemand: {
2105
1588
  root: (rootUUID) => isOnDemandRoot(groundDatabase(this.databasePath()), rootUUID),
2106
1589
  home: (rootUUID) => coreRootsAt(groundDatabase(this.databasePath()), this.userRoot()).includes(rootUUID),
2107
1590
  },
2108
1591
  enterRoot: (rootUUID, through) => this.enterReferencedRoot(rootUUID, through),
2109
- // Apply resumes from a download in its own dispatcher turn, and stops
2110
- // waiting for one when shutdown ends Apply.
2111
1592
  readContent: resumeInTurn((wants, onBytes, lane, staged) => untilAborted(this.applyWaits.signal, async () => {
2112
1593
  const download = (resource, set) => this.downloadContentSet(resource, this.cacheDir(), set, DOWNLOAD_CONTENT_RETRY_ATTEMPTS, { journey: "apply" }, staged, onBytes, lane ? this.laneBytes : undefined);
2113
- // A construct's cargo lives under its own UUID, never the home's.
2114
1594
  const owned = wants.filter(want => want.artifact.kind === "construct");
2115
1595
  if (owned.length === 0)
2116
1596
  return download(authorityId, wants);
@@ -2125,26 +1605,16 @@ export class UserGroundHost {
2125
1605
  progressed: (unit, bytes) => this.applyRail?.progressed(unit, bytes),
2126
1606
  graphs,
2127
1607
  captureLocal: async (intent, plan, compared) => {
2128
- // Apply never suppresses Watch. This explicit named suspicion is the
2129
- // synchronous proof boundary used when Apply's guard found ground
2130
- // Detect has not recorded; Apply holds no ground while it waits here,
2131
- // because Detect waits on held ground. It rings
2132
- // exactly the addresses Apply compared, so the proof costs one named
2133
- // Detect lane, not a walk of every root. Whether durable Outbox work
2134
- // followed is the rail's proof, made once, after this pass settles.
2135
1608
  let addresses = [];
2136
1609
  try {
2137
1610
  addresses = host.applyAddresses(intent, plan);
2138
1611
  }
2139
1612
  catch {
2140
- // Without an address the whole plan is suspect below.
2141
1613
  }
2142
1614
  if (addresses.length === 0)
2143
1615
  this.watchHost.suspectAll();
2144
1616
  for (const address of addresses)
2145
1617
  this.watchHost.suspect(address);
2146
- // The ticket names only these addresses: root recovery elsewhere, or
2147
- // a later complete ring, never widens what this capture waits for.
2148
1618
  const cutoff = this.watchHost.freezeAddresses(addresses);
2149
1619
  try {
2150
1620
  await this.proveTicket(cutoff);
@@ -2163,10 +1633,10 @@ export class UserGroundHost {
2163
1633
  this.watchHost.suspect(path);
2164
1634
  this.applyRail?.localStateChanged(uuids);
2165
1635
  this.placementTidy?.released();
2166
- this.wakeDriveMaps(uuids);
1636
+ this.wakeDrive(uuids);
2167
1637
  if (this.watchHost.hasPending)
2168
1638
  this.ringDetect();
2169
- this.policyReceived(uuids).catch(error => this.options.onBackgroundError?.(error instanceof Error ? error : new Error(String(error))));
1639
+ this.policyReceived(uuids, cones).catch(error => this.options.onBackgroundError?.(error instanceof Error ? error : new Error(String(error))));
2170
1640
  },
2171
1641
  onBackgroundError: (error) => {
2172
1642
  this.options.onBackgroundError?.(error);
@@ -2187,8 +1657,6 @@ export class UserGroundHost {
2187
1657
  onDerivedRelocationStage: this.options.onDerivedRelocationStage,
2188
1658
  now: () => this.options.now?.().getTime() ?? Date.now(),
2189
1659
  });
2190
- // Recovery on every start, before Detect looks: an ended window whose
2191
- // bytes a power cut tore owes its members again (apply-window-recovery.ts).
2192
1660
  await host.recoverStart();
2193
1661
  }
2194
1662
  catch (error) {
@@ -2201,11 +1669,8 @@ export class UserGroundHost {
2201
1669
  if (!host) {
2202
1670
  throw new Error("entity Apply host did not initialize");
2203
1671
  }
2204
- // Named at once, so a failure from here on ends exactly what started.
2205
1672
  this.applyHost = host;
2206
1673
  try {
2207
- // Notes an earlier lifetime left are paid before Apply resumes. A wait on
2208
- // Detect or on another Apply never holds startup: it parks.
2209
1674
  const tidy = new PlacementTidy({
2210
1675
  databaseFile: this.databasePath(),
2211
1676
  acquireGround: (cones, signal) => this.acquireGroundScope(cones, { lane: "placement", signal }),
@@ -2250,8 +1715,6 @@ export class UserGroundHost {
2250
1715
  sha256Hex,
2251
1716
  loops: host.loops,
2252
1717
  now: Date.now,
2253
- // The durability point: every byte the windows since the last point
2254
- // revealed persists, then one strict save (apply-durability.ts).
2255
1718
  onIdle: () => { void host.durabilityPoint(); },
2256
1719
  onWaiting: (wait) => {
2257
1720
  this.stage({
@@ -2264,9 +1727,6 @@ export class UserGroundHost {
2264
1727
  if (wait.prerequisite.producer === "detect")
2265
1728
  this.requestExamination(wait.entityId, wait.prerequisite.entityIds);
2266
1729
  },
2267
- // A failed head holds its authority's Apply line, which retries it with
2268
- // backoff. Surface it as evidence so a persistently failing entity is
2269
- // visible rather than silent.
2270
1730
  onBackgroundError: (error) => {
2271
1731
  this.options.onBackgroundError?.(error);
2272
1732
  this.stage({
@@ -2276,17 +1736,7 @@ export class UserGroundHost {
2276
1736
  measurements: { error: error instanceof Error ? error.message : String(error) },
2277
1737
  });
2278
1738
  },
2279
- // The host now coordinates by address cone, so Apply's final guard waits
2280
- // only for effects on its own addresses. The rail still runs one
2281
- // entity's effects at a time (its bookkeeping settles a page at once):
2282
- // parallel private preparation multiplies content fetches per connection
2283
- // and has not been certified against the gateway's content lane. Raise
2284
- // deliberately, with that proof.
2285
1739
  concurrency: 1,
2286
- // First opens in different places place side by side. Lanes that meet
2287
- // in one cone wait for each other at the final guard, and the content
2288
- // they fly shares one byte bound (src/apply-window-cargo.ts), so more
2289
- // lanes cost no more memory.
2290
1740
  laneConcurrency: APPLY_FETCH_LANES,
2291
1741
  });
2292
1742
  this.applyRail = rail;
@@ -2300,16 +1750,13 @@ export class UserGroundHost {
2300
1750
  throw failedDuring("pipeline", "entity Apply resume", error);
2301
1751
  }
2302
1752
  }
2303
- /** Ends this lifetime's Apply once its rail has stopped: the placement
2304
- * tidy stops and closes its connection, then the Apply store closes, and
2305
- * nothing names either again. */
2306
1753
  async endApply() {
2307
1754
  const tidy = this.placementTidy;
2308
1755
  const host = this.applyHost;
2309
1756
  this.applyRail = null;
2310
1757
  this.applyHost = null;
2311
1758
  this.placementTidy = null;
2312
- this.closeDriveMaps();
1759
+ this.graphs = null;
2313
1760
  try {
2314
1761
  await tidy?.stop();
2315
1762
  }
@@ -2322,8 +1769,6 @@ export class UserGroundHost {
2322
1769
  this.wire.close();
2323
1770
  return this.closeTask ??= this.shutdown(options);
2324
1771
  }
2325
- /** Every step runs in order even after an earlier one failed; the failures
2326
- * reject together only once every resource is closed. */
2327
1772
  async shutdown(options) {
2328
1773
  const failures = [];
2329
1774
  const teardown = {
@@ -2343,17 +1788,12 @@ export class UserGroundHost {
2343
1788
  const reached = options.catchUp === false
2344
1789
  ? await this.cancelLifetime(teardown)
2345
1790
  : await this.catchUpThroughCutoff(teardown, network);
2346
- // Every catch-up claim is earned by every catch-up step. A failed step
2347
- // leaves the cutoff unproved, so the rejection claims no catch-up at all.
2348
1791
  const catchUp = failures.length > failedBefore ? null : reached;
2349
1792
  this.namedDetect?.close();
2350
1793
  this.namedDetect = null;
2351
1794
  this.detectLedger = null;
2352
- // Held removals join the Outbox first, so Send offers them too.
2353
1795
  await attempt(() => this.heldRemovals?.close());
2354
1796
  this.heldRemovals = null;
2355
- // Send spends what the budget has left, then closing the wire cancels
2356
- // what is still in flight. The store stays open until the rail settles.
2357
1797
  const recordRail = this.recordRail;
2358
1798
  const delivery = recordRail
2359
1799
  ? await network.spend(ms => recordRail.close(ms, () => this.wire.close()))
@@ -2370,11 +1810,8 @@ export class UserGroundHost {
2370
1810
  this.recordStore = null;
2371
1811
  this.recordRail = null;
2372
1812
  await attempt(() => this.endApply());
2373
- // A download still in flight holds its own lease.
2374
1813
  await this.cacheIndex?.release();
2375
1814
  this.cacheIndex = null;
2376
- // Last: every pass and rail that reads the ground has stopped, and the
2377
- // naming they started lets its journal rows go before the saver stops.
2378
1815
  if (this.activeIdentity) {
2379
1816
  const file = this.databasePath();
2380
1817
  await attempt(() => cargoNamed(file));
@@ -2385,21 +1822,15 @@ export class UserGroundHost {
2385
1822
  }
2386
1823
  return Object.freeze({ resources: "closed", catchUp, delivery });
2387
1824
  }
2388
- /** What this lifetime owed ends with its Watch; the next lifetime's blind
2389
- * interval examines every root. */
2390
1825
  forgetOwed() {
2391
1826
  this.hearingOwed?.();
2392
1827
  this.hearingOwed = null;
2393
1828
  this.owedExaminations.close();
2394
1829
  }
2395
- /** Pause cancels this lifetime. Durable work and the blind interval remain
2396
- * for resume; nothing here claims catch-up. */
2397
1830
  async cancelLifetime({ attempt }) {
2398
1831
  this.closing = true;
2399
1832
  this.forgetOwed();
2400
1833
  this.clearDetectParks();
2401
- // Apply hears the stop before its waits end, so a preparation the abort
2402
- // ends reads as the stop it is and starts no reveal (Live journey.ts).
2403
1834
  const applyStopped = this.applyRail?.stop();
2404
1835
  this.applyWaits.abort();
2405
1836
  const stopped = [this.watchHost.close({ catchUp: false }), applyStopped, this.placementTidy?.stop(),
@@ -2410,38 +1841,19 @@ export class UserGroundHost {
2410
1841
  await attempt(() => stop);
2411
1842
  return { state: "cancelled" };
2412
1843
  }
2413
- /** Command shutdown is the last catch-up boundary. Durable Apply ownership
2414
- * of observed or unreachable ground, Git refusing a root, ground still
2415
- * moving through the final pass, or user ground this process cannot read
2416
- * leaves it incomplete; startup suspects every root unconditionally, and
2417
- * a terminal Apply or a changed refusal wakes the held Detect. */
2418
1844
  async catchUpThroughCutoff({ attempt, fail }, network) {
2419
1845
  this.endNextTurns(true);
2420
- // Apply resumes from its durable intent at startup, so shutdown gives it
2421
- // one bounded chance to release ground rather than waiting on its retries.
2422
- // Send keeps running beside it; its own share of the budget comes last.
2423
1846
  const applyRail = this.applyRail;
2424
1847
  await attempt(() => applyRail && network.spend(ms => bounded(applyRail.flush(), ms)));
2425
- // Ends every Apply wait, including a download in flight: its durable
2426
- // intent resumes at startup. Apply hears the stop first, so a preparation
2427
- // the abort ends reads as the stop it is and starts no reveal (Live journey.ts).
2428
1848
  const applyStopped = attempt(() => this.applyRail?.stop());
2429
1849
  this.applyWaits.abort();
2430
- // Only a lifetime whose Apply store opened has owners to name; a failed
2431
- // convergence never created one.
2432
1850
  const applyRan = this.applyHost !== null;
2433
1851
  await applyStopped;
2434
1852
  await attempt(() => this.endApply());
2435
- // A filesystem callback may still be queued, so watcher silence cannot be
2436
- // used as evidence yet; full suspicion also covers whatever was owed.
2437
1853
  this.forgetOwed();
2438
1854
  this.watchHost.suspectAll();
2439
1855
  this.closing = true;
2440
1856
  this.clearDetectParks();
2441
- // Full suspicion already contains every callback that could still be
2442
- // queued. Retire physical coverage before the final observation so native
2443
- // backends cannot continuously widen a finite shutdown pass. Changes
2444
- // after this cutoff belong to the next startup blind interval.
2445
1857
  await attempt(() => this.watchHost.close());
2446
1858
  const cutoff = this.watchHost.pending();
2447
1859
  let owners = [];
@@ -2451,10 +1863,6 @@ export class UserGroundHost {
2451
1863
  await this.proveOwed();
2452
1864
  }
2453
1865
  catch (error) {
2454
- // Ground still moving through the final pass is a change after the
2455
- // cutoff. User ground this process cannot read keeps its last-known
2456
- // facts until it can be. Each is named even when the others are
2457
- // present. A binding whose read faulted, or anything else, is a failure.
2458
1866
  if (error instanceof DetectResidual)
2459
1867
  ({ roots: movingRoots, unavailable } = error);
2460
1868
  else if (error instanceof DetectUnavailable)
@@ -2462,11 +1870,6 @@ export class UserGroundHost {
2462
1870
  else
2463
1871
  fail(error);
2464
1872
  }
2465
- // The cutoff answers for every declared root, not only those this
2466
- // lifetime reached: a binding whose ground cannot be reached was never
2467
- // examined, so no Detect answer names it. It is named here, and so is
2468
- // any open intent that owns ground behind it. A binding whose read
2469
- // faulted fails where Detect attributes it.
2470
1873
  if (this.activeIdentity) {
2471
1874
  try {
2472
1875
  unavailable = [...unavailable, ...workspaceBindings(this.bindingDir()).unreachable];
@@ -2476,8 +1879,6 @@ export class UserGroundHost {
2476
1879
  }
2477
1880
  }
2478
1881
  if (applyRan && this.activeIdentity) {
2479
- // Every open window's members are owed to its end, which the next
2480
- // startup's recovery reaches: each is named, with the roots it shows in.
2481
1882
  try {
2482
1883
  owners = sqliteApplyOwnership(groundDatabase(this.databasePath())).read();
2483
1884
  }
@@ -2485,13 +1886,10 @@ export class UserGroundHost {
2485
1886
  fail(error);
2486
1887
  }
2487
1888
  }
2488
- // Lanes on other ground end before the rails that follow them close.
2489
1889
  await this.detectDrained();
2490
1890
  this.clearDetectParks();
2491
1891
  this.endNextTurns(true);
2492
1892
  const roots = new Set(cutoff.map(observation => observation.directory));
2493
- // Every cause list is ordered and free of repeats, whatever order the
2494
- // lanes answered in; one root may stand in more than one list.
2495
1893
  const waiting = this.waiting()
2496
1894
  .filter(wait => [...roots].some(root => pathWithin(root, wait.path)));
2497
1895
  const waitingRoots = [...roots].filter(root => waiting.some(wait => pathWithin(root, wait.path)));
@@ -2508,10 +1906,6 @@ export class UserGroundHost {
2508
1906
  return {
2509
1907
  state: "incomplete",
2510
1908
  cutoff: cutoff.map(({ rootId, pending }) => ({ rootId, generation: pending.generation })),
2511
- // An open window withholds only the roots its members show in; a
2512
- // waiting repository, moving ground or unreadable ground withholds
2513
- // only its own root, whether or not that root was still bound at the
2514
- // cutoff.
2515
1909
  unresolvedRoots: [...new Set([...[...roots].filter(root => owners.some(owner => owner.cones.some(cone => pathWithin(root, cone) || pathWithin(cone, root)))),
2516
1910
  ...waitingRoots, ...moving,
2517
1911
  ...unavailableRootList.map(root => root.directory)])].sort(),
@@ -2521,12 +1915,6 @@ export class UserGroundHost {
2521
1915
  unavailableRoots: unavailableRootList,
2522
1916
  };
2523
1917
  }
2524
- /**
2525
- * The host half of Sharing's ports: the access tables over the tunnel, the
2526
- * owner and principal lookups the gateway answers, and this computer's
2527
- * rail. The product supplies `constructs`; the caller supplies the link a
2528
- * person opens.
2529
- */
2530
1918
  sharingPorts(input) {
2531
1919
  const access = this.entityAccess;
2532
1920
  const rail = this.recordRail;
@@ -2545,28 +1933,12 @@ export class UserGroundHost {
2545
1933
  };
2546
1934
  return ports;
2547
1935
  }
2548
- /**
2549
- * One deliberate construct change, from the product that owns it. Every
2550
- * create, save, rename and delete of a construct reaches the rails here and
2551
- * nowhere else.
2552
- */
2553
1936
  recordConstruct(change) {
2554
1937
  if (!this.constructDoor) {
2555
1938
  throw new Error("recording a construct requires the running entity Record rail");
2556
1939
  }
2557
1940
  return this.constructDoor(change);
2558
1941
  }
2559
- /**
2560
- * Empty Trash, or delete one item in it for good: Live plans one deletion
2561
- * per entity the pick holds, children first, and each enters the Outbox as
2562
- * an intentional record. The view is this machine's notebook over the roots
2563
- * it holds whole (ground-reads.ts readTrashView): its accepted results and
2564
- * Detect's own committed ones. A root served on demand is left out, and
2565
- * the answer names how many, since only the Gateway's view holds them
2566
- * whole; an item in one is refused. A pass cut short is finished by running
2567
- * it again; the mutation ids repeat, so the Outbox keeps what it already
2568
- * holds.
2569
- */
2570
1942
  async deleteFromTrash(pick) {
2571
1943
  const authorityId = this.authorityId, store = this.recordStore, rail = this.recordRail;
2572
1944
  const deviceId = this.activeIdentity?.deviceId;
@@ -2589,11 +1961,6 @@ export class UserGroundHost {
2589
1961
  });
2590
1962
  return { recorded, onDemandRoots: view.onDemandRoots.length };
2591
1963
  }
2592
- /**
2593
- * One sealed secret value, fetched because the keychain asked for it. A
2594
- * construct's cargo lives under its own UUID, so that is the resource. The
2595
- * sealed copy in the content cache is collected like any unheld artifact.
2596
- */
2597
1964
  async readSecretPayload(entityId, head) {
2598
1965
  const artifact = { entityId, entityType: "secret", kind: "construct", contentHash: head };
2599
1966
  const files = await this.downloadContentSet(entityId, this.cacheDir(), [{ artifact }], DOWNLOAD_CONTENT_RETRY_ATTEMPTS, { journey: "apply" });
@@ -2602,104 +1969,65 @@ export class UserGroundHost {
2602
1969
  throw new Error(`secret ${entityId} has no value at its head`);
2603
1970
  return readFile(file);
2604
1971
  }
2605
- /** Every secret record this computer holds, for the keychain's shelf. */
2606
1972
  secretRecords() {
2607
1973
  if (!this.constructLedger) {
2608
1974
  throw new Error("secret records require the running entity Record rail");
2609
1975
  }
2610
1976
  return this.constructLedger.ofType("secret");
2611
1977
  }
2612
- /** The entity type this computer recorded for a UUID, for construct doors. */
2613
1978
  constructKind(uuid) {
2614
1979
  if (!this.constructLedger) {
2615
1980
  throw new Error("construct kinds require the running entity Record rail");
2616
1981
  }
2617
1982
  return this.constructLedger.kind(uuid);
2618
1983
  }
2619
- /** The user root's synchronization address, resolved once when first
2620
- * bound; every child cone is derived from it. */
2621
1984
  userRoot() {
2622
1985
  return this.boundUserRoot ??= physicalPath(resolve(this.options.userRoot));
2623
1986
  }
2624
- /** The active top-level workspace rows standing at the user root: the core
2625
- * root as this computer holds it, exactly one once login has placed it. */
2626
1987
  localCoreRoots() {
2627
1988
  return coreRootsAt(groundDatabase(this.databasePath()), this.userRoot());
2628
1989
  }
2629
- /** Every root this computer materializes, as the one sharing policy
2630
- * reaches them: the home, once login placed it, and each reached binding. */
2631
1990
  policyRoots() {
2632
1991
  const home = this.localCoreRoots();
2633
1992
  return [
2634
- ...(home.length === 1 ? [{ rootUUID: home[0], directory: this.userRoot(), home: true }] : []),
1993
+ ...(home.length === 1 ? [{ rootUUID: home[0], directory: this.userRoot() }] : []),
2635
1994
  ...materializedWorkspaceBindings(this.bindingDir())
2636
- .map(({ workspaceId, directory }) => ({ rootUUID: workspaceId, directory, home: false })),
1995
+ .map(({ workspaceId, directory }) => ({ rootUUID: workspaceId, directory })),
2637
1996
  ];
2638
1997
  }
2639
- /** A received result of the home's policy file, now applied here, owes
2640
- * every root its selection under it, as a local edit would
2641
- * (policy-owed.ts). Read after the window committed, so the text is what
2642
- * Apply verified or a later edit, which rings Detect itself. */
2643
- async policyReceived(uuids) {
2644
- const roots = this.policyRoots(), home = roots.find(root => root.home);
2645
- if (!home || uuids.length === 0)
1998
+ async policyReceived(uuids, cones) {
1999
+ const roots = this.policyRoots();
2000
+ if (roots.length === 0 || uuids.length === 0)
2646
2001
  return;
2647
- const policyRow = groundDatabase(this.databasePath()).prepare(`SELECT uuid FROM entities
2648
- WHERE root_uuid = ? AND relative_path = ?`).pluck().all(home.rootUUID, USER_IGNORE_FILE_NAME);
2649
- if (!policyRow.some(uuid => uuids.includes(uuid)))
2002
+ const select = groundDatabase(this.databasePath())
2003
+ .prepare(`SELECT ${GROUND_ROW_PROJECTION} FROM entities WHERE uuid = ?`);
2004
+ const rows = uuids.map(uuid => select.get(uuid))
2005
+ .filter((row) => row !== undefined);
2006
+ const owed = this.skipRulesOwed.received(rows, roots, cones);
2007
+ if (owed.reaches.length === 0)
2650
2008
  return;
2651
- const { text } = readSharingPolicy(home.directory, home.directory);
2652
- for (const path of await policyExaminations(this.databasePath(), text, roots))
2009
+ for (const path of await policyExaminations(this.databasePath(), owed))
2653
2010
  this.watchHost.suspect(path);
2654
2011
  if (this.watchHost.hasPending)
2655
2012
  this.ringDetect();
2656
2013
  }
2657
- /** The root the drive serves by default: this computer's core root. */
2658
2014
  coreRootUUID() {
2659
- const local = this.localCoreRoots();
2660
- if (local.length === 0)
2661
- throw new Error("this computer holds no core root yet: log in first");
2662
- if (local.length > 1)
2663
- throw new Error(`${this.userRoot()} holds ${local.length} core roots`);
2664
- return local[0];
2665
- }
2666
- /** Where a root's placed ground stands on this computer: the user root for
2667
- * the core root, a bound external workspace's directory, else null for a
2668
- * root this computer never bound, which the drive lists from its map. */
2015
+ return soleCoreRoot(this.localCoreRoots(), this.userRoot());
2016
+ }
2669
2017
  shelfDirectory(rootUUID) {
2670
- if (this.localCoreRoots().includes(rootUUID))
2671
- return this.userRoot();
2672
- const wanted = rootUUID.toLowerCase();
2673
- return workspaceBindings(this.bindingDir()).declared.find((binding) => binding.workspaceId === wanted)?.directory ?? null;
2018
+ return rootDirectory(rootUUID, this.localCoreRoots(), this.userRoot(), this.bindingDir());
2674
2019
  }
2675
2020
  cacheDir() {
2676
- return join(this.options.dir, "content");
2021
+ return groundPlaces(this.options.dir).content;
2677
2022
  }
2678
- /** Each external workspace's machine-local binding, `<uuid>` → its ground. */
2679
2023
  bindingDir() {
2680
- return join(this.options.dir, "bindings");
2024
+ return groundPlaces(this.options.dir).bindings;
2681
2025
  }
2682
- /** This computer's folder in the computers folder, once chosen: the drive
2683
- * never shows it here, where its ground already stands. */
2684
2026
  keptComputerFolder() {
2685
2027
  if (this.computer !== undefined)
2686
2028
  return this.computer;
2687
- let name;
2688
- try {
2689
- name = readFileSync(this.computerFolderFile(), "utf8").replace(/\n$/, "");
2690
- }
2691
- catch (error) {
2692
- if (error.code !== "ENOENT")
2693
- throw error;
2694
- return this.computer = null;
2695
- }
2696
- if (name === "")
2697
- throw new Error(`${this.computerFolderFile()} does not name this computer's folder`);
2698
- return this.computer = name;
2029
+ return this.computer = readComputerFolder(this.computerFolderFile());
2699
2030
  }
2700
- /** The folder Register adds outside the home under: kept once chosen, and
2701
- * chosen from this computer's name among the folders the accepted
2702
- * computers folder already holds, so no two computers share one. */
2703
2031
  async computerFolder(identity) {
2704
2032
  const kept = this.keptComputerFolder();
2705
2033
  if (kept !== null)
@@ -2716,7 +2044,7 @@ export class UserGroundHost {
2716
2044
  return this.computer = chosen;
2717
2045
  }
2718
2046
  computerFolderFile() {
2719
- return join(this.options.dir, "computer-folder");
2047
+ return groundPlaces(this.options.dir).computerFolder;
2720
2048
  }
2721
2049
  cloudPort(identity, scope) {
2722
2050
  return {
@@ -2738,16 +2066,11 @@ export class UserGroundHost {
2738
2066
  const graph = this.materializeRegistry(frame);
2739
2067
  const ready = readyFromFrame(frame, graph, await this.selectScope(identity, graph, scope));
2740
2068
  await this.keepGraphHead(frame, ready.state);
2741
- // The authority keeps its first graph's checksum: that graph's
2742
- // creation and every retry of it are not duplicates. A created graph
2743
- // is this ground's own at the line's origin; another one is installed.
2744
2069
  const created = frame.duplicate === false;
2745
2070
  return { created, current: created ? ready.cloud : await this.installableGround(identity, scope, ready) };
2746
2071
  },
2747
2072
  };
2748
2073
  }
2749
- /** The authority's head as it stands, selected to the scope and kept; null
2750
- * when the authority holds no graph for this person. */
2751
2074
  async readHead(identity, resourceId, scope) {
2752
2075
  const frame = await this.wire.request({
2753
2076
  type: "private.resource.lookup",
@@ -2761,19 +2084,6 @@ export class UserGroundHost {
2761
2084
  await this.keepGraphHead(frame, ready.state);
2762
2085
  return ready;
2763
2086
  }
2764
- /** The graph an install reads (AGENTS.md §5): the head at N plus the
2765
- * complete accepted tail the Inbox holds after N, folded by the one reducer
2766
- * and selected to the operation's roots, at the tail's watermark T. Login
2767
- * and Add read it alike, so neither installs ground the authority already
2768
- * moved past, nor replays history the fold settled.
2769
- *
2770
- * An install's lookup is the first reader of the line, so it starts Receive
2771
- * if nothing has: Receive then begins at the head it folds onto. The fold
2772
- * waits until Receive has heard the history as it stands; this machine's
2773
- * Send is never a graph's truth. An empty tail leaves the head as the
2774
- * authority stored it. Ground that already holds its place installs
2775
- * nothing: it follows from that place through Receive and Apply, so its
2776
- * lookup only names the head and starts nothing. */
2777
2087
  async installableGround(identity, scope, ready) {
2778
2088
  const { cloud, state } = ready;
2779
2089
  if (scope.kind === "none")
@@ -2789,8 +2099,6 @@ export class UserGroundHost {
2789
2099
  return cloud;
2790
2100
  const tail = readAcceptedTail(groundDatabase(database), cloud.resourceId, cloud.deliveryWatermark);
2791
2101
  const fold = await AcceptedFold.open(state.graph, tail.accepted, sha256Hex);
2792
- // Every root's own record, plus the complete roots the install acts on,
2793
- // each as the fold through T leaves it.
2794
2102
  const selected = new Map((await fold.rootRecords()).map((record) => [record.uuid, record]));
2795
2103
  const roots = new Set([findUserGroundRoot(selected.values(), identity.userEmail)]);
2796
2104
  if (scope.kind === "workspace")
@@ -2809,9 +2117,6 @@ export class UserGroundHost {
2809
2117
  snapshot,
2810
2118
  };
2811
2119
  }
2812
- /** Every head this machine reads is a basis for received state at the
2813
- * positions after it (graph-heads.ts), kept only once its bytes prove the
2814
- * checksum the authority named. */
2815
2120
  async keepGraphHead(frame, head) {
2816
2121
  if (head.graph.checksum() !== head.checksum)
2817
2122
  throw new Error("cloud registry head does not match its checksum");
@@ -2823,19 +2128,10 @@ export class UserGroundHost {
2823
2128
  checksum: head.checksum,
2824
2129
  });
2825
2130
  }
2826
- /** The authority's stored snapshot as this machine's graph. A head is held
2827
- * lazily — no page is read until an operation asks for a root — and every
2828
- * page this machine already cached is a local read, so an unchanged root
2829
- * never crosses the network twice. */
2830
2131
  materializeRegistry(frame) {
2831
2132
  const resourceId = String(frame.resource_id || "");
2832
2133
  return registryGraphFromSnapshot(Buffer.from(String(frame.snapshot_b64 || ""), "base64"), (ref) => this.readGraphPage(resourceId, ref), sha256Hex);
2833
2134
  }
2834
- /** The records a lookup hands to Live: every root's own record — the
2835
- * discovery set that proves root uniqueness — plus the full records of
2836
- * exactly the roots the operation acts on. A records-shaped snapshot is a
2837
- * first publication's own small graph and travels whole, keeping its
2838
- * records-shape checksum law intact. */
2839
2135
  async selectScope(identity, graph, scope) {
2840
2136
  if (graph.head === null)
2841
2137
  return graph.recordsShapedSnapshot().records;
@@ -2859,15 +2155,9 @@ export class UserGroundHost {
2859
2155
  }
2860
2156
  return [...records.values()];
2861
2157
  }
2862
- /** The account's core root: the one active top-level workspace named by the
2863
- * account email. Registered-boundary references live only there. */
2864
2158
  async coreRootId(identity, graph) {
2865
2159
  return findUserGroundRoot(await graph.rootRecords(), identity.userEmail);
2866
2160
  }
2867
- /** Read one graph page by identity: cached pages come off local disk, the
2868
- * rest are fetched straight from content storage and cached on the way in.
2869
- * The graph proves every page against its declared identity as it parses,
2870
- * so this reader only guards the cache against torn copies. */
2871
2161
  async readGraphPage(resourceId, ref) {
2872
2162
  const path = this.graphPagePath(ref.sha256);
2873
2163
  const cached = readVerifiedRegistryPage(path, ref, sha256Hex);
@@ -2882,7 +2172,7 @@ export class UserGroundHost {
2882
2172
  return bytes;
2883
2173
  }
2884
2174
  graphPagePath(sha256) {
2885
- return join(graphPageCacheDir(this.cacheDir()), `${sha256}.bin`);
2175
+ return registryPagePath(this.cacheDir(), sha256);
2886
2176
  }
2887
2177
  localPort(identity) {
2888
2178
  const userRoot = this.userRoot();
@@ -2911,18 +2201,12 @@ export class UserGroundHost {
2911
2201
  onScan: (evidence) => this.reportDetectScan(evidence),
2912
2202
  measuring: this.measuring(),
2913
2203
  });
2914
- // Ground this walk read that cannot travel waits alone,
2915
- // named; the rest of the home publishes beside it.
2916
2204
  this.answerWaits(waits);
2917
- // A cloud head names only content the authority holds, so the
2918
- // graph Live journals next has its content sealed here first.
2919
2205
  const local = localValue(identity, userRoot, database);
2920
2206
  await this.uploadSnapshotContent(authorityId, local.records);
2921
2207
  return local;
2922
2208
  }
2923
2209
  catch (error) {
2924
- // Evidence that moved while it was read or sealed answers again
2925
- // on a fresh walk, exactly as Register's declaring walk does.
2926
2210
  if (!moved(error) || attempt >= STALE_CAPTURE_ATTEMPTS)
2927
2211
  throw error;
2928
2212
  }
@@ -2936,41 +2220,15 @@ export class UserGroundHost {
2936
2220
  });
2937
2221
  },
2938
2222
  place: async (_who, cloud) => {
2939
- // Another graph won any publication this ground journaled.
2940
2223
  await save(database, "record.answerPublication", { authorityId });
2941
- // How much login places is one condition this host states, decided
2942
- // once at this login (Live user-ground.ts): whether this computer's
2943
- // Amalgm folder is served by its drive. With a drive, the runtime's
2944
- // own entries Core's layout names are staged whole and the projects
2945
- // and computers folders bare (Live `placedAtHome`): the products read them in
2946
- // process, where a listed entry could not be read, so they stand
2947
- // before the runtime runs (drive/README.md, one door). Whatever
2948
- // already stands where the map lists it (a race loser holds its own
2949
- // first graph) is adopted as the record it stands for, so no standing
2950
- // file is doubled under a new identity; everything else stays listed,
2951
- // served by the drive and placed on demand. Without a drive a
2952
- // listed entity would be invisible to the OS and nothing could open
2953
- // it, so the home's whole active closure is staged, trash set aside,
2954
- // as Add installs a workspace; this computer then holds every byte
2955
- // and is never marked.
2956
2224
  const drive = this.options.drive === true;
2957
2225
  const home = userGroundSelection(cloud.snapshot.records, identity.userEmail, { drive });
2958
2226
  const { root } = home;
2959
- // Staged in the home's own control tree: same device, same clock,
2960
- // and never Watch's ground.
2961
2227
  const stagings = join(this.options.dir, "install-staging");
2962
2228
  const staging = join(stagings, root);
2963
- // Ground holding a place committed this graph, pinned with its rows,
2964
- // and only its reveal remains. Before that commit nothing is pinned,
2965
- // so whatever an earlier placement staged is untrusted and leaves.
2966
2229
  if (groundPlace(database, authorityId).place === undefined) {
2967
2230
  await rm(stagings, { recursive: true, force: true });
2968
2231
  ensurePrivateDir(stagings);
2969
- // With a drive, what stands is read now, against the home as the
2970
- // map lists it; the reveal merges each standing directory and
2971
- // leaves each occupant, whose bytes Detect proves. Without one the
2972
- // reveal meets occupants the same way, and the install claims no
2973
- // materialization for them (`occupiedMembers`).
2974
2232
  const { placed, listed } = userGroundSelection(cloud.snapshot.records, identity.userEmail, {
2975
2233
  drive,
2976
2234
  ...(drive ? { standing: await standingRecords([...home.placed, ...home.listed], userRoot) } : {}),
@@ -2982,22 +2240,13 @@ export class UserGroundHost {
2982
2240
  clockRoot: userRoot,
2983
2241
  database,
2984
2242
  bindingDir,
2985
- gitStorage: this.options.gitStorage ?? null,
2243
+ held: groundGitOwners(groundDatabase(database), null, this.options.gitStorage ?? null),
2986
2244
  gitLines: installGitLines(database, authorityId, cloud.deliveryWatermark, cacheDir),
2245
+ report: (error) => this.options.onBackgroundError?.(error),
2987
2246
  readContent: (artifacts) => this.downloadContentSet(cloud.resourceId, cacheDir, artifacts.map((artifact) => ({ artifact }))),
2988
2247
  durabilityBarrier: this.options.durabilityBarrier ?? platformDurabilityBarrier,
2989
2248
  });
2990
- // Whatever ground stood at the home — a race loser's own first
2991
- // graph — leaves in the save that commits the placed rows, this
2992
- // ground's place on the line, the pin its reveal resumes from and,
2993
- // with a drive, the on-demand mark Apply reads. It is written while
2994
- // the barrier drains and commits once the staging is verified:
2995
- // durable, and that milestone reported. With a drive the listed
2996
- // records stay in the map, the kept head folded with what Receive
2997
- // brings: Apply lists what it receives for this root, and anything
2998
- // touched is placed from its latest accepted version (src/drive/);
2999
- // none is set aside. Without one the listed records are the trash
3000
- // this install set aside, verified absent as Add verifies it.
2249
+ const occupied = [...await occupiedMembers(rows.map(stagedMember))];
3001
2250
  const verified = durable.then(() => this.options.onInstallStage?.({ journey: "login", rootId: root,
3002
2251
  stage: "materialization-verified" }));
3003
2252
  const committed = persistRows(database, identity, cloud.resourceId, root, { observed: rows, shared: rows }, readRowsRootedAt(database, userRoot), {
@@ -3006,13 +2255,12 @@ export class UserGroundHost {
3006
2255
  watermark: cloud.deliveryWatermark,
3007
2256
  absent: drive ? [] : listed.map(({ uuid }) => uuid),
3008
2257
  lines: playedLines(rows),
3009
- occupied: [...await occupiedMembers(rows.map(stagedMember))],
2258
+ occupied,
3010
2259
  joins: { pinnedJson: stableJson(cloud) }, ...(drive ? { onDemandRoot: root } : {}),
3011
2260
  resolvedAt: this.options.now?.().getTime() ?? Date.now(),
3012
2261
  },
3013
2262
  after: verified,
3014
2263
  });
3015
- // A failure before the staging is verified fails both; its own error is the one reported.
3016
2264
  committed.catch(() => { });
3017
2265
  await verified;
3018
2266
  await committed;
@@ -3023,9 +2271,6 @@ export class UserGroundHost {
3023
2271
  return homeGround(identity, userRoot, database, authorityId);
3024
2272
  },
3025
2273
  join: async (_who, place) => {
3026
- // A drive serves this home from its first login, the one that
3027
- // publishes it included: what this computer made stays placed, and
3028
- // what arrives later is listed until something touches it.
3029
2274
  const root = this.options.drive === true
3030
2275
  ? homeRoot(database, identity.userEmail) : null;
3031
2276
  if (this.options.drive === true && root === null)
@@ -3033,12 +2278,8 @@ export class UserGroundHost {
3033
2278
  await save(database, "record.join", { authorityId, place, ...(root === null ? {} : { onDemandRoot: root }) });
3034
2279
  },
3035
2280
  watch: async () => {
3036
- // A Register that absorbed a workspace and stopped before retiring
3037
- // its binding retires it here, before any root is read.
3038
2281
  retireAbsorbedBindings(this.databasePath(), this.bindingDir());
3039
2282
  const health = this.ensureWatchers(identity);
3040
- // Healthy coverage of a placed home ends its placement; a blind
3041
- // interval before it is the whole-root catch-up Watch just opened.
3042
2283
  const root = groundPlace(database, authorityId).placing === undefined ? null
3043
2284
  : homeRoot(database, identity.userEmail);
3044
2285
  if (root !== null)
@@ -3048,22 +2289,10 @@ export class UserGroundHost {
3048
2289
  },
3049
2290
  };
3050
2291
  }
3051
- /** A package's cargo: its members' content and its pages, in one seal
3052
- * inventory and one cargo stream, so the record it accepts names only
3053
- * durable content. The members' sources are their admitted rows, like any
3054
- * upload's. */
3055
2292
  async uploadPackage(database, record) {
3056
2293
  const trace = { journey: "send", entityId: record.entityId, mutationId: record.mutationId };
3057
2294
  await this.uploadSnapshotContent(record.authorityId, statedResults(database, record.change), trace, keptPackagePages(database, record.change));
3058
2295
  }
3059
- /** Send's small-cargo fast path: the record's sealed artifacts ride its
3060
- * batch's submit frame, so one round trip carries records, manifests, and
3061
- * bytes. Each artifact is read where it stands, the journal first and then
3062
- * the cache (cargo-journal.ts), and only when that copy proves it whole
3063
- * within the inline bound; anything else returns null and the block upload
3064
- * path runs unchanged. A package with a parent here takes that path, whose
3065
- * inventory asks which of its ancestors the authority lacks
3066
- * (git/held-package.ts cachedParent). */
3067
2296
  async readInlineCargo(database, record) {
3068
2297
  const cache = this.cacheDir();
3069
2298
  const inline = [];
@@ -3071,7 +2300,6 @@ export class UserGroundHost {
3071
2300
  const journaled = journaledCargo(database, artifact.contentHash);
3072
2301
  const layout = journaled ? checkedLayoutHint(journaled.manifest, artifact)
3073
2302
  : await readLayoutHint(cache, artifact);
3074
- // Inline cargo is small, so one manifest names it.
3075
2303
  if (!layout || layout.bytes > INLINE_CARGO_MAX_BYTES || isContentParts(layout.index))
3076
2304
  return null;
3077
2305
  const manifest = layout.index;
@@ -3099,12 +2327,6 @@ export class UserGroundHost {
3099
2327
  }
3100
2328
  return inline;
3101
2329
  }
3102
- /** One self-contained cargo segment on the wire: each artifact named by
3103
- * its hash and length in the body ahead of its bytes (Live's cargo law),
3104
- * one round trip in which the authority proves each whole. Returns the authority's sealed hashes for the stream law to
3105
- * prove coverage. The acknowledgement carries the gateway's own leg
3106
- * timings — verification, storage, sealing — which fold into the ledger
3107
- * as a decomposition of this round trip's `wireMs`. */
3108
2330
  async putCargo(resourceId, artifacts, legs) {
3109
2331
  const body = encodeCargoBody(artifacts);
3110
2332
  const encoded = await legs.time("encodeMs", () => encodeContentWireBytes(body));
@@ -3123,9 +2345,6 @@ export class UserGroundHost {
3123
2345
  wireBytes: encoded.bytes.byteLength,
3124
2346
  };
3125
2347
  }
3126
- /** Store one wave of provisional content blocks, addressed by their own
3127
- * digests and bound to no artifact. Resolving means every block is
3128
- * durable at the authority. Answers the wire bytes actually sent. */
3129
2348
  async putContentBlocks(resourceId, blocks, payload, legs) {
3130
2349
  const encoded = await legs.time("encodeMs", () => encodeContentWireBytes(payload));
3131
2350
  const frame = await legs.time("wireMs", () => retryContent(this.wire.signal, () => this.wire.requestBinary({
@@ -3140,10 +2359,6 @@ export class UserGroundHost {
3140
2359
  legs.add("gatewayStoreMs", Number(frame.store_ms));
3141
2360
  return encoded.bytes.byteLength;
3142
2361
  }
3143
- /** Seal one artifact's index: a manifest, or a list of parts. The
3144
- * authority re-proves every named block, or every named part, durable
3145
- * before anything becomes visible, so this frame is only lawful after the
3146
- * complete content went over the wire. */
3147
2362
  async putContentManifest(resourceId, manifest, legs) {
3148
2363
  const bytes = Buffer.from(stableJson(manifest), "utf8");
3149
2364
  const frame = await legs.time("wireMs", () => retryContent(this.wire.signal, () => this.wire.requestBinary({
@@ -3158,10 +2373,7 @@ export class UserGroundHost {
3158
2373
  legs.add("gatewaySealMs", Number(frame.seal_ms));
3159
2374
  return bytes.length;
3160
2375
  }
3161
- async uploadSnapshotContent(resourceId, records, trace,
3162
- /** A package's pages: immutable, already in memory, each its own single
3163
- * chunk. They share the members' inventory and cargo stream. */
3164
- pages = []) {
2376
+ async uploadSnapshotContent(resourceId, records, trace, pages = []) {
3165
2377
  const cache = this.cacheDir();
3166
2378
  const byHash = new Map();
3167
2379
  await eachInTurns(records, (record) => {
@@ -3193,12 +2405,6 @@ export class UserGroundHost {
3193
2405
  artifacts: byHash.size,
3194
2406
  },
3195
2407
  });
3196
- // The authority's seal inventory is the only permission to skip an
3197
- // upload — asked before any source is touched, so sealed artifacts cost
3198
- // zero local reads and a retried publication whose upload already sealed
3199
- // completely never needs its captured ground to still exist. A package travels with every ancestor the authority lacks
3200
- // (git/held-package.ts cachedParent): each held parent joins the same
3201
- // first question, and a parent the authority lacks asks after its own.
3202
2408
  const parentsOf = async (asked) => {
3203
2409
  const found = [];
3204
2410
  for (const { artifact, uuid } of asked) {
@@ -3230,19 +2436,11 @@ export class UserGroundHost {
3230
2436
  unsealed.push(entry);
3231
2437
  });
3232
2438
  const paths = legs.timeSync("planMs", () => new Map(readGroundRowsByUUIDs(this.databasePath(), "entities", new Set(unsealed.map(({ uuid }) => uuid))).map((row) => [row.uuid, row.absolutePath])));
3233
- // Each artifact uploads from its sealed cache copy, which every Detect
3234
- // that plans Send records writes in the read that observes it. Two
3235
- // journeys read ground instead: a first publication, whose login walk
3236
- // seals nothing, and a restore of accepted cargo from ground whose row
3237
- // still names it. Every read is re-proven against the captured hash,
3238
- // turning ground churn into a stale capture instead of a wrong upload.
3239
2439
  const sources = await legs.time("planMs", () => mapInTurns(unsealed, ({ artifact, uuid }) => {
3240
2440
  const cached = contentFile(cache, artifact.contentHash);
3241
2441
  const fromCache = existsSync(cached);
3242
2442
  const path = paths.get(uuid);
3243
2443
  if (!fromCache && artifact.kind === "git") {
3244
- // Ground holds the repository, never its artifact; a lost artifact
3245
- // means capturing the repository again as it now is.
3246
2444
  throw new StaleCaptureError(`repository artifact ${artifact.contentHash} is no longer captured`);
3247
2445
  }
3248
2446
  if (!fromCache && path === undefined) {
@@ -3267,23 +2465,11 @@ export class UserGroundHost {
3267
2465
  }));
3268
2466
  const stale = (source, error) => {
3269
2467
  if (source.fromCache) {
3270
- // A cache copy that no longer proves its hash is torn evidence:
3271
- // purge it so the retry reads the ground itself.
3272
2468
  discardCachedArtifact(cache, source.artifact.contentHash);
3273
2469
  }
3274
2470
  throw new StaleCaptureError(`${source.artifact.contentHash} no longer matches its source`, { cause: error });
3275
2471
  };
3276
- // Complete small artifacts ride the cargo stream: whole artifacts per
3277
- // self-contained segment, each verified and sealed by the authority in
3278
- // its own round trip, so the frame count scales with bytes moved, never
3279
- // with file count — and Live's bounded window keeps later segments on
3280
- // the wire while earlier durability acknowledgements are still
3281
- // outstanding. Large artifacts keep per-artifact transfer where chunk
3282
- // reuse pays.
3283
2472
  const small = sources.filter((source) => source.bytes <= CHUNK_BYTES);
3284
- // Only a large artifact negotiates its blocks, so only it reads a
3285
- // retained layout hint. Retained evidence counts only while it still
3286
- // describes the exact source being read; a disagreeing one is re-derived.
3287
2473
  const unhinted = sources.filter((source) => source.bytes > CHUNK_BYTES);
3288
2474
  const hints = await legs.time("planMs", () => readLayoutHints(cache, unhinted.map(({ artifact }) => artifact)));
3289
2475
  const large = unhinted.map((source) => {
@@ -3292,10 +2478,6 @@ export class UserGroundHost {
3292
2478
  ? { ...source, manifest: declared.index, parts: declared.parts } : source;
3293
2479
  });
3294
2480
  let cargoSegments = 0;
3295
- // The authority proves every cargo artifact whole (Live's cargo law), so
3296
- // the client reads each source once, exactly its stated length, and
3297
- // hashes nothing on the way out. Only a refusal makes it hash: the bytes
3298
- // it actually sent that are not their name are stale captures.
3299
2481
  const sendCargoSegment = async (segment) => {
3300
2482
  const loaded = new Array(segment.items.length).fill(null);
3301
2483
  await eachInTurns(segment.items.entries(), ([index, { page }]) => {
@@ -3315,7 +2497,6 @@ export class UserGroundHost {
3315
2497
  throw error;
3316
2498
  }
3317
2499
  });
3318
- // A body names each artifact once: equal names are equal bytes.
3319
2500
  const named = new Set();
3320
2501
  const shipping = segment.items.flatMap((item, index) => {
3321
2502
  const bytes = loaded[index];
@@ -3346,8 +2527,6 @@ export class UserGroundHost {
3346
2527
  const transfer = async (source) => {
3347
2528
  const { file, manifest: knownManifest, parts: knownParts, bytes: fileBytes } = source;
3348
2529
  const sourceFile = { handle: null };
3349
- // Content the authority already holds whole, by its hash: the
3350
- // artifact itself or, past one manifest, one of its parts.
3351
2530
  const present = new Set();
3352
2531
  const chunkBlocks = (manifest, indexes) => indexes.map((index) => {
3353
2532
  const chunk = manifest.chunks[index];
@@ -3442,9 +2621,6 @@ export class UserGroundHost {
3442
2621
  ...unsealedPages.map((page) => ({ contentHash: page.sha256, bytes: page.bytes.byteLength, page })),
3443
2622
  ], { send: sendCargoSegment });
3444
2623
  for (const source of large) {
3445
- // An incomplete seal means a block the inventory counted is gone, so
3446
- // the same manifest cannot seal until the block is sent again: the
3447
- // upload asks the inventory once more, and a second gap is a fault.
3448
2624
  await transfer(source).catch((error) => {
3449
2625
  if (!(error instanceof WireRequestError && error.code === "entity_content_incomplete"))
3450
2626
  throw error;
@@ -3462,10 +2638,6 @@ export class UserGroundHost {
3462
2638
  artifacts: byHash.size,
3463
2639
  reusedArtifacts: byHash.size - sources.length,
3464
2640
  declaredBytes: sources.reduce((total, source) => total + source.bytes, 0),
3465
- // The same declared source bytes split by rail: whole small
3466
- // artifacts ride shared cargo segments, larger ones ride
3467
- // per-artifact chunk transfer. Any change to either rail's shape
3468
- // is sized from a production trace by these four numbers.
3469
2641
  cargoArtifacts: small.length,
3470
2642
  cargoBytes: small.reduce((total, source) => total + source.bytes, 0),
3471
2643
  largeArtifacts: large.length,
@@ -3478,11 +2650,6 @@ export class UserGroundHost {
3478
2650
  reusedChunks,
3479
2651
  inventoryRequests,
3480
2652
  cargoSegments,
3481
- // Where this upload's time went, leg by leg: plan (seal inventory
3482
- // + ground rows + source stats), load (source reads), hash (block
3483
- // and whole-artifact digests, one pass), encode (compression), wire (data round trips, whose gateway share the
3484
- // acknowledgement timings decompose), inventory round trips, and
3485
- // idle — wall time with nothing in flight.
3486
2653
  ...legs.report(),
3487
2654
  },
3488
2655
  });
@@ -3499,13 +2666,6 @@ export class UserGroundHost {
3499
2666
  throw error;
3500
2667
  }
3501
2668
  }
3502
- /** Fetches back package `transportVersion`, which a row names and the
3503
- * cache lost, through the same verified download Apply uses. Only that
3504
- * package: another of equal content is another event's
3505
- * (git/held-package.ts). When the cloud holds it no more, the row's claim
3506
- * is false: it throws recover()'s `Recovering`, counted. `attempts` names
3507
- * the one owner of its retries: a cold journey's download retries itself;
3508
- * an ongoing lane's own backoff is its only retry. */
3509
2669
  async fetchBase(authorityId, entityId, transportVersion, attempts) {
3510
2670
  try {
3511
2671
  await this.downloadContentSet(authorityId, this.cacheDir(), [{ artifact: { entityId, entityType: "repo.git", kind: "git", contentHash: transportVersion } }], attempts, { journey: "detect", entityId });
@@ -3516,19 +2676,9 @@ export class UserGroundHost {
3516
2676
  throw this.recoveries.recover({ law: "cargo-missing", trigger: "not-found", subject: { id: entityId, type: "repo.git" }, lost: transportVersion });
3517
2677
  }
3518
2678
  }
3519
- /** A cold journey's restore: it reads the whole of its ground in one
3520
- * awaited walk, so it waits for the fetch, and a fault fails the walk. */
3521
2679
  restorePackage(authorityId) {
3522
2680
  return (entityId, transportVersion) => this.fetchBase(authorityId, entityId, transportVersion, DOWNLOAD_CONTENT_RETRY_ATTEMPTS);
3523
2681
  }
3524
- /** An ongoing lane's restore never waits for the cloud. A package that
3525
- * landed answers at once, and so does a fetch that found the cloud holds it
3526
- * no more, with recover(); otherwise the repository waits, alone, while one
3527
- * fetch per package runs. "Could not reach the cloud" is a fault of the
3528
- * world: only the fetch retries, doubling from DETECT_RETRY_MS to
3529
- * UNREADABLE_RETRY_MS, and reads nothing else. "The cloud holds none" is a
3530
- * fact. Either landing rings that repository, so one lane examines it
3531
- * again; a recovering one is asked the cloud again at its next ring. */
3532
2682
  detectRestore(authorityId) {
3533
2683
  return async (entityId, transportVersion, directory) => {
3534
2684
  const lost = this.lostBases.get(transportVersion);
@@ -3566,17 +2716,7 @@ export class UserGroundHost {
3566
2716
  throw new BaseFetching();
3567
2717
  };
3568
2718
  }
3569
- /** Download a set of immutable artifacts straight from content storage.
3570
- * The set is the primitive and the plan is physical: the engine resolves
3571
- * the whole want-list in two planned waves — manifests grouped by the
3572
- * pack that holds them, then blocks the same way — so all members of one
3573
- * pack collapse into a few broad ranged reads while standalone objects
3574
- * stay one read each. A lone artifact is a set of one. */
3575
- async downloadContentSet(resourceId, cacheDir, wants, retryAttempts = 10, trace, staged,
3576
- /** Hears each opened object's verified bytes as they land. */
3577
- onBytes,
3578
- /** The byte bound this set shares with other sets. */
3579
- sharedBytes) {
2719
+ async downloadContentSet(resourceId, cacheDir, wants, retryAttempts = 10, trace, staged, onBytes, sharedBytes) {
3580
2720
  const unique = new Map(wants.map((want) => [want.artifact.contentHash, want]));
3581
2721
  const sole = unique.size === 1 ? [...unique.values()][0]?.artifact : undefined;
3582
2722
  const started = performance.now();
@@ -3611,14 +2751,6 @@ export class UserGroundHost {
3611
2751
  this.cacheIndex ??= ContentCacheIndex.lease(cacheDir);
3612
2752
  let stagedSet = null;
3613
2753
  const targets = new Map();
3614
- // An Add stages ordinary files directly at their hidden final
3615
- // destination — except content this machine already holds sealed,
3616
- // which stays on the cache rail so a warm re-Add remains a local
3617
- // clone instead of a fresh download. Each artifact is routed when the
3618
- // engine first touches its blocks, never in one pass over the set: a
3619
- // route reads its cache file's stat, so a set of thousands would hold
3620
- // the thread, and a warm set touches no real I/O between artifacts, so
3621
- // each takes its turn (turns.ts) before it routes.
3622
2754
  const route = (artifact, layout) => {
3623
2755
  const found = targets.get(artifact.contentHash);
3624
2756
  if (found)
@@ -3634,8 +2766,6 @@ export class UserGroundHost {
3634
2766
  try {
3635
2767
  stagedSet = staged ? new StagedContentSet(staged.installments, staged.retained) : null;
3636
2768
  const hints = await legs.time("planMs", () => readLayoutHints(cacheDir, [...unique.values()].flatMap((want) => want.manifest ? [] : [want.artifact])));
3637
- // A held layout answers for its index and, past one manifest, for each
3638
- // part's manifest, which Live asks for by the part's own hash.
3639
2769
  const held = new Map();
3640
2770
  for (const layout of hints.values()) {
3641
2771
  held.set(layout.contentHash, layout.index);
@@ -3645,9 +2775,6 @@ export class UserGroundHost {
3645
2775
  const reads = this.directReads(resourceId, retryAttempts, legs);
3646
2776
  const { receipts, shape } = await downloadAllArtifacts([...unique.values()].map((want) => want.artifact), {
3647
2777
  sha256Hex: timedSha256Hex,
3648
- // The record's plan or this machine's own manifest cache already
3649
- // proves chunk identity; downloaded bytes are still hash-verified,
3650
- // so a stale local manifest can only fail loudly, never corrupt.
3651
2778
  localManifest: (artifact) => unique.get(artifact.contentHash)?.manifest
3652
2779
  ?? held.get(artifact.contentHash) ?? null,
3653
2780
  ...reads,
@@ -3658,7 +2785,6 @@ export class UserGroundHost {
3658
2785
  onBytes?.(plain.byteLength);
3659
2786
  return plain;
3660
2787
  },
3661
- // A proven manifest routes nothing yet: its first block does.
3662
2788
  manifestProven: async () => { },
3663
2789
  hasChunk: async (artifact, layout, index) => {
3664
2790
  await turnBoundary();
@@ -3703,19 +2829,7 @@ export class UserGroundHost {
3703
2829
  downloadedBytes,
3704
2830
  downloadedChunks,
3705
2831
  reusedChunks,
3706
- // `requests` is logical object reads; the plane deltas below are
3707
- // the physical facts — actual storage GETs, sealed bytes on the
3708
- // wire, refs round-trips, decrypt CPU. The legs place local time:
3709
- // plan (manifest cache + routing), fetch (storage waits, whose
3710
- // decrypt share the plane delta names), hash (chunk verification),
3711
- // reuse (retained-chunk re-proof), write (chunk placement), seal
3712
- // (whole-file proof assertion + duplicates), and idle — wall time
3713
- // with nothing in flight. The staged rail decomposes its own
3714
- // placement legs below; `stagedArtifacts` counts its placements.
3715
2832
  requests,
3716
- // The engine's own geometry: how manifests were known (local vs
3717
- // fetched, packed vs standalone) and how many planned pack spans
3718
- // carried the packed objects.
3719
2833
  ...shape,
3720
2834
  ...physicalPlaneDelta(planeBefore, this.direct.metrics()),
3721
2835
  ...legs.report(),
@@ -3747,8 +2861,6 @@ export class UserGroundHost {
3747
2861
  stagedSet?.close();
3748
2862
  }
3749
2863
  }
3750
- /** Prove a set's manifests from the authority and stop there, moving none
3751
- * of their blocks: content already sealed, named again elsewhere. */
3752
2864
  async proveContentManifests(resourceId, artifacts) {
3753
2865
  return fetchManifests(artifacts, {
3754
2866
  ...this.directReads(resourceId, DOWNLOAD_CONTENT_RETRY_ATTEMPTS, new TransferLegs()),
@@ -3759,13 +2871,6 @@ export class UserGroundHost {
3759
2871
  maxInFlightBytes: DIRECT_OBJECT_DOWNLOAD_MAX_IN_FLIGHT_BYTES,
3760
2872
  });
3761
2873
  }
3762
- /** Every storage object — manifests and blocks alike — is fetched straight
3763
- * from content storage over a presigned URL and opened locally; Live plans
3764
- * whole waves against these reads, so the wire carries only the key handoff
3765
- * and batched refs requests. A retried read refreshes its URL in place. If
3766
- * physical placement moved, Live discards every ref derived from that stale
3767
- * geometry and boundedly replans the unresolved set; content identity
3768
- * remains immutable. */
3769
2874
  directReads(resourceId, retryAttempts, legs) {
3770
2875
  return {
3771
2876
  requestRefs: async (objects) => legs.time("fetchMs", () => retryContent(this.wire.signal, () => this.direct.requestRefs(resourceId, objects), true, retryAttempts)),
@@ -3778,12 +2883,8 @@ export class UserGroundHost {
3778
2883
  signed = await refresh();
3779
2884
  }
3780
2885
  catch (error) {
3781
- // A moved placement is a set-planning signal owned by Live,
3782
- // not a permanent wire failure. Preserve it across the host
3783
- // retry boundary so the whole unresolved set can replan.
3784
2886
  if (isContentPlacementChangedError(error))
3785
2887
  throw error;
3786
- // A refused re-resolution is not a transient byte fetch.
3787
2888
  throw new WireRequestError({
3788
2889
  type: "shared.error",
3789
2890
  code: "entity_content_moved",
@@ -3826,15 +2927,17 @@ export class UserGroundHost {
3826
2927
  wanted.set(directory, {
3827
2928
  rootId: workspaceId,
3828
2929
  directory,
3829
- // Every materialized root has one reserved machine-control subtree.
3830
- // Apply stages and retains recovery bytes here; Watch never enrolls it.
3831
2930
  excludedSubtrees: [join(directory, LOCAL_DIR_NAME)],
3832
2931
  });
3833
2932
  }
3834
- // Outside Git storage is the last declaration; finished passes refresh it.
3835
2933
  this.watchGrounds = { identity, grounds: [...wanted.values()] };
3836
- // An owed baseline is spent by this reconcile whatever it answers: one
3837
- // that cannot settle the root's first coverage only costs its catch-up.
2934
+ this.sealedFolders.clear();
2935
+ if (!this.skipRulesSeeded) {
2936
+ this.skipRulesSeeded = true;
2937
+ this.skipRulesOwed.seed(groundDatabase(this.databasePath())
2938
+ .prepare(`SELECT ${GROUND_ROW_PROJECTION} FROM entities WHERE type = 'repo.git' AND status = 'active'`)
2939
+ .all());
2940
+ }
3838
2941
  const authoritativeBaselineRootIds = [...wanted.values()]
3839
2942
  .map(ground => ground.rootId)
3840
2943
  .filter(rootId => this.owedBaselines.delete(rootId));
@@ -3845,8 +2948,6 @@ export class UserGroundHost {
3845
2948
  if (health.state !== "healthy" || health.contentHandles < 1) {
3846
2949
  throw new Error(`Watch coverage is degraded: ${health.reason ?? "no content coverage"}`);
3847
2950
  }
3848
- // A root admitted on an authoritative baseline stands on the complete
3849
- // walk that verified it: no catch-up examination follows to warm it.
3850
2951
  for (const ground of wanted.values()) {
3851
2952
  if (authoritativeBaselineRootIds.includes(ground.rootId)) {
3852
2953
  this.warmDiscovery(ground.rootId, ground.directory);
@@ -3871,9 +2972,6 @@ export class UserGroundHost {
3871
2972
  this.gitStorage = { identity, dependencies: new GitStorageDependencies() };
3872
2973
  return this.gitStorage.dependencies;
3873
2974
  }
3874
- /** Repository membership and the ground a pass read keep Watch's outside
3875
- * Git storage current. A failed read is staged and leaves the last
3876
- * declaration standing; the next pass reads again. True when it changed. */
3877
2975
  refreshGitStorage(identity, read) {
3878
2976
  try {
3879
2977
  const database = groundDatabase(this.databasePath());
@@ -3886,8 +2984,6 @@ export class UserGroundHost {
3886
2984
  return false;
3887
2985
  }
3888
2986
  }
3889
- /** A finished pass may have read a repository whose outside storage moved,
3890
- * appeared or vanished, or changed which repositories exist. */
3891
2987
  passRead(identity, read) {
3892
2988
  const current = this.watchGrounds;
3893
2989
  if (this.closing || this.activeIdentity !== identity || current?.identity !== identity)
@@ -3895,33 +2991,22 @@ export class UserGroundHost {
3895
2991
  if (this.refreshGitStorage(identity, read))
3896
2992
  this.watchHost.reconcile(this.gitStorageOf(identity).declare(current.grounds));
3897
2993
  }
3898
- /** A ring reaches Detect in the next turn, so rings delivered together
3899
- * are read together and no timer stands between a write and its pass.
3900
- * A ring during a pass is the next pass's work (generation law). */
3901
2994
  ringDetect() {
3902
2995
  if (this.closing || this.detectRingQueued)
3903
2996
  return;
3904
2997
  this.detectRingQueued = true;
3905
2998
  this.nextTurn(() => {
3906
2999
  this.detectRingQueued = false;
3907
- // A ring may be the home holding this database leaving or returning.
3908
3000
  this.sayUnsettled();
3909
3001
  if (this.activeIdentity)
3910
3002
  this.wakeDetect();
3911
3003
  });
3912
3004
  }
3913
3005
  async acquireGroundScope(cones, options = {}) {
3914
- // A file changed in place rings no watcher at its other links. Once the
3915
- // effect releases, the entities known at those links are suspected.
3916
- // Whatever slots the effect's saves noted are committed by its release,
3917
- // so every ground effect wakes the placement tidy then.
3918
3006
  let declared = [];
3919
3007
  const inPlace = options.inPlace;
3920
3008
  const scoped = inPlace ? { ...options, inPlace: () => (declared = [...inPlace()]) } : options;
3921
3009
  const releaseGround = await this.ground.acquire(cones, scoped);
3922
- // Detect answered its crossings when it posted each save. Its grant is
3923
- // recorded now, so every save it could cross was posted before it: it
3924
- // acts only once they committed (ground-saver.ts).
3925
3010
  if (this.activeIdentity)
3926
3011
  await groundSaved(this.databasePath());
3927
3012
  return () => {
@@ -3932,8 +3017,6 @@ export class UserGroundHost {
3932
3017
  this.groundReleased();
3933
3018
  };
3934
3019
  }
3935
- /** Add holds its ground for its whole cold journey; no maintenance visit
3936
- * starts until it releases. */
3937
3020
  async holdWorkspaceAdd(cones) {
3938
3021
  this.workspaceAdds += 1;
3939
3022
  try {
@@ -3952,11 +3035,6 @@ export class UserGroundHost {
3952
3035
  this.watchHost.suspect(path);
3953
3036
  }
3954
3037
  }
3955
- /** A durable binding is registration evidence even if the native event
3956
- * that created it was lost across a crash. Rebuild coverage first, then
3957
- * express that uncertainty through Watch like every other Detect input.
3958
- * These are ambiguous recovery facts, so each affected root is wholly
3959
- * suspect; unrelated roots remain untouched. */
3960
3038
  repairRegistrationGround(identity) {
3961
3039
  const emptyRoots = emptyBoundRoots(this.databasePath(), this.bindingDir());
3962
3040
  if (emptyRoots.length === 0)
@@ -3965,13 +3043,10 @@ export class UserGroundHost {
3965
3043
  for (const root of emptyRoots)
3966
3044
  this.watchHost.suspect(root);
3967
3045
  }
3968
- /** A prepared lane holds its slot across one boundary, then activates.
3969
- * Whatever activation declines stays owed: the freed slot dispatches again,
3970
- * which prepares afresh. */
3971
3046
  startNamed(identity, kind, rootId, directory, paths, cones, prepareMs) {
3972
3047
  const lane = `${kind}:${rootId}`;
3973
3048
  const runtime = this.namedDetect, prepared = performance.now();
3974
- this.examinations.begin(lane, Examinations.examined(directory, cones));
3049
+ this.examinations.begin(lane, cones);
3975
3050
  this.namedAttempts.set(lane, (async () => {
3976
3051
  await turnBoundary();
3977
3052
  const activated = this.activateNamed(identity, runtime, rootId, directory, paths, cones);
@@ -3987,11 +3062,6 @@ export class UserGroundHost {
3987
3062
  this.laneFreed();
3988
3063
  }));
3989
3064
  }
3990
- /** ACTIVATE, one synchronous step. The runtime and the root's binding are
3991
- * those PREPARE read, or nothing is cut. Only names still owed are cut:
3992
- * newer names wait for a lane that prepared them. The prepared footprint is
3993
- * a proposal the collection enforces: storage it resolves outside the lease
3994
- * fails it for a wider retry, and admission re-checks the index it routed by. */
3995
3065
  activateNamed(identity, runtime, rootId, directory, paths, cones) {
3996
3066
  const at = performance.now();
3997
3067
  if (this.activeIdentity !== identity || this.namedDetect !== runtime || !this.watchHost.continuous())
@@ -4003,18 +3073,11 @@ export class UserGroundHost {
4003
3073
  const cut = paths.filter(path => owed.has(path));
4004
3074
  if (cut.length === 0)
4005
3075
  return { at, outcome: "settled" };
4006
- // Ground held since PREPARE: the freed slot's dispatch sets those names aside.
4007
3076
  const lease = this.ground.tryLease(cones);
4008
3077
  if (!lease)
4009
3078
  return { at, outcome: "ground-held" };
4010
3079
  return { at, outcome: "leased", paths: cut, lease };
4011
3080
  }
4012
- /** One root's named rings of one kind, cut now and proved by name or inside
4013
- * their repositories. The cut ends settled, escalated to the complete
4014
- * lane, or pending behind a park. Only what a later reading of the same
4015
- * names answers is parked here: what the narrow proof cannot conclude, a
4016
- * refusal or a fault, is escalated like a widened proof, since rerunning
4017
- * it unchanged would fail again and hold the root's later names behind it. */
4018
3081
  async namedLane(identity, kind, rootId, paths, lease) {
4019
3082
  const lane = `${kind}:${rootId}`;
4020
3083
  const observation = this.watchHost.freezePaths(rootId, paths);
@@ -4022,7 +3085,6 @@ export class UserGroundHost {
4022
3085
  this.coverMaintenance(cuts);
4023
3086
  let failure = null;
4024
3087
  try {
4025
- // COLLECT reads under the open lease; any effect granted meanwhile crosses it.
4026
3088
  await turnBoundary();
4027
3089
  await this.discoverAliases(cuts);
4028
3090
  if (observation?.suspicion.paths?.length) {
@@ -4035,7 +3097,6 @@ export class UserGroundHost {
4035
3097
  catch (caught) {
4036
3098
  const error = this.laneCause(caught, cuts);
4037
3099
  if (!unsettledGround(error) && observationDisposition(error, "named").retry === "complete-lane") {
4038
- // The complete proof answers these names' tickets.
4039
3100
  this.stage({ primitive: "detect", stage: "named", status: "observed", rootId, measurements: {
4040
3101
  lane: kind, outcome: "escalated", error: error instanceof Error ? error.message : String(error)
4041
3102
  } });
@@ -4046,7 +3107,6 @@ export class UserGroundHost {
4046
3107
  this.unpark(lane);
4047
3108
  }
4048
3109
  else {
4049
- // Ground still moving or unreadable fails no ticket, as in the complete lane.
4050
3110
  if (!waits(error))
4051
3111
  failure = { error };
4052
3112
  this.park(lane, new Map(cuts.map(cut => [cut.rootId, cut.suspicion.generation])), error);
@@ -4066,10 +3126,6 @@ export class UserGroundHost {
4066
3126
  this.stage({ primitive: "detect", stage: "pass", status: "started", rootId: observation.rootId,
4067
3127
  measurements: { lane: "named", roots: 1, namedPaths: observation.suspicion.paths?.length ?? 0, ...this.laneState() } });
4068
3128
  let named;
4069
- // Collection holds no ground: Apply may reveal while Detect reads. The
4070
- // lease opened before the cut; its admission requires it uncrossed. The
4071
- // pass fences the cached names it trusts until its Records commit or it
4072
- // is abandoned (content-cache-fences.ts).
4073
3129
  try {
4074
3130
  named = await fencing(() => this.namedDetect.detect(observation, (unit, basis) => pass.collections([{ observations: [observation], unit, basis: basis.describe() }])[0], lease));
4075
3131
  }
@@ -4102,7 +3158,6 @@ export class UserGroundHost {
4102
3158
  }
4103
3159
  const observed = [...named.observedEntityIds];
4104
3160
  this.answerWaits(named.waits);
4105
- // Changed ground found beside the named names owes its own examination.
4106
3161
  for (const path of named.examine ?? [])
4107
3162
  this.watchHost.suspect(path);
4108
3163
  let settled = false;
@@ -4114,28 +3169,19 @@ export class UserGroundHost {
4114
3169
  ...(named.detail ? { detail: named.detail } : {}),
4115
3170
  scope: named.roots === "domain" ? "domain" : beyond ? "roots" : "root" } });
4116
3171
  pass.close({ disposition: "cancelled", retry: "complete-lane", reason: `named proof widened: ${named.proof}` });
4117
- // These names are now owed a complete proof at their original
4118
- // generations; the named lane never offers them again.
4119
3172
  this.watchHost.escalate(observation);
4120
3173
  this.escalateMaintenance(observation);
4121
- // Storage notices can belong to a checkout in another Watch root.
4122
3174
  if (beyond)
4123
3175
  this.watchHost.suspectDomain();
4124
3176
  return;
4125
3177
  }
4126
3178
  if (named.kind === "retry") {
4127
- // A changed consumer relation is never downgraded into root-local
4128
- // reconciliation. Its original notice needs a fresh routing answer.
4129
3179
  this.stage({ primitive: "detect", stage: "named", status: "observed", rootId: observation.rootId,
4130
3180
  path: observation.directory, measurements: { outcome: "retry", reason: named.reason, ...namedTimings(named) } });
4131
- // An effect crossed this attempt. Its cut stays pending and this lane
4132
- // ends holding nothing; the release of that effect dispatches it again.
4133
3181
  if (named.after === "ground-release") {
4134
3182
  pass.close({ disposition: "invalidated", retry: "ground-release", reason: named.reason });
4135
3183
  return;
4136
3184
  }
4137
- // Moved ground fails no ticket, as in the complete lane: the cut is
4138
- // read again now where a commit moved it, otherwise when it settles.
4139
3185
  pass.close({ disposition: "invalidated", retry: "timer", reason: named.reason });
4140
3186
  throw new DetectResidual([observation.directory], [], { settlesInMs: named.after === "now" ? COMMITTED_SETTLES_IN_MS : DETECT_RETRY_MS });
4141
3187
  }
@@ -4148,8 +3194,6 @@ export class UserGroundHost {
4148
3194
  durationMs: performance.now() - started, measurements: { lane: "named", roots: 1, records, ...namedTimings(named) } });
4149
3195
  }
4150
3196
  finally {
4151
- // Commits already made stay useful even when this cut stays pending.
4152
- // The rails follow in their own turn, after this commit's task ends.
4153
3197
  const served = settled ? [observation] : [];
4154
3198
  if (settled || observed.length)
4155
3199
  this.nextTurn(() => this.wakeObservedApply(served, observed));
@@ -4157,16 +3201,10 @@ export class UserGroundHost {
4157
3201
  this.nextTurn(() => this.recordRail?.localRecordsAvailable());
4158
3202
  }
4159
3203
  }
4160
- /** Names in a repository's Git storage are read by the complete lane's own
4161
- * repository handler and per-unit admission, without waiting behind a
4162
- * complete proof. Names that need a wider proof are escalated to it. */
4163
3204
  async proveRepositories(identity, observation, lease) {
4164
3205
  if (!this.detectLedger)
4165
3206
  throw new Error("Detect runs only after its disposition ledger opens");
4166
3207
  const pass = this.detectLedger.pass(++this.detectJobs, 1, [observation]);
4167
- // Collection holds no ground; the lease opened before the cut covers
4168
- // these repositories and admission requires it uncrossed. The pass fences
4169
- // what it trusts in the cache until it ends (content-cache-fences.ts).
4170
3208
  try {
4171
3209
  const outcome = await fencing(() => this.syncLocalChangesUnlocked(identity, [observation], pass, async () => lease, "repository"));
4172
3210
  if (outcome === "widen") {
@@ -4179,8 +3217,6 @@ export class UserGroundHost {
4179
3217
  pass.close(UNDISPOSED);
4180
3218
  }
4181
3219
  catch (error) {
4182
- // A proof that read beyond its lease leaves its cut pending; the lease
4183
- // learned that ground, so the next attempt holds the wider footprint.
4184
3220
  const exceeded = footprintExceeded(error);
4185
3221
  if (exceeded) {
4186
3222
  pass.close({ disposition: "invalidated", retry: "ground-release", reason: exceeded.message });
@@ -4190,9 +3226,6 @@ export class UserGroundHost {
4190
3226
  throw error;
4191
3227
  }
4192
3228
  }
4193
- /** A cut's alias hints are decided before its proof settles them: what they
4194
- * owe rings as a later generation, the domain only when a hint cannot bound
4195
- * its objects. */
4196
3229
  async discoverAliases(cuts) {
4197
3230
  const owed = await aliasDiscovery(cuts, operation => {
4198
3231
  const database = groundDatabase(this.databasePath());
@@ -4210,9 +3243,6 @@ export class UserGroundHost {
4210
3243
  for (const path of owed.names)
4211
3244
  this.watchHost.suspect(path);
4212
3245
  }
4213
- /** One maintenance visit of a Watch root, against O as it stands. A visit
4214
- * that read the whole namespace and could trust O at its root is a complete
4215
- * walk that stands. */
4216
3246
  async maintainRoot(directory) {
4217
3247
  const identity = this.activeIdentity;
4218
3248
  if (!identity)
@@ -4228,16 +3258,11 @@ export class UserGroundHost {
4228
3258
  }
4229
3259
  return result;
4230
3260
  }
4231
- /** Each cut captures, before its proof reads, the maintenance requests that
4232
- * proof answers: a named cut those at and beneath its paths, a complete cut
4233
- * every promoted one. */
4234
3261
  coverMaintenance(cuts) {
4235
3262
  for (const cut of cuts) {
4236
3263
  this.maintenanceCoverage.set(cut, this.maintenance.cover(cut.rootId, cut.suspicion.paths));
4237
3264
  }
4238
3265
  }
4239
- /** Proved cuts answer what they covered, except at and beneath the paths
4240
- * they could not prove; failed, deferred or cancelled ones never do. */
4241
3266
  maintenanceServed(cuts, unproved = []) {
4242
3267
  for (const cut of cuts) {
4243
3268
  const coverage = this.maintenanceCoverage.get(cut);
@@ -4245,9 +3270,6 @@ export class UserGroundHost {
4245
3270
  this.maintenance.served(coverage, unproved);
4246
3271
  }
4247
3272
  }
4248
- /** An escalated cut's requests are owed to the wider proof. Watch escalates
4249
- * only its own names, so the sweep's are escalated beside them: the
4250
- * complete lane proves those paths, not the whole root. */
4251
3273
  escalateMaintenance(cut) {
4252
3274
  const coverage = this.maintenanceCoverage.get(cut);
4253
3275
  if (coverage && this.maintenance.promote(coverage)) {
@@ -4263,18 +3285,13 @@ export class UserGroundHost {
4263
3285
  this.laneFreed();
4264
3286
  });
4265
3287
  }
4266
- /** The complete lane examines the ground its cuts read. */
4267
3288
  examineCuts(cuts) {
4268
- this.examinations.begin("complete", cuts.flatMap(cut => Examinations.examined(cut.directory, this.cutFootprint(cut.directory, cut.suspicion.paths))));
3289
+ this.examinations.begin("complete", cuts.flatMap(cut => this.cutFootprint(cut.directory, cut.suspicion.paths)));
4269
3290
  }
4270
- /** Whole-root proofs, one attempt at a time. Every cut it freezes is
4271
- * released when it ends, proved or not. */
4272
3291
  async completeLane(identity, boundary, cuts) {
4273
3292
  const held = [cuts];
4274
3293
  let failure = null;
4275
3294
  try {
4276
- // Its cut and slot are held from dispatch; the examination starts in
4277
- // its own turn, never inside the task of the attempt that widened.
4278
3295
  await awaitTurn();
4279
3296
  await this.discoverAliases(cuts);
4280
3297
  await this.syncObservationCuts(identity, boundary, cuts, held);
@@ -4284,8 +3301,6 @@ export class UserGroundHost {
4284
3301
  }
4285
3302
  }
4286
3303
  catch (caught) {
4287
- // Ground still moving or unreadable fails no ticket: the lane waits for
4288
- // its next ring or a timer, and then proves the rest.
4289
3304
  const error = this.laneCause(caught, held.flat());
4290
3305
  if (!waits(error))
4291
3306
  failure = { error };
@@ -4307,14 +3322,8 @@ export class UserGroundHost {
4307
3322
  this.ensureWatchers(identity);
4308
3323
  }
4309
3324
  catch {
4310
- // Watch reports the degraded coverage and owns its reopening; healthy
4311
- // coverage rings the roots again, so no Detect timer waits for it.
4312
3325
  }
4313
3326
  }
4314
- /** One complete attempt owns at most one complete-domain continuation, over
4315
- * its finite original cutoffs. Each pass admits what it proved; whatever
4316
- * moved stays pending for its next ring or a short timer, never a retry
4317
- * inside this turn. */
4318
3327
  async syncObservationCuts(identity, boundary, selected, held) {
4319
3328
  let pending = selected;
4320
3329
  let promoted = false;
@@ -4323,9 +3332,6 @@ export class UserGroundHost {
4323
3332
  for (;;) {
4324
3333
  if (!this.watchHost.boundaryCurrent(boundary))
4325
3334
  throw new DetectionBasisAdvancedError();
4326
- // Collection holds no ground: Apply may reveal while Detect reads. The
4327
- // lease opens once no conflicting effect is held, before reading; each
4328
- // unit's admission requires that no later effect crossed its reads.
4329
3335
  const leases = [];
4330
3336
  const lease = async (cones) => {
4331
3337
  const opened = await this.ground.lease(cones, "complete", this.wire.signal);
@@ -4334,8 +3340,6 @@ export class UserGroundHost {
4334
3340
  };
4335
3341
  let continuation;
4336
3342
  try {
4337
- // The pass fences the cached names it trusts until its Records
4338
- // commit or it is abandoned (content-cache-fences.ts).
4339
3343
  continuation = await fencing(async () => {
4340
3344
  let frozen = null;
4341
3345
  if (!this.detectLedger)
@@ -4350,8 +3354,6 @@ export class UserGroundHost {
4350
3354
  retry: confined ? "timer" : "same-turn" });
4351
3355
  if (confined)
4352
3356
  throw new DetectionBasisAdvancedError();
4353
- // Freeze the continuation before releasing these cones. Later rings
4354
- // cannot replace its cutoff or buy another foreground opportunity.
4355
3357
  this.watchHost.suspectDomain();
4356
3358
  frozen = this.watchHost.freeze();
4357
3359
  this.coverMaintenance(frozen);
@@ -4377,12 +3379,6 @@ export class UserGroundHost {
4377
3379
  pending = continuation;
4378
3380
  }
4379
3381
  }
4380
- /** Complete observations are examined on content threads, concurrently:
4381
- * disk and Git against O by the main walk's own laws, and O against its
4382
- * selection standing in B. A root that proves unchanged is not walked
4383
- * here, and one whose differences a scope can hold is examined only
4384
- * there; any other answers with the first reason, and the main walk
4385
- * observes it. */
4386
3382
  async examineQuietRoots(identity, observations, lease) {
4387
3383
  const quiet = new Map();
4388
3384
  const scoped = new Map();
@@ -4404,7 +3400,6 @@ export class UserGroundHost {
4404
3400
  scoped.set(directory, request.root);
4405
3401
  return;
4406
3402
  }
4407
- // Any complete walk of the root answers what a refused scope owed.
4408
3403
  const owed = this.walkOwed.delete(directory);
4409
3404
  if (nested) {
4410
3405
  fallbacks.set(directory, "nested");
@@ -4418,19 +3413,15 @@ export class UserGroundHost {
4418
3413
  const started = performance.now();
4419
3414
  let result;
4420
3415
  for (let reading = 1;; reading++) {
4421
- // The stamp precedes every read the examination takes.
4422
3416
  const { boundary: clock } = await stampContentClock(database, directory);
4423
- // A fault here costs only this shortcut; the main walk answers for it.
4424
3417
  try {
4425
3418
  result = await examineRootContent({ purpose: "admission", database, cacheDir: this.cacheDir(), resourceId,
4426
- rootPath: directory, homePath: this.userRoot(), core, clock });
3419
+ rootPath: directory, core, clock });
4427
3420
  }
4428
3421
  catch (error) {
4429
3422
  fallbacks.set(directory, `fault:${error instanceof Error ? error.message : String(error)}`);
4430
3423
  return;
4431
3424
  }
4432
- // Waiting cannot close a racy listing; a fresh one under a later stamp can.
4433
- // One timed beyond the horizon no near stamp qualifies: the walk closes it.
4434
3425
  if (result.kind !== "racy" || reading === RACY_READINGS || result.retryMs > RACY_HORIZON_MS)
4435
3426
  break;
4436
3427
  const wait = result.retryMs;
@@ -4445,7 +3436,6 @@ export class UserGroundHost {
4445
3436
  return;
4446
3437
  }
4447
3438
  this.gitStorageOf(identity).hold(result.brokenMarkers);
4448
- // Differences are examined along their own names alone.
4449
3439
  const request = result.differences.length ? rootScope(observation.suspicion, result) : null;
4450
3440
  try {
4451
3441
  lease.require(result.footprints);
@@ -4458,8 +3448,6 @@ export class UserGroundHost {
4458
3448
  }
4459
3449
  const physical = new PackedPhysicalKeys(result.physical);
4460
3450
  lease.physical(physical);
4461
- // What returned shows again before the scope reads it, on the revision
4462
- // the examination compared against: the scope then stands on the next.
4463
3451
  let revision = result.revision;
4464
3452
  if (result.returned.length) {
4465
3453
  const revealed = await save(database, "detect.reveal", { rootUUID: result.rootUUID, revision, returned: result.returned });
@@ -4485,15 +3473,6 @@ export class UserGroundHost {
4485
3473
  }));
4486
3474
  return { quiet, scoped, fallbacks, promoted };
4487
3475
  }
4488
- /** A root's first absence would otherwise list its whole namespace while an
4489
- * edit waits. Once a complete walk of the root stands (Register's walk,
4490
- * an Add's verified install, a complete examination, or a maintenance visit
4491
- * that read it whole), the discovery thread lists it in the background, so a
4492
- * later absence re-reads only directories whose signatures moved. It seeks
4493
- * nothing and concludes nothing: when it cannot close, the next discovery
4494
- * reads cold, as it would have. Its stamp and listing read the ground, so
4495
- * close drains it (detectDrained); one that starts after close began does
4496
- * nothing. */
4497
3476
  warmDiscovery(rootUUID, directory) {
4498
3477
  void this.backgroundRead(awaitTurn().then(async () => {
4499
3478
  if (this.closing)
@@ -4525,10 +3504,6 @@ export class UserGroundHost {
4525
3504
  report(result.kind === "gap" ? `gap:${result.reason}` : result.kind, result.stats);
4526
3505
  }));
4527
3506
  }
4528
- /** Names a named proof escalated are examined along those names, by the
4529
- * same handler a pooled examination's differences use. Nothing else of the
4530
- * root is read. A name inside Git storage is its repository's `.git`; the
4531
- * root's own address is its boundary and needs the whole root. */
4532
3507
  directScope(observation) {
4533
3508
  const { directory } = observation;
4534
3509
  const roots = groundStore(groundDatabase(this.databasePath()))
@@ -4555,12 +3530,10 @@ export class UserGroundHost {
4555
3530
  async syncLocalChangesUnlocked(identity, pending, pass, lease, lane = "complete") {
4556
3531
  if (!this.authorityId)
4557
3532
  throw new Error("cloud state is unavailable for user-ground Watch");
4558
- // A repository lane proves one root's cut; its passes pair by that root.
4559
3533
  const laneRootId = lane === "repository" ? { rootId: pending[0].rootId } : {};
4560
3534
  if (!this.watchHost.bindingsCurrent(pending))
4561
3535
  throw new DetectionBasisAdvancedError();
4562
3536
  const passStarted = performance.now();
4563
- // No lane preempts a complete examination; it stops only for shutdown.
4564
3537
  const checkpoint = () => {
4565
3538
  if (this.wire.signal.aborted)
4566
3539
  throw new DetectCancelled();
@@ -4576,8 +3549,6 @@ export class UserGroundHost {
4576
3549
  const reconcileObservations = pending;
4577
3550
  const missingOwners = missingReconciliationOwners(new Set(reconcileSuspicions.keys()), this.watchHost.evidence().roots);
4578
3551
  if (missingOwners.length > 0) {
4579
- // The next pass must acquire the wider cone and its own Watch cutoff.
4580
- // Leave nested observations pending; never settle unexamined ground.
4581
3552
  this.stage({ primitive: "detect", stage: "coverage-owner-needed", status: "observed",
4582
3553
  measurements: { roots: missingOwners.length } });
4583
3554
  return "widen";
@@ -4585,8 +3556,6 @@ export class UserGroundHost {
4585
3556
  const completeDomain = reconcileObservations.some(observation => observation.domain !== undefined);
4586
3557
  const reconcileLease = await lease(reconcileObservations.flatMap(({ directory, suspicion }) => this.cutFootprint(directory, suspicion.paths)));
4587
3558
  const userRoot = this.userRoot();
4588
- // A quiet root is examined off this thread and walked here only when that
4589
- // examination cannot conclude.
4590
3559
  const { quiet, scoped, fallbacks, promoted } = await this.examineQuietRoots(identity, reconcileObservations, reconcileLease);
4591
3560
  const walkedSuspicions = new Map([...reconcileSuspicions]
4592
3561
  .filter(([directory]) => !quiet.has(directory) && !scoped.has(directory) && !promoted.has(directory)));
@@ -4631,8 +3600,6 @@ export class UserGroundHost {
4631
3600
  this.answerWaits(scanned.waits);
4632
3601
  for (const root of scanned.roots)
4633
3602
  this.gitStorageOf(identity).hold(root.units.walk.brokenMarkers);
4634
- // Close every source outside SQLite. Slower owners answer first, one at a
4635
- // time, before any walk closes; what moved defers only what read it.
4636
3603
  const failed = new Map(scanned.roots.flatMap(root => [...root.units.failed]));
4637
3604
  const invalidatedRoots = new Map(scanned.invalidatedRoots
4638
3605
  .map(({ directory, ...movement }) => [directory, movement]));
@@ -4654,17 +3621,11 @@ export class UserGroundHost {
4654
3621
  }
4655
3622
  const promotions = new Map([...promoted,
4656
3623
  ...[...scanned.promotions].map(([directory, reason]) => [directory, { kind: "wider", scope: "root", reason }])]);
4657
- // Ground this pass could not examine defers only the units needing it. A
4658
- // domain participant owned by Apply, moved, or partly unlisted may hide
4659
- // where a missing identity went, so the domain's absence decisions wait.
4660
- // A root the pass could not reach is unread ground like any directory a
4661
- // walk could not list.
4662
3624
  const unreadable = new Map([...scanned.roots.flatMap(root => [...root.units.unread]),
4663
3625
  ...scanned.unreachableRoots.map(({ directory, reason }) => [directory, { reason, directory: true }])]);
4664
3626
  const unlisted = new Map(scanned.roots.flatMap(root => root.units.namespace === null ? [] : [[root.rootUUID, root.units.namespace]]));
4665
3627
  const unexaminedRoots = [...new Set([...scanned.unexaminedParticipants, ...invalidatedRoots.keys()])];
4666
3628
  const gaps = {
4667
- // An address is unread when it, or an unlisted directory above it, is.
4668
3629
  unread: (address) => {
4669
3630
  const exact = unreadable.get(address);
4670
3631
  if (exact)
@@ -4696,8 +3657,6 @@ export class UserGroundHost {
4696
3657
  returned: scanned.returned,
4697
3658
  reveals: scanned.reveals,
4698
3659
  });
4699
- // Only a unit consults a walk's closure; a pass that admits nothing
4700
- // re-reads none of its sources.
4701
3660
  const closures = new Map();
4702
3661
  if (units.length)
4703
3662
  for (const root of scanned.roots) {
@@ -4712,8 +3671,6 @@ export class UserGroundHost {
4712
3671
  return undefined;
4713
3672
  };
4714
3673
  const allClosures = [...closures.values()];
4715
- // The nearest walk at or above an address answers for it: a repository's
4716
- // scope stands inside its root's. Each directory's owner is found once.
4717
3674
  const owners = new Map();
4718
3675
  const closureOf = (address) => {
4719
3676
  const walked = [];
@@ -4743,9 +3700,6 @@ export class UserGroundHost {
4743
3700
  const reason = unit.unsettled(closureOf, allClosures);
4744
3701
  return reason ? moving(reason) : undefined;
4745
3702
  };
4746
- // A unit waits on its first cause, in the order an observation answers
4747
- // them: a fault, moved ground, unreadable ground, then ground owed to
4748
- // the effect writing it.
4749
3703
  const faulted = [];
4750
3704
  const deferred = [];
4751
3705
  const waiting = [];
@@ -4781,8 +3735,6 @@ export class UserGroundHost {
4781
3735
  ready.push(unit);
4782
3736
  }
4783
3737
  await persistRecordCargo(this.cacheDir(), ready.flatMap(unit => unit.writes.proposals.flatMap(proposal => proposal.cargo.map(artifact => artifact.contentHash))));
4784
- // Each new subtree goes out as one package (Live packageProposals). Its
4785
- // members' content was persisted above, so its pages name durable bytes.
4786
3738
  const packagePages = new Map();
4787
3739
  for (const [index, unit] of ready.entries()) {
4788
3740
  const { proposals, pages } = await finishStepsInTurns(packageProposalsSteps(unit.writes.proposals, sha256Hex));
@@ -4792,13 +3744,11 @@ export class UserGroundHost {
4792
3744
  ready[index] = packaged;
4793
3745
  packagePages.set(packaged, pages.map(page => ({ sha256: page.ref.sha256, bytes: page.bytes })));
4794
3746
  }
4795
- // Last scheduling handoff precedes each unit's final validation and admission.
4796
3747
  checkpoint();
4797
3748
  const authorityId = this.authorityId;
4798
3749
  const cursors = this.recordStore?.readEntityCursors(authorityId, ready.flatMap(unit => unit.writes.proposals.map(proposal => proposal.entityId))) ?? new Map();
4799
3750
  const physicalReads = new PhysicalKeySet(...scanned.roots.map(root => root.units.physicalReads));
4800
- // A unit consumes each discovery that answered for one of its members:
4801
- // it reads the discovery's scope and stands on its qualification.
3751
+ const gitRoutes = new Map(scanned.roots.flatMap(root => [...root.units.gitRoutes]));
4802
3752
  const discoveries = [...scanned.scopedRoots.values()].flatMap(root => root.discovery ? [root.discovery] : []);
4803
3753
  const consumed = (unit) => discoveries.filter(discovery => unit.members.some(uuid => discovery.uuids.has(uuid)));
4804
3754
  const scopeOf = (consumers) => groundBasis.scope(keys => {
@@ -4835,7 +3785,7 @@ export class UserGroundHost {
4835
3785
  const result = await admitDetectedUnits(database, batch.map((unit, index) => ({
4836
3786
  unit,
4837
3787
  collection: collections[index],
4838
- crossed: () => reconcileLease.crosses(unit.reads(physicalReads, consumed(unit))),
3788
+ crossed: () => reconcileLease.crosses(unit.reads(physicalReads, consumed(unit), gitRoutes)),
4839
3789
  basis: bases[index],
4840
3790
  pages: packagePages.get(unit) ?? [],
4841
3791
  sources: [
@@ -4849,7 +3799,6 @@ export class UserGroundHost {
4849
3799
  if (!this.watchHost.bindingsCurrent(reconcileObservations))
4850
3800
  throw new DetectionBasisAdvancedError();
4851
3801
  },
4852
- // Build settled against these accepted answers; one that moved re-collects.
4853
3802
  accepted: scanned.accepted,
4854
3803
  observe: this.options.onDetectCommit !== undefined,
4855
3804
  authorityId,
@@ -4909,34 +3858,23 @@ export class UserGroundHost {
4909
3858
  entityId: record.entityId, mutationId: record.mutationId, durationMs: admissionDuration,
4910
3859
  measurements: { records: recorded.length } });
4911
3860
  }
4912
- // Each committed name owes its object's other names (alias-examination.ts).
4913
3861
  if (committedNames.length) {
4914
3862
  const owed = groundStore(database).readSnapshot(reader => aliasExaminations(committedNames, {
4915
3863
  objectRows: key => reader.objectRows("entities", key), physical: uuid => reader.physical(uuid),
4916
3864
  })).value;
4917
3865
  for (const path of owed)
4918
3866
  this.watchHost.suspect(path);
4919
- // A committed change to the home's policy owes every root its
4920
- // selection under the text this admission closed on (policy-owed.ts).
4921
- const roots = this.policyRoots();
4922
- const home = scanned.roots.find(root => root.rootUUID === roots.find(root => root.home)?.rootUUID);
4923
- if (home && policyChanged(committedNames, roots)) {
4924
- for (const path of await policyExaminations(database.name, home.units.policy, roots))
4925
- this.watchHost.suspect(path);
3867
+ const policy = this.skipRulesOwed.owed(committedNames, this.policyRoots());
3868
+ for (const path of policy.reaches.length ? await policyExaminations(database.name, policy) : []) {
3869
+ this.watchHost.suspect(path);
4926
3870
  }
4927
3871
  }
4928
- // The last admission's transaction ends its task. Send's drain starts
4929
- // in the next turn; what the examinations may still claim is checked and
4930
- // installed together in the turn after, against the state then.
4931
3872
  this.nextTurn(() => this.recordRail?.localRecordsAvailable());
4932
3873
  if (batches > 0) {
4933
3874
  await awaitTurn();
4934
3875
  checkpoint();
4935
3876
  }
4936
3877
  const postCommitStarted = performance.now();
4937
- // A quiet root's examination must still stand now: no effect crossed
4938
- // what it read, its binding held, and no row of its O or B was written.
4939
- // Policy stood through the examination; a later edit rings again.
4940
3878
  for (const [directory, { observation, result, physical }] of quiet) {
4941
3879
  const movement = reconcileLease.crosses({ entries: [directory, ...result.footprints], physical })
4942
3880
  ? moving("a ground effect crossed its examination")
@@ -4946,14 +3884,9 @@ export class UserGroundHost {
4946
3884
  if (movement !== null)
4947
3885
  invalidatedRoots.set(directory, movement);
4948
3886
  }
4949
- // A scoped root stands on its pooled examination everywhere else, when
4950
- // one read it: no writer but this pass touched it. Nothing may have
4951
- // crossed what either kind read, and its binding must have held.
4952
3887
  const foreign = foreignRoots(database, groundBasis, { stamped, roots: ourRoots }, scanned.before);
4953
3888
  for (const [directory, { discovery, tops, chain }] of scanned.scopedRoots) {
4954
3889
  const { observation, request, pooled } = scoped.get(directory);
4955
- // A scope read each top whole and each container on the way as its
4956
- // entry list. A discovered absence read the root's whole namespace.
4957
3890
  const reads = pooled ? { entries: [directory, ...pooled.result.footprints], physical: pooled.physical } : {
4958
3891
  entries: discovery?.entries ?? scopeGround(directory, tops),
4959
3892
  namespaces: chain.map(path => path ? join(directory, path) : directory),
@@ -4966,10 +3899,8 @@ export class UserGroundHost {
4966
3899
  if (movement !== null)
4967
3900
  invalidatedRoots.set(directory, movement);
4968
3901
  }
4969
- // An observation settles only when nothing under it waits.
4970
3902
  const reasonAt = (withheld) => (directory) => withheld.find(({ unit }) => within(directory, unit))?.reason;
4971
3903
  const faultAt = reasonAt(faulted), waitingAt = reasonAt(waiting), owedAt = reasonAt(owed);
4972
- // Ground moved across a whole root, or beneath it unit by unit.
4973
3904
  const rootMovedAt = (directory) => [...invalidatedRoots]
4974
3905
  .filter(([root]) => pathWithin(root, directory) || pathWithin(directory, root)).map(([, movement]) => movement);
4975
3906
  const deferredAt = (directory) => deferred.filter(({ unit }) => within(directory, unit));
@@ -4980,24 +3911,11 @@ export class UserGroundHost {
4980
3911
  const promotion = promotions.get(observation.directory);
4981
3912
  const fault = faultAt(observation.directory);
4982
3913
  const rootMoves = rootMovedAt(observation.directory), moved = deferredAt(observation.directory);
4983
- // Of every cause moving a root, the one settling first retries it.
4984
3914
  const movement = firstSettling([...rootMoves, ...moved.map(({ movement }) => movement)]);
4985
3915
  const gap = unreadAt(observation.directory);
4986
- // An unavailable volume is the exact bound root's; a root bound beneath
4987
- // it answers for itself.
4988
3916
  const offDevice = scanned.offDeviceRoots.get(observation.directory);
4989
3917
  const refusal = offDevice;
4990
3918
  if (promotion) {
4991
- // A wider proof is owed from this cut's own rings; its names are
4992
- // escalated to it, so no named lane offers them again, and nothing
4993
- // here is retried. An identity that crossed to an address this cut
4994
- // did not hold owes one named proof along the grown names. A proof
4995
- // that read every name its crossing claims proved both ends, so the
4996
- // claim contradicts its own proof: a fault, never a wider read. Any
4997
- // other refusal owes the complete root at the rings' own arrivals, or
4998
- // every root. A pooled examination already read the complete root:
4999
- // the same scope would refuse again, so the root it owes is the main
5000
- // walk's.
5001
3919
  const refusedScope = scoped.get(observation.directory);
5002
3920
  const crossing = scanned.crossings.get(observation.directory) ?? [], held = observation.suspicion.paths;
5003
3921
  const grows = held !== null && crossing.some(name => !held.some(path => name === path || name.startsWith(`${path}/`)));
@@ -5011,7 +3929,6 @@ export class UserGroundHost {
5011
3929
  this.walkOwed.add(observation.directory);
5012
3930
  this.watchHost.escalate(observation);
5013
3931
  this.escalateMaintenance(observation);
5014
- // The escalated cut keeps every name it held; a crossed name it did not hold is rung.
5015
3932
  if (grows)
5016
3933
  this.watchHost.escalatePaths(observation.rootId, crossing);
5017
3934
  else if (promotion.scope === "domain")
@@ -5023,24 +3940,15 @@ export class UserGroundHost {
5023
3940
  : `scope promoted to ${promotion.scope}: ${promotion.reason}` });
5024
3941
  continue;
5025
3942
  }
5026
- // A root off its device answered its doorbell: its retained rows
5027
- // remain unchanged and its last complete result stays official. It is
5028
- // reported whatever else holds its observation, and never retried
5029
- // until its ground rings again, or restart or maintenance suspects it.
5030
3943
  if (refusal !== undefined) {
5031
3944
  this.rootsOffDevice.set(observation.directory, refusal);
5032
3945
  this.stage({ primitive: "detect", stage: "root-off-device", status: "observed",
5033
3946
  rootId: observation.rootId, path: observation.directory, measurements: { reason: refusal } });
5034
3947
  }
5035
- // Every cause under a root is named; the one disposition only decides
5036
- // how the lane retries.
5037
3948
  if (movement !== undefined)
5038
3949
  unsettled.set(observation.directory, movement);
5039
3950
  if (gap !== undefined)
5040
3951
  unexamined.push({ directory: observation.directory, reason: gap });
5041
- // A complete examination proved all but the units a fault stopped or
5042
- // whose ground moved: they stay owed by their own addresses, and the
5043
- // retry reads only them, never the whole root again.
5044
3952
  const narrowTo = (withheld) => {
5045
3953
  if (observation.suspicion.paths !== null || rootMoves.length > 0 || gap !== undefined
5046
3954
  || withheld.some(({ unit }) => unit.addresses.length === 0))
@@ -5061,10 +3969,6 @@ export class UserGroundHost {
5061
3969
  pass.dispose([observation], { disposition: "unavailable", retry: "timer", reason: gap });
5062
3970
  }
5063
3971
  else {
5064
- // Ground another effect is writing (a repository whose base is still
5065
- // coming back, an object an open Apply window shows) is left as it
5066
- // was, and the rest of its root is admitted: that effect, not a
5067
- // timer, rings it alone when it ends. Each stage names what waits.
5068
3972
  const writing = owed.filter(({ unit }) => within(observation.directory, unit));
5069
3973
  for (const { address, reason } of writing) {
5070
3974
  this.stage({ primitive: "detect", stage: "ground-owed", status: "observed",
@@ -5081,9 +3985,6 @@ export class UserGroundHost {
5081
3985
  && within(observation.directory, unit)) ? "admitted" : "examined-no-change" });
5082
3986
  }
5083
3987
  }
5084
- // A complete examination that stands, quiet or walked with its namespace
5085
- // closed, and that no other writer crossed, warms discovery for the
5086
- // root's next absence.
5087
3988
  if (foreign !== null) {
5088
3989
  for (const { directory, suspicion } of settled) {
5089
3990
  if (suspicion.paths !== null || scanned.scopedRoots.has(directory) || owedAt(directory) !== undefined)
@@ -5101,12 +4002,8 @@ export class UserGroundHost {
5101
4002
  this.nextTurn(() => this.wakeObservedApply(settled, members));
5102
4003
  const postCommitMs = performance.now() - postCommitStarted;
5103
4004
  if (faulted.length > 0 || contradicted.length > 0) {
5104
- // A fault withheld only its own units, or its own root; every other
5105
- // unit stands. The generation is not finished, so the lane retries on
5106
- // its timer.
5107
4005
  throw failedDuring("pipeline", "detection", new Error([...new Set([...faulted.map(({ reason }) => reason), ...contradicted])].join("; ")));
5108
4006
  }
5109
- // A racy listing rings nothing; its retry waits exactly until it can close.
5110
4007
  if (unsettled.size)
5111
4008
  throw new DetectResidual([...unsettled.keys()], unexamined, {
5112
4009
  racyMs: Math.max(0, ...scanned.roots.map(root => root.units.walk.racyWaitMs)),
@@ -5128,10 +4025,6 @@ export class UserGroundHost {
5128
4025
  },
5129
4026
  });
5130
4027
  }
5131
- /** AV: the authority's current head H plus every accepted result Receive
5132
- * has delivered after its watermark M. Neither Apply nor Send is waited on:
5133
- * accepted state is what the authority has accepted, whatever this machine
5134
- * has physically applied or still owes. */
5135
4028
  async freshAcceptedView(identity, resourceId) {
5136
4029
  const head = (await this.readHead(identity, resourceId, { kind: "none" }))?.state;
5137
4030
  if (!head || head.resourceId !== resourceId) {
@@ -5142,9 +4035,6 @@ export class UserGroundHost {
5142
4035
  await this.recordRail.receiveThrough(head.deliveryWatermark);
5143
4036
  return acceptedView(head, readAcceptedTail(groundDatabase(this.databasePath()), resourceId, head.deliveryWatermark), sha256Hex);
5144
4037
  }
5145
- /** Which of these heads does the authority hold sealed under the current
5146
- * content contract? Batched so a whole workspace costs a handful of
5147
- * frames. The answer is the only permission to skip an upload. */
5148
4038
  async sealInventory(resourceId, hashes) {
5149
4039
  const batches = [];
5150
4040
  for (let start = 0; start < hashes.length; start += CONTENT_REFS_BATCH_OBJECTS) {
@@ -5164,14 +4054,6 @@ export class UserGroundHost {
5164
4054
  return sealed;
5165
4055
  }
5166
4056
  }
5167
- /** Graph pages are immutable and content-addressed, so they cache exactly like
5168
- * artifacts do — in their own directory, because they are the registry's own
5169
- * bytes rather than any entity's cargo. */
5170
- function graphPageCacheDir(cacheDir) {
5171
- return join(cacheDir, "graph-pages");
5172
- }
5173
- /** Wait at most `ms` for `work`. A failure inside the bound is the caller's;
5174
- * a later settlement stays with the rail that owns `work`. */
5175
4057
  async function bounded(work, ms) {
5176
4058
  let timer;
5177
4059
  const elapsed = new Promise(resolve => { timer = setTimeout(resolve, ms); });
@@ -5197,8 +4079,6 @@ function networkBudget(ms) {
5197
4079
  },
5198
4080
  };
5199
4081
  }
5200
- /** Settle with the started work, or reject once `signal` aborts. The work runs
5201
- * on to its own end; only this caller stops waiting for it. */
5202
4082
  async function untilAborted(signal, start) {
5203
4083
  signal.throwIfAborted();
5204
4084
  const work = start();
@@ -5208,7 +4088,6 @@ async function untilAborted(signal, start) {
5208
4088
  void work.then(resolve, reject).finally(() => signal.removeEventListener("abort", aborted));
5209
4089
  });
5210
4090
  }
5211
- /** A stage names where an answer arose; it never turns a refusal into a fault. */
5212
4091
  function failedDuring(operation, stage, error) {
5213
4092
  const message = error instanceof Error ? error.message : String(error);
5214
4093
  const wrapped = `Files ${operation} failed during ${stage}: ${message}`;
@@ -5218,10 +4097,8 @@ function failedDuring(operation, stage, error) {
5218
4097
  cause: error,
5219
4098
  });
5220
4099
  }
5221
- /** Watch's existing recovery loop will wake Detect after coverage returns. */
5222
4100
  class WatchCoverageUnavailable extends Error {
5223
4101
  }
5224
- /** The lease overrun behind a failure, however it was wrapped. */
5225
4102
  function footprintExceeded(error) {
5226
4103
  for (let link = error; link instanceof Error; link = link.cause) {
5227
4104
  if (link instanceof GroundFootprintExceededError)
@@ -5229,15 +4106,12 @@ function footprintExceeded(error) {
5229
4106
  }
5230
4107
  return null;
5231
4108
  }
5232
- /** Where a named attempt spent its time, rounded for the stage record. */
5233
4109
  const namedTimings = ({ timings }) => {
5234
4110
  if (!timings)
5235
4111
  return {};
5236
4112
  const ms = (value) => Math.round(value * 1000) / 1000;
5237
4113
  return Object.fromEntries(Object.entries(timings.phases).map(([phase, value]) => [`${phase}Ms`, ms(value)]));
5238
4114
  };
5239
- /** Each directory from `home` down to `folder`, as the object standing there
5240
- * now; `folder` alone when it lies outside `home`. */
5241
4115
  function standingDirectories(home, folder) {
5242
4116
  const below = relative(home, folder);
5243
4117
  const parts = below === "" ? [] : below.split(sep);
@@ -5245,7 +4119,6 @@ function standingDirectories(home, folder) {
5245
4119
  : [home, ...parts.map((_, index) => join(home, ...parts.slice(0, index + 1)))];
5246
4120
  return paths.map(path => ({ path, key: standingKey(path) }));
5247
4121
  }
5248
- /** The object standing at `path` itself, or null when none can be seen there. */
5249
4122
  const standingKey = (path) => {
5250
4123
  try {
5251
4124
  return physicalKey(lstatSync(path, { bigint: true }));
@@ -5260,7 +4133,6 @@ function filesPipelineStage(error) {
5260
4133
  : null;
5261
4134
  return typeof stage === "string" && stage ? stage : null;
5262
4135
  }
5263
- /** The root's covered directory, once its coverage is proved healthy. */
5264
4136
  function assertHealthyWatch(evidence, rootId) {
5265
4137
  const root = evidence.roots.find((candidate) => candidate.rootId === rootId);
5266
4138
  const content = root?.contentOwner
@@ -5280,10 +4152,6 @@ function assertHealthyWatch(evidence, rootId) {
5280
4152
  }
5281
4153
  return root.directory;
5282
4154
  }
5283
- /** A finished attempt answers a ticket when it proved some root the ticket
5284
- * names, through the ticket's generation and in at least the ticket's scope. */
5285
- /** A lane that ended on moving or unreadable ground waits: its park, not a
5286
- * ticket failure, is the answer, joined with every other wait. */
5287
4155
  function waits(error) {
5288
4156
  return unsettledGround(error);
5289
4157
  }
@@ -5294,9 +4162,6 @@ function coversTicket(cuts, ticket) {
5294
4162
  && (cut.suspicion.paths === null || (wanted.suspicion.paths !== null
5295
4163
  && wanted.suspicion.paths.every(suspectScope(cut.suspicion.paths).covers)))));
5296
4164
  }
5297
- /** A recovery fact created before Watch could prove registration: a bound
5298
- * root that has never produced a local entity row. It pulls only that exact
5299
- * root into the next Detect pass. */
5300
4165
  function emptyBoundRoots(file, bindingDir) {
5301
4166
  const bindings = materializedWorkspaceBindings(bindingDir);
5302
4167
  if (bindings.length === 0 || !existsSync(file))
@@ -5308,12 +4173,6 @@ function emptyBoundRoots(file, bindingDir) {
5308
4173
  return bindings.filter(({ workspaceId }) => !hasRows.get(workspaceId))
5309
4174
  .map(({ directory }) => directory);
5310
4175
  }
5311
- /** A binding declares an external workspace root. Once the graph holds that
5312
- * workspace beneath another root, an enclosing Register absorbed it: it is a
5313
- * folder of the new root, so its binding no longer declares anything. The
5314
- * graph is identity authority; a binding only lags it. Register retires it
5315
- * once its accepted view holds the new root, so no proof of that Register
5316
- * still names the old root; login retires one a crash left behind. */
5317
4176
  function retireAbsorbedBindings(file, bindingDir) {
5318
4177
  const declared = workspaceBindings(bindingDir).declared;
5319
4178
  if (declared.length === 0 || !existsSync(file))
@@ -5325,12 +4184,6 @@ function retireAbsorbedBindings(file, bindingDir) {
5325
4184
  rmSync(join(bindingDir, workspaceId));
5326
4185
  }
5327
4186
  }
5328
- /** Where ground stands on its authority's line: the place its verified
5329
- * install or created publication named (never how far Receive has heard),
5330
- * the newest graph head it keeps, which login reports instead of asking,
5331
- * Send work the authority has not accepted, the first publication it
5332
- * journaled and has not learned the answer to, and the graph a placement
5333
- * committed with its place whose reveal Watch does not yet cover. */
5334
4187
  function groundPlace(file, authorityId) {
5335
4188
  const database = groundDatabase(file);
5336
4189
  const place = database.prepare(`
@@ -5348,19 +4201,13 @@ function groundPlace(file, authorityId) {
5348
4201
  ...(place !== undefined ? { place } : {}),
5349
4202
  ...(head ? { head } : {}),
5350
4203
  ...(pending ? { pendingRecords: true } : {}),
5351
- // The journaled bytes exactly as sent; Live proves them by their checksum.
5352
4204
  ...(publication ? { publication: {
5353
4205
  checksum: publication.checksum,
5354
4206
  snapshot: JSON.parse(publication.snapshot.toString("utf8")),
5355
4207
  } } : {}),
5356
- // The pinned graph exactly as pinned; Live proves it by its checksum.
5357
4208
  ...(placing !== undefined ? { placing: JSON.parse(placing) } : {}),
5358
4209
  };
5359
4210
  }
5360
- /** What login's inspection reads of this home: its identity, its place on
5361
- * the line and what it still owes (`groundPlace`), and whether the home root
5362
- * is served on demand (on-demand-roots.ts). Never its rows: nothing login
5363
- * decides reads them, and a home's rows grow with everything in it. */
5364
4211
  function inspectedHome(identity, userRoot, database, authorityId) {
5365
4212
  assertDatabaseIdentity(database, identity);
5366
4213
  const root = homeRoot(database, identity.userEmail);
@@ -5372,22 +4219,15 @@ function inspectedHome(identity, userRoot, database, authorityId) {
5372
4219
  ...(root !== null && isOnDemandRoot(groundDatabase(database), root) ? { onDemand: true } : {}),
5373
4220
  };
5374
4221
  }
5375
- /** A placement's answer: the inspected home and the rows it placed, which
5376
- * login proves against the graph it pinned. */
5377
4222
  function homeGround(identity, userRoot, database, authorityId) {
5378
4223
  return {
5379
4224
  ...inspectedHome(identity, userRoot, database, authorityId),
5380
4225
  records: coreGroundRecords(database, identity.userEmail),
5381
4226
  };
5382
4227
  }
5383
- /** The home root, read from the top-level rows alone. */
5384
4228
  function homeRoot(database, userEmail) {
5385
4229
  return findUserGroundRoot(coreGroundRoots(database, userEmail), userEmail);
5386
4230
  }
5387
- /** Every witness the batch's sources retained, judged once on a content
5388
- * thread: each proof leaf maps to its first failure, or null. Semantic
5389
- * phases already answered, so this is each leaf's physical close less its
5390
- * admission, which only the transaction may run. */
5391
4231
  async function judgeUnitWitnesses(batch, lane) {
5392
4232
  const started = performance.now();
5393
4233
  const leaves = [...new Set(batch.flatMap(entry => entry.sources.flatMap(proofLeaves)))]
@@ -5400,19 +4240,6 @@ async function judgeUnitWitnesses(batch, lane) {
5400
4240
  prepareMs: prepared - started, waitMs: performance.now() - prepared
5401
4241
  } };
5402
4242
  }
5403
- /** Admit independent units in one save (detection/admission-save.ts). Each
5404
- * unit answers alone: no effect crossed its reads, its witnesses held and
5405
- * none of its S0 facts changed; a unit that moved is left out and every
5406
- * other unit commits. A pass-wide change throws.
5407
- *
5408
- * This thread answers what it owns when it posts: bindings, crossings and
5409
- * witnesses. Saves commit in post order, and a runtime effect records its
5410
- * grant before acting and waits for every earlier save, so nothing this
5411
- * thread owns can change between the post and the commit. Ground that
5412
- * changes after its witness was judged is either such an effect, which
5413
- * crosses the unit, or an outside change that rings Watch and belongs to a
5414
- * later generation. The saver answers what only the database can: the
5415
- * accepted results and each unit's S0 facts. */
5416
4243
  async function admitDetectedUnits(database, batch, input) {
5417
4244
  let judged;
5418
4245
  try {
@@ -5510,7 +4337,6 @@ async function admitDetectedUnits(database, batch, input) {
5510
4337
  }
5511
4338
  const result = saved.value;
5512
4339
  if (!result.accepted) {
5513
- // Build settled against an accepted answer a commit moved: the pass re-collects.
5514
4340
  const error = new GroundBasisChangedError("an accepted result this pass built on moved");
5515
4341
  const marks = { requested: saved.posted, began: saved.began, checked: null, ended: saved.ended };
5516
4342
  for (const entry of batch)
@@ -5532,12 +4358,7 @@ async function admitDetectedUnits(database, batch, input) {
5532
4358
  return { admitted, left, changes: result.changes, stamped: admitted.length ? [saved.from, saved.through] : null,
5533
4359
  records: result.records, recorded: recorded.filter((_, index) => !stale.has(index)).flat(), write: result.evidence, judging };
5534
4360
  }
5535
- /** Members one admission transaction carries, so a catch-up pass pays few
5536
- * commits. It bounds batch size, never duration: an indivisible unit is not
5537
- * split to meet it, and a repository's closer may still be slow. */
5538
4361
  const UNIT_BATCH_MEMBERS = 1024;
5539
- /** Consecutive units whose members fit one admission; a larger unit stands
5540
- * alone. Units that change an absence share the last (admission-units.ts). */
5541
4362
  function memberBatches(units, limit) {
5542
4363
  const batches = [];
5543
4364
  let size = limit;
@@ -5556,9 +4377,6 @@ function memberBatches(units, limit) {
5556
4377
  batches.push(activating);
5557
4378
  return batches;
5558
4379
  }
5559
- /** Roots holding a row another writer stamped since S0, or whose visible
5560
- * generation another writer changed; null when a write cannot be attributed
5561
- * to a root. A stamp inside one of this pass's saves is its own. */
5562
4380
  function foreignRoots(database, basis, ours, before) {
5563
4381
  const own = (revision) => ours.stamped.some(([from, through]) => revision > from && revision <= through);
5564
4382
  const roots = new Set();
@@ -5588,10 +4406,6 @@ function foreignRoots(database, basis, ours, before) {
5588
4406
  }
5589
4407
  return roots;
5590
4408
  }
5591
- /** Exactly `bytes` bytes of `file` from its start, read once through one
5592
- * handle. A source shorter than its stated length no longer carries the
5593
- * captured artifact; a longer one is read only to that length, and the
5594
- * authority's whole-hash proof refuses it. */
5595
4409
  async function readExactly(file, bytes) {
5596
4410
  const handle = await open(file, "r");
5597
4411
  try {
@@ -5609,15 +4423,10 @@ async function readExactly(file, bytes) {
5609
4423
  await handle.close();
5610
4424
  }
5611
4425
  }
5612
- /** Local read evidence disagreeing with the recorded content head — the
5613
- * upload law's typed mismatch or the source file being gone entirely. */
5614
4426
  function sourceMismatch(error) {
5615
4427
  const code = error?.code;
5616
4428
  return code === "UPLOAD_SOURCE_MISMATCH" || code === "ENOENT";
5617
4429
  }
5618
- /** Reveal one committed root from its staging (root-install.ts), refreshing
5619
- * what entered before Watch can observe it. The root itself must stand
5620
- * revealed: a destination something else occupies is no install. */
5621
4430
  async function revealInstalledRoot(file, rootUUID, staging, moved) {
5622
4431
  const { revealed, rootStands } = await revealRoot({ staging, ...readRootMembers(file, rootUUID) });
5623
4432
  await moved?.();
@@ -5653,21 +4462,15 @@ function createUserHome(input) {
5653
4462
  const { identity, userRoot, now } = input;
5654
4463
  const user = userLayout(userRoot);
5655
4464
  ensurePrivateDir(userRoot);
5656
- if (!existsSync(user.ignoreFile))
5657
- atomicWrite(user.ignoreFile, DEFAULT_AMALGM_IGNORE);
5658
4465
  if (!existsSync(user.manifest)) {
5659
4466
  const manifest = buildUserManifest({ userId: identity.userId, email: identity.userEmail }, null, {
5660
4467
  nowIso: () => now.toISOString(),
5661
4468
  });
5662
4469
  atomicWrite(user.manifest, `${JSON.stringify(manifest, null, 2)}\n`);
5663
4470
  }
5664
- // The computers folder stands in every home from its first publication, as
5665
- // its roots do, so every computer holds its one identity from sign-in.
5666
4471
  for (const root of [...USER_ROOTS, FILES_FOLDER])
5667
4472
  ensurePrivateDir(join(userRoot, root));
5668
4473
  }
5669
- /** What a scope concludes from: each top's subtree, and the storage a
5670
- * repository whose `.git` is a top keeps elsewhere. */
5671
4474
  function scopeGround(directory, tops) {
5672
4475
  return tops.flatMap(top => {
5673
4476
  const owner = gitStorageOwner(top);
@@ -5676,12 +4479,9 @@ function scopeGround(directory, tops) {
5676
4479
  }
5677
4480
  async function reconcileGround(input) {
5678
4481
  const { identity, userRoot, database, cacheDir, restorePackage, bindingDir, onScan, onDiscovery, measuring = false, } = input;
5679
- // A scoped root that cannot stand alone joins the walked roots.
5680
4482
  const suspicions = input.suspicions && new Map(input.suspicions);
5681
4483
  const selectionFallbacks = new Map(input.selectionFallbacks);
5682
4484
  const resourceId = privateEntityResourceId(identity.userId, sha256Hex);
5683
- // The declaration names every root; whether one can be reached is
5684
- // presence, read here once beside it.
5685
4485
  const bindings = workspaceBindings(bindingDir);
5686
4486
  const boundRootEntries = bindings.reached;
5687
4487
  const coreRootId = `user:${identity.userId}`;
@@ -5690,26 +4490,16 @@ async function reconcileGround(input) {
5690
4490
  const domainBindings = new Map(boundRootEntries.map(entry => [entry.workspaceId, entry.directory]));
5691
4491
  if (presentDirectory(userRoot))
5692
4492
  domainBindings.set(coreRootId, userRoot);
5693
- // A domain stands on the declaration Watch froze: each participant still
5694
- // declared where it was, and every root reachable now a participant. A
5695
- // participant that cannot be reached is unread ground, never an advanced
5696
- // basis: it waits for access while the others are proved.
5697
4493
  if (input.domain && (input.domain.some(item => declaredRoots.get(item.rootId) !== item.directory)
5698
4494
  || [...domainBindings.keys()].some(rootId => !input.domain.some(item => item.rootId === rootId)))) {
5699
4495
  throw new DetectionBasisAdvancedError();
5700
4496
  }
5701
- // A pooled examination is a complete examination of its root: unchanged,
5702
- // or (below) its scopes concluded without refusal.
5703
4497
  const examinedDomainRoots = new Set([...domainBindings]
5704
4498
  .filter(([, directory]) => input.quietRoots?.has(directory)).map(([rootId]) => rootId));
5705
4499
  const outerBoundRoots = boundRootEntries.filter((candidate) => !boundRootEntries.some((other) => other.workspaceId !== candidate.workspaceId
5706
4500
  && pathWithin(other.directory, candidate.directory)));
5707
4501
  const registeredBoundaries = new Map(boundRootEntries
5708
4502
  .map(({ workspaceId, directory }) => [resolve(directory), workspaceId]));
5709
- // Both inventories are read from one observation, closed before the walk.
5710
- // The returned basis protects observed-only writes as well as sharing writes.
5711
- // A scoped root needs its policy and its own classification before S0;
5712
- // without either, it is walked.
5713
4503
  const scopeRequests = new Map();
5714
4504
  const promotions = new Map();
5715
4505
  const crossings = new Map();
@@ -5724,7 +4514,8 @@ async function reconcileGround(input) {
5724
4514
  };
5725
4515
  for (const [directory, request] of input.rootScopes ?? []) {
5726
4516
  try {
5727
- scopeRequests.set(directory, { request, policy: readSharingPolicy(userRoot, directory),
4517
+ scopeRequests.set(directory, { request, policy: readSkipPolicy({ root: directory, database: groundDatabase(database),
4518
+ rootUUID: request.rootUUID }),
5728
4519
  rootMarker: observeGitMarker(directory) });
5729
4520
  }
5730
4521
  catch {
@@ -5732,11 +4523,6 @@ async function reconcileGround(input) {
5732
4523
  }
5733
4524
  }
5734
4525
  const framedRoots = new Map();
5735
- // Each walk reads under its clock root's one stamp for the pass, taken
5736
- // before S0 for every root the pass expects to read, so S0's views already
5737
- // stand under the qualification it decided (content-clock.ts). A root
5738
- // only S0's facts send to a walk is stamped then; should that stamp move
5739
- // its qualification, admission refuses the pass as it refuses any moved read.
5740
4526
  const stamps = new Map();
5741
4527
  const stampOf = async (directory) => {
5742
4528
  let stamp = stamps.get(directory);
@@ -5744,15 +4530,7 @@ async function reconcileGround(input) {
5744
4530
  stamps.set(directory, stamp = await stampContentClock(database, directory));
5745
4531
  return stamp;
5746
4532
  };
5747
- // A first publication declares the home alone. A bound root outside it
5748
- // registers as Register's does: its first Watch coverage owes a whole
5749
- // catch-up, and with no rows its own walk records it as one package.
5750
4533
  const observedRoot = (root) => suspicions ? suspicions.has(root) : root === userRoot;
5751
- // Every bound root whose rows a whole walk reads: each observed outer
5752
- // root's bound family, the roots it encloses included. A walk reuses their
5753
- // proofs, so each is stamped here, before S0, like the root it lies in,
5754
- // and before the root it lies in: a proof carries over only under a clock
5755
- // that does not stand behind its own root's stamp (content-clock.ts).
5756
4534
  const walkedBindings = boundRootEntries.filter(binding => outerBoundRoots.some(owner => observedRoot(owner.directory) && pathWithin(owner.directory, binding.directory)));
5757
4535
  if (observedRoot(userRoot))
5758
4536
  await stampOf(resolve(userRoot));
@@ -5762,12 +4540,7 @@ async function reconcileGround(input) {
5762
4540
  for (const directory of scopeRequests.keys())
5763
4541
  await stampOf(directory);
5764
4542
  const connection = groundDatabase(database);
5765
- // S0 is the observation's first read: everything the pass knows before
5766
- // any frame. Every later read answers with S0's facts or fails the pass,
5767
- // which runs again: each scoped root's frame, a short step at a time, then
5768
- // the roots the pass walks whole, a page at a time.
5769
4543
  const observation = groundStore(connection).observe();
5770
- /** The roots this pass walks whole: each suspected root's bound family. */
5771
4544
  const walkedRoots = (coreUUID) => [...new Set([...(suspicions.has(userRoot) ? [coreUUID] : []), ...walkedBindings.map(binding => binding.workspaceId)])];
5772
4545
  const { coreUUID: observedCore, revisions } = observation.read(reader => {
5773
4546
  if (!suspicions)
@@ -5784,27 +4557,19 @@ async function reconcileGround(input) {
5784
4557
  });
5785
4558
  if (suspicions) {
5786
4559
  for (const [directory, { request, policy, rootMarker }] of scopeRequests) {
5787
- // A pooled examination compared the root at its revision: the rest
5788
- // of the root stands on it only while no row of its O or B moved.
5789
4560
  const frame = request.revision !== null && revisions.get(directory) !== request.revision ? "revision"
5790
4561
  : directory === userRoot && request.rootUUID !== observedCore ? "core"
5791
4562
  : await finishStepsInTurns(frameScope({ observation, directory, resourceId, request, policy, rootMarker }));
5792
4563
  if (typeof frame === "string")
5793
4564
  fallBack(directory, frame);
5794
- // The frame reads what O holds, which the gate's index may not have:
5795
- // it takes that ground only while no effect holds it.
5796
4565
  else if (input.ground && !input.ground.widen(scopeGround(directory, frame.tops)))
5797
4566
  fallBack(directory, "ground-held");
5798
4567
  else
5799
4568
  framedRoots.set(directory, { request, policy, ...frame });
5800
4569
  }
5801
4570
  }
5802
- // A root a refused frame hands to the walk is walked whole with the rest.
5803
4571
  const { materialized, notebook } = await finishStepsInTurns(readWalkedRoots(observation, suspicions ? walkedRoots(observedCore) : [null]));
5804
4572
  const basis = observation.finish();
5805
- // Physical identity is read only from observation. The sharing notebook
5806
- // remains the independent predecessor for Record and retained lifecycle.
5807
- // Every index of the walked rows is built a bounded batch per step.
5808
4573
  const joinRoot = (index, row) => {
5809
4574
  const rows = index.get(row.rootUUID);
5810
4575
  if (rows)
@@ -5838,11 +4603,7 @@ async function reconcileGround(input) {
5838
4603
  if (row.resourceId === resourceId)
5839
4604
  ownNotebook.push(row);
5840
4605
  });
5841
- // Each outer bound root's own row as its walk read it.
5842
4606
  const existingRoots = new Map(outerBoundRoots.map(({ workspaceId }) => [workspaceId, materializedByUuid.get(workspaceId)]));
5843
- // A framed root's context joins S0 by identity only; no walked root's
5844
- // inventory ever includes it. A vacant top's hidden aliased leaves join no
5845
- // inventory.
5846
4607
  const hiddenAliases = new Map();
5847
4608
  for (const frame of framedRoots.values()) {
5848
4609
  for (const [top, rows] of frame.aliased)
@@ -5872,8 +4633,6 @@ async function reconcileGround(input) {
5872
4633
  const returned = new Map(), reveals = new Map();
5873
4634
  const acceptedNotebookRows = [];
5874
4635
  const detection = [];
5875
- // An exact accepted result Apply has not yet resolved is already ordered:
5876
- // Build settles against it and makes no record; admission rechecks it.
5877
4636
  const accepted = new AcceptedInboxResultIndex(connection).snapshot();
5878
4637
  const settled = [];
5879
4638
  const waits = new Map();
@@ -5939,9 +4698,6 @@ async function reconcileGround(input) {
5939
4698
  catch (error) {
5940
4699
  const deferred = (reason) => report([], { outcome: "deferred", reason });
5941
4700
  const movement = movementOf(error);
5942
- // Units: a root off its device holds none of its identities there, so
5943
- // the domain's absence decisions do not wait on it; a root bound
5944
- // beneath it is examined by its own walk, and other roots admit.
5945
4701
  if (input.units && error instanceof RootOffDevice) {
5946
4702
  await deferred("root-off-device");
5947
4703
  offDeviceRoots.set(parameters.rootPath, error.message);
@@ -5951,21 +4707,16 @@ async function reconcileGround(input) {
5951
4707
  }
5952
4708
  return undefined;
5953
4709
  }
5954
- // Units: a root the walk could not look at is unread like one whose
5955
- // binding the pass could not follow; the domain waits for it.
5956
4710
  if (error instanceof RootUnreachable) {
5957
4711
  await deferred("root-unreachable");
5958
4712
  unreachable.push(error.root);
5959
4713
  return undefined;
5960
4714
  }
5961
- // Units: a re-created root owes its complete examination, and the
5962
- // domain's absence decisions wait for it.
5963
4715
  if (input.units && error instanceof RootRecreated) {
5964
4716
  await deferred("root-recreated-owes-complete");
5965
4717
  promotions.set(parameters.rootPath, "root-recreated");
5966
4718
  return undefined;
5967
4719
  }
5968
- // Units: this root's own evidence moved; other roots still admit.
5969
4720
  if (input.units && !isDetectCancelled(error) && moved(error)) {
5970
4721
  await deferred("moved");
5971
4722
  invalidatedRoots.push({ directory: parameters.rootPath, ...movement });
@@ -5998,7 +4749,6 @@ async function reconcileGround(input) {
5998
4749
  detection.push(plan);
5999
4750
  const currentIds = new Set();
6000
4751
  await eachInTurns(result.observedRows, row => currentIds.add(row.record.uuid));
6001
- // Each removal as S0 stores it, in its root's frame.
6002
4752
  const removed = [];
6003
4753
  await eachInTurns(parameters.folders ? result.examined : materializedByRoot.get(parameters.rootUUID) ?? [], prior => {
6004
4754
  if (!currentIds.has(prior.uuid)) {
@@ -6010,9 +4760,6 @@ async function reconcileGround(input) {
6010
4760
  returned.set(uuid, row);
6011
4761
  for (const [top, absent] of result.reveals)
6012
4762
  reveals.set(top, absent);
6013
- // A walk proves absent each top it did not find where it read: its
6014
- // root whole, or a frame's every listing on the way to a name it
6015
- // follows. The top's absence hides everything stored beneath it.
6016
4763
  if (removed.length) {
6017
4764
  const occupied = new Set();
6018
4765
  await eachInTurns(result.observedRows, row => occupied.add(row.relativePath));
@@ -6025,7 +4772,6 @@ async function reconcileGround(input) {
6025
4772
  const observed = capturedGroundRow(parameters.resourceId, rootId, row);
6026
4773
  if (input.domain && parameters.suspects === null)
6027
4774
  examineDomain(observed);
6028
- // A row back where it stood shows by its reveal, unwritten while equal.
6029
4775
  const base = materializedByUuid.get(observed.uuid) ?? result.revealed.get(observed.uuid);
6030
4776
  const captured = retainSighting(base, observed);
6031
4777
  if (!sameNotebookBasisRow(captured, base))
@@ -6050,15 +4796,9 @@ async function reconcileGround(input) {
6050
4796
  notebookByUuid.set(row.uuid, row);
6051
4797
  });
6052
4798
  await report(proposals);
6053
- // Native callbacks retain further suspicion between roots. These roots'
6054
- // proofs remain pending until the caller's final Record transaction.
6055
4799
  await awaitTurn();
6056
4800
  return result;
6057
4801
  };
6058
- // A Watch pass names exactly the roots it observed. A root outside that
6059
- // observation has nothing to prove and is not scanned, planned, or
6060
- // inspected; its rows stay as they are. A bound root that has never
6061
- // produced a row is pulled in by Watch's suspicion (emptyBoundRoots).
6062
4802
  if (observedRoot(userRoot)) {
6063
4803
  await scan({
6064
4804
  identity,
@@ -6066,7 +4806,6 @@ async function reconcileGround(input) {
6066
4806
  rootUUID: coreUUID,
6067
4807
  rootName: identity.userEmail,
6068
4808
  rootPath: userRoot,
6069
- homePath: userRoot,
6070
4809
  rootType: "workspace",
6071
4810
  database,
6072
4811
  cacheDir,
@@ -6081,13 +4820,10 @@ async function reconcileGround(input) {
6081
4820
  });
6082
4821
  }
6083
4822
  for (const { workspaceId, directory: rootPath } of outerBoundRoots) {
6084
- // Ongoing Detect consumes only the roots Watch named.
6085
4823
  if (!observedRoot(rootPath))
6086
4824
  continue;
6087
4825
  const existingRoot = existingRoots.get(workspaceId);
6088
4826
  const existingWorkspaceRows = existingByOutermostRoot.get(workspaceId) || [];
6089
- // A root whose entries are hidden keeps its last rail; its own walk
6090
- // records the gap instead of voiding every other root's examination.
6091
4827
  let rootMarker;
6092
4828
  try {
6093
4829
  rootMarker = observeGitMarker(rootPath);
@@ -6103,7 +4839,6 @@ async function reconcileGround(input) {
6103
4839
  rootUUID: workspaceId,
6104
4840
  rootName: existingRoot?.name || basename(rootPath),
6105
4841
  rootPath,
6106
- homePath: userRoot,
6107
4842
  rootType: existingRoot?.parentUUID
6108
4843
  ? classifyDirectory({ repository })
6109
4844
  : classifyRegisteredRoot({ repository }),
@@ -6125,14 +4860,6 @@ async function reconcileGround(input) {
6125
4860
  plansSendRecords: true,
6126
4861
  });
6127
4862
  }
6128
- // A scoped root is read only inside its changed repositories and the folder
6129
- // subtrees Watch's names reach, each in its root's frame. What those reads
6130
- // cannot account for, an identity arriving from elsewhere in the root,
6131
- // invalidates the root. A row they no longer
6132
- // found is absent only where a pooled examination saw its absence, or where
6133
- // the root's whole namespace, discovered after them, holds its identity
6134
- // nowhere they did not observe it. Nothing here infers a move or a removal:
6135
- // the resolver already weighed every place they observed.
6136
4863
  const scopedRoots = new Map();
6137
4864
  if (framedRoots.size) {
6138
4865
  const current = groundDatabase(database);
@@ -6153,7 +4880,6 @@ async function reconcileGround(input) {
6153
4880
  let reason = null;
6154
4881
  let strays = [];
6155
4882
  for (let reading = 1;; reading++) {
6156
- // The stamp precedes every read the discovery takes.
6157
4883
  stamp = await stampContentClock(database, directory);
6158
4884
  try {
6159
4885
  result = await discoverRootIdentities({ database, rootUUID, rootPath: directory, boundary: stamp.boundary, keys, uuids });
@@ -6165,8 +4891,6 @@ async function reconcileGround(input) {
6165
4891
  reason = `failed:${error instanceof Error ? error.message : String(error)}`;
6166
4892
  break;
6167
4893
  }
6168
- // Waiting cannot close a racy listing; a fresh one under a later stamp can.
6169
- // One timed beyond the horizon no near stamp qualifies: the walk closes it.
6170
4894
  if (result.kind !== "racy" || reading === RACY_READINGS || result.retryMs > RACY_HORIZON_MS)
6171
4895
  break;
6172
4896
  const wait = result.retryMs;
@@ -6185,9 +4909,6 @@ async function reconcileGround(input) {
6185
4909
  reason, found: result?.kind === "closed" ? result.found.length : 0, ...(result ? { stats: result.stats } : {}) });
6186
4910
  return { reason, stamp, strays };
6187
4911
  };
6188
- // An identity a scope observed but does not hold, which O holds active at
6189
- // another address of the root that no longer holds it, crossed the
6190
- // scope's edge: both of its addresses are named.
6191
4912
  const crossingIn = (rootUUID) => (row, holds) => candidates.all(row.physicalKey)
6192
4913
  .filter(prior => prior.rootUUID === rootUUID && prior.status === "active"
6193
4914
  && !holds(prior.uuid) && !stillAt(prior.absolutePath, row))
@@ -6198,18 +4919,11 @@ async function reconcileGround(input) {
6198
4919
  };
6199
4920
  scopedRoots.set(directory, scopedRoot);
6200
4921
  let refused = false;
6201
- // Both addresses of every identity that crossed this root's scope,
6202
- // relative to it; null once a refusal names no crossing.
6203
4922
  let crossing = new Set();
6204
- // What a scoped root proved stays unadmitted. A scope that waits, on
6205
- // moved ground or on Apply, retries as Watch named it.
6206
4923
  const stop = ({ reason, settlesInMs }) => {
6207
4924
  refused = true;
6208
4925
  invalidatedRoots.push({ directory, reason: `scope:${reason}`, settlesInMs });
6209
4926
  };
6210
- // A refused root owes its complete examination instead: the main walk,
6211
- // when a pooled examination already read it. Only a scope Watch's
6212
- // names located can grow to both addresses of a crossing.
6213
4927
  const refuse = (reason, addresses = []) => {
6214
4928
  stop({ reason, settlesInMs: null });
6215
4929
  if (!promotions.has(directory))
@@ -6225,26 +4939,17 @@ async function reconcileGround(input) {
6225
4939
  for (const name of names)
6226
4940
  crossing?.add(name);
6227
4941
  };
6228
- // Rows the scope did not account for, and everything it observed.
6229
- // Beneath a vacant name everything stored is its top's absence, which
6230
- // hides it whole: only another absence needs discovery. A claim of any
6231
- // of it elsewhere is no vacancy, and refuses as a crossing.
6232
4942
  const unaccounted = [];
6233
4943
  const vacantly = suspectScope(request.vacant).covers;
6234
4944
  const account = (row) => { if (!vacantly(row.relativePath))
6235
4945
  unaccounted.push(row); };
6236
4946
  const observed = [];
6237
- // The root's own walk follows the scope's names; every other member of
6238
- // a container on the way is context, which no result, absence or
6239
- // arrival of this scope is drawn from. The scope answers for the rows
6240
- // it read; its context is only read around.
6241
4947
  const result = await scan({
6242
4948
  identity,
6243
4949
  resourceId,
6244
4950
  rootUUID: request.rootUUID,
6245
4951
  rootName: directory === userRoot ? identity.userEmail : frame.row.name,
6246
4952
  rootPath: directory,
6247
- homePath: userRoot,
6248
4953
  rootType: frame.row.type,
6249
4954
  rootMarker: frame.marker,
6250
4955
  rootParentUUID: frame.row.parentUUID,
@@ -6285,13 +4990,10 @@ async function reconcileGround(input) {
6285
4990
  for (const row of result.observedRows)
6286
4991
  observed.push(row);
6287
4992
  }
6288
- // Discovery reads the root's whole namespace, which it takes only while
6289
- // no effect holds it; held, the complete root waits for it.
6290
4993
  if (!refused && unaccounted.length && input.ground && !input.ground.widen([directory]))
6291
4994
  refuse("absence-held");
6292
4995
  if (!refused && unaccounted.length) {
6293
4996
  const { reason, stamp, strays } = await discoverAbsence(directory, request.rootUUID, unaccounted, observed);
6294
- // Every unit holding an identity it answered for consumes it.
6295
4997
  if (reason === null)
6296
4998
  scopedRoot.discovery = { entries: [directory], uuids: new Set(unaccounted.map(row => row.uuid)),
6297
4999
  proof: admissionProof(() => assertQualified(database, stamp)) };
@@ -6339,14 +5041,11 @@ async function reconcileGround(input) {
6339
5041
  };
6340
5042
  }
6341
5043
  const deleteRootRows = (file, resourceId, rootUUID) => save(file, "install.clearRoot", { resourceId, rootUUID });
6342
- /** Files Add's own part: its destination's checks, its intent, the shared
6343
- * install, then the references it places in the home. */
6344
5044
  async function installCloudWorkspace(input) {
6345
5045
  const { identity, userRoot, database, bindingDir, resourceId, workspace, reference, references, records, setAside, destinationParent, cloudHead, deliveryWatermark, onStage, } = input;
6346
5046
  const existing = readGroundClosureRows(database, workspace.uuid);
6347
5047
  let intent = readWorkspaceAddIntent(database, workspace.uuid);
6348
5048
  if (existing.length > 0 && !intent) {
6349
- // A completed Add's rows are on their rails, and Live judges them.
6350
5049
  const root = existing.find((row) => row.uuid === workspace.uuid);
6351
5050
  if (!root || !pathExists(root.absolutePath)) {
6352
5051
  throw new Error(`local workspace ${workspace.uuid} has unresolved placement`);
@@ -6370,22 +5069,19 @@ async function installCloudWorkspace(input) {
6370
5069
  throw new Error(`workspace ${workspace.uuid} is entering on demand on this computer; add it once it has`);
6371
5070
  }
6372
5071
  if (existing.length === 0) {
6373
- const parent = realpathSync(resolve(destinationParent));
6374
- if (!statSync(parent).isDirectory())
6375
- throw new Error("destination must be a directory");
5072
+ const parent = folderStanding(resolve(destinationParent));
5073
+ if (parent === null)
5074
+ throw refusal(`files add refuses ${seenName(resolve(destinationParent))}: it is not a folder`);
6376
5075
  const destination = join(parent, workspace.name);
6377
5076
  if (dirname(destination) !== parent || basename(destination) !== workspace.name) {
6378
5077
  throw new Error("workspace name must be one path segment");
6379
5078
  }
6380
- const canonicalUserRoot = realpathSync(userRoot);
6381
- if (pathWithin(canonicalUserRoot, destination) || pathWithin(destination, canonicalUserRoot)) {
6382
- throw new Error("files add destination must be outside the Amalgm user ground");
6383
- }
6384
5079
  if (!intent) {
6385
5080
  assertEnclosesNothingHeld(database, workspace.uuid, records);
6386
5081
  for (const bound of materializedWorkspaceBindings(bindingDir)) {
6387
5082
  if (pathWithin(bound.directory, destination) || pathWithin(destination, bound.directory)) {
6388
- throw new Error(`files add destination overlaps materialized workspace ${bound.workspaceId}`);
5083
+ throw refusal(`files add refuses ${seenName(destination)}: it overlaps workspace ${bound.workspaceId} `
5084
+ + `at ${bound.directory}. Choose a folder of your own.`);
6389
5085
  }
6390
5086
  }
6391
5087
  intent = await beginWorkspaceAddIntent(database, bindingDir, {
@@ -6428,11 +5124,6 @@ async function installCloudWorkspace(input) {
6428
5124
  alreadyMaterialized: false,
6429
5125
  };
6430
5126
  }
6431
- /** One machine materializes each UUID in exactly one place. A selection may
6432
- * enclose a boundary this machine already added elsewhere; a fresh install
6433
- * would re-root those rows under the new destination while the old binding
6434
- * stayed bound and watched over ground with no rows, and the next Detect pass
6435
- * there would mint a second identity for every file. */
6436
5127
  function assertEnclosesNothingHeld(database, workspaceId, records) {
6437
5128
  const selectedUUIDs = new Set(records.map((record) => record.uuid));
6438
5129
  const enclosedElsewhere = readGroundRowsByUUIDs(database, "entities", selectedUUIDs)
@@ -6447,10 +5138,7 @@ function assertEnclosesNothingHeld(database, workspaceId, records) {
6447
5138
  throw new Error(`files add: workspace ${workspaceId} encloses ${enclosedElsewhere.length} entities already `
6448
5139
  + `materialized on this machine under ${roots.join(", ")}; remove that materialization first`);
6449
5140
  }
6450
- /** The repositories an install played onto their lines, each with the line
6451
- * its next record plays onto (git-install-lines.ts). */
6452
5141
  const playedLines = (rows) => rows.flatMap(({ record, gitLine }) => gitLine ? [{ uuid: record.uuid, line: gitLine }] : []);
6453
- /** Write a new install's intent, once nothing stands where it will. */
6454
5142
  async function beginWorkspaceAddIntent(database, bindingDir, proposed, onStage) {
6455
5143
  if (pathExists(proposed.destinationPath)) {
6456
5144
  throw new Error(`workspace destination already exists: ${proposed.destinationPath}`);
@@ -6466,11 +5154,6 @@ async function beginWorkspaceAddIntent(database, bindingDir, proposed, onStage)
6466
5154
  await onStage?.("intent-recorded");
6467
5155
  return written.intent;
6468
5156
  }
6469
- /** The install of one Add intent, Files Add's and a fetch lane's Enter of a
6470
- * root alike: its selection staged and verified, its rows committed with
6471
- * what it verified at its watermark, the staging revealed, then the binding
6472
- * that first makes it coverable. Rows already committed resume from the
6473
- * reveal. Each step is durable, so a crash resumes from the intent. */
6474
5157
  async function installWorkspaceIntent(input) {
6475
5158
  const { identity, database, bindingDir, gitStorage, intent, readContent, durabilityBarrier, onStage, } = input;
6476
5159
  const existing = readGroundClosureRows(database, intent.workspaceId);
@@ -6479,8 +5162,6 @@ async function installWorkspaceIntent(input) {
6479
5162
  if (!root)
6480
5163
  throw new Error(`local workspace ${intent.workspaceId} has unresolved placement`);
6481
5164
  const localRecords = existing.map(portableRecord);
6482
- // Interrupted rows must be exactly what the install persisted, a played
6483
- // repository standing at its line (Live statedRecords).
6484
5165
  if (!sameRecords(statedRecords(localRecords, intent.records), intent.records)) {
6485
5166
  throw new Error(`local workspace ${intent.workspaceId} differs from its pending install`);
6486
5167
  }
@@ -6508,9 +5189,6 @@ async function installWorkspaceIntent(input) {
6508
5189
  if (pathExists(join(bindingDir, intent.workspaceId))) {
6509
5190
  throw new Error(`workspace ${intent.workspaceId} has a binding without committed entity rows`);
6510
5191
  }
6511
- // Staging retained from an interrupted install is deliberately kept: the
6512
- // staged download re-proves every retained chunk against its manifest and
6513
- // downloads only the gaps. Unverified staged bytes are never trusted.
6514
5192
  const { rows, measurements, durable } = await stageRoot({
6515
5193
  records: intent.records,
6516
5194
  staging: intent.stagingPath,
@@ -6519,17 +5197,13 @@ async function installWorkspaceIntent(input) {
6519
5197
  staged: true,
6520
5198
  database,
6521
5199
  bindingDir,
6522
- gitStorage,
5200
+ held: groundGitOwners(groundDatabase(database), null, gitStorage),
6523
5201
  gitLines: installGitLines(database, intent.resourceId, intent.deliveryWatermark, input.cacheDir),
5202
+ report: input.report,
6524
5203
  readContent,
6525
5204
  durabilityBarrier,
6526
5205
  });
6527
- // Only verified materialization discharges Apply work: the rows commit
6528
- // with what this install verified, and every other received record stays
6529
- // owed. They are written while the barrier drains and commit once the
6530
- // staging is verified: durable, and that milestone reported. The
6531
- // milestone's duration spans the whole materialization; its legs say where
6532
- // that wall time went after the content set itself.
5206
+ const occupied = [...await occupiedMembers(rows.map(stagedMember))];
6533
5207
  const verified = durable.then((proof) => onStage?.("materialization-verified", { ...measurements, ...proof }));
6534
5208
  const committed = persistRows(database, identity, intent.resourceId, intent.workspaceId, { observed: rows, shared: rows }, [], {
6535
5209
  verified: {
@@ -6537,17 +5211,14 @@ async function installWorkspaceIntent(input) {
6537
5211
  watermark: intent.deliveryWatermark,
6538
5212
  absent: intent.setAside,
6539
5213
  lines: playedLines(rows),
6540
- occupied: [...await occupiedMembers(rows.map(stagedMember))],
5214
+ occupied,
6541
5215
  resolvedAt: input.now(),
6542
5216
  ...(intent.onDemand ? { onDemandRoot: intent.workspaceId } : {}),
6543
5217
  },
6544
5218
  after: verified,
6545
5219
  });
6546
- // A failure before the staging is verified fails both; its own error is the one reported.
6547
5220
  committed.catch(() => { });
6548
5221
  await verified;
6549
- // Its legs: the rows arriving and the saves before them, the save running
6550
- // and held for the barrier, and the commit's write.
6551
5222
  const { posted, began, committing, ended } = await committed;
6552
5223
  await onStage?.("rows-committed", { queuedMs: Math.round(began - posted), ranMs: Math.round(committing - began),
6553
5224
  committedMs: Math.round(ended - committing) });
@@ -6558,14 +5229,10 @@ async function installWorkspaceIntent(input) {
6558
5229
  workspaceId: intent.workspaceId,
6559
5230
  absolutePath: intent.destinationPath,
6560
5231
  });
6561
- // No binding existed before rows (above), so this one first makes the root
6562
- // coverable: no coverage can predate the verified reveal.
6563
5232
  input.owesBaseline(intent.workspaceId);
6564
5233
  await onStage?.("binding-created");
6565
5234
  return { path: intent.destinationPath, rows: rows.length, records: rows.map((row) => row.record) };
6566
5235
  }
6567
- /** The authority's ready frame as Live sees it. The snapshot carries only the
6568
- * records the caller's scope selected — never a flattened whole account. */
6569
5236
  function readyFromFrame(frame, graph, records) {
6570
5237
  const cloud = {
6571
5238
  resourceId: String(frame.resource_id || ""),
@@ -6587,8 +5254,6 @@ function readyFromFrame(frame, graph, records) {
6587
5254
  },
6588
5255
  };
6589
5256
  }
6590
- /** What one leg physically did on the content plane: the counter movement
6591
- * between its start and end, ms rounded for the ledger. */
6592
5257
  function physicalPlaneDelta(before, after) {
6593
5258
  return {
6594
5259
  rangedGets: after.rangedGets - before.rangedGets,
@@ -6599,10 +5264,6 @@ function physicalPlaneDelta(before, after) {
6599
5264
  decryptMs: Math.round(after.decryptMs - before.decryptMs),
6600
5265
  };
6601
5266
  }
6602
- /** Immutable content reads and writes are idempotent. Retry transient wire or
6603
- * authority failures; reads additionally tolerate the brief not-found window
6604
- * between an immutable object acknowledgement and globally visible R2 state.
6605
- * The host's close ends the wait between attempts as it ends a request. */
6606
5267
  async function retryContent(signal, operation, eventualNotFound = false, attempts = 10) {
6607
5268
  if (!Number.isSafeInteger(attempts) || attempts < 1) {
6608
5269
  throw new Error("content retry attempts must be a positive integer");
@@ -6614,14 +5275,10 @@ async function retryContent(signal, operation, eventualNotFound = false, attempt
6614
5275
  }
6615
5276
  catch (error) {
6616
5277
  last = error;
6617
- // Physical geometry moved. The current fetch unit and every sibling ref
6618
- // came from one stale plan, so only Live's outer set loop may retry it.
6619
5278
  if (isContentPlacementChangedError(error))
6620
5279
  throw error;
6621
5280
  if (error instanceof Error && error.name === 'AbortError')
6622
5281
  throw error;
6623
- // A seal missing a block cannot succeed by asking again; only its
6624
- // planner, sending the block, can make the same request true.
6625
5282
  if (error instanceof WireRequestError && error.code === "entity_content_incomplete")
6626
5283
  throw error;
6627
5284
  if (error instanceof WireRequestError
@@ -6633,11 +5290,6 @@ async function retryContent(signal, operation, eventualNotFound = false, attempt
6633
5290
  }
6634
5291
  throw last;
6635
5292
  }
6636
- /** Send's cargo for a record made here. A source that no longer yields the
6637
- * hash its record names is cargo lost here (docs/entity-apply.md
6638
- * "recover()"): Detect owes its bytes sealed at capture. Retired proofs
6639
- * (`GroundBasisChangedError`) lose no bytes and are no need. The error and
6640
- * its retry stay as they were; only the count reads the need. */
6641
5293
  function lostHere(record, upload) {
6642
5294
  return async () => {
6643
5295
  try {
@@ -6651,11 +5303,20 @@ function lostHere(record, upload) {
6651
5303
  }
6652
5304
  };
6653
5305
  }
6654
- /** Whether `error` or a cause says a captured source no longer holds its bytes. */
6655
5306
  function sourceMoved(error) {
6656
5307
  for (let at = error; at instanceof Error; at = at.cause)
6657
5308
  if (at instanceof StaleCaptureError)
6658
5309
  return true;
6659
5310
  return false;
6660
5311
  }
6661
- //# sourceMappingURL=user-ground-host.js.map
5312
+ function folderStanding(path) {
5313
+ try {
5314
+ const real = realpathSync(shelfName(path));
5315
+ return statSync(real).isDirectory() ? real : null;
5316
+ }
5317
+ catch (error) {
5318
+ if (error.code === "ENOENT" || error.code === "ENOTDIR")
5319
+ return null;
5320
+ throw error;
5321
+ }
5322
+ }