@rt-tools/agent-kit 0.27.0 → 0.29.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 (112) hide show
  1. package/assets/checks/board-epic-link.github.mjs +13 -1
  2. package/assets/checks/board-epic-plan.github.mjs +86 -0
  3. package/assets/checks/board-epics.github.mjs +12 -67
  4. package/assets/checks/board-pull-state.github.mjs +6 -11
  5. package/assets/checks/board-runs.github.mjs +102 -2
  6. package/assets/checks/check-board.github.mjs +63 -3
  7. package/assets/checks/check-glossary.mjs +10 -2
  8. package/assets/checks/check-lib-layers.mjs +24 -1
  9. package/assets/checks/check-reuse.mjs +26 -2
  10. package/assets/checks/check-specs.mjs +8 -1
  11. package/assets/checks/lib-boundaries.mjs +2 -2
  12. package/assets/checks/lib-common.mjs +46 -0
  13. package/assets/checks/lib-manifests.mjs +18 -13
  14. package/assets/checks/main-run.github.mjs +69 -0
  15. package/assets/checks/rt-kit-checks.config.mjs +21 -0
  16. package/assets/checks/signals.mjs +39 -5
  17. package/assets/checks/spec-anchors.mjs +48 -4
  18. package/assets/checks/spec-common.mjs +40 -6
  19. package/assets/checks/spec-contract.mjs +33 -7
  20. package/assets/checks/spec-scenarios.mjs +24 -1
  21. package/assets/checks/task-new.github.mjs +9 -3
  22. package/assets/checks/tree-assignment.mjs +169 -0
  23. package/assets/defaults/gate-map.sh +20 -5
  24. package/assets/defaults/project.sh +6 -0
  25. package/assets/hooks/dev-server-guard.sh +61 -32
  26. package/assets/hooks/end-conversation-guard.sh +59 -0
  27. package/assets/hooks/epic-over.sh +11 -2
  28. package/assets/hooks/exam-guard.sh +10 -10
  29. package/assets/hooks/git-guard-delivery-conflict.sh +53 -1
  30. package/assets/hooks/git-guard-delivery-draft.sh +7 -6
  31. package/assets/hooks/git-guard-delivery-epic.sh +7 -0
  32. package/assets/hooks/git-guard-delivery-tree.sh +50 -0
  33. package/assets/hooks/git-guard-delivery.sh +45 -24
  34. package/assets/hooks/git-guard-discard.sh +144 -0
  35. package/assets/hooks/git-guard-push-tests.sh +36 -16
  36. package/assets/hooks/git-guard-tree-assignment.sh +77 -0
  37. package/assets/hooks/hook-input.sh +8 -1
  38. package/assets/hooks/main-run-context.sh +45 -0
  39. package/assets/hooks/reuse-first-guard.sh +29 -4
  40. package/assets/hooks/rule-source-guard.sh +17 -2
  41. package/assets/hooks/skill-gate.sh +7 -0
  42. package/assets/hooks/sql-guard-write.sh +18 -2
  43. package/assets/hooks/tree-assignment-guard.sh +101 -0
  44. package/assets/hooks/turn-exit-epic.sh +110 -0
  45. package/assets/hooks/turn-exit-guard.sh +80 -82
  46. package/assets/hooks/turn-exit-patterns.sh +18 -10
  47. package/assets/hooks/turn-exit-verdict.sh +96 -0
  48. package/assets/laws/delivery.md +20 -6
  49. package/assets/laws/verifiability.md +22 -4
  50. package/assets/laws/work-conduct.md +4 -0
  51. package/assets/patterns/git-workflow-merge.md +13 -0
  52. package/assets/patterns/git-workflow-pr-body.github.md +156 -0
  53. package/assets/patterns/git-workflow-pr.github.md +42 -119
  54. package/assets/patterns/git-workflow-stack.md +38 -2
  55. package/assets/patterns/task-flow-close.md +66 -79
  56. package/assets/patterns/task-flow-resume.md +8 -0
  57. package/assets/patterns/ts-procedure.md +6 -0
  58. package/assets/pitfalls/git-workflow.github.md +44 -0
  59. package/assets/pitfalls/task-flow.md +25 -23
  60. package/assets/pitfalls/turn-conduct.md +18 -0
  61. package/assets/rules/browser-verification.md +8 -0
  62. package/assets/rules/deploy-flow.github.md +6 -0
  63. package/assets/rules/doc-style.md +9 -2
  64. package/assets/rules/git-workflow.azure.md +10 -0
  65. package/assets/rules/git-workflow.github.md +128 -130
  66. package/assets/rules/git-workflow.gitlab.md +10 -0
  67. package/assets/rules/lib-layers.md +11 -0
  68. package/assets/rules/spec-driven.md +10 -1
  69. package/assets/rules/task-flow.md +82 -79
  70. package/assets/rules/testing.md +7 -0
  71. package/assets/rules/turn-conduct.md +47 -28
  72. package/assets/samples/tasks/_template/plan.md +4 -1
  73. package/assets/samples/tasks/_template/progress.md +1 -1
  74. package/assets/skills/agent-kit.md +17 -4
  75. package/bin/agent-kit.d.ts.map +1 -1
  76. package/bin/agent-kit.js +3 -2
  77. package/bin/agent-kit.js.map +1 -1
  78. package/lib/cargo.d.ts +49 -1
  79. package/lib/cargo.d.ts.map +1 -1
  80. package/lib/cargo.js +9 -2
  81. package/lib/cargo.js.map +1 -1
  82. package/lib/commands.d.ts +1 -1
  83. package/lib/commands.d.ts.map +1 -1
  84. package/lib/commands.js +59 -2
  85. package/lib/commands.js.map +1 -1
  86. package/lib/hooks-map.d.ts +5 -0
  87. package/lib/hooks-map.d.ts.map +1 -1
  88. package/lib/hooks-map.js +9 -3
  89. package/lib/hooks-map.js.map +1 -1
  90. package/lib/observations-cargo.d.ts +20 -0
  91. package/lib/observations-cargo.d.ts.map +1 -0
  92. package/lib/observations-cargo.js +88 -0
  93. package/lib/observations-cargo.js.map +1 -0
  94. package/lib/plan.d.ts +2 -0
  95. package/lib/plan.d.ts.map +1 -1
  96. package/lib/plan.js +8 -0
  97. package/lib/plan.js.map +1 -1
  98. package/lib/proposals.d.ts +25 -0
  99. package/lib/proposals.d.ts.map +1 -1
  100. package/lib/proposals.js +43 -1
  101. package/lib/proposals.js.map +1 -1
  102. package/lib/shipment.d.ts +8 -20
  103. package/lib/shipment.d.ts.map +1 -1
  104. package/lib/shipment.js +30 -50
  105. package/lib/shipment.js.map +1 -1
  106. package/lib/tree-mark.d.ts +17 -0
  107. package/lib/tree-mark.d.ts.map +1 -0
  108. package/lib/tree-mark.js +41 -0
  109. package/lib/tree-mark.js.map +1 -0
  110. package/package.json +1 -1
  111. package/rt-tools-agent-kit-0.29.0.tgz +0 -0
  112. package/rt-tools-agent-kit-0.27.0.tgz +0 -0
