@rt-tools/agent-kit 0.26.0 → 0.28.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 (148) hide show
  1. package/assets/agents/cargo-writer.md +54 -0
  2. package/assets/checks/board-epic-link.github.mjs +29 -0
  3. package/assets/checks/board-epic-plan.github.mjs +86 -0
  4. package/assets/checks/board-epics.github.mjs +217 -69
  5. package/assets/checks/board-long-work.github.mjs +5 -1
  6. package/assets/checks/board-pull-state.github.mjs +163 -0
  7. package/assets/checks/board-task-dirs.github.mjs +98 -0
  8. package/assets/checks/board.github.mjs +8 -91
  9. package/assets/checks/check-board.github.mjs +25 -165
  10. package/assets/checks/check-glossary.mjs +10 -2
  11. package/assets/checks/check-lib-layers.mjs +24 -1
  12. package/assets/checks/check-prose-style.mjs +19 -3
  13. package/assets/checks/check-reuse.mjs +26 -2
  14. package/assets/checks/check-schema-drift.mjs +19 -3
  15. package/assets/checks/check-specs.mjs +8 -1
  16. package/assets/checks/epic-table.github.mjs +268 -0
  17. package/assets/checks/lib-boundaries.mjs +2 -2
  18. package/assets/checks/lib-common.mjs +46 -0
  19. package/assets/checks/lib-manifests.mjs +18 -13
  20. package/assets/checks/rt-kit-checks.config.mjs +19 -0
  21. package/assets/checks/signals.mjs +39 -5
  22. package/assets/checks/spec-anchors.mjs +48 -4
  23. package/assets/checks/spec-common.mjs +40 -6
  24. package/assets/checks/spec-contract.mjs +33 -7
  25. package/assets/checks/spec-scenarios.mjs +24 -1
  26. package/assets/checks/specs-for.mjs +214 -0
  27. package/assets/checks/task-new.github.mjs +237 -6
  28. package/assets/commands/night.md +115 -0
  29. package/assets/defaults/gate-map.sh +20 -5
  30. package/assets/defaults/project.sh +13 -0
  31. package/assets/defaults/turn-map.md +3 -1
  32. package/assets/docs/GLOSSARY.md +22 -22
  33. package/assets/hooks/browser-device-id.sh +4 -0
  34. package/assets/hooks/browser-guard-device-id.sh +4 -0
  35. package/assets/hooks/commit-msg.sh +3 -0
  36. package/assets/hooks/dev-server-guard.sh +64 -31
  37. package/assets/hooks/epic-over.sh +49 -0
  38. package/assets/hooks/epic-stop-guard.sh +108 -0
  39. package/assets/hooks/exam-guard.sh +10 -10
  40. package/assets/hooks/git-guard-delivery-conflict.sh +56 -1
  41. package/assets/hooks/git-guard-delivery-draft.sh +10 -6
  42. package/assets/hooks/git-guard-delivery-epic.sh +167 -0
  43. package/assets/hooks/git-guard-delivery-signature.sh +32 -2
  44. package/assets/hooks/git-guard-delivery-tree.sh +50 -0
  45. package/assets/hooks/git-guard-delivery.sh +71 -27
  46. package/assets/hooks/git-guard-discard.sh +144 -0
  47. package/assets/hooks/git-guard-push-tests.sh +36 -16
  48. package/assets/hooks/handoff-entry-guard.sh +20 -2
  49. package/assets/hooks/prose-style-guard.sh +31 -8
  50. package/assets/hooks/qa-dataid-guard.sh +33 -11
  51. package/assets/hooks/reuse-first-guard.sh +29 -4
  52. package/assets/hooks/rule-article.sh +3 -0
  53. package/assets/hooks/rule-source-guard.sh +17 -2
  54. package/assets/hooks/skill-gate-layers.sh +4 -0
  55. package/assets/hooks/skill-gate.sh +7 -0
  56. package/assets/hooks/skill-loaded.sh +4 -0
  57. package/assets/hooks/sql-guard-parse.sh +3 -0
  58. package/assets/hooks/sql-guard-request.sh +3 -0
  59. package/assets/hooks/sql-guard-target.sh +3 -0
  60. package/assets/hooks/sql-guard-write.sh +21 -2
  61. package/assets/hooks/stand-login-guard.sh +3 -0
  62. package/assets/hooks/turn-exit-guard.sh +55 -67
  63. package/assets/hooks/turn-exit-patterns.sh +28 -1
  64. package/assets/hooks/turn-exit-verdict.sh +84 -0
  65. package/assets/hooks/utf8.sh +3 -0
  66. package/assets/hooks/waiting-turn-guard.sh +11 -1
  67. package/assets/hooks/write-targets.sh +3 -0
  68. package/assets/laws/delivery.md +37 -7
  69. package/assets/laws/verifiability.md +22 -4
  70. package/assets/patterns/git-workflow-commit.azure.md +1 -1
  71. package/assets/patterns/git-workflow-commit.github.md +9 -2
  72. package/assets/patterns/git-workflow-commit.gitlab.md +1 -1
  73. package/assets/patterns/git-workflow-merge.md +8 -5
  74. package/assets/patterns/git-workflow-pr.azure.md +1 -1
  75. package/assets/patterns/git-workflow-pr.github.md +44 -18
  76. package/assets/patterns/git-workflow-pr.gitlab.md +1 -1
  77. package/assets/patterns/git-workflow-stack.md +32 -9
  78. package/assets/patterns/status-report-table.github.md +11 -0
  79. package/assets/patterns/task-flow-close.md +96 -90
  80. package/assets/patterns/task-flow-start.md +40 -26
  81. package/assets/patterns/ts-procedure.md +6 -0
  82. package/assets/pitfalls/agent-kit.md +19 -0
  83. package/assets/pitfalls/git-workflow.github.md +44 -0
  84. package/assets/pitfalls/task-flow.md +25 -23
  85. package/assets/rules/autonomous-work.md +15 -3
  86. package/assets/rules/browser-verification.md +8 -0
  87. package/assets/rules/deploy-flow.github.md +6 -0
  88. package/assets/rules/doc-style.md +13 -4
  89. package/assets/rules/git-workflow.azure.md +10 -0
  90. package/assets/rules/git-workflow.github.md +144 -126
  91. package/assets/rules/git-workflow.gitlab.md +10 -0
  92. package/assets/rules/lib-layers.md +11 -0
  93. package/assets/rules/spec-driven.md +17 -1
  94. package/assets/rules/status-report.md +7 -0
  95. package/assets/rules/task-flow.md +78 -54
  96. package/assets/rules/testing.md +7 -0
  97. package/assets/rules/turn-conduct.md +30 -3
  98. package/assets/samples/tasks/_template/plan.md +4 -1
  99. package/assets/skills/agent-kit.md +40 -25
  100. package/bin/agent-kit.d.ts.map +1 -1
  101. package/bin/agent-kit.js +9 -2
  102. package/bin/agent-kit.js.map +1 -1
  103. package/lib/cargo-prose.d.ts +41 -0
  104. package/lib/cargo-prose.d.ts.map +1 -0
  105. package/lib/cargo-prose.js +88 -0
  106. package/lib/cargo-prose.js.map +1 -0
  107. package/lib/cargo.d.ts +12 -1
  108. package/lib/cargo.d.ts.map +1 -1
  109. package/lib/cargo.js +8 -2
  110. package/lib/cargo.js.map +1 -1
  111. package/lib/commands.d.ts +1 -1
  112. package/lib/commands.d.ts.map +1 -1
  113. package/lib/commands.js +59 -2
  114. package/lib/commands.js.map +1 -1
  115. package/lib/fate.d.ts +29 -0
  116. package/lib/fate.d.ts.map +1 -0
  117. package/lib/fate.js +147 -0
  118. package/lib/fate.js.map +1 -0
  119. package/lib/hooks-map.d.ts +5 -0
  120. package/lib/hooks-map.d.ts.map +1 -1
  121. package/lib/hooks-map.js +9 -3
  122. package/lib/hooks-map.js.map +1 -1
  123. package/lib/override-marks.d.ts +7 -0
  124. package/lib/override-marks.d.ts.map +1 -1
  125. package/lib/override-marks.js +14 -0
  126. package/lib/override-marks.js.map +1 -1
  127. package/lib/plan.d.ts +2 -0
  128. package/lib/plan.d.ts.map +1 -1
  129. package/lib/plan.js +8 -0
  130. package/lib/plan.js.map +1 -1
  131. package/lib/proposals.d.ts +25 -0
  132. package/lib/proposals.d.ts.map +1 -1
  133. package/lib/proposals.js +43 -1
  134. package/lib/proposals.js.map +1 -1
  135. package/lib/ship.d.ts +29 -2
  136. package/lib/ship.d.ts.map +1 -1
  137. package/lib/ship.js +34 -0
  138. package/lib/ship.js.map +1 -1
  139. package/lib/shipment.d.ts.map +1 -1
  140. package/lib/shipment.fixture.d.ts +8 -1
  141. package/lib/shipment.fixture.d.ts.map +1 -1
  142. package/lib/shipment.fixture.js +9 -0
  143. package/lib/shipment.fixture.js.map +1 -1
  144. package/lib/shipment.js +40 -14
  145. package/lib/shipment.js.map +1 -1
  146. package/package.json +1 -1
  147. package/rt-tools-agent-kit-0.28.0.tgz +0 -0
  148. package/rt-tools-agent-kit-0.26.0.tgz +0 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The task folders of the tree: recognising a number in a name, walking the folders and removing
