@rt-tools/agent-kit 0.37.0 → 0.38.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 (436) hide show
  1. package/README.md +5 -5
  2. package/assets/checks/action-of.mjs +154 -0
  3. package/assets/checks/board-pull-state.github.mjs +82 -13
  4. package/assets/checks/board-runs.github.mjs +40 -5
  5. package/assets/checks/board.github.mjs +1 -1
  6. package/assets/checks/check-board.github.mjs +58 -19
  7. package/assets/checks/check-specs.mjs +2 -2
  8. package/assets/checks/check-state-next.mjs +22 -10
  9. package/assets/checks/check-turn-map.mjs +26 -6
  10. package/assets/checks/check-work-steps.mjs +4 -173
  11. package/assets/checks/decide.mjs +285 -0
  12. package/assets/checks/decision-table.json +21365 -0
  13. package/assets/checks/decision-table.mjs +495 -0
  14. package/assets/checks/epic-table.github.mjs +4 -3
  15. package/assets/checks/epic-window.mjs +98 -0
  16. package/assets/checks/flow-condition.mjs +64 -0
  17. package/assets/checks/flow-data.mjs +136 -0
  18. package/assets/checks/flow-forecast.mjs +330 -0
  19. package/assets/checks/flow-guard-run.mjs +90 -0
  20. package/assets/checks/flow-guard.mjs +294 -0
  21. package/assets/checks/flow-model.mjs +271 -0
  22. package/assets/checks/flow-override.mjs +130 -0
  23. package/assets/checks/flow-plan.mjs +206 -0
  24. package/assets/checks/flow-scaffold.mjs +224 -0
  25. package/assets/checks/flow-step.mjs +365 -0
  26. package/assets/checks/flow-sync.mjs +296 -0
  27. package/assets/checks/flow-syntax.mjs +292 -0
  28. package/assets/checks/flow-verdict.mjs +112 -0
  29. package/assets/checks/lib-common.mjs +10 -2
  30. package/assets/checks/lib-domains.mjs +1 -1
  31. package/assets/checks/lib-manifests.mjs +34 -2
  32. package/assets/checks/merge-read.mjs +239 -0
  33. package/assets/checks/owner-nudges.mjs +389 -0
  34. package/assets/checks/push-inputs.mjs +444 -0
  35. package/assets/checks/push-trace.mjs +108 -0
  36. package/assets/checks/record-count.mjs +410 -0
  37. package/assets/checks/record-recount.mjs +187 -0
  38. package/assets/checks/record-turn.mjs +155 -0
  39. package/assets/checks/rt-kit-checks.config.mjs +17 -2
  40. package/assets/checks/spec-anchors.mjs +4 -4
  41. package/assets/checks/spec-contract.mjs +5 -5
  42. package/assets/checks/task-flow-script.mjs +292 -0
  43. package/assets/checks/tree-assignment.mjs +26 -7
  44. package/assets/checks/work-result.mjs +281 -0
  45. package/assets/checks/work-steps-lib.mjs +205 -0
  46. package/assets/commands/next-session.md +3 -1
  47. package/assets/commands/night.md +28 -18
  48. package/assets/defaults/gate-map.sh +39 -12
  49. package/assets/defaults/merges.sh +48 -0
  50. package/assets/defaults/project.sh +43 -13
  51. package/assets/defaults/push.sh +23 -0
  52. package/assets/defaults/turn-map.md +24 -21
  53. package/assets/docs/GLOSSARY.md +6 -2
  54. package/assets/hooks/ask-judge.md +65 -0
  55. package/assets/hooks/browser-guard-device-id.sh +11 -9
  56. package/assets/hooks/browser-guard-no-asking.sh +12 -6
  57. package/assets/hooks/browser-guard-no-listing.sh +13 -7
  58. package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
  59. package/assets/hooks/browser-guard-require-select.sh +15 -15
  60. package/assets/hooks/commit-msg.sh +13 -3
  61. package/assets/hooks/conscience-guard.sh +9 -25
  62. package/assets/hooks/decide.sh +141 -0
  63. package/assets/hooks/deny-tail.sh +16 -11
  64. package/assets/hooks/dev-server-guard.sh +27 -20
  65. package/assets/hooks/dispatch.sh +47 -4
  66. package/assets/hooks/docs-guard.sh +31 -200
  67. package/assets/hooks/end-conversation-guard.sh +12 -21
  68. package/assets/hooks/epic-stop-guard.sh +54 -105
  69. package/assets/hooks/exam-guard.sh +32 -65
  70. package/assets/hooks/facts-docs.sh +221 -0
  71. package/assets/hooks/facts-flow.sh +173 -0
  72. package/assets/hooks/facts.sh +308 -0
  73. package/assets/hooks/flow-step-guard.sh +93 -0
  74. package/assets/hooks/git-guard-delivery-body.sh +4 -4
  75. package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
  76. package/assets/hooks/git-guard-delivery-draft.sh +3 -3
  77. package/assets/hooks/git-guard-delivery-epic.sh +18 -9
  78. package/assets/hooks/git-guard-delivery-folder.sh +32 -7
  79. package/assets/hooks/git-guard-delivery-merge.sh +2 -2
  80. package/assets/hooks/git-guard-delivery-merged.sh +12 -1
  81. package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
  82. package/assets/hooks/git-guard-delivery-rerun.sh +32 -0
  83. package/assets/hooks/git-guard-delivery-signature.sh +82 -45
  84. package/assets/hooks/git-guard-delivery-task.sh +47 -0
  85. package/assets/hooks/git-guard-delivery.sh +112 -101
  86. package/assets/hooks/git-guard-discard.sh +8 -18
  87. package/assets/hooks/git-guard-main.sh +13 -19
  88. package/assets/hooks/git-guard-no-verify.sh +56 -16
  89. package/assets/hooks/git-guard-push-ahead.sh +46 -5
  90. package/assets/hooks/git-guard-push-marks.sh +227 -31
  91. package/assets/hooks/git-guard-push-tests.sh +51 -53
  92. package/assets/hooks/git-guard-tree-assignment.sh +7 -4
  93. package/assets/hooks/guard-note.sh +8 -6
  94. package/assets/hooks/handoff-entry-guard.sh +20 -39
  95. package/assets/hooks/handoff-write.sh +3 -1
  96. package/assets/hooks/hook-input.sh +0 -41
  97. package/assets/hooks/metric-marks.sh +19 -7
  98. package/assets/hooks/observe.sh +1 -1
  99. package/assets/hooks/override-write-guard.sh +27 -9
  100. package/assets/hooks/pre-push.sh +20 -10
  101. package/assets/hooks/prose-style-guard.sh +6 -19
  102. package/assets/hooks/pull-merges.sh +76 -0
  103. package/assets/hooks/push-set.sh +39 -7
  104. package/assets/hooks/qa-dataid-guard.sh +7 -17
  105. package/assets/hooks/record-turn.sh +52 -0
  106. package/assets/hooks/rerun-guard.sh +11 -16
  107. package/assets/hooks/reuse-first-guard.sh +7 -21
  108. package/assets/hooks/role-calls.sh +25 -3
  109. package/assets/hooks/rule-source-guard.sh +54 -21
  110. package/assets/hooks/skill-gate-rearm.sh +18 -5
  111. package/assets/hooks/skill-gate.sh +156 -20
  112. package/assets/hooks/skill-loaded.sh +18 -3
  113. package/assets/hooks/sql-guard-target.sh +2 -2
  114. package/assets/hooks/sql-guard-write.sh +12 -12
  115. package/assets/hooks/sql-guard.sh +58 -16
  116. package/assets/hooks/task-context-load.sh +3 -1
  117. package/assets/hooks/task-flow-context.sh +20 -22
  118. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  119. package/assets/hooks/task-flow-guard.sh +28 -129
  120. package/assets/hooks/tree-assignment-guard.sh +25 -14
  121. package/assets/hooks/turn-entry-load.sh +3 -1
  122. package/assets/hooks/turn-exit-guard.sh +92 -452
  123. package/assets/hooks/turn-exit-role.sh +47 -0
  124. package/assets/hooks/turn-judge.md +103 -0
  125. package/assets/hooks/window-fill-guard.sh +22 -41
  126. package/assets/laws/work-conduct.md +9 -8
  127. package/assets/patterns/autonomous-work-run.md +35 -10
  128. package/assets/patterns/browser-verification-measure.md +10 -20
  129. package/assets/patterns/browser-verification-stand.md +30 -42
  130. package/assets/patterns/doc-style-human.md +0 -6
  131. package/assets/patterns/doc-style-sweep.md +7 -7
  132. package/assets/patterns/doc-style-trace.md +5 -4
  133. package/assets/patterns/doc-style-write.md +7 -7
  134. package/assets/patterns/epic-flow-declare.md +15 -8
  135. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  136. package/assets/patterns/git-workflow-commit.github.md +11 -269
  137. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  138. package/assets/patterns/git-workflow-docker.md +8 -231
  139. package/assets/patterns/git-workflow-freshness.md +9 -56
  140. package/assets/patterns/git-workflow-merge.md +7 -174
  141. package/assets/patterns/git-workflow-migration.md +5 -73
  142. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  143. package/assets/patterns/git-workflow-pr-ready.md +9 -69
  144. package/assets/patterns/git-workflow-pr.azure.md +14 -220
  145. package/assets/patterns/git-workflow-pr.github.md +13 -253
  146. package/assets/patterns/git-workflow-pr.gitlab.md +14 -241
  147. package/assets/patterns/git-workflow-restart.md +5 -41
  148. package/assets/patterns/git-workflow-secrets.md +10 -76
  149. package/assets/patterns/git-workflow-stack.md +9 -205
  150. package/assets/patterns/lib-layers-new.md +7 -3
  151. package/assets/patterns/queue-audit-read.github.md +9 -3
  152. package/assets/patterns/spec-driven-domain.md +50 -48
  153. package/assets/patterns/spec-driven-rule.md +18 -19
  154. package/assets/patterns/status-report-table.github.md +2 -2
  155. package/assets/patterns/task-flow-archive.md +15 -256
  156. package/assets/patterns/task-flow-close.md +16 -291
  157. package/assets/patterns/task-flow-cycle.md +13 -39
  158. package/assets/patterns/task-flow-graph.needs-graph.md +8 -58
  159. package/assets/patterns/task-flow-handoff.md +13 -161
  160. package/assets/patterns/task-flow-resume.md +19 -183
  161. package/assets/patterns/task-flow-start.md +9 -248
  162. package/assets/patterns/testing-e2e.md +14 -18
  163. package/assets/patterns/testing-unit.md +9 -13
  164. package/assets/patterns/turn-entry-map.md +15 -5
  165. package/assets/pitfalls/agent-kit-extend.md +200 -0
  166. package/assets/pitfalls/agent-kit.2.md +323 -0
  167. package/assets/pitfalls/angular-patterns.md +98 -0
  168. package/assets/pitfalls/autonomous-work.md +15 -0
  169. package/assets/pitfalls/browser-verification.md +265 -0
  170. package/assets/pitfalls/component-structure.md +98 -0
  171. package/assets/pitfalls/dependencies.md +92 -0
  172. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  173. package/assets/pitfalls/deploy-flow.github.md +211 -0
  174. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  175. package/assets/pitfalls/doc-style.2.md +286 -0
  176. package/assets/pitfalls/doc-style.md +3 -3
  177. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  178. package/assets/pitfalls/entity-models.md +89 -0
  179. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  180. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  181. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  182. package/assets/pitfalls/git-workflow-docker.md +275 -0
  183. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  184. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  185. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  186. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  187. package/assets/pitfalls/git-workflow-merge.md +220 -0
  188. package/assets/pitfalls/git-workflow-migration.md +103 -0
  189. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  190. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  191. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  192. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  193. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  194. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  195. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  196. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  197. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  198. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  199. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  200. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  201. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  202. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  203. package/assets/pitfalls/git-workflow-restart.md +72 -0
  204. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  205. package/assets/pitfalls/git-workflow-stack.md +254 -0
  206. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  207. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  208. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  209. package/assets/pitfalls/git-workflow.github.md +5 -9
  210. package/assets/pitfalls/lib-layers.md +114 -0
  211. package/assets/pitfalls/lists.md +117 -0
  212. package/assets/pitfalls/navigation.md +94 -0
  213. package/assets/pitfalls/reuse-first.md +201 -0
  214. package/assets/pitfalls/spec-driven.2.md +318 -0
  215. package/assets/pitfalls/spec-driven.md +9 -7
  216. package/assets/pitfalls/styling-bem.2.md +125 -0
  217. package/assets/pitfalls/task-flow-archive.md +264 -0
  218. package/assets/pitfalls/task-flow-close.2.md +165 -0
  219. package/assets/pitfalls/task-flow-close.md +167 -0
  220. package/assets/pitfalls/task-flow-cycle.md +73 -0
  221. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  222. package/assets/pitfalls/task-flow-handoff.md +200 -0
  223. package/assets/pitfalls/task-flow-handover.md +30 -0
  224. package/assets/pitfalls/task-flow-owner.md +29 -0
  225. package/assets/pitfalls/task-flow-plan.md +29 -0
  226. package/assets/pitfalls/task-flow-resume.md +257 -0
  227. package/assets/pitfalls/task-flow-start.md +287 -0
  228. package/assets/pitfalls/task-flow.2.md +303 -0
  229. package/assets/pitfalls/task-flow.md +18 -29
  230. package/assets/pitfalls/testing.2.md +279 -0
  231. package/assets/pitfalls/testing.md +11 -12
  232. package/assets/pitfalls/turn-conduct.md +17 -18
  233. package/assets/pitfalls/typescript-conventions.md +161 -0
  234. package/assets/pitfalls/write-a-skill.md +128 -0
  235. package/assets/rules/angular-patterns.md +21 -86
  236. package/assets/rules/autonomous-work.md +37 -29
  237. package/assets/rules/browser-verification.md +28 -251
  238. package/assets/rules/component-structure.md +25 -87
  239. package/assets/rules/dependencies.md +20 -78
  240. package/assets/rules/deploy-flow.azure.md +27 -134
  241. package/assets/rules/deploy-flow.github.md +34 -196
  242. package/assets/rules/deploy-flow.gitlab.md +28 -137
  243. package/assets/rules/doc-style.md +32 -282
  244. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  245. package/assets/rules/entity-models.md +14 -63
  246. package/assets/rules/epic-flow.md +5 -3
  247. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  248. package/assets/rules/git-workflow-hosting.github.md +38 -0
  249. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  250. package/assets/rules/git-workflow-push.azure.md +28 -0
  251. package/assets/rules/git-workflow-push.github.md +28 -0
  252. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  253. package/assets/rules/git-workflow-queue.azure.md +23 -0
  254. package/assets/rules/git-workflow-queue.github.md +30 -0
  255. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  256. package/assets/rules/git-workflow.azure.md +21 -264
  257. package/assets/rules/git-workflow.github.md +24 -285
  258. package/assets/rules/git-workflow.gitlab.md +21 -258
  259. package/assets/rules/lib-layers.md +30 -103
  260. package/assets/rules/lists.md +21 -105
  261. package/assets/rules/navigation.md +10 -69
  262. package/assets/rules/queue-audit.github.md +5 -3
  263. package/assets/rules/reuse-first.md +20 -195
  264. package/assets/rules/spec-driven.md +35 -316
  265. package/assets/rules/status-report.md +5 -3
  266. package/assets/rules/styling-bem.md +20 -117
  267. package/assets/rules/task-flow-handover.md +24 -0
  268. package/assets/rules/task-flow-owner.md +34 -0
  269. package/assets/rules/task-flow-plan.md +38 -0
  270. package/assets/rules/task-flow.md +22 -289
  271. package/assets/rules/testing.md +32 -270
  272. package/assets/rules/turn-conduct.md +109 -111
  273. package/assets/rules/turn-entry.md +2 -2
  274. package/assets/rules/typescript-conventions.md +41 -147
  275. package/assets/samples/tasks/_template/plan.md +30 -6
  276. package/assets/samples/tasks/_template/progress.md +0 -1
  277. package/assets/skills/agent-kit-extend.md +25 -168
  278. package/assets/skills/agent-kit.md +27 -299
  279. package/assets/skills/write-a-skill.md +20 -106
  280. package/assets/task-flow/flow.js +188 -0
  281. package/assets/task-flow/flow.md +102 -0
  282. package/assets/task-flow/measure/agreement.mjs +24 -0
  283. package/assets/task-flow/measure/copy.mjs +22 -0
  284. package/assets/task-flow/measure/epic-of.mjs +50 -0
  285. package/assets/task-flow/measure/epic-text.mjs +35 -0
  286. package/assets/task-flow/measure/epic.mjs +114 -0
  287. package/assets/task-flow/measure/folder.mjs +16 -0
  288. package/assets/task-flow/measure/footprint.mjs +28 -0
  289. package/assets/task-flow/measure/grill.mjs +21 -0
  290. package/assets/task-flow/measure/host.mjs +8 -0
  291. package/assets/task-flow/measure/owner.mjs +20 -0
  292. package/assets/task-flow/measure/plan.mjs +27 -0
  293. package/assets/task-flow/measure/pr.mjs +20 -0
  294. package/assets/task-flow/measure/progress.mjs +50 -0
  295. package/assets/task-flow/measure/session.mjs +175 -0
  296. package/assets/task-flow/measure/task.mjs +23 -0
  297. package/assets/task-flow/measure/text.mjs +77 -0
  298. package/assets/task-flow/source/git.mjs +86 -0
  299. package/assets/task-flow/source/host.mjs +172 -0
  300. package/assets/task-flow/source/marks.mjs +56 -0
  301. package/assets/task-flow/source/owner.mjs +74 -0
  302. package/assets/task-flow/source/records.mjs +116 -0
  303. package/assets/task-flow/source/session.mjs +232 -0
  304. package/assets/task-flow/source/steps.mjs +28 -0
  305. package/assets/task-flow/source/tree.mjs +42 -0
  306. package/assets/templates/rule.md +2 -2
  307. package/bin/agent-kit.d.ts.map +1 -1
  308. package/bin/agent-kit.js +30 -0
  309. package/bin/agent-kit.js.map +1 -1
  310. package/lib/agent-checks.d.ts +55 -0
  311. package/lib/agent-checks.d.ts.map +1 -0
  312. package/lib/agent-checks.js +209 -0
  313. package/lib/agent-checks.js.map +1 -0
  314. package/lib/assets.d.ts.map +1 -1
  315. package/lib/assets.js +7 -2
  316. package/lib/assets.js.map +1 -1
  317. package/lib/cargo-prose.d.ts +2 -1
  318. package/lib/cargo-prose.d.ts.map +1 -1
  319. package/lib/cargo-prose.js.map +1 -1
  320. package/lib/cargo.d.ts +29 -0
  321. package/lib/cargo.d.ts.map +1 -1
  322. package/lib/cargo.js +27 -1
  323. package/lib/cargo.js.map +1 -1
  324. package/lib/cascade.d.ts.map +1 -1
  325. package/lib/cascade.js +3 -1
  326. package/lib/cascade.js.map +1 -1
  327. package/lib/commands.d.ts.map +1 -1
  328. package/lib/commands.js +78 -2
  329. package/lib/commands.js.map +1 -1
  330. package/lib/companion.d.ts +0 -5
  331. package/lib/companion.d.ts.map +1 -1
  332. package/lib/companion.js +1 -1
  333. package/lib/companion.js.map +1 -1
  334. package/lib/config.d.ts +18 -0
  335. package/lib/config.d.ts.map +1 -1
  336. package/lib/config.js +18 -1
  337. package/lib/config.js.map +1 -1
  338. package/lib/cost.d.ts +0 -8
  339. package/lib/cost.d.ts.map +1 -1
  340. package/lib/cost.js +4 -4
  341. package/lib/cost.js.map +1 -1
  342. package/lib/epic-window-send.d.ts +74 -0
  343. package/lib/epic-window-send.d.ts.map +1 -0
  344. package/lib/epic-window-send.js +166 -0
  345. package/lib/epic-window-send.js.map +1 -0
  346. package/lib/hooks-map.d.ts +4 -12
  347. package/lib/hooks-map.d.ts.map +1 -1
  348. package/lib/hooks-map.js +4 -27
  349. package/lib/hooks-map.js.map +1 -1
  350. package/lib/integrity.d.ts +3 -0
  351. package/lib/integrity.d.ts.map +1 -1
  352. package/lib/integrity.js +7 -0
  353. package/lib/integrity.js.map +1 -1
  354. package/lib/metric-lines.d.ts +2 -1
  355. package/lib/metric-lines.d.ts.map +1 -1
  356. package/lib/metric-lines.js +49 -1
  357. package/lib/metric-lines.js.map +1 -1
  358. package/lib/metric-send-mark.d.ts +6 -3
  359. package/lib/metric-send-mark.d.ts.map +1 -1
  360. package/lib/metric-send-mark.js +15 -5
  361. package/lib/metric-send-mark.js.map +1 -1
  362. package/lib/metric-send.d.ts +6 -2
  363. package/lib/metric-send.d.ts.map +1 -1
  364. package/lib/metric-send.js +47 -13
  365. package/lib/metric-send.js.map +1 -1
  366. package/lib/metrics.d.ts +17 -0
  367. package/lib/metrics.d.ts.map +1 -1
  368. package/lib/metrics.js +26 -15
  369. package/lib/metrics.js.map +1 -1
  370. package/lib/observations-cargo.d.ts +1 -5
  371. package/lib/observations-cargo.d.ts.map +1 -1
  372. package/lib/observations-cargo.js +2 -2
  373. package/lib/observations-cargo.js.map +1 -1
  374. package/lib/observations.d.ts +0 -2
  375. package/lib/observations.d.ts.map +1 -1
  376. package/lib/observations.js +3 -3
  377. package/lib/observations.js.map +1 -1
  378. package/lib/order.d.ts +0 -2
  379. package/lib/order.d.ts.map +1 -1
  380. package/lib/order.js +0 -4
  381. package/lib/order.js.map +1 -1
  382. package/lib/outcomes.d.ts +7 -9
  383. package/lib/outcomes.d.ts.map +1 -1
  384. package/lib/outcomes.js +8 -7
  385. package/lib/outcomes.js.map +1 -1
  386. package/lib/proposals.d.ts +0 -1
  387. package/lib/proposals.d.ts.map +1 -1
  388. package/lib/proposals.js +1 -1
  389. package/lib/proposals.js.map +1 -1
  390. package/lib/push-gate.d.ts +13 -0
  391. package/lib/push-gate.d.ts.map +1 -1
  392. package/lib/push-gate.js +11 -7
  393. package/lib/push-gate.js.map +1 -1
  394. package/lib/push-set-usefulness.d.ts +78 -0
  395. package/lib/push-set-usefulness.d.ts.map +1 -0
  396. package/lib/push-set-usefulness.js +225 -0
  397. package/lib/push-set-usefulness.js.map +1 -0
  398. package/lib/shipment.d.ts +2 -11
  399. package/lib/shipment.d.ts.map +1 -1
  400. package/lib/shipment.fixture.d.ts +0 -3
  401. package/lib/shipment.fixture.d.ts.map +1 -1
  402. package/lib/shipment.fixture.js +3 -3
  403. package/lib/shipment.fixture.js.map +1 -1
  404. package/lib/shipment.js +2 -2
  405. package/lib/shipment.js.map +1 -1
  406. package/lib/sync.d.ts +10 -0
  407. package/lib/sync.d.ts.map +1 -1
  408. package/lib/sync.js +14 -1
  409. package/lib/sync.js.map +1 -1
  410. package/lib/traits.d.ts +0 -3
  411. package/lib/traits.d.ts.map +1 -1
  412. package/lib/traits.js +2 -2
  413. package/lib/traits.js.map +1 -1
  414. package/lib/variants.d.ts +0 -1
  415. package/lib/variants.d.ts.map +1 -1
  416. package/lib/variants.js +1 -1
  417. package/lib/variants.js.map +1 -1
  418. package/lib/work-result.d.ts +43 -0
  419. package/lib/work-result.d.ts.map +1 -0
  420. package/lib/work-result.js +39 -0
  421. package/lib/work-result.js.map +1 -0
  422. package/package.json +1 -1
  423. package/assets/checks/signals/ui-kit.json +0 -11
  424. package/assets/hooks/claim-guard.sh +0 -212
  425. package/assets/hooks/grill-gate-ask.sh +0 -26
  426. package/assets/hooks/grill-gate-bypass.sh +0 -61
  427. package/assets/hooks/grill-gate-options.sh +0 -50
  428. package/assets/hooks/grill-gate.sh +0 -482
  429. package/assets/hooks/postmortem-guard.sh +0 -124
  430. package/assets/hooks/proposal-guard.sh +0 -154
  431. package/assets/hooks/stand-login-guard.sh +0 -107
  432. package/assets/hooks/turn-exit-epic.sh +0 -173
  433. package/assets/hooks/turn-exit-patterns.sh +0 -123
  434. package/assets/hooks/turn-exit-verdict.sh +0 -149
  435. package/assets/hooks/waiting-turn-guard.sh +0 -320
  436. package/assets/hooks/work-start-guard.sh +0 -175
