@rt-tools/agent-kit 0.37.1 → 0.39.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 (371) hide show
  1. package/README.md +5 -5
  2. package/assets/checks/action-of.mjs +154 -0
  3. package/assets/checks/board-runs.github.mjs +40 -5
  4. package/assets/checks/check-board.github.mjs +38 -7
  5. package/assets/checks/check-state-next.mjs +22 -10
  6. package/assets/checks/check-turn-map.mjs +26 -6
  7. package/assets/checks/check-work-steps.mjs +4 -173
  8. package/assets/checks/decide.mjs +285 -0
  9. package/assets/checks/decision-table.json +21432 -0
  10. package/assets/checks/decision-table.mjs +495 -0
  11. package/assets/checks/epic-window.mjs +98 -0
  12. package/assets/checks/flow-condition.mjs +64 -0
  13. package/assets/checks/flow-data.mjs +135 -0
  14. package/assets/checks/flow-forecast.mjs +334 -0
  15. package/assets/checks/flow-guard-run.mjs +90 -0
  16. package/assets/checks/flow-guard.mjs +496 -0
  17. package/assets/checks/flow-model.mjs +271 -0
  18. package/assets/checks/flow-override.mjs +130 -0
  19. package/assets/checks/flow-plan.mjs +206 -0
  20. package/assets/checks/flow-scaffold.mjs +224 -0
  21. package/assets/checks/flow-step.mjs +495 -0
  22. package/assets/checks/flow-sync.mjs +296 -0
  23. package/assets/checks/flow-syntax.mjs +292 -0
  24. package/assets/checks/flow-verdict.mjs +227 -0
  25. package/assets/checks/merge-read.mjs +239 -0
  26. package/assets/checks/owner-nudges.mjs +389 -0
  27. package/assets/checks/push-inputs.mjs +59 -16
  28. package/assets/checks/record-count.mjs +437 -0
  29. package/assets/checks/record-recount.mjs +187 -0
  30. package/assets/checks/record-turn.mjs +155 -0
  31. package/assets/checks/task-flow-script.mjs +318 -0
  32. package/assets/checks/tree-assignment.mjs +26 -7
  33. package/assets/checks/work-result.mjs +362 -0
  34. package/assets/checks/work-steps-lib.mjs +205 -0
  35. package/assets/commands/night.md +6 -6
  36. package/assets/defaults/gate-map.sh +39 -12
  37. package/assets/defaults/merges.sh +48 -0
  38. package/assets/defaults/project.sh +6 -5
  39. package/assets/defaults/turn-map.md +23 -22
  40. package/assets/docs/GLOSSARY.md +5 -1
  41. package/assets/hooks/ask-judge.md +67 -0
  42. package/assets/hooks/browser-guard-device-id.sh +11 -9
  43. package/assets/hooks/browser-guard-no-asking.sh +12 -6
  44. package/assets/hooks/browser-guard-no-listing.sh +13 -7
  45. package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
  46. package/assets/hooks/browser-guard-require-select.sh +15 -15
  47. package/assets/hooks/commit-msg.sh +13 -3
  48. package/assets/hooks/conscience-guard.sh +9 -25
  49. package/assets/hooks/decide.sh +141 -0
  50. package/assets/hooks/deny-tail.sh +16 -11
  51. package/assets/hooks/dev-server-guard.sh +27 -20
  52. package/assets/hooks/dispatch.sh +47 -4
  53. package/assets/hooks/docs-guard.sh +31 -200
  54. package/assets/hooks/end-conversation-guard.sh +12 -21
  55. package/assets/hooks/epic-stop-guard.sh +54 -152
  56. package/assets/hooks/exam-guard.sh +32 -65
  57. package/assets/hooks/facts-docs.sh +221 -0
  58. package/assets/hooks/facts-flow.sh +173 -0
  59. package/assets/hooks/facts.sh +374 -0
  60. package/assets/hooks/flow-step-guard.sh +93 -0
  61. package/assets/hooks/git-guard-delivery-body.sh +4 -4
  62. package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
  63. package/assets/hooks/git-guard-delivery-draft.sh +3 -3
  64. package/assets/hooks/git-guard-delivery-epic.sh +18 -9
  65. package/assets/hooks/git-guard-delivery-folder.sh +32 -7
  66. package/assets/hooks/git-guard-delivery-merge.sh +2 -2
  67. package/assets/hooks/git-guard-delivery-merged.sh +12 -1
  68. package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
  69. package/assets/hooks/git-guard-delivery-rerun.sh +44 -0
  70. package/assets/hooks/git-guard-delivery-signature.sh +82 -45
  71. package/assets/hooks/git-guard-delivery-task.sh +47 -0
  72. package/assets/hooks/git-guard-delivery.sh +112 -101
  73. package/assets/hooks/git-guard-discard.sh +8 -18
  74. package/assets/hooks/git-guard-main.sh +13 -19
  75. package/assets/hooks/git-guard-no-verify.sh +56 -16
  76. package/assets/hooks/git-guard-push-ahead.sh +39 -6
  77. package/assets/hooks/git-guard-push-marks.sh +262 -13
  78. package/assets/hooks/git-guard-push-tests.sh +58 -52
  79. package/assets/hooks/git-guard-tree-assignment.sh +7 -4
  80. package/assets/hooks/guard-note.sh +8 -6
  81. package/assets/hooks/handoff-entry-guard.sh +19 -38
  82. package/assets/hooks/handoff-write.sh +3 -1
  83. package/assets/hooks/hook-input.sh +0 -41
  84. package/assets/hooks/metric-marks.sh +19 -7
  85. package/assets/hooks/observe.sh +1 -1
  86. package/assets/hooks/override-write-guard.sh +27 -9
  87. package/assets/hooks/pre-push.sh +40 -12
  88. package/assets/hooks/prose-style-guard.sh +6 -19
  89. package/assets/hooks/pull-merges.sh +76 -0
  90. package/assets/hooks/push-ahead-call-guard.sh +447 -0
  91. package/assets/hooks/push-set.sh +38 -8
  92. package/assets/hooks/qa-dataid-guard.sh +7 -17
  93. package/assets/hooks/record-turn.sh +52 -0
  94. package/assets/hooks/rerun-guard.sh +11 -16
  95. package/assets/hooks/reuse-first-guard.sh +7 -21
  96. package/assets/hooks/role-calls.sh +25 -3
  97. package/assets/hooks/rule-source-guard.sh +54 -21
  98. package/assets/hooks/skill-gate-rearm.sh +18 -5
  99. package/assets/hooks/skill-gate.sh +156 -20
  100. package/assets/hooks/skill-loaded.sh +18 -3
  101. package/assets/hooks/sql-guard-target.sh +2 -2
  102. package/assets/hooks/sql-guard-write.sh +12 -12
  103. package/assets/hooks/sql-guard.sh +58 -16
  104. package/assets/hooks/task-context-load.sh +3 -1
  105. package/assets/hooks/task-flow-context.sh +5 -18
  106. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  107. package/assets/hooks/task-flow-guard.sh +28 -130
  108. package/assets/hooks/tree-assignment-guard.sh +25 -14
  109. package/assets/hooks/turn-entry-load.sh +3 -1
  110. package/assets/hooks/turn-exit-guard.sh +92 -452
  111. package/assets/hooks/turn-exit-role.sh +3 -1
  112. package/assets/hooks/turn-judge.md +113 -0
  113. package/assets/hooks/window-fill-guard.sh +22 -41
  114. package/assets/patterns/doc-style-human.md +36 -76
  115. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  116. package/assets/patterns/git-workflow-commit.github.md +11 -269
  117. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  118. package/assets/patterns/git-workflow-docker.md +8 -231
  119. package/assets/patterns/git-workflow-freshness.md +8 -56
  120. package/assets/patterns/git-workflow-merge.md +6 -176
  121. package/assets/patterns/git-workflow-migration.md +5 -75
  122. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  123. package/assets/patterns/git-workflow-pr-ready.md +9 -70
  124. package/assets/patterns/git-workflow-pr.azure.md +13 -285
  125. package/assets/patterns/git-workflow-pr.github.md +13 -251
  126. package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
  127. package/assets/patterns/git-workflow-restart.md +5 -42
  128. package/assets/patterns/git-workflow-secrets.md +10 -76
  129. package/assets/patterns/git-workflow-stack.md +7 -207
  130. package/assets/patterns/status-report-table.github.md +1 -1
  131. package/assets/patterns/task-flow-archive.md +12 -233
  132. package/assets/patterns/task-flow-close.md +16 -292
  133. package/assets/patterns/task-flow-cycle.md +13 -39
  134. package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
  135. package/assets/patterns/task-flow-handoff.md +13 -161
  136. package/assets/patterns/task-flow-resume.md +18 -218
  137. package/assets/patterns/task-flow-start.md +9 -247
  138. package/assets/patterns/turn-entry-map.md +2 -2
  139. package/assets/pitfalls/agent-kit-extend.md +200 -0
  140. package/assets/pitfalls/agent-kit.2.md +323 -0
  141. package/assets/pitfalls/angular-patterns.md +98 -0
  142. package/assets/pitfalls/browser-verification.md +265 -0
  143. package/assets/pitfalls/component-structure.md +98 -0
  144. package/assets/pitfalls/dependencies.md +92 -0
  145. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  146. package/assets/pitfalls/deploy-flow.github.md +211 -0
  147. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  148. package/assets/pitfalls/doc-style-human.md +112 -0
  149. package/assets/pitfalls/doc-style.2.md +286 -0
  150. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  151. package/assets/pitfalls/entity-models.md +89 -0
  152. package/assets/pitfalls/epic-flow.md +92 -0
  153. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  154. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  155. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  156. package/assets/pitfalls/git-workflow-docker.md +275 -0
  157. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  158. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  159. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  160. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  161. package/assets/pitfalls/git-workflow-merge.md +220 -0
  162. package/assets/pitfalls/git-workflow-migration.md +103 -0
  163. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  164. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  165. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  166. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  167. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  168. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  169. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  170. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  171. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  172. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  173. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  174. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  175. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  176. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  177. package/assets/pitfalls/git-workflow-restart.md +72 -0
  178. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  179. package/assets/pitfalls/git-workflow-stack.md +254 -0
  180. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  181. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  182. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  183. package/assets/pitfalls/lib-layers.md +114 -0
  184. package/assets/pitfalls/lists.md +117 -0
  185. package/assets/pitfalls/mockups.needs-mockups.md +87 -0
  186. package/assets/pitfalls/navigation.md +94 -0
  187. package/assets/pitfalls/observability.needs-app.md +186 -0
  188. package/assets/pitfalls/platform-access.md +94 -0
  189. package/assets/pitfalls/queue-audit.github.md +78 -0
  190. package/assets/pitfalls/reuse-first.md +201 -0
  191. package/assets/pitfalls/spec-driven.2.md +318 -0
  192. package/assets/pitfalls/styling-bem.2.md +125 -0
  193. package/assets/pitfalls/task-flow-archive.md +265 -0
  194. package/assets/pitfalls/task-flow-close.2.md +166 -0
  195. package/assets/pitfalls/task-flow-close.md +167 -0
  196. package/assets/pitfalls/task-flow-cycle.md +73 -0
  197. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  198. package/assets/pitfalls/task-flow-handoff.md +200 -0
  199. package/assets/pitfalls/task-flow-handover.md +30 -0
  200. package/assets/pitfalls/task-flow-owner.md +58 -0
  201. package/assets/pitfalls/task-flow-plan.md +29 -0
  202. package/assets/pitfalls/task-flow-resume.md +257 -0
  203. package/assets/pitfalls/task-flow-start.md +287 -0
  204. package/assets/pitfalls/task-flow.2.md +303 -0
  205. package/assets/pitfalls/task-flow.md +4 -4
  206. package/assets/pitfalls/testing.2.md +279 -0
  207. package/assets/pitfalls/turn-conduct.md +16 -17
  208. package/assets/pitfalls/typescript-conventions.md +161 -0
  209. package/assets/pitfalls/write-a-skill.md +128 -0
  210. package/assets/rules/angular-patterns.md +21 -86
  211. package/assets/rules/autonomous-work.md +2 -2
  212. package/assets/rules/browser-verification.md +28 -256
  213. package/assets/rules/component-structure.md +25 -87
  214. package/assets/rules/dependencies.md +20 -78
  215. package/assets/rules/deploy-flow.azure.md +26 -156
  216. package/assets/rules/deploy-flow.github.md +34 -200
  217. package/assets/rules/deploy-flow.gitlab.md +27 -159
  218. package/assets/rules/doc-style.md +32 -286
  219. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  220. package/assets/rules/entity-models.md +14 -63
  221. package/assets/rules/epic-flow.md +24 -63
  222. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  223. package/assets/rules/git-workflow-hosting.github.md +38 -0
  224. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  225. package/assets/rules/git-workflow-push.azure.md +28 -0
  226. package/assets/rules/git-workflow-push.github.md +28 -0
  227. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  228. package/assets/rules/git-workflow-queue.azure.md +23 -0
  229. package/assets/rules/git-workflow-queue.github.md +30 -0
  230. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  231. package/assets/rules/git-workflow.azure.md +21 -282
  232. package/assets/rules/git-workflow.github.md +24 -284
  233. package/assets/rules/git-workflow.gitlab.md +21 -269
  234. package/assets/rules/lib-layers.md +30 -103
  235. package/assets/rules/lists.md +21 -105
  236. package/assets/rules/mockups.needs-mockups.md +25 -64
  237. package/assets/rules/navigation.md +10 -69
  238. package/assets/rules/observability.needs-app.md +43 -172
  239. package/assets/rules/platform-access.md +28 -75
  240. package/assets/rules/queue-audit.github.md +25 -52
  241. package/assets/rules/reuse-first.md +20 -195
  242. package/assets/rules/spec-driven.md +35 -308
  243. package/assets/rules/styling-bem.md +20 -117
  244. package/assets/rules/task-flow-handover.md +24 -0
  245. package/assets/rules/task-flow-owner.md +34 -0
  246. package/assets/rules/task-flow-plan.md +38 -0
  247. package/assets/rules/task-flow.md +22 -300
  248. package/assets/rules/testing.md +32 -273
  249. package/assets/rules/turn-conduct.md +105 -106
  250. package/assets/rules/turn-entry.md +2 -2
  251. package/assets/rules/typescript-conventions.md +41 -147
  252. package/assets/samples/tasks/_template/plan.md +30 -6
  253. package/assets/samples/tasks/_template/progress.md +0 -1
  254. package/assets/skills/agent-kit-extend.md +25 -168
  255. package/assets/skills/agent-kit.md +27 -299
  256. package/assets/skills/write-a-skill.md +20 -106
  257. package/assets/task-flow/flow.js +184 -0
  258. package/assets/task-flow/flow.md +101 -0
  259. package/assets/task-flow/measure/agreement.mjs +24 -0
  260. package/assets/task-flow/measure/ci.mjs +184 -0
  261. package/assets/task-flow/measure/copy.mjs +22 -0
  262. package/assets/task-flow/measure/epic-of.mjs +50 -0
  263. package/assets/task-flow/measure/epic-text.mjs +35 -0
  264. package/assets/task-flow/measure/epic.mjs +114 -0
  265. package/assets/task-flow/measure/folder.mjs +16 -0
  266. package/assets/task-flow/measure/footprint.mjs +28 -0
  267. package/assets/task-flow/measure/grill.mjs +21 -0
  268. package/assets/task-flow/measure/host.mjs +8 -0
  269. package/assets/task-flow/measure/owner.mjs +27 -0
  270. package/assets/task-flow/measure/plan.mjs +27 -0
  271. package/assets/task-flow/measure/pr.mjs +20 -0
  272. package/assets/task-flow/measure/progress.mjs +50 -0
  273. package/assets/task-flow/measure/session.mjs +252 -0
  274. package/assets/task-flow/measure/task.mjs +23 -0
  275. package/assets/task-flow/measure/text.mjs +77 -0
  276. package/assets/task-flow/source/git.mjs +254 -0
  277. package/assets/task-flow/source/host.mjs +277 -0
  278. package/assets/task-flow/source/marks.mjs +56 -0
  279. package/assets/task-flow/source/owner.mjs +94 -0
  280. package/assets/task-flow/source/records.mjs +116 -0
  281. package/assets/task-flow/source/session.mjs +269 -0
  282. package/assets/task-flow/source/steps.mjs +28 -0
  283. package/assets/task-flow/source/tree.mjs +42 -0
  284. package/bin/agent-kit.d.ts.map +1 -1
  285. package/bin/agent-kit.js +30 -0
  286. package/bin/agent-kit.js.map +1 -1
  287. package/lib/agent-checks.d.ts +55 -0
  288. package/lib/agent-checks.d.ts.map +1 -0
  289. package/lib/agent-checks.js +221 -0
  290. package/lib/agent-checks.js.map +1 -0
  291. package/lib/assets.d.ts.map +1 -1
  292. package/lib/assets.js +7 -2
  293. package/lib/assets.js.map +1 -1
  294. package/lib/cargo.d.ts +29 -0
  295. package/lib/cargo.d.ts.map +1 -1
  296. package/lib/cargo.js +27 -1
  297. package/lib/cargo.js.map +1 -1
  298. package/lib/cascade.d.ts.map +1 -1
  299. package/lib/cascade.js +3 -1
  300. package/lib/cascade.js.map +1 -1
  301. package/lib/commands.d.ts.map +1 -1
  302. package/lib/commands.js +78 -2
  303. package/lib/commands.js.map +1 -1
  304. package/lib/config.d.ts +18 -0
  305. package/lib/config.d.ts.map +1 -1
  306. package/lib/config.js +18 -1
  307. package/lib/config.js.map +1 -1
  308. package/lib/epic-window-send.d.ts +74 -0
  309. package/lib/epic-window-send.d.ts.map +1 -0
  310. package/lib/epic-window-send.js +166 -0
  311. package/lib/epic-window-send.js.map +1 -0
  312. package/lib/hooks-map.d.ts +4 -0
  313. package/lib/hooks-map.d.ts.map +1 -1
  314. package/lib/hooks-map.js +2 -2
  315. package/lib/hooks-map.js.map +1 -1
  316. package/lib/integrity.d.ts +3 -0
  317. package/lib/integrity.d.ts.map +1 -1
  318. package/lib/integrity.js +7 -0
  319. package/lib/integrity.js.map +1 -1
  320. package/lib/metric-lines.d.ts +2 -1
  321. package/lib/metric-lines.d.ts.map +1 -1
  322. package/lib/metric-lines.js +49 -1
  323. package/lib/metric-lines.js.map +1 -1
  324. package/lib/metric-send-mark.d.ts +6 -3
  325. package/lib/metric-send-mark.d.ts.map +1 -1
  326. package/lib/metric-send-mark.js +15 -5
  327. package/lib/metric-send-mark.js.map +1 -1
  328. package/lib/metric-send.d.ts +6 -2
  329. package/lib/metric-send.d.ts.map +1 -1
  330. package/lib/metric-send.js +47 -13
  331. package/lib/metric-send.js.map +1 -1
  332. package/lib/metrics.d.ts +17 -0
  333. package/lib/metrics.d.ts.map +1 -1
  334. package/lib/metrics.js +26 -15
  335. package/lib/metrics.js.map +1 -1
  336. package/lib/observations.js +3 -3
  337. package/lib/observations.js.map +1 -1
  338. package/lib/outcomes.d.ts +5 -2
  339. package/lib/outcomes.d.ts.map +1 -1
  340. package/lib/outcomes.js +5 -4
  341. package/lib/outcomes.js.map +1 -1
  342. package/lib/push-gate.d.ts +13 -0
  343. package/lib/push-gate.d.ts.map +1 -1
  344. package/lib/push-gate.js +11 -7
  345. package/lib/push-gate.js.map +1 -1
  346. package/lib/push-set-usefulness.d.ts +78 -0
  347. package/lib/push-set-usefulness.d.ts.map +1 -0
  348. package/lib/push-set-usefulness.js +225 -0
  349. package/lib/push-set-usefulness.js.map +1 -0
  350. package/lib/sync.d.ts +10 -0
  351. package/lib/sync.d.ts.map +1 -1
  352. package/lib/sync.js +14 -1
  353. package/lib/sync.js.map +1 -1
  354. package/lib/work-result.d.ts +43 -0
  355. package/lib/work-result.d.ts.map +1 -0
  356. package/lib/work-result.js +39 -0
  357. package/lib/work-result.js.map +1 -0
  358. package/package.json +1 -1
  359. package/assets/hooks/claim-guard.sh +0 -212
  360. package/assets/hooks/grill-gate-ask.sh +0 -26
  361. package/assets/hooks/grill-gate-bypass.sh +0 -61
  362. package/assets/hooks/grill-gate-options.sh +0 -50
  363. package/assets/hooks/grill-gate.sh +0 -482
  364. package/assets/hooks/postmortem-guard.sh +0 -124
  365. package/assets/hooks/proposal-guard.sh +0 -154
  366. package/assets/hooks/stand-login-guard.sh +0 -107
  367. package/assets/hooks/turn-exit-epic.sh +0 -173
  368. package/assets/hooks/turn-exit-patterns.sh +0 -123
  369. package/assets/hooks/turn-exit-verdict.sh +0 -149
  370. package/assets/hooks/waiting-turn-guard.sh +0 -320
  371. package/assets/hooks/work-start-guard.sh +0 -175
