@rt-tools/agent-kit 0.24.0 → 0.27.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 (312) hide show
  1. package/assets/agents/business-analyst.md +51 -50
  2. package/assets/agents/cargo-writer.md +54 -0
  3. package/assets/agents/conscience.md +37 -35
  4. package/assets/agents/project-manager.md +49 -48
  5. package/assets/agents/prose-editor.md +31 -29
  6. package/assets/agents/qa-engineer.md +50 -48
  7. package/assets/agents/rules-reviewer.md +63 -58
  8. package/assets/agents/skill-curator.md +83 -78
  9. package/assets/agents/spec-critic.md +34 -29
  10. package/assets/agents/spec-writer.md +35 -32
  11. package/assets/agents/strict-teacher.md +39 -37
  12. package/assets/checks/archive-age.mjs +48 -28
  13. package/assets/checks/archive-prune.mjs +16 -14
  14. package/assets/checks/board-epic-link.github.mjs +29 -0
  15. package/assets/checks/board-epics.github.mjs +286 -49
  16. package/assets/checks/board-folders.mjs +61 -0
  17. package/assets/checks/board-gh.github.mjs +35 -26
  18. package/assets/checks/board-long-work.github.mjs +29 -25
  19. package/assets/checks/board-paths.github.mjs +21 -16
  20. package/assets/checks/board-pull-state.github.mjs +168 -0
  21. package/assets/checks/board-runs.github.mjs +45 -43
  22. package/assets/checks/board-task-dirs.github.mjs +98 -0
  23. package/assets/checks/board-titles.github.mjs +19 -17
  24. package/assets/checks/board.github.mjs +133 -194
  25. package/assets/checks/check-archive-age.mjs +23 -19
  26. package/assets/checks/check-board.github.mjs +131 -263
  27. package/assets/checks/check-descriptions.mjs +30 -29
  28. package/assets/checks/check-doc-paths.mjs +91 -88
  29. package/assets/checks/check-dupes.mjs +84 -80
  30. package/assets/checks/check-file-size.mjs +74 -71
  31. package/assets/checks/check-glossary.mjs +47 -37
  32. package/assets/checks/check-hook-scope.mjs +30 -27
  33. package/assets/checks/check-lib-layers.mjs +22 -21
  34. package/assets/checks/check-profile-drift.mjs +48 -43
  35. package/assets/checks/check-prose-style.mjs +138 -39
  36. package/assets/checks/check-push-gate.mjs +53 -50
  37. package/assets/checks/check-reuse.mjs +50 -40
  38. package/assets/checks/check-schema-drift.mjs +104 -84
  39. package/assets/checks/check-specs.mjs +155 -134
  40. package/assets/checks/check-state-next.mjs +66 -52
  41. package/assets/checks/check-states.mjs +32 -30
  42. package/assets/checks/check-styles.mjs +52 -51
  43. package/assets/checks/check-turn-map.mjs +54 -46
  44. package/assets/checks/epic-table.github.mjs +268 -0
  45. package/assets/checks/lib-boundaries.mjs +32 -30
  46. package/assets/checks/lib-common.mjs +30 -29
  47. package/assets/checks/lib-domains.mjs +34 -34
  48. package/assets/checks/lib-manifests.mjs +17 -15
  49. package/assets/checks/lib-reexports.mjs +18 -18
  50. package/assets/checks/rt-kit-checks.config.mjs +187 -142
  51. package/assets/checks/signals.mjs +43 -39
  52. package/assets/checks/spec-anchors.mjs +114 -87
  53. package/assets/checks/spec-common.mjs +128 -84
  54. package/assets/checks/spec-contract.mjs +30 -30
  55. package/assets/checks/spec-proposed.mjs +27 -24
  56. package/assets/checks/spec-scenarios.mjs +51 -28
  57. package/assets/checks/specs-for.mjs +214 -0
  58. package/assets/checks/task-new.github.mjs +315 -61
  59. package/assets/commands/feedback.md +65 -59
  60. package/assets/commands/next-session.md +64 -57
  61. package/assets/commands/night.md +115 -0
  62. package/assets/commands/skill-curator.md +83 -79
  63. package/assets/defaults/gate-map.sh +108 -97
  64. package/assets/defaults/project.sh +232 -185
  65. package/assets/defaults/shell.sh +73 -68
  66. package/assets/defaults/turn-map.md +47 -44
  67. package/assets/docs/GLOSSARY.md +142 -65
  68. package/assets/hooks/browser-device-id.sh +16 -12
  69. package/assets/hooks/browser-guard-device-id.sh +34 -28
  70. package/assets/hooks/browser-guard-no-asking.sh +5 -4
  71. package/assets/hooks/browser-guard-no-listing.sh +12 -11
  72. package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
  73. package/assets/hooks/browser-guard-require-select.sh +34 -23
  74. package/assets/hooks/claim-guard.sh +62 -56
  75. package/assets/hooks/commit-msg.sh +14 -10
  76. package/assets/hooks/conscience-guard.sh +91 -45
  77. package/assets/hooks/constitution-index.sh +16 -16
  78. package/assets/hooks/deny-tail.sh +28 -26
  79. package/assets/hooks/dev-server-guard.sh +50 -43
  80. package/assets/hooks/dispatch.sh +60 -46
  81. package/assets/hooks/docs-guard.sh +100 -91
  82. package/assets/hooks/epic-over.sh +49 -0
  83. package/assets/hooks/epic-stop-guard.sh +108 -0
  84. package/assets/hooks/exam-guard.sh +105 -93
  85. package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
  86. package/assets/hooks/git-guard-delivery-draft.sh +48 -38
  87. package/assets/hooks/git-guard-delivery-epic.sh +167 -0
  88. package/assets/hooks/git-guard-delivery-folder.sh +50 -43
  89. package/assets/hooks/git-guard-delivery-signature.sh +119 -53
  90. package/assets/hooks/git-guard-delivery.sh +223 -183
  91. package/assets/hooks/git-guard-main.sh +38 -34
  92. package/assets/hooks/git-guard-push-tests.sh +99 -87
  93. package/assets/hooks/glossary-load.sh +23 -22
  94. package/assets/hooks/grill-gate-ask.sh +12 -11
  95. package/assets/hooks/grill-gate.sh +94 -87
  96. package/assets/hooks/guard-note.sh +20 -19
  97. package/assets/hooks/handoff-entry-guard.sh +45 -25
  98. package/assets/hooks/handoff-write.sh +74 -67
  99. package/assets/hooks/hook-input.sh +67 -58
  100. package/assets/hooks/lint-after-edit.sh +95 -61
  101. package/assets/hooks/observe.sh +28 -26
  102. package/assets/hooks/override-write-guard.sh +23 -21
  103. package/assets/hooks/postmortem-guard.sh +42 -39
  104. package/assets/hooks/profile-check.sh +22 -20
  105. package/assets/hooks/proposal-guard.sh +57 -49
  106. package/assets/hooks/prose-style-guard.sh +49 -24
  107. package/assets/hooks/qa-dataid-guard.sh +83 -58
  108. package/assets/hooks/rerun-guard.sh +31 -30
  109. package/assets/hooks/reuse-first-guard.sh +108 -87
  110. package/assets/hooks/roles.sh +14 -14
  111. package/assets/hooks/rule-article.sh +39 -34
  112. package/assets/hooks/rule-source-guard.sh +47 -42
  113. package/assets/hooks/skill-gate-layers.sh +63 -57
  114. package/assets/hooks/skill-gate-rearm.sh +15 -8
  115. package/assets/hooks/skill-gate.sh +89 -81
  116. package/assets/hooks/skill-loaded.sh +10 -6
  117. package/assets/hooks/sql-guard-parse.sh +71 -66
  118. package/assets/hooks/sql-guard-request.sh +51 -46
  119. package/assets/hooks/sql-guard-target.sh +60 -51
  120. package/assets/hooks/sql-guard-write.sh +87 -79
  121. package/assets/hooks/sql-guard.sh +52 -47
  122. package/assets/hooks/stand-login-guard.sh +43 -37
  123. package/assets/hooks/task-context-load.sh +60 -55
  124. package/assets/hooks/task-flow-context.sh +87 -69
  125. package/assets/hooks/task-flow-draft-guard.sh +55 -48
  126. package/assets/hooks/task-flow-guard.sh +67 -64
  127. package/assets/hooks/turn-entry-load.sh +39 -32
  128. package/assets/hooks/turn-exit-guard.sh +260 -204
  129. package/assets/hooks/turn-exit-patterns.sh +63 -0
  130. package/assets/hooks/utf8.sh +14 -11
  131. package/assets/hooks/waiting-turn-guard.sh +104 -94
  132. package/assets/hooks/window-fill-guard.sh +70 -62
  133. package/assets/hooks/work-start-guard.sh +52 -49
  134. package/assets/hooks/write-targets.sh +99 -44
  135. package/assets/laws/autonomous-work.md +29 -27
  136. package/assets/laws/code-structure.md +31 -30
  137. package/assets/laws/delivery.md +170 -137
  138. package/assets/laws/entity-editing.md +52 -50
  139. package/assets/laws/entity-models.md +14 -13
  140. package/assets/laws/frontend-application.md +39 -38
  141. package/assets/laws/lib-imports.md +27 -27
  142. package/assets/laws/lists.md +31 -29
  143. package/assets/laws/navigation.md +37 -37
  144. package/assets/laws/observability.md +41 -40
  145. package/assets/laws/project-documentation.md +106 -99
  146. package/assets/laws/reuse-first.md +31 -29
  147. package/assets/laws/shared-code.md +27 -27
  148. package/assets/laws/verifiability.md +131 -124
  149. package/assets/laws/work-conduct.md +250 -244
  150. package/assets/patterns/admin-lists-screen.md +72 -69
  151. package/assets/patterns/admin-nav-item.md +51 -46
  152. package/assets/patterns/angular-patterns-state.md +32 -31
  153. package/assets/patterns/api-layer-pair.md +33 -31
  154. package/assets/patterns/autonomous-work-run.md +50 -49
  155. package/assets/patterns/browser-verification-measure.md +124 -88
  156. package/assets/patterns/browser-verification-stand.md +169 -157
  157. package/assets/patterns/component-structure-new.md +51 -42
  158. package/assets/patterns/dependencies-upgrade.md +55 -39
  159. package/assets/patterns/doc-style-human.md +55 -37
  160. package/assets/patterns/doc-style-sweep.md +82 -79
  161. package/assets/patterns/doc-style-trace.md +87 -81
  162. package/assets/patterns/doc-style-write.md +130 -122
  163. package/assets/patterns/entity-aside.md +77 -63
  164. package/assets/patterns/entity-models-new.md +37 -37
  165. package/assets/patterns/entity-store.md +33 -33
  166. package/assets/patterns/git-workflow-commit.azure.md +94 -87
  167. package/assets/patterns/git-workflow-commit.github.md +160 -142
  168. package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
  169. package/assets/patterns/git-workflow-docker.md +165 -147
  170. package/assets/patterns/git-workflow-freshness.md +45 -45
  171. package/assets/patterns/git-workflow-merge.md +102 -94
  172. package/assets/patterns/git-workflow-migration.md +54 -52
  173. package/assets/patterns/git-workflow-pr-ready.md +57 -56
  174. package/assets/patterns/git-workflow-pr.azure.md +127 -122
  175. package/assets/patterns/git-workflow-pr.github.md +186 -177
  176. package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
  177. package/assets/patterns/git-workflow-restart.md +35 -31
  178. package/assets/patterns/git-workflow-secrets.md +80 -73
  179. package/assets/patterns/git-workflow-stack.md +136 -107
  180. package/assets/patterns/lib-layers-move.md +62 -53
  181. package/assets/patterns/lib-layers-new.md +59 -45
  182. package/assets/patterns/observability-record.md +72 -67
  183. package/assets/patterns/platform-access-di.md +31 -29
  184. package/assets/patterns/reuse-first-extend.md +66 -61
  185. package/assets/patterns/shared-code-new.md +39 -38
  186. package/assets/patterns/spec-driven-domain.md +161 -151
  187. package/assets/patterns/spec-driven-rule.md +179 -168
  188. package/assets/patterns/spec-driven-sweep.md +41 -39
  189. package/assets/patterns/status-report-table.github.md +48 -36
  190. package/assets/patterns/styling-bem-component.md +42 -42
  191. package/assets/patterns/styling-bem-layout.md +39 -34
  192. package/assets/patterns/styling-bem-sheet.md +59 -58
  193. package/assets/patterns/task-flow-archive.md +222 -215
  194. package/assets/patterns/task-flow-close.md +234 -203
  195. package/assets/patterns/task-flow-handoff.md +154 -145
  196. package/assets/patterns/task-flow-resume.md +138 -133
  197. package/assets/patterns/task-flow-start.md +228 -202
  198. package/assets/patterns/testing-e2e.md +102 -101
  199. package/assets/patterns/testing-unit.md +77 -70
  200. package/assets/patterns/ts-procedure.md +32 -29
  201. package/assets/patterns/turn-entry-map.md +50 -48
  202. package/assets/pitfalls/agent-kit.md +172 -142
  203. package/assets/pitfalls/doc-style.md +96 -91
  204. package/assets/pitfalls/git-workflow.azure.md +49 -46
  205. package/assets/pitfalls/git-workflow.github.md +270 -234
  206. package/assets/pitfalls/git-workflow.gitlab.md +49 -45
  207. package/assets/pitfalls/spec-driven.md +73 -71
  208. package/assets/pitfalls/styling-bem.md +46 -40
  209. package/assets/pitfalls/task-flow.md +262 -246
  210. package/assets/pitfalls/testing.md +99 -92
  211. package/assets/pitfalls/turn-conduct.md +96 -81
  212. package/assets/rules/angular-patterns.md +81 -80
  213. package/assets/rules/api-layer.md +77 -74
  214. package/assets/rules/autonomous-work.md +87 -74
  215. package/assets/rules/browser-verification.md +223 -214
  216. package/assets/rules/component-structure.md +72 -69
  217. package/assets/rules/dependencies.md +74 -67
  218. package/assets/rules/deploy-flow.azure.md +118 -108
  219. package/assets/rules/deploy-flow.github.md +145 -135
  220. package/assets/rules/deploy-flow.gitlab.md +120 -110
  221. package/assets/rules/doc-style.md +201 -173
  222. package/assets/rules/entity-conventions.needs-admin.md +81 -79
  223. package/assets/rules/entity-models.md +73 -70
  224. package/assets/rules/git-workflow.azure.md +224 -228
  225. package/assets/rules/git-workflow.github.md +268 -239
  226. package/assets/rules/git-workflow.gitlab.md +218 -217
  227. package/assets/rules/lib-layers.md +85 -86
  228. package/assets/rules/lists.md +101 -97
  229. package/assets/rules/navigation.md +78 -78
  230. package/assets/rules/observability.needs-app.md +165 -153
  231. package/assets/rules/platform-access.md +76 -75
  232. package/assets/rules/reuse-first.md +153 -143
  233. package/assets/rules/shared-code.md +82 -79
  234. package/assets/rules/spec-driven.md +279 -260
  235. package/assets/rules/status-report.md +62 -58
  236. package/assets/rules/styling-bem.md +81 -77
  237. package/assets/rules/task-flow.md +303 -270
  238. package/assets/rules/testing.md +224 -209
  239. package/assets/rules/turn-conduct.md +262 -258
  240. package/assets/rules/turn-entry.md +92 -87
  241. package/assets/rules/typescript-conventions.md +94 -88
  242. package/assets/samples/specs/_template/spec.md +47 -47
  243. package/assets/samples/tasks/_template/grill.md +20 -20
  244. package/assets/samples/tasks/_template/plan.md +32 -30
  245. package/assets/samples/tasks/_template/progress.md +16 -16
  246. package/assets/skills/agent-kit-extend.md +129 -113
  247. package/assets/skills/agent-kit.md +259 -233
  248. package/assets/skills/write-a-skill.md +76 -71
  249. package/assets/templates/findings.md +19 -19
  250. package/assets/templates/gate-map.sh +16 -14
  251. package/assets/templates/implementation.md +28 -27
  252. package/assets/templates/pattern.md +17 -17
  253. package/assets/templates/pitfalls.md +6 -6
  254. package/assets/templates/postmortem.md +24 -23
  255. package/assets/templates/project.sh +24 -24
  256. package/assets/templates/proposal.md +62 -60
  257. package/assets/templates/rule.md +38 -38
  258. package/assets/workflows/feature.js +46 -46
  259. package/assets/workflows/plan.js +54 -54
  260. package/bin/agent-kit.d.ts.map +1 -1
  261. package/bin/agent-kit.js +8 -1
  262. package/bin/agent-kit.js.map +1 -1
  263. package/lib/cargo-prose.d.ts +41 -0
  264. package/lib/cargo-prose.d.ts.map +1 -0
  265. package/lib/cargo-prose.js +88 -0
  266. package/lib/cargo-prose.js.map +1 -0
  267. package/lib/cargo.d.ts +12 -1
  268. package/lib/cargo.d.ts.map +1 -1
  269. package/lib/cargo.js +8 -2
  270. package/lib/cargo.js.map +1 -1
  271. package/lib/catalog.d.ts +2 -0
  272. package/lib/catalog.d.ts.map +1 -1
  273. package/lib/catalog.js +4 -3
  274. package/lib/catalog.js.map +1 -1
  275. package/lib/commands.d.ts.map +1 -1
  276. package/lib/commands.js +5 -2
  277. package/lib/commands.js.map +1 -1
  278. package/lib/companion.js +3 -2
  279. package/lib/companion.js.map +1 -1
  280. package/lib/enroll.d.ts +7 -1
  281. package/lib/enroll.d.ts.map +1 -1
  282. package/lib/enroll.js +12 -3
  283. package/lib/enroll.js.map +1 -1
  284. package/lib/fate.d.ts +29 -0
  285. package/lib/fate.d.ts.map +1 -0
  286. package/lib/fate.js +147 -0
  287. package/lib/fate.js.map +1 -0
  288. package/lib/override-marks.d.ts +7 -0
  289. package/lib/override-marks.d.ts.map +1 -1
  290. package/lib/override-marks.js +14 -0
  291. package/lib/override-marks.js.map +1 -1
  292. package/lib/plan.d.ts +11 -0
  293. package/lib/plan.d.ts.map +1 -1
  294. package/lib/plan.js +10 -1
  295. package/lib/plan.js.map +1 -1
  296. package/lib/ship.d.ts +29 -9
  297. package/lib/ship.d.ts.map +1 -1
  298. package/lib/ship.js +44 -2
  299. package/lib/ship.js.map +1 -1
  300. package/lib/shipment.d.ts.map +1 -1
  301. package/lib/shipment.fixture.d.ts +8 -1
  302. package/lib/shipment.fixture.d.ts.map +1 -1
  303. package/lib/shipment.fixture.js +9 -0
  304. package/lib/shipment.fixture.js.map +1 -1
  305. package/lib/shipment.js +38 -5
  306. package/lib/shipment.js.map +1 -1
  307. package/lib/sync.d.ts.map +1 -1
  308. package/lib/sync.js +45 -11
  309. package/lib/sync.js.map +1 -1
  310. package/package.json +1 -1
  311. package/rt-tools-agent-kit-0.27.0.tgz +0 -0
  312. package/rt-tools-agent-kit-0.24.0.tgz +0 -0
