@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
@@ -7,82 +7,43 @@ description: Rule under the mockups law. Load when a screen is drawn or changed
7
7
 
8
8
  # Mockups — how it works here
9
9
 
10
- Rule under the law `docs/constitution/mockups.md`. The law says what the owner must see before
11
- the code is written; here — what it is called in this tree, where it lives and what is not checked.
10
+ Rule under the law `docs/constitution/mockups.md`. Cold part: `pitfalls.md`. Where it lives: the
11
+ table in `implementation.md` next to it.
12
12
 
13
13
  ## What it is called here
14
14
 
15
- | In the law | Here |
16
- | ----------------------------------- | ---------------------------------------------------------------------------- |
17
- | mockup | a frame on a sheet of the design tool |
18
- | the screen the mockup draws | the page or panel in the application that carries the same name |
19
- | a sheet of the design file | a file page, never a page of the application |
20
- | the description of the behaviour | the domain spec in `docs/specs/<domain>/` |
21
- | the agreement | the product agreement of the task, `docs/specs/<domain>/proposed/<feature>/` |
22
- | approved | shown to the owner and accepted in their words |
23
-
24
- ## Where it lives
25
-
26
- In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
27
- travels between repositories, the layout does not, and a path named in the rule lies in the
28
- first tree that keeps its code differently.
29
-
30
- ## Flow
31
-
32
- The flow of a mockup from the first frame to the code: what is read before drawing, what is
33
- measured before showing, and what is checked before work starts by the agreement.
34
-
35
- ```mermaid
36
- flowchart TD
37
- A[A screen is to be drawn or changed] --> B{The behaviour already exists in the tree}
38
- B -->|Yes| C[The spec of its domain is read before the first frame]
39
- B -->|No| D[A sample is asked per screen]
40
- C --> E{A component of the kit goes on the sheet}
41
- D --> E
42
- E -->|Yes| F[It is measured in the running showcase and compared with the copy by numbers]
43
- E -->|No| G[The frames are drawn]
44
- F --> G
45
- G --> H[The coordinates of the frames are measured]
46
- H --> I[The owner approves the mockups]
47
- I --> J{The agreement has visual rules}
48
- J -->|Yes| K[Each rule is found on the mockup of every width; a rule the mockups do not show goes to the owner]
49
- J -->|No| L[The code is written]
50
- K --> L
51
- ```
15
+ | In the law | Here |
16
+ | --- | --- |
17
+ | mockup | a frame on a sheet of the design tool |
18
+ | the screen the mockup draws | the page or panel in the application that carries the same name |
19
+ | a sheet of the design file | a file page, never a page of the application |
20
+ | the description of the behaviour | the domain spec in `docs/specs/<domain>/` |
21
+ | the agreement | the product agreement of the task, `docs/specs/<domain>/proposed/<feature>/` |
22
+ | approved | shown to the owner and accepted in their words |
52
23
 
53
24
  ## How the law applies here
54
25
 
55
26
  - **A kit component on a design-tool sheet is a copy of the kit, and the copy drifts.** The source
56
- of look is the kit's styles in code. Before a component from the sheet goes into a mockup, it is
57
- measured in the running showcase, and its sizes, alignment and controls are compared with the
58
- bounds of the copy's nodes by numbers. Reading the styles does not show what the layout computes:
59
- the height of a row, where unselected items sit, a control that replaces an icon. A divergence is
60
- a question to the owner, and the answer is fixed once in the copy.
61
- - **A mockup of behaviour the tree already has starts with reading the spec of its domain.** A
62
- screen in a design tool looks like work without code, so exploration stops at the sheet of earlier
63
- mockups. How a payment is taken, what a window asks and which fields a form holds are already
64
- described by the spec and carried out by code. The spec is read before the first frame, and the
65
- sample question is asked per screen: one sheet named as the sample of the whole set leaves the
66
- other screens without one.
67
- - **The agreement is checked against the approved mockups before work by it.** Every visual rule of
68
- the agreement is found on the mockup of each width. A rule the mockups do not show goes to the
69
- owner as a question. Found after the code, it costs a code edit and an agreement edit together.
70
- - **A mockup is measured by node coordinates before it is shown.** The technique is the pattern
71
- `mockups-measure`.
27
+ of look is the kit's styles in code. Before the component goes into a mockup, it is measured in
28
+ the running showcase, and its sizes, alignment and controls are compared with the bounds of the
29
+ copy's nodes by numbers; a divergence is a question to the owner, fixed once in the copy.
30
+ - **A mockup of behaviour the tree already has starts with reading the spec of its domain.** The
31
+ spec is read before the first frame. With a spec or without one, the sample is asked per screen,
32
+ not once for the whole set.
33
+ - **The agreement is checked against the approved mockups before work by it.** Every visual rule is
34
+ found on the mockup of each width; a rule the mockups do not show goes to the owner as a question.
35
+ - **A mockup is measured by node coordinates before it is shown.** Pattern `mockups-measure`.
72
36
  - **An audit of a design file is accepted only when every file page that draws a kit component is
