rvlib-shipkit 2.31.0 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/package.json +1 -1
  3. package/src/advisors/acts.ts +16 -15
  4. package/src/advisors/advice.ts +56 -102
  5. package/src/advisors/advisor-view.ts +122 -76
  6. package/src/advisors/app-graph.ts +1 -1
  7. package/src/advisors/app.ts +3 -11
  8. package/src/advisors/cf-api.ts +1 -1
  9. package/src/advisors/dir-bucket.ts +4 -3
  10. package/src/advisors/edge/api.ts +20 -221
  11. package/src/advisors/edge/bucket.ts +2 -2
  12. package/src/advisors/edge/handler.ts +13 -155
  13. package/src/advisors/edge/here.ts +5 -5
  14. package/src/advisors/edge/pages.ts +12 -9
  15. package/src/advisors/edge/shell.ts +6 -5
  16. package/src/advisors/edge/sign-in.ts +101 -36
  17. package/src/advisors/edge/status.ts +19 -6
  18. package/src/advisors/edge/types.ts +36 -60
  19. package/src/advisors/expose.ts +29 -29
  20. package/src/advisors/here.ts +12 -12
  21. package/src/advisors/invite-send.ts +79 -35
  22. package/src/advisors/invite.ts +31 -8
  23. package/src/advisors/job.ts +24 -16
  24. package/src/advisors/login.ts +40 -15
  25. package/src/advisors/owner-store.ts +46 -22
  26. package/src/advisors/photos.ts +3 -3
  27. package/src/advisors/project.ts +27 -25
  28. package/src/advisors/reach.ts +89 -0
  29. package/src/advisors/rights.ts +1 -1
  30. package/src/advisors/routes.ts +55 -74
  31. package/src/advisors/scan.ts +0 -4
  32. package/src/advisors/setup-run.ts +14 -14
  33. package/src/advisors/share-trace.ts +3 -3
  34. package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
  35. package/src/advisors/speaks.ts +29 -0
  36. package/src/advisors/sync.ts +97 -183
  37. package/src/advisors/tunnel.ts +6 -5
  38. package/src/advisors/users-listen.ts +92 -0
  39. package/src/advisors/users-router.ts +261 -87
  40. package/src/advisors/users-store.ts +81 -0
  41. package/src/agent-time/blocked-scan.ts +181 -0
  42. package/src/agent-time/registry.ts +12 -5
  43. package/src/agent-time/store.ts +9 -109
  44. package/src/asks/ask-bar-fold.ts +2 -1
  45. package/src/asks/ask-close.ts +2 -1
  46. package/src/asks/ask-doc.ts +2 -1
  47. package/src/asks/ask-migrate.ts +3 -2
  48. package/src/asks/ask-steps-fold.ts +2 -1
  49. package/src/asks/ask-store.ts +4 -3
  50. package/src/check.ts +3 -43
  51. package/src/checks/SK001-package-json-shape.check.ts +4 -55
  52. package/src/checks/SK004-gitignore-policy.check.ts +24 -69
  53. package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
  54. package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
  55. package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
  56. package/src/checks/SK020-self-spawning-check.check.ts +5 -7
  57. package/src/checks/SK035-public-clean.check.ts +1 -1
  58. package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
  59. package/src/checks/SK042-post-kinds.check.ts +5 -14
  60. package/src/checks/SK054-agent-allow-list.check.ts +5 -74
  61. package/src/checks/SK055-retired-config-keys.check.ts +45 -0
  62. package/src/cli/cmd_Advisors.ts +11 -45
  63. package/src/cli/cmd_Asks.ts +3 -10
  64. package/src/cli/cmd_Backup.ts +25 -127
  65. package/src/cli/cmd_BackupTargets.ts +1 -1
  66. package/src/cli/cmd_Capacity.ts +6 -2
  67. package/src/cli/cmd_Checks.ts +0 -14
  68. package/src/cli/cmd_Ci.ts +2 -1
  69. package/src/cli/cmd_Db.ts +3 -82
  70. package/src/cli/cmd_Home.ts +4 -32
  71. package/src/cli/cmd_Hq.ts +0 -17
  72. package/src/cli/cmd_Releases.ts +57 -4
  73. package/src/cli/cmd_Review.ts +333 -354
  74. package/src/cli/cmd_Shot.ts +26 -4
  75. package/src/cli/cmd_SocialDrafts.ts +6 -13
  76. package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
  77. package/src/cli/cmd_Time.ts +1 -1
  78. package/src/cli/cmd_Trailer.ts +1 -1
  79. package/src/cli/inbox-hook-run.ts +5 -23
  80. package/src/cli/registry-heads.ts +5 -55
  81. package/src/cli/registry.ts +1 -5
  82. package/src/cli/review-here.ts +1 -1
  83. package/src/cli.ts +15 -4
  84. package/src/collections/collection-types.ts +1 -1
  85. package/src/collections/review.ts +5 -4
  86. package/src/core/admission.ts +268 -0
  87. package/src/core/agent-allow-policy.ts +32 -2
  88. package/src/core/agent-env.ts +8 -0
  89. package/src/core/allow-rows.ts +74 -0
  90. package/src/core/check-file-names.ts +19 -106
  91. package/src/core/code-lines.ts +36 -21
  92. package/src/core/footprint.ts +17 -13
  93. package/src/core/identities-root.ts +1 -4
  94. package/src/core/layout.ts +1 -2
  95. package/src/core/machine-db.ts +33 -208
  96. package/src/core/machine-layout.ts +14 -127
  97. package/src/core/machine-read.ts +5 -2
  98. package/src/core/mask-source.ts +60 -0
  99. package/src/core/memory-watch.ts +17 -14
  100. package/src/core/motherhome.ts +8 -35
  101. package/src/core/one-way-in-policy.ts +0 -3
  102. package/src/core/peer-sk.ts +8 -0
  103. package/src/core/repo-walk.ts +0 -9
  104. package/src/core/retention.ts +1 -9
  105. package/src/core/retired-checks.ts +2 -0
  106. package/src/core/tmux-policy.ts +1 -1
  107. package/src/core/tree-watch.ts +2 -2
  108. package/src/core/when.ts +7 -45
  109. package/src/gate/admit-heavy.ts +150 -0
  110. package/src/gate/check-runner.ts +6 -0
  111. package/src/gate/discover-checks.ts +42 -32
  112. package/src/gate/gate-checks.ts +21 -131
  113. package/src/gate/head-gate.ts +1 -1
  114. package/src/gate/job-run.ts +2 -1
  115. package/src/gate/pre-commit-discovery.ts +22 -28
  116. package/src/gate/run-check.ts +3 -4
  117. package/src/gate/run-ci.ts +4 -0
  118. package/src/gate/run-fix.ts +5 -17
  119. package/src/gate/run-fixers.ts +6 -42
  120. package/src/home/app-sign.ts +2 -2
  121. package/src/home/backup-status.ts +52 -92
  122. package/src/home/backup-verdict.ts +2 -2
  123. package/src/home/daemon-jobs.ts +51 -95
  124. package/src/home/database-words.ts +1 -2
  125. package/src/home/databases.ts +9 -25
  126. package/src/home/home-launchd.ts +0 -6
  127. package/src/home/home-paths.ts +8 -4
  128. package/src/home/home-routes.ts +3 -10
  129. package/src/home/home-state.ts +2 -14
  130. package/src/home/inbox-shape.ts +14 -15
  131. package/src/home/inbox.ts +1 -1
  132. package/src/home/machine-repair.ts +102 -103
  133. package/src/home/resume.ts +1 -15
  134. package/src/home/run-daemon.ts +7 -12
  135. package/src/home/space-page.ts +3 -2
  136. package/src/home/supervise.ts +3 -7
  137. package/src/hooks/commit-msg-run.ts +61 -0
  138. package/src/hooks/commit-run.ts +16 -166
  139. package/src/hooks/gate-outcome.ts +108 -0
  140. package/src/hooks/git-hook.ts +9 -9
  141. package/src/hooks/hook-config.ts +8 -8
  142. package/src/hooks/leak-guard.ts +1 -1
  143. package/src/hooks/pre-commit-checks.ts +1 -1
  144. package/src/hooks/run-hooks.ts +2 -6
  145. package/src/hooks/shared-file.ts +3 -2
  146. package/src/hq/daemon-db.ts +8 -8
  147. package/src/hq/door.ts +3 -16
  148. package/src/hq/hq-db.ts +4 -3
  149. package/src/hq/hq-local.ts +1 -2
  150. package/src/hq/hq-store.ts +0 -15
  151. package/src/hq/item-direct.ts +8 -10
  152. package/src/hq/item-fill.ts +37 -0
  153. package/src/hq/kinds/item-gone.ts +7 -10
  154. package/src/hq/kinds/item-msg.ts +12 -18
  155. package/src/hq/kinds/item.ts +13 -19
  156. package/src/hq/kinds/report.ts +3 -4
  157. package/src/hq/owner-switch.ts +3 -3
  158. package/src/hq/report.ts +5 -9
  159. package/src/hq/switch.ts +2 -11
  160. package/src/hq/thread-sync.ts +5 -17
  161. package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
  162. package/src/http/owner-word.ts +1 -1
  163. package/src/identities/machine.ts +16 -0
  164. package/src/init-repo.ts +0 -1
  165. package/src/ledger/check-stats.ts +6 -5
  166. package/src/ledger/db.ts +2 -4
  167. package/src/ledger/record-kept.ts +117 -48
  168. package/src/ledger/run-log.ts +21 -2
  169. package/src/ledger/slow-tests.ts +96 -0
  170. package/src/ledger/store.ts +3 -86
  171. package/src/ledger/suite-log.ts +8 -2
  172. package/src/media-store/backup/facts.ts +3 -37
  173. package/src/media-store/backup/keys.ts +1 -8
  174. package/src/media-store/backup/manifest.ts +6 -67
  175. package/src/media-store/backup/restore.ts +4 -13
  176. package/src/media-store/backup/retention.ts +13 -1
  177. package/src/media-store/backup/run.ts +6 -267
  178. package/src/media-store/backup/snapshot.ts +2 -38
  179. package/src/media-store/backup/sources.ts +3 -113
  180. package/src/media-store/backup/target-send.ts +5 -29
  181. package/src/media-store/db.ts +8 -7
  182. package/src/media-store/forget-one.ts +1 -1
  183. package/src/media-store/forget.ts +1 -80
  184. package/src/orchestrator/guards.ts +0 -1
  185. package/src/orchestrator/presence.ts +2 -2
  186. package/src/orchestrator/routes.ts +1 -1
  187. package/src/orchestrator/started.ts +0 -9
  188. package/src/orchestrator/talk-key.ts +3 -4
  189. package/src/orchestrator/unheard.ts +1 -1
  190. package/src/plan/planner.ts +3 -2
  191. package/src/recordings/edit.ts +3 -3
  192. package/src/recordings/marks-draw.ts +17 -6
  193. package/src/recordings/marks.ts +120 -9
  194. package/src/reflections/reflections-queue.ts +3 -10
  195. package/src/release/notes.ts +1 -1
  196. package/src/release/public-clean.ts +66 -6
  197. package/src/release/run-bump.ts +11 -0
  198. package/src/release/run-release.ts +4 -0
  199. package/src/releases/from-thread.ts +3 -3
  200. package/src/releases/model.ts +186 -36
  201. package/src/releases/store.ts +13 -3
  202. package/src/releases/validate.ts +83 -0
  203. package/src/repo-config.ts +36 -64
  204. package/src/review/answer-kinds.ts +63 -4
  205. package/src/review/blocked-guard.ts +11 -0
  206. package/src/review/blocked-object.ts +298 -0
  207. package/src/review/cells.ts +144 -230
  208. package/src/review/close.ts +39 -1
  209. package/src/review/doc-save.ts +3 -2
  210. package/src/review/draft-item.ts +1 -1
  211. package/src/review/events.ts +3 -7
  212. package/src/review/expect.ts +23 -39
  213. package/src/review/format.ts +79 -46
  214. package/src/review/glyphs.ts +1 -0
  215. package/src/review/hand-over.ts +3 -3
  216. package/src/review/heard.ts +1 -1
  217. package/src/review/holds-sync.ts +2 -1
  218. package/src/review/inbox-hook.ts +2 -2
  219. package/src/review/inbox-read.ts +39 -33
  220. package/src/review/instruction-guards.ts +12 -0
  221. package/src/review/instructions.ts +0 -1
  222. package/src/review/item-db.ts +13 -43
  223. package/src/review/item-hq.ts +2 -2
  224. package/src/review/item-rows.ts +3 -14
  225. package/src/review/kind-catalog.ts +3 -1
  226. package/src/review/kinds.ts +18 -8
  227. package/src/review/live-view.ts +3 -0
  228. package/src/review/media-kind.ts +1 -1
  229. package/src/review/mentions.ts +1 -2
  230. package/src/review/model.ts +158 -114
  231. package/src/review/move.ts +149 -0
  232. package/src/review/need-threads.ts +3 -2
  233. package/src/review/object-card.ts +11 -0
  234. package/src/review/object-read.ts +6 -1
  235. package/src/review/one-block.ts +1 -1
  236. package/src/review/owner-read.ts +1 -1
  237. package/src/review/phone-push.ts +10 -9
  238. package/src/review/previews.ts +32 -4
  239. package/src/review/push.ts +2 -2
  240. package/src/review/recap.ts +129 -0
  241. package/src/review/referring.ts +6 -3
  242. package/src/review/reflection-object.ts +4 -3
  243. package/src/review/routes.ts +51 -47
  244. package/src/review/secret-route.ts +3 -2
  245. package/src/review/settle.ts +0 -6
  246. package/src/review/snooze.ts +5 -3
  247. package/src/review/speaker.ts +68 -0
  248. package/src/review/start-title.ts +19 -0
  249. package/src/review/store-parties.ts +28 -0
  250. package/src/review/store.ts +94 -59
  251. package/src/review/{wakes.ts → thread-events.ts} +92 -7
  252. package/src/review/thread-md.ts +35 -14
  253. package/src/review/thread-state.ts +804 -0
  254. package/src/review/threads.ts +29 -347
  255. package/src/review/traces.ts +104 -7
  256. package/src/review/trailer-item.ts +1 -1
  257. package/src/review/unit.ts +7 -9
  258. package/src/review/verdict-items.ts +12 -10
  259. package/src/review/view-layout.ts +25 -1
  260. package/src/review/watch-feed.ts +1 -2
  261. package/src/review/working-guards.ts +2 -3
  262. package/src/rules/untrack-generated.ts +1 -15
  263. package/src/secrets/copy.ts +4 -4
  264. package/src/secrets/lapse.ts +2 -1
  265. package/src/serve/hub-app/advisor-app.tsx +4 -4
  266. package/src/serve/hub-app/advisor-face.tsx +9 -3
  267. package/src/serve/hub-app/advisor-host.ts +27 -27
  268. package/src/serve/hub-app/advisors-model.ts +17 -8
  269. package/src/serve/hub-app/advisors-rights.tsx +1 -1
  270. package/src/serve/hub-app/advisors-st.ts +15 -14
  271. package/src/serve/hub-app/advisors-view.tsx +13 -11
  272. package/src/serve/hub-app/app-bridge.ts +23 -3
  273. package/src/serve/hub-app/asks-page.tsx +1 -1
  274. package/src/serve/hub-app/auto-text.tsx +71 -16
  275. package/src/serve/hub-app/check-view.tsx +0 -8
  276. package/src/serve/hub-app/controls.css +14 -3
  277. package/src/serve/hub-app/database-view.tsx +1 -2
  278. package/src/serve/hub-app/dock-st.ts +1 -1
  279. package/src/serve/hub-app/git-view.tsx +3 -1
  280. package/src/serve/hub-app/hub.css +12 -5
  281. package/src/serve/hub-app/icons.tsx +1 -1
  282. package/src/serve/hub-app/inbox-view.tsx +1 -2
  283. package/src/serve/hub-app/live-sources.ts +2 -2
  284. package/src/serve/hub-app/main-panel.tsx +2 -1
  285. package/src/serve/hub-app/panel-repo.ts +0 -9
  286. package/src/serve/hub-app/pic.tsx +29 -12
  287. package/src/serve/hub-app/polled.ts +16 -2
  288. package/src/serve/hub-app/recordings-st.ts +23 -2
  289. package/src/serve/hub-app/recordings-view.tsx +68 -10
  290. package/src/serve/hub-app/ref-pill.ts +1 -1
  291. package/src/serve/hub-app/repo-st.ts +1 -2
  292. package/src/serve/hub-app/review/advisor-add.tsx +1 -1
  293. package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
  294. package/src/serve/hub-app/review/draft-body.tsx +2 -2
  295. package/src/serve/hub-app/review/heard-line.tsx +1 -1
  296. package/src/serve/hub-app/review/instructions-view.tsx +1 -8
  297. package/src/serve/hub-app/review/kind-states.tsx +14 -9
  298. package/src/serve/hub-app/review/kit.tsx +4 -11
  299. package/src/serve/hub-app/review/lane-bar.tsx +3 -3
  300. package/src/serve/hub-app/review/lightbox.tsx +15 -11
  301. package/src/serve/hub-app/review/line-window.ts +4 -1
  302. package/src/serve/hub-app/review/live-bar-st.ts +2 -2
  303. package/src/serve/hub-app/review/live-view.tsx +57 -1
  304. package/src/serve/hub-app/review/object-panel.tsx +20 -8
  305. package/src/serve/hub-app/review/question-views.tsx +191 -53
  306. package/src/serve/hub-app/review/recap-bar.tsx +40 -0
  307. package/src/serve/hub-app/review/request-cell.tsx +48 -0
  308. package/src/serve/hub-app/review/review-cells.tsx +154 -96
  309. package/src/serve/hub-app/review/review-host.ts +8 -4
  310. package/src/serve/hub-app/review/review-kit.ts +17 -11
  311. package/src/serve/hub-app/review/review-list.tsx +30 -35
  312. package/src/serve/hub-app/review/review-st.ts +32 -42
  313. package/src/serve/hub-app/review/review-thread.tsx +139 -85
  314. package/src/serve/hub-app/review/review-views.tsx +127 -68
  315. package/src/serve/hub-app/review/share-lines.tsx +4 -4
  316. package/src/serve/hub-app/review/start-st.ts +2 -5
  317. package/src/serve/hub-app/review/superseded-runs.ts +4 -3
  318. package/src/serve/hub-app/review/thread-close.tsx +10 -7
  319. package/src/serve/hub-app/review/thread-st.ts +381 -202
  320. package/src/serve/hub-app/review/tone-bar.tsx +129 -0
  321. package/src/serve/hub-app/review/tones.ts +53 -0
  322. package/src/serve/hub-app/review/trailer-body.tsx +2 -2
  323. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  324. package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
  325. package/src/serve/hub-app/review.css +189 -106
  326. package/src/serve/hub-app/search-view.tsx +1 -1
  327. package/src/serve/hub-app/social/social-model.ts +0 -4
  328. package/src/serve/hub-app/source-acts.ts +2 -1
  329. package/src/serve/hub-app/stores/stores-page.tsx +2 -2
  330. package/src/serve/hub-app/terminal-sources.tsx +2 -1
  331. package/src/serve/hub-app/thread-row.tsx +3 -4
  332. package/src/serve/hub-app/tree-build.ts +0 -4
  333. package/src/serve/hub-app/urls-view.tsx +2 -1
  334. package/src/serve/hub-app/view-layout.css +13 -3
  335. package/src/serve/hub-app/wikis-view.tsx +5 -2
  336. package/src/serve/hub-runtime.ts +7 -37
  337. package/src/serve/project-gutter-route.ts +6 -2
  338. package/src/serve/read-thread.ts +20 -2
  339. package/src/serve/read-worker.ts +9 -1
  340. package/src/serve/record-pages.ts +46 -0
  341. package/src/serve/serve-hub.ts +2 -2
  342. package/src/serve/terminal-host.ts +1 -1
  343. package/src/serve/terminal-route.ts +1 -3
  344. package/src/serve/tracked-watch.ts +1 -3
  345. package/src/setup-house.ts +2 -2
  346. package/src/shipkit-files.ts +1 -1
  347. package/src/shipkit.ts +1 -6
  348. package/src/shot/client.ts +2 -1
  349. package/src/shot/film-box.ts +0 -20
  350. package/src/shot/on-place.ts +141 -0
  351. package/src/social/drafts.ts +1 -1
  352. package/src/social/kinds.ts +6 -29
  353. package/src/social/load.ts +2 -2
  354. package/src/social/post-object.ts +3 -2
  355. package/src/social/release-stage.ts +1 -1
  356. package/src/social/stage.ts +2 -2
  357. package/src/stores/model.ts +4 -0
  358. package/src/stores/routes.ts +11 -3
  359. package/src/suite/judge-suites.ts +58 -0
  360. package/src/suite/red-alone.ts +54 -18
  361. package/src/suite/runner-shapes.ts +2 -2
  362. package/src/suite/suite-cli.ts +67 -14
  363. package/src/suite/test-units.ts +2 -1
  364. package/src/urls/fill.ts +1 -1
  365. package/src/urls/places.ts +1 -2
  366. package/src/vault/vault-config.ts +2 -2
  367. package/src/vault/vault-init.ts +1 -5
  368. package/src/wiki/graph-page.ts +14 -2
  369. package/src/advisors/copy-truth.ts +0 -49
  370. package/src/advisors/door-child.ts +0 -112
  371. package/src/advisors/door-serve.ts +0 -52
  372. package/src/advisors/door.ts +0 -118
  373. package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
  374. package/src/checks/SK029-explicit-check-files.check.ts +0 -112
  375. package/src/checks/SK048-one-local-file.check.ts +0 -36
  376. package/src/core/config-rewrite.ts +0 -111
  377. package/src/core/daemon-port.ts +0 -10
  378. package/src/core/legacy-shapes.ts +0 -263
  379. package/src/core/migrate-layout.ts +0 -638
  380. package/src/core/port-check-cli.ts +0 -52
  381. package/src/core/port-check-file.ts +0 -295
  382. package/src/core/port-check-files.ts +0 -31
  383. package/src/gate/discover-legacy-checks.ts +0 -26
  384. package/src/home/home-move.ts +0 -527
  385. package/src/home/machine-fold.ts +0 -810
  386. package/src/hq/item-shapes.ts +0 -54
  387. package/src/hq/kinds/items-read.ts +0 -4
  388. package/src/media-store/backup/daemon.ts +0 -220
  389. package/src/media-store/backup/kept.ts +0 -241
  390. package/src/media-store/backup/prune.ts +0 -359
  391. package/src/media-store/backup/secret.ts +0 -88
  392. package/src/media-store/backup/ssh-space.ts +0 -202
  393. package/src/media-store/backup/watch.ts +0 -117
  394. package/src/review/band.ts +0 -182
  395. package/src/review/folders.ts +0 -216
  396. package/src/review/hook-ask.ts +0 -58
  397. package/src/review/role.ts +0 -48
  398. package/src/review/thread-fold.ts +0 -64
  399. package/src/review/wait.ts +0 -91
  400. package/src/rules/rule.ts +0 -43
  401. package/src/serve/hook-thread.ts +0 -37
  402. package/src/serve/hook-work.ts +0 -92
  403. package/src/serve/hook-worker.ts +0 -57
  404. package/src/serve/hub-app/review/dock.tsx +0 -147
  405. package/src/serve/hub-app/review/faces.tsx +0 -18
  406. package/src/serve/hub-app/review/item-verdict.tsx +0 -112
  407. package/src/serve/hub-app/review/review-board.tsx +0 -48
  408. /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
