@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
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env bash
2
- # The parsing of the turn record for the turn-exit guard. NOT a guard: it has no `rt-hook:`
3
- # declaration and hooks into no agent event. The guard sources it right after the patterns —
4
- # it was moved out when the guard crossed the file length limit, and the parsing reads apart
5
- # from the tiers that apply its answer.
6
- #
7
- # It expects the patterns to be sourced already and `$transcript` to be set; it prints nothing
8
- # and leaves the answer in `$verdict`.
9
-
10
- rt_te_verdict() {
11
- verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re" --arg read "$read_re" --arg part "$part_re" --arg wait "$wait_re" --arg handover "$handover_re" --arg started "$started_re" --arg promise "$promise_re" --arg standing "$standing_work_re" '
12
- # A service message — a skill load, a compaction summary — carries the user type and is not the word
13
- # of the owner: it neither starts a turn nor is read as one.
14
- def is_service:
15
- ((.isCompactSummary // false) or (.isMeta // false))
16
- or ((.message.content // "") | if type == "string" then . elif type == "array"
17
- then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end
18
- | test("^[[:space:]]*Stop hook feedback"));
19
- def is_input:
20
- .type == "user"
21
- and (is_service | not)
22
- and (((.message.content // []) | if type == "array"
23
- then ([.[] | select(.type == "tool_result")] | length)
24
- else 0 end) == 0);
25
-
26
- (map(is_input) | rindex(true)) as $i
27
- | (if $i == null then [] else .[$i:] end) as $turn
28
- | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")] as $uses
29
- # An edit of a file is work by definition, whatever tool it goes through.
30
- | ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$"))) as $edited
31
- | ($uses | map(.name // "") | any(test("AskUserQuestion"))) as $asked
32
- | ($uses | map((.input.command // "")) | join("\n")) as $ran
33
- # Work is a part of the command that matched the work pattern and did not match the exploration
34
- # pattern: switching a branch and reading history in the same turn do not become work.
35
- | ([$ran | splits($part)] | map(test($work) and (test($read) | not)) | any) as $ran_work
36
- # The last action of the turn. Waiting for a step by anyone else is never the end of a turn,
37
- # however much work there was before: the work stays exactly where it stood.
38
- | ([$uses[] | select((.name // "") == "Bash") | ((.input.command // "") + (if (.input.run_in_background // false) then " &" else "" end))] | last // "") as $last
39
- | ([$uses[] | (.name // "")] | last // "") as $last_name
40
- # A launch in the background as the last action: a role sent to work by the agent tool, or a
41
- # command sent behind the turn. The launch is an announcement of intent, and what does not
42
- # depend on it is done while it runs — the turn does not end on the launch itself.
43
- | (($last_name | test("^(Agent|Task)$")) or (($last_name == "Bash") and ($last | test("&[[:space:]]*$")))) as $launched_last
44
- | (($last_name == "Bash") and ($last | test($wait))) as $waited
45
- # A turn woken by a notification about an own background task. The notification is written under
46
- # the role of the owner, and the turn it opens holds nothing to do while another own task still
47
- # runs. The launches are read over the whole window; a launch ends with a notification naming its
48
- # call, whether it woke a turn or arrived as an attachment in the middle of one. Such a turn
49
- # gets no verdict at all, and the guard lets an empty verdict through: the guard has no room.
50
- | (if $i == null then false else
51
- ((.[$i].origin.kind // "") == "task-notification")
52
- or ((.[$i].message.content // "") | if type == "string" then test("^[[:space:]]*<task-notification>") else false end)
53
- end) as $woken
54
- | ([.[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")
55
- | select(((.name // "") | test("^(Agent|Task)$")) or (((.name // "") == "Bash") and (.input.run_in_background // false)))
56
- | (.id // empty)]) as $launches
57
- | ([.[] | ((.message.content // "") | if type == "string" then . else "" end), (.attachment.prompt // "")
58
- | select(test("<task-notification>"))
59
- | select(test("<status>(completed|failed|killed|stopped)</status>"))
60
- | (capture("<tool-use-id>(?<id>[^<]+)</tool-use-id>").id // empty)]) as $finished
61
- | ($woken and (($uses | length) == 0) and (($launches - $finished) | length) > 0) as $woken_waiting
62
- # Handing the work over: the tail of the turn after the PR was opened. Everything before it was
63
- # done on the task handed in and says nothing about the next one.
64
- | ([$uses[] | select((.name // "") == "Bash") | (.input.command // "")]) as $cmds
65
- | (($cmds | map(test($handover)) | index(true))) as $handover_at
66
- | ($handover_at != null) as $handed_over
67
- | (if $handover_at == null then [] else $cmds[$handover_at:] end) as $tail
68
- | (($tail | map(test($started)) | any)
69
- or ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$")))) as $started_next
70
- # THE LAST ACTION OF THE TURN is the shared sign, and the particular tiers below only derive an
71
- # understandable refusal from it. Nine incident analyses in a day describe nine different stops,
72
- # and in all nine the last action of the turn was a text to the owner: a report, a summary, an
73
- # announcement of intent. A tier for every kind of stop is an endless race: there are as many
74
- # kinds as there are reasons to start talking. Hence one sign — the LAST action must be work.
75
- | ([$uses[] | (.name // "")] | last // "") as $last_tool
76
- | (($last_tool | test("^(Edit|Write|MultiEdit|NotebookEdit)$"))
77
- or ([$last | splits($part)] | map(test($work) and (test($read) | not)) | any)) as $ended_working
78
- # A guard refusal and a session handover — both end the turn by the rule. The refusal is read
79
- # from the LAST tool result: a refusal in the middle of the turn was answered by the work that
80
- # followed it, and a turn that went on after it is judged by how it ended.
81
- | ([$turn[] | select(.type == "user") | .message.content // [] | select(type == "array") | .[]
82
- | select(.type == "tool_result") | .content
83
- | if type == "string" then .
84
- elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
85
- else tostring end]) as $outs
86
- | ($outs | join("\n")) as $out
87
- | ($outs | last // "") as $last_out
88
- # The refusal of the closing tool is left out: the refused call was itself the stop, not work.
89
- | ($last_out | test("BLOCKED by (?!end-conversation-guard)|Refused by the rules gate|Отбито гейтом")) as $denied
90
- | ($ran | test("handoff")) as $handed
91
- # The word of the owner about stopping: the reply itself is judged, not its retelling.
92
- | ([$turn[] | select(.type == "user") | select(is_service | not) | .message.content
93
- | if type == "string" then . elif type == "array"
94
- then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end] | join("\n")) as $said
95
- | ([.[] | select(.type == "user") | select(is_service | not) | .message.content
96
- | if type == "string" then . elif type == "array"
97
- then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end] | join("\n")) as $session_said
98
- | ($session_said | test($standing)) as $standing_work
99
- | (($said | test("останов|стоп|хватит|подожди|не надо|прерв|отложи|не двигайся|не продолжай|прекрати")) and ($said | test($standing) | not)) as $told_stop
100
- # A question refused by the conversation guard, and a question appended as prose at the end of
101
- # the reply. The conversation guard judges the call of the question tool and does not see prose
102
- # at all: a refused question came back in the same wording one turn later and passed freely.
103
- | ($out | test("BLOCKED by grill-gate")) as $ask_denied
104
- | ([$turn[] | select(.type == "assistant") | (.message.content // [])[]
105
- | select(.type == "text") | (.text // "")] | last // "") as $last_say
106
- | (($last_say | test("\\?[[:space:]]*$")) and $ask_denied) as $asked_in_prose
107
- # The word of the owner about a stop said a turn earlier holds until a later message of theirs
108
- # orders work. It is read from the whole session: read from this turn alone, it was lost, and
109
- # the turn could leave only by a line in the progress of a folder already taken apart. Such a
110
- # word releases the turn when the reply quotes it in « » and the quote stands in that message.
111
- | ([.[] | select(is_input) | .message.content
112
- | if type == "string" then . elif type == "array"
113
- then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end]) as $owner_said
114
- | ($owner_said | map(test("останов|стоп|хватит|подожди|не надо|прерв|отложи|не двигайся|не продолжай|прекрати") and (test($standing) | not)) | rindex(true)) as $stop_at
115
- | (if $stop_at == null then null
116
- elif ($owner_said[$stop_at + 1:] | map(test("продолжай|работай|делай|бери|давай|вперёд|можно")) | any) then null
117
- else $owner_said[$stop_at] end) as $stop_word
118
- | ([$last_say | match("«([^»]+)»"; "g") | .captures[0].string]) as $quotes
119
- | ($stop_word != null and ($quotes | map(. as $q | $stop_word | contains($q)) | any)) as $quoted_stop
120
- | ($told_stop or $quoted_stop) as $told_stop
121
- # What is left in the tree is named with a reason, and the line «Не отправлено: <reason>» in
122
- # the reply is that naming: without it the only lawful move was a push made to lift the refusal.
123
- | ($last_say | test("Не отправлено:[[:space:]]*[^[:space:]]")) as $unpushed_named
124
- # Waiting for the word of the owner, announced by the executor. That word is read from
125
- # the owner: without his word in the turn and without a question to him through the tool, the
126
- # phrase "waiting for your word" is a stop announced by the one it suits. The set of patterns is
127
- # named and closed.
128
- | (($last_say | test("[Жж]ду (твоего|вашего|его|её) (слова|указани|решени|ответа|команды|отмашки)|[Жж]ду слова владельца|[Жж]ду, что скаж|[Оо]стаюсь ждать|[Бб]уду ждать (твоего|вашего)"))
129
- and (($asked or $told_stop or $handed) | not)) as $awaits_word
130
- | ($last_say | test($promise)) as $promised
131
- # The next step rewritten into the progress and not begun. The last edit of the progress in the
132
- # turn is found — by the editing tool or by a writing command naming the file — and after it the
133
- # turn must hold work other than the commit and the push of it: an edit outside the task folder
134
- # or a command changing the tree. Four stops of one shape ended with a full report, a moved
135
- # stage number and an untouched next step; the volume before the line is not the step.
136
- | ($uses | map(
137
- (((.name // "") | test("^(Edit|Write|MultiEdit|NotebookEdit)$")) and ((.input.file_path // "") | test("(^|/)progress\\.md$")))
138
- or (((.name // "") == "Bash") and ((.input.command // "") | test("progress\\.md")) and ((.input.command // "") | test("sed -i|tee |>|python3|cat ")))
139
- ) | rindex(true)) as $progress_at
140
- | ($progress_at != null) as $progress_edited
141
- | (if $progress_at == null then [] else $uses[($progress_at + 1):] end) as $after
142
- | ($after | map(
143
- (((.name // "") | test("^(Edit|Write|MultiEdit|NotebookEdit)$")) and ((.input.file_path // "") | test("/tasks/") | not))
144
- or (((.name // "") == "Bash") and ([(.input.command // "") | splits($part)] | map(test($work) and (test($read) | not) and (test("^[[:space:]]*([^[:space:]]*/)?git[[:space:]]+(add|commit|push)") | not)) | any))
145
- ) | any) as $after_progress
146
- | (($last_name == "Bash") and ($last | test($started)) and ($handed_over | not)) as $only_took
147
- | if $woken_waiting then empty else { promised: $promised, only_took: $only_took, asked: $asked, handed_by_hand: ($handed and (($asked or $denied or $told_stop) | not)), standing_work: $standing_work, worked: ($edited or $ran_work), released: ($asked or $denied or $handed or $told_stop), waited: $waited, handed_over: $handed_over, started_next: $started_next, ended_working: $ended_working, asked_in_prose: $asked_in_prose, awaits_word: $awaits_word, progress_edited: $progress_edited, after_progress: $after_progress, launched_last: $launched_last, ran: $ran, unpushed_named: $unpushed_named } end
148
- ' 2>/dev/null)"
149
- }
@@ -1,320 +0,0 @@
1
- #!/usr/bin/env bash
2
- # rt-hook: Stop
3
- # Requires: hooks/deny-tail.sh, hooks/epic-over.sh
4
- # Waiting guard: a turn that tells the owner about someone else's step does not end until it holds
5
- # at least one action on the next task. Stop.
6
- #
7
- # Why this way. The article "waiting for a run is not what work is spent on" is held by the
8
- # executor's memory, and held badly: the sample message to the owner ends with a phrase about the
9
- # next task, and the phrase is carried out as a promise — the session says it and ends the turn. A
10
- # turn in which nothing was done gives itself away by nothing: no file edit, no command — and the
11
- # miss is seen only by the owner, only by the work not moving, and only when they ask directly.
12
- #
13
- # Someone else's step is known by two signs, and both are taken from the turn, not from the
14
- # network. The first is a PR opened: the work is handed in, and from there the owner moves it. The
15
- # second is a red run read: it has to be fixed, but a turn that read it and did nothing is the same
16
- # emptiness. Reading the run is not a sign by itself: the end of a run is also read to go and fix
17
- # it; the sign is a red answer, and it lies in the command output — in the same turn record.
18
- #
19
- # Asking the hosting would be more precise, but a network call at the end of a turn fails together
20
- # with the connection and would refuse the work instead of the miss.
21
- #
22
- # What counts as an action: creating a task, creating a branch, moving the task to the work column,
23
- # creating the task folder. Moving to the review column and removing the folder are not in it —
24
- # those are steps of closing the previous work, not the start of the next. The set is open and
25
- # grows by edits — its completeness is an open question, not a promise.
26
- #
27
- # What the guard does not judge. A turn that says nothing about someone else's step — here it stays
28
- # silent: an empty turn cannot be told from a turn that had nothing to do. This is its known
29
- # boundary. A green run it does not judge either: after it comes work of one's own — cleanup and
30
- # lifting the draft — not someone else's step.
31
- #
32
- # FAIL-OPEN: on any error, missing `jq`, missing turn record or a repeated call on the same turn
33
- # the turn is ALLOWED (exit 0). A broken guard has no right to jam the conversation.
34
-
35
- # Its own name in observations: the refusal is written by the shared deny tail, not by the guard.
36
- RT_GUARD_NAME=waiting-turn-guard
37
- RT_GUARD_RULE=turn-conduct
38
-
39
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
40
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
41
-
42
- rt_hook_read
43
- input="$RT_HOOK_INPUT"
44
- [ -z "$input" ] && exit 0
45
-
46
- command -v jq >/dev/null 2>&1 || exit 0
47
-
48
- # A repeated call on the same turn is not judged: the guard said its word once and lets go.
49
- active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
50
- [ "$active" = "true" ] && exit 0
51
-
52
- transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
53
- [ -z "$transcript" ] && exit 0
54
- [ -f "$transcript" ] || exit 0
55
-
56
- # Opening a PR differs per hosting, and the guard moves between them whole: the set names all
57
- # three forms, not the one this tree uses. Editing the PR body is not in it — it opens nothing.
58
- opened_re='gh[^|;&]*pr[[:space:]]+create|api[^|;&]*-X[[:space:]]+POST[^|;&]*/pulls|glab[^|;&]*mr[[:space:]]+create|az[[:space:]]+repos[[:space:]]+pr[[:space:]]+create'
59
-
60
- # Reading a run is the second case of someone else's step. By itself it means nothing: the end of
61
- # a run is also read to go and fix it. The sign is a red answer, and it lies not in the command
62
- # but in its output — in the same turn record, and no network is needed for that.
63
- read_re='run[[:space:]]+(list|view|watch)|pipelines[[:space:]]+runs'
64
- red_re='completed[[:space:]]+failure|"conclusion"[[:space:]]*:[[:space:]]*"failure"|conclusion:[[:space:]]*failure|completed with .failure.|run[[:space:]]+failed'
65
-
66
- # The first action on the next task. Listed is what taking a task CAN BE, not what counts as an
67
- # action: the list of work-closing steps is open and grows, while the list of actions on the next
68
- # task is closed — a list of "what it can be" has no hole for a closing step.
69
- #
70
- # Moving the closed task to the review column and removing its folder are left out on purpose:
71
- # both are mandatory steps of closing work, and both stand in the same turn that opened the PR.
72
- # While the sign listed them alongside taking a task, it always matched, and the guard let through
73
- # the very turn it was made for — work stopped three times in one session that way.
74
- #
75
- # A code edit in the branch of the same PR does not count as an action on the next task — it fixes
76
- # the previous one and does not move the work on.
77
- taken_re='task:new|checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|task:move[^|;&]*in-progress|(cp|mkdir)[^|;&]*/tasks/'
78
-
79
- # The task folder is also created without the shell: the file-editing tool writes its first file,
80
- # and no command line stands behind that. So next to the commands the edit path is judged — with a
81
- # pattern of its own, since no command name is in it.
82
- taken_path_re='/tasks/'
83
-
84
- # How the turn shows it carried the handed-in work to the end rather than leaving it a draft.
85
- # Lifting the draft is the obvious case; reading the run is the one where there is nothing to lift
86
- # yet, but the executor looked instead of saying "waiting". Two ready PRs stood as drafts precisely
87
- # because the next task was taken instead of this, not on top of it.
88
- # The GitLab client lifts the draft by an update with a flag and reads the pipeline by `ci`.
89
- ready_re='pr[[:space:]]+ready|run[[:space:]]+(list|view|watch)|pr[[:space:]]+checks|check-runs|check:board|board\.mjs|glab[^|;&]*mr[[:space:]]+update[^|;&]*(--ready|[[:space:]]-r)([[:space:]]|$)|glab[^|;&]*ci[[:space:]]+(status|view|list|trace|get)'
90
-
91
- # A run started or rerun in the turn. Its outcome does not call by itself: a rerun went through in
92
- # one line between other things, its state was read once — «queued» — and the turn ended by a lawful
93
- # exit while the request stayed without watching; the owner found the green run before the
94
- # executor. The sign is the pair: a starting command in the turn and no command that waits for the
95
- # end in the same turn. A wait is a watching command of the hosting client, a loop until the end or
96
- # the watching tool — in the background or blocking; a single read of the state is not a wait.
97
- # Incident analysis — the record "2026-09-15-turn-idle-after-green-run" in the intake.
98
- started_run_re='run[[:space:]]+rerun|workflow[[:space:]]+run|ci[[:space:]]+(retry|run)|pipeline[[:space:]]+(run|retry)|pipelines[[:space:]]+run'
99
-
100
- # A run nobody started by hand: the pipeline wakes on an opened request by itself, and the tier
101
- # above stays silent — there is no starting command in the turn at all. The sign is taken from the
102
- # output rather than from the base of the request: which bases wake the pipeline the guard cannot
103
- # know, and a demand by the bare fact of opening would refuse every request into an epic branch.
104
- # So the pair is "the request is opened in the turn" and "its run is read as going".
105
- going_run_re='queued|in_progress|"status"[[:space:]]*:[[:space:]]*"(queued|in_progress)"|status:[[:space:]]*(queued|in_progress)'
106
- watched_run_re='run[[:space:]]+watch|pr[[:space:]]+checks[^|;&]*--watch|until[[:space:]][^\n]*sleep|while[[:space:]][^\n]*sleep|ci[[:space:]]+status[^|;&]*--live|pipelines[[:space:]]+runs[[:space:]]+show'
107
-
108
- # One's own named action. An empty turn that declared what it will do next gives itself away by
109
- # nothing: it opened no PR, read no run, and both earlier signs are silent. It is caught by form —
110
- # a set of future-tense patterns about one's own step — not by understanding the meaning; and no
111
- # call may stand behind the words, otherwise the declaration was said along the work, not instead
112
- # of it.
113
- vow_re='дальше беру|дальше возьму|дальше иду|следующим шагом|следующий шаг:|затем сделаю|затем возьму|потом сделаю|после этого сделаю|далее беру'
114
-
115
- # The turn is everything recorded after the owner's last real input. A tool result arrives under
116
- # the same role, so lines with `tool_result` do not count as input.
117
- #
118
- # A 400-line tail: the turn record grows all session, and only the last turn is judged.
119
- verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r \
120
- --arg opened "$opened_re" --arg taken "$taken_re" --arg taken_path "$taken_path_re" \
121
- --arg read "$read_re" --arg red "$red_re" --arg ready "$ready_re" --arg vow "$vow_re" \
122
- --arg started_run "$started_run_re" --arg watched_run "$watched_run_re" \
123
- --arg going_run "$going_run_re" '
124
- def is_input:
125
- .type == "user"
126
- and ((.isCompactSummary // false) | not)
127
- and (((.message.content // []) | if type == "array"
128
- then ([.[] | select(.type == "tool_result")] | length)
129
- else 0 end) == 0);
130
-
131
- (map(is_input) | rindex(true)) as $i
132
- | (if $i == null then [] else .[$i:] end) as $turn
133
- | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")] as $uses
134
- | ($uses | map((.input.command // "")) | join("\n")) as $ran
135
- # The edit path is the second way to create a task folder. Only the writing tools are judged:
136
- # reading has the same path and is not work.
137
- | ($uses | map(select(.name == "Write" or .name == "Edit" or .name == "MultiEdit")
138
- | (.input.file_path // "")) | join("\n")) as $wrote
139
- # The tool result is taken as text, not as the JSON record: there a tab and a quote leave
140
- # escaped, and the pattern misses them entirely. It arrives both as a string and as a list of
141
- # blocks — both forms are brought to one text.
142
- | ([$turn[] | select(.type == "user") | .message.content // [] | select(type == "array") | .[]
143
- | select(.type == "tool_result") | .content
144
- | if type == "string" then .
145
- elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
146
- else tostring end] | join("\n")) as $out
147
- | ($ran | test($opened; "i")) as $opened_pr
148
- | (($ran | test($read; "i")) and ($out | test($red; "i"))) as $red_run
149
- | (($ran | test($taken; "i")) or ($wrote | test($taken_path; "i"))) as $went_on
150
- | ($ran | test($ready; "i")) as $checked
151
- # The run started in the turn and the wait for its end: the watching tool counts as a wait too.
152
- | ($ran | test($started_run; "i")) as $reran
153
- # The run of the request opened in this turn: read as going and left without a wait.
154
- | ($opened_pr and ($out | test($going_run; "i"))) as $own_run_going
155
- | (($ran | test($watched_run; "i")) or ($uses | map(.name // "") | any(. == "Monitor"))) as $watched_run
156
- | ([$turn[] | select(.type == "assistant") | (.message.content // [])[]
157
- | select(.type == "text") | .text] | join("\n")) as $said
158
- | ($said | test($vow; "i")) as $announced
159
- | ($uses | length) as $tools
160
- | if $opened_pr and ($went_on | not) and ($checked | not) then "owe:both"
161
- elif $opened_pr and ($went_on | not) then "owe:pr"
162
- elif $opened_pr and ($checked | not) then "owe:draft"
163
- elif ($reran or $own_run_going) and ($watched_run | not) then "owe:watch"
164
- elif $went_on then "pass"
165
- elif $red_run then "owe:run"
166
- elif $announced and $tools == 0 then "owe:vow"
167
- else "pass" end
168
- ' 2>/dev/null)"
169
-
170
- # Neither of the two actions: the refusal names both at once. Before, it named only the first and
171
- # was lifted by the first too — the executor took the next task, the open-PR sign left with the
172
- # turn, and the second demand evaporated without ever sounding.
173
- if [ "$verdict" = "owe:both" ]; then
174
- reason="BLOCKED by waiting-turn-guard: a PR was opened in this turn, and neither of the two actions was done about the handed-over work — its state was not asked, and the next task was not taken.
175
-
176
- There are exactly two actions, and one of them does not lift the refusal: what was handed over is brought to a lifted draft by the one who handed it over, and the next task is taken on top of that, not instead. A taken next task carries the sign of the open request away with it — the second requirement will never sound after it.
177
-
178
- gh run list # состояние отданного
179
- npm run task:new -- <заголовок> # следующая работа
180
-
181
- The guard judges one turn: the next session is not refused."
182
-
183
- # shellcheck disable=SC1090
184
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
185
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
186
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
187
- deny_tail_text="$(rt_deny_tail "")"
188
- [ -n "$deny_tail_text" ] && reason="${reason}
189
-
190
- ${deny_tail_text}"
191
-
192
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
193
- || printf '{"decision":"block","reason":"waiting-turn-guard: neither of the two actions was done about the handed-over work."}\n'
194
- exit 0
195
- fi
196
-
197
- # A turn that declared its next action and did nothing on it. The refusal names the declaration
198
- # itself: an executor told "the turn is empty" will rewrite the words rather than take the step.
199
- if [ "$verdict" = "owe:vow" ]; then
200
- reason="BLOCKED by waiting-turn-guard: not a single edit was made in the turn and not a single command was called, while the next action is named in words — «дальше беру», «следующим шагом», «затем сделаю».
201
-
202
- An announcement of your own step is never work: it is more precise than any promise, and the emptiness behind it is visible to nobody. Do what is named in this same turn — or tell the owner what stops the work, and name exactly what.
203
-
204
- The guard judges one turn: the next session is not refused."
205
-
206
- # shellcheck disable=SC1090
207
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
208
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
209
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
210
- deny_tail_text="$(rt_deny_tail "")"
211
- [ -n "$deny_tail_text" ] && reason="${reason}
212
-
213
- ${deny_tail_text}"
214
-
215
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
216
- || printf '{"decision":"block","reason":"waiting-turn-guard: the next action is named in words, and nothing was done in the turn."}\n'
217
- exit 0
218
- fi
219
-
220
- # A run started or rerun in the turn without a wait for its end. The next task taken does not lift
221
- # this: the request stays without watching either way, and its outcome reaches the owner first.
222
- if [ "$verdict" = "owe:watch" ]; then
223
- reason="BLOCKED by waiting-turn-guard: a run of this turn was left without a wait for its end — started by hand, or started by the request opened here and read as going.
224
-
225
- The outcome of a run does not call by itself: a state read once — «queued», «in_progress» — is a moment, not a result. Without a wait the request stays without watching, the draft is not lifted and the merge is not asked, and the owner finds the green run before the executor.
226
-
227
- Put the wait in this same turn, in the background or blocking:
228
-
229
- gh run watch <id> --exit-status & # returns the session to the request at the end
230
- gh pr checks <number> --watch
231
-
232
- The end of a run is learned from the return of such a command, not from a look at the page.
233
-
234
- The guard judges one turn: the next session is not refused."
235
-
236
- # shellcheck disable=SC1090
237
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
238
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
239
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
240
- deny_tail_text="$(rt_deny_tail "")"
241
- [ -n "$deny_tail_text" ] && reason="${reason}
242
-
243
- ${deny_tail_text}"
244
-
245
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
246
- || printf '{"decision":"block","reason":"waiting-turn-guard: a run was started in the turn, and nothing waits for its end."}\n'
247
- exit 0
248
- fi
249
-
250
- # A draft left while the next task is taken is a separate refusal: there the demand is not about
251
- # the next task but about carrying the handed-in one to the end.
252
- if [ "$verdict" = "owe:draft" ]; then
253
- reason="BLOCKED by waiting-turn-guard: a PR was opened in this turn, the next task is taken, and the state of the handed-over work was asked by no command.
254
-
255
- A draft is read by the owner as «the work is not finished»: its merge button is locked by the hosting itself, and in the list of requests the ready cannot be told from the unfinished — grey in both. Bringing what was handed over to a lifted draft is owed by the one who handed it over.
256
-
257
- Ask the run on the tip in this same turn — `gh run list`, `gh pr checks` or the audit of the work queue — and lift the draft when it is green and the branch merges. The run is still going — then say so to the owner, naming its output.
258
-
259
- The next task is taken on top of that, not instead: both ready requests stood as drafts on exactly this substitution.
260
-
261
- The guard judges one turn: the next session is not refused."
262
-
263
- # shellcheck disable=SC1090
264
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
265
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
266
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
267
- deny_tail_text="$(rt_deny_tail "")"
268
- [ -n "$deny_tail_text" ] && reason="${reason}
269
-
270
- ${deny_tail_text}"
271
-
272
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
273
- || printf '{"decision":"block","reason":"waiting-turn-guard: the handed-over work stayed a draft — ask the run and lift the draft."}\n'
274
- exit 0
275
- fi
276
-
277
- case "$verdict" in
278
- owe:pr) said="a PR was opened in this turn" ;;
279
- owe:run) said="a red run was read in this turn" ;;
280
- *) exit 0 ;;
281
- esac
282
-
283
- # The end of an epic: there the next task is exactly what is not taken — the guard of the stop
284
- # refuses taking it — and demanding it here would leave the turn with no lawful end. The reading is
285
- # shared with that guard and is asked right before the refusal: it goes to the hosting, and every
286
- # turn must not pay for it.
287
- # shellcheck disable=SC1090
288
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/epic-over.sh" 2>/dev/null || true
289
- if command -v rt_epic_over >/dev/null 2>&1 && rt_epic_over; then
290
- exit 0
291
- fi
292
-
293
- reason="BLOCKED by waiting-turn-guard: ${said}, and there is not a single action about the next task in it. Waiting for someone else's step is not what a session is spent on: the run, the review and the merge go on elsewhere and do not get faster from being watched.
294
-
295
- Saying «беру следующую задачу» is not the same as taking it: the phrase lives to the end of the turn while the work does not move, and only the owner can notice that.
296
-
297
- The first action about the next task is done in this same turn — creating the task, the branch or the folder:
298
-
299
- npm run task:new -- --title '<Что не так>' --slug <slug>
300
- git checkout -b <KEY>-<number>-<slug>
301
-
302
- The end of a run is learned from the return of a background command, not from a look at the page.
303
-
304
- The guard judges one turn: the next session is not refused."
305
-
306
- # The shared deny tail: two lawful moves. The file may not be laid out — then there is no tail,
307
- # and the reason for the refusal stays as it was.
308
- # shellcheck disable=SC1090
309
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
310
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
311
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
312
- deny_tail_text="$(rt_deny_tail "")"
313
- [ -n "$deny_tail_text" ] && reason="${reason}
314
-
315
- ${deny_tail_text}"
316
-
317
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
318
- || printf '{"decision":"block","reason":"waiting-turn-guard: a PR is open — the next task is taken in the same turn."}\n'
319
-
320
- exit 0