@@ -1,44 +1,52 @@
1
1
  #!/usr/bin/env bash
2
- # Снятие черновика для гарда поставки: есть ли у заявки разбор, не конфликтует ли она и той ли
3
- # записью открыта.
2
+ # Leaving draft, for the delivery guard: does the PR have a review, does it conflict, and was it
3
+ # opened by the right account.
4
4
  #
5
- # Строки `# rt-hook:` здесь нет намеренно: событие и образец вызова объявляет сам гард, а
6
- # помощник рядом хуком не регистрируется и в одиночку ничего не решает. Он зовётся из гарда и
7
- # пользуется его же переменными — командой, корнем дерева, машинной записью — и его отказом.
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.
8
7
  #
9
- # Вынесен он отсюда потому, что гард дорос до предела длины: снятие черновика среди его
10
- # предметов самое отдельное — своя точка проверки, свой сетевой ярус, свои три отказа.
8
+ # There is deliberately no `# rt-hook:` line here: the event and the call pattern are declared by
9
+ # the guard itself, while a helper next to it registers as no hook and decides nothing on its own.
10
+ # It is called from the guard and uses the guard's own variables — the command, the tree root, the
11
+ # machine account — and the guard's refusal.
12
+ #
13
+ # It was moved out because the guard grew to the length limit: leaving draft is the most separate
14
+ # of its subjects — its own check point, its own network tier, its own three refusals.
11
15
 