73
- captured, measured and compared with the code of that component.** Names, properties and the list
74
- of variants say what a node is called, not what it draws: an arc drawn as a sector and a rounded
75
- field drawn as a capsule keep correct names. The technique and the report are the pattern
76
- `mockups-measure`.
37
+ captured, measured and compared with the code of that component.** Names, properties and variants
38
+ do not show what a node draws. Pattern `mockups-measure`.
77
39
  - **A design-tool call asks the rules gate for this rule,** like the browser driver does for its
78
- own: without that the measurement pattern stays unread for the whole mockup task.
40
+ own: otherwise the measurement pattern stays unread.
79
41
 
80
42
  ## What of the law is not here
81
43
 
82
- Nothing checks that a mockup matches the screen it draws or that the owner approved it: both live
83
- outside the tree, in the design tool and in the owner's words. The checks above are held by reading.
44
+ Nothing checks that a mockup matches its screen or that the owner approved it: both live outside
45
+ the tree. The checks above are held by reading.
84
46
 
85
47
  ## Patterns
86
48
 
87
- - `mockups-measure` — reading the bounds of frames and buttons in one call and what the numbers
88
- mean.
49
+ - `mockups-measure` — the bounds of frames and buttons in one call and what the numbers mean.
@@ -7,9 +7,8 @@ description: Rule under the navigation law. Load when editing the menu declarati
7
7
 
8
8
  # Admin navigation — how it works here
9
9
 
10
- Rule under the law `docs/constitution/navigation.md`. The law says how the user finds a section and
11
- gets into it; here — what the menu is assembled from in this tree and how it looks. The look is
12
- spoken of by the rule: the law is silent about it on purpose.
10
+ Rule under the law `docs/constitution/navigation.md`. Cold part: `pitfalls.md`. Where it lives: the
11
+ table in `implementation.md` next to it.
13
12
 
14
13
  ## What it is called here
15
14
 
@@ -21,79 +20,21 @@ spoken of by the rule: the law is silent about it on purpose.
21
20
  | unread sign | a dot, comes as a predicate by the item id |
22
21
  | the "no screen yet" flag | `disabled` in the declaration |
23
22
 
24
- ## Where it lives
25
-
26
- In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
27
- travels between repositories, the layout does not, and a path named in the rule lies in the first
28
- tree that keeps its code differently.
29
-
30
- ## Flow
31
-
32
- The flow of creating a section: one declaration per item and route, two layers of gating and the
33
- data path into the header.
34
-
35
- ```mermaid
36
- flowchart TD
37
- A[A section is created] --> B[The item is declared once: it is the source of both the menu and route gating]
38
- B --> C{What closes the section}
39
- C -->|A user right| D[The right stands in the item declaration]
40
- C -->|A section flag| E[The item is declared without a screen of its own, with a hint why]
41
- C -->|Nothing| F[The item is open to everyone signed in]
42
- D --> G[The route is closed by the same declaration, not by a list of its own]
43
- E --> G
44
- F --> G
45
- G --> H{The header needs domain data}
46
- H -->|Yes| I[It comes by a token: the declaration does not import the application shell]
47
- H -->|No| J[Done]
48
- I --> J
49
- ```
23
+ Items without a screen are rolled out as unavailable, not removed. The header is drawn by the kit;
24
+ the project only declares items.
50
25
 
