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
@@ -0,0 +1,60 @@
1
+ // a TS source with its strings, comments, template text and regex literals blanked, so a scanner that matches code
2
+ // by text finds code only, at the same offsets as the original.
3
+
4
+ /** the source with every string, comment, template text and regex literal
5
+ * blanked to spaces, newlines kept, so offsets line up with the original */
6
+ export function maskSource(src: string): string {
7
+ const out = src.split('')
8
+ const blank = (from: number, to: number): void => { for (let k = from; k < to; k++) if (out[k] !== '\n') out[k] = ' ' }
9
+ let i = 0
10
+ // one entry per open template: the brace depth of its current `${`
11
+ const tpl: number[] = []
12
+ let last = ''
13
+ const regexOk = (): boolean => last === '' || '(,=:[!&|?{};+-*%<>~^'.includes(last)
14
+ const readTemplateText = (): void => {
15
+ // at a character inside template text: blank until `${` or the closing backtick
16
+ const start = i
17
+ while (i < src.length && src[i] !== '`' && !(src[i] === '$' && src[i + 1] === '{')) i += src[i] === '\\' ? 2 : 1
18
+ blank(start, i)
19
+ if (src[i] === '`') { i++; tpl.pop(); last = 'x' } else { i += 2; tpl[tpl.length - 1] = 0; last = '{' }
20
+ }
21
+ while (i < src.length) {
22
+ const ch = src[i]!
23
+ const next = src[i + 1]
24
+ if (ch === '/' && next === '/') { const s = i; while (i < src.length && src[i] !== '\n') i++; blank(s, i); continue }
25
+ if (ch === '/' && next === '*') { const s = i; const e = src.indexOf('*/', i + 2); i = e < 0 ? src.length : e + 2; blank(s, i); continue }
26
+ if (ch === "'" || ch === '"') {
27
+ const s = i
28
+ i++
29
+ while (i < src.length && src[i] !== ch && src[i] !== '\n') i += src[i] === '\\' ? 2 : 1
30
+ i++
31
+ blank(s + 1, i - 1)
32
+ last = 'x'
33
+ continue
34
+ }
35
+ if (ch === '`') { tpl.push(-1); i++; readTemplateText(); continue }
36
+ if (tpl.length > 0 && tpl[tpl.length - 1]! >= 0) {
37
+ if (ch === '{') tpl[tpl.length - 1]!++
38
+ if (ch === '}') {
39
+ if (tpl[tpl.length - 1] === 0) { tpl[tpl.length - 1] = -1; i++; readTemplateText(); continue }
40
+ tpl[tpl.length - 1]!--
41
+ }
42
+ }
43
+ if (ch === '/' && regexOk()) {
44
+ const s = i
45
+ let j = i + 1
46
+ let inClass = false
47
+ while (j < src.length && src[j] !== '\n') {
48
+ if (src[j] === '\\') { j += 2; continue }
49
+ if (src[j] === '[') inClass = true
50
+ else if (src[j] === ']') inClass = false
51
+ else if (src[j] === '/' && !inClass) break
52
+ j++
53
+ }
54
+ if (src[j] === '/') { j++; while (/[a-z]/.test(src[j] ?? '')) j++; blank(s + 1, j - 1); i = j; last = 'x'; continue }
55
+ }
56
+ if (!/\s/.test(ch)) last = ch
57
+ i++
58
+ }
59
+ return out.join('')
60
+ }
@@ -3,8 +3,10 @@
3
3
  // the log past its cap (capLog), so the disk never fills from it. A restart in place starts it again from zero.
4
4
  // Beside it, the budget: a look every 30 s, a WARN at most every 10 minutes while the footprint (core/footprint.ts; the
5
5
  // resident size where none is read) is over it, and the last pass kept in the machine db row MEMORY_OVER, which the
6
- // house check daemon-memory turns red for an hour
7
- import { footprint } from './footprint.ts'
6
+ // house check daemon-memory turns red for an hour. The footprint counts every thread, the read thread too; the heap is
7
+ // the loop's thread alone. The resident size ps shows counts the pages bun's allocator freed and keeps mapped, which the
8
+ // footprint does not (4.7 GB resident for a footprint of 822 MB)
9
+ import { footprintAndPeak } from './footprint.ts'
8
10
  import { machineSet } from './machine-db.ts'
9
11
  import { bytesWords } from './words.ts'
10
12
 
@@ -19,8 +21,11 @@ export const BUDGET_EVERY_MS = 30_000
19
21
  /** the machine db row of the daemon's last pass over its budget */
20
22
  export const MEMORY_OVER = 'daemon-memory-over'
21
23
 