@@ -19,35 +19,47 @@ demand, not with the rule.
19
19
  | In the law | Here |
20
20
  | --- | --- |
21
21
  | turn | one pass of the agent: from the owner's message to the reply |
22
- | a turn exit | one of the four ways to end a turn; what confirms each — the turn map |
23
- | the guard of turn exits | a guard at the turn's end: reads the declared work state and what the turn did in the tree |
22
+ | a turn exit | the end of the scenario or the owner's stop word; the other release cases of the task flow description |
23
+ | the guard of turn exits | a guard at the turn's end: asks the engine to measure the branch by the task flow description |
24
+ | the agent hook of the turn's end | a model at the turn's end: reads the owner's last message, the reply and the calls of the turn |
24
25
  | a statement about the state of the tree | a word in the reply to the owner backed by a command of the same turn and its output |
25
- | the session handover | a record outside the tree retelling the progress for a new session |
26
+ | the session handover | a section of the progress retelling it for a new session; a file outside the tree where there is no task folder |
26
27
  | the compaction threshold and the stop threshold | two window-fill numbers the tree sets itself; the first stands below the second |
27
28
 
28
29
  ## Turn exits
29
30
 
30
- A turn ends in four ways and no others: a question to the owner the rules do not answer **and no
31
- task in the work queue that can be taken without waiting for the answer**; a guard's refusal; a
32
- filled window where there is no compaction; work handed in, with the next begun. What confirms
33
- each, the turn map lists where the tree laid it out. While an epic has an unfinished task, a turn
34
- ends by these four alone.
31
+ A turn ends when the scenario is over or when the owner's last word is a stop word. The owner put it
32
+ so: «Только твоё «стоп»». The exit guard measures the branch by the task flow description and holds
33
+ every other turn with the one move that comes next, unless a release case below is met.
34
+
35
+ <!-- flow:turn-end -->
36
+ The engine lets a turn end before the scenario does when a case is met, asked in this order:
37
+
38
+ - **1** · the end of the scenario — `any(measure.epic.finished, all(measure.copy.outsideEpic, measure.pr.handed))`
39
+ - **2** · a stop word of the owner — `measure.owner.saidStop`
40
+ - **3** · a background task of the session runs — `all(measure.session.waiting, not(measure.pr.handed))`
41
+ - **4** · no write to the tree, or a branch outside the scenario — `any(measure.copy.outOfScenario, all(not(measure.session.wrote), not(measure.owner.nudged)))`
42
+ - **5** · a role session — `measure.session.role`
43
+ - **6** · the host did not answer twice — `measure.host.silent`
44
+ - **8** · the menu did not reach the owner — `measure.session.menuLost`
45
+ <!-- /flow:turn-end -->
46
+
47
+ A question to the owner, a guard's refusal, a handover and handed-in work do not end a turn. A
48
+ question waits for its answer inside the turn, a refusal is answered by the next call, and handed-in
49
+ work is followed by the next task. A step that another guard refuses twice
50
+ goes to the owner as one menu with the options of the description: «отложить RT-N», «стоп».
35
51
 
