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
@@ -1,33 +1,33 @@
1
- // the Mac's side of the door (wiki tools/shipkit/advisors.md): every live share projected, scanned and written to the
2
- // door's folder with the images he confirmed, re-encoded; the list of live shares and logins written FIRST and the
3
- // copies of ended ones deleted after; the advice pulled
4
- import { createHash, randomBytes } from 'node:crypto'
1
+ // what a person reads of a share, and the owner's pass (wiki tools/shipkit/advisors.md): `prepare` projects one live
2
+ // share, scanned, through the hub's own builders, for the users' port to answer at the request; the pass keeps the
3
+ // owner's store true about the people: who may sign in, each share's reach and what it masks, where each reader
4
+ // stopped, the advice the owner's rights make direct since, the sweeps of the port's folder. A thread a person reads is
5
+ // prepared at their request, never kept from a pass
6
+ import { createHash } from 'node:crypto'
5
7
  import { existsSync, readFileSync, statSync } from 'node:fs'
6
8
  import { HOUSE_LAYOUT } from '../core/house-layout.ts'
7
9
  import { identitiesFile } from '../core/identities-root.ts'
8
- import { imageFile, readAll, storeDir, threadFile } from '../review/store.ts'
10
+ import { imageFile, readAll, storeDir, threadCodeOf, threadFile } from '../review/store.ts'
9
11
  import { isGallery, verdictOf, type ReviewItem } from '../review/model.ts'
10
12
  import type { ReplyCell } from '../review/cells.ts'
11
- import type { Turn } from '../review/band.ts'
12
13
  import { namedFiles } from '../review/file-tags.ts'
13
- import { membersOf, statusOf, threadOfAddress, turnOf, type Thread } from '../review/threads.ts'
14
+ import { membersOf, threadOfAddress, type Thread } from '../review/threads.ts'
14
15
  import { cursorOf } from '../review/traces.ts'
15
16
  import { advisorThread, personReads, storeNames, type AdvisorThread } from './advisor-view.ts'
16
- import { truthfulCopy } from './copy-truth.ts'
17
- import type { AppBundle } from './app.ts'
18
17
  import { ADVISOR_WHO } from '../serve/hub-app/review/review-host.ts'
19
18
  import { getJson, type Bucket, type Bytes } from './edge/bucket.ts'
20
- import { KEYS, type ServedProject, type ServedShare, type ShareManifest, type SharesFile } from './edge/types.ts'
21
- import { importAdvice } from './advice.ts'
19
+ import { KEYS, type ServedProject, type ShareManifest } from './edge/types.ts'
20
+ import { deliverPending, sweepUploads } from './advice.ts'
22
21
  import { shareAllOfAccess } from './acts.ts'
23
22
  import { opaqueItem, opaqueMessage, picturesOf, projectItems, questionHash, type Masked } from './project.ts'
24
23
  import { maskHits, privateWordsOf } from './scan.ts'
25
- import { photoBytes } from './photos.ts'
26
24
  import { rightsOf } from './rights.ts'
27
25
  import { keepLogins } from './login.ts'
28
- import { identityOfRoot } from './door.ts'
26
+ import { identityOfRoot } from './speaks.ts'
29
27
  import { ownerNameOf } from './owner-name.ts'
30
28
  import { displayOf, isLive, startPlacesOf, readState, servedShares, withState, type OwnerState, type Share, type ShareRead } from './owner-store.ts'
29
+ import { bandOf, threadState } from '../review/thread-state.ts'
30
+ import { partiesOfStore } from '../review/store-parties.ts'
31
31
 
32
32
  /** a picture as the advisor gets it: re-encoded, no metadata (EXIF, PNG text) survives */
33
33
  export type Encode = (path: string) => Promise<Bytes>
@@ -47,23 +47,21 @@ export function privateWords(house: string | null): string[] {
47
47
  return existsSync(f) ? privateWordsOf(readFileSync(f, 'utf8')) : []
48
48
  }
49
49
 