51
26
  ## How the law applies here
52
27
 
53
28
  - **An item is declared once and serves as the source of both the menu and route gating.** A second
54
- declaration next to the routes would drift from the first, and the result would be "the item is
55
- not visible, but the page opens".
56
- - **The declaration imports no `shell`.** Otherwise the graph `shell → container/feature → shell`
57
- closes into a cycle and the layout check stops.
58
- - **Gating has two layers: the user right and the section flag.** An item with a flag is declared
59
- without rights and without an address — a right opens the screen, and there is no screen; it is
60
- visible to everyone all the while.
29
+ declaration drifts: the item is not visible, but the page opens.
30
+ - **The declaration imports no `shell`.** It would close a cycle through `container/feature`.
31
+ - **Gating has two layers: the user right and the section flag.** The flag marks an item with no
32
+ screen yet: it has no rights and no address, and stays visible to everyone.
61
33
  - **Domain data comes into the header by a token, not by an import.** The interface and the
62
- `InjectionToken` live in `container/util`; the composition root ties them to the implementation.
63
-
64
- ## What of the law is not here
65
-
66
- The menu holds seventeen second-level items and the "Finance" section that have no screen yet: they
67
- are rolled out as unavailable, because a vanished item cannot be told from one that never existed.
68
-
69
- The rendering of the header itself lives in `rt-page-header` from `@rt-tools/ui-kit-v2`. The project
70
- does not write it and cannot break it: it declares the items, and the kit draws them. The kit sets:
71
-
72
- - the hint on an unavailable item and `aria-disabled` instead of the native `disabled`;
73
- - section highlighting by address prefix;
74
- - opening the second-level panel on hover, and on touch — by a tap;
75
- - the panel layout in columns, inside a column — in groups with a caption; if the first group in a
76
- column has no heading, its items start from the top of the panel;
77
- - the panel width by the number of columns, not by the length of captions, and its fit from its own
78
- section to the right edge of the screen;
79
- - the expand pointer on a section with a panel and its absence on a section without one;
80
- - a separate mobile layout: the menu collapses into a button, expands with the same sections and
81
- groups and scrolls when the items do not fit in height.
82
-
83
- None of this the rule binds to project code: there is nothing to bind.
34
+ `InjectionToken` live in `container/util`; the composition root binds the token to the domain
35
+ implementation.
84
36
 
85
37
  ## Patterns
86
38
 
87
39
  - `admin-nav-item` — create a menu item and its route: the declaration, rights, the flag, address
88
40
  nesting, the caption in all locales.
89
-
90
- ## Pitfalls
91
-
92
- - An unavailable item has no click handler at all: `aria-disabled` does not refuse a click.
93
- - A branch where the ro-route constant was not merged in differs only in that the button in the
94
- header opens nothing on it.
95
- - Groups inside an expanded section on a narrow screen do not collapse separately, so the set of
96
- expanded ones holds only section ids.
97
- - The panel width is computed by the number of columns, not by the content; the numbers are set by
98
- `--rt-*` tokens, raw values are forbidden by the styling rule.
99
- - An address move touches links and the e2e specs — they walk by addresses.
@@ -7,185 +7,56 @@ description: Rule under the observability law. Load when editing the logger, the
7
7
 
8
8
  # Observability — how it works here
9
9
 
