@rt-tools/agent-kit 0.30.0 → 0.30.1

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 (38) hide show
  1. package/assets/checks/board-runs.github.mjs +7 -2
  2. package/assets/checks/board.github.mjs +23 -3
  3. package/assets/checks/task-new-queue.github.mjs +51 -0
  4. package/assets/checks/task-new.github.mjs +4 -41
  5. package/assets/hooks/epic-stop-guard.sh +6 -1
  6. package/assets/hooks/grill-gate.sh +2 -2
  7. package/assets/hooks/write-targets.sh +69 -3
  8. package/assets/patterns/admin-nav-item.md +2 -1
  9. package/assets/patterns/browser-verification-stand.md +3 -0
  10. package/assets/patterns/doc-style-human.md +21 -0
  11. package/assets/patterns/git-workflow-docker.md +4 -2
  12. package/assets/patterns/git-workflow-merge.md +6 -0
  13. package/assets/patterns/spec-driven-domain.md +12 -0
  14. package/assets/patterns/testing-e2e.md +16 -2
  15. package/assets/patterns/testing-unit.md +4 -0
  16. package/assets/pitfalls/styling-bem.md +11 -0
  17. package/assets/rules/browser-verification.md +7 -5
  18. package/assets/rules/component-structure.md +4 -0
  19. package/assets/rules/deploy-flow.github.md +28 -2
  20. package/assets/rules/git-workflow.github.md +1 -1
  21. package/assets/rules/lib-layers.md +2 -2
  22. package/assets/rules/reuse-first.md +7 -0
  23. package/assets/rules/shared-code.md +3 -0
  24. package/assets/rules/spec-driven.md +3 -1
  25. package/assets/rules/testing.md +3 -1
  26. package/assets/rules/turn-conduct.md +10 -11
  27. package/lib/proposals.d.ts.map +1 -1
  28. package/lib/proposals.js +9 -1
  29. package/lib/proposals.js.map +1 -1
  30. package/lib/ship.d.ts +9 -0
  31. package/lib/ship.d.ts.map +1 -1
  32. package/lib/ship.js +16 -0
  33. package/lib/ship.js.map +1 -1
  34. package/lib/shipment.d.ts.map +1 -1
  35. package/lib/shipment.js +30 -29
  36. package/lib/shipment.js.map +1 -1
  37. package/package.json +1 -1
  38. package/rt-tools-agent-kit-0.30.0.tgz +0 -0