36
52
  The queue is asked by a command in the same turn: "there are no tasks" is a statement about the
37
- tree, and the executor's memory does not confirm it. A turn where the owner's answer holds one
38
- piece of work while an independent one lies next to it ends with the work taken, and the question
39
- goes in a line beside it.
53
+ tree, and the executor's memory does not confirm it.
40
54
 
41
- Everything else is the turn going on, not its end. A milestone does not end a turn: not a commit,
42
- not a read agreement, not the boundary "read — now editing", not a green check.
43
- A transition from state to state — least of all: the next mandatory action is done in the same
44
- turn, and a state boundary looks like a finished piece better than any milestone.
55
+ Everything else is the turn going on. A milestone does not end a turn: not a commit, not a read
56
+ agreement, not the boundary "read — now editing", not a green check.
57
+ A transition from state to state — least of all: the next mandatory action is done in the same turn.
45
58
 
46
- Four ways to end a turn look like work and are not: a summary of someone else's step, a menu under
47
- an assigned order, a declaration of intent, and a command named but not run.
59
+ Four stops look like work and are not: a summary of someone else's step, a menu under an assigned
60
+ order, a declaration of intent, and a command named but not run.
48
61
 
49
- A turn ending while an epic runs shows the owner their position by the table the handover carries:
50
- the order is written down, and the one it is followed for cannot otherwise see the queue's state.
62
+ A turn ending while an epic runs shows the owner their position by the epic's table: otherwise they cannot see the queue's state.
51
63
 