@@ -79,11 +79,11 @@ rt_epic_base() {
79
79
  if rt_epic_is_merged "$_epic"; then
80
80
  return 0
81
81
  fi
82
- fault "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has."
82
+ unmet epic_branch none "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has. Take it from the fresh main branch, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh} > \"\${TMPDIR:-/tmp}/push-ahead-\$(basename \"\$PWD\").log\" 2>&1\` (the Bash call with run_in_background, nothing after it; the verdict is the code of the notice and the last \`push ahead:\` line of the log) and push it after their end: the push is refused until they have a green mark."
83
83
  return 0
84
84
  ;;
85
85
  *' '*)
86
- fault "the epic #${_epic} has more than one branch in the remote — ${_epic_branch}. There is no telling which of them the task branches from; leave one."
86
+ unmet epic_branch several "the epic #${_epic} has more than one branch in the remote — ${_epic_branch}. There is no telling which of them the task branches from; leave one."
87
87
  return 0
88
88
  ;;
89
89
  esac
@@ -91,8 +91,10 @@ rt_epic_base() {
91
91
  git rev-parse --verify --quiet "origin/${_epic_branch}" >/dev/null 2>&1 || return 0
92
92
 
93
93
  if ! git merge-base --is-ancestor "origin/${_epic_branch}" "$_base_ref" 2>/dev/null; then
94
- fault "the branch will grow from a base that does not carry the branch of the epic «${_epic_branch}». A task branched from the main one leaves its epic half merged before the epic itself is handed in. Take the base from the epic: git fetch origin && git checkout -b ${_branch} origin/${_epic_branch}."
95
- return 0
94
+ unmet_class branch_create_stale_base "the branch will grow from a base that does not carry the branch of the epic «${_epic_branch}». A task branched from the main one leaves its epic half merged before the epic itself is handed in. Take the base from the epic: git fetch origin && git checkout -b ${_branch} origin/${_epic_branch}."
95
+ # The check below goes on against the base just named: stopped here, the refusal named a
96
+ # base the next call refused for the main branch the epic lacks.
97
+ _base_ref="origin/${_epic_branch}"
96
98
  fi
97
99
 
98
100
  # The main branch is asked of the epic, not of the base: there it is fixed by one merge, and the
@@ -107,7 +109,7 @@ rt_epic_base() {
107
109
  && ! git merge-base --is-ancestor "origin/${main_branch}" "origin/${_epic_branch}" 2>/dev/null \
108
110
  && ! git merge-base --is-ancestor "origin/${main_branch}" "$_base_ref" 2>/dev/null; then
109
111
  _behind="$(git rev-list --count "origin/${_epic_branch}..origin/${main_branch}" 2>/dev/null)"
110
- fault "the branch of the epic «${_epic_branch}» does not carry the tip of «${main_branch}» — it has moved ahead by ${_behind:-several} commits. The main branch is merged into the branch of the epic, not bypassed by taking the base from the main one: git checkout ${_epic_branch}, git merge origin/${main_branch}, and send the branch."
112
+ unmet epic_has_main_tip no "the branch of the epic «${_epic_branch}» does not carry the tip of «${main_branch}» — it has moved ahead by ${_behind:-several} commits. The main branch is merged into the branch of the epic, not bypassed by taking the base from the main one: git checkout ${_epic_branch}, git merge origin/${main_branch}, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh} > \"\${TMPDIR:-/tmp}/push-ahead-\$(basename \"\$PWD\").log\" 2>&1\` (the Bash call with run_in_background, nothing after it; the verdict is the code of the notice and the last \`push ahead:\` line of the log), and send the branch after their end: the push is refused until they have a green mark."
111
113
  fi
112
114
 
113
115
  return 0
@@ -157,14 +159,15 @@ rt_epic_pull_base() {
157
159
  fi
158
160
 
159
161
  if [ "$_base" != "$_epic_branch" ] && [ -z "$_chain" ]; then
160
- fault "the request of a task of the epic #${_epic} goes into the branch of the epic «${_epic_branch}», and the base here is ${_base:-the default branch of the repository}. A request into the main branch takes the task past its epic: the epic is handed in without it. Name the base: --base ${_epic_branch}."
161
- return 0
162
+ unmet_class pr_create_wrong_base "the request of a task of the epic #${_epic} goes into the branch of the epic «${_epic_branch}», and the base here is ${_base:-the default branch of the repository}. A request into the main branch takes the task past its epic: the epic is handed in without it. Name the base: --base ${_epic_branch}."
163
+ # The freshness of the branch is judged below all the same: it is what the request into the
164
+ # named base is refused for next, and stopped here, this refusal led into that one.
162
165
  fi
163
166
 
164
167
  if git rev-parse --verify --quiet "origin/${_epic_branch}" >/dev/null 2>&1 \
165
168
  && ! git merge-base --is-ancestor "origin/${_epic_branch}" HEAD 2>/dev/null; then
166
169
  _behind="$(git rev-list --count "HEAD..origin/${_epic_branch}" 2>/dev/null)"
167
- fault "the branch of the epic «${_epic_branch}» has moved ahead by ${_behind:-several} commits and is not merged into this branch. The reviewer would see the edit mixed with someone else's: git fetch origin && git merge origin/${_epic_branch}."
170
+ unmet branch_has_epic_tip no "the branch of the epic «${_epic_branch}» has moved ahead by ${_behind:-several} commits and is not merged into this branch. The reviewer would see the edit mixed with someone else's: git fetch origin && git merge origin/${_epic_branch}."
168
171
  fi
169
172
 
170
173
  return 0
@@ -205,7 +208,13 @@ rt_epic_own_pull() {
205
208
  done
206
209
  [ -n "$_left" ] || return 0
207
210
 
208
- fault "the branch of the epic still carries the folders of its tasks — ${_left}. The request of an epic opens when the last of its folders is taken apart: merged as it is, the epic takes the folders of unfinished work into the main branch, and the reader has no way to tell them from current work."
211
+ # The words of the commit the move names: a foreign signature refuses it first.
212
+ _where=''
213
+ command -v rt_signature_commit_note >/dev/null 2>&1 && _where="$(rt_signature_commit_note)"
214
+ [ -n "$_where" ] && fact commits_signed_declared no
215
+ # No foreign signature: the word of the neighbours the commit meets goes here, the decider puts it.
216
+ [ -n "$_where" ] || _where='{first}'
217
+ unmet epic_folders_left yes "the branch of the epic still carries the folders of its tasks — ${_left}. The request of an epic opens when the last of its folders is taken apart: merged as it is, the epic takes the folders of unfinished work into the main branch, and the reader has no way to tell them from current work. Take them apart and commit that.${_where}"
209
218
 
210
219
  return 0
211
220
  }
@@ -38,7 +38,7 @@ rt_folder_was_in_branch() {
38
38
  # checked-out branch carries a folder the named PR does not have. The tree of the head is read from
39
39
  # the remote ref. Without a head, or without its ref, the checked-out branch is judged, as before.
40
40
  rt_delivery_folder_target() {
41
- _branch="$(git branch --show-current 2>/dev/null)"
41
+ _branch="$(rt_fact_branch)"
42
42
  _tree=HEAD
43
43
  [ -n "$1" ] && [ "$1" != "$_branch" ] || return 0
44
44
  git rev-parse --verify --quiet "refs/remotes/origin/$1" >/dev/null 2>&1 || return 0
@@ -46,6 +46,29 @@ rt_delivery_folder_target() {
46
46
  _tree="refs/remotes/origin/$1"
47
47
  }
48
48
 
49
+ # A sentence for a refusal whose fix is a commit in the branch the folder lies in. Two things refuse
50
+ # that commit next: a copy standing on another branch commits elsewhere — on the main one it is
51
+ # refused outright — and a contribution under a foreign signature refuses every commit until it is
52
+ # rewritten, and the neighbouring guards may want their own move first — the document pair, the
53
+ # exam. Each is named before the commit. Argument: the branch the folder lies in.
54
+ rt_folder_commit_where() {
55
+ # The words go to `_where`, and the facts of that commit to the table: where the copy stands and
56
+ # whether the contribution carries a foreign signature. What the neighbouring guards want before
57
+ # the commit — the document pair, the exam — the decider names from their rows.
58
+ _where=''
59
+ _here="$(rt_fact_branch)"
60
+ if [ -n "$1" ] && [ "$1" != "$_here" ]; then
61
+ [ "$_here" = "$main_branch" ] && fact branch_is_main yes
62
+ _where="$(printf ' The folder lies in the branch «%s», and the copy stands on «%s»: switch to it first — git checkout %s — and commit there.' "$1" "${_here:-a detached head}" "$1")"
63
+ return 0
64
+ fi
65
+ command -v rt_signature_commit_note >/dev/null 2>&1 && _where="$(rt_signature_commit_note)"
66
+ [ -n "$_where" ] && fact commits_signed_declared no
67
+ # No foreign signature: the word of the neighbours the commit meets goes here, the decider puts it.
68
+ [ -n "$_where" ] || _where='{first}'
69
+ return 0
70
+ }
71
+
49
72
  # Condition for opening the PR: the folder is taken apart, and a record from the branch has arrived
50
73
  # in the archive. The refusal accumulates together with the other delivery conditions and is
51
74
  # printed all at once.
@@ -64,7 +87,7 @@ rt_delivery_open_folder() {
64
87
  _folder="$tasks_dir/$branch"
65
88
  _lying="$(rt_folder_in_branch "$_folder")"
66
89
  if [ -n "$_lying" ]; then
67
- fault "the branch carries the task folder «${_lying}» — a request is opened after the tidying, not before it. Move to «${archive_dir:-archive}» what explains the decisions taken, delete the rest, commit it by the last commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command."
90
+ rt_folder_commit_where "$branch" && unmet task_folder_in_branch yes "the branch carries the task folder «${_lying}» — a request is opened after the tidying, not before it. Move to «${archive_dir:-archive}» what explains the decisions taken, delete the rest, commit it by the last commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command.${_where}"
68
91
  return 0
69
92
  fi
70
93
 
@@ -81,7 +104,7 @@ rt_delivery_open_folder() {
81
104
  [ -n "$_plan" ] || continue
82
105
  _draft="$(rt_branch_plan_draft "${_plan%/plan.md}" "$_base")"
83
106
  [ -n "$_draft" ] && [ -n "$(git ls-tree -d --name-only HEAD -- "${_draft%/}" 2>/dev/null)" ] \
84
- && fault "the branch carries the unmerged agreement «${_draft}» its plan named — merge its rules and scenarios into the domain spec, remove the directory by a commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command."
107
+ && unmet draft_spec_merged no "the branch carries the unmerged agreement «${_draft}» its plan named — merge its rules and scenarios into the domain spec, remove the directory by a commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command."
85
108
  done <<EOF
86
109
  $(git log --format= --name-only "$_base..HEAD" -- "$tasks_dir/*/plan.md" 2>/dev/null | sort -u)
87
110
  EOF
@@ -92,7 +115,7 @@ EOF
92
115
 
93
116
  _gained="$(git diff --name-only --diff-filter=A "$_base" HEAD -- "$archive_dir" 2>/dev/null | head -1)"
94
117
  [ -z "$_gained" ] \
95
- && fault "the task folder was deleted, but the branch added nothing to «${archive_dir}». Deleting is cheaper than taking apart — and together with the folder the analysis of the request is gone, the only record of the words of the owner. Move what explains the decisions taken as one file with a telling name and repeat."
118
+ && rt_folder_commit_where "$branch" && unmet archive_gained no "the task folder was deleted, but the branch added nothing to «${archive_dir}». Deleting is cheaper than taking apart — and together with the folder the analysis of the request is gone, the only record of the words of the owner. Move what explains the decisions taken as one file with a telling name, commit it and repeat.${_where}"
96
119
  }
97
120
 
98
121
  # The base the opening command names. Absent — the host takes the default branch: an empty answer.
@@ -133,7 +156,7 @@ rt_delivery_ready_folder() {
133
156
 
134
157
  _lying="$(rt_folder_in_branch "$tasks_dir/$_branch" "$_tree")"
135
158
  [ -n "$_lying" ] \
136
- && fault "the branch carries the task folder «${_lying}» — a lifted draft reads as «ready to merge», and merging it there is not allowed. The button is pressed by a person on the hosting, and the folder reaches main before their hand does. Move to «${archive_dir:-archive}» what explains the decisions taken, delete the rest, commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command."
159
+ && rt_folder_commit_where "$_branch" && unmet task_folder_in_branch yes "the branch carries the task folder «${_lying}» — a lifted draft reads as «ready to merge», and merging it there is not allowed. The button is pressed by a person on the hosting, and the folder reaches main before their hand does. Move to «${archive_dir:-archive}» what explains the decisions taken, delete the rest, commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command.${_where}"
137
160
  }
138
161
 
139
162
  # Condition for the merge: the same subject as a second line. It catches a merge going by command —
@@ -165,7 +188,8 @@ rt_delivery_merge_folder() {
165
188
 
166
189
  _lying="$(rt_folder_in_branch "$_folder" "$_tree")"
167
190
  [ -n "$_lying" ] \
168
- && deny "BLOCKED: the task folder «${_lying}» is left in the branch — it will travel into main. There will be nobody to take it apart later: the work moves on to the next task, and this request closes. Move to «${archive_dir:-archive}» what explains the decisions taken, delete the rest and repeat. If the work is merged in parts, put the line «Task-folder-skip: <reason>» into the body of the request."
191
+ && rt_folder_commit_where "$_branch" && fact task_folder_in_branch yes \
192
+ && refuse pr_merge "$(jq -cn --arg l "$_lying" --arg a "${archive_dir:-archive}" --arg w "${_where%\{first\}}" '{lying:$l, archive_dir:$a, where:$w}')"
169
193
 
170
194
  [ -n "$archive_dir" ] || exit 0
171
195
  _base="$(git merge-base "$main_branch" "$_tree" 2>/dev/null)"
@@ -174,7 +198,8 @@ rt_delivery_merge_folder() {
174
198
 
175
199
  _gained="$(git diff --name-only --diff-filter=A "$_base" "$_tree" -- "$archive_dir" 2>/dev/null | head -1)"
176
200
  [ -z "$_gained" ] \
177
- && deny "BLOCKED: the task folder was deleted, but the branch added nothing to «${archive_dir}». Deleting is cheaper than taking apart — and together with the folder the analysis of the request is gone, the only record of the words of the owner. Move what explains the decisions taken as one file with a telling name and repeat."
201
+ && rt_folder_commit_where "$_branch" && fact archive_gained no \
202
+ && refuse pr_merge "$(jq -cn --arg a "$archive_dir" --arg w "${_where%\{first\}}" '{archive_dir:$a, where:$w}')"
178
203
 
179
204
  exit 0
180
205
  }
@@ -24,9 +24,9 @@ rt_delivery_merge_run() {
24
24
  name="${name:-$ref}"
25
25
  case "$run" in
26
26
  failure)
27
- fault "the run on the tip of the request${name:+ #${name}} is red. A merge over red carries the breakage into the branch, and every next request into it turns red. Read the run — gh run list --commit <tip> — fix it in the branch and repeat." ;;
27
+ unmet pr_tip_run failure "the run on the tip of the request${name:+ #${name}} is red. A merge over red carries the breakage into the branch, and every next request into it turns red. Read the run — gh run list --commit <tip> — fix it in the branch and repeat." ;;
28
28
  running)
29
- fault "the run on the tip of the request${name:+ #${name}} has not finished. A merge before its end carries what it has not checked yet. Wait for its end and read the result by a command." ;;
29
+ unmet pr_tip_run running "the run on the tip of the request${name:+ #${name}} has not finished. A merge before its end carries what it has not checked yet. Wait for its end and read the result by a command." ;;
30
30
  esac
31
31
  return 0
32
32
  }
@@ -61,5 +61,16 @@ rt_delivery_merged() {
61
61
  _merged="$(cd "$root" && rt_pull_merged "$_target" 2>/dev/null)" || return 0
62
62
  [ -n "$_merged" ] || return 0
63
63
 
64
- deny "BLOCKED: the PR #${_merged} of the branch «${_target}» is merged, and the branch has no open PR. The host deleted the branch with the merge, and this push recreates it with commits nobody will merge. Take a new branch from the fresh base and move the commits there: git fetch origin && git checkout -b <new branch> origin/<base> && git cherry-pick <commits>."
64
+ # The move named below is new work: a task and its branch. Both are refused while a conflicting
65
+ # request of one's own stands or the copy has no assignment, so those are asked first and named
66
+ # in place of the creation.
67
+ fact branch_pr_merged yes
68
+ command -v rt_delivery_conflict >/dev/null 2>&1 && rt_delivery_conflict 'moving the commits of a merged branch into a new task'
69
+ faults=''
70
+ command -v rt_assignment_unmet >/dev/null 2>&1 && rt_assignment_unmet '' 'a new task for these commits'
71
+ # The words after the first sentence: the misses that refuse taking the new task, or the way to it.
72
+ _rest="Create a new task for these commits — ${task_new:-npm run task:new} — then take its branch from the fresh base and move the commits there: git fetch origin && git checkout -b <task branch> origin/<base> && git cherry-pick <commits>."
73
+ [ -n "$faults" ] && _rest="The commits move into a new task, and taking it is refused now:
74
+ ${faults}"
75
+ refuse push "$(jq -cn --arg m "$_merged" --arg t "$_target" --arg r "$_rest" '{merged:$m, target:$t, rest:$r}')"
65
76
  }
@@ -95,5 +95,5 @@ rt_delivery_pull_draft() {
95
95
  $bases
96
96
  EOF
97
97
 
98
- fault "a draft into «${base}»: the pipeline «${file##*/}» wakes for a request only into $(printf '%s' "$bases" | tr '\n' ' ' | sed 's/ $//'), so no run will come and the draft will wait for nothing. Open the request ready, without --draft, and set the reviewer in the same call."
98
+ unmet_class pr_create_draft "a draft into «${base}»: the pipeline «${file##*/}» wakes for a request only into $(printf '%s' "$bases" | tr '\n' ' ' | sed 's/ $//'), so no run will come and the draft will wait for nothing. Open the request ready, without --draft, and set the reviewer in the same call."
99
99
  }
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # The rerun of the done steps before a PR opens, for the delivery guard. NOT a guard: it has no
3
+ # `rt-hook:` declaration and hooks into no agent event. The delivery guard sources it and calls
4
+ # `rt_delivery_rerun` on a PR opening, before it names what is unmet.
5
+ #
6
+ # Only the engine marks a step done, and the work-conduct guard refuses a hand mark. A script that
7
+ # writes the done mark and a step mark past both is caught here: every step the progress marks done
8
+ # is measured once more, whatever mark lies on disk, and a step that does not match keeps the PR
9
+ # closed. The engine puts a taken-apart task folder back from the history for the run.
10
+ #
11
+ # FAIL-OPEN: no node, no engine, a branch with no plan or a plan with no checks — nothing is judged.
12
+ #
13
+ # Requires: hooks/facts.sh
14
+
15
+ rt_delivery_rerun() {
16
+ command -v node >/dev/null 2>&1 || return 0
17
+ local engine="" candidate out code
18
+ for candidate in "$rt_hooks_dir/../checks/task-flow-script.mjs" "${CLAUDE_PROJECT_DIR:-.}/tools/task-flow-script.mjs"; do
19
+ [ -f "$candidate" ] && engine="$candidate" && break
20
+ done
21
+ [ -n "$engine" ] || return 0
22
+ local dir="${root:-${CLAUDE_PROJECT_DIR:-.}}" pinned run_path="$PATH"
23
+ # The checks run on the node the tree pins in .nvmrc, as they ran when measured: the session may
24
+ # carry another default, and a tree with an engines field refuses it. The same function names the
25
+ # directory for the push set.
26
+ # shellcheck disable=SC1091
27
+ command -v rt_node_pinned_dir >/dev/null 2>&1 || { [ -f "$rt_hooks_dir/facts.sh" ] && . "$rt_hooks_dir/facts.sh" 2>/dev/null; }
28
+ command -v rt_node_pinned_dir >/dev/null 2>&1 && pinned="$(rt_node_pinned_dir "$dir")"
29
+ [ -n "$pinned" ] && run_path="$pinned:$PATH"
30
+ out="$(cd "$dir" && PATH="$run_path" node "$engine" step --done --pr 2>&1)"
31
+ code=$?
32
+ [ "$code" -eq 0 ] && return 0
33
+ # The move names the steps by their numbers: a line of a step begins with it and does not end matched.
34
+ local steps move
35
+ steps="$(printf '%s\n' "$out" | awk '/^[0-9]+\.[0-9]+ / && !/· совпало$/ { printf "%s`node tools/task-flow-script.mjs step %s`", (n++ ? ", " : ""), $1 }')"
36
+ move="Fix what each step measures and run $steps again: it marks the step done when the check matches."
37
+ # No unmatched step: a live run holds the folder, or a check changed a tracked file — the lines say which.
38
+ [ -n "$steps" ] || move="The lines above name the cause: do what they say, then open the PR again."
39
+ printf '%s' "$out" | grep -q 'git revert --no-edit' &&
40
+ move="$move The task folder is taken apart: the command puts it back for the run, and a fix that lies in the folder takes the move the engine named above."
41
+ unmet steps_remeasured no "the done steps of the plan were measured once more before the PR, and not every one matched:
42
+ $(printf '%s\n' "$out" | sed 's/^/ /')
43
+ $move"
44
+ }
@@ -34,11 +34,76 @@ rt_delivery_branch_signature() {
34
34
  [ "$tree_email" = "$one" ] && human_email=1 && break
35
35
  done
36
36
  [ -n "$tree_email" ] && [ "$tree_email" != "$commit_email" ] && [ -z "$human_email" ] \
37
- && fault "the working copy signs commits as «${tree_email}», while the tree declared the email of the machine account «${commit_email}». The very first commit leaves under a foreign signature: git config user.email \"${commit_email}\"."
37
+ && unmet worktree_email_declared no "the working copy signs commits as «${tree_email}», while the tree declared the email of the machine account «${commit_email}». The very first commit leaves under a foreign signature: git config user.email \"${commit_email}\"."
38
38
  fi
39
39
  return 0
40
40
  }
41
41
 
42
+ # The commits of the contribution signed past the declaration, in two lists: `strangers` — a machine
43
+ # commit with a foreign mail, `unknown` — a mail the tree never named. Silent with no declared mail
44
+ # or no tip of the main branch. Used by the signature point below and by every refusal that names a
45
+ # commit as its move: such a commit is refused while the divergence stands, so the refusal names the
46
+ # rewrite first.
47
+ rt_signature_divergence() {
48
+ strangers=''
49
+ unknown=''
50
+ [ -n "$commit_email" ] || return 0
51
+ git rev-parse --verify --quiet "refs/remotes/origin/${main_branch}" >/dev/null 2>&1 || return 0
52
+ bot_login="${commit_email%%@*}"
53
+ bot_login="${bot_login##*+}"
54
+ while IFS="$(printf '\t')" read -r short author email; do
55
+ [ -z "$short" ] && continue
56
+ login="${email%%@*}"
57
+ login="${login##*+}"
58
+ [ "$author" = "$bot_login" ] || [ "$login" = "$bot_login" ] || continue
59
+ [ "$email" = "$commit_email" ] && continue
60
+ strangers="${strangers}${strangers:+, }${short} <${email}>"
61
+ done <<EOF
62
+ $(git log --format='%h%x09%an%x09%ae' "origin/${main_branch}..HEAD" 2>/dev/null)
63
+ EOF
64
+
65
+ # A commit under a record the tree has not declared used to pass silently: the helper judged
66
+ # only a commit that called itself the machine record, and five commits in a row under a foreign
67
+ # login did not fall under that condition at all. The hole is wider than the one the helper
68
+ # closes.
69
+ #
70
+ # This half is switched on by the tree, by naming the mails of people in a profile key: without
71
+ # it, demanding a known signature from every commit would refuse work done by a person with
72
+ # their own hands. Named — then the machine record and the listed people are known, and
73
+ # everything else is refused.
74
+ [ -n "${RT_HUMAN_EMAILS:-}" ] || return 0
75
+ while IFS="$(printf '\t')" read -r short author email; do
76
+ [ -z "$short" ] && continue
77
+ [ "$email" = "$commit_email" ] && continue
78
+ known=''
79
+ for one in $RT_HUMAN_EMAILS; do
80
+ [ "$email" = "$one" ] && known=1 && break
81
+ done
82
+ [ -n "$known" ] && continue
83
+ unknown="${unknown}${unknown:+, }${short} <${email}>"
84
+ done <<EOF
85
+ $(git log --format='%h%x09%an%x09%ae' "origin/${main_branch}..HEAD" 2>/dev/null)
86
+ EOF
87
+ return 0
88
+ }
89
+
90
+ # A sentence for a refusal whose fix is a commit while the copy stands on the main branch: the commit
91
+ # guard refuses every commit there, so the first move is a branch. A branch with no task number is
92
+ # judged by no delivery guard and is taken at once.
93
+ rt_signature_where() {
94
+ [ "$(rt_fact_branch)" = "${main_branch:-main}" ] || return 0
95
+ printf ' The copy stands on «%s», where every commit is refused: take a local branch first — git checkout -b <name> — and rewrite there.' "${main_branch:-main}"
96
+ }
97
+
98
+ # A sentence for a refusal that names a commit as its move: while the contribution carries a
99
+ # diverging signature, the signature point refuses that commit, so the rewrite is named first.
100
+ rt_signature_commit_note() {
101
+ rt_signature_divergence
102
+ [ -n "$strangers$unknown" ] || return 0
103
+ printf ' The branch carries commits under a foreign signature — %s: before this commit rewrite it, on your task branch — GIT_AUTHOR_EMAIL="%s" GIT_COMMITTER_EMAIL="%s" git commit --amend --no-edit --reset-author.' \
104
+ "${strangers}${strangers:+${unknown:+, }}${unknown}" "$commit_email" "$commit_email"
105
+ }
106
+
42
107
  rt_delivery_signature() {
43
108
  # --- the signature of a machine commit ----------------------------------------------------
44
109
  #
@@ -124,52 +189,24 @@ if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git([[:space:]]|\$)" \
124
189
  repair=1
125
190
  fi
126
191
 
127
- strangers=''
128
- while IFS="$(printf '\t')" read -r short author email; do
129
- [ -z "$short" ] && continue
130
- login="${email%%@*}"
131
- login="${login##*+}"
132
- [ "$author" = "$bot_login" ] || [ "$login" = "$bot_login" ] || continue
133
- [ "$email" = "$commit_email" ] && continue
134
- strangers="${strangers}${strangers:+, }${short} <${email}>"
135
- done <<EOF
136
- $(git log --format='%h%x09%an%x09%ae' "origin/${main_branch}..HEAD" 2>/dev/null)
137
- EOF
192
+ rt_signature_divergence
193
+ where="$(rt_signature_where)"
138
194
 
139
- # A commit under a record the tree has not declared used to pass silently: the helper
140
- # judged only a commit that called itself the machine record, and five commits in a row
141
- # under a foreign login did not fall under that condition at all. The hole is wider than the
142
- # one the helper closes.
143
- #
144
- # This half is switched on by the tree, by naming the mails of people in a profile key:
145
- # without it, demanding a known signature from every commit would refuse work done by a
146
- # person with their own hands. Named — then the machine record and the listed people are
147
- # known, and everything else is refused.
148
- unknown=''
149
- if [ -n "${RT_HUMAN_EMAILS:-}" ]; then
150
- while IFS="$(printf '\t')" read -r short author email; do
151
- [ -z "$short" ] && continue
152
- [ "$email" = "$commit_email" ] && continue
153
- known=''
154
- for one in $RT_HUMAN_EMAILS; do
155
- [ "$email" = "$one" ] && known=1 && break
156
- done
157
- [ -n "$known" ] && continue
158
- unknown="${unknown}${unknown:+, }${short} <${email}>"
159
- done <<EOF
160
- $(git log --format='%h%x09%an%x09%ae' "origin/${main_branch}..HEAD" 2>/dev/null)
161
- EOF
195
+ # The decision and the words come from the decision table; the hook names the diverging
196
+ # commits, where the copy stands and the ready-made rewrite.
197
+ if [ -z "$repair" ] && [ -n "$unknown$strangers" ]; then
198
+ fact commits_signed_declared no
199
+ [ -n "$where" ] && fact branch_is_main yes
200
+ if [ -n "$unknown" ]; then
201
+ _problem="a commit of the contribution is signed by an account the tree never declared. Known are the machine account ${commit_email} and the emails of people named by the profile; everything else the hosting attributes to whoever owns that address, and from inside the history the miss is invisible. Diverging: ${unknown}."
202
+ _last="GIT_AUTHOR_EMAIL=\"${commit_email}\" GIT_COMMITTER_EMAIL=\"${commit_email}\" git commit --amend --no-edit --reset-author"
203
+ else
204
+ _problem="a machine commit is signed by an email other than the one the tree declared. The hosting matches a service address by the number in it, and a commit with a foreign number it attributes to an outside person — from inside the miss is invisible, because the name of the account next to it is right. Diverging: ${strangers}. Declared: ${commit_email} — the email is taken from there, not typed from memory."
205
+ _last="GIT_AUTHOR_NAME=\"${bot_login}\" GIT_AUTHOR_EMAIL=\"${commit_email}\" GIT_COMMITTER_NAME=\"${bot_login}\" GIT_COMMITTER_EMAIL=\"${commit_email}\" git commit --amend --no-edit --reset-author"
206
+ fi
207
+ refuse "?commit" "$(jq -cn --arg p "$_problem" --arg w "$where" --arg l "$_last" --arg e "$commit_email" --arg m "$main_branch" \
208
+ '{problem:$p, where:$w, last:$l, commit_email:$e, main_branch:$m}')"
162
209
  fi
163
-
164
- [ -n "$unknown" ] && [ -z "$repair" ] \
165
- && deny "BLOCKED: a commit of the contribution is signed by an account the tree never declared. Known are the machine account ${commit_email} and the emails of people named by the profile; everything else the hosting attributes to whoever owns that address, and from inside the history the miss is invisible. Diverging: ${unknown}. Rewrite the signature before the push, after it only a force push fixes this:
166
- the last commit — GIT_AUTHOR_EMAIL=\"${commit_email}\" GIT_COMMITTER_EMAIL=\"${commit_email}\" git commit --amend --no-edit --reset-author
167
- the whole contribution of the branch — git filter-branch -f --env-filter 'GIT_AUTHOR_EMAIL=\"${commit_email}\"; GIT_COMMITTER_EMAIL=\"${commit_email}\"' origin/${main_branch}..HEAD"
168
-
169
- [ -n "$strangers" ] && [ -z "$repair" ] \
170
- && deny "BLOCKED: a machine commit is signed by an email other than the one the tree declared. The hosting matches a service address by the number in it, and a commit with a foreign number it attributes to an outside person — from inside the miss is invisible, because the name of the account next to it is right. Diverging: ${strangers}. Declared: ${commit_email} — the email is taken from there, not typed from memory. Rewrite the signature before the push, after it only a force push fixes this:
171
- the last commit — GIT_AUTHOR_NAME=\"${bot_login}\" GIT_AUTHOR_EMAIL=\"${commit_email}\" GIT_COMMITTER_NAME=\"${bot_login}\" GIT_COMMITTER_EMAIL=\"${commit_email}\" git commit --amend --no-edit --reset-author
172
- the whole contribution of the branch — git filter-branch -f --env-filter 'GIT_AUTHOR_EMAIL=\"${commit_email}\"; GIT_COMMITTER_EMAIL=\"${commit_email}\"' origin/${main_branch}..HEAD"
173
210
  fi
174
211
  fi
175
212
  # This point has no exit of its own: a push happens to be a compound command too, and its second
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env bash
2
+ # The task of a branch, for the delivery guard: the task exists, is open, stands in the work queue,
3
+ # has an assignee and a numbered title, and is not left in the first column.
4
+ #
5
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The delivery guard
6
+ # sources it — one tier of its verdict, moved out when the guard reached its length limit. It reads
7
+ # the guard's variables (`task_new`, `board_check`, `task_bot`, `task_move`, `backlog_column`) and
8
+ # adds what is unmet by the guard's `fault`; it refuses nothing by itself.
9
+ #
10
+ # Parameters: the task number, the words that name where the number came from, and `yes` when the
11
+ # column is judged.
12
+
13
+ check_task() {
14
+ number="$1"
15
+ where="$2"
16
+ # The column is asked about where it should already have been moved. At branch creation it has
17
+ # not been moved yet — the work pattern moves the column with the next command — and the
18
+ # requirement here would refuse the very first command of the work together with the one that
19
+ # lifts it.
20
+ judge_column="${3:-no}"
21
+ rt_needs rt_task_state git-guard-delivery || return 0
22
+ state="$(rt_delivery_task_state "$number" 2>/dev/null)" || return 0
23
+ [ -z "$state" ] && return 0
24
+
25
+ printf '%s' "$state" | jq -e '.exists' >/dev/null 2>&1 \
26
+ || unmet task_exists no "${where} refers to the task #${number}, which does not exist. Check the number or create the task — ${task_new}."
27
+ printf '%s' "$state" | jq -e '.open' >/dev/null 2>&1 \
28
+ || unmet task_open no "the task #${number} is closed, and a task has one branch. Work behind a closed task is created as a new task — ${task_new}."
29
+ printf '%s' "$state" | jq -e '.onBoard' >/dev/null 2>&1 \
30
+ || unmet task_on_board no "the task #${number} is not in the work queue — the edit behind it is invisible. The queue is not bound to the repository and does not take a task by itself; add it and check — ${board_check}."
31
+ printf '%s' "$state" | jq -e '.assigned' >/dev/null 2>&1 \
32
+ || unmet task_assigned no "the task #${number} has no assignee — by the work queue there is no seeing who took it. Set the assignee${task_bot:+: }${task_bot}."
33
+ printf '%s' "$state" | jq -e '.numbered' >/dev/null 2>&1 \
34
+ || unmet task_title_numbered no "the title of the task #${number} does not start with its number — one work would have to be recognised by the text of the title. Fix the title and check the queue — ${board_check}."
35
+
36
+ # The task column. The work queue answer has been giving it for a long time, and nobody read it:
37
+ # the column was judged only by the queue audit, that is, already after the PR is opened. A task
38
+ # left in the first column reads through the queue as not taken — while the work is done and put
39
+ # out.
40
+ if [ -n "$backlog_column" ] && [ "$judge_column" = "yes" ]; then
41
+ column="$(printf '%s' "$state" | jq -r '.status // empty' 2>/dev/null)"
42
+ [ "$column" = "$backlog_column" ] \
43
+ && unmet task_column_taken no "the task #${number} stands in the column «${column}» — by the work queue it is not taken, though the work on it is going. Move it: ${task_move}."
44
+ fi
45
+
46
+ return 0
47
+ }