10
- Rule under the law `docs/constitution/observability.md`. The law says what the owner must know
11
- about the running application; here — what it is called in this tree, where it lives and what
12
- is not here yet.
13
-
14
- ## What it is called here
15
-
16
- | In the law | Here |
17
- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
18
- | what the application writes about itself | application logs: one line per logger call, in machine form |
19
- | the step of importance | the level: from debugging details to a failure that took the process down |
20
- | the request number | the request id, also the response header |
21
- | the marker by which all failures of one request are found | the same request number — it stands in every log line |
22
- | failure details | the parsed cause: class, text, protocol code, code and details from the storage, a trimmed stack |
23
- | the generic error text going outside | an internal error without details |
24
- | scrubbing secrets | replacing values by field name |
25
- | a failure in the store | what the failures domain saved: a failure group and its occurrences |
26
- | what the application came up with | the startup digest: one log line with the version, the port, the storage address and the lists of features — enabled, disabled and broken |
27
-
28
- ## Where it lives
29
-
30
- In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
31
- travels between repositories, the layout does not, and a path named in the rule lies in the
32
- first tree that keeps its code differently.
33
-
34
- ## Flow
35
-
36
- The flow of handling a request through the eyes of observability: where the request number is
37
- created, how a failure differs from a breakage and what goes outside.
38
-
39
- ```mermaid
40
- flowchart TD
41
- A[A request arrives] --> B{The request number came from outside}
42
- B -->|Yes| C[Cleaned and shortened]
43
- B -->|No| D[Created anew, one for the whole request]
44
- C --> E[Stands in every log line about this request]
45
- D --> E
46
- E --> F{How the work ended}
47
- F -->|Done| G[The response leaves with the request number in the header]
48
- F -->|Input or rights| H[Written apart from a breakage and without a stack: a check that fired]
49
- F -->|Breakage| I[The cause is parsed in one place, the line fields are always scrubbed]
50
- H --> J[Outside — a code and a generic text; the details stay in the logs]
51
- I --> J
52
- J --> K[The request number stands in the failure details too]
53
- G --> L[Done]
54
- K --> L
55
- ```
10
+ Rule under the law `docs/constitution/observability.md`. Cold part: `pitfalls.md`; paths: `implementation.md`.
11
+
12
+ | In the law | Here
13
+ | --- | ---
14
+ | what the application writes about itself | application logs: one line per logger call, in machine form
15
+ | the step of importance | the level: from debugging details to a failure that took the process down
16
+ | the request number | the request id, also the response header
17
+ | the marker by which all failures of one request are found | the same request number — it stands in every log line
18
+ | failure details | the parsed cause: class, text, protocol code, code and details from the storage, a trimmed stack
19
+ | the generic error text going outside | an internal error without details
20
+ | scrubbing secrets | replacing values by field name
21
+ | a failure in the store | what the failures domain saved: a failure group and its occurrences
22
+ | what the application came up with | the startup digest: one log line with the version, the port, the storage address and the lists of features — enabled, disabled and broken
56
23
 
57
24
  ## How the law applies here
58
25
 
59
- - **The request number is created once per request and stands in every log line about it.** By
60
- time the lines of one request cannot be picked out: there are a dozen requests a second.
61
- - **The request number goes to the caller as a response header and in the failure details.** It
62
- also stands in the logs, so a number named by a person is found by a direct filter. The header
63
- is open to a page of a foreign domain: without explicit permission the browser does not hand
64
- it over.
26
+ - **The request number is created once per request and stands in every log line about it.**
27
+ - **The request number goes to the caller as a response header and in the failure details.** Expose it cross-origin.
65
28
  - **A number that came from outside is cleaned and shortened, and an empty one is created anew.**