package/src/hq/hq-db.ts CHANGED
@@ -4,7 +4,7 @@ import type { Database } from 'bun:sqlite'
4
4
  import { migrateTo, openWith, ownerOnly } from '../ledger/db.ts'
5
5
  import { TARGETS_SCHEMA } from './backup-targets.ts'
6
6
  import { KINDS } from './kinds/index.ts'
7
- import { fillItemRows } from './item-shapes.ts'
7
+ import { fillItemRows } from './item-fill.ts'
8
8
  import { HQ_FILE_VERSION, hqDbPath } from './hq-role.ts'
9
9
 
10
10
  // people who owns nodes
@@ -26,7 +26,8 @@ import { HQ_FILE_VERSION, hqDbPath } from './hq-role.ts'
26
26
  // last read through the vault route (vault-route.ts): one row a node, gone with its end
27
27
  // meta the file's own words: its `name`, made once and kept by a restore, and the feed's generation `gen`
28
28
  // backup_targets the places the house's backups go (backup-targets.ts): an ssh machine or a bucket the config names (18)
29
- // review_* the items in the store's own tables beside `cards` and `card_msgs`, filled once (20, item-shapes.ts)
29
+ // review_* the items in the store's own tables, the item kinds' (20). A file of before holds them in `cards` and
30
+ // `card_msgs` too, which fill them once and are kept as they were (item-fill.ts)
30
31
  // wanted a switch value the hq's console wants a node to take (sk hq switch): given to that node alone at its