12
16
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
13
17
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
14
18
 
15
19
  rt_delivery_draft_ready() {
16
- # --- снятие черновика --------------------------------------------------------------------
20
+ # --- leaving draft ----------------------------------------------------------------------
17
21
  #
18
- # Ревьювера до этой правки не спрашивал никто. Он стоял прозой в правиле, а хостинг запрос
19
- # разбора на самого себя принимает молча и не создаёт: разбор при этом выглядит запрошенным.
20
- # Раньше снятия черновика спросить негде — до открытия заявки ревьювера нет вовсе, — а само
21
- # снятие и есть тот ход, которым работа объявляется готовой.
22
+ # Before this edit nobody asked for a reviewer. He stood as prose in the rule, while the
23
+ # hosting accepts a review request on oneself silently and creates none: the review looks
24
+ # requested all the same. There is nowhere to ask earlier than leaving draft — before the PR
25
+ # is opened there is no reviewer at all — and leaving draft is itself the move that declares
26
+ # the work ready.
22
27
  #
23
- # Ярус сетевой, и молчит он так же, как ярус состояния задачи: нет ответа — нет требования.
28
+ # The tier is a network one, and it stays silent the same way as the task state tier: no
29
+ # answer — no demand.
24
30
  #
25
- # Возврат заявки в черновик под требование не подпадает: он делает ровно то, чего гард и
26
- # добивается, — снимает с работы вид готовой.
31
+ # Returning a PR to draft does not fall under the demand: it does exactly what the guard is
32
+ # after — it takes the look of readiness off the work.
27
33
  if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}(gh[[:space:]]+pr[[:space:]]+ready|glab[[:space:]]+mr[[:space:]]+update[^|;&]*--ready)([[:space:]]|\$)" \
28
34
  && ! printf '%s' "$cmd" | grep -q -- '--undo'; then