3
+ * the layout header from a copy of the template.
4
+ *
5
+ * A file of its own because the subject is the tree, not the work queue: these three go to disk
6
+ * and never to the network, and the queue module they lived in stood at the file length limit.
7
+ * The queue module re-exports them under their old names — three neighbouring modules and the
8
+ * tree's commands call them from there, and rewriting them would mean paying for the split twice.
9
+ */
10
+ import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
11
+ import { join } from 'node:path';
12
+
13
+ import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
14
+
15
+ const TASK_KEY = CONFIG.board?.taskKey ?? '';
16
+
17
+ /**
18
+ * The task number by the folder name. The key in front is optional: a branch name of the kind
19
+ * `chore/312-slug` is lawful too, and the folder under it is named by the bare number. If the
20
+ * audit does not recognise a number in the name, the folder will lie among the current ones for
21
+ * any length of time — one such was found by grep, not by a check.
22
+ */
23
+ export function numberFromTaskDir(name) {
24
+ // The key is substituted only if the tree has set it: an empty one would give `^(?:-)?`, and
25
+ // a folder with the key in its name would stop being recognised at all.
26
+ const prefix = TASK_KEY ? `(?:${TASK_KEY}-)?` : '';
27
+ const match = new RegExp(`^${prefix}(\\d+)-`).exec(name ?? '');
28
+ return match ? Number(match[1]) : null;
29
+ }
30
+
31
+ /**
32
+ * Task folders, including nested ones. The path repeats the branch name in full, slash included,
33
+ * so the folder of branch `chore/312-slug` lies on the second level — a walk over the top level
34
+ * alone does not see it.
35
+ *
36
+ * We descend exactly one level: a branch name has one slash, and anything deeper is no longer a
37
+ * task folder — but the archive would get in there, if the tree keeps it inside.
38
+ */
39
+ /** The layout header: by it the laid-out copy is recognised, and so is the edit-place guard. */
40
+ const STAMP = /^<!-- rt-kit v[^\n]*-->\n/m;
41
+
42
+ /**
43
+ * Remove the layout header from copies of the template.
44
+ *
45
+ * The template carries the header by right: the layout puts it there and updates it. A copy under
46
+ * a task is already the project's text, by the same argument by which the companion draft is laid
47
+ * out without a header: from the first edit there is nothing to audit in it. Left in the copy, the
48
+ * header refuses the very first edit of the grill and sends one to edit the package template
49
+ * instead. It was removed by three lines by hand, anew with every piece of work.
50
+ *
51
+ * Returns the names of the files the header was removed from: by them the scenario judges that
52
+ * the removal works, and the caller that the folder is assembled.
53
+ */
54
+ export function unstampFolder(folder) {
55
+ const cleaned = [];
56
+
57
+ if (!existsSync(folder)) {
58
+ return cleaned;
59
+ }
60
+
61
+ for (const name of readdirSync(folder)) {
62
+ if (!name.endsWith('.md')) {
63
+ continue;
64
+ }
65
+
66
+ const path = join(folder, name);
67
+ const before = readFileSync(path, 'utf8');
68
+ const after = before.replace(STAMP, '');
69
+
70
+ if (after !== before) {
71
+ writeFileSync(path, after);
72
+ cleaned.push(name);
73
+ }
74
+ }
75
+
76
+ return cleaned;
77
+ }
78
+
79
+ export function taskDirs(dir = join(ROOT, CONFIG.tasksDir), prefix = '') {
80
+ if (!existsSync(dir)) {
81
+ return [];
82
+ }
83
+ const found = [];
84
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
85
+ if (!entry.isDirectory() || entry.name === '_template') {
86
+ continue;
87
+ }
88
+ const name = prefix ? `${prefix}/${entry.name}` : entry.name;
89
+ if (entry.name.startsWith('_draft-') || numberFromTaskDir(entry.name) !== null) {
90
+ found.push(name);
91
+ continue;
92
+ }
93
+ if (!prefix) {
94
+ found.push(...taskDirs(join(dir, entry.name), name));
95
+ }
96
+ }
97
+ return found;
98
+ }
@@ -12,18 +12,16 @@
12
12
  * <number>` prints the task state as one line of JSON; `move <number> <column>` moves its column,
13
13
  * also `npm run task:move`.
14
14
  *
15
- * No network or no token is not a discrepancy but an inability to check: the functions return
16
- * `null`, the command mode prints `{"offline":true}`.
15
+ * No network or no token is an inability to check, not a discrepancy: the functions return `null`,
16
+ * the command mode prints `{"offline":true}`.
17
17
  */
18
- import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
19
- import { join } from 'node:path';
20
-
21
18
  import { OfflineError, botToken, gh, ghJson, graphql } from './board-gh.mjs';
22
- import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
19
+ import { declaredEpicOf } from './board-epic-link.mjs';
20
+ export { numberFromTaskDir, taskDirs, unstampFolder } from './board-task-dirs.mjs';
21
+ import { CONFIG } from './rt-kit-checks.config.mjs';
23
22
 
24
23
  // The client leaves here under its old name: three neighbouring modules and the tree's commands
25
- // call it from the board module, and rewriting them for the moved declaration would mean paying
26
- // for the file split twice.
24
+ // call it from the board module, and rewriting them would mean paying for the split twice.
27
25
  export { OfflineError, botToken, gh, ghJson, graphql };
28
26
 
29
27
  /**
@@ -147,7 +145,7 @@ export function fetchIssues(state, options) {
147
145
 
148
146
  export function fetchIssue(number, options) {
149
147
  try {
150
- return ghJson(['issue', 'view', String(number), '--json', 'number,title,state,assignees,labels'], options);
148
+ return ghJson(['issue', 'view', String(number), '--json', 'number,title,state,assignees,labels,body'], options);
151
149
  } catch (error) {
152
150
  if (error instanceof OfflineError) {
153
151
  throw error;
@@ -267,88 +265,6 @@ export function numberFromTitle(title) {
267
265
  return match ? Number(match[1]) : null;
268
266
  }
269
267
 
270
- /**
271
- * The task number by the folder name. The key in front is optional: a branch name of the kind
272
- * `chore/312-slug` is lawful too, and the folder under it is named by the bare number. If the
273
- * audit does not recognise a number in the name, the folder will lie among the current ones for
274
- * any length of time — one such was found by grep, not by a check.
275
- */
276
- export function numberFromTaskDir(name) {
277
- // The key is substituted only if the tree has set it: an empty one would give `^(?:-)?`, and
278
- // a folder with the key in its name would stop being recognised at all.
279
- const prefix = TASK_KEY ? `(?:${TASK_KEY}-)?` : '';
280
- const match = new RegExp(`^${prefix}(\\d+)-`).exec(name ?? '');
281
- return match ? Number(match[1]) : null;
282
- }
283
-
284
- /**
285
- * Task folders, including nested ones. The path repeats the branch name in full, slash included,
286
- * so the folder of branch `chore/312-slug` lies on the second level — a walk over the top level
287
- * alone does not see it.
288
- *
289
- * We descend exactly one level: a branch name has one slash, and anything deeper is no longer a
290
- * task folder — but the archive would get in there, if the tree keeps it inside.
291
- */
292
- /** The layout header: by it the laid-out copy is recognised, and so is the edit-place guard. */
293
- const STAMP = /^<!-- rt-kit v[^\n]*-->\n/m;
294
-
295
- /**
296
- * Remove the layout header from copies of the template.
297
- *
298
- * The template carries the header by right: the layout puts it there and updates it. A copy under
299
- * a task is already the project's text, by the same argument by which the companion draft is laid
300
- * out without a header: from the first edit there is nothing to audit in it. Left in the copy, the
301
- * header refuses the very first edit of the grill and sends one to edit the package template
302
- * instead. It was removed by three lines by hand, anew with every piece of work.
303
- *
304
- * Returns the names of the files the header was removed from: by them the scenario judges that
305
- * the removal works, and the caller that the folder is assembled.
306
- */
307
- export function unstampFolder(folder) {
308
- const cleaned = [];
309
-
310
- if (!existsSync(folder)) {
311
- return cleaned;
312
- }
313
-
314
- for (const name of readdirSync(folder)) {
315
- if (!name.endsWith('.md')) {
316
- continue;
317
- }
318
-
319
- const path = join(folder, name);
320
- const before = readFileSync(path, 'utf8');
321
- const after = before.replace(STAMP, '');
322
-
323
- if (after !== before) {
324
- writeFileSync(path, after);
325
- cleaned.push(name);
326
- }
327
- }
328
-
329
- return cleaned;
330
- }
331
-
332
- export function taskDirs(dir = join(ROOT, CONFIG.tasksDir), prefix = '') {
333
- if (!existsSync(dir)) {
334
- return [];
335
- }
336
- const found = [];
337
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
338
- if (!entry.isDirectory() || entry.name === '_template') {
339
- continue;
340
- }
341
- const name = prefix ? `${prefix}/${entry.name}` : entry.name;
342
- if (entry.name.startsWith('_draft-') || numberFromTaskDir(entry.name) !== null) {
343
- found.push(name);
344
- continue;
345
- }
346
- if (!prefix) {
347
- found.push(...taskDirs(join(dir, entry.name), name));
348
- }
349
- }
350
- return found;
351
- }
352
268
 
353
269
  export function numberFromBranch(branch) {
354
270
  const match = BRANCH_NUMBER.exec(branch ?? '');
@@ -377,6 +293,7 @@ export function taskState(number, options) {
377
293
  assignees: issue.assignees.map((assignee) => assignee.login),
378
294
  numbered: numberFromTitle(issue.title) === issue.number,
379
295
  labels: issue.labels.map((label) => label.name),
296
+ epic: declaredEpicOf(issue.body) ?? null,
380
297
  };
381
298
  }
382
299
 
@@ -48,11 +48,11 @@ import {
48
48
  numberFromTitle,
49
49
  taskDirs,
50
50
  } from './board.mjs';
51
- import { onlyIgnoredPaths } from './board-paths.mjs';
52
51
  import { checkBranchFolders } from './board-folders.mjs';
52
+ import { checkConflicting, checkHeadRun } from './board-pull-state.mjs';
53
53
  import { checkLongWork } from './board-long-work.mjs';
54
- import { HAS_PIPELINE, deployLag, evictedOnHead, headCommittedAt, lastDeploy, runsOnHead, verdictOnHead } from './board-runs.mjs';
55
- import { checkEpicLinks } from './board-epics.mjs';
54
+ import { HAS_PIPELINE, deployLag, lastDeploy } from './board-runs.mjs';
55
+ import { checkEpicLinks, checkEpicPullBase, checkEpicState, checkEpicSubIssues } from './board-epics.mjs';
56
56
  import { similarTitles } from './board-titles.mjs';
57
57
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
58
58
 
@@ -60,11 +60,6 @@ const IN_REVIEW = STATUS_OPTIONS[IN_REVIEW_STATUS].name;
60
60
  const TASKS_DIR = join(ROOT, CONFIG.tasksDir);
61
61
  /** Age of an abandoned draft after which it stops looking like one started today. */
62
62
  const DRAFT_DAYS = 7;
63
- /**
64
- * How long a head is given for a run to start behind it. The event does not reach the hosting
65
- * instantly, and an audit called right after a push would otherwise go red on a healthy branch.
66
- */
67
- const RUN_GRACE_MINUTES = 10;
68
63
  /**
69
64
  * The tree's pipeline. Runs are asked for only where they have somewhere to come from: a tree
70
65
  * without a pipeline would get a line for every open PR, and about nothing.
@@ -83,9 +78,21 @@ const RUN_GRACE_MINUTES = 10;
83
78
  *
84
79
  * The label name names the tree: each has its own, and an invented default would match nothing
85
80
  * and silently switch the filtering off. A tree that names no label is judged as before.
81
+ *
82
+ * The label alone is not enough to recognise cargo: a tree puts it on the tasks that grew out of
83
+ * cargo too — that is how the reader sees where the work came from. Read by the label alone, such
84
+ * a task fell out of the whole task half at once: neither the executor, nor the board, nor the
85
+ * link with an epic, nor a matching title was asked about it, and a request about it got the line
86
+ * "the task is not among the open ones". So a title with a number outweighs the label: that is
87
+ * what the tree itself tells a task by.
86
88
  */
87
89
  const CARGO_LABELS = new Set(CONFIG.board?.cargoLabels ?? []);
88
90
 
91
+ /** A record of the cargo: the label of one, and no title of a task. */
92
+ function isCargo(issue) {
93
+ return numberFromTitle(issue.title) === null && (issue.labels ?? []).some((label) => CARGO_LABELS.has(label.name));
94
+ }
95
+
89
96
  const DEPLOY_WORKFLOW = CONFIG.deploy?.workflow ?? '';
90
97
  const MAIN_BRANCH = CONFIG.deploy?.mainBranch ?? 'main';
91
98
 
@@ -150,157 +157,6 @@ function folderInBranch(branch, options) {
150
157
  }
151
158
  }
152
159
 
153
- /**
154
- * The run on the head of an open PR.
155
- *
156
- * A silent page and a green run read the same, and the event does not always reach the hosting:
157
- * in the hour of its failures the push went through and no run started behind it. The audit names
158
- * such a head while the PR is still open — after the merge it is too late to learn about it.
159
- *
160
- * What counts is the fact of a run, not its colour. A running and a failed run are both visible
161
- * on the PR page; only absence is invisible, and the audit speaks of exactly that.
162
- *
163
- * A fresh head is not judged: time passes between the push and the run, and a red line in that
164
- * gap would mean "wait", not "fix".
165
- *
166
- * A conflicting PR gets no run at all, and the cause is not a lost event: the pipeline checks the
167
- * merge of the branch with its base, and under a conflict there is no merge. The advice to bring
168
- * the event back is followed literally and does not help — in one session a PR was closed and
169
- * reopened twice in a row, and the run started only after the main branch was merged in. So the
170
- * line names the cause that can be fixed.
171
- */
172
- function checkHeadRun(pull, options) {
173
- if (checkEvicted(pull, options)) {
174
- return;
175
- }
176
-
177
- if (runsOnHead(pull.headRefOid, options) > 0) {
178
- checkReadyDraft(pull, options);
179
- return;
180
- }
181
-
182
- const minutes = Math.floor((Date.now() - headCommittedAt(pull.headRefOid, options)) / 60000);
183
- if (minutes < RUN_GRACE_MINUTES) {
184
- return;
185
- }
186
-
187
- if (onlyIgnoredPaths(pull, options)) {
188
- return;
189
- }
190
-
191
- if (pull.mergeable === 'CONFLICTING') {
192
- report(
193
- `PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)} and there will be none while it conflicts — ` +
194
- `the pipeline checks the merge of the branch with the base, and there is no merge while it conflicts; merge the main branch in and push, ` +
195
- `reopening the PR does not help here`
196
- );
197
-
198
- return;
199
- }
200
-
201
- // A PR on top of a neighbouring one gets no run: the workflow listens for PRs into the main
202
- // branch and does not see events with another base. The line about a lost event is wrong
203
- // here twice: the event was not lost, and closing and reopening will not bring it back — the
204
- // advice is followed literally, no run starts, and on the second try the breakage is looked
205
- // for in the hosting.
206
- if (pull.baseRefName && pull.baseRefName !== MAIN_BRANCH) {
207
- report(
208
- `PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)} and there will be none — ` +
209
- `the request is opened into the branch «${pull.baseRefName}», and the workflow listens to requests into the main one; ` +
210
- `move the base to «${MAIN_BRANCH}» once the lower request is merged`
211
- );
212
-
213
- return;
214
- }
215
-
216
- report(
217
- `PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)}, and it has lain there ${minutes} min — ` +
218
- `the pipeline received no event; bring it back by a new commit or by reopening the PR ` +
219
- `(gh pr close ${pull.number} && gh pr reopen ${pull.number})`
220
- );
221
- }
222
-
223
- /**
224
- * A head run evicted from the pipeline queue.
225
- *
226
- * The queue group protects a running run and does not protect a waiting one: the hosting keeps
227
- * one waiting run per group, and the next one to start evicts the previous. The branch behind
228
- * such a run was not checked by a single line, yet by the work queue it looks checked — there is
229
- * a run on the head, and the audit counts exactly the fact.
230
- *
231
- * Judged before the absence of a run and before the colour: otherwise one head gets two lines
232
- * about one thing. Returns `true` when the line has been said, and the other head checks are
233
- * skipped.
234
- *
235
- * The line names both commands, in the order they are called. The guard refuses a rerun until the
236
- * output of that step has been read within the same turn, and the order in the line meets the
237
- * requirement by itself: the executor calls what is written and does not hit a refusal on the
238
- * second step.
239
- */
240
- function checkEvicted(pull, options) {
241
- const evicted = evictedOnHead(pull.headRefOid, options);
242
- if (evicted.length === 0) {
243
- return false;
244
- }
245
-
246
- const run = evicted[0];
247
- report(
248
- `PR #${pull.number}: the run ${run} on the tip ${pull.headRefOid.slice(0, 8)} was pushed out of the pipeline queue — ` +
249
- `it has zero steps, the branch was not checked, and in the list it looks failed; ` +
250
- `read the run and restart it (gh run view ${run} && gh run rerun ${run})`
251
- );
252
- return true;
253
- }
254
-
255
- /**
256
- * Finished work left as a draft.
257
- *
258
- * On a draft the merge button is blocked by the hosting itself, so a green PR page allows the
259
- * owner nothing: a list in which everything is grey reads as "the work is not done". The
260
- * draft-lifting guard does not reach here — it judges one turn and stays silent while the branch
261
- * carries its task folder; the audit looks at the state of the whole queue.
262
- *
263
- * Four PRs stood as drafts for two days — the analysis is the record
264
- * "2026-08-18-ready-work-left-in-drafts" in the intake.
265
- */
266
- function checkReadyDraft(pull, options) {
267
- if (pull.isDraft !== true) {
268
- return;
269
- }
270
- if (verdictOnHead(pull.headRefOid, options) !== 'success') {
271
- return;
272
- }
273
-
274
- report(
275
- `PR #${pull.number}: the run on the tip ${pull.headRefOid.slice(0, 8)} is green, and the PR is a draft — ` +
276
- `take the task folder apart and lift the draft (gh pr ready ${pull.number}) or tell the owner what you are waiting for`
277
- );
278
- }
279
-
280
- /**
281
- * A PR that conflicts with the main branch.
282
- *
283
- * A conflict arrives in a handed-over PR through someone else's merge, without a single action by
284
- * its author: the base checked at opening goes stale the minute the owner merges a neighbouring
285
- * piece of work. The draft-lifting guard does not reach here — it judges one turn, and a PR stands
286
- * in the queue for days.
287
- *
288
- * Only a direct "conflicting" is judged: `UNKNOWN` means the hosting is still computing
289
- * mergeability, and a line about it would go red on every fresh head. Two PRs went to review with
290
- * a conflict this way — the analysis is the record
291
- * "2026-08-20-drafts-cleared-without-re-reading-pr-state" in the intake.
292
- */
293
- function checkConflicting(pull) {
294
- if (pull.mergeable !== 'CONFLICTING') {
295
- return;
296
- }
297
-
298
- report(
299
- `PR #${pull.number}: it conflicts with the main branch — merge it into the task branch, resolve the conflict and push; ` +
300
- `the owner cannot merge this request, and on the page that shows only inside it`
301
- );
302
- }
303
-
304
160
  let checked = { issues: 0, pulls: 0, cargo: 0 };