52
64
  ## Where it lives
53
65
 
@@ -60,32 +72,27 @@ One turn: what it ends with, what is checked before its end and what the owner i
60
72
 
61
73
  ```mermaid
62
74
  flowchart TD
63
- A[The turn is going] --> B{What happened}
64
- B -->|A question to the owner| C[Laws and rules read in the same turn]
65
- B -->|A guard refused an edit| D[The refusal named to the owner, no bypass sought]
66
- B -->|The window is filled| E{The tree declared compaction}
67
- B -->|Work handed in by a PR| F[An action done on the next task, not spoken]
68
- B -->|None of these| G[The turn goes on: a milestone never ends it]
69
- E -->|Yes| G
70
- E -->|No| H[Progress written up, handover written]
71
- C --> I{The reply speaks of the tree}
72
- D --> I
73
- F --> I
74
- H --> I
75
+ A[The turn is going] --> B{The engine measures the branch}
76
+ B -->|The scenario is over| L[The epic table shown]
77
+ B -->|The owner's last word is a stop word| I
78
+ B -->|Another release case of the description| I
79
+ B -->|None| D{The next move}
80
+ D -->|The executor's step| G[Done in the same turn: a question, a refusal, a handover never end it]
81
+ D -->|Another guard refuses it twice| M[One menu: «отложить RT-N», «стоп»]
82
+ M --> A
83
+ G --> A
84
+ L --> I{The reply speaks of the tree}
75
85
  I -->|Yes| J[Every word carries a command of the same turn and its output]
76
86
  I -->|No| K[The turn is over]
77
87
  J --> K
78
- G --> A
79
88
  ```