29
- # Ссылка на заявку необязательна: без неё клиент берёт заявку текущей ветки, и это самая
30
- # короткая форма вызова. Требовать номер значило бы снимать всё требование одним пробелом.
31
- # Поэтому берётся первый довод, каким бы он ни был — номер, адрес или имя ветки, — а его
32
- # отсутствие означает «спроси про текущую ветку».
35
+ # A reference to the PR is optional: without it the client takes the PR of the current
36
+ # branch, and that is the shortest form of the call. Demanding a number would mean lifting
37
+ # the whole demand with a single space. So the first argument is taken, whatever it is —
38
+ # a number, an address or a branch name — and its absence means "ask about the current
39
+ # branch".
33
40
  pull_ref="$(printf '%s' "$cmd" | sed -nE 's/.*(gh[[:space:]]+pr[[:space:]]+ready|glab[[:space:]]+mr[[:space:]]+update)[[:space:]]+([^[:space:];&|-][^[:space:];&|]*).*/\2/p' | head -1)"
34
41
  if rt_needs rt_pull_state git-guard-delivery; then
35
42
  pull="$(cd "$root" && rt_pull_state "$pull_ref" 2>/dev/null)" || pull=''
36
43
  if [ -n "$pull" ] && printf '%s' "$pull" | jq -e '.exists' >/dev/null 2>&1; then
37
- # Номер берётся из ответа, а если его там нет — из самой команды: заявка,
38
- # названная адресом или именем ветки, в отказе должна остаться узнаваемой.
44
+ # The number is taken from the answer, and if it is not there — from the command
45
+ # itself: a PR named by an address or a branch name must stay recognisable in the
46
+ # refusal.
39
47
  pull_name="$(printf '%s' "$pull" | jq -r '.number // empty' 2>/dev/null)"