305
161
 
306
162
  // Drafts are judged by the disk and so are checked always: no connection is needed for that.
@@ -313,10 +169,11 @@ try {
313
169
  const board = fetchBoard(options);
314
170
  const issues = fetchIssues('all', options);
315
171
  const allOpen = issues.filter((issue) => issue.state === 'OPEN');
316
- // Filtering happens once and before all task checks: a labelled record is not a task as a
317
- // whole, not by half — it is judged neither by title, nor by executor, nor by the board, nor
318
- // by the digest of matching titles, nor by the link to an epic.
319
- const open = CARGO_LABELS.size === 0 ? allOpen : allOpen.filter((issue) => !(issue.labels ?? []).some((label) => CARGO_LABELS.has(label.name)));
172
+ // Filtering happens once and before all task checks: a cargo record is not a task as a whole,
173
+ // not by half — it is judged neither by title, nor by executor, nor by the board, nor by the
174
+ // digest of matching titles, nor by the link to an epic. A card with a title of a task is not
175
+ // such a record, whatever labels it wears.
176
+ const open = CARGO_LABELS.size === 0 ? allOpen : allOpen.filter((issue) => !isCargo(issue));
320
177
  const pulls = fetchOpenPulls(options);
321
178
  checked = { issues: issues.length, pulls: pulls.length, cargo: allOpen.length - open.length };
322
179
 
@@ -340,6 +197,9 @@ try {
340
197
 
341
198
  similarTitles(open);
342
199
  checkEpicLinks(open, report);
200
+ checkEpicPullBase(open, pulls, report);
201
+ checkEpicState(open, pulls, report);
202
+ checkEpicSubIssues(open, report, options);
343
203
  checkLongWork(open, report);
344
204
 
345
205
  const openNumbers = new Set(open.map((issue) => issue.number));
@@ -368,10 +228,10 @@ try {
368
228
  // opened past the guard. Said after the merge, this line is no longer fixed by the same
369
229
  // PR: the work has moved on, and a second task is created for the clean-up.
370
230
  if (HAS_PIPELINE && pull.headRefOid) {
371
- checkHeadRun(pull, options);
231
+ checkHeadRun(pull, report, MAIN_BRANCH, options);
372
232
  }
373
233
 
374
- checkConflicting(pull);
234
+ checkConflicting(pull, report);
375
235
 
376
236
  // The PR falling behind the main branch: the guard judges the base once, at the minute of
377
237
  // opening, and a PR stands for days. Merged while behind, it carries into main a
@@ -45,6 +45,13 @@ const GLOSSARY = 'docs/GLOSSARY.md';
45
45
  const SECTIONS = ['## Not written here', '## Так не пишем'];
46
46
  /** A pair of the glossary: `- **left** — right`. On the left there may be several words by comma. */
47
47
  const PAIR = /^-\s+\*\*(.+?)\*\*\s+—/;
48
+ /**
49
+ * The same pair written as a table row: `| left | right |`. The form is the tree's to choose, and a
50
+ * section set as a table used to read as empty — the check then declared a skip and stood in the
51
+ * gate next to the passed ones without judging a single word. The header row and the delimiter row
52
+ * are sifted out by the same expression: neither holds a word in bold or in backticks.
53
+ */
54
+ const ROW = /^\|\s*(?:\*\*(.+?)\*\*|`(.+?)`)\s*\|/;
48
55
  /** A bracketed clarification at a word: one meaning of two is forbidden, and search cannot part them. */
49
56
  const HINT = /\([^)]*\)\s*$/;
50
57
 
@@ -73,11 +80,12 @@ function forbiddenWords(text) {
73
80
  if (line.startsWith('## ')) {
74
81
  break;
75
82
  }
76
- const found = PAIR.exec(line);
83
+ const found = PAIR.exec(line) ?? ROW.exec(line);
77
84
  if (!found) {
78
85
  continue;
79
86
  }
80
- for (const part of found[1].split(',')) {
87
+ const left = found[1] ?? found[2] ?? found[3];
88
+ for (const part of left.split(',')) {
81
89
  const word = part.trim();
82
90
  if (!word) {
83
91
  continue;
@@ -23,7 +23,7 @@ import { existsSync } from 'node:fs';
23
23
  import { join } from 'node:path';
24
24
 
25
25
  import { checkBoundaries, checkCoreLibs, checkNoDependencyLibs } from './lib-boundaries.mjs';
26
- import { LIB_ROOTS, isDir, problems, report } from './lib-common.mjs';
26
+ import { FAMILIES, LIBS_ROOT, LIB_ROOTS, isDir, problems, report } from './lib-common.mjs';
27
27
  import { collectAllDomainLibs, collectApiDomainLibs, collectFlatLibs, collectStrayLibs } from './lib-domains.mjs';
28
28
  import { checkAliases, checkLib } from './lib-manifests.mjs';
29
29
  import { checkReexports } from './lib-reexports.mjs';
@@ -37,11 +37,34 @@ skipUnless(
37
37
  `the layout of the libs ${LIB_ROOTS.join(', ')} or the file tsconfig.base.json`
38
38
  );
39
39
 
40
+ // A family named in the settings whose directory the tree does not hold. The walk goes past it in
41
+ // silence, and the answer comes out the same as an honest one: the check reads the names of the
42
+ // families from the settings, and a tree that renamed one keeps the package default. The whole
43
+ // absence of the layout is another matter — it is the skip above.
44
+ const lost = FAMILIES.filter((family) => !isDir(`${LIBS_ROOT}/${family}`));
45
+ if (lost.length > 0) {
46
+ console.error(`check-lib-layers: the family «${lost.join('», «')}» is declared by the key «families», and the tree holds no ${lost.map((family) => `${LIBS_ROOT}/${family}`).join(', ')}\n`);
47
+ console.error(' A family walked past in silence answers exactly like an honest zero. Either the directory is named otherwise — then the key is fixed — or the family is gone, and its name leaves the key.');
48
+ process.exit(1);
49
+ }
50
+
40
51
  const domainLibs = collectAllDomainLibs();
41
52
  const apiLibs = collectApiDomainLibs();
42
53
  const flatLibs = collectFlatLibs();
43
54
  const strays = collectStrayLibs([...domainLibs, ...apiLibs]);
44
55
 
56
+ // A walk that met not a single lib is a refusal, not a green answer. The skip above says the tree
57
+ // has no lib layout at all; here the roots are in place, and the walk came back empty — the domains
58
+ // lie a level deeper, the settings named an empty list of families, or a lib carries no
59
+ // `project.json` and is therefore not a lib to this check. The line «0 libs, no divergences» is
60
+ // indistinguishable from an honest zero, and the check stands in the push gate: its silence reads
61
+ // as its green answer.
62
+ if (domainLibs.length + apiLibs.length + flatLibs.length === 0) {
63
+ console.error(`check-lib-layers: not a single lib was met over the roots ${LIB_ROOTS.join(', ')}\n`);
64
+ console.error(' The check would answer «no divergences» without having read a lib. The roots are named by the keys «libsRoot», «families» and «apiFamily» of the checks config; a lib is recognised by its `project.json`.');
65
+ process.exit(1);
66
+ }
67
+
45
68
  strays.forEach((path) => report(path, `the lib is outside the domain grid and is not listed in ${allowlistOf('lib-layers')}`));
46
69
  domainLibs.forEach((libPath) => checkLib(libPath));
47
70
  apiLibs.forEach((libPath) => checkLib(libPath, { requirePrefix: false }));
@@ -16,7 +16,8 @@
16
16
  * by that. This is its boundary, not its promise.
17
17
  *
18
18
  * A non-zero return code and a list of findings: the file, the line, what was found, what to
19
- * replace it with.
19
+ * replace it with. Called with `--json`, it reads the text from the input and prints the findings
20
+ * as data with a zero code: a machine decides for itself what to do about them.
20
21
  *
21
22
  * Word boundaries are written with a look at letters, not `\b`: it counts by ASCII, Cyrillic does
22
23
  * not fall under `\w`, and a pattern with it silently never fires once.
@@ -28,6 +29,9 @@ import { CONFIG } from './rt-kit-checks.config.mjs';
28
29
  /** The sentence length limit in words. Beyond it the reader loses the beginning. */
29
30
  const WORDS_LIMIT = 40;
30
31
 
32
+ /** The argument by which the check is asked for findings as data: the text comes in on the input. */
33
+ const JSON_FLAG = '--json';
34
+
31
35
  /**
32
36
  * The signs of officialese. Each is a pattern and what to replace it with: without a replacement
33
37
  * a finding reads as a ban on writing.
@@ -214,8 +218,20 @@ export function checkProse(text) {
214
218
  );
215
219
  }
216
220
 
217
- const files = process.argv.slice(2);
218
- if (files.length > 0) {
221
+ // Запуск строкой отличается от вызова из другого модуля именем в строке запуска: без этого
222
+ // условия модуль, который просто позвали, читал бы доводы чужой команды как имена файлов — и
223
+ // падал бы на первом же из них. Тот же приём стоит у команд груза.
224
+ const called = process.argv[1]?.endsWith('check-prose-style.mjs') === true;
225
+ const asked = called ? process.argv.slice(2) : [];
226
+ const files = asked.filter((one) => one !== JSON_FLAG);
227
+
228
+ // Ответ машине: текст приходит на вход, находки уходят разбором. Так проверку зовёт тот, кто
229
+ // держит текст в памяти, а не на диске: уезжающий груз лежит блоками внутри файла дня, и
230
+ // именами файлов его не назвать. Код возврата тут нулевой всегда — находка машине не отказ, а
231
+ // данные: отказ по ней выносит зовущий.
232
+ if (asked.includes(JSON_FLAG)) {
233
+ process.stdout.write(JSON.stringify(checkProse(readFileSync(0, 'utf8'))));
234
+ } else if (files.length > 0) {
219
235
  const problems = files.flatMap((file) =>
220
236
  checkProse(readFileSync(file, 'utf8')).map((p) => ` ${file}:${p.line} — «${p.what}» → ${p.fix}`)
221
237
  );
@@ -11,7 +11,9 @@
11
11
  * The signs do not lie here: they are declared as bundles per package of rt-tools, and the tree
12
12
  * names in the setting of the checks the ones it takes. The same list is read by the guard — they
13
13
  * must not diverge, otherwise an edit passes the guard and falls on the gate. Its own signs the
14
- * tree appends by a file of its own.
14
+ * tree appends by a file of its own. A bundle is declared with the area of the tree it holds over:
15
+ * an application assembled from another set of ready-made code drops out of the walk by the
16
+ * declaration, not by the tree declining to declare the bundle at all.
15
17
  *
16
18
  * There are two differences from the guard. The first: the inventory of the kit is not read — the
17
19
  * guard asks the disk because it answers for one edit, while a sweeping check cares about what has
@@ -112,6 +114,21 @@ function withoutMarked(text) {
112
114
  return lines.filter((line, index) => !line.includes('native-ok') && !lines[index - 1]?.includes('native-ok')).join('\n');
113
115
  }
114
116
 
117
+ /**
118
+ * Whether the file lies in the area the sign was declared with.
119
+ *
120
+ * The boundary is judged by the directory, not by the beginning of the string: `apps/admin` must
121
+ * not take in `apps/administration`, otherwise a neighbouring application gets judged by a set of
122
+ * ready-made code it was never assembled from. A sign without an area holds over the whole tree.
123
+ */
124
+ function within(path, roots) {
125
+ if (!roots || roots.length === 0) {
126
+ return true;
127
+ }
128
+
129
+ return roots.some((area) => path === area || path.startsWith(area.endsWith('/') ? area : `${area}/`));
130
+ }
131
+
115
132
  const allowlist = parseAllowlist('reuse');
116
133
  const known = allowlist.keys;
117
134
  const debt = new Set(allowlist.debt.keys());
@@ -126,7 +143,14 @@ for (const root of SOURCE_ROOTS) {
126
143
  // itself takes the folders of the source of that ready-made out from under the sign,
127
144
  // not the bundle whole.
128
145
  const excluded = signal.exceptNamed && new RegExp(signal.exceptNamed).test(path);
129
- if (!path.endsWith(signal.ext) || skipped || excluded || (signal.onlyNamed && !new RegExp(signal.onlyNamed).test(path))) {
146
+ const outside = !within(path, signal.roots);
147
+ if (
148
+ !path.endsWith(signal.ext) ||
149
+ skipped ||
150
+ excluded ||
151
+ outside ||
152
+ (signal.onlyNamed && !new RegExp(signal.onlyNamed).test(path))
153
+ ) {
130
154
  continue;
131
155
  }
132
156
  const times = found(signal, text);