rvlib-shipkit 2.31.0 → 2.32.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 (384) hide show
  1. package/CHANGELOG.md +31 -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 +98 -73
  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 +26 -198
  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 +25 -23
  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 +92 -182
  37. package/src/advisors/tunnel.ts +6 -5
  38. package/src/advisors/users-listen.ts +92 -0
  39. package/src/advisors/users-router.ts +257 -85
  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_Checks.ts +0 -14
  67. package/src/cli/cmd_Db.ts +3 -82
  68. package/src/cli/cmd_Home.ts +4 -32
  69. package/src/cli/cmd_Hq.ts +0 -17
  70. package/src/cli/cmd_Releases.ts +57 -4
  71. package/src/cli/cmd_Review.ts +333 -354
  72. package/src/cli/cmd_SocialDrafts.ts +6 -13
  73. package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
  74. package/src/cli/cmd_Time.ts +1 -1
  75. package/src/cli/cmd_Trailer.ts +1 -1
  76. package/src/cli/inbox-hook-run.ts +5 -23
  77. package/src/cli/registry-heads.ts +5 -55
  78. package/src/cli/registry.ts +1 -5
  79. package/src/cli/review-here.ts +1 -1
  80. package/src/cli.ts +2 -2
  81. package/src/collections/collection-types.ts +1 -1
  82. package/src/collections/review.ts +5 -4
  83. package/src/core/agent-allow-policy.ts +32 -2
  84. package/src/core/agent-env.ts +8 -0
  85. package/src/core/allow-rows.ts +74 -0
  86. package/src/core/check-file-names.ts +19 -106
  87. package/src/core/footprint.ts +17 -13
  88. package/src/core/identities-root.ts +1 -4
  89. package/src/core/layout.ts +1 -2
  90. package/src/core/machine-db.ts +33 -208
  91. package/src/core/machine-layout.ts +14 -127
  92. package/src/core/mask-source.ts +60 -0
  93. package/src/core/memory-watch.ts +17 -14
  94. package/src/core/motherhome.ts +8 -35
  95. package/src/core/one-way-in-policy.ts +0 -3
  96. package/src/core/repo-walk.ts +0 -9
  97. package/src/core/retention.ts +1 -9
  98. package/src/core/retired-checks.ts +2 -0
  99. package/src/core/tmux-policy.ts +1 -1
  100. package/src/core/tree-watch.ts +2 -2
  101. package/src/core/when.ts +7 -45
  102. package/src/gate/discover-checks.ts +42 -32
  103. package/src/gate/gate-checks.ts +21 -131
  104. package/src/gate/pre-commit-discovery.ts +16 -25
  105. package/src/gate/run-check.ts +0 -4
  106. package/src/gate/run-fix.ts +5 -17
  107. package/src/gate/run-fixers.ts +6 -42
  108. package/src/home/app-sign.ts +2 -2
  109. package/src/home/backup-status.ts +52 -92
  110. package/src/home/backup-verdict.ts +2 -2
  111. package/src/home/daemon-jobs.ts +51 -95
  112. package/src/home/database-words.ts +1 -2
  113. package/src/home/databases.ts +9 -25
  114. package/src/home/home-launchd.ts +0 -6
  115. package/src/home/home-paths.ts +8 -4
  116. package/src/home/home-routes.ts +3 -10
  117. package/src/home/home-state.ts +2 -14
  118. package/src/home/inbox-shape.ts +14 -15
  119. package/src/home/inbox.ts +1 -1
  120. package/src/home/machine-repair.ts +102 -103
  121. package/src/home/resume.ts +1 -15
  122. package/src/home/run-daemon.ts +4 -11
  123. package/src/home/space-page.ts +3 -2
  124. package/src/home/supervise.ts +3 -7
  125. package/src/hooks/hook-config.ts +6 -7
  126. package/src/hooks/leak-guard.ts +1 -1
  127. package/src/hooks/run-hooks.ts +0 -5
  128. package/src/hq/daemon-db.ts +8 -8
  129. package/src/hq/door.ts +3 -16
  130. package/src/hq/hq-db.ts +4 -3
  131. package/src/hq/hq-local.ts +1 -2
  132. package/src/hq/hq-store.ts +0 -15
  133. package/src/hq/item-direct.ts +8 -10
  134. package/src/hq/item-fill.ts +37 -0
  135. package/src/hq/kinds/item-gone.ts +7 -10
  136. package/src/hq/kinds/item-msg.ts +12 -18
  137. package/src/hq/kinds/item.ts +13 -19
  138. package/src/hq/kinds/report.ts +3 -4
  139. package/src/hq/owner-switch.ts +3 -3
  140. package/src/hq/report.ts +5 -9
  141. package/src/hq/switch.ts +2 -11
  142. package/src/hq/thread-sync.ts +5 -17
  143. package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
  144. package/src/http/owner-word.ts +1 -1
  145. package/src/identities/machine.ts +16 -0
  146. package/src/init-repo.ts +0 -1
  147. package/src/ledger/check-stats.ts +6 -5
  148. package/src/ledger/db.ts +2 -4
  149. package/src/ledger/record-kept.ts +117 -48
  150. package/src/ledger/run-log.ts +21 -2
  151. package/src/ledger/slow-tests.ts +96 -0
  152. package/src/ledger/store.ts +3 -86
  153. package/src/ledger/suite-log.ts +8 -2
  154. package/src/media-store/backup/facts.ts +3 -37
  155. package/src/media-store/backup/keys.ts +1 -8
  156. package/src/media-store/backup/manifest.ts +6 -67
  157. package/src/media-store/backup/restore.ts +4 -13
  158. package/src/media-store/backup/retention.ts +13 -1
  159. package/src/media-store/backup/run.ts +6 -267
  160. package/src/media-store/backup/snapshot.ts +2 -38
  161. package/src/media-store/backup/sources.ts +3 -113
  162. package/src/media-store/backup/target-send.ts +5 -29
  163. package/src/media-store/db.ts +8 -7
  164. package/src/media-store/forget-one.ts +1 -1
  165. package/src/media-store/forget.ts +1 -80
  166. package/src/orchestrator/guards.ts +0 -1
  167. package/src/orchestrator/presence.ts +2 -2
  168. package/src/orchestrator/routes.ts +1 -1
  169. package/src/orchestrator/started.ts +0 -9
  170. package/src/orchestrator/talk-key.ts +3 -4
  171. package/src/orchestrator/unheard.ts +1 -1
  172. package/src/recordings/edit.ts +3 -3
  173. package/src/recordings/marks-draw.ts +17 -6
  174. package/src/recordings/marks.ts +120 -9
  175. package/src/reflections/reflections-queue.ts +3 -10
  176. package/src/release/notes.ts +1 -1
  177. package/src/release/public-clean.ts +66 -6
  178. package/src/release/run-bump.ts +11 -0
  179. package/src/release/run-release.ts +4 -0
  180. package/src/releases/from-thread.ts +3 -3
  181. package/src/releases/model.ts +186 -36
  182. package/src/releases/store.ts +13 -3
  183. package/src/releases/validate.ts +83 -0
  184. package/src/repo-config.ts +29 -64
  185. package/src/review/answer-kinds.ts +61 -4
  186. package/src/review/blocked-guard.ts +11 -0
  187. package/src/review/blocked-object.ts +298 -0
  188. package/src/review/cells.ts +116 -229
  189. package/src/review/close.ts +39 -1
  190. package/src/review/doc-save.ts +3 -2
  191. package/src/review/draft-item.ts +1 -1
  192. package/src/review/events.ts +3 -7
  193. package/src/review/expect.ts +23 -39
  194. package/src/review/format.ts +79 -46
  195. package/src/review/glyphs.ts +1 -0
  196. package/src/review/hand-over.ts +3 -3
  197. package/src/review/heard.ts +1 -1
  198. package/src/review/holds-sync.ts +2 -1
  199. package/src/review/inbox-hook.ts +2 -2
  200. package/src/review/inbox-read.ts +39 -33
  201. package/src/review/instruction-guards.ts +12 -0
  202. package/src/review/instructions.ts +0 -1
  203. package/src/review/item-db.ts +13 -43
  204. package/src/review/item-hq.ts +2 -2
  205. package/src/review/item-rows.ts +3 -14
  206. package/src/review/kind-catalog.ts +3 -1
  207. package/src/review/kinds.ts +18 -8
  208. package/src/review/live-view.ts +3 -0
  209. package/src/review/media-kind.ts +1 -1
  210. package/src/review/mentions.ts +1 -2
  211. package/src/review/model.ts +158 -114
  212. package/src/review/move.ts +149 -0
  213. package/src/review/need-threads.ts +3 -2
  214. package/src/review/object-card.ts +11 -0
  215. package/src/review/object-read.ts +6 -1
  216. package/src/review/one-block.ts +1 -1
  217. package/src/review/owner-read.ts +1 -1
  218. package/src/review/phone-push.ts +10 -9
  219. package/src/review/previews.ts +32 -4
  220. package/src/review/push.ts +2 -2
  221. package/src/review/recap.ts +129 -0
  222. package/src/review/referring.ts +6 -3
  223. package/src/review/reflection-object.ts +4 -3
  224. package/src/review/routes.ts +49 -19
  225. package/src/review/secret-route.ts +3 -2
  226. package/src/review/settle.ts +0 -6
  227. package/src/review/snooze.ts +5 -3
  228. package/src/review/speaker.ts +68 -0
  229. package/src/review/start-title.ts +19 -0
  230. package/src/review/store.ts +86 -59
  231. package/src/review/{wakes.ts → thread-events.ts} +92 -7
  232. package/src/review/thread-md.ts +35 -14
  233. package/src/review/thread-state.ts +798 -0
  234. package/src/review/threads.ts +29 -347
  235. package/src/review/traces.ts +104 -7
  236. package/src/review/trailer-item.ts +1 -1
  237. package/src/review/unit.ts +7 -9
  238. package/src/review/verdict-items.ts +12 -10
  239. package/src/review/view-layout.ts +25 -1
  240. package/src/review/watch-feed.ts +1 -2
  241. package/src/review/working-guards.ts +2 -3
  242. package/src/rules/untrack-generated.ts +1 -15
  243. package/src/secrets/lapse.ts +2 -1
  244. package/src/serve/hub-app/advisor-app.tsx +4 -4
  245. package/src/serve/hub-app/advisor-face.tsx +9 -3
  246. package/src/serve/hub-app/advisor-host.ts +27 -27
  247. package/src/serve/hub-app/advisors-model.ts +17 -8
  248. package/src/serve/hub-app/advisors-rights.tsx +1 -1
  249. package/src/serve/hub-app/advisors-st.ts +15 -14
  250. package/src/serve/hub-app/advisors-view.tsx +13 -11
  251. package/src/serve/hub-app/app-bridge.ts +23 -3
  252. package/src/serve/hub-app/asks-page.tsx +1 -1
  253. package/src/serve/hub-app/auto-text.tsx +71 -16
  254. package/src/serve/hub-app/check-view.tsx +0 -8
  255. package/src/serve/hub-app/controls.css +14 -3
  256. package/src/serve/hub-app/database-view.tsx +1 -2
  257. package/src/serve/hub-app/git-view.tsx +3 -1
  258. package/src/serve/hub-app/hub.css +12 -5
  259. package/src/serve/hub-app/icons.tsx +1 -1
  260. package/src/serve/hub-app/inbox-view.tsx +1 -2
  261. package/src/serve/hub-app/live-sources.ts +2 -2
  262. package/src/serve/hub-app/main-panel.tsx +2 -1
  263. package/src/serve/hub-app/panel-repo.ts +0 -9
  264. package/src/serve/hub-app/pic.tsx +29 -12
  265. package/src/serve/hub-app/polled.ts +16 -2
  266. package/src/serve/hub-app/recordings-st.ts +23 -2
  267. package/src/serve/hub-app/recordings-view.tsx +68 -10
  268. package/src/serve/hub-app/ref-pill.ts +1 -1
  269. package/src/serve/hub-app/repo-st.ts +1 -2
  270. package/src/serve/hub-app/review/advisor-add.tsx +1 -1
  271. package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
  272. package/src/serve/hub-app/review/draft-body.tsx +2 -2
  273. package/src/serve/hub-app/review/heard-line.tsx +1 -1
  274. package/src/serve/hub-app/review/instructions-view.tsx +1 -8
  275. package/src/serve/hub-app/review/kind-states.tsx +14 -9
  276. package/src/serve/hub-app/review/kit.tsx +4 -11
  277. package/src/serve/hub-app/review/lane-bar.tsx +3 -3
  278. package/src/serve/hub-app/review/lightbox.tsx +15 -11
  279. package/src/serve/hub-app/review/line-window.ts +4 -1
  280. package/src/serve/hub-app/review/live-bar-st.ts +2 -2
  281. package/src/serve/hub-app/review/live-view.tsx +57 -1
  282. package/src/serve/hub-app/review/object-panel.tsx +20 -8
  283. package/src/serve/hub-app/review/question-views.tsx +181 -54
  284. package/src/serve/hub-app/review/recap-bar.tsx +40 -0
  285. package/src/serve/hub-app/review/request-cell.tsx +48 -0
  286. package/src/serve/hub-app/review/review-cells.tsx +154 -96
  287. package/src/serve/hub-app/review/review-host.ts +2 -2
  288. package/src/serve/hub-app/review/review-kit.ts +17 -11
  289. package/src/serve/hub-app/review/review-list.tsx +23 -31
  290. package/src/serve/hub-app/review/review-st.ts +30 -40
  291. package/src/serve/hub-app/review/review-thread.tsx +139 -85
  292. package/src/serve/hub-app/review/review-views.tsx +124 -68
  293. package/src/serve/hub-app/review/share-lines.tsx +4 -4
  294. package/src/serve/hub-app/review/start-st.ts +2 -5
  295. package/src/serve/hub-app/review/superseded-runs.ts +4 -3
  296. package/src/serve/hub-app/review/thread-close.tsx +10 -7
  297. package/src/serve/hub-app/review/thread-st.ts +372 -201
  298. package/src/serve/hub-app/review/tone-bar.tsx +126 -0
  299. package/src/serve/hub-app/review/tones.ts +35 -0
  300. package/src/serve/hub-app/review/trailer-body.tsx +2 -2
  301. package/src/serve/hub-app/review/trailer-st.ts +3 -2
  302. package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
  303. package/src/serve/hub-app/review.css +180 -106
  304. package/src/serve/hub-app/search-view.tsx +1 -1
  305. package/src/serve/hub-app/social/social-model.ts +0 -4
  306. package/src/serve/hub-app/source-acts.ts +2 -1
  307. package/src/serve/hub-app/stores/stores-page.tsx +2 -2
  308. package/src/serve/hub-app/terminal-sources.tsx +2 -1
  309. package/src/serve/hub-app/thread-row.tsx +3 -4
  310. package/src/serve/hub-app/tree-build.ts +0 -4
  311. package/src/serve/hub-app/urls-view.tsx +2 -1
  312. package/src/serve/hub-app/view-layout.css +13 -3
  313. package/src/serve/hub-app/wikis-view.tsx +5 -2
  314. package/src/serve/hub-runtime.ts +7 -37
  315. package/src/serve/project-gutter-route.ts +6 -2
  316. package/src/serve/read-thread.ts +20 -2
  317. package/src/serve/read-worker.ts +9 -1
  318. package/src/serve/record-pages.ts +46 -0
  319. package/src/serve/serve-hub.ts +2 -2
  320. package/src/serve/terminal-host.ts +1 -1
  321. package/src/serve/terminal-route.ts +1 -3
  322. package/src/serve/tracked-watch.ts +1 -3
  323. package/src/setup-house.ts +2 -2
  324. package/src/shipkit-files.ts +1 -1
  325. package/src/shipkit.ts +1 -6
  326. package/src/shot/film-box.ts +0 -20
  327. package/src/social/drafts.ts +1 -1
  328. package/src/social/kinds.ts +6 -29
  329. package/src/social/load.ts +2 -2
  330. package/src/social/post-object.ts +3 -2
  331. package/src/social/release-stage.ts +1 -1
  332. package/src/social/stage.ts +2 -2
  333. package/src/stores/model.ts +4 -0
  334. package/src/stores/routes.ts +11 -3
  335. package/src/suite/judge-suites.ts +58 -0
  336. package/src/suite/red-alone.ts +54 -18
  337. package/src/suite/runner-shapes.ts +2 -2
  338. package/src/suite/suite-cli.ts +67 -14
  339. package/src/suite/test-units.ts +2 -1
  340. package/src/urls/fill.ts +1 -1
  341. package/src/urls/places.ts +1 -2
  342. package/src/vault/vault-config.ts +2 -2
  343. package/src/vault/vault-init.ts +1 -5
  344. package/src/wiki/graph-page.ts +14 -2
  345. package/src/advisors/copy-truth.ts +0 -49
  346. package/src/advisors/door-child.ts +0 -112
  347. package/src/advisors/door-serve.ts +0 -52
  348. package/src/advisors/door.ts +0 -118
  349. package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
  350. package/src/checks/SK029-explicit-check-files.check.ts +0 -112
  351. package/src/checks/SK048-one-local-file.check.ts +0 -36
  352. package/src/core/config-rewrite.ts +0 -111
  353. package/src/core/daemon-port.ts +0 -10
  354. package/src/core/legacy-shapes.ts +0 -263
  355. package/src/core/migrate-layout.ts +0 -638
  356. package/src/core/port-check-cli.ts +0 -52
  357. package/src/core/port-check-file.ts +0 -295
  358. package/src/core/port-check-files.ts +0 -31
  359. package/src/gate/discover-legacy-checks.ts +0 -26
  360. package/src/home/home-move.ts +0 -527
  361. package/src/home/machine-fold.ts +0 -810
  362. package/src/hq/item-shapes.ts +0 -54
  363. package/src/hq/kinds/items-read.ts +0 -4
  364. package/src/media-store/backup/daemon.ts +0 -220
  365. package/src/media-store/backup/kept.ts +0 -241
  366. package/src/media-store/backup/prune.ts +0 -359
  367. package/src/media-store/backup/secret.ts +0 -88
  368. package/src/media-store/backup/ssh-space.ts +0 -202
  369. package/src/media-store/backup/watch.ts +0 -117
  370. package/src/review/band.ts +0 -182
  371. package/src/review/folders.ts +0 -216
  372. package/src/review/hook-ask.ts +0 -58
  373. package/src/review/role.ts +0 -48
  374. package/src/review/thread-fold.ts +0 -64
  375. package/src/review/wait.ts +0 -91
  376. package/src/rules/rule.ts +0 -43
  377. package/src/serve/hook-thread.ts +0 -37
  378. package/src/serve/hook-work.ts +0 -92
  379. package/src/serve/hook-worker.ts +0 -57
  380. package/src/serve/hub-app/review/dock.tsx +0 -147
  381. package/src/serve/hub-app/review/faces.tsx +0 -18
  382. package/src/serve/hub-app/review/item-verdict.tsx +0 -112
  383. package/src/serve/hub-app/review/review-board.tsx +0 -48
  384. /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