40
- # Номер пишется с решёткой, а имя ветки или адрес — в кавычках: решётка перед
41
- # адресом читается как опечатка, а не как ссылка на заявку.
48
+ # A number is written with a hash, and a branch name or an address in quotes: a
49
+ # hash before an address reads as a typo, not as a reference to a PR.
42
50
  [ -z "$pull_name" ] && pull_name="$pull_ref"
43
51
  case "$pull_name" in
44
52
  '') ;;
@@ -46,31 +54,33 @@ rt_delivery_draft_ready() {
46
54
  *) pull_name=" #${pull_name}" ;;
47
55
  esac
48
56
  printf '%s' "$pull" | jq -e '.reviewed' >/dev/null 2>&1 \
49
- || fault "у заявки${pull_name} нет разбора: ревьювер не запрошен и отзыва никто не оставлял. Снятый черновик читается как «можно вливать», а вливать некому — назначь ревьювера и повтори."
57
+ || fault "the request${pull_name} has no review: no reviewer was requested and nobody left a review. A lifted draft reads as «ready to merge», and there is nobody to merge — set a reviewer and repeat."
50
58
 
51
- # Конфликт приезжает в отданную заявку чужим слиянием, без единого действия её
52
- # автора: основание, проверенное на открытии, к моменту снятия черновика уже
53
- # вчерашнее. Снятый черновик читается как «можно вливать», а вливать нечего —
54
- # владелец открывает заявку и находит там конфликт. Молчание при неизвестной
55
- # сливаемости остаётся: хостинг считает её заново после каждой правки главной ветки,
56
- # и «ещё не посчитано» — не «конфликтует».
59
+ # A conflict arrives into a handed-over PR through someone else's merge, without
60
+ # a single action by its author: the base checked at opening is yesterday's by the
61
+ # time draft is left. A PR out of draft reads as "ready to merge", and there is
62
+ # nothing to merge — the owner opens the PR and finds a conflict there. Silence on
63
+ # unknown mergeability stays: the hosting recomputes it after every edit of the
64
+ # main branch, and "not computed yet" is not "conflicts".
57
65
  printf '%s' "$pull" | jq -e '.conflicting' >/dev/null 2>&1 \
58
- && fault "заявка${pull_name} конфликтует с главной веткой. Влей её в свою ветку, разбери конфликт и повтори: снятый черновик читается как «можно вливать», а слить эту заявку нельзя."
66
+ && fault "the request${pull_name} conflicts with the main branch. Merge it into your branch, resolve the conflict and repeat: a lifted draft reads as «ready to merge», and this request cannot be merged."
59
67
 
60
- # Автор заявки. На открытии судить было нечем, кроме текста команды: личность вызова
61
- # приходит окружением. Здесь она уже названа хостингом, и это последний ход, где
62
- # промах ещё исправим — после снятия черновика заявку вливают, а переоткрыть влитую
63
- # нельзя. Дерево, не назвавшее машинной записи, автора не судит.
68
+ # The author of the PR. At opening there was nothing to judge by but the text of
69
+ # the command: the identity of the call comes from the environment. Here it is
70
+ # already named by the hosting, and this is the last move where the miss is still
71
+ # fixable — after draft is left the PR gets merged, and a merged one cannot be
72
+ # reopened. A tree that named no machine account does not judge the author.
64
73
  if [ -n "$task_bot" ]; then
65
74
  pull_author="$(printf '%s' "$pull" | jq -r '.author // empty' 2>/dev/null)"
66
75
  [ -n "$pull_author" ] && [ "$pull_author" != "$task_bot" ] \
67
- && fault "заявку${pull_name} открыла запись «${pull_author}», а не машинная «${task_bot}». Автор заявки её ревьювером не бывает, и разбор ей назначить нечем. Автора не сменить — закрой заявку и открой заново${pull_token_hint:+, подставив токен: ${pull_token_hint} …}."
76
+ && fault "the request${pull_name} was opened by the account «${pull_author}», not the machine one «${task_bot}». The author of a request is never its reviewer, and there is nothing to assign the review to. The author cannot be changed — close the request and open it anew${pull_token_hint:+, substituting the token: ${pull_token_hint} …}."
68
77
  fi
69
78
  fi
70
79
  fi
71
80
 
72
- # Папка задачи: тот же предмет, что на открытии и на слиянии, третьим рубежом. Условие
73
- # местное — оно читает ветку, а не хостинг, — и потому стоит вне сетевого яруса выше.
81
+ # The task folder: the same subject as at opening and at the merge, as a third line. The
82
+ # condition is local — it reads the branch, not the hosting — and therefore stands outside
83
+ # the network tier above.
74
84
  command -v rt_delivery_ready_folder >/dev/null 2>&1 && rt_delivery_ready_folder
75
85
 