@@ -39,6 +39,11 @@ export function runsOnHead(sha, options) {
39
39
  * nothing about it: production was 476 commits behind while the check stayed silent. Only a rollout
40
40
  * finished with success is judged — one still going may end with anything.
41
41
  *
42
+ * The status filter of the hosting is not used: it counts by a separate index that lags, and the same
43
+ * request returned a month-old run and yesterday's one within a minute. The twenty latest runs come
44
+ * without it, and the first successful among them is taken; twenty failed in a row are named by the
45
+ * neighbouring check of the last rollout.
46
+ *
42
47
  * Returns `null` if there were no rollouts at all: that is not a discrepancy but nothing to compare.
43
48
  */
44
49
  export function deployLag(workflow, mainBranch, options) {
@@ -46,9 +51,9 @@ export function deployLag(workflow, mainBranch, options) {
46
51
  [
47
52
  'api',
48
53
  `repos/${OWNER}/${REPO}/actions/workflows/${encodeURIComponent(workflow)}/runs` +
49
- '?status=success&per_page=1',
54
+ '?per_page=20',
50
55
  '--jq',
51
- '[.workflow_runs[] | {sha: .head_sha, at: .created_at}] | first // empty',
56
+ '[.workflow_runs[] | select(.conclusion == "success") | {sha: .head_sha, at: .created_at}] | first // empty',
52
57
  ],
53
58
  options
54
59
  );
@@ -101,6 +101,23 @@ export function fetchBoard(options) {
101
101
  }
102
102
  }
103
103
 
104
+ /**
105
+ * The card of one task on this board, read by a direct request to the task itself — its
106
+ * `projectItems` field — and not out of the list of the whole board. The list took three seconds on
107
+ * two hundred cards, a direct request answered in under one, and it names the column in the same
108
+ * answer. `undefined` — the task stands on no card of this board (yet).
109
+ */
110
+ export function fetchCard(number, options) {
111
+ const issue = graphql(
112
+ `{ repository(owner: "${OWNER}", name: "${REPO}") { issue(number: ${Number(number)}) { projectItems(first: 20) {
113
+ nodes { id project { id }
114
+ status: fieldValueByName(name: "Status") { ... on ProjectV2ItemFieldSingleSelectValue { name optionId } } } } } } }`,
115
+ options
116
+ ).data?.repository?.issue;
117
+ const card = issue?.projectItems?.nodes?.find((node) => node.project?.id === PROJECT_ID);
118
+ return card ? { itemId: card.id, status: card.status?.name ?? null } : undefined;
119
+ }
120
+
104
121
  /**
105
122
  * Moving a task to another column. The task's state on the board is the only thing the progress
106
123
  * is visible by: the board does not read the branch or the open PR itself.
@@ -284,7 +301,7 @@ export function taskState(number, options) {
284
301
  if (!issue) {
285
302
  return { exists: false, viewer: viewerOf(options) };
286
303
  }
287
- const item = fetchBoard(options).items.get(issue.number);
304
+ const item = fetchCard(issue.number, options);
288
305
  return {
289
306
  exists: true,
290
307
  viewer: viewerOf(options),
@@ -310,7 +327,7 @@ export function taskState(number, options) {
310
327
  *
311
328
  * `state` — what `taskState` returned, or `{ offline: <reason> }` if asking failed.
312
329
  */
313
- export function describeTaskState(number, state) {
330
+ export function describeTaskState(number, state, waitedSeconds) {
314
331
  if (state?.offline) {
315
332
  return {
316
333
  ok: false,
@@ -326,7 +343,10 @@ export function describeTaskState(number, state) {
326
343
  if (!state.onBoard) {
327
344
  return {
328
345
  ok: false,
329
- lines: [`in the work queue: NO`, 'a task that is not in the queue is backed by no work — nobody will come for it'],
346
+ lines: [
347
+ `in the work queue: NO${waitedSeconds === undefined ? '' : ` — not seen in ${waitedSeconds} s of waiting`}`,
348
+ 'a task that is not in the queue is backed by no work — nobody will come for it',
349
+ ],
330
350
  };
331
351
  }
332
352
 
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The fifth step of creating a task: creation is confirmed by the answer of the work queue, not by
3
+ * the output of the command.
4
+ *
5
+ * All four steps before it answer for their own calls and stay silent about whether the task is
6
+ * visible to whoever comes for it. Sixteen creations in a row printed the number with a link that
7
+ * way, and not one of them landed in the queue: the account was limited by the hosting, and the
8
+ * calls gave no refusal at that.
9
+ */
10
+ import { OfflineError, describeTaskState, taskState } from './board.mjs';
11
+
12
+ /**
13
+ * The window of waiting: the pauses between readings, in milliseconds, growing, about thirty seconds
14
+ * in all. The queue hands a new card back after seconds, and the delay sometimes outlasts a window
15
+ * of twelve seconds: one creation in six printed «NO» for a card that stood on the board with its
16
+ * assignee. A false refusal here costs more than a delay — it pushes to create the card a second
17
+ * time, and only an administrator can take it off the board. The list of pauses can be set by
18
+ * `RT_TASK_NEW_PAUSES_MS` — a suite does not wait half a minute for it.
19
+ */
20
+ export const QUEUE_PAUSES_MS = (process.env.RT_TASK_NEW_PAUSES_MS || '1000,2000,4000,8000,15000')
21
+ .split(',')
22
+ .map((pause) => Number(pause))
23
+ .filter((pause) => Number.isFinite(pause) && pause >= 0);
24
+
25
+ const WAITED_SECONDS = Number((QUEUE_PAUSES_MS.reduce((sum, pause) => sum + pause, 0) / 1000).toFixed(1));
26
+
27
+ /**
28
+ * One reading of the queue. `unreachable` — there was nothing to ask with: there is nothing to
29
+ * repeat, the answer is not late, there will be none at all.
30
+ */
31
+ function askQueue(number, token, waitedSeconds) {
32
+ try {
33
+ return { answer: describeTaskState(number, taskState(number, { token }), waitedSeconds), unreachable: false };
34
+ } catch (error) {
35
+ const reason = error instanceof OfflineError ? error.message : String(error.message ?? error);
36
+ return { answer: describeTaskState(number, { offline: reason }), unreachable: true };
37
+ }
38
+ }
39
+
40
+ /**
41
+ * The queue's answer about the created task. «NO» is printed only after the whole window: until then
42
+ * it is the queue's delay, not an answer.
43
+ */
44
+ export function confirmInQueue(number, token) {
45
+ let reading = askQueue(number, token, 0);
46
+ for (let attempt = 0; !reading.answer.ok && !reading.unreachable && attempt < QUEUE_PAUSES_MS.length; attempt += 1) {
47
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, QUEUE_PAUSES_MS[attempt]);
48
+ reading = askQueue(number, token, WAITED_SECONDS);
49
+ }
50
+ return reading.answer;
51
+ }
@@ -50,14 +50,13 @@ import {
50
50
  STATUS_FIELD_ID,
51
51
  TASK_KEY,
52
52
  botToken,
53
- describeTaskState,
54
53
  gh,
55
54
  ghJson,
56
55
  graphql,
57
56
  numberFromTitle,
58
- taskState,
59
57
  unstampFolder,
60
58
  } from './board.mjs';
59
+ import { confirmInQueue } from './task-new-queue.mjs';
61
60
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
62
61
 
63
62
  /**
@@ -437,45 +436,9 @@ if (args.epic) {
437
436
  console.log(`[${TASK_KEY}-${number}] ${args.title}`);
438
437
  console.log(`https://github.com/${OWNER}/${REPO}/issues/${number}`);
439
438
 
440
- /**
441
- * The fifth step: creation is confirmed by the answer of the work queue, not by the output of this
442
- * command.
443
- *
444
- * All four steps above answer for their own calls and stay silent about whether the task is visible
445
- * to whoever comes for it. Sixteen creations in a row printed the number with a link that way, and
446
- * not one of them landed in the queue: the account was limited by the hosting, and the calls gave
447
- * no refusal at that.
448
- */
449
- /**
450
- * This is read more than once. The queue does not hand back a new card the same second it was
451
- * created, and the reading goes as the next call after the adding: two creations in a row printed
452
- * that the task is not in the queue while the card was in place. A false refusal here costs more
453
- * than a delay — it pushes to create the card a second time, and only an administrator can take it
454
- * off the board.
455
- */
456
- let unreachable = false;
457
-
458
- function askQueue() {
459
- try {
460
- return describeTaskState(number, taskState(number, { token }));
461
- } catch (error) {
462
- // There was nothing to ask with — there is nothing to repeat: the answer is not late,
463
- // there will be none at all.
464
- unreachable = true;
465
- const reason = error instanceof OfflineError ? error.message : String(error.message ?? error);
466
- return describeTaskState(number, { offline: reason });
467
- }
468
- }
469
-
470
- /** How long to wait between readings and how many times to re-read: the queue delay is seconds. */
471
- const QUEUE_RETRIES = 3;
472
- const QUEUE_PAUSE_MS = 1500;
473
-
474
- let answer = askQueue();
475
- for (let attempt = 1; !answer.ok && !unreachable && attempt < QUEUE_RETRIES; attempt += 1) {
476
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, QUEUE_PAUSE_MS);
477
- answer = askQueue();
478
- }
439
+ // The fifth step: creation is confirmed by the answer of the work queue, not by the output of this
440
+ // command. How long it waits and why is in the module of the step.
441
+ const answer = confirmInQueue(number, token);
479
442
  for (const line of answer.lines) {
480
443
  (answer.ok ? console.log : console.error)(`task-new: ${line}`);
481
444
  }
@@ -92,7 +92,12 @@ rt_epic_over || exit 0
92
92
  taken="$(printf '%s' "$cmd" | sed -nE 's/.*(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-([0-9]+)-.*/\4/p; s/.*(task:move|board\.mjs[[:space:]]+move)[^0-9|;&]*([0-9]+).*/\2/p; s/.*--epic-of[[:space:]=]+([0-9]+).*/\1/p' | head -1)"
93
93
  transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
94
94
  if [ -n "$taken" ] && [ -n "$transcript" ] && [ -f "$transcript" ]; then
95
+ # A menu answer comes in two forms, «The user answered:» and «Your questions have been answered:»,
96
+ # followed by "question"="answer" pairs. Only the answers count: the question is written by the
97
+ # executor, and a number in «take RT-N?» answered «no» is not the owner's word.
95
98
  named="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg n "$taken" '
99
+ def menu_answers: if test("^(The user answered|Your questions have been answered):")
100
+ then ([match("\"=\"([^\"]*)\""; "g") | .captures[0].string] | join("\n")) else "" end;
96
101
  [.[] | select(.type == "user")
97
102
  | select(((.isMeta // false) or (.isCompactSummary // false)) | not)
98
103
  | (.message.content // "")
@@ -102,7 +107,7 @@ if [ -n "$taken" ] && [ -n "$transcript" ] && [ -f "$transcript" ]; then
102
107
  elif .type == "tool_result" then ((.content
103
108
  | if type == "string" then . elif type == "array"
104
109
  then (map(if type == "object" then (.text // "") else "" end) | join(" ")) else "" end)
105
- | if test("^The user answered:") then . else "" end)
110
+ | menu_answers)
106
111
  else "" end) | join("\n"))
107
112
  else "" end]
108
113
  | map(test("(^|[^0-9])" + $n + "([^0-9]|$)")) | any
@@ -275,7 +275,7 @@ if [ -n "$tool" ]; then
275
275
  | select(type == "array") | .[] | select(.type == "tool_result") | .content
276
276
  | if type == "string" then . elif type == "array"
277
277
  then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end
278
- | select(test("^The user answered:"))];
278
+ | select(test("^(The user answered|Your questions have been answered):"))];
279
279
  def recommended: ([match("\"=\"[^\"]*\""; "g")] | length) as $all
280
280
  | ([match("\\((Recommended|Рекомендую|Рекомендован[^)]*)\\)\"(,|\\.|[[:space:]]|$)"; "g")] | length) as $marked
281
281
  | $all > 0 and $all == $marked;
@@ -436,7 +436,7 @@ fi
436
436
  # circle: the search was made, the same refusal came back, and the executor stopped asking at all.
437
437
  if [ -n "$need_re" ]; then
438
438
  named="$(printf '%s' "$need_re" | tr '|' '\n' | sed 's/.*/«&»/' | paste -sd ',' - | sed 's/,/, /g')"
439
- reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. The turn holds edits, and for them only the rules of their area count: $named. Load them by the tool Skill, or read them in $rules_dir, and answer from what is found; ask only what they do not cover.
439
+ reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. The turn holds edits, and for them only the rules of their area count: $named. A search over the specs or over other rules does not lift this refusal. The area counts every edit since the owner's last message, the stretch before a context compaction included. Load them by the tool Skill, or read them in $rules_dir, and answer from what is found; ask only what they do not cover.
440
440
 
441
441
  A rule loaded before the owner's last message does not count: the guard judges one turn, and the next session is not refused."
442
442
  else
@@ -104,7 +104,7 @@ rt_write_targets() {
104
104
  # data.
105
105
  function emit_calls(s, rest, arg, name) {
106
106
  rest = s
107
- while (match(rest, /(open|writeFileSync|writeFile|appendFileSync|appendFile|write_text|write_bytes|copyfile|copy2|rename|symlink|mkdir|makedirs)[ \t]*\(/)) {
107
+ while (match(rest, /(open|writeFileSync|writeFile|appendFileSync|appendFile|copyfile|copy2|rename|symlink|mkdir|makedirs)[ \t]*\(/)) {
108
108
  rest = substr(rest, RSTART + RLENGTH)
109
109
  arg = rest
110
110
  sub(/[,)].*$/, "", arg)
@@ -132,6 +132,72 @@ rt_write_targets() {
132
132
  || s ~ /(^|[|;&(]|[ \t])(tee|cp|mv|rm|touch|install|truncate)([ \t]|$)/
133
133
  }
134
134
  function trim(s) { sub(/^[ \t]+/, "", s); sub(/[ \t]+$/, "", s); return s }
135
+ # The index of the bracket that closes the call whose arguments start at `from`: the
136
+ # quotes are skipped, and a bracket inside a string closes nothing.
137
+ function args_end(s, from, i, c, depth, q) {
138
+ depth = 1
139
+ for (i = from; i <= length(s); i++) {
140
+ c = substr(s, i, 1)
141
+ if (q != "") {
142
+ if (c == q && substr(s, i - 1, 1) != "\\") { q = "" }
143
+ } else if (c == "\047" || c == "\"") {
144
+ q = c
145
+ } else if (c == "(") {
146
+ depth++
147
+ } else if (c == ")") {
148
+ depth--
149
+ if (depth == 0) { return i }
150
+ }
151
+ }
152
+ return length(s) + 1
153
+ }
154
+ # The first argument of a call: everything up to a comma outside quotes and brackets.
155
+ function first_arg(a, i, c, depth, q) {
156
+ for (i = 1; i <= length(a); i++) {
157
+ c = substr(a, i, 1)
158
+ if (q != "") {
159
+ if (c == q && substr(a, i - 1, 1) != "\\") { q = "" }
160
+ } else if (c == "\047" || c == "\"") {
161
+ q = c
162
+ } else if (c == "(") {
163
+ depth++
164
+ } else if (c == ")") {
165
+ depth--
166
+ } else if (c == "," && depth == 0) {
167
+ return substr(a, 1, i - 1)
168
+ }
169
+ }
170
+ return a
171
+ }
172
+ # What the script writes or substitutes is the content of the write, not its target: a
173
+ # path inside the written string belongs to the content of that file. A script that
174
+ # edited a work file and named a laid-out copy in the text of a new line was refused by
175
+ # the name of a copy it never opened. The call stays and its first argument stays where
176
+ # that argument is the address (`writeFileSync(path, data)`); the data and the argument
177
+ # of `.write(`, `.write_text(`, `.write_bytes(` and of a string `.replace(` are cut.
178
+ # `os.replace(source, target)` is a transfer, and its arguments stay.
179
+ function strip_content(s, out, pre, name, from, endp, args) {
180
+ out = ""
181
+ while (match(s, /(\.write|\.write_text|\.write_bytes|\.replace|writeFileSync|appendFileSync|writeFile|appendFile)[ \t]*\(/)) {
182
+ pre = substr(s, 1, RSTART - 1)
183
+ name = substr(s, RSTART, RLENGTH)
184
+ from = RSTART + RLENGTH
185
+ if (name ~ /^\.replace/ && pre ~ /(^|[^A-Za-z0-9_])os$/) {
186
+ out = out pre name
187
+ s = substr(s, from)
188
+ continue
189
+ }
190
+ endp = args_end(s, from)
191
+ if (name ~ /^\./) {
192
+ out = out pre name ")"
193
+ } else {
194
+ args = substr(s, from, endp - from)
195
+ out = out pre name first_arg(args) ")"
196
+ }
197
+ s = substr(s, endp + 1)
198
+ }
199
+ return out s
200
+ }
135
201
  # Paths are taken from the write lines, not from the whole body.
136
202
  #
137
203
  # Before, a body that writes anything at all gave away all its path-like words at once:
@@ -146,7 +212,7 @@ rt_write_targets() {
146
212
  if (wrote) {
147
213
  for (i = 1; i <= lines; i++) { note_var(line[i]) }
148
214
  for (i = 1; i <= lines; i++) {
149
- if (writes(line[i])) { emit(line[i]); emit_calls(line[i]) }
215
+ if (writes(line[i])) { emit(strip_content(line[i])); emit_calls(line[i]) }
150
216
  }
151
217
  }
152
218
  for (i = 1; i <= lines; i++) { delete line[i] }
@@ -167,7 +233,7 @@ rt_write_targets() {
167
233
  if ($0 ~ /(^|[|;&(]|[ \t])(python3?|node|ruby|perl|php|deno|bun)([ \t]|$)/ \
168
234
  && match($0, /[ \t]-[ce][ \t]/)) {
169
235
  rest = substr($0, RSTART + RLENGTH)
170
- if (writes(rest)) { note_var(rest); emit(rest); emit_calls(rest) }
236
+ if (writes(rest)) { note_var(rest); emit(strip_content(rest)); emit_calls(rest) }
171
237
  }
172
238
  # The heredoc body: the write path of the interpreter stands exactly there.
173
239
  if (match($0, /<<-?[ \t]*[\047\"]?[A-Za-z_][A-Za-z0-9_]*/)) {
@@ -73,4 +73,5 @@ declaration: a domain section is named by the id of its item.
73
73
  - An address move without editing the end-to-end tests: they walk by addresses, and the run goes
74
74
  red.
75
75
  - An icon picked as "similar": a missing one is added to the sprite and to
76
- `<prefix>-icon-names.ts`.
76
+ `<prefix>-icon-names.ts`. The name of a present icon is copied from the kit icon file as is: some
77
+ names carry the `ico-` prefix and most do not.
@@ -239,6 +239,9 @@ past session, and it answers 200 with old code.
239
239
  `nx run-many -t build` both the site and the admin go down. Build what you check
240
240
  (`npx nx build site`), not the whole tree. If the servers went down, the agent cannot bring them
241
241
  back up — the guard is in the way, so the owner is told at once, not at the end of the session.
242
+ The push gate is such a build too: its set runs the build of everything affected. So the
243
+ measurement is taken before the push or on a stand from the production build. The answer of the
244
+ server, not its port, tells whether it survived.
242
245
  - Take the rendering port with care: the developer's stand goes by the same name
243
246
  `ssr:<rendering port>` through `host-gateway`, and while a foreign process hangs on it, the
244
247
  stand serves a foreign build.
@@ -83,8 +83,29 @@ The owner's language is the one they write in chat and on cards. An owner writin
83
83
  gets an English task, and that is no miss: the miss is a text in a language the addressee did
84
84
  not choose.
85
85
 
86
+ ## A guide for an executor in another tree
87
+
88
+ Its reader has neither the author's memory nor the author's conversation, so the guide is checked
89
+ step by step before it is handed over: each step is done from the text alone. Addresses, access
90
+ and the state of name records are written in. A solution already found and verified goes in as a
91
+ recipe; "decide later" stands only where no way was verified. The ban on naming another tree covers
92
+ its name, not the infrastructure its reader needs.
93
+
94
+ ```text
95
+ ✗ Шаг 1. Подготовьте узел. Адрес и доступ решим позже.
96
+ ✓ Шаг 1. Узел — таблица «Где узел»: адрес, порт почты, вход по ключу. Запись DNS ставит владелец
97
+ домена, и в задаче она названа его действием.
98
+ ```
99
+
86
100
  ## Pitfalls
87
101
 
102
+ - **A promise about the behaviour of an outside service names what backs it.** A host or a bot is
103
+ promised to do something only with a quote of its documentation or a run that did it; where it
104
+ cannot be checked before the merge, the text says exactly that.
105
+ - **What a text says about another record is read from that record in the same turn.** A release
106
+ note names a task by the title read in the tracker at that minute, and a commit without a task
107
+ number does not go into it: a number taken from memory lands on someone else's task.
108
+
88
109
  - **An edit made by a shell command is judged by the whole command, the old version inside it
89
110
  included.** The style check gets the body of the call, not the text that will end up in the
90
111
  file: a rewrite carrying the previous wording inside a heredoc or an interpreter string is
@@ -89,11 +89,13 @@ for v in $(docker volume ls -q -f dangling=true); do
89
89
  [ -z "$(docker volume inspect "$v" --format '{{index .Labels "com.docker.compose.project"}}')" ] \
90
90
  && docker volume rm "$v"
91
91
  done
92
- docker builder prune --force --filter until=24h # yesterday's cache is nobody's, the fresh one the build needs
92
+ docker builder prune --builder <name> --force --filter until=24h # yesterday's cache is nobody's, the fresh one the build needs
93
93
  ```
94
94
 
95
95
  A threshold on the cache, not a full cleanup: removed whole, it makes the next build go from
96
- scratch.
96
+ scratch. The cache is pruned with the builder named: without `--builder` the command prunes the
97
+ current builder, and a pipeline running on the same machine changes which one that is, so the cache
98
+ the pipeline builds with goes with it.
97
99
 
98
100
  A pipeline run living on the owner's machine cleans up after itself, and does it in a step that
99
101
  runs on failure too: space runs out exactly when the run fails, and a cleanup skipped on failure
@@ -181,6 +181,12 @@ one's own hand: it is removed by whoever's work it is, in their own branch.
181
181
 
182
182
  - "Keep both sides" applied to all files alike: in a spec it is right, in code and in the work
183
183
  list it is not.
184
+ - **A merge carries edits of files, not edits of an application.** A function switched on by one
185
+ line in the root of one application stays off in the second application of the tree: nobody
186
+ touched that root, so there is no conflict, and an optional dependency is allowed to be absent, so
187
+ no check turns red. After the merge the diff of the merged-in roots and shared layers is read for
188
+ every application of the tree: each added line is either carried over or named in the report as
189
+ not needed there.
184
190
  - The merge command taken without the signature variables: the merge commit is signed by a
185
191
  person, and the push set refuses it — at the step where all checks are already green. This is
186
192
  fixed by rewriting the branch, not by editing one commit: conflict resolutions usually already
@@ -38,6 +38,12 @@ has a scenario prefix of its own, and the audit gives no spec a second prefix: t
38
38
  such work part into two numberings — one per spec they will merge into. The plan names both, and
39
39
  they merge apart, each into its own spec.
40
40
 
41
+ The place of an agreement is chosen by the length of the spec it will merge into, at the moment it
42
+ is written. The domain spec plus the agreement's rules is measured against the tree's size limit;
43
+ one that would cross it is written from the start as the agreement of a new subdomain, with its
44
+ own scenario prefix. Measured only at the merge, the overrun moves a finished agreement to a new
45
+ place and a new prefix, together with the test titles that carry its numbers.
46
+
41
47
  ## Mandatory sections
42
48
 
43
49
  `## Зачем` · `## Терминология` with the subsection `### Как это называется в интерфейсе` ·
@@ -155,6 +161,12 @@ command's name is given by the rule's companion.
155
161
  4. `npm run check:specs` — before the push.
156
162
  5. Acceptance goes by the scenarios, not by a retelling of the edit.
157
163
 
164
+ Between steps 2 and 3 `npm run check:specs` is red by design, not by mistake. A scenario without a
165
+ test it only lists, but a rule without a binding and a contract row without a procedure it refuses,
166
+ and their bindings name code that is not written yet. So a stage that edits the spec names as its
167
+ readiness sign the refusal list itself — only the new rules unbound, only the new scenarios under
168
+ "no test" — and not exit 0. Exit 0 is the sign of the stage that writes the bound code.
169
+
158
170
  A rule promising a result a person sees is confirmed on the running application, not by
159
171
  inference from the call graph. Reading confirms headings, the link to bindings and the shape of
160
172
  data; a rule with nothing to confirm it on leaves as an open question and is not written as a
@@ -2,7 +2,7 @@
2
2
  name: testing-e2e
3
3
  kind: pattern
4
4
  rule: testing
5
- description: Pattern of rule testing. Load when editing and running end-to-end tests in apps/site-e2e and apps/admin-e2e — what an end-to-end test closes, ready-made run commands, a stand from the production build behind real nginx, test switches. Not for unit tests — that is pattern testing-unit.
5
+ description: Pattern of rule testing. Load when editing and running end-to-end tests in any end-to-end suite of the tree (apps/*-e2e) — what an end-to-end test closes, ready-made run commands, a stand from the production build behind real nginx, test switches. Not for unit tests — that is pattern testing-unit.
6
6
  ---
7
7
 
8
8
  # End-to-end tests
@@ -31,7 +31,8 @@ An action that adds a node to the page — sending a message, adding a row, atta
31
31
  done at least twice in one test. The first time the page holds only the node the action needs; the
32
32
  second time it also holds the one the first action added, and a query that matched by a shared mark
33
33
  now finds the wrong node. One send per test passes against a handler that breaks on every second
34
- send.
34
+ send. A toast is such a node too: the one from the previous action is still on screen, so the toast
35
+ is matched by the text only its own action puts out, not by a broad pattern.
35
36
 
36
37
  Elements are found by `qa-dataid`: classes change together with the layout, and a search by role
37
38
  and text breaks on translations.
@@ -128,8 +129,17 @@ The same holds for a popup that stays open after its item is chosen. It covers t
128
129
  click aimed at a button under it goes to the popup: the screen answers as if the button had not
129
130
  been pressed at all. The popup is closed and its absence awaited by the same pair of lines.
130
131
 
132
+ A screen is ready when its data is, not when its heading is. A heading, a month title or a toolbar
133
+ comes from the template and is drawn before the request answers. A check or a frame that waits for
134
+ it reads an empty grid. The wait names a node that exists only with data: a row, a booking, a
135
+ selected record.
136
+
131
137
  ## Common misses
132
138
 
139
+ - **A search on the stand matches by substring, and older seeds stay.** `editor@example.com` also
140
+ found `stand-editor@…` and `e2e-editor@…` left by earlier runs, and four old tests failed at
141
+ once. People a suite creates carry the suite prefix in the whole value (`e2e-<suite>-…`), and the
142
+ test searches by that whole value, not by a common part.
133
143
  - **A service limit per client address counts the whole suite as one client.** Every test goes from
134
144
  one machine, so a limit on requests per minute is reached by the sum of the tests, not by any one
135
145
  of them. Adding tests pushes old ones into refusal (429): a run of one spec stays green, and only
@@ -164,3 +174,7 @@ been pressed at all. The popup is closed and its absence awaited by the same pai
164
174
  - **A build directory removed under a mounted volume leaves the container with an empty root:** the
165
175
  stand answers 403 to everything, and all tests fail at once. After
166
176
  `rm -rf dist/apps/<application>` the container is recreated.
177
+ - **The service name of a direct call is copied from the contract.** A service is often named by
178
+ its audience, not by its record. A guessed name gets "not found" for the whole path, and that
179
+ reads as a broken procedure or a missing right. The name is found in the contract declarations
180
+ before the first call.
@@ -129,6 +129,10 @@ nothing.
129
129
 
130
130
  - A lib without its own `vitest.config.mts`: `nx test <project>` passes green without running a
131
131
  single file. Before writing the first test in a lib, check that the config is next to it.
132
+ - **The compiler import goes into the harness file, not into the spec.** A lib that renders nothing
133
+ still pulls the framework when its test imports a barrel with a framework service, and the first
134
+ import fails on JIT. The import goes into the file named in `setupFiles` of the lib's run config:
135
+ in the spec the linter moves it below its neighbours, and the test turns red only in the full set.
132
136
  - Substituting a module (`vi.mock`) would hide what the test is created for — which call went to
133
137
  the database and in what order. The double is written by hand.
134
138
  - Do not create your own helpers for assertions: `expect(...).toBe(...)` and `.toEqual(...)`
@@ -37,6 +37,10 @@ The rule is `styling-bem`; the articles that hold the law stand there.
37
37
  - **`justify-content: center` in a flex container with `overflow-x` pushes the first items beyond
38
38
  zero scroll** — there is no way to scroll to them. In scrollable strips —
39
39
  `justify-content: safe center`.
40
+ - **A strip with `overflow-x` inside a flex column collapses to a few pixels.** Any `overflow` other
41
+ than `visible` makes the item a scroll container, and its automatic minimum height becomes zero.
42
+ When the column runs out of height, the strip yields first. The strip gets `flex-shrink: 0`. The
43
+ measurement is the strip's height against its button's, at three widths.
40
44
  - **Do not put `scrollbar-gutter: stable` on the root:** the reserve for the scrollbar narrows the
41
45
  containing block for `position: fixed`, and a popup aligned to the right edge lands a reserve's
42
46
  width to the left of its button.
@@ -49,3 +53,10 @@ The rule is `styling-bem`; the articles that hold the law stand there.
49
53
  be reset.
50
54
  - **stylelint disable comments are not placed.** Selectors are combined by nesting.
51
55
  - **Moving styles adds no new declarations** — only existing ones are relocated.
56
+ - **A moved rule keeps the reach it had, not the one its comment names.** Sass `&` repeats the
57
+ whole parent selector, `:host-context(...)` included. `:host-context(.x) .block { &__a &__b {} }`
58
+ compiles to two `:host-context` in one selector. After the encapsulation shim, `__a` no longer
59
+ limits `__b`, and the rule reaches every `__b`. Before a move, the reach is read from the
60
+ compiled selector in the build output. After the move, frames of the affected screens are
61
+ compared byte for byte with frames taken before the edit. Build, lint and the class check stay
62
+ green, and the eye misses a change of one font step.
@@ -91,6 +91,10 @@ flowchart TD
91
91
  answers it. The sign that closes the screen arrives with the substituted profile. Asking a person
92
92
  to do a step of the check — type a password, open a tab, press a button — means a wrongly chosen
93
93
  path, not a lack of rights on the executor's side.
94
+ - **A move of people into a sign-in system is checked by signing in as a moved person.** The stand
95
+ holds the same profile fields as the real people have after the move: a person moved with only a
96
+ mail and rights lacks what the system requires of a profile, and is sent to a step the form check
97
+ never reaches. Requests to the form, the API and the sign-in settings walk no part of that path.
94
98
  - **Changing the number of elements in a container is a layout edit.** It touches no styles, so it
95
99
  reads as a markup edit, and the check shrinks to response codes. The pages answer in every locale,
96
100
  and the document is already twice the viewport width. It is closed by a measurement — document
@@ -102,6 +106,9 @@ flowchart TD
102
106
  edge and clipping without a sign show only where the content does not fit its place. On a short
103
107
  value all three look fine. The value for measurement is the extreme one — what the node can get
104
108
  from a real consumer, not what stands in the example.
109
+ - **The longest value is set for every node that shares the line, not only for the edited one.** An
110
+ element next to a neighbour takes its place from the neighbour's length. A long neighbour wraps
111
+ the element to a new line, and the element lands at its start. Its own short value hides that.
105
112
  - **A ready-made kit piece taken for values of another size is measured, not looked at.** A
106
113
  component that lived where values are short gets a value four times longer in its new place. It
107
114
  behaves differently while staying the same code. The test does not see this at all: clipping by
@@ -194,11 +201,6 @@ frontend-application law: such access compiles and fails only when the page is s
194
201
  the new stand, and the list of what was left is named to the owner at the end of the session —
195
202
  only they can kill those. Not named so, stands pile up across sessions and hold connections to the
196
203
  storage.
197
- - **A measurement is also taken by an end-to-end test, not only by the browser driver.** Window
198
- width, node position and the document going sideways are read there by the same computed values.
199
- The viewport is set for the test suite, and the result repeats on every run — unlike a manual
200
- measurement, which lives exactly one session. The driver stays where an unfamiliar screen is
201
- looked at, not where a known number is confirmed.
202
204
  - **A statement about the production build is made from the build itself, not from the branch.**
203
205
  Between the branch and what is served to the reader stands the image build. It substitutes
204
206
  environment values, cuts out the unused and renames symbols. "The build holds this" is checked by
@@ -94,3 +94,7 @@ environment either — that is `Q-FA-1` in the law.
94
94
  `role="dialog"`, `role="tablist"` or `role="tooltip"` means that `<prefix>-message`,
95
95
  `<prefix>-table`, `<prefix>-dialog`, `<prefix>-tabs` or `<prefix>-tooltip` were bypassed. The rule
96
96
  whole — `reuse-first`.
97
+ - **A kit icon name is copied from its file, and an unknown name draws an empty frame.** The kit
98
+ draws the frame of an icon it did not find and says nothing. The build, the lint and the tests
99
+ stay green, and the owner sees an empty square. Before the edit the name is looked up among the
100
+ kit icon files: some names carry the `ico-` prefix and most do not.
@@ -72,7 +72,30 @@ flowchart TD
72
72
  image says only that the build passed: the migrate step, the storage login, the startup order
73
73
  and whether every container has enough put inside are visible from one launch of the stack. On
74
74
  one's own machine that costs one command; on the node it costs a rollout that can no longer be
75
- cancelled — the migrate failure surfaces as a container log on the node.
75
+ cancelled — the migrate failure surfaces as a container log on the node. The same launch is made
76
+ before a merge that lifts packages without a line of code changed: the stack passes an unset
77
+ variable as an empty string, and a new package version may stop accepting what the old one took.
78
+ - **A variable read by several procedures is turned on first on a stand from the production
79
+ build.** On the stand every reader passes; on production one edit says nothing about the
80
+ neighbours, and a variable left empty there turns into addresses built from nothing.
81
+ - **The name production is served under is confirmed by a live answer of that name.** `curl -s -o
82
+ /dev/null -w '%{http_code} %{redirect_url}\n' https://<name>/`: a redirect to a foreign address
83
+ means the name is dead, and the rollout does not go by it. Three files of one epoch agree by
84
+ common origin, not by being right. When a domain moves, the old name is searched across the whole
85
+ tree, not only the paths of one's own part.
86
+ - **Data the screens need that migrations do not create is a step of the rollout.** A seed run once
87
+ by hand heals one storage; a new or restored one stays empty, and a screen that shows an empty
88
+ list for an empty answer looks the same as an unreachable server. The step runs on every rollout
89
+ and is safe to repeat: found records are not overwritten. After the first rollout that depends on
90
+ seeded data the count of records is read on production.
91
+ - **A move of the pipeline to another runner is closed by a search for the labels across all
92
+ workflows.** A flow left on the host is named in the task with its reason. An order worded by a
93
+ set — "all", "every" — is closed against the list of that set, not against the member that got in
94
+ the way first. A rollout with production keys from a developer machine needs a separate word of
95
+ the owner.
96
+ - **The epic plan is checked line by line against the pitfalls of the rollout step before the merge
97
+ of the epic.** Every empty secret in the preparation script becomes a step "before the merge" or
98
+ a decision of the owner, not a line "left to do".
76
99
 
77
100
  - **The image carries every file its own startup steps read.** The storage schema, the client
78
101
  settings, the environment template — everything lying next to it in the repository does not get
@@ -87,7 +110,10 @@ flowchart TD
87
110
  notice that by. They differ in the tail: the server then removes dangling layers and the build
88
111
  cache, the build machine keeps them, otherwise every build goes as the first. Cleanup on the
89
112
  build side does not wait for the merge: a branch image takes as much space, never leaves for the
90
- registry and is never a rollback point.
113
+ registry and is never a rollback point. The build step names its builder explicitly: without the
114
+ name the build goes through the machine's current builder, which may have no cache limit, while
115
+ the declared one stands empty. The build machine keeps the build cache and removes dangling
116
+ images: the builder cache lies in its own volume, and dangling images are not part of it.
91
117
  - **The rollout cleans up old images after itself, keeping the last three sha.** An image tagged
92
118
  with a sha is never dangling, and a dangling cleanup does not touch it: in half a year they eat
93
119
  the server disk whole. Three sha is the rollback depth, and fewer cannot be taken: a breakage
@@ -172,7 +172,7 @@ flowchart TD
172
172
  - **The build is in the set on a par with lint and unit tests.** The linter does not read types,
173
173
  and a type error in uncovered code lives until the merge.
174
174
  - **On a machine with several runners, any path from the home directory is shared.** Install
175
- directory, container name and builder name are per project.
175
+ directory, container name, builder name and published port are per project.
176
176
  - **The push gate set is never narrower than the pipeline set.** A pipeline step with neither a
177
177
  line in the set nor a declared exclusion refuses the push: a warning reads as permission.
178
178
  - **The gate set calls the package default instead of listing it line by line.** Rewritten as