66
- The value from the header comes from anyone, and it lands in a filter over the store.
67
- - **Outside goes the code and a generic error text; the details stay in the logs.** Otherwise a
68
- guest on a broken rollout reads a column name and the storage layout.
69
- - **A failure on input or rights is written apart from a breakage and without a stack.** It is a
70
- check that fired. On one level with breakages it floods the alarm with guests' typos.
71
- - **The cause of a failure is parsed in one place.** Otherwise the same error arrives in the logs
72
- in three different shapes.
73
- - **A field added to the answer of a refusal is added where the answer is assembled, not where the
74
- refusal is thrown.** The application parses failures in one place and builds the body there out
75
- of what it knows: every throw may name the field, and the body carries none of them. Neither the
76
- linter nor the tests next to the throws see it — the loss shows on the screen of whoever reads
77
- the answer.
78
- - **The fields of a log line are always scrubbed, not at the discretion of whoever writes.**
79
- Deciding on every call whether the fields hold a secret means being wrong once.
80
- - **At startup the application writes what it came up with.** Half of the features are enabled by
81
- the presence of an environment variable and are silently off without it. Otherwise the
82
- question "why does it not work there when it works locally" is answered by reading the
83
- production settings over ssh.
84
- - **The startup digest holds the names of features and their state, but not the values of
85
- variables.** The states are laid out as three lists, not as a map "name → state": scrubbing
86
- works by key name, and the map would arrive in the log scrubbed exactly where the state is
87
- needed.
88
- - **A feature enabled by a pair of keys knows a third state.** The halves of the pair lie on
89
- different sides of the delivery, and exactly one can be filled; then the feature is neither off
90
- nor on but broken — a list of two states has no name for this case, and it reads as enabled.
91
- - **The level threshold decides whether a log line appears in the output, but not in the failure
92
- store.** The threshold is set for the volume of output, and under a high threshold the selected
93
- lines of a lower level would silently vanish from the store.
94
- - **A selected log line is saved to the store as a failure.** Selected are the failure level and
95
- everything above it, and lines of a lower level — by a list of names declared in the code.
96
- - **The logger hands a failure to the sink and does not see the store.** The sink interface is
97
- declared next to the logger, the failures domain implements it, and it is set from outside at
98
- startup.
99
- - **Log lines of the storage client, the failures domain and the alerts domain do not go to the
100
- sink.** The source is cut off, not the moment of writing: a slow insert into the failures table
101
- itself produces a log line of the storage client, and a marker "I am inside a write" cannot
102
- catch it. The alerts domain is cut off for the same reason: a failed alert would become a new
103
- failure, and that one — a new alert.
104
- - **A call to a foreign service goes with an explicit wait limit.** Without it a silent — not
105
- failed — service holds the connection up to the environment default, and that is minutes: there
106
- is no failure, nothing to record, and to the owner such silence is indistinguishable from
107
- healthy work. The limit is named as a number next to the client, because the price of waiting
108
- differs per service.
109
- - **A send outside creates its own line before the call, and the outcome is appended to it
110
- after.** The line is created by whoever sees the store, not by whoever sends: the client of the
111
- external service does not see the store at all. The line also serves as a lock — a second call
112
- on the same record does not leave — and an unclosed line shows the difference between "running
113
- right now" and "fell in the middle of sending".
114
- - **Recording a failure does not delay the response and does not take the request down.**
115
- Between the logger and the store stands a bounded queue; a full queue drops the new failure and
116
- counts what was dropped.
117
- - **The request context is captured at the moment of the logger call, not at the moment of
118
- writing.** By the time of writing the execution storage has already been handed to the next
119
- request.
120
- - **The owner reads what was recorded in their own section, closed by a separate right.** The
121
- groups that are theirs, and under a group — its occurrences with the cause, the log line fields
122
- and the bodies.
29
+ - **Outside goes the code and a generic error text; the details stay in the logs.**
30
+ - **A failure on input or rights is written apart from a breakage and without a stack.** A level below breakage.
31
+ - **The cause of a failure is parsed in one place.**
32
+ - **A field added to the answer of a refusal is added where the answer is assembled, not where the refusal is thrown.**
33
+ - **The fields of a log line are always scrubbed, not at the discretion of whoever writes.** A foreign-body key is checked against the key lists.
34
+ - **At startup the application writes what it came up with.**
35
+ - **The startup digest holds the names of features and their state, but not the values of variables.**
36
+ - **A feature enabled by a pair of keys knows a third state.** One half filled — broken.
37
+ - **The level threshold decides whether a log line appears in the output, but not in the failure store.**
38
+ - **A selected log line is saved to the store as a failure.** Failure level up; lower by a declared list.
39
+ - **The logger hands a failure to the sink and does not see the store.**
40
+ - **Log lines of the storage client, the failures domain and the alerts domain do not go to the sink.** Cut by source, not by moment.
41
+ - **A call to a foreign service goes with an explicit wait limit.**
42
+ - **A send outside creates its own line before the call, and the outcome is appended to it after.** Made where the store is seen; also the lock.
43
+ - **Recording a failure does not delay the response and does not take the request down.** A full queue drops the new one and counts.
44
+ - **The request context is captured at the moment of the logger call, not at the moment of writing.**
45
+ - **The owner reads what was recorded in their own section, closed by a separate right.**
123
46
  - **The store does not grow without limit: once a day the excess and the old are removed.**