80
89
 
81
90
  ## How the law applies here
82
91
 
83
- - **A promise to do the work in the next turn is an announcement of intent.** It differs from a
84
- command named and not run only in that it sounds politer and is therefore recognised as
85
- a stop less often.
92
+ - **A promise to do the work in the next turn is an announcement of intent.** It sounds politer than
93
+ a command named and not run, and so is recognised as a stop less often.
86
94
  - **An order named by a number or by the word "all" is counted aloud before the turn ends.** The reply carries the count — how many out of how many. A turn where the count did
87
- not add up does not end: it goes on with the next item of the order. How many items the order
88
- holds is written nowhere in the tree — only whoever read the order knows it.
95
+ not add up does not end: it goes on with the next item of the order.
89
96
  - **The owner's word to work without stops holds until they cancel it themselves.** A turn ending
90
97
  with waiting for that same word invents the cancellation. A new fact against the instruction is a
91
98
  line about the price in the reply, not waiting; a decision the tree does not hold is asked as a
@@ -102,11 +109,12 @@ flowchart TD
102
109
  lawful only where neither the rules nor the tree answer it; the list is written after all the
103
110
  executor could close is struck out.
104
111
  - **A menu under an assigned order.** A choice offered to the owner before the epic is over asks to
105
- assign the order anew. No work left in the epic — say so: the epic is over — not "what next".
112
+ assign the order anew. No work left in the epic — say so, show its table and ask for the next
113
+ work.
106
114
  - **No order at all is a lawful state, and it is said, not filled.** A queue card is not an order.
107
115
  The turn names that there is no order and asks for one.
108
116
  - **A standing order is written into the progress in the owner's words.** Read once, «merge every
109
- PR» is lost at the first refusal; the line «Waiting for the owner: no — <their words>» carries it.
117
+ PR» is lost at the first refusal; a decision along the way carries it, quoted.
110
118
  - **Done work is shown on the running application built from it.** Host pages show delivery, not
111
119
  «what did you do».
112
120
  - **A declaration of intent.** "Taking the next task" is not taking it: the phrase lives to the end
@@ -137,15 +145,11 @@ flowchart TD
137
145
  - **A stop is named in a message of its own.** Not in a line at the end of a report: there it drowns
138
146
  — the owner reads a report as an account of the done. Three things are named: what stands, what it
139
147
  waits for and what the owner can decide.
140
- - **Turn exits are watched by a guard, not by the executor's memory.** It reads the declared work state and what
141
- the turn did on it: a file edit or a tree-changing command. A turn with neither returns to the
142
- executor with the next step from the progress.
143
- - **A removed task folder lifts the state requirement and does not end the turn.** The progress
144
- leaves with the folder, taken apart before the PR opens; a removed folder means the middle of
145
- handing in, not its end. From there the turn is judged by the second sign.
146
- - **Work without a branch and without a task folder is judged by the same guard by the second
147
- sign.** It has no state, and the first sign has nowhere to come from — but a turn with no edit of
148
- the tree does not end here either.
148
+ - **Turn exits are watched by a guard, not by the executor's memory.** It asks the engine, and the
149
+ engine measures the state of the branch: nothing is declared. What the reply says — a promise, a
150
+ report instead of the next step — the agent hook on the same event judges by meaning.
151
+ - **A removed task folder lifts the state requirement.** The progress leaves with the folder, taken
152
+ apart before the PR opens; a removed folder means the middle of handing in, not its end.
149
153
  - **A taken task is not yet begun work, and the turn does not end on it.** Creating the branch,
150
154
  moving the column and naming the number are preparation: the mandatory action of `задача-взята` is
151
155
  not done by a single line. An epic branch, named by the header of its plan, carries no folder by
@@ -156,70 +160,61 @@ flowchart TD
156
160
  - **A reply to the owner is not an action and does not stand last in a turn.** The order inside a
157
161
  turn is one: work, the first step of the next, then text; what was done is said after the next
158
162
  action, not instead of it.
159
- - **The last action of a turn is only ever work.** One sign for every kind of stop: a file edit or a
160
- changing command — last among what the turn did. The guard's tiers — exploration, waiting, handing
161
- in without starting the next — only derive a readable refusal from it.
163
+ - **The last action of a turn is only ever work.** A file edit or a changing command stands last
164
+ among what the turn did. The exit guard does not read the last call: a turn whose scenario is not
165
+ over is held whatever stood last, unless a release case is met.
162
166
  - **Waiting for someone else's step is never the last action of a turn.** While they are waited for,
163
167
  the work stays where it stood. The last action is judged: waiting mid-turn is lawful, and so is a
164
- launch in the background mid-turn. Standing last, it is an announcement of intent: what does not depend on it is done while it runs.
168
+ launch in the background mid-turn. Standing last, it ends the turn only as a wait the record shows: a background task of the session with no end, younger than twenty minutes, once per task and not after the work is handed over. What does not depend on it is done first.
165
169
  - **The handover is written even where the branch has no name.** All of it lies in the tree and is
166
170
  reachable on a detached head; one file needs a name, and a short snapshot of the head gives it.
167
171
  Otherwise compaction comes without a handover, and the next session starts from a blank.
168
- - **A next step written into the progress is begun by the same turn.** The guard reads the order
169
- of actions: after the last edit of the progress it wants work other than the commit and the push
170
- of it. A full report and a moved stage number do not replace the step.
171
- - **A plan stage is declared closed only after its check command has passed.** The "Checked by"
172
- (`Чем проверяется`) line carries the command in backticks and what in its output means "matches".
173
- The guard reads the previous stage number from the branch history and holds a turn where the
174
- number grew and the command did not run.
175
- - **The end of an epic is a stop, and it is the one lawful waiting for a word.** The turn shows
176
- the table of the epic's tasks, what was done on each and what confirms it, and says that the
177
- session waits for orders. On the main branch the epic is not read, and the turn is judged as before.
172
+ - **A next step written into the progress is begun by the same turn.** The held turn names the
173
+ current step and the command that measures it. A full report and a moved stage number do not
174
+ replace the step.
175
+ - **A plan stage is declared closed only after its check command has passed.** Every step of the
176
+ plan carries a check line: a command in backticks and the expected output. The engine runs it and
177
+ writes the mark of the step; a step marked done without its mark is refused.
178
+ - **The end of an epic is the end of the scenario, and the turn ends there.** The turn shows the
179
+ epic's tasks in the table of rule `status-report`, not the handover's; new work is taken by the
180
+ owner's word, given in the permission window the guard opens on the call that takes it — not
181
+ guessed from the conversation. On the main branch the epic is not read.
178
182
  <!-- rt-when: ответ владельцу о состоянии работы -->