@@ -24,6 +24,18 @@ const TASK_KEY = CONFIG.board?.taskKey ?? '';
24
24
  * kinship of cards.
25
25
  */
26
26
  export function declaredEpicOf(body, number = null) {
27
- const named = String(body ?? '').match(new RegExp(`задач[аи]\\s+эпика?\\s+(?:#|${TASK_KEY}-)(\\d+)`, 'i'))?.[1];
27
+ const named = String(body ?? '').match(DECLARATION)?.[1];
28
28
  return number === null ? named : named !== undefined && Number(named) === number;
29
29
  }
30
+
31
+ /**
32
+ * The declaration opens its line: the creating command writes it as a line of its own, and a
33
+ * hand-written one carries at most an ordinal before it — «Первая задачи эпика #7». A list marker
34
+ * is allowed for the same reason: in a plan the declaration lies among items.
35
+ *
36
+ * Read anywhere in the line, it caught the same words inside a sentence: a task whose description
37
+ * said «семь задач эпика #1870» was read as belonging to that epic, and the delivery check refused
38
+ * its branch from the main one. The words alone cannot tell a declaration from prose about an
39
+ * epic — the place in the line can.
40
+ */
41
+ const DECLARATION = new RegExp(`^\\s*(?:[-*]\\s+)?(?:\\S+\\s+)?задач[аи]\\s+эпика?\\s+(?:#|${TASK_KEY}-)(\\d+)`, 'im');
@@ -0,0 +1,86 @@
1
+ /**
2
+ * The plan of an epic named by its own card: which of the paths in the body is the plan.
3
+ *
4
+ * A file of its own because two readers need it at once — the queue audit and the creating command
5
+ * — and they lie in different layers. Read in two places, the choice diverges silently: the audit
6
+ * takes the document that carries the makeup, while the command took the first path in the body,
7
+ * and a card that names a law before its plan then wrote the law into every task of the epic as its
8
+ * plan. Both sides answered as usual, and the miss showed only from a third side — by reading a
9
+ * created task.
10
+ */
11
+ import { existsSync, readFileSync } from 'node:fs';
12
+ import { join } from 'node:path';
13
+
14
+ import { ROOT } from './rt-kit-checks.config.mjs';
15
+
16
+ /** A path counts as a spelling with a directory: a bare file name occurs in the body in prose. */
17
+ const PATH_IN_BODY = /(?:^|[\s(`])([\w.-]+(?:\/[\w.-]+)+\.md)/g;
18
+
19
+ /**
20
+ * The rows of the epic makeup — those standing in the table with the task column.
21
+ *
22
+ * The epic plan holds other tables too: the sources of findings, the makeup of families, the count
23
+ * of items. Numbers taken from the whole text, and even from all the tables, would make an epic
24
+ * task out of everything it mentioned — the previous epic its findings grew from, a review, a task
25
+ * of a neighbouring tree.
26
+ */
27
+ export function planRows(plan) {
28
+ const rows = [];
29
+ let inside = false;
30
+ for (const line of plan.split('\n')) {
31
+ const isRow = line.trimStart().startsWith('|');
32
+ if (!isRow) {
33
+ inside = false;
34
+ continue;
35
+ }
36
+ if (!inside) {
37
+ // The column has two names, English and the owner's: a tree translates its plans one at
38
+ // a time, and one name would take the untranslated epics out of the check silently. A
39
+ // word boundary is no good here either: `\b` knows only Latin letters and never matches
40
+ // Cyrillic — the check would stay silent on any plan.
41
+ inside = /\|[^|]*(?:Task|Задача)/.test(line);
42
+ continue;
43
+ }
44
+ rows.push(line);
45
+ }
46
+
47
+ return rows.join('\n');
48
+ }
49
+
50
+ /**
51
+ * The plan of an epic named by its own card, and the reason there is none.
52
+ *
53
+ * The plan is the document that carries the makeup, not the first path in the body. A card names
54
+ * its decision next to its plan, and the decision has no table of tasks: read as the plan, it made
55
+ * the makeup empty and every open task of the epic read as not belonging to it — fourteen false
56
+ * lines at once, and the true ones drowned among them.
57
+ */
58
+ export function planPathOf(body, { makeupRequired = true } = {}) {
59
+ const named = [...String(body ?? '').matchAll(PATH_IN_BODY)].map((match) => match[1]);
60
+ if (named.length === 0) {
61
+ return { path: null, why: 'the epic card names no path to the plan — there is nowhere to read what the epic holds' };
62
+ }
63
+
64
+ const onDisk = named.filter((path) => existsSync(join(ROOT, path)));
65
+ if (onDisk.length === 0) {
66
+ return { path: null, why: `the epic plan «${named[0]}» is not on disk — the card points into emptiness` };
67
+ }
68
+
69
+ const carrying = onDisk.find((path) => planRows(readFileSync(join(ROOT, path), 'utf8')) !== '') ?? null;
70
+ if (carrying !== null) {
71
+ return { path: carrying, why: '' };
72
+ }
73
+
74
+ // The makeup is not demanded of the creating command: it creates the tasks of an epic, and the
75
+ // numbers land in the plan by the same edit — that is, after. Demanded here, the requirement
76
+ // would refuse the very first task of every epic, and there would be no way to create one at
77
+ // all. The audit runs later and demands it: by its minute the numbers stand in the plan.
78
+ if (!makeupRequired) {
79
+ return { path: onDisk[0], why: '' };
80
+ }
81
+
82
+ return {
83
+ path: null,
84
+ why: `none of the documents the card names carries the makeup of the epic — «${onDisk.join('», «')}». The makeup is a table with a task column`,
85
+ };
86
+ }
@@ -2,10 +2,11 @@
2
2
  * The link between a task and an epic. Lives in a file of its own: the work queue audit stands at
3
3
  * the length limit even without it, and these two checks are read separately.
4
4
  */
5
- import { existsSync, readFileSync } from 'node:fs';
5
+ import { readFileSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
7
 
8
8
  import { declaredEpicOf } from './board-epic-link.mjs';
9
+ import { planPathOf, planRows } from './board-epic-plan.mjs';
9
10
  import { ghJson, numberFromTitle, OfflineError, OWNER, REPO, TASK_KEY } from './board.mjs';
10
11
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
11
12
 
@@ -14,77 +15,15 @@ import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
14
15
  * tell an epic card from an ordinary task by.
15
16
  */
16
17
  // Чтение объявления переехало в свой модуль, а звали его отсюда: имя оставлено на прежнем месте,
17
- // чтобы соседям не пришлось знать о переезде.
18
- export { declaredEpicOf };
18
+ // чтобы соседям не пришлось знать о переезде. Тем же ходом переехал выбор документа замысла — его
19
+ // читает и команда заведения задачи.
20
+ export { declaredEpicOf, planPathOf, planRows };
19
21
 
20
22
  const EPIC_LABEL = CONFIG.board?.epicLabel ?? '';
21
23
 
22
24
  /** The labels of the cargo of the trees: those records are not tasks and are not judged as such. */
23
25
  const CARGO_LABELS = CONFIG.board?.cargoLabels ?? [];
24
26
 
25
- /**
26
- * The rows of the epic makeup — those standing in the table with the task column.
27
- *
28
- * The epic plan holds other tables too: the sources of findings, the makeup of families, the count
29
- * of items. Numbers taken from the whole text, and even from all the tables, would make an epic
30
- * task out of everything it mentioned — the previous epic its findings grew from, a review, a task
31
- * of a neighbouring tree.
32
- */
33
- export function planRows(plan) {
34
- const rows = [];
35
- let inside = false;
36
- for (const line of plan.split('\n')) {
37
- const isRow = line.trimStart().startsWith('|');
38
- if (!isRow) {
39
- inside = false;
40
- continue;
41
- }
42
- if (!inside) {
43
- // The column has two names, English and the owner's: a tree translates its plans one at
44
- // a time, and one name would take the untranslated epics out of the check silently. A
45
- // word boundary is no good here either: `\b` knows only Latin letters and never matches
46
- // Cyrillic — the check would stay silent on any plan.
47
- inside = /\|[^|]*(?:Task|Задача)/.test(line);
48
- continue;
49
- }
50
- rows.push(line);
51
- }
52
- return rows.join('\n');
53
- }
54
-
55
- /**
56
- * The plan of an epic named by its own card, and the reason there is none.
57
- *
58
- * The plan is the document that carries the makeup, not the first path in the body. A card names
59
- * its decision next to its plan, and the decision has no table of tasks: read as the plan, it made
60
- * the makeup empty and every open task of the epic read as not belonging to it — fourteen false
61
- * lines at once, and the true ones drowned among them.
62
- *
63
- * A path counts as a spelling with a directory: a bare file name occurs in the body in prose and
64
- * would lead the reader to the very first mention.
65
- */
66
- export function planPathOf(body) {
67
- const named = [...String(body ?? '').matchAll(/(?:^|[\s(`])([\w.-]+(?:\/[\w.-]+)+\.md)/g)].map((match) => match[1]);
68
- if (named.length === 0) {
69
- return { path: null, why: 'the epic card names no path to the plan — there is nowhere to read what the epic holds' };
70
- }
71
-
72
- const onDisk = named.filter((path) => existsSync(join(ROOT, path)));
73
- if (onDisk.length === 0) {
74
- return { path: null, why: `the epic plan «${named[0]}» is not on disk — the card points into emptiness` };
75
- }
76
-
77
- const carrying = onDisk.find((path) => planRows(readFileSync(join(ROOT, path), 'utf8')) !== '') ?? null;
78
- if (carrying === null) {
79
- return {
80
- path: null,
81
- why: `none of the documents the card names carries the makeup of the epic — «${onDisk.join('», «')}». The makeup is a table with a task column`,
82
- };
83
- }
84
-
85
- return { path: carrying, why: '' };
86
- }
87
-
88
27
  /**
89
28
  * The link between a task and an epic, read in both directions.
90
29
  *
@@ -241,7 +180,13 @@ export function checkEpicSubIssues(open, report, options) {
241
180
 
242
181
  let linked;
243
182
  try {
244
- linked = new Set(ghJson(['api', `repos/${OWNER}/${REPO}/issues/${epic.number}/sub_issues`, '--jq', '[.[].number]'], options));
183
+ // The list comes in pages, and an epic outgrows one page long before it is closed.
184
+ // Read by the first page alone, the audit calls a linked task unlinked: the line
185
+ // then stands in every run, the eye stops reading it, and a real divergence rides
186
+ // past together with it.
187
+ linked = new Set(
188
+ ghJson(['api', '--paginate', `repos/${OWNER}/${REPO}/issues/${epic.number}/sub_issues`, '--jq', '[.[].number]'], options)
189
+ );
245
190
  } catch (error) {
246
191
  if (error instanceof OfflineError) {
247
192
  throw error;
@@ -64,18 +64,13 @@ export function checkHeadRun(pull, report, mainBranch, options) {
64
64
  return;
65
65
  }
66
66
 
67
- // A PR on top of a neighbouring one gets no run: the workflow listens for PRs into the main
68
- // branch and does not see events with another base. The line about a lost event is wrong
69
- // here twice: the event was not lost, and closing and reopening will not bring it back — the
70
- // advice is followed literally, no run starts, and on the second try the breakage is looked
71
- // for in the hosting.
67
+ // A PR whose base is not the main branch gets no run at all: the workflow listens for PRs
68
+ // into the main branch and does not see events with another base. That is the order of
69
+ // handing in, not a discrepancy — every task of an epic is handed in exactly so — and the
70
+ // audit says nothing about it. The former line was wrong three times over: the event was not
71
+ // lost, reopening will not bring it back, and the base of a task request stays the epic
72
+ // branch to the merge.
72
73
  if (pull.baseRefName && pull.baseRefName !== mainBranch) {
73
- report(
74
- `PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)} and there will be none — ` +
75
- `the request is opened into the branch «${pull.baseRefName}», and the workflow listens to requests into the main one; ` +
76
- `move the base to «${mainBranch}» once the lower request is merged`
77
- );
78
-
79
74
  return;
80
75
  }
81
76
 
@@ -10,8 +10,8 @@
10
10
  * No network or no token — the calls throw `OfflineError`, like the rest of the work with the
11
11
  * hosting: an inability to ask does not count as a discrepancy.
12
12
  */