76
86
  deny_faults
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env bash
2
+ # Delivery conditions about the epic of a task. NOT a guard: it has no `rt-hook:` declaration and
3
+ # it hooks into no agent event. The delivery guard sources it — the same way it sources the task
4
+ # folder conditions and the signature.
5
+ #
6
+ # Why a file of its own. The subject is one — the epic a task hangs on — and it shows at two call
7
+ # sites: the base of a new branch and the base of the request. Together with the command parsing,
8
+ # the signature, the folder and the work queue it would take the guard past the file length limit,
9
+ # and the guard cannot be split by event: it is one whole, and its command parsing is shared.
10
+ #
11
+ # WHAT IS HERE. Two calls, both called from the delivery guard, where `fault`, `main_branch` and
12
+ # the profile calls are already declared. The helper reads neither the input nor the settings.
13
+
14
+ # The branch of an epic by its number: the same form as a task branch — the profile pulls the
15
+ # number out of a name, and the epic branch is the one whose number is the epic's.
16
+ #
17
+ # The branch is looked for among the remote refs, not the local ones: a branch that exists only on
18
+ # somebody's machine is a base nobody else has, and the branches of the tasks are taken from it.
19
+ # Several matched — none is chosen: two branches of one epic is a discrepancy of its own, and a
20
+ # guess here would name a base at random.
21
+ rt_epic_branch() {
22
+ _epic="$1"
23
+ _found=''
24
+ for _ref in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin 2>/dev/null); do
25
+ _name="${_ref#origin/}"
26
+ [ "$(rt_task_branch_number "$_name" 2>/dev/null)" = "$_epic" ] || continue
27
+ _found="${_found}${_found:+ }${_name}"
28
+ done
29
+ printf '%s' "$_found"
30
+ }
31
+
32
+ # The base of a new task branch against the branch of its epic.
33
+ #
34
+ # The task branch is taken from the branch of the epic, and a branch taken from the main one leaves
35
+ # the epic half merged before its last task is done: the merge of the epic then carries nothing of
36
+ # that task. The guard used to judge the base against the main branch alone and let this through in
37
+ # silence.
38
+ #
39
+ # The freshness of the main branch is not dropped, it is moved: it is asked of the branch of the
40
+ # epic, and there it is fixed by one merge — while asked of the base of the task branch it made the
41
+ # executor either wait for the epic branch to catch up or take the base from the main one, that is,
42
+ # do exactly what this condition forbids.
43
+ #
44
+ # Arguments: the number of the epic, the ref the branch grows from, the name of the new branch.
45
+ rt_epic_base() {
46
+ _epic="$1"
47
+ _base_ref="$2"
48
+ _branch="$3"
49
+ [ -n "$_epic" ] || return 0
50
+
51
+ _epic_branch="$(rt_epic_branch "$_epic")"
52
+ case "$_epic_branch" in
53
+ '')
54
+ 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."
55
+ return 0
56
+ ;;
57
+ *' '*)
58
+ 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."
59
+ return 0
60
+ ;;
61
+ esac
62
+
63
+ git rev-parse --verify --quiet "origin/${_epic_branch}" >/dev/null 2>&1 || return 0
64
+
65
+ if ! git merge-base --is-ancestor "origin/${_epic_branch}" "$_base_ref" 2>/dev/null; then
66
+ 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}."
67
+ return 0
68
+ fi
69
+
70
+ # The main branch is asked of the epic, not of the base: there it is fixed by one merge, and the
71
+ # branches of all its tasks get it at once.
72
+ if git rev-parse --verify --quiet "origin/${main_branch}" >/dev/null 2>&1 \
73
+ && ! git merge-base --is-ancestor "origin/${main_branch}" "origin/${_epic_branch}" 2>/dev/null; then
74
+ _behind="$(git rev-list --count "origin/${_epic_branch}..origin/${main_branch}" 2>/dev/null)"
75
+ 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."
76
+ fi
77
+
78
+ return 0
79
+ }
80
+
81
+ # The base of a request about a task of an epic.
82
+ #
83
+ # A request of a task goes into the branch of its epic, and one opened into the main branch takes
84
+ # the task past the epic: the epic is then handed in without it, and the reviewer sees the edit
85
+ # next to everything that lies in the main branch and not in the epic. The guard let any base
86
+ # through and asked only that the main branch be merged in.
87
+ #
88
+ # The freshness asked here is of the epic, not of the main branch: the request goes into the epic,
89
+ # and it is the divergence with the epic that shows in the diff. The main branch reaches the task
90
+ # through the epic — that is the same order as at the creation of the branch.
91
+ #
92
+ # Arguments: the number of the epic and the text of the command.
93
+ rt_epic_pull_base() {
94
+ _epic="$1"
95
+ _cmd="$2"
96
+ [ -n "$_epic" ] || return 0
97
+
98
+ _epic_branch="$(rt_epic_branch "$_epic")"
99
+ case "$_epic_branch" in
100
+ '' | *' '*) return 0 ;;
101
+ esac
102
+
103
+ # The base named by the command. Absent — the hosting takes the default branch of the
104
+ # repository, that is the main one: the very case this condition is about.
105
+ _base=''
106
+ if command -v perl >/dev/null 2>&1; then
107
+ _base="$(printf '%s' "$_cmd" | perl -0ne '
108
+ if (/(?:^|\s)(?:--base|-B)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
109
+ print defined $1 ? $1 : (defined $2 ? $2 : $3);
110
+ }
111
+ ' 2>/dev/null)"
112
+ fi
113
+
114
+ if [ "$_base" != "$_epic_branch" ]; then
115
+ 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}."
116
+ return 0
117
+ fi
118
+
119
+ if git rev-parse --verify --quiet "origin/${_epic_branch}" >/dev/null 2>&1 \
120
+ && ! git merge-base --is-ancestor "origin/${_epic_branch}" HEAD 2>/dev/null; then
121
+ _behind="$(git rev-list --count "HEAD..origin/${_epic_branch}" 2>/dev/null)"
122
+ 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}."
123
+ fi
124
+
125
+ return 0
126
+ }
127
+
128
+ # The request of an epic itself: it goes into the main branch, and it opens only when the folders
129
+ # of all its tasks are taken apart.
130
+ #
131
+ # The folder guard reads the folder of one task — by the name of the branch — and the branch of an
132
+ # epic has none of its own: every folder lying there belongs to a task of the epic whose work is
133
+ # not closed. Merged into the main branch, such an epic carries the folders of unfinished tasks
134
+ # there, and the reader of the main branch has no way to tell them from current work.
135
+ #
136
+ # The epic is recognised by the label of its card, not by the shape of the branch name: the branch
137
+ # of an epic and the branch of a task are named alike, and the label is the only thing that tells
138
+ # them apart. The tree has not named the label — the condition is not judged at all.
139
+ #
140
+ # Arguments: the state of the card of the current branch, as the work queue answered it.
141
+ rt_epic_own_pull() {
142
+ _state="$1"
143
+ [ -n "$epic_label" ] || return 0
144
+ [ -n "$_state" ] || return 0
145
+ [ -n "$tasks_dir" ] || return 0
146
+
147
+ printf '%s' "$_state" | jq -e --arg l "$epic_label" '(.labels // []) | index($l)' >/dev/null 2>&1 || return 0
148
+
149
+ _folders="$(git ls-tree -d --name-only HEAD -- "$tasks_dir" 2>/dev/null)"
150
+ [ -n "$_folders" ] || return 0
151
+
152
+ # What lies in the tasks directory of the branch, one level down: the sample and the index of
153
+ # the directory are not folders of tasks and do not hold the request.
154
+ _left=''
155
+ for _entry in $(git ls-tree -d --name-only "HEAD:${tasks_dir}" 2>/dev/null); do
156
+ case "$_entry" in
157
+ _template | _draft-*) continue ;;
158
+ esac
159
+ _left="${_left}${_left:+, }${_entry}"
160
+ done
161
+ [ -n "$_left" ] || return 0
162
+
163
+ 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."
164
+
165
+ return 0
166
+ }
167
+
@@ -1,28 +1,30 @@
1
1
  #!/usr/bin/env bash