50
- /** what one live share shows the advisor now, as the Mac reads it: the copy (the hub's own view and row, its
51
- * manifest), every picture of the thread served by its re-encoded name */
50
+ /** what one live share shows the advisor now: the hub's own view and row, the manifest the port checks requests
51
+ * against, every picture of the thread by the hash of its raw bytes */
52
52
  export interface Prepared {
53
53
  /** the project's name as the advisor reads it, scanned */
54
54
  project: string
55
- /** his name as this share's project reads it, scanned */
55
+ /** the owner's name as this share's project reads it, scanned */
56
56
  owner: string
57
- /** the advisor's copy: null when nothing of the thread leaves */
58
- copy: AdvisorThread | null
57
+ /** what the advisor reads, the hub's view and row: null when nothing of the thread leaves */
58
+ theirs: AdvisorThread | null
59
59
  manifest: ShareManifest | null
60
60
  /** the entries that went out with strings masked */
61
61
  masked: Masked[]
62
- /** each served name and its file */
63
- served: { sha: string; path: string }[]
64
- /** each image of the projection, raw content hash, file: the preview draws all of them */
62
+ /** each image of the projection, raw content hash, file: the port encodes one at its request */
65
63
  all: { ref: string; sha: string; path: string }[]
66
- /** the time of his newest word in the thread: a read up to it is « seen by <name> » in his hub */
64
+ /** the time of the owner's newest word in the thread: a read up to it is « seen by <name> » in the owner's hub */
67
65
  his: string | null
68
66
  /** the thread's versions and how many the person sees */
69
67
  parts: { versions: number; shown: number }
@@ -71,8 +69,8 @@ export interface Prepared {
71
69
 
72
70
  const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/
73
71
 
74
- /** the door's read cursor of a share (edge/api.ts writes it, `upTo` one of the copy's own cell times, which the Mac's
75
- * clock wrote): a small object of two times; anything else is no read */
72
+ /** a person's read cursor of a share (users-router.ts writes it, `upTo` one of the view's own cell times): a small
73
+ * object of two times; anything else is no read */
76
74
  export function readOf(bytes: Bytes | null, his: string | null): ShareRead | null {
77
75
  if (bytes === null || bytes.byteLength > 512) return null
78
76
  let v: unknown
@@ -89,9 +87,6 @@ export function readOf(bytes: Bytes | null, his: string | null): ShareRead | nul
89
87
  return { at, upTo, seen: his === null || upTo >= his }
90
88
  }
91
89
 
92
- /** the re-encoded bytes of this run, by served name: put once each */
93
- const encoded = new Map<string, Bytes>()
94
-
95
90
  const resolverOf =
96
91
  (root: string) =>
97
92
  (itemId: string, name: string, of: 'view' | 'message'): string | null =>
@@ -99,17 +94,17 @@ const resolverOf =
99
94
 
100
95
  const ADVICE_WORDS: Record<string, string> = { approve: 'I approve', change: "I'd change this", words: '' }
101
96
 
102
- /** the cell of a person's own advice in their copy */
97
+ /** the cell of a person's own advice in their view */
103
98
  const adviceCell = (head: string, advice: string): string => `${head}/m${sha256(`advice|${advice}`).slice(0, 12)}`
104
99
 
105
- /** each word the person's rights let in at once, as the copy names it (opaqueMessage), and its cell there: an agent's
100
+ /** each word the person's rights let in at once, as their view names it (opaqueMessage), and its cell there: an agent's
106
101
  * read of it links that cell. The thread's word is the one its advice wrote, at the moment the advice says it was done */
107
102
  function ownCells(s: OwnerState, x: Share, thread: Thread, head: string): Map<string, string> {
108
103
  const out = new Map<string, string>()
109
104
  const direct = s.advice.filter((a) => a.share === x.id && a.state === 'direct' && a.done !== undefined)
110
105
  for (const y of membersOf(thread))
111
106
  for (const m of y.thread) {
112
- // their verdict is a cell of the copy itself, never an advice's
107
+ // their verdict is a cell of the view itself, never an advice's
113
108
  if (m.who !== 'player' || m.advisor?.id !== x.advisor || m.verdict !== undefined) continue
114
109
  const a = direct.find((z) => z.done === m.at)
115
110
  if (a !== undefined) out.set(opaqueMessage(x.id, m.id), adviceCell(head, a.id))
@@ -117,11 +112,11 @@ function ownCells(s: OwnerState, x: Share, thread: Thread, head: string): Map<st
117
112
  return out
118
113
  }
119
114
 
120
- /** the person's own advice on this share: drawn in their copy as their words, « waits for <owner> » while it waits.
121
- * One their rights made direct is in the thread as a `player` word, which the projection never copies (another
122
- * person's word stays theirs), so their copy draws it from here, with no wait */
115
+ /** the person's own advice on this share: drawn in their view as their words, « waits for <owner> » while it waits.
116
+ * One their rights made direct is in the thread as a `player` word, which the projection never carries (another
117
+ * person's word stays theirs), so their view draws it from here, with no wait */
123
118
  function pendingCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThread['view'], owner: string): AdvisorThread['view']['cells'] {
124
- // a direct verdict that is the version's verdict is in the copy already (project.ts); one of the older shape (a word)
119
+ // a direct verdict that is the version's verdict is in the view already (project.ts); one of the older shape (a word)
125
120
  // is drawn from here
126
121
  const verdicts = new Set(membersOf(thread).flatMap((y) => y.thread.filter((m) => m.who === 'player' && m.advisor?.id === x.advisor && m.verdict !== undefined).map((m) => m.at)))
127
122
  // a pick is drawn on its question's cell (markVotes), never as words of its own
@@ -135,7 +130,7 @@ function pendingCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThre
135
130
  }
136
131
 
137
132
  /** the words a person started this thread with, opened at once by their rights: in the thread as a `player` word, which
138
- * the projection never copies, so their copy draws them from their proposal, as its first message */
133
+ * the projection never carries, so their view draws them from their proposal, as its first message */
139
134
  function proposedCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThread['view']): AdvisorThread['view']['cells'] {
140
135
  const heads = new Set(membersOf(thread).map((y) => y.item.id))
141
136
  return s.proposals.flatMap((p) => {
@@ -145,12 +140,12 @@ function proposedCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThr
145
140
  })
146
141
  }
147
142
 
148
- /** the person's newest pick on each question, on the question's cell of their copy: their vote while it waits for his
149
- * OK. A direct pick that answered is in the copy already, and wins */
143
+ /** the person's newest pick on each question, on the question's cell of their view: their vote while it waits for the
144
+ * owner's OK. A direct pick that answered is in the view already, and wins */
150
145
  function markVotes(s: OwnerState, x: Share, view: AdvisorThread['view']): void {
151
146
  const newest = new Map<string, { option: number; at: string }>()
152
147
  for (const a of s.advice) {
153
- // a direct one of the older shape (a word with no answer on it) is theirs too: the copy holds no answer for it
148
+ // a direct one of the older shape (a word with no answer on it) is theirs too: the view holds no answer for it
154
149
  if (a.share !== x.id || a.kind !== 'pick' || (a.state !== 'pending' && a.state !== 'direct') || a.item === undefined || a.message === undefined || a.option === undefined) continue
155
150
  const cell = `${opaqueItem(x.id, a.item)}/${opaqueMessage(x.id, a.message)}`
156
151
  if ((newest.get(cell)?.at ?? '') <= a.at) newest.set(cell, { option: a.option, at: a.at })
@@ -174,11 +169,9 @@ function rawSha(path: string): string {
174
169
  return sha
175
170
  }
176
171
 
177
- /** a share projected and its pictures served: a thread he shared goes whole, its pictures with it. `names: 'raw'`:
178
- * each picture named by the hash of its raw bytes and encoded by the reader on request (his preview, the users'
179
- * port), never here */
180
- export async function prepare(s: OwnerState, x: Share, o: { words: string[]; encode: Encode; now: Date; preview?: boolean; names?: 'raw' }): Promise<Prepared | null> {
181
- const raw = o.preview === true || o.names === 'raw'
172
+ /** a share projected and its pictures named: a thread the owner shared goes whole, its pictures with it, each named by
173
+ * the hash of its raw bytes and encoded by the reader on request (the owner's preview, the users' port), never here */
174
+ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; now: Date }): Promise<Prepared | null> {
182
175
  const a = s.advisors.find((y) => y.id === x.advisor)
183
176
  if (a === undefined) return null
184
177
  const stored = readAll(storeDir(x.root)).items
@@ -190,10 +183,9 @@ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; enc
190
183
  const name = ownerNameOf(s, { project: x.repo, identity: await identityOfRoot(x.root) })
191
184
  const owner = maskHits(name, scan).length === 0 ? name : 'the owner'
192
185
  const resolve = resolverOf(x.root)
193
- // every picture once, re-encoded; his preview draws each raw
194
- const served: Prepared['served'] = []
186
+ // every picture once, named by the hash of its raw bytes; the port encodes it at the request
195
187
  const all: Prepared['all'] = []
196
- const byPath = new Map<string, { raw: string; served: string | null } | null>()
188
+ const byPath = new Map<string, string | null>()
197
189
  for (const pic of picturesOf(thread)) {
198
190
  const path = resolve(pic.itemId, pic.name, pic.of)
199
191
  if (path === null || byPath.has(path)) continue
@@ -203,61 +195,49 @@ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; enc
203
195
  }
204
196
  const rawHash = rawSha(path)
205
197
  all.push({ ref: path, sha: rawHash, path })
206
- if (raw) {
207
- byPath.set(path, { raw: rawHash, served: null })
208
- continue
209
- }
210
- const bytes = await o.encode(path)
211
- const sha = sha256(bytes)
212
- if (!served.some((y) => y.sha === sha)) served.push({ sha, path })
213
- byPath.set(path, { raw: rawHash, served: sha })
214
- encoded.set(sha, bytes)
198
+ byPath.set(path, rawHash)
215
199
  }
216
- /** a picture's name in the copy: the served one, or by its raw hash where the reader encodes it */
200
+ /** a picture's name in what the person reads: the hash of its raw bytes */
217
201
  const nameOf = (path: string | null): string | null => {
218
202
  const b = path === null ? null : (byPath.get(path) ?? null)
219
- if (b === null) return null
220
- return raw ? `${b.raw}.webp` : b.served === null ? null : `${b.served}.webp`
203
+ return b === null ? null : `${b}.webp`
221
204
  }
222
205
  const answers = rightsOf(s.rights, { person: x.advisor, project: x.repo, thread: x.address }).answers
223
206
  const items = projectItems({ thread, share: x.id, advisor: x.advisor, answers, scan, include: x.include, picture: (itemId, name, of) => nameOf(resolve(itemId, name, of)) })
224
- const copy = advisorThread(items, { scan, now: o.now, owner, cursor: cursorOf(thread, o.now), names: storeNames(thread) })
225
- if (copy !== null) {
226
- truthfulCopy(copy, items, { turn: turnOf(thread, o.now), status: statusOf(thread.head, stored) })
227
- // their words at their own time among the thread's cells, as his hub draws them (a stable sort keeps the
207
+ const real = threadState(thread, o.now)
208
+ // the band his hub draws: a live agent works it now, read of his parties (never theirs to read)
209
+ const works = real.turn === 'agents' && bandOf(real, (await partiesOfStore(storeDir(x.root))).parties, o.now) === 'working'
210
+ const theirs = advisorThread(items, { scan, now: o.now, owner, cursor: cursorOf(thread, o.now), names: storeNames(thread), real, deferred: x.deferred === true, code: threadCodeOf(storeDir(x.root))(thread), works })
211
+ if (theirs !== null) {
212
+ // their words at their own time among the thread's cells, as the owner's hub draws them (a stable sort keeps the
228
213
  // builders' order of cells of one time)
229
- copy.view.cells = [...copy.view.cells, ...proposedCells(s, x, thread, copy.view), ...pendingCells(s, x, thread, copy.view, owner)].sort((p, q) => p.at.localeCompare(q.at))
230
- markVotes(s, x, copy.view)
231
- personReads(copy.view, items.items, { owner, own: ownCells(s, x, thread, copy.view.head) })
232
- // the turn as the advisor reads it: a thread deferred to them and set aside on his side is theirs; his turn, or a
233
- // thread he set aside himself, waits for him (the page says « waits for <owner> », ReviewSt.bandWord)
234
- const turnFor = (t: Turn): Turn => (x.deferred && t === 'aside' ? 'yours' : t === 'yours' || t === 'aside' ? 'aside' : t)
235
- copy.view.turn = turnFor(copy.view.turn)
236
- copy.row.turn = turnFor(copy.row.turn)
214
+ theirs.view.cells = [...theirs.view.cells, ...proposedCells(s, x, thread, theirs.view), ...pendingCells(s, x, thread, theirs.view, owner)].sort((p, q) => p.at.localeCompare(q.at))
215
+ markVotes(s, x, theirs.view)
216
+ personReads(theirs.view, items.items, { owner, own: ownCells(s, x, thread, theirs.view.head) })
237
217
  }
238
- const manifest = copy === null ? null : manifestOf(copy, thread, x.id, x.advisor)
218
+ const manifest = theirs === null ? null : manifestOf(theirs, thread, x.id, x.advisor)
239
219
  const his = membersOf(thread).flatMap((y) => y.thread.filter((m) => m.who === 'owner' && m.op !== 'seen').map((m) => m.at)).sort().at(-1) ?? null
240
- return { project, owner, copy, manifest, masked: items.masked, served, all, his, parts: { versions: items.versions, shown: items.shown } }
220
+ return { project, owner, theirs, manifest, masked: items.masked, all, his, parts: { versions: items.versions, shown: items.shown } }
241
221
  }
242
222
 
243
- /** what the door checks a share's reads and writes against: the copy's ids and pictures, each version that waits with
223
+ /** what the users' port checks a share's reads and writes against: the view's ids and pictures, each version that waits with
244
224
  * its count of views in the store, each choice question open to `advisor` (open, or answered by their own pick alone,
245
225
  * which they may change) with the hash of its words in the store */
246
- export function manifestOf(copy: AdvisorThread, thread: Thread, share: string, advisor?: string): ShareManifest {
226
+ export function manifestOf(read: AdvisorThread, thread: Thread, share: string, advisor?: string): ShareManifest {
247
227
  const real = new Map<string, ReviewItem>()
248
228
  for (const x of membersOf(thread)) real.set(opaqueItem(share, x.item.id), x)
249
- const ids = [copy.view.head, ...copy.view.members, ...copy.view.cells.map((c) => c.id)]
229
+ const ids = [read.view.head, ...read.view.members, ...read.view.cells.map((c) => c.id)]
250
230
  const images = new Set<string>()
251
231
  const judge: ShareManifest['judge'] = []
252
232
  const questions: ShareManifest['questions'] = []
253
- for (const c of copy.view.cells) {
233
+ for (const c of read.view.cells) {
254
234
  if (c.kind === 'version') {
255
235
  for (const v of c.item.views) for (const f of isGallery(v) ? v.gallery.map((g) => g.file) : 'image' in v.files ? [v.files.image] : 'before' in v.files ? [v.files.before, v.files.after] : []) images.add(f.slice(0, 64))
256
236
  const x = real.get(c.item.id)
257
237
  // waits, or holds their own direct verdict alone, which they may change
258
238
  const v = x === undefined ? null : verdictOf(x)
259
239
  const theirs = v !== null && advisor !== undefined && x!.thread.some((m) => m.id === v.id && m.who === 'player' && m.advisor?.id === advisor)
260
- if (x !== undefined && c.id === copy.view.head && (copy.view.waits || theirs)) judge.push({ item: c.item.id, version: x.item.views.length })
240
+ if (x !== undefined && c.id === read.view.head && (read.view.state.headWaits || theirs)) judge.push({ item: c.item.id, version: x.item.views.length })
261
241
  }
262
242
  if (c.kind === 'reply') {
263
243
  if (c.image !== undefined) images.add(c.image.slice(0, 64))
@@ -272,10 +252,11 @@ export function manifestOf(copy: AdvisorThread, thread: Thread, share: string, a
272
252
  }
273
253
  }
274
254
  }
275
- return { v: 1, head: copy.view.head, ids: [...new Set(ids)], images: [...images], judge, questions }
255
+ return { v: 1, head: read.view.head, ids: [...new Set(ids)], images: [...images], judge, questions }
276
256
  }
277
257
 
278
- /** where each person may start a thread (startPlacesOf), by the door's id; its names scanned like any text that leaves */
258
+ /** where each person may start a thread (startPlacesOf), by the id the advisors page names it by; its names scanned
259
+ * like any text that leaves */
279
260
  export async function projectsOf(s: OwnerState, words: string[], now = new Date()): Promise<Record<string, ServedProject>> {
280
261
  const out: Record<string, ServedProject> = {}
281
262
  for (const x of startPlacesOf(s, now)) {
@@ -290,132 +271,75 @@ export async function projectsOf(s: OwnerState, words: string[], now = new Date(
290
271
  }
291
272
 
292
273
  export interface SyncReport {
293
- pushed: number
294
- removed: number
274
+ /** the shares a person reads now */
275
+ reached: number
276
+ /** the advice his rights made direct since and that landed */
295
277
  advice: number
296
278
  errors: string[]
297
279
  }
298
280
 
299
- /** one pass: what leaves, what ends, what came back. A failed push is said on its share (`reach`) and in the report */
300
- export async function syncOnce(dir: string, o: { bucket: Bucket; words: string[]; encode?: Encode; now?: Date; app?: () => Promise<AppBundle>; again?: false }): Promise<SyncReport> {
281
+ /** the owner's pass over the users' port's folder `bucket` (users-store.ts): who may sign in kept equal to the grants,
282
+ * each live share prepared once for its reach and what it masks, where each reader stopped pulled into his store, the
283
+ * advice his rights make direct since delivered, the files staged and waiting swept, the sessions and passwords of
284
+ * people no longer listed ended. A failed share is said on it (`reach`) and in the report */
285
+ export async function syncOnce(dir: string, o: { bucket: Bucket; words: string[]; now?: Date }): Promise<SyncReport> {
301
286
  const now = o.now ?? new Date()
302
- const encode = o.encode ?? sharpWebp
303
- const report: SyncReport = { pushed: 0, removed: 0, advice: 0, errors: [] }
304
- // a project's access that shows every thread shares each new one before the push
287
+ const report: SyncReport = { reached: 0, advice: 0, errors: [] }
288
+ // a project's access that shows every thread shares each new one
305
289
  shareAllOfAccess(dir, now)
306
- // who may sign in: each person with a live grant, and whether the door says their code set a password
290
+ // who may sign in: each person with a live grant, and whether the port says their code set a password
307
291
  const used = new Map<string, number>()
308
292
  for (const a of readState(dir).advisors) {
309
- if (a.login === undefined || a.login.used === true) continue
293
+ if (a.login === undefined || (a.login.used === true && a.login.reset === undefined)) continue
310
294
  const kept = await getJson<{ gen?: unknown }>(o.bucket, KEYS.password(sha256(a.email))).catch(() => null)
311
295
  if (typeof kept?.gen === 'number') used.set(a.email, kept.gen)
312
296
  }
313
297
  const logins = withState(dir, (st) => keepLogins(st, now, used))
314
298
  const s = readState(dir)
315
- // the door opens what this writes and nothing else: the one answer to « who can open a thread » (owner-store.ts)
316
299
  const live = servedShares(s, now)
317
- const results = new Map<string, { prepared: Prepared | null; pushed?: string; read?: ShareRead | null; reach: Share['reach'] }>()
318
- const fallback = ownerNameOf(s)
319
- const shares: SharesFile = { v: 1, shares: {}, projects: await projectsOf(s, o.words, now), owner: maskHits(fallback, { advisorEmail: '', words: o.words }).length === 0 ? fallback : 'the owner', logins }
320
- const media = new Set<string>()
300
+ const results = new Map<string, { prepared: Prepared | null; read?: ShareRead | null; reach: Share['reach'] }>()
321
301
  for (const x of live) {
322
302
  try {
323
- const p = await prepare(s, x, { words: o.words, encode, now })
303
+ const p = await prepare(s, x, { words: o.words, now })
324
304
  if (p === null) {
325
305
  results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: 'its thread or advisor is gone' } })
326
306
  continue
327
307
  }
328
- if (p.copy !== null && p.copy.faults.length > 0) {
329
- // a value the copy's whitelist refused: a builder wrote what the door must not hold, so nothing of it leaves
330
- report.errors.push(`${x.id}: the copy refused ${p.copy.faults.length} values: ${p.copy.faults.slice(0, 3).join('; ')}`)
331
- results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: `its copy refused ${p.copy.faults.length} values: an agent's fix waits` } })
308
+ if (p.theirs !== null && p.theirs.faults.length > 0) {
309
+ // a value the output whitelist refused: a builder wrote what a person must not read, so the port shows nothing of it
310
+ report.errors.push(`${x.id}: the whitelist refused ${p.theirs.faults.length} values: ${p.theirs.faults.slice(0, 3).join('; ')}`)
311
+ results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: `its whitelist refused ${p.theirs.faults.length} values: an agent's fix waits` } })
332
312
  continue
333
313
  }
334
- const a = s.advisors.find((y) => y.id === x.advisor)!
335
- const served: ServedShare = { email: a.email, name: a.name, expires: x.expires, project: p.project, owner: p.owner, title: p.copy?.view.title ?? 'a thread', ...(a.photo?.seen === true ? { photo: a.photo.sha } : {}) }
336
- shares.shares[x.id] = served
337
- for (const m of p.served) media.add(m.sha)
338
- results.set(x.id, { prepared: p, reach: { ok: true, at: now.toISOString() } })
314
+ report.reached++
315
+ // where the person's reading stands, written by the port on their own page
316
+ results.set(x.id, { prepared: p, read: readOf(await o.bucket.get(KEYS.reads(x.id)), p.his), reach: { ok: true, at: now.toISOString() } })
339
317
  } catch (e) {
340
318
  report.errors.push(`${x.id}: ${(e as Error).message}`)
341
319
  results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: (e as Error).message } })