22
- /** `footprint` absent where the system gives none: the budget then reads the resident size */
23
- export type Memory = { rss: number; heap: number; footprint?: number }
24
+ /** `footprint` and `peak` (the highest footprint since the start) absent where the system gives none: the budget then
25
+ * reads the resident size */
26
+ export type Memory = { rss: number; heap: number; footprint?: number; peak?: number }
27
+ const held = (m: Memory): number => m.footprint ?? m.rss
28
+ const heldWords = (m: Memory): string => (m.footprint == null ? `${bytesWords(m.rss)} resident` : `${bytesWords(m.footprint)} footprint${m.peak == null ? '' : ` (peak ${bytesWords(m.peak)})`}`)
24
29
  /** a pass over the budget, as the row keeps it: `held` is what the budget measured */
25
30
  export type MemoryOver = { at: number; held: number; rss: number; heap: number; budget: number; boot: boolean; pid: number }
26
31
 
@@ -36,8 +41,8 @@ export class MemoryWatch {
36
41
  constructor(
37
42
  private read: () => Memory = () => {
38
43
  const m = process.memoryUsage()
39
- const f = footprint()
40
- return { rss: m.rss, heap: m.heapUsed, ...(f == null ? {} : { footprint: f }) }
44
+ const f = footprintAndPeak()
45
+ return { rss: m.rss, heap: m.heapUsed, ...(f == null ? {} : { footprint: f.now, peak: f.peak }) }
41
46
  },
42
47
  private now: () => number = Date.now,
43
48
  private record: (over: MemoryOver) => void = (over) => void machineSet(MEMORY_OVER, over),
@@ -46,13 +51,13 @@ export class MemoryWatch {
46
51
  this.started = now()
47
52
  }
48
53
 
49
- /** one look: the line when the resident size moved by MEMORY_STEP since the last line (or the start), else null */
54
+ /** one look: the line when the footprint moved by MEMORY_STEP since the last line (or the start), else null */
50
55
  look(): string | null {
51
56
  const m = this.read()
52
57
  const base = this.said ?? this.from
53
- if (Math.abs(m.rss - base.rss) < base.rss * MEMORY_STEP) return null
58
+ if (Math.abs(held(m) - held(base)) < held(base) * MEMORY_STEP) return null
54
59
  this.said = m
55
- return `memory: ${bytesWords(m.rss)} resident, ${bytesWords(m.heap)} heap (${m.rss >= base.rss ? 'up' : 'down'} from ${bytesWords(base.rss)}, ${bytesWords(this.from.rss)} at start)`
60
+ return `memory: ${heldWords(m)}, ${bytesWords(m.heap)} main heap (${held(m) >= held(base) ? 'up' : 'down'} from ${bytesWords(held(base))}, ${bytesWords(held(this.from))} at start)`
56
61
  }
57
62
 
58
63
  /** one look at the budget: each pass over it is recorded; the line, at most once per MEMORY_EVERY_MS, else null */
@@ -61,13 +66,11 @@ export class MemoryWatch {
61
66
  const t = this.now()
62
67
  const since = t - this.started
63
68
  const budget = budgetAt(since)
64
- const held = m.footprint ?? m.rss
65
- if (held <= budget) return null
66
- this.record({ at: t, held, rss: m.rss, heap: m.heap, budget, boot: since < BOOT_MS, pid: process.pid })
69
+ if (held(m) <= budget) return null
70
+ this.record({ at: t, held: held(m), rss: m.rss, heap: m.heap, budget, boot: since < BOOT_MS, pid: process.pid })
67
71
  if (t - this.warnedAt < MEMORY_EVERY_MS) return null
68
72
  this.warnedAt = t
69
- const what = m.footprint == null ? `${bytesWords(held)} resident` : `${bytesWords(held)} (its footprint; ${bytesWords(m.rss)} resident)`
70
- return `the daemon holds ${what}, ${bytesWords(m.heap)} heap, over its budget of ${bytesWords(budget)}${since < BOOT_MS ? ' while it boots' : ''}`
73
+ return `the daemon holds ${heldWords(m)}, ${bytesWords(m.heap)} main heap, over its budget of ${bytesWords(budget)}${since < BOOT_MS ? ' while it boots' : ''}`
71
74
  }
72
75
 
73
76
  /** looks on a timer and says each move and each pass over the budget; returns its stop */
@@ -32,12 +32,9 @@ import { LIB_VERSION } from './lib-version.ts'
32
32
  import { machineName } from '../home/machine-host.ts'
33
33
  import { dayStamp } from './day-stamp.ts'
34
34
 
35
- /** the block before the per Mac markers */
36
- const LEGACY_BEGIN = '<!-- >>> shipkit local-projects — machine-written, edit outside the markers -->'
37
- const LEGACY_END = '<!-- <<< shipkit local-projects -->'
38
35
  export const blockBegin = (machine: string): string => `<!-- >>> shipkit local-projects on ${machine} — machine-written, edit outside the markers -->`
39
36
  export const blockEnd = (machine: string): string => `<!-- <<< shipkit local-projects on ${machine} -->`
40
- const ANY_END = /^<!-- <<< shipkit local-projects( on .+)? -->$/
37
+ const ANY_END = /^<!-- <<< shipkit local-projects on .+ -->$/
41
38
  const STALE_DAYS = 7
42
39
  /** the longest the page waits for a changed row: one commit a day at most */
43
40
  export const LAND_GAP_MS = 24 * 60 * 60 * 1000
@@ -121,36 +118,13 @@ function blockAt(lines: string[], begin: string, end: string): [number, number]
121
118
 
122
119
  const rowsIn = (lines: string[], [b, e]: [number, number]): Row[] => lines.slice(b + 1, e).map(parseRow).filter((row): row is Row => row != null)
123
120
 
124
- /** the page once this Mac's filed rows land in its own block; null when its markers are missing or out of order.
125
- * The legacy block keeps the rows of another Mac and goes once it holds none */
126
- export function landPage(text: string, filed: Row[], machine: string, home: string): string | null {
127
- let lines = text.split('\n')
128
- const legacy = blockAt(lines, LEGACY_BEGIN, LEGACY_END)
129
- if (legacy === 'broken') return null
130
- let carried: Row[] = []
131
- if (legacy != null) {
132
- const [b, e] = legacy
133
- const rows = rowsIn(lines, legacy)
134
- // this Mac's: under its home, or a repo it filed (a checkout on another volume)
135
- const filedHere = new Set(filed.map((f) => f.root))
136
- const mine = (r: Row): boolean => r.root === home || r.root.startsWith(`${home}/`) || filedHere.has(r.root)
137
- const kept = rows.filter((r) => !mine(r))
138
- if (kept.length > 0) {
139
- carried = rows.filter(mine)
140
- lines = [...lines.slice(0, b + 1), ...kept.map(rowLine), ...lines.slice(e)]
141
- } else if (blockAt(lines, blockBegin(machine), blockEnd(machine)) == null) {
142
- // every row is this Mac's: the block becomes its own, in place
143
- lines = [...lines.slice(0, b), blockBegin(machine), ...lines.slice(b + 1, e), blockEnd(machine), ...lines.slice(e + 1)]
144
- } else {
145
- carried = rows
146
- lines = [...lines.slice(0, b), ...lines.slice(e + 1)]
147
- if (lines[b - 1] === '' && lines[b] === '') lines.splice(b, 1)
148
- }
149
- }
121
+ /** the page once this Mac's filed rows land in its own block; null when its markers are missing or out of order */
122
+ export function landPage(text: string, filed: Row[], machine: string): string | null {
123
+ const lines = text.split('\n')
150
124
  const own = blockAt(lines, blockBegin(machine), blockEnd(machine))
151
125
  if (own === 'broken') return null
152
126
  if (own != null) {
153
- const block = mergeRows([...rowsIn(lines, own), ...carried], filed).map(rowLine)
127
+ const block = mergeRows(rowsIn(lines, own), filed).map(rowLine)
154
128
  return [...lines.slice(0, own[0] + 1), ...block, ...lines.slice(own[1])].join('\n')
155
129
  }
156
130
  // no block of this Mac yet: a new one right after the last block of any Mac, every line of it a marker or a row,
@@ -158,15 +132,14 @@ export function landPage(text: string, filed: Row[], machine: string, home: stri
158
132
  const ends = lines.flatMap((l, i) => (ANY_END.test(l) ? [i] : []))
159
133
  if (ends.length === 0) return null
160
134
  const at = ends[ends.length - 1]! + 1
161
- return [...lines.slice(0, at), blockBegin(machine), ...mergeRows(carried, filed).map(rowLine), blockEnd(machine), ...lines.slice(at)].join('\n')
135
+ return [...lines.slice(0, at), blockBegin(machine), ...mergeRows([], filed).map(rowLine), blockEnd(machine), ...lines.slice(at)].join('\n')
162
136
  }
163
137
 
164
138
  /** render every filed row into its page and land each changed page as one
165
139
  * commit, at most once per LAND_GAP_MS. Returns what to print */
166
- export function landMotherhome(o: { now?: number; gapMs?: number; machine?: string; home?: string } = {}): string[] {
140
+ export function landMotherhome(o: { now?: number; gapMs?: number; machine?: string } = {}): string[] {
167
141
  const now = o.now ?? Date.now()
168
142
  const machine = o.machine ?? machineName()
169
- const home = o.home ?? homedir()
170
143
  const notes: string[] = []
171
144
  const filed = machineList<Filed>(ROW)
172
145
  for (const f of filed) if (!existsSync(f.value.root)) machineDelete(f.name)
@@ -179,7 +152,7 @@ export function landMotherhome(o: { now?: number; gapMs?: number; machine?: stri
179
152
  if (last != null && now - last < (o.gapMs ?? LAND_GAP_MS)) continue
180
153
  const r = withFileLock(page, (): boolean => {
181
154
  const text = readFileSync(page, 'utf8')
182
- const next = landPage(text, rows, machine, home)
155
+ const next = landPage(text, rows, machine)
183
156
  if (next == null) { notes.push(`WARN motherhome: markers missing or out of order in ${page}, rows not written`); return false }
184
157
  if (next === text) return false
185
158
  atomicWrite(page, next)
@@ -151,9 +151,6 @@ const STASH_READS = new Set(['list', 'show'])
151
151
  const STASH_WRITES = ['push', 'pop', 'apply', 'drop', 'clear', 'save', 'store', 'create', 'branch'] as const
152
152
  export const GIT_STASH_RULES: readonly string[] = [`Bash(${GIT_STASH_HEAD})`, `Bash(${GIT_STASH_HEAD} -*)`, ...STASH_WRITES.map((w) => `Bash(${GIT_STASH_HEAD} ${w}*)`)]
153
153
 
154
- /** the blanket row older repos carry: it blocks the reads too, SK013 replaces it with GIT_STASH_RULES */
155
- export const LEGACY_STASH_RULE = `Bash(${GIT_STASH_HEAD}*)`
156
-
157
154
  /** git's global options that take their value as the NEXT word */
158
155
  const GIT_VALUE_OPTS = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--exec-path'])
159
156
 
@@ -0,0 +1,8 @@
1
+ // a shipkit command on another place of the house over ssh: from its house checkout at the same place under its home,
2
+ // the tools' folders named, since an ssh command shell reads no rc file
3
+
4
+ /** a word quoted for the peer's sh */
5
+ export const shq = (s: string): string => `'${s.replaceAll("'", `'\\''`)}'`
6
+
7
+ /** the line the peer's shell runs for `sk <args>`, args already quoted */
8
+ export const peerSk = (houseRel: string, args: string): string => `cd ~/${houseRel} && PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH" sk ${args}`
@@ -93,12 +93,3 @@ export async function importFresh(path: string): Promise<unknown> {
93
93
  try { real = realpathSync(path) } catch {}
94
94
  return ((await import(`${real}?v=${stamp}`)) as { default?: unknown }).default
95
95
  }
96
-
97
- /** every `*.check.ts` file under a repo root, check files and legacy
98
- * scripts alike, by the same walk discovery takes, without importing one.
99
- * Sorted. */
100
- export function repoCheckFiles(root: string): string[] {
101
- const out: string[] = []
102
- walkKept(root, out, SUFFIX, undefined, prunedDirs(root))
103
- return out.sort()
104
- }
@@ -18,7 +18,7 @@ import { GONE, GONE_KEEP_MS, goneUse, sweepGone } from '../review/gone.ts'
18
18
  import { compactDb, dbPath, shipkitRoot } from '../ledger/db.ts'
19
19
  import { SCAN_INDEX_KEEP_MS, sweepScanIndexes } from '../ledger/git-scan.ts'
20
20
  import { KEEP_MS as RECORD_KEEP_MS, MAX_ROWS, recordUse, sweepRuns } from '../ledger/run-log.ts'
21
- import { answersDb, answersUse, importLegacyStore, KEEP_MS as ANSWERS_KEEP_MS, legacyStoreDir, MAX_ANSWERS, slimAnswers, sweepAnswers } from '../ledger/store.ts'
21
+ import { answersDb, answersUse, KEEP_MS as ANSWERS_KEEP_MS, MAX_ANSWERS, slimAnswers, sweepAnswers } from '../ledger/store.ts'
22
22
  import { ageWords, bytesWords } from './words.ts'
23
23
 
24
24
  export type Cap = {
@@ -112,14 +112,6 @@ export function repoStores(root: string): Store[] {
112
112
  },
113
113
  sweep: (now) => { sweepAnswers(answersDb(root), now) },
114
114
  },
115
- {
116
- // the json store this table replaced: read once, then gone
117
- id: 'json answers',
118
- where: legacyStoreDir(root),
119
- cap: { maxCount: 0 },
120
- measure: () => walkUse(legacyStoreDir(root)),
121
- sweep: async (now) => { await importLegacyStore(root, now) },
122
- },
123
115
  {
124
116
  id: 'run record',
125
117
  where: `${dbPath(root)} (runs, invocations, suites)`,
@@ -4,6 +4,8 @@
4
4
  export const RETIRED_CHECK_IDS: Readonly<Record<string, string>> = {
5
5
  SK009: 'the AI attribution guard is gone: no rule polices commit trailers',
6
6
  SK014: 'the STE prose rule is gone: no rule polices prose style',
7
+ SK016: 'the legacy check shapes are gone: defineRepo refuses each removed key by name, and discovery fails a repo `*.check.ts` with the unit file to write',
7
8
  SK021: "the gh login is a machine fact: the house repo's github-login check runs src/core/gh-login.ts",
8
9
  SK023: "the store caps are the machine daemon's health: the house repo's stores-under-cap check",
10
+ SK029: 'the implicit check file keys are gone: check() refuses each retired key at load, and defineRepo refuses every old way to turn a check off',
9
11
  }
@@ -125,7 +125,7 @@ function collect(script: string, c: Ctx, depth: number): void {
125
125
  }
126
126
  }
127
127
 
128
- const shipkitSockets = (home: string): string[] => [`${home}/.shipkit/home/terminals.sock`, `${home}/.shipkit/terminals.sock`, `${home}/.config/shipkit/home/terminals.sock`]
128
+ const shipkitSockets = (home: string): string[] => [`${home}/.shipkit/home/terminals.sock`, `${home}/.shipkit/terminals.sock`]
129
129
 
130
130
  /** true for shipkit's socket, and for a `terminals.sock` nothing proves to be another: a relative path, an unknown variable */
131
131
  function isShipkitSocket(path: string, env: KillEnv): boolean {
@@ -1,5 +1,5 @@
1
- // one recursive watch of a folder for the whole process, its events handed to every listener (the save watch, the
2
- // backup's watch): a second watch of the same tree doubles what fseventsd delivers. A folder of UNWATCHED is never
1
+ // one recursive watch of a folder for the whole process, its events handed to every listener (the save watch): a
2
+ // second watch of the same tree doubles what fseventsd delivers. A folder of UNWATCHED is never
3
3
  // watched. Bun watches any folder through a recursive FSEvents stream, even with `recursive: false` (a write deep
4
4
  // down is heard as its top entry), so a folder above an unwatched one is never watched itself: each of its folders
5
5
  // gets its own watch, each of its files a watch of the file, and a listing every LIST_MS finds what was added or
package/src/core/when.ts CHANGED
@@ -3,12 +3,6 @@
3
3
  // its own declaration (core/runs.ts); a repo says of a whole check it does
4
4
  // not own only that it does not run here, and why. An off row runs in
5
5
  // no context, and every surface shows it with its reason.
6
- //
7
- // Four retired spellings still read as off while SK029 ports them: a `when`
8
- // entry `'off:<why>'` (defineRepo refuses the other words), `ruleExempt`,
9
- // `hooks.disable` and a floor slot `defaults: { <slot>: false }`. The last two
10
- // never carried a reason, so they read with one that says so. They die once
11
- // `shipkit fleet` shows no repo carrying them.
12
6
  import type { CheckRow } from '../gate/gate-checks.ts'
13
7
  import type { ResolvedRuns } from './runs.ts'
14
8
  import type { RepoConfig } from '../repo-config.ts'
@@ -16,55 +10,23 @@ import type { RepoConfig } from '../repo-config.ts'
16
10
  /** the coarse word a resolved row reads as on the check page */
17
11
  export type WhenAt = 'always' | 'release' | 'health' | 'commit' | 'off'
18
12
 
19
- /** which declaration is answering: the repo's `off`, one of its two retired
20
- * spellings, the check file, the `defaults` block, or a derived row */
21
- export type WhenSource = 'off' | 'when' | 'ruleExempt' | 'hooks.disable' | 'check-file' | 'defaults' | 'default'
13
+ /** which declaration is answering: the repo's `off`, the check file, or a derived row */
14
+ export type WhenSource = 'off' | 'check-file' | 'default'
22
15
 
23
16
  export type WhenDecl = { at: WhenAt; reason: string | null; source: WhenSource }
24
17
 
25
- /** the words a retired `when` value used */
26
- const WORDS: Record<string, WhenAt> = { always: 'always', release: 'release', health: 'health' }
27
-
28
- /** one retired `when` value, or the problem with it. defineRepo refuses every
29
- * word but `off:<why>`, which reads as `off` */
30
- export function parseWhen(raw: unknown): WhenDecl | string {
31
- if (typeof raw !== 'string') return `must be a string: off:<reason>`
32
- const v = raw.trim()
33
- if (v === 'off' || v.startsWith('off:')) {
34
- const reason = v.slice(4).trim()
35
- if (reason === '') return `off needs a reason ('off:<why this repo turns it off>') — a check nobody can explain is a silenced gate`
36
- return { at: 'off', reason, source: 'when' }
37
- }
38
- const at = WORDS[v]
39
- if (at == null) return `'${v}' is not a when value (off:<reason>)`
40
- return { at, reason: null, source: 'when' }
41
- }
42
-
43
- /** the repo turned this check off, with why and where it said so, or null */
44
- export type RepoOff = { reason: string; source: 'off' | 'when' | 'ruleExempt' | 'hooks.disable' | 'defaults' }
45
-
46
- /** the reason a spelling that never carried one reads with, and the one the
47
- * SK029 port writes when no comment beside the entry says more. A machine
48
- * cannot invent a reason, so every surface shows the gap */
49
- export const legacyOffReason = (source: 'hooks.disable' | 'defaults', id: string): string =>
50
- source === 'defaults' ? `was defaults: { ${/^[A-Za-z_$][\w$]*$/.test(id) ? id : `'${id}'`}: false }, no reason recorded` : `was hooks.disable: ['${id}'], no reason recorded`
18
+ /** the repo turned this check off, with why */
19
+ export type RepoOff = { reason: string; source: 'off' }
51
20
 
52
21
  /** the keys `repoOff` reads, so a caller holding part of a config can ask */
53
- export type OffKeys = Pick<RepoConfig, 'off' | 'when' | 'ruleExempt'> & { hooks?: { disable?: readonly string[] }; defaults?: Record<string, unknown> }
22
+ export type OffKeys = Pick<RepoConfig, 'off'>
54
23
 
55
24
  /** THE one answer to "is this id off here", for a check, a floor slot and a
56
25
  * commit gate alike. A floor slot that is off is off everywhere: no task, no
57
26
  * routed script, no deny rule */
58
27
  export function repoOff(c: OffKeys, id: string): RepoOff | null {
59
28
  const own = c.off?.[id]
60
- if (own != null) return { reason: own, source: 'off' }
61
- const w = c.when?.[id] == null ? null : parseWhen(c.when[id])
62
- if (w != null && typeof w !== 'string' && w.at === 'off') return { reason: w.reason ?? '', source: 'when' }
63
- const exempt = c.ruleExempt?.[id]
64
- if (exempt != null) return { reason: exempt, source: 'ruleExempt' }
65
- if (c.hooks?.disable?.includes(id) === true) return { reason: legacyOffReason('hooks.disable', id), source: 'hooks.disable' }
66
- if (c.defaults?.[id] === false) return { reason: legacyOffReason('defaults', id), source: 'defaults' }
67
- return null
29
+ return own == null ? null : { reason: own, source: 'off' }
68
30
  }
69
31
 
70
32
  /** a resolved row the repo turned off: it runs in no context */
@@ -84,5 +46,5 @@ export function whenSummary(r: ResolvedRuns, off: RepoOff | null, fromFile: bool
84
46
  * check is discovered on disk, so this is where the rest is caught, loud */
85
47
  export function unknownOffIds(rows: CheckRow[], c: RepoConfig): string[] {
86
48
  const known = new Set(rows.map((r) => r.decl.id))
87
- return [...new Set([...Object.keys(c.off ?? {}), ...Object.keys(c.when ?? {})])].filter((id) => !known.has(id))
49
+ return Object.keys(c.off ?? {}).filter((id) => !known.has(id))
88
50
  }
@@ -0,0 +1,150 @@
1
+ // THE ADMISSION GATE'S READINGS (the judge: core/admission.ts): one ps of the
2
+ // machine, the session files of Claude Code, the load, the memo of a wait that
3
+ // reached its bound, and the two entries: every sk command before it runs
4
+ // (cli.ts admitLine), and an asked gate before its first heavy check that misses
5
+ // the cache (check-runner.ts, through runCi's `admit`). A release never waits:
6
+ // sk bump runs its gate in its own process, with no `admit`.
7
+ //
8
+ // the one constraint a reader breaks first: the calm path is os.loadavg alone,
9
+ // with no spawn and no file read, since every sk command passes here: the rest
10
+ // of what it reads loads by await import, past that line.
11
+ import { readFileSync } from 'fs'
12
+ import { availableParallelism, homedir, loadavg } from 'os'
13
+ import { dirname, join, resolve } from 'path'
14
+ import { admit, boundMs, builtInHeavy, declaredHeavy, FULL_FACTOR, isFull, parsePs, SHOT_LOOP_COUNT, SHOT_LOOP_MS, whoUses, type AdmitMemo, type Look, type SessionProc, type UseGroup } from '../core/admission.ts'
15
+ import { SLOT_HELD_ENV } from '../core/slot-env.ts'
16
+
17
+ /** the Claude Code processes of this machine, by pid: the session files every config folder holds */
18
+ async function sessionProcs(): Promise<Map<number, SessionProc>> {
19
+ const [{ configDirs }, { everyRecord }] = await Promise.all([import('../agent-time/store.ts'), import('../agent-time/claude-sessions.ts')])
20
+ return new Map(everyRecord(configDirs()).map((r) => [r.pid, { cwd: r.cwd, name: r.name !== '' ? r.name : r.sessionId.slice(0, 8) }]))
21
+ }
22
+
23
+ /** one ps of every process, empty when it cannot run */
24
+ export async function readPs(): Promise<string> {
25
+ try {
26
+ const p = Bun.spawn(['ps', '-Axo', 'pid=,ppid=,%cpu=,args='], { stdout: 'pipe', stderr: 'ignore', env: { ...process.env, LC_ALL: 'C' } })
27
+ const [out, code] = await Promise.all([new Response(p.stdout).text(), p.exited])
28
+ return code === 0 ? out : ''
29
+ } catch {
30
+ return ''
31
+ }
32
+ }
33
+
34
+ /** who uses the CPU now, read with one ps */
35
+ export async function readWho(): Promise<UseGroup[]> {
36
+ const [ps, sessions] = await Promise.all([readPs(), sessionProcs().catch(() => new Map<number, SessionProc>())])
37
+ return whoUses(parsePs(ps), sessions, { home: homedir(), self: process.pid })
38
+ }
39
+
40
+ /** the machine as the gate reads it: the 1 minute load alone while it is under FULL_FACTOR times the cores, else the
41
+ * cores in use (the daemon's smoothed reading when fresh, else the ps sum) and who uses them */
42
+ export async function lookNow(): Promise<Look> {
43
+ if (process.env['SHIPKIT_MACHINE_LOAD'] != null) {
44
+ const { machineLoad } = await import('../core/machine-read.ts')
45
+ const m = machineLoad()
46
+ return { m, groups: isFull(m) ? await readWho() : null }
47
+ }
48
+ const cores = availableParallelism()
49
+ const load1 = loadavg()[0] ?? 0
50
+ if (load1 <= FULL_FACTOR * cores) return { m: { load1, cores }, groups: null }
51
+ const groups = await readWho()
52
+ let busy: number | null = null
53
+ try {
54
+ const { homeStateFile, readPublished } = await import('../core/machine-read.ts')
55
+ const file = homeStateFile('machine-busy.json')
56
+ busy = file == null ? null : readPublished(file, cores)
57
+ } catch { /* no home: the ps sum */ }
58
+ busy ??= Math.min(cores, groups.reduce((s, g) => s + g.cpu, 0) / 100)
59
+ return { m: { load1, cores, busy }, groups }
60
+ }
61
+
62
+ const readJson = <T>(file: string, empty: T): T => {
63
+ try { return JSON.parse(readFileSync(file, 'utf8')) as T } catch { return empty }
64
+ }
65
+
66
+ /** the memo of the last wait that reached its bound: who held the CPU then, in the home dir */
67
+ async function memoFile(): Promise<AdmitMemo | null> {
68
+ const [{ homeStateFile }, { atomicWrite }] = await Promise.all([import('../core/machine-read.ts'), import('../core/locked-write.ts')])
69
+ const file = homeStateFile('admission-over.json')
70
+ if (file == null) return null
71
+ return {
72
+ read: () => readJson<{ top?: unknown }>(file, {}).top as string | null ?? null,
73
+ write: (top) => {
74
+ if (top === (readJson<{ top?: unknown }>(file, {}).top ?? null)) return
75
+ try { atomicWrite(file, JSON.stringify({ top, at: Date.now() })) } catch { /* a read only home: every wait is a first one */ }
76
+ },
77
+ }
78
+ }
79
+
80
+ /** a still now from the command that runs it (this process's parent): true once it is the SHOT_LOOP_COUNT-th inside
81
+ * SHOT_LOOP_MS. Recorded only on a full machine, the one place the count is read */
82
+ export async function shotLoop(parent: number, now = Date.now()): Promise<boolean> {
83
+ const [{ homeStateFile }, { atomicWrite }] = await Promise.all([import('../core/machine-read.ts'), import('../core/locked-write.ts')])
84
+ const file = homeStateFile('admission-shots.json')
85
+ if (file == null) return false
86
+ const key = String(parent)
87
+ const all = readJson<Record<string, number[]>>(file, {})
88
+ const mine = [...(all[key] ?? []).filter((t) => now - t < SHOT_LOOP_MS), now]
89
+ const kept: Record<string, number[]> = { [key]: mine }
90
+ for (const [k, ts] of Object.entries(all)) if (k !== key && ts.some((t) => now - t < SHOT_LOOP_MS)) kept[k] = ts
91
+ try { atomicWrite(file, JSON.stringify(kept)) } catch { /* a read only home: no loop is seen */ }
92
+ return mine.length >= SHOT_LOOP_COUNT
93
+ }
94
+
95
+ /** the nearest folder at or above `from` holding a repo.config.ts */
96
+ function configRoot(from: string): string | null {
97
+ for (let d = resolve(from); ; d = dirname(d)) {
98
+ try { readFileSync(join(d, 'repo.config.ts')); return d } catch { /* go up */ }
99
+ if (dirname(d) === d) return null
100
+ }
101
+ }
102
+
103
+ const stderrSay = (l: string): void => void process.stderr.write(`${l}\n`)
104
+
105
+ /** a process a check started runs on its parent's admission; CI and a zero bound never wait */
106
+ const exempt = (): boolean => process.env['CI'] != null || process.env[SLOT_HELD_ENV] === '1' || boundMs() === 0
107
+
108
+ /** wait for room once the first look found the machine full, the memo read and written */
109
+ async function waitFor(what: string, first: Look, say: (l: string) => void): Promise<void> {
110
+ let seen = false
111
+ const memo = await memoFile().catch(() => null)
112
+ await admit(what, { look: async () => (seen ? lookNow() : ((seen = true), first)), now: () => Date.now(), sleep: (ms) => Bun.sleep(ms), say, boundMs: boundMs(), ...(memo != null ? { memo } : {}) })
113
+ }
114
+
115
+ /** THE ENTRY every sk command passes: a heavy line on a full machine waits (admit); anything else returns at once.
116
+ * Never throws: a gate that breaks warns and lets the command run */
117
+ export async function admitLine(argv: readonly string[], cwd: string, say: (l: string) => void = stderrSay): Promise<void> {
118
+ try {
119
+ if (argv.includes('--help') || argv.includes('-h') || exempt()) return
120
+ const first = await lookNow()
121
+ if (!isFull(first.m)) return
122
+ let what = builtInHeavy(argv)
123
+ if (what == null && argv[0] !== 'ci') {
124
+ const root = configRoot(cwd)
125
+ if (root == null) return
126
+ const { loadRepoConfig } = await import('../repo-config.ts')
127
+ what = declaredHeavy(argv, (await loadRepoConfig(root)).heavy ?? [])
128
+ }
129
+ if (what == null) return
130
+ if (what === 'shot-still') {
131
+ if (!(await shotLoop(process.ppid))) return
132
+ what = 'a loop of sk shot'
133
+ }
134
+ await waitFor(what, first, say)
135
+ } catch (e) {
136
+ say(`WARN the admission gate broke, the command runs: ${e instanceof Error ? e.message : String(e)}`)
137
+ }
138
+ }
139
+
140
+ /** an asked gate's admission, before its first heavy check that misses the cache (check-runner.ts beforeHeavy):
141
+ * a gate whose every answer is cached never waits. Never throws */
142
+ export async function admitCheck(id: string, say: (l: string) => void): Promise<void> {
143
+ try {
144
+ if (exempt()) return
145
+ const first = await lookNow()
146
+ if (isFull(first.m)) await waitFor(`the gate's ${id}`, first, say)
147
+ } catch (e) {
148
+ say(`WARN the admission gate broke, the gate runs: ${e instanceof Error ? e.message : String(e)}`)
149
+ }
150
+ }
@@ -30,6 +30,7 @@
30
30
  // status, whether it replayed, whether it can block, what it cost.
31
31
  import { closeSync, existsSync, mkdirSync, openSync, writeSync } from 'fs'
32
32
  import { basename, isAbsolute, join, relative } from 'path'
33
+ import { heavyCheck } from '../core/admission.ts'
33
34
  import { shareRun } from '../core/attach.ts'
34
35
  import { CheckCtx } from '../core/check-ctx.ts'
35
36
  import { CheckPass } from '../core/check-pass.ts'
@@ -167,6 +168,9 @@ export type CheckEvent = {
167
168
  export type Audience = 'gate' | 'health'
168
169
 
169
170
  export type RunChecksOpts = {
171
+ /** awaited once, before the body of the first heavy check (core/admission.ts heavyCheck): a replay, an attached
172
+ * answer and a light check never wait on it */
173
+ beforeHeavy?: (id: string) => Promise<void>
170
174
  checks: RunnableCheck[]
171
175
  root: string
172
176
  config: CheckEnv['config']
@@ -819,6 +823,7 @@ export async function runChecks(o: RunChecksOpts): Promise<RunChecksSummary> {
819
823
  /** ONE measurement per in flight question: an asker whose exact key
820
824
  * another run is measuring right now waits for that answer instead of
821
825
  * running the tool a second time (core/attach.ts) */
826
+ let admitted: Promise<void> | null = null
822
827
  const measureShared = async (u: Live): Promise<void> => {
823
828
  const slot = o.ledger?.attachSlot(u.id) ?? null
824
829
  if (slot == null) return await measureAndKeep(u)
@@ -841,6 +846,7 @@ export async function runChecks(o: RunChecksOpts): Promise<RunChecksSummary> {
841
846
  const measureAndKeep = async (u: Live): Promise<void> => {
842
847
  // a machine slot for the body, and only the body: a replay or an
843
848
  // attached wait runs nothing, so it holds none
849
+ if (o.beforeHeavy != null && heavyCheck(u.id)) await (admitted ??= o.beforeHeavy(u.id))
844
850
  const who = { repo: o.config.name, check: u.id }
845
851
  const queue = pool != null && !isShort(u)
846
852
  if (queue) { waitMark(); wait.waiting++ }