2
- # Условия поставки о папке задачи. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента
3
- # он не подключается. Его источает гард поставки — тем же приёмом, каким источает хвост отказа и
4
- # запись наблюдений.
2
+ # Delivery conditions about the task folder. NOT a guard: it has no `rt-hook:` declaration and it
3
+ # hooks into no agent event. The delivery guard sources it — the same way it sources the refusal
4
+ # tail and the observation record.
5
5
  #
6
- # Зачем он отдельным файлом. Условий о папке два, и живут они в разных местах вызова: одно на
7
- # открытии заявки, другое на слиянии. Вместе с разбором команды, подписью, основанием и очередью
8
- # работ они переросли предел длины файла, а делить гард по событиям нельзя — он одно целое,
9
- # и разбор команды у него общий. Делится он по предмету: папка задачи — свой предмет, у неё свой
10
- # обход и своя запись в архиве.
6
+ # Why a file of its own. There are two conditions about the folder, and they live at different call
7
+ # sites: one at opening the PR, the other at the merge. Together with the command parsing, the
8
+ # signature, the base and the work queue they outgrew the file length limit, and the guard cannot
9
+ # be split by event — it is one whole, and its command parsing is shared. It is split by subject
10
+ # instead: the task folder is a subject of its own, with its own bypass and its own record in the
11
+ # archive.
11
12
  #
12
- # ЧТО ЗДЕСЬ. Три вызова, и все три зовутся из гарда поставки, где уже объявлены `deny`, `fault`
13
- # и переменные профиля: `tasks_dir`, `archive_dir`, `main_branch`, `folder_skip_re`, `root`.
14
- # Своих у помощника нет — он не читает ни ввода, ни настроек.
15
-
16
- # Есть ли папка задачи в ветке. Смотрим содержимое ветки, а не рабочее дерево: если папку
17
- # удалили, но не закоммитили, проверка прошла бы, а папка всё равно уехала бы в главную. Имя
18
- # ветки подставляем целиком, вместе с косой: у ветки вида `chore/312-slug` папка лежит во
19
- # вложенном каталоге.
13
+ # WHAT IS HERE. Three calls, and all three are called from the delivery guard, where `deny`,
14
+ # `fault` and the profile variables are already declared: `tasks_dir`, `archive_dir`,
15
+ # `main_branch`, `folder_skip_re`, `root`. The helper has none of its own — it reads neither the
16
+ # input nor the settings.
17
+
18
+ # Is the task folder in the branch. We look at the content of the branch, not at the working tree:
19
+ # if the folder was deleted but not committed, the check would pass and the folder would travel
20
+ # into the main branch all the same. The branch name is substituted whole, slash included: for a
21
+ # branch like `chore/312-slug` the folder lies in a nested directory.
20
22
  rt_folder_in_branch() {
21
23
  git ls-tree -d --name-only HEAD -- "$1" 2>/dev/null | head -1
22
24
  }
23
25
 