124
- Occurrences are removed: first the excess beyond the limit, then the old beyond the age.
125
- A group left with no occurrence after that goes in a third step — and only if it is older than
126
- an hour: between its creation and its first occurrence a separate request passes.
127
- - **The store limit is named in rows, not bytes.** Deletion does not shrink the physical size of
128
- the table, and the condition "size under the limit" would never become true.
129
- - **The owner learns of a new failure by themselves — by an event journal line and by mail.**
130
- Both roads are opened by one threshold: a new group, or a group silent for longer than a day.
131
- - **The mail holds nothing that is closed by the right to the failures screen.** It goes to an
132
- address closed by no right, and details in it would bypass the right by mail.
133
- - **The owner reads the failure rate as a curve above the feed: a bar is a bucket of the chosen
134
- period.** The group counter says how many times it happened, but not when: by it a breakage
135
- streaming right now cannot be told from one accumulated over a month.
136
- - **The alarm is raised by growth in breakages, not in all failures.** A rejected call is a check
137
- that fired, and those are nine in ten: against them growth in breakages is not visible at all.
47
+ - **The store limit is named in rows, not bytes.**
48
+ - **The owner learns of a new failure by themselves — by an event journal line and by mail.** On a new group or one silent a day.
49
+ - **The mail holds nothing that is closed by the right to the failures screen.**
50
+ - **The owner reads the failure rate as a curve above the feed: a bar is a bucket of the chosen period.**
51
+ - **The alarm is raised by growth in breakages, not in all failures.**
138
52
  - **A spike is counted over the last closed bucket; the current one is not given to the rule.**
139
- It is still filling, and at the start of every period a comparison with it would show a drop in
140
- the rate.
141
- - **The rate is analysed by a schedule tick, not by a screen request.** The curve computes the
142
- alarm on every response, but the owner may never open the screen, and must learn of a spike
143
- without it.
144
- - **The owner learns of a spike by a journal line and by mail; a repeat of the mail is held by a
145
- fuse.** One incident takes one line in the feed, and a mail about a lasting breakage is needed
146
- the next day too.
53
+ - **The rate is analysed by a schedule tick, not by a screen request.**
54
+ - **The owner learns of a spike by a journal line and by mail; a repeat of the mail is held by a fuse.** One feed line per incident; a lasting breakage mails next day too; fuse keyed by subject.
147
55
 
148
- ## What of the law is not here
149
-
150
- A failure that happened before the application came up has nowhere to be recorded: the store
151
- does not exist yet at that moment. Such failures stay only in the container output. A failure of
152
- the store itself goes there too: its log lines are excluded from failures entirely, otherwise a
153
- breakage of the store produces a stream that speeds itself up.
154
-
155
- The list of selected lower-level names is checked against nothing. A new place that needs the
156
- store appends itself to it by hand, and a forgotten one silently stays only in the output.
157
-
158
- Nothing checks that the level was chosen right. A new place decides on its own which level to
159
- take, and the mistake shows only when the code is read.
160
-
161
- The completeness of the startup digest is checked by nothing. Feature names are listed by hand,
162
- while the environment variable is read by dozens of files across all domains: a new feature that
163
- forgot to append itself to the digest silently lands in none of the three lists — and in
164
- production looks not disabled but nonexistent. That is why reading an environment variable
165
- itself demands this rule as a second layer: the guard sees the access to the environment in the
166
- text of the edit, but not whether the digest was appended.
56
+ By hand, unchecked: a lower-level name joins the selected list; an environment-read feature
57
+ joins the digest, or is in no list; the level. A failure before startup stays in container output.
58
+ Serialising a log line must not throw. An unwrapped stream's failure never reaches the logs.
167
59
 
168
60
  ## Patterns
169
61
 