179
183
 
180
184
  - **A step of the plan that is not done forbids a stop, and a report about the done is not an
181
- exception.** The tier about the epic judges the whole and says nothing about a turn inside one
182
- task. The count is read from the progress; lawful exits stay as they were.
185
+ exception.** The engine counts the steps by their marks, and a running stage holds the turn
186
+ whatever the report says.
183
187
  - **The word about a stop the guard reads from the owner, not from the executor.** Otherwise the
184
188
  stop is declared by whoever finds it convenient, and the ban holds until the first inconvenience.
185
- - **Until the epic is closed a turn ends only by one of the four exits.** A turn that ended with
186
- work is a stop all the same, and so is a second pass over the same turn: the exit guard judges
187
- both by the epic and returns the turn with the next step named. The end of the epic is the fifth.
188
- - **The owner's standing word about a stop is quoted in the progress, in « », in the line «Waiting
189
- for the owner».** The guard reads their word, not a retelling: a line without a quote releases
190
- nothing, and a quote holds until the owner cancels it. A word said in this turn releases by itself.
189
+ - **Until the scenario is over a turn ends only by the owner's stop word or by a release case.** A question, a refusal, a
190
+ handover and a second pass are the turn going on: the exit guard returns each with the next move
191
+ named. The other release cases of the description are not the executor's to choose.
192
+ - **The owner's word about a stop is read from the record of the session, not from the progress.**
193
+ A stop written on disk by the executor is a retelling. The guard reads the owner's last message,
194
+ typed or the free text of a menu answer, and a stop word holds only while that message is the last.
191
195
  - **The session is ended by the owner and by nobody else.** The tool that closes the conversation is
192
196
  refused by a guard always, with no lawful form of bypass: an assignment stands until the owner
193
197
  cancels it, and a session that must close is closed by them.
194
- - **A refusal of a guard ends the turn only as its last action, and only a refusal of work.** A
195
- refusal answered by the next call is the middle of the turn. A refused stop — the closing tool —
196
- is no exit: the refused call was itself the stop, and the exit guard leaves it out.
197
- - **The phrase "waiting for your word" is a stop declared by the executor, and the guard refuses it
198
- by name.** Without the owner's word about a stop in the turn and without a question put to them by
199
- the tool, waiting for their word is a report, not work; the instruction holds until they cancel
200
- it.
201
- - **A statement about the tree's state is watched by the statement guard, not by the executor's
198
+ - **A refusal of a guard never ends the turn.** It is answered by the next call: the condition met,
199
+ another step taken, or the owner's menu put to them. A refused stop — the
200
+ closing tool — is no exit either.
201
+ - **The phrase "waiting for your word" is a stop declared by the executor.** Without the owner's stop
202
+ word, waiting for their word is a report, not work. A decision that is theirs goes to them as a
203
+ menu, and the turn waits for the answer inside itself. The agent hook judges it by meaning.
204
+ - **A statement about the tree's state is watched by the agent hook, not by the executor's
202
205
  memory.** Everything the reply says about the tree carries a command and its output; said without
203
- one, it is no statement — not "checked", not "cleared", not "done". The guard reads the turn's
204
- text to the owner and looks for a command of the same turn; each word has its own kind of
205
- command.
206
- - **The statement guard waits for the reply text rather than judging the record as it found it.**
207
- The text lands in the turn record no earlier than the host calls the hook. Not having waited, the
208
- guard returns the turn: an empty record means not "nothing to say" but "nothing to read".
209
- - **The guard catches a statement word, not a wrong conclusion.** About a sample judged by one file
210
- there is nothing to judge by: no word and no command to compare with. This is the guard's known boundary; the articles below hold it, not the guard.
211
- - **A turn about someone else's step is watched by the waiting guard, not by the executor's
212
- memory.** It refuses a turn's end where someone else's step was spoken of and nothing was done on
213
- the next task — no task created, no branch, no folder, no column moved. Someone else's step it
214
- knows by two signs: a PR opened or a red run read in the turn.
206
+ one, it is no statement — not "checked", not "cleared", not "done". The hook reads the reply and
207
+ the results of the turn's calls.
208
+ - **A wrong conclusion from a right command is not judged.** About a sample judged by one file there
209
+ is nothing to compare with. This is the hook's known boundary; the articles below hold it.
210
+ - **A turn that handed work in does not end before the next task is begun.** Someone else's step —
211
+ the run, the review, the merge — goes without the executor. Handed-in work is a measured state, and
212
+ its exit is the next task of the epic taken.
215
213
  - **A turn that handed work in carries it to a lifted draft.** A draft's merge button is locked by
216
214
  the host, and in the PR list ready cannot be told from unfinished. The next task is taken on top
217
- of that, not instead. The waiting guard demands a command of the same turn about the state of the
218
- handed-in work.
219
- - **The waiting guard's refusal is lifted by both actions at once.** The taken next task carries the
220
- open-PR sign away, and the demand to ask the handed-in work's state never sounds after it.
215
+ of that, not instead.
221
216
  - **Work left in the working tree does not end the turn.** A branch ahead of the remote ref with no
222
- open PR is done work nobody sees; the guard reads this without the network.
217
+ open PR is done work nobody sees, and the scenario goes on until the PR.
223
218
  - **"Waiting for the run" is a statement about someone else's step, not a work state.** A run may be
224
219
  green in an hour, or may never have started — and the second does not fix itself. The word demands
225
220
  a command of the same turn that shows the run; said bare, the owner reads it as "the work is still
@@ -229,14 +224,13 @@ flowchart TD
229
224
  repeated idly or not at all — the work does not move.
230
225
  - **A run nobody started by hand is watched the same as a rerun, and the opened PR starts it.** The
231
226
  pipeline wakes by itself: the turn holds no starting command, and one read of the state closes
232
- nothing. Read as going, the run goes under a wait in the same turn — the waiting guard watches
233
- the pair "the request opened here, its run read as going".
227
+ nothing. Read as going, the run goes under a wait in the same turn.
234
228
  - **A green run is carried to a lifted draft by the one who handed the work over, a red one is
235
229
  fixed in the same branch.** The owner sees a locked button and reads it as work still going. The
236
230
  wait runs in the background, next to the next work.
237
231
  - **Waiting for one's own measurement is done with one wait, not a notification on every step.** A
238
232
  notification is for where every event is acted on; where the outcome matters — one wait.
239
- - **A guard's refusal ends the turn.** No other road to the refused edit is sought: not a shell
233
+ - **A guard's refusal closes every other road to the refused edit.** None is sought: not a shell
240
234
  command, not a neighbouring tool, not an edit of the guard itself. The edit is done once the
241
235
  refusal's condition is met, or not at all — then the owner is told the refusal, not a result.
242
236
  - **A command refused by a gate is repeated whole, not by its tail.** A gate refuses the call before
@@ -247,10 +241,9 @@ flowchart TD
247
241
  For a call with a reading twin, the kind is chosen by the action, not the command's name.
248
242
  - **A turn in which a question was put to the owner does not end until laws and rules were read in
249
243
  that same turn.** Reading is any of three roads: loading a rule, reading a file of laws or rules,
250
- a search over them. With edits in the turn, only the rule the gate demands counts, and the
251
- refusal names it. The guard refuses on the question tool before the menu leaves, and at
252
- the turn's end for a question in prose. What was found lands in the grill section "What the
253
- rules already say".
244
+ a search over them. What was found lands in the grill section "What the rules already say". The
245
+ agent hook of the question tool holds a question a rule or a spec answers plainly; whether the
246
+ reading was done in the same turn no check counts.
254
247
  - **The owner's answer is sought in their own messages before the rules.** The law says a question
