@rt-tools/agent-kit 0.30.1 → 0.32.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 (40) hide show
  1. package/assets/checks/board.github.mjs +5 -1
  2. package/assets/checks/spec-anchors.mjs +13 -0
  3. package/assets/checks/task-new.github.mjs +24 -0
  4. package/assets/defaults/gate-map.sh +4 -0
  5. package/assets/defaults/project.sh +3 -0
  6. package/assets/defaults/shell.sh +18 -5
  7. package/assets/hooks/dispatch.sh +8 -4
  8. package/assets/hooks/epic-stop-guard.sh +1 -1
  9. package/assets/hooks/git-guard-delivery-body.sh +51 -0
  10. package/assets/hooks/git-guard-delivery-epic.sh +21 -0
  11. package/assets/hooks/git-guard-delivery-merge.sh +32 -0
  12. package/assets/hooks/git-guard-delivery.sh +12 -26
  13. package/assets/hooks/skill-gate-rearm.sh +18 -2
  14. package/assets/hooks/skill-gate.sh +10 -5
  15. package/assets/laws/mockups.needs-mockups.md +28 -0
  16. package/assets/patterns/git-workflow-commit.azure.md +5 -1
  17. package/assets/patterns/git-workflow-commit.github.md +5 -1
  18. package/assets/patterns/git-workflow-commit.gitlab.md +5 -1
  19. package/assets/patterns/git-workflow-merge.md +12 -0
  20. package/assets/patterns/git-workflow-pr-body.github.md +4 -1
  21. package/assets/patterns/git-workflow-pr-ready.md +9 -0
  22. package/assets/patterns/git-workflow-pr.azure.md +2 -0
  23. package/assets/patterns/git-workflow-pr.github.md +4 -0
  24. package/assets/patterns/git-workflow-pr.gitlab.md +2 -0
  25. package/assets/patterns/lib-layers-new.md +4 -0
  26. package/assets/patterns/mockups-measure.needs-mockups.md +28 -0
  27. package/assets/patterns/spec-driven-domain.md +4 -0
  28. package/assets/patterns/task-flow-archive.md +4 -1
  29. package/assets/patterns/task-flow-resume.md +6 -0
  30. package/assets/patterns/task-flow-start.md +30 -30
  31. package/assets/patterns/testing-e2e.md +15 -1
  32. package/assets/rules/component-structure.md +3 -0
  33. package/assets/rules/deploy-flow.azure.md +4 -0
  34. package/assets/rules/deploy-flow.github.md +4 -0
  35. package/assets/rules/deploy-flow.gitlab.md +4 -0
  36. package/assets/rules/mockups.needs-mockups.md +80 -0
  37. package/assets/rules/task-flow.md +11 -12
  38. package/assets/rules/typescript-conventions.md +9 -0
  39. package/assets/traits.json +15 -12
  40. package/package.json +1 -1
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import { OfflineError, botToken, gh, ghJson, graphql } from './board-gh.mjs';
19
19
  import { declaredEpicOf } from './board-epic-link.mjs';
20
+ import { verdictOnHead } from './board-runs.mjs';
20
21
  export { numberFromTaskDir, taskDirs, unstampFolder } from './board-task-dirs.mjs';
21
22
  import { CONFIG } from './rt-kit-checks.config.mjs';
22
23
 