31
32
  // hello, `done` once a report of that node shows the value
32
33
  // The rows the daemons send are in the tables of their kind (kinds/)
@@ -83,7 +84,7 @@ export function openHq(path: string = hqDbPath(), o: { create?: boolean } = {}):
83
84
  if (was > 0 && was < 5) db.exec("insert or ignore into outboxes (node, epoch, applied) select id, epoch, applied from nodes where epoch <> ''")
84
85
  for (const k of KINDS) db.exec(k.schema)
85
86
  if (db.query("select 1 from sqlite_master where name = 'card_gone_v6'").get() != null) db.exec("insert or ignore into card_gone (repo, id, created, node, at) select repo, id, '', node, at from card_gone_v6; drop table card_gone_v6")
86
- // the items in the store's own tables, each rev computed again: one that differs keeps the file at its version (20)
87
+ // the items of a file of before 20 in the store's own tables, each rev computed again: one that differs keeps the file at its version
87
88
  let filled: ReturnType<typeof fillItemRows>
88
89
  try {
89
90
  filled = fillItemRows(db)
@@ -290,7 +290,6 @@ export async function hqReportTick(o: { repos: { name: string; path: string }[];
290
290
  const waiting = db.query('select count(*) as waiting, min(since) as since from retry').get() as { waiting: number; since: number | null }
291
291
  const { machineFacts, realReaders } = await import('./report-facts.ts')
292
292
  const { mediaReport } = await import('../media-store/daemon.ts')
293
- const { ownBackupFacts } = await import('../media-store/backup/facts.ts')
294
293
  const facts = await machineFacts({ repos, now, ...(await realReaders()), ...(o.urls == null ? {} : { urls: o.urls }) })
295
294
  // what the hq holds of this machine's rows, counted once an hour and carried by every report
296
295
  const { holdsTick } = await import('./hq-holds.ts')
@@ -298,7 +297,7 @@ export async function hqReportTick(o: { repos: { name: string; path: string }[];
298
297
  o.printErr(`WARN hq report: what the hq holds of this machine is not counted: ${(e as Error).message}`)
299
298
  return null
300
299
  })
301
- outbox.push('report', await buildReport({ repos, house: o.house, tailnet: { name: status?.Self?.DNSName?.replace(/\.$/, '') || null, up: status?.BackendState === 'Running' }, diskOf: homeDir(), cards: waiting, media: mediaReport(), backups: await ownBackupFacts(now), ...(holds == null ? {} : { holds }), ...facts }), now)
300
+ outbox.push('report', await buildReport({ repos, house: o.house, tailnet: { name: status?.Self?.DNSName?.replace(/\.$/, '') || null, up: status?.BackendState === 'Running' }, diskOf: homeDir(), cards: waiting, media: mediaReport(), ...(holds == null ? {} : { holds }), ...facts }), now)
302
301
  const r = await flush(outbox, hq, now)
303
302
  if ('refused' in r) return o.printErr(`WARN hq report: ${r.refused} (${outbox.size()} rows wait in the outbox)`)
304
303
  if (r.renamed) o.printErr('WARN hq report: the hq held rows this outbox never made (the outbox is an older copy of itself): it took a new name and sent every row it holds again')
@@ -16,7 +16,6 @@ import { machineLabel } from '../http/door-forward.ts'
16
16
  import type { Report } from './report.ts'
17
17
  import { afarRefusal, type Wanted } from './switch.ts'
18
18
  import { isOnceAsk, ONCE_ASKS } from './follow-fact.ts'
19
- import { compareShapes, shapesLine } from './item-shapes.ts'
20
19
 
21
20
  export type Grant = { kind: 'all' } | { kind: 'repo' | 'identity' | 'machine'; name: string }
22
21
 
@@ -76,9 +75,6 @@ export const READ_MAX_ROWS = 2_000
76
75
  export const SWEEP_EVERY_MS = 3600_000
77
76
  const SWEEP_AT_CAP_MS = 60_000
78
77
 
79
- /** the `meta` word of the last compare of the items in their two shapes */
80
- export const SHAPES_WORD = 'item-shapes'
81
-
82
78
  const sha = (s: string): string => createHash('sha256').update(s).digest('hex')
83
79
  const mint = (bytes: number): string => randomBytes(bytes).toString('base64url')
84
80
 
@@ -132,7 +128,6 @@ export class HqStore {
132
128
  const logged = new Set(gone.map((g) => `${g.kind}\t${g.name}`))
133
129
  for (const k of KINDS) for (const name of k.forgotten?.(this.db) ?? []) if (!logged.has(`${k.kind}\t${name}`)) this.forgotten.add(k.kind, name)
134
130
  }
135
- this.keepShapes(Date.now())
136
131
  }
137
132
 
138
133
  private word(name: string, make: () => string): string {
@@ -582,19 +577,9 @@ export class HqStore {
582
577
  recountUsage(this.db)
583
578
  }).immediate()
584
579
  const invites = this.db.query('delete from invites where (used is not null and used < ?1) or expires < ?1').run(now - 24 * 3600_000).changes
585
- this.keepShapes(now)
586
580
  return { rows, invites }
587
581
  }
588
582
 
589
- /** the items in their two shapes compared, at the open and at each sweep (a tenth of a second on the owner's
590
- * file): kept in `meta` with its time for the database page, a difference said in the daemon's log */
591
- keepShapes(now: number): void {
592
- const shapes = compareShapes(this.db)
593
- if (shapes == null) return
594
- this.setWord(SHAPES_WORD, JSON.stringify({ at: now, ...shapes }))
595
- if (!shapes.ok) console.error(`WARN hq: ${shapesLine(shapes)}`)
596
- }
597
-
598
583
  /** a switch value for every live node of one machine with the grant all (its id or its name), from the hq's console alone: never
599
584
  * reached from a route a token opens. The switch must be one this code declares settable from afar; the node's
600
585
  * own code decides again when it applies it */
@@ -1,5 +1,5 @@
1
1
  // a write of the review store straight into the hq's file, on the machine that carries it (review/item-hq.ts): the
2
- // checks the hq's door runs on a daemon's row, then both shapes and the feed entry, inside the store's own write
2
+ // checks the hq's door runs on a daemon's row, then the store's rows and the feed entry, inside the store's own write
3
3
  // transaction on that file. What a daemon of another machine sends goes through HqStore.apply; these are the same
4
4
  // kinds' checks and the same writes (kinds/item*.ts), with no outbox and no hop.
5
5
  // The one constraint a reader breaks first: a refusal throws, so the store's transaction takes the whole write back
@@ -13,14 +13,12 @@ import { feedMove, type RowKind } from './kinds/kind.ts'
13
13
 
14
14
  const refused = (why: string): Error => Object.assign(new Error(`the hq file refused this write of the threads: ${why}`), { code: 'EHQREFUSED' })
15
15
 
16
- /** the door's checks of one row, as HqStore.apply runs them: its size, its shape, a refusal, a wait: its text */
17
- function door(k: RowKind, body: unknown, max: number, db: Database, node: string, now: number): string {
18
- const text = JSON.stringify(body)
19
- if (Buffer.byteLength(text) > max) throw refused(`a row of kind ${k.kind} is over ${max} bytes`)
16
+ /** the door's checks of one row, as HqStore.apply runs them: its size, its shape, a refusal, a wait */
17
+ function door(k: RowKind, body: unknown, max: number, db: Database, node: string, now: number): void {
18
+ if (Buffer.byteLength(JSON.stringify(body)) > max) throw refused(`a row of kind ${k.kind} is over ${max} bytes`)
20
19
  if (!k.check(body)) throw refused(`the row is no ${k.kind}`)
21
20
  const why = k.refuses?.(db, body, { node, now }) ?? k.keeps?.(db, body) ?? null
22
21
  if (why != null) throw refused(why)
23
- return text
24
22
  }
25
23
 
26
24
  /** a head written in the hq's file: made on top of the head the file held (`base`), as a daemon's change is */
@@ -28,16 +26,16 @@ export function directHead(db: Database, repo: string, id: string, head: unknown
28
26
  const rev = revOf(head)
29
27
  const held = (db.query('select rev from review_cards where repo = ? and id = ?').get(repo, id) as { rev: string } | null)?.rev
30
28
  const body: ItemBody = { repo, id, head: head as Record<string, unknown>, rev, ...(held == null || held === rev ? {} : { base: held }) }
31
- const text = door(itemKind, body, ITEM_MAX_ROW_BYTES, db, node, at)
32
- storeHead(db, body, node, at, text)
29
+ door(itemKind, body, ITEM_MAX_ROW_BYTES, db, node, at)
30
+ storeHead(db, body, node, at)
33
31
  feedMove(db, 'card', repo, itemName(repo, id), at)
34
32
  }
35
33
 
36
34
  /** a message added in the hq's file: false when one holds its id */
37
35
  export function directMessage(db: Database, repo: string, card: string, m: { id: string }, at: number, node: string): boolean {
38
36
  const body: ItemMsgBody = { repo, card, id: m.id, msg: m as Record<string, unknown> }
39
- const text = door(itemMsgKind, body, MAX_ROW_BYTES, db, node, at)
40
- if (!storeMsg(db, body, node, at, text)) return false
37
+ door(itemMsgKind, body, MAX_ROW_BYTES, db, node, at)
38
+ if (!storeMsg(db, body, node)) return false
41
39
  feedMove(db, 'card-msg', repo, itemMsgName(repo, card, m.id), at)
42
40
  return true
43
41
  }
@@ -0,0 +1,37 @@
1
+ // the migration of an hq file older than version 20 (wiki tools/shipkit/hq.md, The items): its items were in `cards`
2
+ // and `card_msgs`, and fill the store's own tables once, each rev computed again. Those two tables stay in such a
3
+ // file with their rows, and nothing reads or writes them after the fill; a file made at 20 never has them.
4
+ // The one constraint a reader breaks first: a head is the store's text of it (`JSON.stringify(head)`), never the
5
+ // body the kind kept, so a rev is always the sha of what the store reads
6
+ import type { Database } from 'bun:sqlite'
7
+ import { putHead, putMessage } from '../review/item-rows.ts'
8
+ import { revOf } from '../review/rev.ts'
9
+
10
+ /** what a fill of the store's tables did, and how long it took */
11
+ export type ItemFill = { heads: number; messages: number; ms: number }
12
+
13
+ const has = (db: Database, table: string): boolean => db.query("select 1 from sqlite_master where type = 'table' and name = ?").get(table) != null
14
+
15
+ /** the store's tables filled once from `cards` and `card_msgs`, in the migration's transaction, the tables made
16
+ * before: a row whose rev does not compute again throws, so the migration takes nothing back but its own
17
+ * transaction and the file stays at its version */
18
+ export function fillItemRows(db: Database): ItemFill {
19
+ const t0 = performance.now()
20
+ const held = (db.query('select (select count(*) from review_cards) + (select count(*) from review_msgs) as n').get() as { n: number }).n
21
+ if (held > 0) return { heads: 0, messages: 0, ms: performance.now() - t0 }
22
+ let heads = 0
23
+ if (has(db, 'cards')) for (const r of db.query('select repo, id, node, at, rev, body from cards order by at, repo, id').iterate() as IterableIterator<{ repo: string; id: string; node: string; at: number; rev: string; body: string }>) {
24
+ const b = JSON.parse(r.body) as { head: unknown; base?: string }
25
+ if (revOf(b.head) !== r.rev) throw new Error(`the hq file stays at its version: head ${r.id} of ${r.repo} holds rev ${r.rev.slice(0, 12)}, its head computes another, nothing is filled`)
26
+ putHead(db, r.repo, r.id, b.head, r.at, { node: r.node, base: b.base ?? null })
27
+ heads++
28
+ }
29
+ let messages = 0
30
+ if (has(db, 'card_msgs')) for (const r of db.query('select repo, card, id, node, rev, body from card_msgs order by repo, card, id').iterate() as IterableIterator<{ repo: string; card: string; id: string; node: string; rev: string; body: string }>) {
31
+ const m = (JSON.parse(r.body) as { msg: { id: string } }).msg
32
+ if (revOf(m) !== r.rev) throw new Error(`the hq file stays at its version: message ${r.card}/${r.id} of ${r.repo} holds rev ${r.rev.slice(0, 12)}, its body computes another, nothing is filled`)
33
+ putMessage(db, r.repo, r.card, m, { node: r.node })
34
+ messages++
35
+ }
36
+ return { heads, messages, ms: performance.now() - t0 }
37
+ }
@@ -6,10 +6,10 @@
6
6
  // aside, never another of the same id
7
7
  import type { Database } from 'bun:sqlite'
8
8
  import { ID_RE } from '../../review/model.ts'
9
+ import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
9
10
  import { asideRows } from '../../review/item-rows.ts'
10
11
  import { MAX_ID_LENGTH, setAside, storeDir } from '../../review/store.ts'
11
12
  import { isRepoId, kind } from './kind.ts'
12
- import { ITEMS_READ } from './items-read.ts'
13
13
 
14
14
  export type ItemGoneBody = { repo: string; id: string; created: string }
15
15
 
@@ -22,7 +22,7 @@ export const itemGoneName = (repo: string, id: string, created: string): string
22
22
 
23
23
  /** the `created` of the head the hq holds under that id, null for none */
24
24
  const heldCreated = (db: Database, repo: string, id: string): string | null => {
25
- const r = db.query(ITEMS_READ === 'store' ? "select json_extract(head, '$.created') as created from review_cards where repo = ? and id = ?" : "select json_extract(body, '$.head.created') as created from cards where repo = ? and id = ?").get(repo, id) as { created: unknown } | null
25
+ const r = db.query("select json_extract(head, '$.created') as created from review_cards where repo = ? and id = ?").get(repo, id) as { created: unknown } | null
26
26
  return r == null ? null : String(r.created)
27
27
  }
28
28
 
@@ -36,16 +36,13 @@ export const isGone = (db: Database, repo: string, id: string, created: string):
36
36
  /** is some item of that id deleted, and no item of that id held: a message of it has no item to belong to */
37
37
  export const noItemLeft = (db: Database, repo: string, id: string): boolean => db.query('select 1 from card_gone where repo = ? and id = ?').get(repo, id) != null && heldCreated(db, repo, id) == null
38
38
 
39
- /** a tombstone kept, in the caller's transaction: the item's rows of both shapes and their feed entries go, its store
40
- * rows set aside whole as a machine's store keeps a deletion. `held` when the tombstone was there; else what the set
41
- * aside did and its entry. What the kind keeps of a row it took, and what a store write straight into the hq's file
42
- * keeps (item-direct.ts) */
39
+ /** a tombstone kept, in the caller's transaction: the item's feed entries go, its store rows set aside whole as a
40
+ * machine's store keeps a deletion. `held` when the tombstone was there; else what the set aside did and its entry.
41
+ * What the kind keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
43
42
  export function storeGone(db: Database, body: ItemGoneBody, node: string, at: number): { did: 'held' | 'moved' | 'none' | 'other'; entry: string } {
44
43
  if (isGone(db, body.repo, body.id, body.created)) return { did: 'held', entry: body.id }
45
44
  db.query('insert into card_gone (repo, id, created, node, at) values (?, ?, ?, ?, ?)').run(body.repo, body.id, body.created, node, at)
46
- // that item's rows and their entries of the feed go with it: no daemon reads them again
47
- db.query('delete from cards where repo = ? and id = ?').run(body.repo, body.id)
48
- db.query('delete from card_msgs where repo = ? and card = ?').run(body.repo, body.id)
45
+ // that item's entries of the feed go with it: no daemon reads them again
49
46
  db.query("delete from feed where kind = 'card' and name = ?").run(JSON.stringify([body.repo, body.id]))
50
47
  db.query("delete from feed where kind = 'card-msg' and repo = ? and json_extract(name, '$[1]') = ?").run(body.repo, body.id)
51
48
  return asideRows(db, body.repo, body.id, { created: body.created }, at, { node })
@@ -56,7 +53,7 @@ export const itemGoneKind = kind<ItemGoneBody>({
56
53
  schema: `
57
54
  create table if not exists card_gone (repo text not null, id text not null, created text not null, node text not null, at integer not null, primary key (repo, id, created)) without rowid;
58
55
  create index if not exists card_gone_node on card_gone (node);
59
- `,
56
+ ${HQ_ITEM_SCHEMA}`,
60
57
  tables: ['card_gone', 'review_gone'],
61
58
  check: (v): v is ItemGoneBody => isObj(v) && isRepoId(v['repo']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && ID_RE.test(v['id']) && typeof v['created'] === 'string' && v['created'].length <= 64,
62
59
  repoOf: (b) => b.repo,
@@ -3,12 +3,12 @@
3
3
  // may reach the hq before its item's head: it is kept, and a daemon holds it until the head lands
4
4
  import { MESSAGE_RE, ID_RE } from '../../review/model.ts'
5
5
  import type { Database } from 'bun:sqlite'
6
+ import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
6
7
  import { putMessage } from '../../review/item-rows.ts'
7
8
  import { holdsMessage, landMessage, MAX_ID_LENGTH, revOf, storeDir } from '../../review/store.ts'
8
9
  import type { Ledger } from '../ledger.ts'
9
10
  import { noItemLeft } from './item-gone.ts'
10
11
  import { isRepoId, kind, type Landed } from './kind.ts'
11
- import { ITEMS_READ } from './items-read.ts'
12
12
 
13
13
  export type ItemMsgBody = { repo: string; card: string; id: string; msg: Record<string, unknown> }
14
14
 
@@ -37,30 +37,25 @@ export function landItemMsg(b: ItemMsgBody, ledger: Ledger, o: { dry: boolean; a
37
37
  return r
38
38
  }
39
39
 
40
- /** a message in both shapes of the hq's file, in the caller's transaction: false when one holds its id. What the kind
41
- * keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
42
- export function storeMsg(db: Database, body: ItemMsgBody, node: string, at: number, text: string): boolean {
43
- if (db.query('insert into card_msgs (repo, card, id, node, at, rev, body) values (?, ?, ?, ?, ?, ?, ?) on conflict (repo, card, id) do nothing').run(body.repo, body.card, body.id, node, at, revOf(body.msg), text).changes === 0) return false
44
- // the store's shape of the same message (item-shapes.ts)
45
- putMessage(db, body.repo, body.card, body.msg as { id: string }, { node })
46
- return true
40
+ /** a message in the store's tables of the hq's file, in the caller's transaction: false when one holds its id. What
41
+ * the kind keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
42
+ export function storeMsg(db: Database, body: ItemMsgBody, node: string): boolean {
43
+ return putMessage(db, body.repo, body.card, body.msg as { id: string }, { node })
47
44
  }
48
45
 
49
46
  export const itemMsgKind = kind<ItemMsgBody>({
50
47
  kind: 'card-msg',
51
- schema: `
52
- create table if not exists card_msgs (repo text not null, card text not null, id text not null, node text not null, at integer not null, rev text not null, body text not null, primary key (repo, card, id)) without rowid;
53
- create index if not exists card_msgs_node on card_msgs (node);
54
- `,
55
- tables: ['card_msgs', 'review_msgs'],
48
+ // the store's tables, which each of the three item kinds makes (`if not exists`)
49
+ schema: HQ_ITEM_SCHEMA,
50
+ tables: ['review_msgs'],
56
51
  check: (v): v is ItemMsgBody => isObj(v) && isRepoId(v['repo']) && typeof v['card'] === 'string' && v['card'].length <= MAX_ID_LENGTH && ID_RE.test(v['card']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && MESSAGE_RE.test(v['id']) && isObj(v['msg']) && v['msg']['id'] === v['id'],
57
52
  repoOf: (b) => b.repo,
58
- insert: (db, r) => (storeMsg(db, r.body, r.node, r.at, r.text) ? { rows: 1, bytes: Buffer.byteLength(r.text) } : null),
53
+ insert: (db, r) => (storeMsg(db, r.body, r.node) ? { rows: 1, bytes: Buffer.byteLength(JSON.stringify(r.body.msg)) } : null),
59
54
  outbox: 'cards',
60
55
  refuses: (db, b) => (noItemLeft(db, b.repo, b.card) ? `a message of item ${b.card} of ${b.repo}, which was deleted` : null),
61
56
  // the hq never holds the thread of an item it lacks: the message waits at its daemon for its item
62
- keeps: (db, b) => (db.query(`select 1 from ${ITEMS_READ === 'store' ? 'review_cards' : 'cards'} where repo = ? and id = ?`).get(b.repo, b.card) == null ? `a message of item ${b.card} of ${b.repo}: its item is not in the hq` : null),
63
- usage: (db) => db.query(`select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from ${ITEMS_READ === 'store' ? 'review_msgs' : 'card_msgs'} group by node`).all() as { node: string; rows: number; bytes: number }[],
57
+ keeps: (db, b) => (db.query('select 1 from review_cards where repo = ? and id = ?').get(b.repo, b.card) == null ? `a message of item ${b.card} of ${b.repo}: its item is not in the hq` : null),
58
+ usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from review_msgs group by node').all() as { node: string; rows: number; bytes: number }[],
64
59
  maxPerNode: NODE_MAX_ITEM_MSGS,
65
60
  maxBytesPerNode: NODE_MAX_ITEM_MSG_BYTES,
66
61
  sweep: () => 0,
@@ -68,12 +63,11 @@ create index if not exists card_msgs_node on card_msgs (node);
68
63
  nameOf: (b) => itemMsgName(b.repo, b.card, b.id),
69
64
  read: (db, name) => {
70
65
  const [repo, item, id] = JSON.parse(name) as [string, string, string]
71
- if (ITEMS_READ === 'cards') return (db.query('select body from card_msgs where repo = ? and card = ? and id = ?').get(repo, item, id) as { body: string } | null)?.body ?? null
72
66
  // the body as its sender sent it: the message under its repo, its item and its id
73
67
  const r = db.query('select body from review_msgs where repo = ? and card = ? and id = ?').get(repo, item, id) as { body: string } | null
74
68
  return r == null ? null : JSON.stringify({ repo, card: item, id, msg: JSON.parse(r.body) as unknown })
75
69
  },
76
- revs: (db, repo) => db.query(`select card || '/' || id as name, rev from ${ITEMS_READ === 'store' ? 'review_msgs' : 'card_msgs'} where repo = ? order by card, id`).all(repo) as { name: string; rev: string }[],
70
+ revs: (db, repo) => db.query("select card || '/' || id as name, rev from review_msgs where repo = ? order by card, id").all(repo) as { name: string; rev: string }[],
77
71
  },
78
72
  land: landItemMsg,
79
73
  })
@@ -9,11 +9,11 @@
9
9
  // says so
10
10
  import { ID_RE } from '../../review/model.ts'
11
11
  import type { Database } from 'bun:sqlite'
12
+ import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
12
13
  import { putHead } from '../../review/item-rows.ts'
13
14
  import { holdsItem, landHead, MAX_ID_LENGTH, revOf, storeDir } from '../../review/store.ts'
14
15
  import { isGone } from './item-gone.ts'
15
16
  import { landItemMsg } from './item-msg.ts'
16
- import { ITEMS_READ } from './items-read.ts'
17
17
  import { isRepoId, kind } from './kind.ts'
18
18
 
19
19
  export type ItemBody = { repo: string; id: string; head: Record<string, unknown>; rev: string; base?: string }
@@ -29,36 +29,31 @@ const isObj = (v: unknown): v is Record<string, unknown> => v != null && typeof
29
29
 
30
30
  export const itemName = (repo: string, id: string): string => JSON.stringify([repo, id])
31
31
 
32
- /** a head in both shapes of the hq's file, in the caller's transaction: what the kind keeps of a row it took, and
33
- * what a store write straight into the hq's file keeps (item-direct.ts) */
34
- export function storeHead(db: Database, body: ItemBody, node: string, at: number, text: string): void {
35
- db.query('insert into cards (repo, id, node, at, rev, body) values (?, ?, ?, ?, ?, ?) on conflict (repo, id) do update set node = excluded.node, at = excluded.at, rev = excluded.rev, body = excluded.body').run(body.repo, body.id, node, at, body.rev, text)
36
- // the store's shape of the same head (item-shapes.ts)
32
+ /** a head in the store's tables of the hq's file, in the caller's transaction: what the kind keeps of a row it took,
33
+ * and what a store write straight into the hq's file keeps (item-direct.ts) */
34
+ export function storeHead(db: Database, body: ItemBody, node: string, at: number): void {
37
35
  putHead(db, body.repo, body.id, body.head, at, { node, base: body.base ?? null })
38
36
  }
39
- // the kinds `card`, `card-msg` and `card-gone` and their tables keep their stored names (wiki tools/shipkit/threads.md,
40
- // The words): every machine sends them and the hq's file and its copy in the Space hold them
37
+ // the kinds `card`, `card-msg` and `card-gone` keep their stored names (wiki tools/shipkit/threads.md, The words):
38
+ // every machine sends them. Their rows are the store's own tables (item-db.ts HQ_ITEM_SCHEMA)
41
39
  export const itemKind = kind<ItemBody>({
42
40
  kind: 'card',
43
- schema: `
44
- create table if not exists cards (repo text not null, id text not null, node text not null, at integer not null, rev text not null, body text not null, primary key (repo, id)) without rowid;
45
- create index if not exists cards_node on cards (node);
46
- `,
47
- tables: ['cards', 'review_cards', 'review_replaced'],
41
+ schema: HQ_ITEM_SCHEMA,
42
+ tables: ['review_cards', 'review_replaced'],
48
43
  // the rev is the head's own: a row that names another is a lie, and its readers would compare it for nothing
49
44
  check: (v): v is ItemBody => isObj(v) && isRepoId(v['repo']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && ID_RE.test(v['id']) && isObj(v['head']) && v['head']['id'] === v['id'] && typeof v['rev'] === 'string' && v['rev'] === revOf(v['head']) && (v['base'] === undefined || (typeof v['base'] === 'string' && /^[0-9a-f]{64}$/.test(v['base']))),
50
45
  repoOf: (b) => b.repo,
51
46
  insert: (db, r) => {
52
- const bytes = ITEMS_READ === 'store' ? Buffer.byteLength(JSON.stringify(r.body.head)) : Buffer.byteLength(r.text)
53
- const held = db.query(ITEMS_READ === 'store' ? 'select at, rev, length(cast(head as blob)) as bytes from review_cards where repo = ? and id = ?' : 'select at, rev, length(cast(body as blob)) as bytes from cards where repo = ? and id = ?').get(r.body.repo, r.body.id) as { at: number; rev: string; bytes: number } | null
47
+ const bytes = Buffer.byteLength(JSON.stringify(r.body.head))
48
+ const held = db.query('select at, rev, length(cast(head as blob)) as bytes from review_cards where repo = ? and id = ?').get(r.body.repo, r.body.id) as { at: number; rev: string; bytes: number } | null
54
49
  if (held != null && (held.rev === r.body.rev || !(r.at > held.at || (r.at === held.at && r.body.rev > held.rev)))) return null
55
- storeHead(db, r.body, r.node, r.at, r.text)
50
+ storeHead(db, r.body, r.node, r.at)
56
51
  return held == null ? { rows: 1, bytes } : { rows: 0, bytes: bytes - held.bytes }
57
52
  },
58
53
  outbox: 'cards',
59
54
  maxRowBytes: ITEM_MAX_ROW_BYTES,
60
55
  refuses: (db, b) => (isGone(db, b.repo, b.id, String(b.head['created'])) ? `item ${b.id} of ${b.repo} made ${String(b.head['created'])} was deleted: that item is never taken again` : null),
61
- usage: (db) => db.query(ITEMS_READ === 'store' ? 'select node, count(*) as rows, sum(length(cast(head as blob))) as bytes from review_cards group by node' : 'select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from cards group by node').all() as { node: string; rows: number; bytes: number }[],
56
+ usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(head as blob))) as bytes from review_cards group by node').all() as { node: string; rows: number; bytes: number }[],
62
57
  maxPerNode: NODE_MAX_ITEMS,
63
58
  maxBytesPerNode: NODE_MAX_ITEM_BYTES,
64
59
  sweep: () => 0,
@@ -66,12 +61,11 @@ create index if not exists cards_node on cards (node);
66
61
  nameOf: (b) => itemName(b.repo, b.id),
67
62
  read: (db, name) => {
68
63
  const [repo, id] = JSON.parse(name) as [string, string]
69
- if (ITEMS_READ === 'cards') return (db.query('select body from cards where repo = ? and id = ?').get(repo, id) as { body: string } | null)?.body ?? null
70
64
  // the body as its sender sent it: the head, its rev, and the rev it was made on top of
71
65
  const r = db.query('select head, rev, base from review_cards where repo = ? and id = ?').get(repo, id) as { head: string; rev: string; base: string | null } | null
72
66
  return r == null ? null : JSON.stringify({ repo, id, head: JSON.parse(r.head) as unknown, rev: r.rev, ...(r.base == null ? {} : { base: r.base }) })
73
67
  },
74
- revs: (db, repo) => db.query(`select id as name, rev from ${ITEMS_READ === 'store' ? 'review_cards' : 'cards'} where repo = ? order by id`).all(repo) as { name: string; rev: string }[],
68
+ revs: (db, repo) => db.query('select id as name, rev from review_cards where repo = ? order by id').all(repo) as { name: string; rev: string }[],
75
69
  },
76
70
  // a head is written over this machine's only when this machine holds no change of it the hq has not seen, and
77
71
  // only over the same item: two items made apart under one id stay each on its machine, and the check names them
@@ -15,8 +15,7 @@ export const REPORT_ACTIVITY_MS = 24 * 3600_000
15
15
  /** a report past a day: what only the newest one is read for (its activity, each repo's gate, each process's url, its
16
16
  * url facts) goes */
17
17
  export function slimReport(r: Report): Report {
18
- // the backup status reads a node's newest report only: an old one keeps no backup records
19
- const { activity: _activity, urls: _urls, backups: _backups, ...rest } = r
18
+ const { activity: _activity, urls: _urls, ...rest } = r
20
19
  return { ...rest, repos: r.repos.map(({ gate: _gate, ...x }) => x), ...(r.processes == null ? {} : { processes: r.processes.map(({ url: _url, ...p }) => p) }) }
21
20
  }
22
21
 
@@ -33,8 +32,8 @@ create index if not exists reports_at on reports (node, at);
33
32
  repoOf: () => '',
34
33
  insert: (db, r) => {
35
34
  // its url facts rebuilt field by field: a login or a secret's name a sender put beside one is never stored; its
36
- // backup records of a wrong shape dropped, the rest of the report kept
37
- const text = r.body.urls === undefined && r.body.backups === undefined ? r.text : JSON.stringify(storedReport(r.body))
35
+ // holds of a wrong shape dropped, the rest of the report kept
36
+ const text = r.body.urls === undefined && r.body.holds === undefined ? r.text : JSON.stringify(storedReport(r.body))
38
37
  if (db.query('insert into reports (node, epoch, seq, at, body) values (?, ?, ?, ?, ?) on conflict (node, epoch, seq) do nothing').run(r.node, r.epoch, r.seq, r.at, text).changes === 0) return null
39
38
  // a wanted switch value is done once a report of its node shows it
40
39
  const sw = r.body.switches
@@ -7,8 +7,8 @@
7
7
  // terminal refuse it too. The daemon's own variables prove nothing either way (an agent may have started it): his
8
8
  // click is judged by the gates of the route (the owner's word, loopback only), never by the daemon's env
9
9
  import { machineName } from '../core/machine-name.ts'
10
- import { AGENT_ENV, SSH_ENV } from '../vault/vault-init.ts'
11
- import { heldSwitch, switchOf, SWITCHES, switchValue, type SwitchDecl } from './switch.ts'
10
+ import { AGENT_ENV, SSH_ENV } from '../core/agent-env.ts'
11
+ import { switchOf, SWITCHES, switchValue, type SwitchDecl } from './switch.ts'
12
12
  import { hqHostOf } from './terminal-hop.ts'
13
13
  import { machineGet } from '../core/machine-db.ts'
14
14
 
@@ -56,6 +56,6 @@ export function ownerSwitchesView(get: (name: string) => unknown = machineGet, o
56
56
  return {
57
57
  machine: (o.machine ?? machineName)(),
58
58
  hq,
59
- switches: ownerSwitches().map((d) => ({ name: d.name, on: switchValue(d, heldSwitch(d, get)) === true, title: d.byOwner!.title, ask: d.byOwner!.ask(label), what: d.what })),
59
+ switches: ownerSwitches().map((d) => ({ name: d.name, on: switchValue(d, get(d.name)) === true, title: d.byOwner!.title, ask: d.byOwner!.ask(label), what: d.what })),
60
60
  }
61
61
  }
package/src/hq/report.ts CHANGED
@@ -11,7 +11,6 @@ import { maskSecrets } from '../agent-time/mask.ts'
11
11
  import { maskFields } from './kinds/kind.ts'
12
12
  import { realGit } from '../core/git.ts'
13
13
  import { isFollowFact, MAX_WHY, type FollowFact } from './follow-fact.ts'
14
- import { type BackupFacts, isBackupFacts } from '../media-store/backup/facts.ts'
15
14
  import { type Holds, isHolds } from './holds-shape.ts'
16
15
 
17
16
  export type RepoFacts = {
@@ -72,8 +71,6 @@ export type Report = {
72
71
  follow?: FollowFact
73
72
  /** each one time ask (switch.ts ONCE_ASKS) by the time of the last one this machine took: absent before */
74
73
  taken?: Record<string, number>
75
- /** its own backups' records (media-store/backup/facts.ts), which the hq's machine judges: absent before */
76
- backups?: BackupFacts
77
74
  /** what the hq holds of its rows, kind by kind, as it last counted them (hq/hq-holds.ts): absent before */
78
75
  holds?: Holds
79
76
  }
@@ -175,11 +172,11 @@ export function urlFacts(v: unknown): UrlFact[] {
175
172
  return out
176
173
  }
177
174
 
178
- /** a report as the hq stores it: its url facts rebuilt by urlFacts, its backup records dropped when their shape is
179
- * wrong (the rest of the report stays: the machine's rows then say it does not report them), nothing else changed */
175
+ /** a report as the hq stores it: its url facts rebuilt by urlFacts, its holds dropped when their shape is wrong (the
176
+ * rest of the report stays), nothing else changed */
180
177
  export function storedReport(r: Report): Report {
181
- const { backups, holds, ...rest } = r
182
- const out: Report = { ...rest, ...(backups === undefined || !isBackupFacts(backups) ? {} : { backups }), ...(holds === undefined || !isHolds(holds) ? {} : { holds }) }
178
+ const { holds, ...rest } = r
179
+ const out: Report = { ...rest, ...(holds === undefined || !isHolds(holds) ? {} : { holds }) }
183
180
  return out.urls === undefined ? out : { ...out, urls: urlFacts(out.urls) }
184
181
  }
185
182
 
@@ -306,7 +303,7 @@ async function gateOf(path: string): Promise<GateFact | undefined> {
306
303
  }
307
304
 
308
305
  /** this machine's report. `house` is the checkout shipkit runs from, null on a machine with none */
309
- export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls' | 'follow' | 'taken' | 'backups' | 'holds'>): Promise<Report> {
306
+ export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls' | 'follow' | 'taken' | 'holds'>): Promise<Report> {
310
307
  const since = (o.now ?? Date.now()) - ACTIVITY_MS
311
308
  const read = await Promise.all(
312
309
  o.repos.slice(0, MAX_REPOS).map(async (r) => {
@@ -334,7 +331,6 @@ export async function buildReport(o: { repos: { name: string; path: string }[];
334
331
  ...(o.urls == null ? {} : { urls: urlFacts(o.urls) }),
335
332
  ...(o.follow == null ? {} : { follow: { ...o.follow, why: o.follow.why == null ? null : o.follow.why.slice(0, MAX_WHY) } }),
336
333
  ...(o.taken == null ? {} : { taken: o.taken }),
337
- ...(o.backups == null ? {} : { backups: o.backups }),
338
334
  ...(o.holds == null ? {} : { holds: o.holds }),
339
335
  }
340
336
  return maskFields(report, REPORT_TEXTS)
package/src/hq/switch.ts CHANGED
@@ -27,8 +27,6 @@ export type SwitchValue = boolean | number | null
27
27
 
28
28
  export type SwitchDecl = {
29
29
  name: string
30
- /** its name before: read where the machine db holds none under `name`, until its owner's code moves the value */
31
- was?: string
32
30
  /** on or off, or a time (ms) the owner's code writes */
33
31
  type: 'bool' | 'time'
34
32
  /** its value while the machine db holds none */
@@ -52,7 +50,7 @@ export const SWITCHES: readonly SwitchDecl[] = [
52
50
  { name: VAULT_SNAPSHOTS_PRUNE, type: 'bool', default: false, owner: 'hq/switch.ts', what: "the vault's sealed snapshots older than 30 days deleted from the Space for good", deletes: true },
53
51
  { name: 'hq-open', type: 'bool', default: false, owner: 'hq/hq-role.ts', what: "the hq's port to the other machines" },
54
52
  { name: 'hq-proxy', type: 'bool', default: false, owner: 'hq/door.ts', what: "the hq's home opens a process of any machine at <process>.<machine>.localhost, on the hq's machine only" },
55
- { name: 'machine-urls', was: 'machine-door', type: 'bool', default: false, owner: 'hq/door.ts', what: "this machine's web opens its own global processes and loopback urls to the hq's proxy, for the key the hq gave it", byOwner: { set: async (on) => (await import('./door.ts')).setUrlsOn(on), title: "urls to the hq's home", ask: (hq) => `let the hq's home (${hq}) open this machine's global processes and urls` } },
53
+ { name: 'machine-urls', type: 'bool', default: false, owner: 'hq/door.ts', what: "this machine's web opens its own global processes and loopback urls to the hq's proxy, for the key the hq gave it", byOwner: { set: async (on) => (await import('./door.ts')).setUrlsOn(on), title: "urls to the hq's home", ask: (hq) => `let the hq's home (${hq}) open this machine's global processes and urls` } },
56
54
  { name: 'machine-terminals', type: 'bool', default: false, owner: 'hq/terminal-hop.ts', what: "the hq Mac's page types into this machine's terminals, for the key the hq gave it; never the phone", byOwner: { set: async (on) => (await import('./terminal-hop.ts')).setTerminalsOn(on), title: "terminals to the hq's Mac", ask: (hq) => `let the hq's Mac (${hq}) type into this machine's terminals` } },
57
55
  { name: 'media-purge-auto', type: 'bool', default: false, owner: 'media-store/daemon.ts', what: 'an uploaded media file leaves the disk after a day', deletes: true, afar: async (on) => (await import('../media-store/daemon.ts')).setAutoPurge(on) },
58
56
  { name: 'annex-auto', type: 'bool', default: false, owner: 'annex/tidy.ts', what: 'the daemon tidies the annex on its own', deletes: true, afar: async (on) => (await import('../annex/tidy.ts')).setAnnexAuto(on) },
@@ -60,7 +58,6 @@ export const SWITCHES: readonly SwitchDecl[] = [
60
58
  { name: 'temp-auto-at', type: 'time', default: null, owner: 'home/machine-temp.ts', what: 'since when the temp sweep is on' },
61
59
  { name: 'temp-repos-from', type: 'time', default: null, owner: 'home/machine-temp.ts', what: "since when the sweep deletes in each repo's .shipkit/tmp" },
62
60
  { name: 'hq-threads', type: 'bool', default: false, owner: 'review/item-hq.ts', what: "on the machine that carries the hq, the threads of the repos it holds are read and written in the hq's file; off, in the daemon's file, the hq holding their copy" },
63
- { name: 'db-fold-auto', type: 'bool', default: true, owner: 'core/machine-db.ts', what: 'the daemon folds the media index and the agent time index into the machine db; off (a way back), a store not folded is read in its own file' },
64
61
  { name: 'time-diet', type: 'bool', default: false, owner: 'agent-time/diet.ts', what: "the agent time index drops the command text of an ordinary call older than 7 days (never back: Claude Code prunes the transcripts)", deletes: true },
65
62
  { name: HOUSE_FOLLOW, type: 'bool', default: true, owner: 'hq/switch.ts', what: "the daemon merges the house checkout's upstream when nothing holds it, pushes its machine commits and restarts the web and the daemon onto it", afar: async (on) => setFollowOn(on) },
66
63
  { name: 'trace.enabled', type: 'bool', default: true, owner: 'trace/tracer.ts', what: 'the traces of shipkit runs', afar: async (on) => ((await import('../trace/tracer.ts')).setTraceEnabled(on), true) },
@@ -75,13 +72,7 @@ export function switchValue(d: SwitchDecl, v: unknown): SwitchValue {
75
72
  }
76
73
 
77
74
  /** every declared switch with its value on this machine */
78
- export const switchValues = (get: (name: string) => unknown = machineGet): Record<string, SwitchValue> => Object.fromEntries(SWITCHES.map((d) => [d.name, switchValue(d, heldSwitch(d, get))]))
79
-
80
- /** what the machine db holds for a switch: under its name, else under the name it had before */
81
- export function heldSwitch(d: SwitchDecl, get: (name: string) => unknown = machineGet): unknown {
82
- const v = get(d.name)
83
- return v == null && d.was != null ? get(d.was) : v
84
- }
75
+ export const switchValues = (get: (name: string) => unknown = machineGet): Record<string, SwitchValue> => Object.fromEntries(SWITCHES.map((d) => [d.name, switchValue(d, get(d.name))]))
85
76
 
86
77
  /** why the hq's machine may not ask this value of a node, null when it may */
87
78
  export function afarRefusal(name: string, on: boolean): string | null {
@@ -336,24 +336,12 @@ export async function hqThreadsTick(o: { repos: { name: string; path: string }[]
336
336
 
337
337
  /** the lease one look of the threads job holds, beside the daemon's own database */
338
338
  export const threadsLease = (): string => `${daemonDbPath()}-threads`
339
- /** its name before: still taken, so an older copy of shipkit on this machine (a worktree's, a daemon not restarted yet)
340
- * and this one never run a look or a move at once */
341
- const threadsLeaseBefore = (): string => `${daemonDbPath()}-cards`
342
-
343
- /** both leases, or null while either is held; its release frees both */
344
- export function tryThreadsLease(label: string): { release: () => void } | null {
345
- const now = tryLease(threadsLease(), label)
346
- if (now == null) return null
347
- const before = tryLease(threadsLeaseBefore(), label)
348
- if (before == null) {
349
- now.release()
350
- return null
351
- }
352
- return { release: () => (before.release(), now.release()) }
353
- }
354
339
 
355
- /** who holds the lease, by either name */
356
- export const threadsLeaseHolder = (): ReturnType<typeof leaseHolder> => leaseHolder(threadsLease()) ?? leaseHolder(threadsLeaseBefore())
340
+ /** the lease, or null while it is held */
341
+ export const tryThreadsLease = (label: string): { release: () => void } | null => tryLease(threadsLease(), label)
342
+
343
+ /** who holds the lease */
344
+ export const threadsLeaseHolder = (): ReturnType<typeof leaseHolder> => leaseHolder(threadsLease())
357
345
 
358
346
  /** the heads and messages this machine's store holds */
359
347
  const storeRows = (db: Database): number => (db.query('select (select count(*) from review_cards) + (select count(*) from review_msgs) as n').get() as { n: number }).n
@@ -1,8 +1,5 @@
1
- // the hq's threads as words: where this machine reads them (review/item-hq.ts), the compare of their two shapes
2
- // (item-shapes.ts). No import, so the hub's page reads it too
3
-
4
- /** both shapes by rev: the heads and messages of each, the ones that differ or are in one alone. `ok` when none */
5
- export type ShapesDiff = { heads: number; messages: number; storeHeads: number; storeMessages: number; differ: number; onlyOld: number; onlyStore: number; ok: boolean }
1
+ // the hq's threads as words: where this machine reads them (review/item-hq.ts). No import, so the hub's page reads
2
+ // it too
6
3
 
7
4
  /** where this machine's threads are read and written now (review/item-hq.ts threadsWhere), and why */
8
5
  export type ThreadsWhere = { where: 'hq' | 'machine'; switchOn: boolean; carries: boolean; why: string }
@@ -22,10 +19,3 @@ export function threadsLine(t: ThreadsWhere): string {
22
19
  const w = threadsWords(t)
23
20
  return `threads: ${w.read}, ${w.copy} (${w.tip})`
24
21
  }
25
-
26
- /** the compare as one line, the same in the daemon's log, `sk db hq` and the database page */
27
- export function shapesLine(d: ShapesDiff): string {
28
- const n = (x: number): string => x.toLocaleString('en-US')
29
- if (d.ok) return `both shapes of the threads agree: ${n(d.heads)} heads, ${n(d.messages)} messages`
30
- return `the threads differ between the two shapes: ${n(d.heads)} heads and ${n(d.messages)} messages in the old tables, ${n(d.storeHeads)} and ${n(d.storeMessages)} in the store's tables; ${d.differ} at two revs, ${d.onlyOld} only in the old tables, ${d.onlyStore} only in the store's tables`
31
- }
@@ -24,7 +24,7 @@ export const FETCH_SITE_HEADER = 'x-shipkit-fetch-site'
24
24
  export type OwnerRoutes = { under: string; what: string; not?: readonly string[] }
25
25
 
26
26
  export const OWNER_WORD_ROUTES: readonly OwnerRoutes[] = [
27
- { under: '/api/review', what: 'a thread: his reply, the delete of his own message, answer, verdict, close, reopen, snooze, mute, attach, lane ask, note, raised item, rating, action, read mark, staged draft, file, share, secret' },
27
+ { under: '/api/review', what: 'a thread: his reply, the delete of his own message, answer, verdict, close, reopen, rename, snooze, mute, attach, lane ask, note, raised item, rating, action, read mark, staged draft, file, share, secret' },
28
28
  { under: '/api/trailer', what: 'a trailer: his note on a frame, its state and words, his voice takes' },
29
29
  { under: '/api/act', what: "an ask's done, decline, proof and remark, his act on a reflection, a note on an asset" },
30
30
  { under: '/api/docs', what: 'the editor: his save of a document, a picture he drops into it' },
@@ -47,6 +47,22 @@ export const markUrl = (i: Identity): string | null => {
47
47
  return f == null ? null : `/api/projects/identity-mark/${encodeURIComponent(i.id)}?v=${pictureVersion(f)}`
48
48
  }
49
49
 
50
+ /** the side in px the hub's mark is served at: it draws at 28 px at most (a tile's badge 14, the identities page 28),
51
+ * sharp at 2x with room; the avatar file itself is often 1024 px, 4 MB decoded for a 14 px badge on every page */
52
+ export const MARK_PX = 96
53
+ const marks = new Map<string, Promise<ArrayBuffer | null>>()
54
+ /** the mark as the hub draws it: the avatar file down to MARK_PX, a png, made once per file and version; null when
55
+ * the file does not decode */
56
+ export function markPng(file: string, version: string): Promise<ArrayBuffer | null> {
57
+ const key = `${file}@${version}`
58
+ let m = marks.get(key)
59
+ if (m == null) {
60
+ m = import('sharp').then(({ default: sharp }) => sharp(file).resize(MARK_PX, MARK_PX, { fit: 'cover', withoutEnlargement: true }).png().toBuffer()).then((b) => new Uint8Array(b).buffer, () => null)
61
+ marks.set(key, m)
62
+ }
63
+ return m
64
+ }
65
+
50
66
  export const railOf = (i: Identity): RailIdentity => ({ id: i.id, name: i.name, default: i.default, colour: colourOf(i), mark: markUrl(i) })
51
67
 
52
68
  /** the identities of a folder, read once per change of an identity.md; one cache per caller */