255
248
  with a written answer is not put to the owner, and the most reachable record lies in the
256
249
  conversation: the owner's first message and their answers to past rounds.
@@ -271,11 +264,10 @@ flowchart TD
271
264
  - **The sign of irreversibility is taken from the list, not derived by argument.** The list was
272
265
  drawn up by someone who already weighed reversibility, and an argument cancels it silently. Actions outside the list the executor does not gate.
273
266
  - **A turn in which the executor admitted a miss does not end until the incident record exists.**
274
- The incident guard refuses at the turn's end. The records directory is named by the rule's companion, the file name is the date and
275
- the miss, the form — the layout template. The admission is caught by a set of samples: a miss
276
- admitted in words outside the set the guard lets through.
267
+ The agent hook refuses at the turn's end. The records directory is named by the rule's companion,
268
+ the file name is the date and the miss, the form — the layout template.
277
269
  - **A session begun from a handover enters the work by the same rule as any other.** The handover
278
- lies outside the tree, no check reads it, and it was written yesterday: everything in it is
270
+ was written by a past session, no check reads it, and it describes yesterday: everything in it is
279
271
  checked against the tree. The entry order is four steps in the resume pattern; a guard watches it,
280
272
  not memory.
281
273
  - **The state of unfinished work comes into the context at session start.** The plan and the
@@ -304,12 +296,18 @@ flowchart TD
304
296
 
305
297
  ## What of the law is not here
306
298
 
307
- Nothing checks the completeness of what is said to the owner: the statement guard catches a
308
- statement word and looks for a command of the same turn; a wrong conclusion from a right command it
309
- cannot judge — there is nothing to compare with.
299
+ Nothing checks the completeness of what is said to the owner: the agent hook judges whether a result
300
+ of the turn shows a statement; a wrong conclusion from a right command it cannot judge — there is
301
+ nothing to compare with.
302
+
303
+ What a turn said is judged by a model, and a model can let a case pass. The hook is told to let a
304
+ doubtful turn end: a false refusal costs the owner a repeated answer, a missed one is visible in the
305
+ reply. A broken or timed-out hook lets every turn end, and that shows only as the absence of its
306
+ mark in the transcripts.
310
307
 
311
- An admission of a miss is caught by samples, not by understanding: words outside the set the
312
- incident guard lets through. That is its known boundary, not a promise.
308
+ The exit guard measures, it does not judge meaning. An engine that fails, runs past its limit or
309
+ cannot be called releases the turn and writes the failure to the journal; the next turn begins with
310
+ that line.
313
311
 
314
312
  ## Patterns
315
313
 
@@ -19,7 +19,7 @@ into the session.
19
19
  | --- | --- |
20
20
  | session entry | what the startup hook puts into the context before the first reply |
21
21
  | what the past session handed over | the "Session handover" section in the progress of this branch; for work without a task folder — a file named after the branch in the handovers directory. The hook writes it before context compaction |
22
- | the order of conducting work | the turn map — the states with their mandatory actions and the four turn exits |
22
+ | the order of conducting work | the turn map — the states with their mandatory actions and the two ends of a turn |
23
23
  | a launch | first launch, resume, context compaction, clear |
24
24
 
25
25
  ## Where it lives
@@ -41,7 +41,7 @@ flowchart TD
41
41
  B2 -->|No| D[Nothing is said about a handover]
42
42
  C --> E{The turn map resource is laid out}
43
43
  D --> E
44
- E -->|Yes| F[The map goes next: states, actions, four exits]
44
+ E -->|Yes| F[The map goes next: states, actions, two ends of a turn]
45
45
  E -->|No| G[Nothing is said about a map]
46
46
  F --> H[The hook exits with zero: the launch is refused on no outcome]
47
47
  G --> H
@@ -7,160 +7,54 @@ description: Rule under the code-structure law. Load when editing any .ts except
7
7
 
8
8
  # Code structure — how it works here
9
9
 
10
- Rule under the law `docs/constitution/code-structure.md`. The law says what must be true about
11
- declarations; here — how that is written in this tree.
12
-
13
- ## What it is called here
14
-
15
- | In the law | Here |
16
- | ----------------------------- | -------------------------------------------------------------------- |
17
- | the kind sign in the name | a prefix: `I` on an interface, `E` on an enum, `T` on a type |
18
- | a watched source | the `$` suffix on an observable and `Source` on a subject |
19
- | a private field | `#field`, not `private field` |
20
- | a backend procedure | a class with the `@ConnectProcedure()` decorator, one per procedure |
21
-
22
- ## Where it lives
23
-
24
- In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
25
- travels between repositories, the layout does not, and a path named in the rule lies in the
26
- first tree that keeps its code differently.
27
-
28
- ## Flow
29
-
30
- The flow of declaring a symbol: what sets the name, where the type comes from and what is done
31
- with a removed declaration.
32
-
33
- ```mermaid
34
- flowchart TD
35
- A[A symbol is declared] --> B[The kind shows in the name prefix, and the file suffix promises what lies inside]
36
- B --> C{The type is already declared somewhere}
37
- C -->|Yes| D[Taken from the package where it is declared: an own copy diverges from the original silently]
38
- C -->|No| E[Declared here]
39
- D --> F{The value arrives in the wrong shape}
40
- E --> F
41
- F -->|Yes| G[The cast goes by the named way; a two-step one is forbidden]
42
- F -->|No| H{The declaration is removed}
43
- G --> H
44
- H -->|Yes| I[The deprecation mark is set together with a walk over all consumers]
45
- H -->|No| J[The file stays within the length limit, complexity is asked from the plugin, not recalled]
46
- I --> J
47
- ```
10
+ Rule under the law `docs/constitution/code-structure.md`. Cold part: `pitfalls.md` — the whole text,
11
+ every section and article with its reasons.
48
12
 
49
13
  ## How the law applies here
50
14
 