170
- - `observability-record` — how to add a new log line.
171
-
172
- ## Pitfalls
173
-
174
- - **The request context lives in the execution storage and does not move into deferred work.** A
175
- deferred write reads the context of the request that took the place of the original one. The
176
- context is captured at the moment of the logger call.
177
- - **The logger is set on the whole application, so the framework lines go the same way as our
178
- own.** Everything the framework writes about itself lands in the same output and the same
179
- selection.
180
- - **A stream failure arrives after the response has started.** Control returns when only the
181
- header has been sent. Without a wrapper such a failure does not reach the logs at all.
182
- - **Serialising a log line must not throw.** Otherwise a circular reference in the fields takes
183
- down the request whose log the fields were assembled for.
184
- - **The key that wraps a foreign body for scrubbing is chosen by the scrubbing rules.** Scrubbing
185
- works by key name, and a bare value passes it entirely — but a key that itself counts as free
186
- text carries the whole body into the store as one scrubbing mark. A new wrapper is checked
187
- against the key lists before it gets such a name.
188
- - **A repeat fuse whose key is built from what measures time never fires.** When the analysis
189
- tick equals the bucket width, every analysis sees an empty lock and sends again. From the
190
- outside it looks working: the fuse is declared, the binding matches, mails go out every hour.
191
- The key is taken from the subject of the alert, not from the stretch of time it is counted by.
62
+ - `observability-record` — a new log line.
@@ -7,93 +7,46 @@ description: Rule under the frontend-application law. Load when an edit touches
7
7
 
8
8
  # Browser environment — how it works here
9
9
 
10
- Rule under the law `docs/constitution/frontend-application.md`. The law says what must be true; here
11
- — what replaces a direct call to the global object in this tree. State — `angular-patterns`, the
12
- component file — `component-structure`, styles — `styling-bem`, the server access layer —
13
- `api-layer`. All five under one law.
14
-
15
- The rule is about the front end: `libs/api/**` and `apps/api/**` are NestJS, the environment there
16
- is its own, and nothing of the listed applies.
10
+ Rule under the law `docs/constitution/frontend-application.md`. Cold part: `pitfalls.md`; paths:
11
+ `implementation.md`. Not for `libs/api/**` and `apps/api/**`: NestJS. Same law:
12
+ `angular-patterns`, `component-structure`, `styling-bem`, `api-layer`.
17
13
 
18
14
  ## What it is called here
19
15
 
20
- | Direct call | Here |
21
- | ---------------------------------------- | ----------------------------------------------------- |
22
- | `globalThis.open(...)`, `window.open()` | `inject(WINDOW).open(...)` |
23
- | `globalThis.crypto.randomUUID()` | `inject(WINDOW).crypto.randomUUID()` |
24
- | `isPlatformBrowser(inject(PLATFORM_ID))` | `inject(PlatformService).isPlatformBrowser` |
25
- | `document.defaultView` | `inject(WINDOW)` |
26
- | direct `document` | `inject(DOCUMENT)` from `@angular/common` — as before |
27
- | DOM initialisation after rendering | `afterNextRender()` |
16
+ | Direct call | Here |
17
+ | --- | --- |
18
+ | `globalThis.open(...)`, `window.open()` | `inject(WINDOW).open(...)` |
19
+ | `globalThis.crypto.randomUUID()` | `inject(WINDOW).crypto.randomUUID()` |
20
+ | `isPlatformBrowser(inject(PLATFORM_ID))` | `inject(PlatformService).isPlatformBrowser` |
21
+ | `document.defaultView` | `inject(WINDOW)` |
22
+ | direct `document` | `inject(DOCUMENT)` from `@angular/common` — as before |
23
+ | DOM initialisation after rendering | `afterNextRender()` |
28
24
 
29
25
  `WINDOW`, `PlatformService` and `StorageService` come from `@rt-tools/core`.
30
26
 
31
- ## Where it lives
32
-
33
- In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
34
- travels between repositories, the layout does not, and a path named in the rule lies in the first
35
- tree that keeps its code differently.
36
-
37
- ## Flow
38
-
39
- The flow of reaching the runtime: how the global object is taken, where the environment is checked
40
- and what is done in a file without dependency injection.
41
-
42
- ```mermaid
43
- flowchart TD
44
- A[Code needs the global object or the environment] --> B{Where it lies}
45
- B -->|A class with dependency injection| C[The global object comes by a token, not taken directly]
46
- B -->|A pure function| D[The window is taken as a parameter: there is no injection there]
47
- C --> E{It matters where the code runs}
48
- D --> E
49
- E -->|Yes| F[The platform service is asked, not the presence of a name in the environment]
50
- E -->|No| G[Work goes on]
51
- F --> G
52
- G --> H{The class is created at application startup}
53
- H -->|Yes| I[Server-side page rendering is checked too: the linter does not see it]
54
- H -->|No| J[Done]
55
- I --> J
56
- ```
57
-
58
27
  ## How the law applies here