@@ -186,7 +187,7 @@ export function pullState(ref, options) {
186
187
  const target = ref === undefined || ref === null || `${ref}`.trim() === '' ? [] : [`${ref}`.trim()];
187
188
  let pull;
188
189
  try {
189
- pull = ghJson(['pr', 'view', ...target, '--json', 'number,isDraft,reviewRequests,latestReviews,author,mergeable,headRefName'], options);
190
+ pull = ghJson(['pr', 'view', ...target, '--json', 'number,isDraft,reviewRequests,latestReviews,author,mergeable,headRefName,headRefOid'], options);
190
191
  } catch (error) {
191
192
  if (error instanceof OfflineError) {
192
193
  throw error;
@@ -214,6 +215,9 @@ export function pullState(ref, options) {
214
215
  // The head branch: the folder guard judges the branch of the named PR, not the checked-out
215
216
  // one — the lower PR of a stack is lifted from the upper branch.
216
217
  branch: pull.headRefName ?? null,
218
+ // The run on the tip: `success`, `failure`, `running` or `none`. The merge guard reads it —
219
+ // an epic went into main over a red image build, and the rollout fell after it.
220
+ run: pull.headRefOid ? verdictOnHead(pull.headRefOid, options) : 'none',
217
221
  };
218
222
  }
219
223
 
@@ -151,6 +151,11 @@ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules',
151
151
  const cell = cells[2].trim();
152
152
  rows.set(head, {
153
153
  anchors: [...cells[2].matchAll(ANCHOR)],
154
+ // A path-like token in backticks — a slash and an extension — whose symbol follows it
155
+ // without the colon inside the backticks: `file.ts` `symbol`, or `file.ts`:symbol. A
156
+ // bare path alone is lawful: prose names files in the same cell, and the whole tree
157
+ // turned red on such mentions when every one of them was judged.
158
+ bare: [...cells[2].matchAll(/`([\w./-]*\/[\w./-]*\.[A-Za-z]{2,10})`(?::[\p{L}_#]|\s*`#?[\p{L}_][\p{L}\p{N}_-]*`)/gu)],
154
159
  verdict: VERDICT.test(cell) && cell.length >= VERDICT_MIN,
155
160
  used: false,
156
161
  });
@@ -179,6 +184,14 @@ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules',
179
184
  'or the verdict «Not carried out», «Not applicable», «Not checked» with a reason'
180
185
  );
181
186
  }
187
+ // A binding that lost the colon between the file and the symbol is not read as an anchor,
188
+ // and a row that still has other anchors passed in silence. Judged only in a row that has an
189
+ // anchor: a verdict row names files in prose, and there a bare path is lawful.
190
+ if (row.anchors.length) {
191
+ for (const [, token] of row.bare) {
192
+ report(mapFile, `the colon between the file and the symbol is lost: \`${token}\``);
193
+ }
194
+ }
182
195
  for (const [, path, symbol] of row.anchors) {
183
196
  if (!exists(path)) {
184
197
  report(mapFile, `the binding leads nowhere: there is no file \`${path}\``);
@@ -194,6 +194,30 @@ const labels = args.epic && !args.labels.includes(EPIC_LABEL) ? [...args.labels,
194
194
  */
195
195
  const token = botToken() ?? undefined;
196
196
 
197
+ /**
198
+ * A label that is not in the repository breaks the creation whole: the hosting refuses the call
199
+ * with one line about a label that could not be added, and neither a card nor a number exists. The
200
+ * labels are asked before the creation, and the refusal names the missing ones, the existing ones
201
+ * and the fact that no task was created. The list that cannot be read — offline, no right — does
202
+ * not hold the creation: the hosting will refuse by itself if the label is really missing.
203
+ */
204
+ if (labels.length > 0) {
205
+ let existing = null;
206
+ try {
207
+ existing = ghJson(['label', 'list', '--repo', `${OWNER}/${REPO}`, '--limit', '200', '--json', 'name'], { token }).map(
208
+ (label) => label.name
209
+ );
210
+ } catch {
211
+ existing = null;
212
+ }
213
+ const missing = existing === null ? [] : labels.filter((label) => !existing.includes(label));
214
+ if (missing.length > 0) {
215
+ fail(
216
+ `no task was created: the labels ${missing.map((label) => `«${label}»`).join(', ')} are not in the repository. Existing: ${existing.join(', ')}`
217
+ );
218
+ }
219
+ }
220
+
197
221
  /**
198
222
  * The plan of the epic and the line about it in the card body.
199
223
  *
@@ -235,6 +235,10 @@ skill_for_default() {
235
235
  # The check through the browser is the only area where the rule is needed not for a file
236
236
  # edit but for a tool: what lies there is not the files but the stand and the coordinates.
237
237
  browser) printf '%s\n' 'browser-verification' ;;
238
+ # A call of the design tool needs the rule of mockups for the same reason: what lies there
239
+ # is a sheet, not a file. A tree without the rule is not refused: the gate skips a missing
240
+ # one.
241
+ design) printf '%s\n' 'mockups' ;;
238
242
  esac
239
243
 
240
244
  return 0
@@ -359,6 +359,9 @@ rt_pull_token_login() { :; }
359
359
  # foreign words: a section not named by the tree is not judged at all.
360
360
  RT_PULL_BODY_SECTION="${RT_PULL_BODY_SECTION:-}"
361
361
 
362
+ # The PR body line closing the branch's task (`{number}`); the keyword is the hosting's, so silent.
363
+ RT_PULL_CLOSES_LINE="${RT_PULL_CLOSES_LINE:-}"
364
+
362
365
  # The command that moves a task between the columns of the work queue, and the name of the first
363
366
  # column — the one the task leaves when it is taken into work. The name has no default: the tree
364
367
  # names the columns in its own words, and an invented one would match nothing and silently turn off
@@ -14,8 +14,11 @@
14
14
  # from one laid down by the tool. The analysis — `2026-08-15-guard-denied-shell-wrote-anyway.md`.
15
15
  #
16
16
  # The list is wide on purpose, and the price of that is named: a read command that carries the name
17
- # of an interpreter will be refused on a par with an edit command. A narrow list would cost more — a
18
- # missed form of writing brings back the whole bypass, and it can be found only by a miss.
17
+ # of an interpreter with a document on input will be refused on a par with an edit command. A narrow
18
+ # list would cost more — a missed form of writing brings back the whole bypass, and it can be found
19
+ # only by a miss. Code given to an interpreter as an argument is narrowed: it is a write only when
20
+ # it holds a call that writes, and the price there is the opposite one — a write by a rarer call
21
+ # passes unseen.
19
22
  #
20
23
  # Deletion and moving stand in the list on purpose, not by oversight. Removing a file is an edit
21
24
  # more destructive than any write. What was written is visible in the tree and rolls back, while
@@ -56,11 +59,21 @@ rt_shell_writes_default() {
56
59
  # demand for the shared-code rule without editing anything in it. Over two tasks such refusals
57
60
  # came to about fifteen, and part of them fell on commands that wrote nothing.
58
61
  #
59
- # An interpreter's body comes in two kinds, and both remain a write: a document on input and
60
- # code as an argument.
62
+ # An interpreter's body comes in two kinds. A document on input stays a write: it is a script
63
+ # nobody has read. Code as an argument is a write only when the code holds a call that writes —
64
+ # `writeFile`, `appendFile`, `fs.write`, a stream opened for writing, an opening for `w` or `a`,
65
+ # `write_text`, `write_bytes`, a rename, a copy or a removal. Code without one is a read, and
66
+ # the paths it names are not judged as write targets: a read of one script from the package
67
+ # manifest by `node -e` demanded the dependencies rule. The price of this is named: a write by a
68
+ # call that is not in the list passes unseen, and the list can only grow by a miss.
61
69
  interp='(^|[|;&(]|[[:space:]])(python3?|node|ruby|deno|bun|php|perl)'
70
+ if printf '%s' "$cleaned" | grep -Eq "${interp}([[:space:]][^|]*)?<<"; then
71
+ return 0
72
+ fi
62
73
  if printf '%s' "$cleaned" | grep -Eq \
63
- "${interp}([[:space:]][^|]*)?<<|${interp}([[:space:]]+-[^[:space:]]*)*[[:space:]]+(-e|--eval|-c|-p|--print)([[:space:]]|\$)"; then
74
+ "${interp}([[:space:]]+-[^[:space:]]*)*[[:space:]]+(-e|--eval|-c|-p|--print)([[:space:]]|\$)" \
75
+ && printf '%s' "$cleaned" | grep -Eq \
76
+ 'writeFile|appendFile|fs\.write|createWriteStream|\.write\(|write_text|write_bytes|open\([^)]*,[[:space:]]*["'"'"'][wa]|renameSync|copyFile|cpSync|unlinkSync|rmSync|os\.(rename|remove|unlink)|shutil\.|File\.(write|open)'; then
64
77
  return 0
65
78
  fi
66
79
 
@@ -107,17 +107,21 @@ EOF
107
107
  fi
108
108
  if [ "$code" -ne 0 ]; then
109
109
  if [ -n "$branch_out" ]; then
110
- printf '%s\n' "$branch_out"
110
+ refusal="$branch_out"
111
111
  elif [ -n "$said_err" ]; then
112
- printf '%s\n' "$said_err"
112
+ refusal="$said_err"
113
113
  else
114
114
  # The branch exited non-zero and said nothing by either stream. From the outside that
115
115
  # is indistinguishable from a refusal on the merits, and there is nothing to fix: nobody
116
116
  # knows which file is broken. So the dispatcher names it itself, otherwise nothing says
117
117
  # anything about a broken branch.
118
- printf 'The guard %s exited with code %s and printed nothing: the file looks broken.\n' \
119
- "$(basename "$branch")" "$code"
118
+ refusal="$(printf 'The guard %s exited with code %s and printed nothing: the file looks broken.' \
119
+ "$(basename "$branch")" "$code")"
120
120
  fi
121
+ printf '%s\n' "$refusal"
122
+ # At code 2 the agent is given only the error stream, and the output stream is dropped:
123
+ # a refusal printed only above reached the executor empty. The text goes to both.
124
+ printf '%s\n' "$refusal" >&2
121
125
  exit "$code"
122
126
  fi
123
127
 
@@ -121,7 +121,7 @@ if [ -z "$checks" ] || [ "$checks" = null ]; then
121
121
  checks=tools
122
122
  fi
123
123
 
124
- reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left: their message or their answer to a menu that names the number of this work releases the call."
124
+ reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left: their message or their answer to a menu that names the number of this work releases the call. A new epic the owner has declared needs the bypass line in the calls that create its card, its tasks and its branch; once the branch of the new epic is taken, the guard reads that epic and stops refusing."
125
125
 
126
126
  # shellcheck disable=SC1090
127
127
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ # The body of a PR being opened, for the delivery guard: the section about the remaining step and the
3
+ # line that closes the task.
4
+ #
5
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The delivery guard
6
+ # sources it — one tier of its verdict, moved out when the guard reached its length limit. It uses
7
+ # the guard's own variables — the command, the task number of the branch, both samples — and the
8
+ # guard's `fault`.
9
+
10
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
11
+
12
+ rt_delivery_pull_body() {
13
+ # The body arrives either as an argument or as a file, both are read here; by the time of the
14
+ # parse the file is already written. Neither one nor the other — there is no requirement: a PR
15
+ # without a body is checked by the guard elsewhere. The flag is recognised only as a separate
16
+ # word: the tail `-b` of a branch name in the base argument read as the body flag, and the next
17
+ # word of the command became the body.
18
+ [ -z "$pull_body_section" ] && [ -z "$pull_closes_line" ] && return 0
19
+ command -v perl >/dev/null 2>&1 || return 0
20
+
21
+ local body body_file closes
22
+ body="$(printf '%s' "$cmd" | perl -0ne '
23
+ if (/(?:^|\s)(?:--body|-b)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
24
+ print defined $1 ? $1 : (defined $2 ? $2 : $3);
25
+ }
26
+ ' 2>/dev/null)"
27
+ body_file="$(printf '%s' "$cmd" | perl -0ne '
28
+ if (/(?:^|\s)(?:--body-file|-F)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
29
+ print defined $1 ? $1 : (defined $2 ? $2 : $3);
30
+ }
31
+ ' 2>/dev/null)"
32
+ [ -z "$body" ] && [ -n "$body_file" ] && [ -f "$body_file" ] && body="$(cat "$body_file" 2>/dev/null)"
33
+ [ -z "$body" ] && return 0
34
+
35
+ # The section about the remaining step: without it the owner merges the PR by the button while
36
+ # the run is still going.
37
+ if [ -n "$pull_body_section" ] && ! printf '%s' "$body" | grep -qE "$pull_body_section"; then
38
+ fault "the body of the request carries no section about the remaining step. The merge button is pressed by a person on the hosting, where there are no guards, and they merge as soon as they see green: all that holds the requirement there is what the owner read on the page. The section stands last and says exactly one thing — whether anything is left before the merge; it is rewritten by the same call that edits the body."
39
+ fi
40
+
41
+ # The line that closes the task. Without it the merged task stays open on the board, and the
42
+ # work queue audit names that only after the merge — three PRs of one epic went out so, and the
43
+ # owner closed their tasks by hand. The number is the branch's, not the one the executor
44
+ # remembers.
45
+ if [ -n "$pull_closes_line" ] && [ -n "$number" ]; then
46
+ closes="${pull_closes_line//\{number\}/$number}"
47
+ printf '%s' "$body" | grep -qE "$closes" \
48
+ || fault "the body of the request carries no line that closes the task #${number}. Without it the task stays open after the merge, and the board shows the merged work as not done. Write the line by the sample of the tree: ${closes}"
49
+ fi
50
+ return 0
51
+ }
@@ -36,6 +36,19 @@ rt_epic_branch() {
36
36
  printf '%s' "$_found"
37
37
  }
38
38
 
39
+ # Whether the epic is already merged into the main branch: a merge commit of the remote main branch
40
+ # names it by the key and the number (`RT-12`) — in the branch name of a merge of the host or in the
41
+ # title of the request. The number is matched whole, so `RT-1` does not match `RT-12`. Success — the
42
+ # epic is merged. No remote main branch, or no such commit, is not merged: the refusal that follows
43
+ # is the former one.
44
+ rt_epic_is_merged() {
45
+ _num="$1"
46
+ [ -n "$_num" ] || return 1
47
+ git rev-parse --verify --quiet "origin/${main_branch}" >/dev/null 2>&1 || return 1
48
+ [ -n "$(git log "origin/${main_branch}" --merges -n 1 -E \
49
+ --grep="(^|[^0-9A-Za-z])[A-Za-z]+-${_num}([^0-9]|\$)" --format=%H 2>/dev/null)" ]
50
+ }
51
+
39
52
  # The base of a new task branch against the branch of its epic.
40
53
  #
41
54
  # The task branch is taken from the branch of the epic, and a branch taken from the main one leaves
@@ -58,6 +71,14 @@ rt_epic_base() {
58
71
  _epic_branch="$(rt_epic_branch "$_epic")"
59
72
  case "$_epic_branch" in
60
73
  '')
74
+ # An epic that is already merged has no branch in the remote: the host deletes it on the
75
+ # merge, and a task left behind in it would be demanded a base nobody has — then a push
76
+ # recreates the branch with a merge nobody reviews. The merge of the epic is recognised
77
+ # by a merge commit of the main branch that names the epic; the task then grows from
78
+ # the main branch.
79
+ if rt_epic_is_merged "$_epic"; then
80
+ return 0
81
+ fi
61
82
  fault "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has."
62
83
  return 0
63
84
  ;;
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+ # The run on the tip of a PR being merged, for the delivery guard.
3
+ #
4
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The delivery guard
5
+ # sources it and calls it on a merge command. It uses the guard's own variables — the command and
6
+ # the tree root — and the guard's `fault`.
7
+
8
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
9
+
10
+ rt_delivery_merge_run() {
11
+ # An epic went into main while the run on its tip was red on the image build: the rollout fell,
12
+ # and every next PR into main turned red. The red was on the PR page and was not read.
13
+ #
14
+ # A red and an unfinished run refuse. `none` passes: a PR into an epic branch gets no run at
15
+ # all, and refusing it would refuse every task of an epic. The tier is a network one — no answer
16
+ # from the work queue helper, no demand.
17
+ command -v rt_pull_state >/dev/null 2>&1 || return 0
18
+ local ref pull run name
19
+ ref="$(printf '%s' "$cmd" | sed -nE 's/.*(gh[[:space:]]+pr[[:space:]]+merge)[[:space:]]+([^[:space:];&|-][^[:space:];&|]*).*/\2/p' | head -1)"
20
+ pull="$(cd "$root" && rt_pull_state "$ref" 2>/dev/null)" || return 0
21
+ printf '%s' "$pull" | jq -e '.exists' >/dev/null 2>&1 || return 0
22
+ run="$(printf '%s' "$pull" | jq -r '.run // empty' 2>/dev/null)"
23
+ name="$(printf '%s' "$pull" | jq -r '.number // empty' 2>/dev/null)"
24
+ name="${name:-$ref}"
25
+ case "$run" in
26
+ failure)
27
+ fault "the run on the tip of the request${name:+ #${name}} is red. A merge over red carries the breakage into the branch, and every next request into it turns red. Read the run — gh run list --commit <tip> — fix it in the branch and repeat." ;;
28
+ running)
29
+ fault "the run on the tip of the request${name:+ #${name}} has not finished. A merge before its end carries what it has not checked yet. Wait for its end and read the result by a command." ;;
30
+ esac
31
+ return 0
32
+ }
@@ -117,6 +117,9 @@ pull_token_hint="${RT_PULL_TOKEN_HINT:-}"
117
117
  # the pattern is named by the tree, not by the package: the package does not know someone else's
118
118
  # words, and an invented default would match nothing.
119
119
  pull_body_section="${RT_PULL_BODY_SECTION:-}"
120
+ # The line that closes the task on the merge, with `{number}` in place of the task number. Its keyword
121
+ # belongs to the hosting, so the sample is named by the tree, as the section above.
122
+ pull_closes_line="${RT_PULL_CLOSES_LINE:-}"
120
123
  commit_email="${RT_COMMIT_EMAIL:-}"
121
124
  tasks_dir="${RT_TASKS_DIR:-}"
122
125
  archive_dir="${RT_ARCHIVE_DIR:-}"
@@ -332,6 +335,10 @@ command -v rt_delivery_draft_ready >/dev/null 2>&1 && rt_delivery_draft_ready
332
335
  # quotes — that is how it fired on an edit of this very text. A quoted substring cannot be cut off
333
336
  # entirely this way, but an accidental mention inside a word or a path no longer gets through.
334
337
  if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}(gh[[:space:]]+pr[[:space:]]+merge|glab[[:space:]]+mr[[:space:]]+merge|az[[:space:]]+repos[[:space:]]+pr[[:space:]]+update)([[:space:]]|\$)"; then
338
+ # The run on the tip goes first: the folder tier below leaves the guard early on many paths.
339
+ [ -f "$rt_hooks_dir/git-guard-delivery-merge.sh" ] && . "$rt_hooks_dir/git-guard-delivery-merge.sh" 2>/dev/null
340
+ command -v rt_delivery_merge_run >/dev/null 2>&1 && rt_delivery_merge_run
341
+ deny_faults
335
342
  rt_delivery_merge_folder
336
343
  fi
337
344
 
@@ -457,32 +464,11 @@ elif [ -n "$pull_token_var" ] \
457
464
  fault "who will open the request cannot be learned: the hosting was not asked, and the command carries no substitution of «${pull_token_var}». Opened by the logged-in account, the request may come out from the very person named as its reviewer, and that is fixed only by reopening.${pull_token_hint:+ Substitute the token: ${pull_token_hint} …}"
458
465
  fi
459
466
 
460
- # The PR body carries the section about the remaining step from the minute it opens: without it the
461
- # owner merges the PR by the button while the run is still going. The body arrives either as an
462
- # argument or as a file, both are read here; by the time of the parse the file is already written.
463
- # Neither one nor the other — there is no requirement: a PR without a body is checked by the line
464
- # above. The flag is recognised only as a separate word: the tail `-b` of a branch name in the base
465
- # argument read as the body flag, and the next word of the command became the body.
466
- if [ -n "$pull_body_section" ]; then
467
- body=''
468
- if command -v perl >/dev/null 2>&1; then
469
- body="$(printf '%s' "$cmd" | perl -0ne '
470
- if (/(?:^|\s)(?:--body|-b)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
471
- print defined $1 ? $1 : (defined $2 ? $2 : $3);
472
- }
473
- ' 2>/dev/null)"
474
- body_file="$(printf '%s' "$cmd" | perl -0ne '
475
- if (/(?:^|\s)(?:--body-file|-F)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
476
- print defined $1 ? $1 : (defined $2 ? $2 : $3);
477
- }
478
- ' 2>/dev/null)"
479
- [ -z "$body" ] && [ -n "$body_file" ] && [ -f "$body_file" ] && body="$(cat "$body_file" 2>/dev/null)"
480
- fi
481
-
482
- if [ -n "$body" ] && ! printf '%s' "$body" | grep -qE "$pull_body_section"; then
483
- fault "the body of the request carries no section about the remaining step. The merge button is pressed by a person on the hosting, where there are no guards, and they merge as soon as they see green: all that holds the requirement there is what the owner read on the page. The section stands last and says exactly one thing — whether anything is left before the merge; it is rewritten by the same call that edits the body."
484
- fi
485
- fi
467
+ # The body of the request: the section about the remaining step and the line that closes the task.
468
+ # The subject lives in a helper next door — `git-guard-delivery-body.sh`, by the same technique as
469
+ # the draft above.
470
+ [ -f "$rt_hooks_dir/git-guard-delivery-body.sh" ] && . "$rt_hooks_dir/git-guard-delivery-body.sh" 2>/dev/null
471
+ command -v rt_delivery_pull_body >/dev/null 2>&1 && rt_delivery_pull_body
486
472
 
487
473
 
488
474
  # The task folder is taken apart before the PR opens, not after the approval: the owner merges as
@@ -21,7 +21,18 @@ input="$RT_HOOK_INPUT"
21
21
  sid="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
22
22
  [ -z "$sid" ] && exit 0
23
23
 
24
- rm -f "${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded" 2>/dev/null
24
+ record="${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded"
25
+
26
+ # The names the session had loaded are read before the record is removed. The gate asks for one rule
27
+ # per refusal, and a session that does not know which rules it had loaded meets them one refusal at
28
+ # a time: one edit after a compaction went through six refusals in a row. An empty or missing record
29
+ # gives no names, and the line stays as it was.
30
+ loaded=""
31
+ if [ -s "$record" ]; then
32
+ loaded="$(awk 'NF && !seen[$0]++ { printf "%s%s", (n++ ? ", " : ""), $0 }' "$record" 2>/dev/null)"
33
+ fi
34
+
35
+ rm -f "$record" 2>/dev/null
25
36
 
26
37
  # The re-arming is told to the session in words.
27
38
  #
@@ -29,6 +40,11 @@ rm -f "${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded" 2>/dev/null
29
40
  # the gate answers that they were not — and the session spends a turn finding out which of the two
30
41
  # is right. A turn was spent that way four times in one session. The line removes the contradiction:
31
42
  # the rule text is no longer in the context, which is why it is asked for again.
32
- jq -n '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:"The rules gate is armed anew: the compaction carried the text of the rules themselves out of the session, and every area will ask for its rule once more. The former loading does not count — load the rule and work on."}}' 2>/dev/null
43
+ context="The rules gate is armed anew: the compaction carried the text of the rules themselves out of the session, and every area will ask for its rule once more. The former loading does not count — load the rule and work on."
44
+ if [ -n "$loaded" ]; then
45
+ context="${context} Loaded before the compaction: ${loaded}. Load in one turn every one of them that the current stage touches, before the first edit."
46
+ fi
47
+
48
+ jq -n --arg c "$context" '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:$c}}' 2>/dev/null
33
49
 
34
50
  exit 0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__claude-in-chrome__.*
2
+ # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__claude-in-chrome__.*|mcp__figma__use_figma
3
3
  # Requires: hooks/deny-tail.sh
4
4
  # The rules gate: it does not let a file be edited until the rule it falls under has been loaded.
5
5
  #
@@ -25,9 +25,10 @@
25
25
  # override is loaded second and may call the default back — `skill_for_default`. There is neither
26
26
  # — the gate passes everything: an empty gate is better than a gate that refuses at random.
27
27
  #
28
- # The call kind is `edit`, `bash` or `browser`. Browser verification is the only area where a rule
29
- # is needed not for a file edit but for a tool: what lies there is not the files but the stand and
30
- # the coordinates.
28
+ # The call kind is `edit`, `bash`, `browser` or `design`. Browser verification and the design tool
29
+ # are the areas where a rule is needed not for a file edit but for a tool: what lies there is not
30
+ # the files but the stand and the coordinates, or the sheet of mockups. A rule the tree lacks is not
31
+ # demanded, so the design kind costs a tree without mockups nothing.
31
32
  #
32
33
  # FAIL-OPEN: any error and any unrecognised path let the edit through (exit 0). A broken gate has
33
34
  # no right to stop the work altogether.
@@ -137,6 +138,10 @@ EOF
137
138
  req="$(skill_for browser "$tool" "" 2>/dev/null)"
138
139
  kind="browser"
139
140
  ;;
141
+ mcp__figma__use_figma)
142
+ req="$(skill_for design "$tool" "" 2>/dev/null)"
143
+ kind="design"
144
+ ;;
140
145
  *) exit 0 ;;
141
146
  esac
142
147
 
@@ -214,7 +219,7 @@ fi
214
219
  # itself. The rule whole stays the second move — for whoever finds the article not enough.
215
220
  # shellcheck disable=SC1090
216
221
  [ -f "$rt_hooks_dir/rule-article.sh" ] && . "$rt_hooks_dir/rule-article.sh" 2>/dev/null
217
- if [ "$kind" != "command" ] && [ "$kind" != "browser" ] && command -v rt_rule_article_heads >/dev/null 2>&1; then
222
+ if [ "$kind" != "command" ] && [ "$kind" != "browser" ] && [ "$kind" != "design" ] && command -v rt_rule_article_heads >/dev/null 2>&1; then
218
223
  article="$(rt_rule_article_heads "$root/$rules_dir/${req}/SKILL.md" "$target" 2>/dev/null)"
219
224
  if [ -n "$article" ]; then
220
225
  reason="Refused by the rules gate. This edit falls under the articles of the rule «${req}»:
@@ -0,0 +1,28 @@
1
+ # Law on mockups
2
+
3
+ What the owner sees before the code is written. The owner reads a screen by its picture, and a
4
+ picture that does not match the screen makes every detail of the code read as broken layout.
5
+
6
+ **Revision:** 2026-10-15
7
+
8
+ ## Articles
9
+
10
+ - **An approved mockup is the source of truth for how a screen looks.** Where mockups exist, a
11
+ change of the look starts with a change of the mockup. The changed mockup is shown to the owner,
12
+ and the code is written only after their approval. An agreement in words does not replace the
13
+ mockup: the owner reads the screen by the picture. A detail the code adds past the mockup reads to
14
+ the owner as broken layout, however correct the text behind it.
15
+ - **Mockups are kept in step with the screens they draw.** A mockup that lags behind the code no
16
+ longer says what is right, and the next change is checked against a wrong picture. A finding along
17
+ the way that changes the look goes to the mockup first, and only then into the code.
18
+ - **A mockup makes a layout claim, and the claim is measured.** A frame is checked by numbers, the
19
+ way a page is: what the eye misses on a screenshot — buttons of one row off one line, frames
20
+ overlapping on the sheet — is read from the node coordinates before the owner sees the frames.
21
+ - **A mockup of behaviour the product already has starts from the description of that behaviour.**
22
+ A screen on a sheet looks like work without code, but how a payment is taken or which fields a
23
+ form holds is already written down and carried out. The description is read before the first
24
+ frame.
25
+
26
+ ## Open questions
27
+
28
+ None.
@@ -147,7 +147,7 @@ GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<почта бота>" \
147
147
 
148
148
  The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
149
149
  `test`, `chore`, `perf`. Scopes are the tree's own, listed in `implementation.md`. A full stop
150
- at the end of the subject is not accepted.
150
+ at the end of the subject is not accepted. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
151
151
 
152
152
  The line `AB#<номер>` in the commit body attaches it to the work item. It does not replace the
153
153
  attachment of the PR itself: the commit is linked to the item, and the work queue reads the PR's
@@ -162,6 +162,10 @@ is mandatory:
162
162
  Docs-skip: правка только в тестах хука, зеркала у него нет
163
163
  ```
164
164
 
165
+ The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
166
+ `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
167
+ as in `git commit -F -` with the text after it.
168
+
165
169
  ## Common misses
166
170
 
167
171
  - **An audit right after adding answers "no" when the card already stands.** The work queue gives
@@ -204,7 +204,7 @@ GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<номер>+<бот>@users.n
204
204
 
205
205
  The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
206
206
  `test`, `chore`, `perf`. Scopes: `site`, `admin`, `api`, `common`, `proto`, `deploy`. A full stop
207
- at the end of the subject is not accepted; the length — up to 150 characters.
207
+ at the end of the subject is not accepted; the length — up to 150 characters. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
208
208
 
209
209
  ```
210
210
  feat(<область>): availability calendar with season prices
@@ -235,6 +235,10 @@ is mandatory:
235
235
  Docs-skip: правка только в тестах хука, зеркала у него нет
236
236
  ```
237
237
 
238
+ The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
239
+ `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
240
+ as in `git commit -F -` with the text after it.
241
+
238
242
  ## Common misses
239
243
 
240
244
  - **An amend goes through the same hooks as a commit.** The flag that skips the commit hooks is not
@@ -149,7 +149,7 @@ GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<почта бота>" \
149
149
 
150
150
  The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
151
151
  `test`, `chore`, `perf`. Scopes are the tree's own, listed in `implementation.md`. A full stop
152
- at the end of the subject is not accepted.
152
+ at the end of the subject is not accepted. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
153
153
 
154
154
  ```
155
155
  feat(site): availability calendar with season prices
@@ -166,6 +166,10 @@ is mandatory:
166
166
  Docs-skip: правка только в тестах хука, зеркала у него нет
167
167
  ```
168
168
 
169
+ The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
170
+ `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
171
+ as in `git commit -F -` with the text after it.
172
+
169
173
  ## Common misses
170
174
 
171
175
  - **An audit right after adding answers "no" when the card already stands.** The work queue gives
@@ -113,6 +113,18 @@ npm run check:docs && npm run check:specs && npm run check:dupes && npm run chec
113
113
  bash .claude/hooks/tests/run.sh # if the conflict touched the hooks
114
114
  ```
115
115
 
116
+ A merge without conflicts is not exempt: two branches can declare the same value apart, and the
117
+ merge joins them silently — the duplicate check turns red only at the push. After every merge of the
118
+ base, a conflict-free one included, the duplicate and the styles checks run (`npm run check:dupes`
119
+ and `npm run check:styles`), and the value moves to its one shared place; no line goes into the
120
+ known list.
121
+
122
+ **After a merge of the base, the migrations it brought are read.** Those that set the rights of a
123
+ role are opened. A branch migration that writes a role's full set of rights drops any right the base
124
+ added meanwhile; git sees two different files and marks no conflict, and the fall shows later as a
125
+ failing test on the count of rights, easy to take for a test error. The lost right returns by a new
126
+ migration of the branch.
127
+
116
128
  The merge commit is signed by the bot the same way as any other — pattern
117
129
  `git-workflow-commit`. After the push the state is read from the PR itself, not from one's own
118
130
  tree — more on this in pattern `git-workflow-pr`:
@@ -21,7 +21,10 @@ Pattern of the rule `git-workflow`. What must be true — the law
21
21
 
22
22
  ## The PR is attached to the task
23
23
 
24
- The body starts with the link line — by it the board fills the linked PRs field. Reviewer,
24
+ The body starts with the link line — by it the board fills the linked PRs field, and by it the task
25
+ closes on the merge. The number in it is the branch's, copied rather than recalled; a tree that
26
+ named the sample of the line in its profile, `RT_PULL_CLOSES_LINE`, gets the opening refused by the
27
+ delivery guard without it. Reviewer,
25
28
  assignee and labels are set by the same command, and a PR does not open without them:
26
29
 
27
30
  ```bash
@@ -34,6 +34,15 @@ gh pr ready <номер>
34
34
  Lifting the draft is the last step of handing the work over, not a separate matter. Until it is
35
35
  done, the work is not handed over, however many commits lie in the branch.
36
36
 
37
+ **A merge the executor was told to make goes after the run on the tip is read by a command.** The
38
+ merge command is refused by the delivery guard on a red or unfinished run; a click on the host's
39
+ button no guard sees, so before it the run is read the same way. An epic went into main over a red
40
+ image build, and the rollout fell after it.
41
+
42
+ ```bash
43
+ gh run list --commit "$(gh pr view <номер> --json headRefOid --jq .headRefOid)"
44
+ ```
45
+
37
46
  ## Finish the handed-over first, then take new work
38
47
 
39
48
  An open PR is work in flight: its run ages, its branch lags behind main, its body describes the
@@ -79,6 +79,8 @@ AZURE_DEVOPS_EXT_PAT="$TOKEN" az repos pr create \
79
79
  --description 'Закрывает рабочий элемент 86.'
80
80
  ```
81
81
 
82
+ Before the target branch is named, its presence on the host is checked: `git ls-remote --heads origin <ветка>`. An empty answer means the base was merged and removed; the request then takes the next branch up the chain as its base.
83
+
82
84
  The reviewer is always the owner: without a review request the PR does not show in their queue.
83
85
  One PR closes the work item whole — half a task is not rolled out by one PR: a task has one
84
86
  branch, and work that does not fit it is split into tasks before the branch is created.
@@ -81,6 +81,10 @@ the repository's default branch: the request then carries the task past the epic
81
81
  branch stays a copy nobody merges. The epic's own request is the only one based on the main branch,
82
82
  and it opens when the last folder of its tasks is taken apart.
83
83
 
84
+ Before `gh pr create --base <ветка>` the base is checked on the host by `git ls-remote --heads origin
85
+ <ветка>`. An empty answer means the base was merged and removed: the request then takes the next
86
+ branch up the chain as its base, not the removed one.
87
+
84
88
  Everything waiting for a pipeline run, a rework or an answer goes as a draft, and the question is
85
89
  asked in the PR itself: a person reads the PR, not the session's conversation.
86
90
 
@@ -82,6 +82,8 @@ GITLAB_TOKEN="$TOKEN" glab mr create \
82
82
  …'
83
83
  ```
84
84
 
85
+ Before the target branch is named, its presence on the host is checked: `git ls-remote --heads origin <ветка>`. An empty answer means the base was merged and removed; the request then takes the next branch up the chain as its base.
86
+
85
87
  The reviewer is always the owner: without a review request the MR does not show in their queue.
86
88
  The assignee is the same account the machine work goes from. Labels are read from the task, not
87
89
  picked from memory:
@@ -94,3 +94,7 @@ rename or removal.
94
94
  - **A lib nobody imports is checked by nothing.** `nx lint` and `nx test` check the lib itself,
95
95
  not its contract with the consumer. The first importer is the first check: the models layer is
96
96
  accepted after `nx build` and a live run of the scenario, not by a green `lint test`.
97
+ - **A lib's own `sourceTag` is written as a string literal.** The layout check finds the
98
+ description of a lib by the text `sourceTag: '<tag>'`, not by evaluating the module. A tag taken
99
+ from a constant passes the lint and is reported as "described in no file". Constants are for the
100
+ tags in `onlyDependOnLibsWithTags` only.
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: mockups-measure
3
+ kind: pattern
4
+ rule: mockups
5
+ description: Pattern of rule mockups. Load before the frames of a mockup are shown to the owner — reading the bounds of the sheet's frames and of the buttons inside them in one call, overlapping pairs and the distinct tops of a row. Not for checking a running page — that is the rule browser-verification.
6
+ ---
7
+
8
+ # Measuring a mockup
9
+
10
+ Pattern of the rule `mockups`. What must be true — the law `docs/constitution/mockups.md`.
11
+
12
+ ## When to use
13
+
14
+ - The frames of a sheet are about to be shown to the owner.
15
+ - A row of cards, a toolbar or a form is drawn at a width other than the desktop one.
16
+
17
+ ## A mockup is measured by node coordinates
18
+
19
+ A frame in a design tool makes a layout claim, just like a page. A look at its screenshot misses the
20
+ same things: the buttons of a card row are off one line, or frames on the sheet overlap. Before the
21
+ frames are shown to the owner, one call reads the bounds of the sheet's top-level frames and of the
22
+ buttons inside them. It prints the overlapping pairs and each row's distinct button tops. Two
23
+ values in one row are the defect.
24
+
25
+ ## Common misses
26
+
27
+ - **At the tablet width the buttons of a card row stood at different heights, and frames on the
28
+ sheet overlapped.** The owner found both; one call reading node bounds would have shown them.
@@ -222,3 +222,7 @@ statement.
222
222
  author sees their edit, not what the subject will grow into: a domain created along the way
223
223
  turns out a month later to be half of its neighbour, and parting them means parting the scenario
224
224
  numbers too.
225
+ - **A changed or removed scenario is edited in the live spec, not restated in `proposed/`.** The
226
+ spec audit refuses a second heading with a taken number. A changed promise or a removed
227
+ scenario goes into the domain's `scenarios.md` by the commit that changes the code and the test
228
+ title; the agreement names such scenarios by number in prose.
@@ -54,7 +54,7 @@ pick.
54
54
 
55
55
  | File | Where |
56
56
  | --- | --- |
57
- | `grill.md` | to `docs/archive/` — the owner's answers cannot be recovered, and this is the only record of why the task was set this way |
57
+ | `grill.md` | to `docs/archive/` in the owner's language — the owner's answers cannot be recovered, and this is the only record of why the task was set this way. A grill in the layer's language is rewritten at the move; the quoted request stays verbatim |
58
58
  | `progress.md` | to `docs/archive/` if it holds decisions along the way with reasons; otherwise deleted |
59
59
  | `plan.md` | deleted — after the rollout its question is answered by the code, and "how it works" by the domain spec |
60
60
  | review findings | written straight next to the epic plan — they do not move from here; work outside an epic shows them to the owner in the same turn |
@@ -262,6 +262,9 @@ indistinguishable from a sent one.
262
262
  apart, and the owner's words are written only there, with nowhere to recover them from. So the
263
263
  guard demands that the branch add a record to the archive. What exactly was moved it does not
264
264
  check — the owner looks at that in review.
265
+ - **The folder of a task created after the work enters by a commit of its own.** The next commit
266
+ takes it apart. A folder assembled and removed between two commits leaves no trace: the owner may
267
+ merge the PR in that minute, and the grill is gone.
265
268
  - **The closing steps are not agreed with the owner — they are listed here.** The rules review of
266
269
  the work is part of closing, as are merging the agreement and taking the folder apart. The owner
267
270
  decides not whether to launch it but what to do with the findings. A turn that ended with such a
@@ -144,6 +144,12 @@ A stage revision — to the same place, not by editing the plan:
144
144
  прежний этап в замысле оставлен видимым.
145
145
  ```
146
146
 
147
+ A new request of the owner inside the same task goes into the grill, not only into the progress.
148
+ The grill leaves for the archive, the progress only when it holds decisions. The request is quoted
149
+ verbatim under "The owner request"; under "Decisions" goes the answer, or the line "closed by
150
+ assumption: <what is taken>" when the question was not put. Otherwise the archive keeps the first
151
+ answer while the code carries the second.
152
+
147
153
  The session entry marks what was done and what confirms it:
148
154
 
149
155
  ```markdown
@@ -40,9 +40,7 @@ is found is written into the tree in the same turn — into the epic plan if it
40
40
  progress if it concerns one.
41
41
 
42
42
  Exploration that found nothing is no permission to ask: the epic plan, the archive and past sessions
43
- are reached first, and the question names where the search went.
44
-
45
- Exploration ends with command output, not with a feeling: the root memo, `ls` of the directory at
43
+ are reached first, and the question names where the search went. Exploration ends with command output, not with a feeling: the root memo, `ls` of the directory at
46
44
  hand, a search over the documentation and the rules.
47
45
 
48
46
  A member added beside a list, not into it, is named at every reader of that list: each place that
@@ -58,6 +56,10 @@ before questions about techniques: one folder generalised into a map leaves out
58
56
 
59
57
  What was inferred is marked right in the list, together with what confirms it.
60
58
 
59
+ Removing an identifier that lives outside the code starts with a search for its value: a client of
60
+ the authorization server, a key, an environment variable — over the code, the environment samples
61
+ and the composition files. The plan names what uses the identifier now, not what it was created for.
62
+
61
63
  **A ready-made module of the same kind is looked for before the first question** — in this tree and
62
64
  in the trees recorded as samples of its layout. The one found is read whole: it closes the questions
63
65
  about the structure — the source of the numbers, the rows, the screen, the storage.
@@ -86,10 +88,9 @@ All six questions are closed, and those the exploration did not answer are asked
86
88
 
87
89
  The list of six is the set of what is closed by the start of work, not a set of lines to be said. A
88
90
  question the owner has already answered is marked closed together with what closed it: the answer is
89
- sought in the documentation and in what was said in this same session, the original request
90
- included. It can be closed by an assumption too, when the answer is obvious — by the line "question
91
- closed by assumption: <what is taken>": a wrong assumption costs an edit, a question about the
92
- obvious costs a session.
91
+ sought in the documentation and in this session, the original request included. An obvious answer
92
+ closes by the line "question closed by assumption: <what is taken>": a wrong assumption costs an
93
+ edit, a question about the obvious costs a session.
93
94
 
94
95
  **Two answers «recommended» in a row close the remaining questions by assumption.** An owner who took
95
96
  the recommended option twice running has shown that the decisions are not theirs. From the second
@@ -117,12 +118,9 @@ The message with which the executor stops begins with what they wait for:
117
118
  <Вопрос>
118
119
  ```
119
120
 
120
- Under the question goes the table of the epic's position — the same as in the handover. Under, not
121
- above: the stop is named by the first line, and the epic's position is what the owner decides from.
122
- Work outside an epic carries no table.
123
-
124
- Measurements, role findings and the list of decisions are by then written in the progress and are
125
- superfluous in the message: a report with a question at its end drowns the question.
121
+ Under the question goes the table of the epic's position — the same as in the handover; work outside
122
+ an epic carries no table. Measurements, role findings and the list of decisions are already in the
123
+ progress and are left out of the message: a report with a question at its end drowns the question.
126
124
 
127
125
  The answers are written into `docs/tasks/_draft-<slug>/grill.md` — the folder is still a draft,
128
126
  there is no number.
@@ -132,6 +130,10 @@ mkdir -p docs/tasks/_draft-<slug>
132
130
  cp docs/tasks/_template/grill.md docs/tasks/_draft-<slug>/grill.md
133
131
  ```
134
132
 
133
+ An answer chosen from a menu is written with the options it was chosen from: the label alone does
134
+ not show whether the owner took a ready option or wrote their own. A task that stands only on a
135
+ chosen option says so in its body.
136
+
135
137
  **Next move:** the owner's answer is appended to the grill, and the next question follows. The
136
138
  answers are over — in the same turn the work goes into the roles pipeline.
137
139
 
@@ -151,7 +153,9 @@ The agreement that came out of the pipeline is checked against `grill.md` line b
151
153
  by it. The role writes the text without seeing the owner and can turn their answer into its
152
154
  opposite: the order of stages came out reversed, and included items moved to "not included". A
153
155
  critic's finding that diverges from the owner's answer is carried to the owner, not carried out in
154
- silence.
156
+ silence. The same check holds for the executor's own decision on an open question of the agreement:
157
+ it is compared with the grill before it goes to the writer — an open question lists the owner's
158
+ answer among its variants without a mark, and is decided anew.
155
159
 
156
160
  The turn does not end on this boundary. A closed grill looks like a finished piece — the answers are
157
161
  on disk, the file is committed, there is something to report — and the report takes the place of the
@@ -182,9 +186,9 @@ an order is no order: two tasks whose order rested on understanding went into wo
182
186
  round, and the second was redone under the first. The assigned order holds to the end of the epic; a
183
187
  revision is the owner's decision.
184
188
 
185
- The cards are created for all the tasks at once, right here — by the same call with `--epic-of`, for
186
- every row of the makeup. The issued numbers return to the same table, and from this minute "take the
187
- next" answers with a number, not a name.
189
+ The cards for all the tasks are created at once, right here — by the same call with `--epic-of`, for
190
+ every row of the makeup. The issued numbers return to the same table: "take the next" answers with a
191
+ number from now on.
188
192
 
189
193
  **Next move:** the declared epic is committed together with the task numbers, and in the same turn
190
194
  its branch is taken.
@@ -202,7 +206,7 @@ The plan of the epic is committed into it and the branch is pushed at once — t
202
206
  tasks are taken from it, and one that exists only on the machine is a base nobody else has. The card
203
207
  names the branch: the reader comes to the epic from the queue, and the queue holds no branches.
204
208
 
205
- Nothing else is committed into the epic branch: it carries the plan and the merges of the tasks. An
209
+ Nothing else is committed into the epic branch: it carries the plan and the merges of the tasks; an
206
210
  edit made in it directly reaches the main branch unreviewed.
207
211
 
208
212
  **Next move:** the first task of the epic is taken — the branch of the task from the branch of the
@@ -229,10 +233,9 @@ call with `--outside-epic '<слово владельца>'` — a refusal witho
229
233
  branch is created by a second call: a compound "create and commit at once" is refused by the
230
234
  main-branch guard whole.
231
235
 
232
- The number is already issued — there is no draft and none is created: the folder opens straight
233
- under the branch name. Half of all work starts this way: the number comes from a past session, a
234
- noticed defect or a neighbouring task, and there is nothing to rename. The pitfall "the number never
235
- comes first" does not apply here — it is about not creating the task before the grill.
236
+ The number is already issued — there is no draft: the folder opens straight under the branch name.
237
+ Half of all work starts this way (a past session, a noticed defect, a neighbouring task). The pitfall
238
+ "the number never comes first" does not apply: it is about not creating the task before the grill.
236
239
 
237
240
  The other two files are written, not laid down as templates for later: an empty `plan.md` cannot be
238
241
  told from a plan without stages, and the next session trusts the task folder. The template is opened
@@ -297,14 +300,11 @@ state line is rewritten to `этап-идёт`, and from there the work is led b
297
300
  - **Stage:** 1 из 3 — <название первого этапа из замысла>
298
301
  ```
299
302
 
300
- The turn does not end on this boundary. A written plan looks like a finished piece: the stages are
301
- laid out, the file is committed, there is something to report — and the report takes exactly the
302
- place the work should have taken. The owner reads it as done, and nothing is done: on 21 August a
303
- session ended with the line "next step — such-and-such" at a window fill of about two percent.
304
-
305
- Four things end a turn, and they are the same as for the other states: the window fill limit, a
306
- guard's refusal, a question to the owner and handed-in work with the next begun. A pattern read to
307
- the end is not among them — the text ended, the work did not.
303
+ The turn does not end on this boundary. A written plan looks like a finished piece — the file is
304
+ committed, there is something to report — and the report takes the place of the work: a session
305
+ ended with "next step — such-and-such" at a window fill of about two percent. A turn ends by the
306
+ window fill limit, a guard's refusal, a question to the owner or handed-in work with the next
307
+ begun; a pattern read to the end is not among them.
308
308
 
309
309
  **Next move:** the first stage is done in the same turn, and it is declared closed after its command
310
310
  from the "Checked by" line has passed.
@@ -134,6 +134,10 @@ comes from the template and is drawn before the request answers. A check or a fr
134
134
  it reads an empty grid. The wait names a node that exists only with data: a row, a booking, a
135
135
  selected record.
136
136
 
137
+ After a change of the window width, layout values come from different sources at different
138
+ moments: a media query applies at once, a breakpoint signal on the next frame. The test awaits by
139
+ polling the very value it measures; a wait for one value proves nothing about another.
140
+
137
141
  ## Common misses
138
142
 
139
143
  - **A search on the stand matches by substring, and older seeds stay.** `editor@example.com` also
@@ -158,7 +162,17 @@ selected record.
158
162
  - **Not only what the screen requests is substituted, but also what the header requests.** The
159
163
  unread counter is requested on every screen under the header. Without a substitution the real
160
164
  server answers that request, refuses the fake sign-in, the interceptor drops the session, and
161
- fifty-nine tests fail on the vanished header — it looks like a screen defect.
165
+ fifty-nine tests fail on the vanished header — it looks like a screen defect. The same holds for a
166
+ call the task itself adds to a screen: the list of substituted calls is read against the calls
167
+ the screen makes after the edit, and the new one is substituted in every end-to-end test of that
168
+ screen. Unsubstituted, it goes to the real server, which refuses the fake sign-in; the screen
169
+ turns into the sign-in form, and the test fails by its time limit with no visible cause.
170
+ - **A default that matches the first option proves nothing.** A form that opens with a value taken
171
+ from context, such as the record of the card it was opened from, is checked with that value
172
+ standing anywhere but first in the substituted list. A form that ignored the context and took the
173
+ first option shows the same value, and the test stays green on the very defect it was written to
174
+ catch. A comment saying the test tells the two apart does not make it so; the order of the
175
+ substitution does.
162
176
  - **State that lives only during an operation is not checked by a test.** The upload list under the
163
177
  button is visible while the files are in flight: on substituted answers they land before the test
164
178
  manages to read it, and the test turns red every other run. What is checked is either the final
@@ -98,3 +98,6 @@ environment either — that is `Q-FA-1` in the law.
98
98
  draws the frame of an icon it did not find and says nothing. The build, the lint and the tests
99
99
  stay green, and the owner sees an empty square. Before the edit the name is looked up among the
100
100
  kit icon files: some names carry the `ico-` prefix and most do not.
101
+ - **A component that grew past the file limit is split, not squeezed.** An edit of a component does
102
+ not load the rule of plain TypeScript files, where the 500-line article lives, so it is repeated
103
+ in one line here: what the component does on its own moves out into a file next to it.
@@ -98,6 +98,10 @@ flowchart TD
98
98
  - **The migration chain is run from an empty storage before the merge.** The apply order is
99
99
  lexicographic by directory name, and the timestamp is set at creation: a migration from a branch
100
100
  started earlier lands before the one it depends on.
101
+ - **A migration without a reverse is merged only after a copy of the production storage, and the PR
102
+ body names the copy.** Rolling back the image does not bring a dropped column or table back. When
103
+ the executor cannot reach the server, the owner is told which step is blocked and what opens it:
104
+ the owner's word replaces a check only when the owner was told the check did not run.
101
105
  - **The divergence of migrations from the schema is measured on a shadow storage, not on the one
102
106
  the pusher works with.** That one lawfully carries the trace of any unfinished branch, and a
103
107
  check against it would hold up someone else's edit. The gate and the rollout call one and the
@@ -157,6 +157,10 @@ flowchart TD
157
157
  - **The migration chain is run from an empty storage before the merge.** The apply order is
158
158
  lexicographic by directory name, and the timestamp is set at creation: a migration from a branch
159
159
  started earlier lands before the one it depends on.
160
+ - **A migration without a reverse is merged only after a copy of the production storage, and the PR
161
+ body names the copy.** Rolling back the image does not bring a dropped column or table back. When
162
+ the executor cannot reach the server, the owner is told which step is blocked and what opens it:
163
+ the owner's word replaces a check only when the owner was told the check did not run.
160
164
  - **The divergence of migrations from the schema is measured on a shadow storage, not on the one
161
165
  the pusher works with.** That one lawfully carries the trace of any unfinished branch, and a
162
166
  check against it would hold up someone else's edit. The gate and the rollout call one and the
@@ -100,6 +100,10 @@ flowchart TD
100
100
  - **The migration chain is run from an empty storage before the merge.** The apply order is
101
101
  lexicographic by directory name, and the timestamp is set at creation: a migration from a branch
102
102
  started earlier lands before the one it depends on.
103
+ - **A migration without a reverse is merged only after a copy of the production storage, and the PR
104
+ body names the copy.** Rolling back the image does not bring a dropped column or table back. When
105
+ the executor cannot reach the server, the owner is told which step is blocked and what opens it:
106
+ the owner's word replaces a check only when the owner was told the check did not run.
103
107
  - **The divergence of migrations from the schema is measured on a shadow storage, not on the one
104
108
  the pusher works with.** That one lawfully carries the trace of any unfinished branch, and a
105
109
  check against it would hold up someone else's edit. The gate and the rollout call one and the
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: mockups
3
+ kind: rule
4
+ law: mockups
5
+ description: Rule under the mockups law. Load when a screen is drawn or changed in a design tool, before the first frame and before the mockups are shown to the owner. Names the kit copy, the spec read before drawing, the agreement checked against mockups. Pattern mockups-measure.
6
+ ---
7
+
8
+ # Mockups — how it works here
9
+
10
+ Rule under the law `docs/constitution/mockups.md`. The law says what the owner must see before
11
+ the code is written; here — what it is called in this tree, where it lives and what is not checked.
12
+
13
+ ## What it is called here
14
+
15
+ | In the law | Here |
16
+ | ----------------------------------- | ---------------------------------------------------------------------------- |
17
+ | mockup | a frame on a sheet of the design tool |
18
+ | the screen the mockup draws | the page or panel in the application that carries the same name |
19
+ | the description of the behaviour | the domain spec in `docs/specs/<domain>/` |
20
+ | the agreement | the product agreement of the task, `docs/specs/<domain>/proposed/<feature>/` |
21
+ | approved | shown to the owner and accepted in their words |
22
+
23
+ ## Where it lives
24
+
25
+ In this tree — the table in `implementation.md` next to it. Paths live there, not here: the rule
26
+ travels between repositories, the layout does not, and a path named in the rule lies in the
27
+ first tree that keeps its code differently.
28
+
29
+ ## Flow
30
+
31
+ The flow of a mockup from the first frame to the code: what is read before drawing, what is
32
+ measured before showing, and what is checked before work starts by the agreement.
33
+
34
+ ```mermaid
35
+ flowchart TD
36
+ A[A screen is to be drawn or changed] --> B{The behaviour already exists in the tree}
37
+ B -->|Yes| C[The spec of its domain is read before the first frame]
38
+ B -->|No| D[A sample is asked per screen]
39
+ C --> E{A component of the kit goes on the sheet}
40
+ D --> E
41
+ E -->|Yes| F[Its lines and spacing are checked against the kit styles in code]
42
+ E -->|No| G[The frames are drawn]
43
+ F --> G
44
+ G --> H[The coordinates of the frames are measured]
45
+ H --> I[The owner approves the mockups]
46
+ I --> J{The agreement has visual rules}
47
+ J -->|Yes| K[Each rule is found on the mockup of every width; a rule the mockups do not show goes to the owner]
48
+ J -->|No| L[The code is written]
49
+ K --> L
50
+ ```
51
+
52
+ ## How the law applies here
53
+
54
+ - **A kit component on a design-tool sheet is a copy of the kit, and the copy drifts.** The source
55
+ of look is the kit's styles in code. Before a component from the sheet goes into a mockup, its
56
+ visible lines and spacing are checked against the kit's styles. A divergence is a question to the
57
+ owner, and the answer is fixed once in the copy.
58
+ - **A mockup of behaviour the tree already has starts with reading the spec of its domain.** A
59
+ screen in a design tool looks like work without code, so exploration stops at the sheet of earlier
60
+ mockups. How a payment is taken, what a window asks and which fields a form holds are already
61
+ described by the spec and carried out by code. The spec is read before the first frame, and the
62
+ sample question is asked per screen: one sheet named as the sample of the whole set leaves the
63
+ other screens without one.
64
+ - **The agreement is checked against the approved mockups before work by it.** Every visual rule of
65
+ the agreement is found on the mockup of each width. A rule the mockups do not show goes to the
66
+ owner as a question. Found after the code, it costs a code edit and an agreement edit together.
67
+ - **A mockup is measured by node coordinates before it is shown.** The technique is the pattern
68
+ `mockups-measure`.
69
+ - **A design-tool call asks the rules gate for this rule,** like the browser driver does for its
70
+ own: without that the measurement pattern stays unread for the whole mockup task.
71
+
72
+ ## What of the law is not here
73
+
74
+ Nothing checks that a mockup matches the screen it draws or that the owner approved it: both live
75
+ outside the tree, in the design tool and in the owner's words. The checks above are held by reading.
76
+
77
+ ## Patterns
78
+
79
+ - `mockups-measure` — reading the bounds of frames and buttons in one call and what the numbers
80
+ mean.
@@ -149,15 +149,12 @@ flowchart TD
149
149
  justification under someone else's accepted decision reads as its appraisal. One exception:
150
150
  execution stopped by an obstacle — then the obstacle is named.
151
151
  - **The last run of the main branch is read first thing in a session and after every known
152
- merge.** A red main branch after a merge lives until the owner notices; a red or pushed-out run is
153
- fixed before new work is taken.
152
+ merge.** A red main branch lives until the owner notices; a red run is fixed before new work is taken.
154
153
  - **A session does not start work by itself.** The handover, the state from the startup hook and an
155
154
  assigned epic say what to do, not whether to work: a start needs the owner's word in the same
156
155
  session. An empty message, one word or one path order no work.
157
156
  - **A refusal by an external limiter removes the way, not the task.** It names no exit: the way is
158
157
  taken from the guard that already described this fix, and the task stays the same.
159
- - **An instruction to work by the progress covers all its steps, including those that change
160
- history.** Questions are asked about what the progress lacks.
161
158
  - **A question written by a past session does not become a question to the owner.** It is addressed
162
159
  to the handover's author, and some are closed by a work step.
163
160
  - **The owner's instruction holds until they cancel it, and a new fact against it is a line in the
@@ -176,8 +173,7 @@ flowchart TD
176
173
  - **The task folder is taken apart by the last commit before the PR opens, not after approval.** A
177
174
  person merges as soon as they see green, and no room is left for a closing commit.
178
175
  - **After opening the PR, the executor tells the owner the number, what it waits for and what comes
179
- next.** A draft waits for the run and is lifted after it; a PR opened ready waits for the owner's
180
- hand, and that is said in the same words.
176
+ next.** A draft waits for the run, a PR opened ready waits for the owner's hand, and that is said.
181
177
  - **A request to merge never comes before the work is checked.** Where the pipeline wakes for this
182
178
  base: folder taken apart and pushed → PR as a draft → run green → draft lifted → the request to
183
179
  merge, naming the number. Where it does not wake, the green push gate is the check, and opening
@@ -186,22 +182,25 @@ flowchart TD
186
182
  open PR reads as an invitation to merge. Which of the two applies is decided by the bases the pipeline wakes for, and that is read from its file.
187
183
  - **The plan guard is the lower bound of the requirement, not its limit.** It demands a folder only
188
184
  for an edit of application code; the article above — for any work.
189
- - **An instruction to work by a rule is an instruction to do its steps, including those that change
190
- history.** Marking a stage, a commit, a push and opening a PR are prescribed by the rule.
185
+ - **An instruction to work by a rule or by the progress is an instruction to do all its steps,
186
+ including those that change history.** Marking a stage, a commit, a push and opening a PR are
187
+ prescribed by the rule; questions are asked about what the progress lacks.
191
188
  - **A taken task does not end a turn.** Creating the task, the branch, the column and the folder is
192
- preparation: the work moves to the written-plan state, where the action is different. The
193
- turn-exit guard names the first stage in its refusal.
189
+ preparation; the turn-exit guard names the first stage in its refusal.
194
190
  - **The stages of a plan cover its done-sign whole.** Otherwise every stage closes, the run is
195
191
  green, and half the order is not done. Either the stages are written up to the sign, or the sign
196
192
  is narrowed to what the stages give.
193
+ - **Every rule of the product agreement becomes a step of some stage.** The plan names, per rule,
194
+ the stage that writes its code and the check that proves it, and is compared with the agreement
195
+ rule by rule before the first stage: a rule with no stage is found at the merge review, when the
196
+ code is written.
197
197
  - **A stage's readiness sign is taken from the output of a command run while the plan is written.**
198
198
  Written by a guess, it is checked at the stage itself — latest of everything that depended on it.
199
199
  - **A plan for work that ports a technique from outside is written by a measurement of one's own
200
200
  code.** Reading the sample says how it is built; what is needed here is said by a count over
201
201
  one's own files.
202
202
  - **A count that becomes the measure of the work is bounded by the declaration, not by the file.**
203
- A file holds neighbouring sets too: a count over it took a neighbour's suite and came out twice
204
- the real measure.
203
+ A file holds neighbouring sets too: a count over it came out twice the real measure.
205
204
  - **Waiting for one part of a stage is never a stop of the stage.** The parts independent of what is
206
205
  awaited are done in the same turn; the owner is told what is done and what is left for their step.
207
206
  - **A finding made mid-stage is checked against the plan's exit conditions before the first edit.**
@@ -141,6 +141,15 @@ not belong there: that is NestJS with constructor DI.
141
141
  console.log(n, JSON.stringify(s.rules[n].meta.defaultOptions));'
142
142
  ```
143
143
 
144
+ - **A decision is moved into a pure function of the util layer before the handler is written.** A
145
+ choice over a closed set becomes a table keyed by the enumeration, and a chain of field checks
146
+ becomes a list of checks. The handler calls them and keeps its branchings for its own flow: the
147
+ complexity linter refused one file twice because both lay right in the handler and spent its limit.
148
+ - **A file an edit pushed past the 500-line limit is split, not squeezed.** Joining comments or
149
+ dropping blank lines lowers the count and leaves the file just as long to read, and the next
150
+ edit hits the limit again. What the file does on its own moves out next to it: a mapping, a set of
151
+ derived values.
152
+
144
153
  - A cast through `as Type` in a mapper is forbidden but watched by nothing: it accepts any value
145
154
  and compiles. Instead — `this.typeCast`.
146
155
  - An unused parameter is removed, not renamed: an underscore before the name hides the finding,
@@ -1,14 +1,17 @@
1
1
  {
2
- "db": {
3
- "title": "хранилище: схема, миграции, записи предметной области"
4
- },
5
- "admin": {
6
- "title": "админка: экраны правки записей и роли доступа"
7
- },
8
- "app": {
9
- "title": "приложение: экраны, которыми пользуются люди"
10
- },
11
- "packages": {
12
- "title": "публикуемые пакеты: реестр, версии, журнал изменений"
13
- }
2
+ "db": {
3
+ "title": "хранилище: схема, миграции, записи предметной области"
4
+ },
5
+ "admin": {
6
+ "title": "админка: экраны правки записей и роли доступа"
7
+ },
8
+ "app": {
9
+ "title": "приложение: экраны, которыми пользуются люди"
10
+ },
11
+ "packages": {
12
+ "title": "публикуемые пакеты: реестр, версии, журнал изменений"
13
+ },
14
+ "mockups": {
15
+ "title": "макеты: рисунки экранов в дизайн-инструменте до кода"
16
+ }
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rt-tools/agent-kit",
3
- "version": "0.30.1",
3
+ "version": "0.32.0",
4
4
  "description": "Переносимый слой правил для агента: законы, хуки, проверки и агенты, раскладываемые в репозиторий одной командой",
5
5
  "author": "RT Team",
6
6
  "license": "Apache-2.0",