51
- - **The kind of a declaration shows in the name prefix, and three linter rules hold that.** The
52
- interface, the type and the enum each have their own; all three are raised for all `.ts`.
53
- <!-- rt-when: *.ts -->
54
-
55
- - **A watched source is named by a suffix.** The subject and the observable raised from it differ
56
- at the place of use, not by jumping to the declaration.
57
- <!-- rt-when: *.ts -->
58
-
59
- - **The file name suffix finds the promised declaration inside.** The list of suffixes is closed:
60
- a word not in it does not count as a suffix, and the rule does not judge such a file.
61
- <!-- rt-when: *.ts -->
62
-
63
- - **A file is no longer than 500 lines, and all lines count — blank ones and comments too.** A
64
- file that does not fit on one screen whole is read in parts, and an edit in it is made without
65
- seeing the rest. For `.ts` a linter rule holds this; harness files — scenarios and scripts — do
66
- not reach it and are judged by a separate check of the tree. What had accumulated by the day of
67
- enabling is listed by name, and a line leaves that list together with the split of its file.
68
- <!-- rt-when: *.ts -->
69
-
70
- - **A value from a closed set arrives as an enum `E<Name>`, not as a string or a number at the
71
- place of use.** The key of a translatable field, a tab name, a cover slot, a record kind — all
72
- these are sets: the form, the store, the markup and the draft comparison name them, and a value
73
- written in place is neither found across the tree nor edited in one go. The enum lives in the
74
- `util` layer of the domain that owns the set, and what is shared by several applications — in
75
- the shared lib. A single address, a separator and a signature sign do not become an enum: they
76
- have no closed set, and they are declared as a file constant with a telling name.
77
- <!-- rt-when: *.ts -->
78
-
79
- - **A set that must be complete is declared as a full record over the key type, not a partial
80
- one.** A partial declaration makes a missing key lawful, and the shortage shows on the screen
81
- rather than at the build. The set that must answer for every key of another one is declared by
82
- that key type whole, and an unfilled key stops compiling. The type is silent about the value —
83
- an empty string and a copy of the key pass it — so the completeness of values is held by a test
84
- that walks the whole set, written by the same change as the declaration.
85
- <!-- rt-when: *.ts -->
15
+ - **The kind of a declaration shows in the name prefix, and three linter rules hold that.**
16
+ <!-- rt-when: *.ts -->
17
+ - **A watched source is named by a suffix.**
18
+ <!-- rt-when: *.ts -->
19
+ - **A file name suffix promises a declaration of that kind inside.**
20
+ <!-- rt-when: *.ts -->
21
+ - **A file is no longer than 500 lines, and all lines count — blank ones and comments too.**
22
+ <!-- rt-when: *.ts -->
23
+ - **A value from a closed set arrives as an enum `E<Name>`, not as a string or a number at the place
24
+ of use.**
25
+ <!-- rt-when: *.ts -->
26
+ - **A set that must be complete is declared as a full record over the key type, not a partial one.**
27
+ <!-- rt-when: *.ts -->
28
+ - **A type is taken from the package where it is declared.**
29
+ <!-- rt-when: *.ts -->
30
+ - **A value declared by one side of an exchange is not recomputed by the other side but taken from
31
+ the first.**
32
+ <!-- rt-when: *.ts -->
33
+ - **The two-step cast `as unknown as` is forbidden by a linter rule.**
34
+ <!-- rt-when: *.ts -->
35
+ - **A deprecation mark is set together with a walk over the consumers.**
36
+ <!-- rt-when: *.ts -->
86
37
 
87
- - **A type is taken from the package where it is declared.** An own copy of a foreign type
88
- diverges from the original silently, and only one of them compiles.
89
- <!-- rt-when: *.ts -->
90
-
91
- - **A value declared by one side of an exchange is not recomputed by the other side but taken
92
- from the first.** Two computations of one value diverge silently: the tree trait was computed by
93
- both the send and the mark — each with its own copy — the copies diverged, and the mark never
94
- once found a single record of its own. Both sides answered as usual all the while, and the miss
95
- was found only from a third side: by reading what actually landed.
96
- <!-- rt-when: *.ts -->
97
-
98
- - **The two-step cast `as unknown as` is forbidden by a linter rule.** Instead — an honest type,
99
- narrowing by a check or reading the field by shape (`Reflect.get`); a place where nothing else
100
- works is marked with a spot disable and the reason on the same line.
101
- <!-- rt-when: *.ts -->
102
-
103
- - **A deprecation mark is set together with a walk over the consumers.** All rules of
104
- `eslint-plugin-sonarjs` are raised to refusal at once, and a mark on a type paints every place
105
- that still calls it: one `@deprecated` per file gave seventeen findings in foreign domains.
106
- <!-- rt-when: *.ts -->
107
-
108
- ## What of the law is not here
109
-
110
- A one-step cast stays unchecked — that is `Q-CS-4` in the law: of seventy-six casts eight are
111
- mandatory, and a blanket ban would refuse them.
38
+ ## Pitfalls
112
39
 
113
- Tests are taken out from under the ban entirely: a hand-written database double is an accepted
114
- technique here, and the ban would have to be bypassed in each of the thirty-five.
40
+ - **Function complexity limits are asked from the plugin, not recalled.**
41
+ - **A decision is moved into a pure function of the util layer before the handler is written.**
42
+ - **A file an edit pushed past the 500-line limit is split, not squeezed.**
115
43
 
116
- The file-name rule judges a promise, not its absence: `menu.items.ts` and `sign-in.ts` do not
117
- fall under it at all — that is `Q-CS-3` in the law. Of the two mapper forms accepted here — a
118
- class on the front end and pure functions on the backend — the rule accepts both: it judges the
119
- name, not the structure, and that there are two forms remains the question `Q-S-1` in the
120
- shared-code law.
44
+ ## Names and techniques
121
45
 
122
- On `libs/api/**` and `apps/api/**` the rule applies whole, but the signal API and `inject` do
123
- not belong there: that is NestJS with constructor DI.
46
+ - Prefix `I` on an interface, `E` on an enum, `T` on a type.
47
+ - Suffix `$` on an observable, `Source` on a subject.
48
+ - A private field is `#field`, not `private field`; `protected` where `viewChild` needs it.
49
+ - An enum lives in the owner domain's `util`; a value with no closed set is a file constant.
50
+ - Completeness of values is held by a test over the whole set, in the same change.
51
+ - Use an honest type, narrowing or `Reflect.get`; else a spot disable with its reason.
52
+ - On `libs/api`, `apps/api` no signals or `inject`: NestJS constructor DI.
53
+ - No `as Type` in a mapper; use `this.typeCast`.
54
+ - Remove an unused parameter; do not hide it behind an underscore.
55
+ - Do not annotate a Prisma aggregate with a type of your own.
56
+ - Enable a linter rule of your own together with fixing all it catches.
124
57
 
125
58
  ## Patterns
126
59
 
127
- - `ts-procedure` — create a Connect procedure on the backend: class, decorator, right,
128
- registration.
129
-
130
- ## Pitfalls
131
-
132
- - **Function complexity limits are asked from the plugin, not recalled.** Where the tree raised
133
- the `sonarjs` rules at once, to refusal, the branching and nesting numbers come as plugin
134
- defaults and are not written by a line of their own in the config: they change with its
135
- version while looking like a tree agreement. Over one task they were asked three times, each
136
- time anew, and twice named from memory — both times wrong.
137
-
138
- ```bash
139
- node -e 'const s = require("eslint-plugin-sonarjs");
140
- for (const n of ["cyclomatic-complexity", "cognitive-complexity", "nested-control-flow"])
141
- console.log(n, JSON.stringify(s.rules[n].meta.defaultOptions));'
142
- ```
143
-
144
- - **A decision is moved into a pure function of the util layer before the handler is written.** A
145
- choice over a closed set becomes a table keyed by the enumeration, and a chain of field checks
146
- becomes a list of checks. The handler calls them and keeps its branchings for its own flow: the
147
- complexity linter refused one file twice because both lay right in the handler and spent its limit.
148
- - **A file an edit pushed past the 500-line limit is split, not squeezed.** Joining comments or
149
- dropping blank lines lowers the count and leaves the file just as long to read, and the next
150
- edit hits the limit again. What the file does on its own moves out next to it: a mapping, a set of
151
- derived values.
152
-
153
- - A cast through `as Type` in a mapper is forbidden but watched by nothing: it accepts any value
154
- and compiles. Instead — `this.typeCast`.
155
- - An unused parameter is removed, not renamed: an underscore before the name hides the finding,
156
- but the parameter stays in the signature.
157
- - A Prisma aggregate is not annotated with its own type: its generated type is wider than the
158
- query result, and the annotation lies.
159
- - A linter rule of one's own is enabled together with converting everyone it catches: enabled on
160
- top of what has accumulated, it gives a red run on files the edit did not touch.
161
- - `#field` is visible only inside the class and is not accepted by `viewChild` — there the field
162
- is declared `protected`.
163
- - The linter does not count a logical assignment as a read of a private field: where `??=` is the
164
- only access to the field, the unused-private-members rule answers "is defined but never used".
165
- The field is live, and the message says the opposite, and whoever read the refusal goes to
166
- remove the declaration. The replacement — an explicit early return and an assignment after it.
60
+ - `ts-procedure` — a Connect procedure on the backend.