59
28
 
60
- - **The global object comes by the `WINDOW` token, not taken directly.** The type is narrowed by a
61
- cast to `Window & typeof globalThis`: constructors like `IntersectionObserver` are declared on the
62
- global object, not on the `Window` interface.
63
- - **The environment is checked through `PlatformService`, not through `typeof window`.** A check by
64
- the presence of a global is right by accident and breaks on the first environment where the global
65
- is stubbed.
66
- - **A direct call to the global object is refused by the linter.** Sixteen browser environment names
67
- are banned on the front-end trees; the three places where direct access is deliberate are taken
68
- out from under the ban by a list in the config, not by a disable on the line.
29
+ - **The global object comes by the `WINDOW` token, not taken directly.** Cast it to `Window & typeof
30
+ globalThis`; DI-less `*.logic.ts` and `*.util.ts` take it as a parameter.
31
+ - **The environment is checked through `PlatformService`, not through `typeof window`.** Storage
32
+ needs none: `StorageService` falls back to memory.
33
+ - **A direct call to the global object is refused by the linter.** Sixteen names on front-end trees;
34
+ deliberate places sit in the config, never disabled per line. Banned by name, not path:
35
+ `this.#document.defaultView` on an injected document is lawful; a bypass looks alike.
69
36
 
70
37
  ## What of the law is not here
71
38
 
72
- The ban acts on names, not on paths to them: the linter lets `this.#document.defaultView` through,
73
- because there is no global name in such a line. Such a call is lawful — the window there already
74
- came by injection — but a real bypass would look the same, and it can be seen only by reading.
39
+ Direct access stays in three places: the inline theme script in `index.html`, the startup failure
40
+ handler in `main.ts`, `page.evaluate` in end-to-end specs. A new one: the owner's word.
75
41
 
76
- Direct access remains in three places, and deliberately: the inline script against theme flicker in
77
- `apps/site/src/index.html` (it runs before the application starts), the startup failure handler in
78
- `apps/*/src/main.ts`, and the code inside `page.evaluate` in the end-to-end specs — it runs in the
79
- page, outside DI. A new place is not added to this list without the owner's explicit agreement.
80
-
81
- ## Patterns
42
+ ## Pitfalls
82
43
 
83
- - `platform-access-di` — ready-made injects, the type cast, pure functions, the environment check.
44
+ - **The `WINDOW` factory throws if the document has no `defaultView`.** `Window is not
45
+ available`. SSR has one: a root service's field inject is safe; a DOM-less service takes it in a method
46
+ under a platform check.
47
+ - **A service created at startup that gains `WINDOW` is checked on a running SSR server too.**
48
+ - **An end-to-end spec does not prepare state by writing to storage.** It walks the user's steps.
84
49
 
85
- ## Pitfalls
50
+ ## Patterns
86
51
 
87
- - **The token factory throws `Window is not available` if the document has no `defaultView`.** Under
88
- server-side page rendering `defaultView` exists, and an inject as a class field in a root service
89
- is safe, but a service that must work without a DOM at all takes the window inside a method under
90
- an environment check.
91
- - **After an edit that adds `WINDOW` to a service created at startup, not only the build is needed
92
- but also a running page-rendering server.** The site is real SSR, and the failure shows only
93
- there.
94
- - **No environment check is needed around storage:** `StorageService` falls back to memory outside
95
- the browser anyway, and an extra `if (!isBrowser)` around a read and a write is dead code.
96
- - **There is no DI in `*.logic.ts` and `*.util.ts`:** the window is taken as a parameter, and the
97
- calling component injects it.
98
- - **Preparing the state of an end-to-end spec by writing to storage is not allowed:** the spec walks
99
- the same steps as the user.
52
+ - `platform-access-di` — ready injects and checks.