13
- import { existsSync } from 'node:fs';
14
- import { join } from 'node:path';
13
+ import { existsSync, readFileSync } from 'node:fs';
14
+ import { basename, join } from 'node:path';
15
15
 
16
16
  import { OWNER, REPO, gh } from './board.mjs';
17
17
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
@@ -169,6 +169,106 @@ export function evictedOnHead(sha, options) {
169
169
  .map((run) => run.id);
170
170
  }
171
171
 
172
+ /**
173
+ * Whether the pipeline wakes on a push to the main branch.
174
+ *
175
+ * A pipeline that listens to requests alone never runs on the main branch, and the absence of a
176
+ * run there says nothing: a tree like that gets no finding about the main run, and the audit says
177
+ * so out loud. The trigger is read from the pipeline file by its `on` block: a `push` key without
178
+ * a list of branches wakes on every branch, one with a list — on the branches named.
179
+ */
180
+ export function pipelineWakesOnPush(pipelineText, mainBranch) {
181
+ const lines = pipelineText.split('\n');
182
+ const indentOf = (line) => line.length - line.trimStart().length;
183
+ // The lines of a block: those below its key and indented deeper than it, blank ones included.
184
+ const blockAfter = (index) => {
185
+ const depth = indentOf(lines[index]);
186
+ const body = [];
187
+ for (let i = index + 1; i < lines.length; i += 1) {
188
+ if (lines[i].trim() !== '' && indentOf(lines[i]) <= depth) {
189
+ break;
190
+ }
191
+ body.push(lines[i]);
192
+ }
193
+ return body;
194
+ };
195
+
196
+ const onIndex = lines.findIndex((line) => /^on:\s*(#.*)?$/.test(line));
197
+ if (onIndex === -1) {
198
+ // The short form: `on: push` or `on: [push, pull_request]` — a push without a list of
199
+ // branches wakes on every branch.
200
+ return lines.some((line) => /^on:\s*(\[.*\bpush\b.*\]|push)\s*(#.*)?$/.test(line));
201
+ }
202
+
203
+ const on = blockAfter(onIndex);
204
+ const pushIndex = on.findIndex((line) => /^\s+push:\s*(#.*)?$/.test(line));
205
+ if (pushIndex === -1) {
206
+ return on.some((line) => /^\s+push:\s*\S/.test(line));
207
+ }
208
+
209
+ const pushLines = on.slice(pushIndex);
210
+ const pushDepth = indentOf(pushLines[0]);
211
+ const push = pushLines.slice(1).filter((line) => line.trim() === '' || indentOf(line) > pushDepth);
212
+ const branchesIndex = push.findIndex((line) => /^\s+branches:/.test(line));
213
+ if (branchesIndex === -1) {
214
+ return true;
215
+ }
216
+
217
+ const inline = /^\s+branches:\s*\[(.*)\]/.exec(push[branchesIndex]);
218
+ const names = inline
219
+ ? inline[1].split(',')
220
+ : push
221
+ .slice(branchesIndex + 1)
222
+ .filter((line) => /^\s+-\s/.test(line))
223
+ .map((line) => line.replace(/^\s+-\s*/, ''));
224
+ return names.map((name) => name.trim().replace(/^['"]|['"]$/g, '')).includes(mainBranch);
225
+ }
226
+
227
+ /**
228
+ * How the last run of the pipeline on the main branch ended: `success`, `failure`, `running`,
229
+ * `evicted` if it was pushed out of the queue and never started, or `none` if there was no run.
230
+ *
231
+ * The main branch is asked about apart from the rollout and apart from the tips of open requests.
232
+ * A merge is read as the end of the work, and the run it starts is read by nobody: a red run of the
233
+ * main branch stood for a day and a half, the rollout behind it did not go, and the owner said so.
234
+ * A cancelled run is told from a fallen one by its step count, the same way as on a request tip:
235
+ * zero steps means the queue pushed it out for the next merge, and the merge was checked by nothing.
236
+ */
237
+ export function lastMainRun(mainBranch, options) {
238
+ const runs = gh(
239
+ [
240
+ 'api',
241
+ `repos/${OWNER}/${REPO}/actions/workflows/${encodeURIComponent(basename(PIPELINE))}/runs` +
242
+ `?branch=${encodeURIComponent(mainBranch)}&per_page=1`,
243
+ '--jq',
244
+ '[.workflow_runs[] | {id, status, conclusion, sha: .head_sha, at: .created_at, url: .html_url}] | first // empty',
245
+ ],
246
+ options
247
+ );
248
+ const last = String(runs).trim();
249
+ if (!last) {
250
+ return { verdict: 'none' };
251
+ }
252
+
253
+ const run = JSON.parse(last);
254
+ if (run.status !== 'completed') {
255
+ return { verdict: 'running', ...run };
256
+ }
257
+ if (run.conclusion === 'success') {
258
+ return { verdict: 'success', ...run };
259
+ }
260
+ if (run.conclusion === 'cancelled' && jobCount(run.id, options) === 0) {
261
+ return { verdict: 'evicted', ...run };
262
+ }
263
+
264
+ return { verdict: 'failure', ...run };
265
+ }
266
+
267
+ /** The text of the pipeline file; an empty string where the tree has none. */
268
+ export function pipelineText() {
269
+ return HAS_PIPELINE ? readFileSync(join(ROOT, PIPELINE), 'utf8') : '';
270
+ }
271
+
172
272
  /** How many steps a run has started. Zero means it never started at all. */
173
273
  function jobCount(id, options) {
174
274
  const answer = gh(['api', `repos/${OWNER}/${REPO}/actions/runs/${id}/jobs?per_page=1`, '--jq', '.total_count'], options);
@@ -51,12 +51,17 @@ import {
51
51
  import { checkBranchFolders } from './board-folders.mjs';
52
52
  import { checkConflicting, checkHeadRun } from './board-pull-state.mjs';
53
53
  import { checkLongWork } from './board-long-work.mjs';
54
- import { HAS_PIPELINE, deployLag, lastDeploy } from './board-runs.mjs';
54
+ import { HAS_PIPELINE, deployLag, lastDeploy, lastMainRun, pipelineText, pipelineWakesOnPush } from './board-runs.mjs';
55
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
 
59
59
  const IN_REVIEW = STATUS_OPTIONS[IN_REVIEW_STATUS].name;
60
+ /**
61
+ * The columns a card reaches only after its task is closed: the merge closes the task, and the
62
+ * board's own rule moves the card. A tree that names neither gets no such audit.
63
+ */
64
+ const CLOSING_STATUSES = [STATUS_OPTIONS.done?.name, STATUS_OPTIONS.deployed?.name].filter((name) => typeof name === 'string' && name !== '');
60
65
  const TASKS_DIR = join(ROOT, CONFIG.tasksDir);
61
66
  /** Age of an abandoned draft after which it stops looking like one started today. */
62
67
  const DRAFT_DAYS = 7;
@@ -157,7 +162,7 @@ function folderInBranch(branch, options) {
157
162
  }
158
163
  }
159
164
 
160
- let checked = { issues: 0, pulls: 0, cargo: 0 };
165
+ let checked = { issues: 0, pulls: 0, cargo: 0, offBase: 0 };
161
166
 
162
167
  // Drafts are judged by the disk and so are checked always: no connection is needed for that.
163
168
  checkDrafts();
@@ -175,7 +180,7 @@ try {
175
180
  // such a record, whatever labels it wears.
176
181
  const open = CARGO_LABELS.size === 0 ? allOpen : allOpen.filter((issue) => !isCargo(issue));
177
182
  const pulls = fetchOpenPulls(options);
178
- checked = { issues: issues.length, pulls: pulls.length, cargo: allOpen.length - open.length };
183
+ checked = { issues: issues.length, pulls: pulls.length, cargo: allOpen.length - open.length, offBase: 0 };
179
184
 
180
185
  for (const item of board.foreign) {
181
186
  report(`the board: ${item} — the board holds tasks, not PRs about them`);
@@ -230,6 +235,9 @@ try {
230
235
  if (HAS_PIPELINE && pull.headRefOid) {
231
236
  checkHeadRun(pull, report, MAIN_BRANCH, options);
232
237
  }
238
+ if (pull.baseRefName && pull.baseRefName !== MAIN_BRANCH) {
239
+ checked.offBase += 1;
240
+ }
233
241
 
234
242
  checkConflicting(pull, report);
235
243
 
@@ -268,6 +276,16 @@ try {
268
276
  if (pull === undefined && status === IN_REVIEW) {
269
277
  report(`#${issue.number}: the task awaits review, and there is no open PR behind it — the column lags the work`);
270
278
  }
279
+ // A closing column is reached by a card whose task the merge has closed: the board moves
280
+ // it by its own rule on a closed item. An open task standing there says the opposite of
281
+ // what the owner reads from the column — and nobody notices: the mover to the last column
282
+ // skips such a card in silence, and the closing of a task merged into an epic branch is
283
+ // done by a pipeline that any tree may lack, may add later, or may see fail.
284
+ if (status !== null && CLOSING_STATUSES.includes(status)) {
285
+ report(
286
+ `#${issue.number}: the task is open, and its card stands at «${status}» — a closing column means the work is merged. Close the task, or move the card back by npm run task:move -- ${issue.number} <column>`
287
+ );
288
+ }
271
289
  }
272
290
 
273
291
  // The task folder dies with the task: what explains a settled decision moves to
@@ -328,11 +346,53 @@ if (!offline && DEPLOY_WORKFLOW) {
328
346
  }
329
347
  }
330
348
 
349
+ // The main branch is audited by the last run of the pipeline on it. A PR is checked before the
350
+ // merge, but the merge itself nobody watches: a red main run stood for a day and a half without a
351
+ // line about it, and a run pushed out of the queue by the next merge looked like a passed one.
352
+ if (!offline && HAS_PIPELINE) {
353
+ if (pipelineWakesOnPush(pipelineText(), MAIN_BRANCH)) {
354
+ try {
355
+ const run = lastMainRun(MAIN_BRANCH, { token: botToken() ?? undefined });
356
+ if (run.verdict === 'failure') {
357
+ report(
358
+ `the last run of «${MAIN_BRANCH}» is red on ${String(run.sha).slice(0, 8)} of ${String(run.at).slice(0, 10)}: ` +
359
+ `merges on top go out unchecked — ${run.url}`
360
+ );
361
+ } else if (run.verdict === 'evicted') {
362
+ report(
363
+ `the run of «${MAIN_BRANCH}» on ${String(run.sha).slice(0, 8)} was pushed out of the queue and never checked the merge — ${run.url}`
364
+ );
365
+ }
366
+ } catch (error) {
367
+ if (error instanceof OfflineError) {
368
+ console.log(`check-board: the main branch run was not checked — ${error.message}`);
369
+ } else {
370
+ throw error;
371
+ }
372
+ }
373
+ } else {
374
+ // Silence here would read as «main is green»: the tree whose pipeline sleeps on a push is told so.
375
+ console.log(`check-board: the main branch run was not checked — the pipeline does not wake on a push to «${MAIN_BRANCH}»`);
376
+ }
377
+ }
378
+
331
379
  // What was not checked is named out loud: silence about runs would read as "the runs are there".
332
380
  if (!offline && !DEPLOY_WORKFLOW) {
333
381
  console.log('check-board: production was not checked against the main branch — the rollout workflow is not named in the tree config');
334
382
  }
335
383
 
384
+ // A base other than the main branch has two consequences, and they are read from one line: the
385
+ // pipeline wakes for no such PR, and the host closes no task on its merge. Named apart, the
386
+ // second was read by nobody — the executor took the line about the run as the whole of it, and
387
+ // the tasks of a chain stayed open after their merges. Per PR the audit is silent: that is the
388
+ // order of handing in of every task of an epic, and a line on each would teach to skip the audit.
389
+ if (!offline && checked.offBase > 0) {
390
+ console.log(
391
+ `check-board: open PRs with a base other than «${MAIN_BRANCH}» — ${checked.offBase}: the pipeline gives them no run, ` +
392
+ `and the host closes no task on their merge — the tree closes those by a pipeline of its own or by the hand after the merge`
393
+ );
394
+ }
395
+
336
396
  // What was filtered out is named by number: silent filtering is indistinguishable from a broken
337
397
  // audit — a label named with a typo would switch the check off entirely and say nothing about it.
338
398
  if (!offline && checked.cargo > 0) {
@@ -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 }));
@@ -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);
@@ -52,7 +52,7 @@ import { checkRuleImplementation, checkSpecLaws, checkTracedAnchors } from './sp
52
52
  import { CONSTITUTION_DIR, REQUIRED_HEADINGS, SPECS_DIR, collectDomains, exists, problems, read, report, walk } from './spec-common.mjs';
53
53
  import { checkContract, checkRefusalCodes, procedureRootsOf } from './spec-contract.mjs';
54
54
  import { proposedGroups, staleProposed } from './spec-proposed.mjs';
55
- import { collectReferences, parseScenarios, promisesScreen } from './spec-scenarios.mjs';
55
+ import { collectReferences, parseScenarios, promisesScreen, unparsedHeadings } from './spec-scenarios.mjs';
56
56
 
57
57
  // ── run ───────────────────────────────────────────────────────────────────────
58
58
 
@@ -158,6 +158,13 @@ for (const domain of domains) {
158
158
 
159
159
  const found = walk(base, (name) => name === 'scenarios.md').flatMap(parseScenarios);
160
160
 
161
+ // A heading the template did not take starts no scenario and, left unnamed, takes it out of
162
+ // the count silently: the coverage marks under it are not read either, and a test referring to
163
+ // its number does not turn red — references are looked for among the parsed ones.
164
+ for (const heading of walk(base, (name) => name === 'scenarios.md').flatMap(unparsedHeadings)) {
165
+ report(`${heading.file}:${heading.line}`, `the scenario heading is not taken by the template and counts as ordinary prose: ${heading.text}`);
166
+ }
167
+
161
168
  // The prefix belongs to the domain together with its subdomains, not to a separate directory.
162
169
  // A domain is split when its spec has outgrown the length limit, and the scenarios move into
163
170
  // the subdomains unchanged: the number is the only thing binding a scenario to a test title,
@@ -9,7 +9,7 @@
9
9
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
10
10
  import { join } from 'node:path';
11
11
 
12
- import { BOUNDARIES_DIR, FAMILIES, isDir, projectTag, report } from './lib-common.mjs';
12
+ import { BOUNDARIES_DIR, FAMILIES, isDir, libTag, report } from './lib-common.mjs';
13
13
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
14
14
 
15
15
  /**
@@ -29,7 +29,7 @@ function checkBoundaries(libs) {
29
29
  const sources = files.map((name) => ({ name, text: readFileSync(join(ROOT, BOUNDARIES_DIR, name), 'utf8') }));
30
30
 
31
31
  for (const libPath of libs) {
32
- const tag = projectTag(libPath);
32
+ const tag = libTag(libPath);
33
33
  const declaration = `sourceTag: '${tag}'`;
34
34
  const owners = sources.flatMap(({ name, text }) => {
35
35
  const count = text.split(declaration).length - 1;