342
320
  }
343
321
  }
344
322
  try {
345
- if ((await o.bucket.get(KEYS.csrf)) === null) await o.bucket.put(KEYS.csrf, new Uint8Array(randomBytes(32)))
346
- // the advisors' page, by the hash of its bytes, before the list that pins it: the door serves only that pair
347
- if ((live.length > 0 || Object.keys(shares.projects ?? {}).length > 0) && o.app !== undefined) {
348
- const b = await o.app()
349
- for (const [f, ext] of [[b.js, 'js'], [b.css, 'css']] as const) if ((await o.bucket.get(KEYS.app(f.sha, ext))) === null) await o.bucket.put(KEYS.app(f.sha, ext), f.bytes, ext === 'js' ? 'text/javascript' : 'text/css')
350
- shares.app = b.pin
323
+ const keep = new Set(live.map((x) => x.id))
324
+ // an ended share's read cursor goes with it (the privacy page says so)
325
+ for (const k of await o.bucket.list('reads/')) {
326
+ const id = /^reads\/(.+)\.json$/.exec(k)?.[1]
327
+ if (id !== undefined && !keep.has(id)) await o.bucket.delete(k)
351
328
  }
352
- // the list of live shares first: an ended share is refused from this write on, whatever follows
353
- await o.bucket.put(KEYS.shares, JSON.stringify(shares), 'application/json')
354
- for (const x of live) {
355
- const r = results.get(x.id)!
356
- if (r.prepared === null) continue
357
- for (const m of r.prepared.served) if ((await o.bucket.get(KEYS.media(m.sha))) === null) await o.bucket.put(KEYS.media(m.sha), encoded.get(m.sha)!, 'image/webp')
358
- const { copy, manifest } = r.prepared
359
- const h = sha256(JSON.stringify({ copy: copy === null ? null : { view: copy.view, row: copy.row }, manifest }))
360
- if (h !== x.pushed) {
361
- if (copy !== null && manifest !== null) {
362
- // the manifest last: the door serves a share's copy once its manifest names it
363
- await o.bucket.put(KEYS.view(x.id), JSON.stringify(copy.view), 'application/json')
364
- await o.bucket.put(KEYS.row(x.id), JSON.stringify(copy.row), 'application/json')
365
- await o.bucket.put(KEYS.files(x.id), JSON.stringify(manifest), 'application/json')
366
- }
367
- report.pushed++
368
- }
369
- r.pushed = h
370
- // where the advisor's reading stands: pulled each pass, written by the door on their own page
371
- r.read = readOf(await o.bucket.get(KEYS.reads(x.id)), r.prepared.his)
372
- }
373
- const keep = new Set(Object.keys(shares.shares))
374
- // an ended share's copy: its manifest first, so the door stops serving it before its view goes; its cursor after
375
- for (const prefix of ['files/', 'view/', 'row/', 'reads/'])
376
- for (const k of await o.bucket.list(prefix)) {
377
- const id = /^[a-z]+\/(.+)\.json$/.exec(k)?.[1]
378
- if (id !== undefined && !keep.has(id)) {
379
- await o.bucket.delete(k)
380
- if (prefix === 'files/') report.removed++
381
- }
382
- }
383
- // a file the page staged and no words took: gone after an hour, or with its share
384
- const projects = new Set(Object.keys(shares.projects ?? {}))
329
+ // a file the page staged and no words took: gone after an hour, or with its share or project
330
+ const places = new Set(startPlacesOf(s, now).map((x) => x.id))
385
331
  for (const k of await o.bucket.list('stage/')) {
386
332
  const m = /^stage\/(s|p)\/([^/]+)\/(\d{13})-/.exec(k)
387
- const open = m !== null && (m[1] === 's' ? keep : projects).has(m[2]!)
333
+ const open = m !== null && (m[1] === 's' ? keep : places).has(m[2]!)
388
334
  if (m === null || !open || Number(m[3]) < now.getTime() - 3_600_000) await o.bucket.delete(k)
389
335
  }
390
- // each advisor's own photo, while a share or a project names it: read by that advisor's page alone (edge/handler.ts)
391
- const photos = new Map<string, string>()
392
- for (const v of [...Object.values(shares.shares), ...Object.values(shares.projects ?? {})]) {
393
- const a = s.advisors.find((y) => y.email === v.email)
394
- if (v.photo !== undefined && a !== undefined) photos.set(v.photo, a.id)
395
- }
396
- for (const [sha, id] of photos) {
397
- if ((await o.bucket.get(KEYS.photo(sha))) !== null) continue
398
- const bytes = photoBytes(dir, 'advisors', id, 64)
399
- if (bytes !== null) await o.bucket.put(KEYS.photo(sha), bytes, 'image/webp')
400
- }
401
336
  // a person no longer in the list: their sessions end; one no longer known: their password too
402
337
  const signed = new Set(Object.keys(logins).map(sha256))
403
338
  const known = new Set(s.advisors.map((a) => sha256(a.email)))
404
339
  for (const k of await o.bucket.list('session/')) if (!signed.has(k.split('/')[1] ?? '')) await o.bucket.delete(k)
405
340
  for (const k of await o.bucket.list('login/')) if (!known.has(/^login\/([0-9a-f]{64})\./.exec(k)?.[1] ?? '')) await o.bucket.delete(k)
406
- for (const k of await o.bucket.list('photo/')) {
407
- const sha = /^photo\/([0-9a-f]{64})\.webp$/.exec(k)?.[1]
408
- if (sha === undefined || !photos.has(sha)) await o.bucket.delete(k)
409
- }
410
- for (const k of await o.bucket.list('media/')) {
411
- const sha = /^media\/([0-9a-f]{64})\.webp$/.exec(k)?.[1]
412
- if (sha === undefined || !media.has(sha)) await o.bucket.delete(k)
413
- }
414
341
  } catch (e) {
415
- report.errors.push(`the bucket: ${(e as Error).message}`)
416
- for (const r of results.values()) r.reach = { ok: false, at: now.toISOString(), why: `the bucket: ${(e as Error).message}` }
417
- } finally {
418
- encoded.clear()
342
+ report.errors.push(`the users' folder: ${(e as Error).message}`)
419
343
  }
420
344
  withState(dir, (st) => {
421
345
  for (const x of st.shares) {
@@ -423,45 +347,35 @@ export async function syncOnce(dir: string, o: { bucket: Bucket; words: string[]
423
347
  if (r !== undefined) {
424
348
  x.reach = r.reach
425
349
  if (r.prepared !== null) {
426
- // nothing is held any more: an older pass's holds and waiting pictures leave the store
350
+ // a share holds nothing back: the store's stale `held` and `waiting` fields go
427
351
  x.masked = r.prepared.masked
428
352
  delete x.held
429
353
  delete x.waiting
430
354
  x.parts = r.prepared.parts
355
+ x.pushed = sha256(JSON.stringify({ view: r.prepared.theirs?.view ?? null, manifest: r.prepared.manifest }))
431
356
  }
432
- if (r.pushed !== undefined) x.pushed = r.pushed
433
357
  if (r.read !== undefined) {
434
358
  if (r.read === null) delete x.read
435
359
  else x.read = r.read
436
360
  }
437
361
  } else if (x.state === 'revoked' || (x.state === 'live' && !isLive(x, now))) {
438
362
  x.reach = report.errors.length === 0 ? { ok: true, at: now.toISOString() } : { ok: false, at: now.toISOString(), why: report.errors[0]! }
439
- // where they stopped reading goes with the share, here as on the door (the door's privacy page says so)
363
+ // where they stopped reading goes with the share
440
364
  delete x.read
441
365
  }
442
366
  }
443
367
  })
444
- if (report.errors.length === 0) {
445
- const proposed = readState(dir).proposals.length
446
- report.advice = (await importAdvice(dir, o.bucket, now)).length
447
- // what came back is drawn in the copies by this pass, not the next: the person's page shows their act (their
448
- // words, « waits for <owner> », a thread they opened) within one pass of the job
449
- if (o.again !== false && (report.advice > 0 || readState(dir).proposals.length > proposed)) {
450
- const r = await syncOnce(dir, { ...o, now, again: false })
451
- report.pushed += r.pushed
452
- report.removed += r.removed
453
- report.errors.push(...r.errors)
454
- }
455
- }
368
+ report.advice = await deliverPending(dir, o.bucket, now)
369
+ await sweepUploads(dir, o.bucket, now)
456
370
  return report
457
371
  }
458
372
 
459
- /** with no advisors page yet (not set up): each live share's masked entries, for his preview */
373
+ /** with no advisors page yet (not set up): each live share's masked entries, for the owner's preview */
460
374
  export async function refreshLocal(dir: string, o: { words: string[]; now?: Date }): Promise<void> {
461
375
  const now = o.now ?? new Date()
462
376
  const s = readState(dir)
463
377
  const got = new Map<string, Prepared | null>()
464
- for (const x of s.shares.filter((y) => isLive(y, now))) got.set(x.id, await prepare(s, x, { words: o.words, encode: sharpWebp, now, preview: true }))
378
+ for (const x of s.shares.filter((y) => isLive(y, now))) got.set(x.id, await prepare(s, x, { words: o.words, now }))
465
379
  withState(dir, (st) => {
466
380
  for (const x of st.shares) {
467
381
  const p = got.get(x.id)
@@ -1,11 +1,12 @@
1
- // the tunnel to the advisors' door (wiki tools/shipkit/advisors.md, The advisors page and its server): `sk advisors tunnel`, a pm process
2
- // (src/advisors-tunnel.shipkit.ts), keeps `cloudflared tunnel run` up while this machine carries the hq and the
3
- // tunnel's token is stored, and stops it when the hq moves: one connector only, on the Mac that holds the copies.
1
+ // the tunnel to the advisors page (wiki tools/shipkit/advisors.md, Who calls: the users' port): `sk advisors
2
+ // tunnel`, a pm process (src/advisors-tunnel.shipkit.ts), keeps `cloudflared tunnel run` up while this machine carries
3
+ // the hq and the tunnel's token is stored, and stops it when the hq moves: one connector only, on the Mac whose daemon
4
+ // opens the users' port.
4
5
  // The one constraint a reader breaks first: the token goes to cloudflared by its environment (TUNNEL_TOKEN), never on
5
6
  // its command line and never in a line of the log
6
7
  import { existsSync } from 'node:fs'
7
8
  import { readSecretHere } from '../secrets/read.ts'
8
- import { TUNNEL_TOKEN } from './door.ts'
9
+ import { TUNNEL_TOKEN } from './reach.ts'
9
10
 
10
11
  export type Proc = { exited: Promise<unknown>; kill: () => void }
11
12
 
@@ -38,7 +39,7 @@ export const cloudflaredBin = (): string | null => BINS.find((b) => existsSync(b
38
39
  /** the global process that keeps cloudflared up (src/advisors-tunnel.shipkit.ts at the house's root) */
39
40
  export const TUNNEL_PROCESS = 'advisors-tunnel'
40
41
 
41
- /** cloudflared for the door's setup: its binary, and the tunnel process started through the one road that starts a
42
+ /** cloudflared for the advisors page's setup: its binary, and the tunnel process started through the one road that starts a
42
43
  * global process (pm's switch), null once it runs, else why not. A surface that reaches pm hands it in */
43
44
  export interface TunnelStart {
44
45
  bin: () => string | null