24
- # Была ли папка задачи в этой ветке вообще. Спрашивается у ветки, которая её удалила: иначе
25
- # требование записи в архиве цеплялось бы к работе, у которой папки и не было.
26
+ # Was there a task folder in this branch at all. Asked of the branch that deleted it: otherwise the
27
+ # demand for a record in the archive would catch work that never had a folder.
26
28
  rt_folder_was_in_branch() {
27
29
  _base="$1"
28
30
  _folder="$2"
@@ -31,15 +33,17 @@ rt_folder_was_in_branch() {
31
33
  [ -n "$_had" ]
32
34
  }
33
35
 
34
- # Условие открытия заявки: папка разобрана, и запись в архиве от ветки прибыла. Отказ копится
35
- # вместе с прочими условиями поставки и печатается разом.
36
+ # Condition for opening the PR: the folder is taken apart, and a record from the branch has arrived
37
+ # in the archive. The refusal accumulates together with the other delivery conditions and is
38
+ # printed all at once.
36
39
  #
37
- # Разбор стоит здесь, а не на слиянии. Прежде было наоборот: считалось, что папка нужна на диске
38
- # всё время разбора, потому что правку по замечаниям без замысла отбивает гард хода работы.
39
- # Владелец же вливает, как только видит зелёное, и закрывающему коммиту места не остаётся —
40
- # трижды подряд папка уехала в главную неразобранной, а гард слияния этого не видел вовсе:
41
- # кнопку нажимает человек на хостинге, и до него гард не достаёт. Замысел после уборки гард хода
42
- # работы берёт из истории ветки, а не с диска.
40
+ # Taking the folder apart stands here, not at the merge. It used to be the other way round: the
41
+ # folder was held to be needed on disk for the whole review, because an edit after remarks without
42
+ # a plan is refused by the progress guard. But the owner merges as soon as he sees green, and no
43
+ # room is left for a closing commit — three times in a row the folder travelled into the main
44
+ # branch without being taken apart, and the merge guard did not see it at all: the button is
45
+ # pressed by a person on the hosting, and the guard does not reach him. After the cleanup the
46
+ # progress guard takes the plan from the history of the branch, not from disk.
43
47
  rt_delivery_open_folder() {
44
48
  [ -n "$tasks_dir" ] || return 0
45
49
  printf '%s' "$cmd" | grep -qiE "$folder_skip_re" && return 0
@@ -47,7 +51,7 @@ rt_delivery_open_folder() {
47
51
  _folder="$tasks_dir/$branch"
48
52
  _lying="$(rt_folder_in_branch "$_folder")"
49
53
  if [ -n "$_lying" ]; then
50
- fault "в ветке лежит папка задачи «${_lying}» — заявка открывается после уборки, а не до неё. Перенеси в «${archive_dir:-архив}» то, что объясняет принятые решения, остальное удали, закоммить последним коммитом и повтори. Если работа вливается частями, поставь в команду комментарий «# Task-folder-skip: <причина>»."
54
+ 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."
51
55
  return 0
52
56
  fi
53
57
 
@@ -58,41 +62,44 @@ rt_delivery_open_folder() {
58
62
 
59
63
  _gained="$(git diff --name-only --diff-filter=A "$_base" HEAD -- "$archive_dir" 2>/dev/null | head -1)"
60
64
  [ -z "$_gained" ] \
61
- && fault "папку задачи удалили, но в «${archive_dir}» ветка ничего не добавила. Удалить проще, чем разобрать, — и вместе с папкой пропадает разбор просьбы, единственная запись слов владельца. Перенеси то, что объясняет принятые решения, одним файлом с понятным именем и повтори."
65
+ && 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."
62
66
  }
63
67
 
64
- # Условие снятия черновика: тот же предмет между открытием и слиянием. Снятый черновик читается
65
- # владельцем как приглашение влить, и кнопку он нажимает, не дожидаясь коммита уборки: гард
66
- # слияния сюда не достаёт вовсе — нажимает человек на хостинге. Три работы подряд уехали в
67
- # главную ветку именно так, и в теле каждой заявки стояло обещание убрать папку после одобрения.
68
+ # Condition for leaving draft: the same subject between opening and merging. The owner reads a PR
69
+ # out of draft as an invitation to merge, and presses the button without waiting for the cleanup
70
+ # commit: the merge guard does not reach here at all — a person on the hosting presses it. Three
71
+ # pieces of work in a row travelled into the main branch exactly that way, and the body of each PR
72
+ # carried a promise to remove the folder after approval.
68
73
  #
69
- # Ветку функция спрашивает сама: на этом ходе гард её ещё не посчитал.
74
+ # The function asks for the branch itself: on this turn the guard has not worked it out yet.
70
75
  rt_delivery_ready_folder() {
71
76
  [ -n "$tasks_dir" ] || return 0
72
77
  printf '%s' "$cmd" | grep -qiE "$folder_skip_re" && return 0
73
78
 
74
79
  _branch="$(git branch --show-current 2>/dev/null)"
75
80
  [ -z "$_branch" ] && return 0
76
- rt_task_branch_ok "$_branch" || return 0 # за беззадачной веткой папки не стоит
81
+ rt_task_branch_ok "$_branch" || return 0 # no folder stands behind a branch without a task
77
82
 
78
83
  _lying="$(rt_folder_in_branch "$tasks_dir/$_branch")"
79
84
  [ -n "$_lying" ] \
80
- && fault "в ветке лежит папка задачи «${_lying}» — снятый черновик читается как «можно вливать», а вливать её туда нельзя. Кнопку нажимает человек на хостинге, и до его руки папка уедет в главную. Перенеси в «${archive_dir:-архив}» то, что объясняет принятые решения, остальное удали, закоммить и повтори. Если работа вливается частями, поставь в команду комментарий «# Task-folder-skip: <причина>»."
85
+ && 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."
81
86
  }
82
87
 
83
- # Условие слияния: тот же предмет вторым рубежом. Он ловит слияние, идущее командой, — то, до
84
- # которого гард достаёт. Отсюда выходят только отказом или молчанием: слияние решается целиком.
88
+ # Condition for the merge: the same subject as a second line. It catches a merge going by command —
89
+ # the one the guard does reach. From here we leave only by a refusal or by silence: the merge is
90
+ # decided whole.
85
91
  rt_delivery_merge_folder() {
86
- [ -n "$tasks_dir" ] || exit 0 # ведения работы папкой в дереве нет
92
+ [ -n "$tasks_dir" ] || exit 0 # the tree keeps no work by a folder
87
93
 
88
94
  _branch="$(git branch --show-current 2>/dev/null)"
89
95
  [ -z "$_branch" ] && exit 0
90
- rt_task_branch_ok "$_branch" || exit 0 # за беззадачной веткой папки не стоит
96
+ rt_task_branch_ok "$_branch" || exit 0 # no folder stands behind a branch without a task
91
97
 
92
98
  _folder="$tasks_dir/$_branch"
93
99
 
94
- # Сначала ищем обход в самой команде — это работает и без сети. Если читать только
95
- # тело заявки, то без сети гард отбил бы слияние, причина которого в этом теле и написана.
100
+ # First we look for the bypass in the command itself — that works without a network too. If
101
+ # only the PR body were read, then without a network the guard would refuse a merge whose
102
+ # reason is written in that very body.
96
103
  printf '%s' "$cmd" | grep -qiE "$folder_skip_re" && exit 0
97
104
 
98
105
  _number="$(printf '%s' "$cmd" | sed -nE 's/.*(pr|mr)[[:space:]]+(merge|update)[[:space:]]+([0-9]+).*/\3/p' | head -1)"
@@ -103,7 +110,7 @@ rt_delivery_merge_folder() {
103
110
 
104
111
  _lying="$(rt_folder_in_branch "$_folder")"
105
112
  [ -n "$_lying" ] \
106
- && deny "BLOCKED: в ветке осталась папка задачи «${_lying}» — она уедет в главную. Разобрать её потом будет некому: работа перейдёт к следующей задаче, а эта заявка закроется. Перенеси в «${archive_dir:-архив}» то, что объясняет принятые решения, остальное удали и повтори. Если работа вливается частями, поставь в тело заявки строку «Task-folder-skip: <причина>»."
113
+ && 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."
107
114
 
108
115
  [ -n "$archive_dir" ] || exit 0
109
116
  _base="$(git merge-base "$main_branch" HEAD 2>/dev/null)"
@@ -112,7 +119,7 @@ rt_delivery_merge_folder() {
112
119
 
113
120
  _gained="$(git diff --name-only --diff-filter=A "$_base" HEAD -- "$archive_dir" 2>/dev/null | head -1)"
114
121
  [ -z "$_gained" ] \
115
- && deny "BLOCKED: папку задачи удалили, но в «${archive_dir}» ветка ничего не добавила. Удалить проще, чем разобрать, — и вместе с папкой пропадает разбор просьбы, единственная запись слов владельца. Перенеси то, что объясняет принятые решения, одним файлом с понятным именем и повтори."
122
+ && 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."
116
123
 
117
124
  exit 0
118
125
  }