@@ -0,0 +1,181 @@
1
+ // the classifier's refusals, read from the agent time index the daemon already keeps (store.ts), each onto its card
2
+ // (review/blocked-object.ts). No new reader of the transcripts: the pass reads the index rows written since its last
3
+ // look, by rowid, a range of the primary key; a refusal whose result landed after its call's row was written is
4
+ // caught by the ids kept open from the look before.
5
+ // The one constraint a reader breaks first: a refusal is the classifier's verdict alone. « gave no verdict » is a
6
+ // failure of the check that the agent retries, a « no » of the owner on a prompt is his own answer, a hook is the
7
+ // repo's own guard: none of them is a card
8
+ import type { Database } from 'bun:sqlite'
9
+ import { closeSync, openSync, readFileSync, readSync, statSync } from 'fs'
10
+ import { refusalOf } from './refused.ts'
11
+ import { laneNameOf } from './lane-name.ts'
12
+
13
+ /** the one form of a classifier's refusal; the « gave no verdict » form starts otherwise */
14
+ export const CLASSIFIER_REFUSAL = 'Permission for this action was denied by the Claude Code auto mode classifier'
15
+
16
+ /** the refusal's reason line when this call's result is the classifier's refusal of a Bash command, else null */
17
+ export function classifierRefusal(c: { tool: string; outcome: string | null; why: string }): { reason: string } | null {
18
+ if (c.tool !== 'Bash' || c.outcome !== 'blocked' || !c.why.startsWith(CLASSIFIER_REFUSAL)) return null
19
+ return { reason: refusalOf('blocked', c.why).reason }
20
+ }
21
+
22
+ export interface FoundRefusal {
23
+ call: string
24
+ at: number
25
+ command: string
26
+ /** the index keeps a long command's head and tail alone */
27
+ clipped: boolean
28
+ reason: string
29
+ project: string
30
+ session: string
31
+ /** '' for a session's own transcript, the sub-agent's file name for a lane */
32
+ agent: string
33
+ path: string
34
+ }
35
+
36
+ const CURSOR = 'blocked cursor'
37
+ /** a call still open this long after it started is let go: its session ended with it in flight */
38
+ const OPEN_MS = 60 * 60_000
39
+ /** a refusal older than this when first read is history, never a card: a transcript indexed again (a rebuild, a file
40
+ * the index never saw) brings its old calls back under new rowids, and the first look after a restart reads this far */
41
+ export const LIVE_MS = 15 * 60_000
42
+ /** clipMiddle in reflect/transcript.ts keeps 2 × 400 characters of a longer command */
43
+ const CLIP_AT = 800
44
+
45
+ type Cursor = { rowid: number; open: string[] }
46
+
47
+ type Row = { rowid: number; file_id: number; id: string; start: number; end: number | null; tool: string; cmd: string; outcome: string | null; why: string; project: string; session: string; agent: string; path: string }
48
+
49
+ const SELECT = 'select c.rowid as rowid, c.file_id, c.id, c.start, c.end, c.tool, c.cmd, c.outcome, c.why, f.project, f.session, f.agent, f.path from time_calls c join time_files f on f.id = c.file_id'
50
+
51
+ /** the session moved on past a refusal: a prompt came after it in its transcript, or the same command ran since */
52
+ function movedOn(db: Database, r: Row, at: number): boolean {
53
+ if (db.query<{ n: number }, [number, number]>('select 1 as n from time_prompts where file_id = ? and at > ? limit 1').get(r.file_id, at) != null) return true
54
+ return db.query<{ n: number }, [number, number, string]>("select 1 as n from time_calls where file_id = ? and start > ? and tool = 'Bash' and cmd = ? and outcome = 'ok' limit 1").get(r.file_id, r.start, r.cmd) != null
55
+ }
56
+
57
+ /** the live refusals the index holds since the last look, and the cursor moved past them: one read the first time
58
+ * within LIVE_MS of now, and not followed in its transcript by the session moving on */
59
+ export function newRefusals(db: Database, now = Date.now()): FoundRefusal[] {
60
+ const meta = db.query<{ value: string }, [string]>('select value from time_meta where key = ?').get(CURSOR)
61
+ const was: Cursor | null = meta == null ? null : (JSON.parse(meta.value) as Cursor)
62
+ const top = db.query<{ m: number | null }, []>('select max(rowid) as m from time_calls').get()?.m ?? 0
63
+ const from = was?.rowid ?? 0
64
+ const rows = was === null ? db.query<Row, [number, number]>(`${SELECT} where c.rowid > ? and c.tool = 'Bash' and c.start >= ?`).all(Math.max(0, top - 50_000), now - LIVE_MS) : db.query<Row, [number]>(`${SELECT} where c.rowid > ? and c.tool = 'Bash'`).all(from)
65
+ const again = (was?.open ?? []).length === 0 ? [] : db.query<Row, string[]>(`${SELECT} where c.id in (${was!.open.map(() => '?').join(',')})`).all(...was!.open)
66
+ const seen = new Set<string>()
67
+ const found: FoundRefusal[] = []
68
+ for (const r of [...again, ...rows]) {
69
+ if (seen.has(r.id)) continue
70
+ seen.add(r.id)
71
+ const refused = classifierRefusal(r)
72
+ if (refused === null) continue
73
+ const at = r.end ?? r.start
74
+ if (at < now - LIVE_MS || movedOn(db, r, at)) continue
75
+ found.push({ call: r.id, at: r.start, command: r.cmd, clipped: r.cmd.length >= CLIP_AT && r.cmd.includes('\n'), reason: refused.reason, project: r.project, session: r.session, agent: r.agent, path: r.path })
76
+ }
77
+ const open = [...again, ...rows].filter((r) => r.end === null && r.start >= now - OPEN_MS).map((r) => r.id)
78
+ const next: Cursor = { rowid: Math.max(from, top, ...rows.map((r) => r.rowid)), open: [...new Set(open)] }
79
+ db.query('insert into time_meta (key, value) values (?, ?) on conflict(key) do update set value = excluded.value').run(CURSOR, JSON.stringify(next))
80
+ return found
81
+ }
82
+
83
+ /** the house repo a transcript's project folder is in: its own folder, a worktree of it under `.claude/worktrees/`, or a
84
+ * folder inside it, the longest match winning; null for a project of no house repo */
85
+ export function repoOfTranscript(project: string, repos: readonly { name: string; path: string }[]): { name: string; path: string } | null {
86
+ const slug = (p: string): string => p.replace(/[^a-zA-Z0-9]/g, '-')
87
+ let best: { name: string; path: string } | null = null
88
+ for (const r of repos) {
89
+ const s = slug(r.path)
90
+ const hit = project === s || project.startsWith(`${s}--claude-worktrees-`) || project.startsWith(`${s}-`)
91
+ if (hit && (best === null || s.length > slug(best.path).length)) best = r
92
+ }
93
+ return best
94
+ }
95
+
96
+ /** a lane's name from the description its session gave it (its transcript's meta file), null for a session's own */
97
+ export function laneOfTranscript(path: string, agent: string): string | null {
98
+ if (agent === '') return null
99
+ try {
100
+ const meta = JSON.parse(readFileSync(path.replace(/\.jsonl$/, '.meta.json'), 'utf8')) as { description?: unknown }
101
+ return typeof meta.description === 'string' ? laneNameOf(meta.description) : null
102
+ } catch {
103
+ return null
104
+ }
105
+ }
106
+
107
+ /** what one pass did, and its cost: `ms` the whole pass, `scanMs` the read of the index alone */
108
+ export type BlockedPass = { refusals: number; counted: number; opened: number; skipped: number; ms: number; scanMs: number }
109
+
110
+ /** one pass: the index rows since the last look, each refusal onto its card in the repo its session works in; `label`
111
+ * names a session as `sk session` prints it */
112
+ export async function blockedPass(db: Database, repos: readonly { name: string; path: string }[], o: { label?: (session: string) => Promise<string>; now?: Date; printErr?: (l: string) => void } = {}): Promise<BlockedPass> {
113
+ const t0 = performance.now()
114
+ const found = newRefusals(db, o.now?.getTime())
115
+ const scanMs = performance.now() - t0
116
+ const out: BlockedPass = { refusals: found.length, counted: 0, opened: 0, skipped: 0, ms: 0, scanMs }
117
+ if (found.length > 0) {
118
+ const { recordRefusal } = await import('../review/blocked-object.ts')
119
+ const { repoNameOf } = await import('./registry.ts')
120
+ for (const f of found) {
121
+ const repo = repoOfTranscript(f.project, repos)
122
+ if (repo === null) {
123
+ out.skipped++
124
+ continue
125
+ }
126
+ try {
127
+ const label = (await o.label?.(f.session).catch(() => null)) ?? `${repo.name} session ${f.session.slice(0, 8)}`
128
+ const r = await recordRefusal(repo.path, repoNameOf(repo.path), f.command, { call: f.call, at: f.at, session: f.session, lane: laneOfTranscript(f.path, f.agent), label, reason: f.reason, clipped: f.clipped }, o.now)
129
+ if (r.counted) out.counted++
130
+ if (r.opened) out.opened++
131
+ } catch (e) {
132
+ o.printErr?.(`WARN blocked card of ${repo.name}: ${(e as Error).message}`)
133
+ }
134
+ }
135
+ }
136
+ out.ms = performance.now() - t0
137
+ return out
138
+ }
139
+
140
+ /** the daemon's look between its passes: the bytes each live transcript grew by since the last look, searched for the
141
+ * refusal's words. A file seen the first time starts at its end; the pass reads the index, which misses nothing */
142
+ export class RefusalTail {
143
+ private offsets = new Map<string, number>()
144
+
145
+ /** whether one of these files grew with a refusal in it */
146
+ saw(paths: readonly string[]): boolean {
147
+ let hit = false
148
+ const keep = new Set(paths)
149
+ for (const p of [...this.offsets.keys()]) if (!keep.has(p)) this.offsets.delete(p)
150
+ for (const p of paths) {
151
+ let size: number
152
+ try {
153
+ size = statSync(p).size
154
+ } catch {
155
+ continue
156
+ }
157
+ const at = this.offsets.get(p)
158
+ this.offsets.set(p, size)
159
+ if (at === undefined || size <= at) continue
160
+ if (grewWith(p, Math.max(at, size - TAIL_MAX), size, CLASSIFIER_REFUSAL)) hit = true
161
+ }
162
+ return hit
163
+ }
164
+ }
165
+
166
+ /** at most this much of a file's growth is read in one look */
167
+ const TAIL_MAX = 4 * 1024 * 1024
168
+
169
+ function grewWith(path: string, from: number, to: number, words: string): boolean {
170
+ let fd: number | null = null
171
+ try {
172
+ fd = openSync(path, 'r')
173
+ const buf = Buffer.alloc(to - from)
174
+ readSync(fd, buf, 0, buf.length, from)
175
+ return buf.includes(words)
176
+ } catch {
177
+ return false
178
+ } finally {
179
+ if (fd !== null) closeSync(fd)
180
+ }
181
+ }
@@ -27,6 +27,16 @@ export interface SessionRecord {
27
27
 
28
28
  export const sessionsDir = (): string => process.env.SHIPKIT_SESSIONS_DIR ?? machinePath('agent-sessions')
29
29
 
30
+ /** a canonical store (review/item-db.ts canonicalStore: a worktree's is its checkout's) in a scratch place (a repo's
31
+ * `.shipkit/tmp/`, the OS temp, a scratchpad: throwawayPath) is nobody's thread home for the machine's own registry:
32
+ * no record names it, no house watch joins it. A worktree of a real repo in a scratch place is its checkout's store,
33
+ * heard. A registry in a scratch place (a test's) keeps the stores beside it, as the store itself does
34
+ * (scratchStoreRefusal) */
35
+ export function scratchStore(store: string): boolean {
36
+ const { throwawayPath } = require('../review/item-db.ts') as typeof import('../review/item-db.ts')
37
+ return throwawayPath(store) && !throwawayPath(`${sessionsDir()}/`)
38
+ }
39
+
30
40
  const fileOf = (session: string): string => join(sessionsDir(), `${session.replace(/[^\w-]/g, '_')}.json`)
31
41
 
32
42
  function readRecord(file: string): SessionRecord | null {
@@ -38,10 +48,6 @@ function readRecord(file: string): SessionRecord | null {
38
48
  }
39
49
  }
40
50
 
41
- /** a store under a repo's `.shipkit/tmp/`: a lane's experiment in the daily emptied scratch, nobody's thread home, so
42
- * no record names it and no house watch joins it */
43
- export const scratchStore = (store: string): boolean => /\/\.shipkit\/tmp\//.test(store)
44
-
45
51
  /** the session of this process acted on `store`: its record names the store and its process. Silent and cheap: it
46
52
  * writes only when something changed, and never fails the act that called it. A lane shares its session's ids, so
47
53
  * its act in its worktree names the store by its canonical folder (review/item-db.ts canonicalStore), never a second
@@ -50,9 +56,10 @@ export function noteSession(at: string, o: { env?: Record<string, string | undef
50
56
  const env = o.env ?? process.env
51
57
  const session = env.CLAUDE_CODE_SESSION_ID?.trim()
52
58
  const pid = Number(env.CLAUDE_PID)
53
- if (!session || !Number.isInteger(pid) || pid <= 0 || scratchStore(at)) return
59
+ if (!session || !Number.isInteger(pid) || pid <= 0) return
54
60
  try {
55
61
  const store = (require('../review/item-db.ts') as typeof import('../review/item-db.ts')).canonicalStore(at)
62
+ if (scratchStore(store)) return
56
63
  const file = fileOf(session)
57
64
  const known = readRecord(file)
58
65
  if (known && known.pid === pid && known.stores.includes(store)) return
@@ -16,8 +16,8 @@
16
16
  import { Database } from 'bun:sqlite'
17
17
  import { closeSync, openSync, readSync, readdirSync, realpathSync, statSync, watch } from 'fs'
18
18
  import { homedir } from 'os'
19
- import { basename, dirname, join } from 'path'
20
- import { MACHINE_DB_FILE, openMachineFile, storeHome } from '../core/machine-db.ts'
19
+ import { dirname, join } from 'path'
20
+ import { MACHINE_DB_FILE, machineDbPath, openMachineFile } from '../core/machine-db.ts'
21
21
  import { machinePath } from '../core/machine-layout.ts'
22
22
  import { type ConfigRoot, discoverConfigRoots } from '../reflect/prompt-corpus.ts'
23
23
  import { type TranscriptEvent, readTranscriptLine } from '../reflect/transcript.ts'
@@ -34,7 +34,7 @@ export const INDEX_VERSION = 17
34
34
  export function agentTimeDbPath(home = homedir()): string {
35
35
  const env = process.env[AGENT_TIME_DB_ENV]
36
36
  if (env != null && env !== '') return env
37
- return home === homedir() ? storeHome('agent time index') : machinePath(MACHINE_DB_FILE, home)
37
+ return home === homedir() ? machineDbPath() : machinePath(MACHINE_DB_FILE, home)
38
38
  }
39
39
 
40
40
  /** the cached answers of `sk time`, a folder of the machine's own */
@@ -82,6 +82,7 @@ create table if not exists time_calls (
82
82
  cmd_sum integer
83
83
  );
84
84
  create index if not exists time_calls_file on time_calls (file_id, start);
85
+ create unique index if not exists time_calls_id on time_calls (id);
85
86
  create table if not exists time_marks (
86
87
  file_id integer not null,
87
88
  at integer not null,
@@ -118,71 +119,20 @@ create table if not exists time_bg_ends (
118
119
  );
119
120
  `
120
121
 
121
- /** the index's tables, made where they are not: the fold makes them before it copies the old file's rows in */
122
- /** the index's tables and every index they need, made where they are not: the fold makes them before it copies the
123
- * old file's rows in, so no open builds an index over real rows */
124
- export const createIndexTables = (db: Database): void => void db.exec(`${SCHEMA}\n${UNIQUE}`)
125
-
126
- /** the unique index of a call's id, apart from SCHEMA: a file of before it may hold a call twice, so it comes after
127
- * their dedupe (migrate) */
128
- const UNIQUE = 'create unique index if not exists time_calls_id on time_calls (id)'
129
-
130
- /** the columns added after the first build, with their type: added in place, a row of a pruned transcript cannot be
131
- * read again */
132
- const ADDED: readonly [string, string][] = [
133
- ['approval', 'integer not null default 0'],
134
- ['perm', "text not null default ''"],
135
- ['read', 'integer not null default 0'],
136
- ['bg', 'integer not null default 0'],
137
- ['msg', "text not null default ''"],
138
- ['model', "text not null default ''"],
139
- ['ctx', 'integer not null default 0'],
140
- ['out', 'integer not null default 0'],
141
- ['why', "text not null default ''"],
142
- ['cmd_sum', 'integer'],
143
- ]
122
+ /** the index's tables and every index they need, made where they are not: a repair makes a table again with them */
123
+ export const createIndexTables = (db: Database): void => void db.exec(SCHEMA)
144
124
 
145
125
  export function openIndex(path = agentTimeDbPath()): Database {
146
126
  return openMachineFile(path, {
147
127
  store: 'agent time index',
148
128
  schema: (db) => {
149
- db.exec(SCHEMA)
150
- migrate(db)
129
+ createIndexTables(db)
130
+ const row = db.query("select value from time_meta where key = 'shape'").get() as { value: string } | null
131
+ if (row?.value !== RULES_VERSION) reshape(db)
151
132
  },
152
133
  })
153
134
  }
154
135
 
155
- /** columns added after the first build, added in place: the rows of pruned
156
- * transcripts cannot be read again, so a migration never drops a table */
157
- function migrate(db: Database): void {
158
- const missing = (): { cols: string[]; unique: boolean } => {
159
- const cols = (db.query('pragma table_info(time_calls)').all() as { name: string }[]).map((c) => c.name)
160
- return { cols: ADDED.filter(([c]) => !cols.includes(c)).map(([c]) => c), unique: db.query("select 1 from sqlite_master where type = 'index' and name = 'time_calls_id'").get() == null }
161
- }
162
- // read first with no lock: a file of today's shape (a fold makes it so) takes no write at its open. Else under the
163
- // write lock, read again: two first opens at once, the second finds the work done
164
- const m = missing()
165
- if (m.cols.length > 0 || m.unique)
166
- db.transaction(() => {
167
- const again = missing()
168
- for (const [c, sql] of ADDED) if (again.cols.includes(c)) db.exec(`alter table time_calls add column ${c} ${sql}`)
169
- // a tool use id is unique on the machine: a session copied into a second account (to resume it there)
170
- // holds the same calls, written once
171
- if (again.unique) {
172
- db.exec('drop index if exists time_calls_open')
173
- db.exec('delete from time_calls where rowid not in (select min(rowid) from time_calls group by id)')
174
- db.exec(UNIQUE)
175
- }
176
- }).immediate()
177
- if (db.query("select 1 from time_meta where key = 'aliases'").get() == null) {
178
- foldAliases(db)
179
- db.query("insert or replace into time_meta (key, value) values ('aliases', '1')").run()
180
- }
181
- const row = db.query("select value from time_meta where key = 'shape'").get() as { value: string } | null
182
- if (row?.value === RULES_VERSION) return
183
- reshape(db)
184
- }
185
-
186
136
  const realOf = (path: string): string => {
187
137
  try {
188
138
  return realpathSync(path)
@@ -191,54 +141,6 @@ const realOf = (path: string): string => {
191
141
  }
192
142
  }
193
143
 
194
- /** the neighbour a project folder is a link to, as a path beside it; null for a folder of its own, and for a link
195
- * to somewhere else (that folder has no other name here) */
196
- function neighbourOf(dir: string): string | null {
197
- try {
198
- const parent = realpathSync(dirname(dir))
199
- const real = realpathSync(dir)
200
- return real !== join(parent, basename(dir)) && dirname(real) === parent ? join(dirname(dir), basename(real)) : null
201
- } catch {
202
- return null
203
- }
204
- }
205
-
206
- /** the rows a lister read under a project folder that is a link to its neighbour (a renamed repo keeps its old
207
- * name as a link) go to the real folder: a call is kept once on the machine, so the linked name held calls its
208
- * real folder then missed, and showed as a repo of its own. Run once per index (migrate): the lister no longer
209
- * lists a linked name. Returns the file rows folded */
210
- export function foldAliases(db: Database): number {
211
- const rows = db.query('select id, path, project from time_files').all() as { id: number; path: string; project: string }[]
212
- const idOf = new Map(rows.map((r) => [r.path, r.id]))
213
- const targets = new Map<string, string | null>()
214
- let folded = 0
215
- db.transaction(() => {
216
- for (const r of rows) {
217
- const at = r.path.indexOf(`/${r.project}/`)
218
- if (at < 0) continue
219
- const dir = r.path.slice(0, at + 1 + r.project.length)
220
- if (!targets.has(dir)) targets.set(dir, neighbourOf(dir))
221
- const target = targets.get(dir)
222
- if (target == null) continue
223
- const path = target + r.path.slice(dir.length)
224
- const real = idOf.get(path)
225
- if (real == null) {
226
- db.query('update time_files set path = ?, project = ? where id = ?').run(path, basename(target), r.id)
227
- idOf.set(path, r.id)
228
- } else {
229
- // the real row holds the same marks and prompts (the same file): only what is kept once moves
230
- db.query('update time_calls set file_id = ? where file_id = ?').run(real, r.id)
231
- db.query('update time_hooks set file_id = ? where file_id = ?').run(real, r.id)
232
- db.query('delete from time_marks where file_id = ?').run(r.id)
233
- db.query('delete from time_prompts where file_id = ?').run(r.id)
234
- db.query('delete from time_files where id = ?').run(r.id)
235
- }
236
- folded++
237
- }
238
- })()
239
- return folded
240
- }
241
-
242
144
  /** the shape rules and the read rules, one stamp: either changing reshapes */
243
145
  const RULES_VERSION = `${SHAPE_VERSION}.${READ_VERSION}`
244
146
 
@@ -829,5 +731,3 @@ export function repoOfProject(project: string, home = homedir()): string {
829
731
  return bare.startsWith(`${devSlug}-`) ? bare.slice(devSlug.length + 1) : bare
830
732
  }
831
733
 
832
- export const fileLabel = (path: string): string => basename(path).replace(/\.jsonl$/, '')
833
-
@@ -4,9 +4,10 @@
4
4
  import { mutateLease, withMutateLease } from '../core/locked-write.ts'
5
5
  import { partyOf, type Message } from '../review/model.ts'
6
6
  import { appendMessage, readAll, storeDir } from '../review/store.ts'
7
- import { askStateOf, membersOf, orderedThreads, type Thread } from '../review/threads.ts'
7
+ import { membersOf, type Thread } from '../review/threads.ts'
8
8
  import { barOwnOf } from '../review/supersede.ts'
9
9
  import { askOfThread, isClosed } from './ask-store.ts'
10
+ import { askStateOf, orderedThreads } from '../review/thread-state.ts'
10
11
 
11
12
  /** the agent's confirms of an ask's thread whose words are « Done: » and a title the ask held, not yet the bar's own */
12
13
  function doneConfirmsOf(t: Thread): { home: string; m: Message }[] {
@@ -6,9 +6,10 @@
6
6
  import { mutateLease, withMutateLease } from '../core/locked-write.ts'
7
7
  import type { ReviewItem } from '../review/model.ts'
8
8
  import { appendMessage, readAll, storeDir } from '../review/store.ts'
9
- import { orderedThreads, type Thread } from '../review/threads.ts'
9
+ import { type Thread } from '../review/threads.ts'
10
10
  import { answerWords, carryAnswers, hisAnswers, type HisAnswer } from './ask-carry.ts'
11
11
  import { findAsk, isClosed, setAskState, type Ask } from './ask-store.ts'
12
+ import { orderedThreads } from '../review/thread-state.ts'
12
13
 
13
14
  export { answerWords, hisAnswers, type HisAnswer }
14
15
 
@@ -7,9 +7,10 @@ import { docChangeLine } from '../review/doc-model.ts'
7
7
  import { instructionsRefusal, parseInstructions } from '../review/instructions.ts'
8
8
  import { readAll, storeDir } from '../review/store.ts'
9
9
  import { currentInstructions } from '../review/supersede.ts'
10
- import { membersOf, orderedThreads } from '../review/threads.ts'
10
+ import { membersOf } from '../review/threads.ts'
11
11
  import type { DocHome } from '../review/unit.ts'
12
12
  import { findAsk, isClosed, saveAskText } from './ask-store.ts'
13
+ import { orderedThreads } from '../review/thread-state.ts'
13
14
 
14
15
  /** the open asks as one kind of document: their words in the database, his answers beside them */
15
16
  export function askDoc(root: string): DocHome<{ text: string; steps: string[] }> {
@@ -8,10 +8,11 @@ import { ASK_FILES_DIR } from '../core/layout.ts'
8
8
  import { mutateLease, withMutateLease } from '../core/locked-write.ts'
9
9
  import { askKindOf, type AskHead, type ReviewItem } from '../review/model.ts'
10
10
  import { appendMessage, openThread, readAll, storeDir, updateHead } from '../review/store.ts'
11
- import { askStateOf, asideUntil, membersOf, threadOfAddress, type Thread } from '../review/threads.ts'
11
+ import { membersOf, threadOfAddress, type Thread } from '../review/threads.ts'
12
12
  import { afterMs } from './ask-after.ts'
13
13
  import { askAddress, askOfThread, isClosed, parseWaits, postQuestions, questionsOf, type Ask, type AskStatus } from './ask-store.ts'
14
14
  import { realGit } from '../core/git.ts'
15
+ import { askStateOf, threadState } from '../review/thread-state.ts'
15
16
 
16
17
 
17
18
  /** one ask file as it reads: `rel` its path under the folder (`done/003-x.md`), `closedFrom` where its closed day came
@@ -193,7 +194,7 @@ async function migrateBody(root: string, o: { go: boolean; lane?: string; now?:
193
194
  if (o.go) appendMessage(store, h.id, { who: f.status === 'declined' ? 'owner' : who, askState: { state: f.status, why: f.why ?? `its record in git said ${f.status}${guessed(f)}` } }, { now: closeAt(t, f, now) })
194
195
  }
195
196
  const until = f.status === 'open' && f.after != null ? afterMs(f.after) : null
196
- if (until != null && until > now.getTime() && asideUntil(t, now) === null) {
197
+ if (until != null && until > now.getTime() && (threadState(t, now).aside?.until ?? null) === null) {
197
198
  what.push(`set aside until ${f.after}`)
198
199
  if (o.go) appendMessage(store, h.id, { who, snooze: { until: new Date(until).toISOString() } }, { now })
199
200
  }
@@ -10,12 +10,13 @@
10
10
  import { mutateLease, withMutateLease } from '../core/locked-write.ts'
11
11
  import { partyOf, type AskHead, type Message } from '../review/model.ts'
12
12
  import { appendMessage, readAll, storeDir } from '../review/store.ts'
13
- import { membersOf, orderedThreads, type Thread } from '../review/threads.ts'
13
+ import { membersOf, type Thread } from '../review/threads.ts'
14
14
  import { currentInstructions, replacersOf } from '../review/supersede.ts'
15
15
  import { answersTo, askOpen } from '../review/answer-kinds.ts'
16
16
  import { parseInstructions } from '../review/instructions.ts'
17
17
  import { askOfThread, fieldKey, instructionsMessage, isClosed, postFields, stepKey, stepsAskOf, tickedTitles } from './ask-store.ts'
18
18
  import { refoldWords, type Loose, type Refold } from './ask-words-fold.ts'
19
+ import { orderedThreads } from '../review/thread-state.ts'
19
20
 
20
21
  /** the old checklists of an ask's thread that its steps were: an agent's « The steps », not superseded */
21
22
  const oldChecklists = (t: Thread): Message[] => {
@@ -8,7 +8,7 @@ import { SECRET_NAME } from '../secrets/name.ts'
8
8
  import { answersTo, kindOfAsk, ticksOf } from '../review/answer-kinds.ts'
9
9
  import { askKindOf, ASK_KINDS, CLOSED_ASK_STATES, isAskItem, isClosedAskState, partyOf, type AskHead, type AskKind, type AskState, type AskWait, type ClosedAskState, type Message, type MessageAsk, type ReviewItem } from '../review/model.ts'
10
10
  import { addMessage, appendMessage, hasStore, openThread, postAsk, readAll, storeDir, updateHead } from '../review/store.ts'
11
- import { askStateOf, asideUntil, membersOf, openAsksOf, orderedThreads, type Thread } from '../review/threads.ts'
11
+ import { membersOf, type Thread } from '../review/threads.ts'
12
12
  import { currentInstructions, foldsOf, replacersOf } from '../review/supersede.ts'
13
13
  import { instructionsRefusal, parseInstructions, stepSections } from '../review/instructions.ts'
14
14
  import { AFTER_FORMS, afterMs, afterWords } from './ask-after.ts'
@@ -16,6 +16,7 @@ import { answerWords, carryAnswers, hisAnswers, stepKey, type HisAnswer } from '
16
16
  import { askedAgain, nameSince } from './ask-since.ts'
17
17
  import { slugOf } from '../core/slug.ts'
18
18
  import { dayStamp } from '../core/day-stamp.ts'
19
+ import { askStateOf, orderedThreads, threadState } from '../review/thread-state.ts'
19
20
 
20
21
  export type { AskWait } from '../review/model.ts'
21
22
 
@@ -117,7 +118,7 @@ export function askOfThread(t: Thread, now = new Date()): Ask | null {
117
118
  const f: AskHead = newer ? { ...newer.instructions.ask, created: h.ask.created, ...(h.ask.pinged ? { pinged: h.ask.pinged } : {}) } : h.ask
118
119
  const s = stateOf(t)
119
120
  const body = newer ? (newer.text ?? '') : (h.what ?? '')
120
- const until = s.status === 'open' ? asideUntil(t, now) : null
121
+ const until = s.status === 'open' ? (threadState(t, now).aside?.until ?? null) : null
121
122
  const secrets = f.secrets ?? []
122
123
  return {
123
124
  id: on.slice('ask:'.length),
@@ -648,7 +649,7 @@ export async function followAskThread(root: string, id: string, o: CloseOpts = {
648
649
  const t = orderedThreads(items).find((x) => membersOf(x).some((y) => y.item.id === id))
649
650
  if (t == null) return null
650
651
  const a = askOfThread(t)
651
- if (a == null || isClosed(a.status) || openAsksOf(t).length > 0) return null
652
+ if (a == null || isClosed(a.status) || threadState(t).waitsOwner.some((w) => w.what === 'question' || w.what === 'change' || w.what === 'steps')) return null
652
653
  const gone = replacersOf(membersOf(t))
653
654
  const asks = membersOf(t).flatMap((y) => y.thread.filter((m) => m.ask !== undefined && !gone.has(m.id)).map((m) => ({ m, thread: y.thread })))
654
655
  if (asks.length === 0) return null
package/src/check.ts CHANGED
@@ -142,6 +142,8 @@ export type CheckDef = {
142
142
 
143
143
  /** the longest description a row can show whole */
144
144
  export const DESCRIPTION_MAX = 90
145
+ /** the shortest one that states anything a reader can use */
146
+ export const DESCRIPTION_MIN = 15
145
147
 
146
148
  /** what is wrong with a description, or null when it states an invariant
147
149
  * the way every surface expects: one line, short, the fact that must hold.
@@ -151,6 +153,7 @@ export function descriptionProblem(description: unknown): string | null {
151
153
  return 'description is required: ONE line stating what must be true'
152
154
  const d = description.trim()
153
155
  if (/[\r\n]/.test(d)) return 'description must be ONE line'
156
+ if (d.length < DESCRIPTION_MIN) return `description is ${d.length} characters, too short to state anything: ${DESCRIPTION_MIN} at least`
154
157
  if (d.length > DESCRIPTION_MAX) return `description is ${d.length} characters, the limit is ${DESCRIPTION_MAX}: state only what must be true`
155
158
  if (/^this checks\b/i.test(d)) return `description states what must be true, with no 'this checks' opener`
156
159
  if (/\b(red|yellow|green|a warning|warn)( one)? means\b|\ba red one\b/i.test(d))
@@ -269,49 +272,6 @@ export type TaskDef = {
269
272
  * add it here. */
270
273
  export const TASK_DEF_KEYS = ['id', 'cmd', 'logic', 'deps', 'env', 'cwd', 'group', 'optIn', 'timeoutMs', 'inputs', 'ttl', 'never'] as const
271
274
 
272
- // ── the legacy rule shape, for the compatibility window ──────────────────
273
- // A repo still registering through `repo.config.ts rules: []` writes this
274
- // one. It is read as a check whose body is `lint`, and it dies with that key
275
- // once `shipkit fleet` shows no repo below 0.40.
276
-
277
- export type RuleEnv = CheckEnv
278
-
279
- export type Rule = {
280
- /** stable PREFIX + 3 digits, never reused or renumbered. `SK###` is
281
- * reserved for the toolkit, so a repo picks its own (`RV###`). A check
282
- * FILE takes its id from its name and may use plain words instead. */
283
- id: string
284
- /** display name, stable: the row in STATUS.md, the TUI, the suite cache */
285
- title: string
286
- /** can this stop you? REQUIRED, no default, exactly as a check declares it */
287
- blocking: boolean
288
- /** wiki page owning the invariant — the body runner appends
289
- * `docsBase + owner` as the fix: pointer whenever a failing lint
290
- * attached none. A check file defaults this to its own path. */
291
- owner: string
292
- /** WORLD population: clean-pass cache duration for a rule that probes the
293
- * network, as in '24h'. A skip, a WARN and a FAIL are never cached. */
294
- ttl?: string
295
- /** CONTENT population: the repo-relative paths this rule reads. Neither
296
- * `inputs` nor `ttl` means never cached, which is the safe default, and
297
- * declaring both is a registration failure. */
298
- inputs?: string[]
299
- /** repo-relative entry file(s) of this rule's OWN code, so fixing a bug in
300
- * the rule moves its key. A check FILE needs none: its own path is its
301
- * closure, which is the field this shape exists without. */
302
- code?: string[]
303
- /** a DECIDED never-cacheable, with the reason: it reads git history, a
304
- * path outside the repo, or the wall clock, so no key can describe it. */
305
- never?: string
306
- /** cache-identity contribution for a TTL'd rule whose verdict depends on
307
- * config: a changed key busts the answer instead of serving it cached */
308
- cacheKey?: (env: RuleEnv) => string
309
- /** the invariant itself, the legacy spelling of a check's `run` */
310
- lint: (t: CheckCtx, env: RuleEnv) => void | Promise<void>
311
- /** idempotent auto-repair, never interactive. `check --fix` applies it */
312
- fix?: (env: RuleEnv) => FixResult | Promise<FixResult>
313
- }
314
-
315
275
  // ── running a body, and what every line it prints carries ────────────────
316
276
 
317
277
  /** the config part of a check's cache identity: its declared key, and the