@rt-tools/agent-kit 0.29.3 → 0.30.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 (60) hide show
  1. package/assets/agents/rules-reviewer.md +2 -1
  2. package/assets/agents/skill-curator.md +3 -0
  3. package/assets/checks/board-epics.github.mjs +17 -2
  4. package/assets/checks/board-folders.mjs +40 -1
  5. package/assets/checks/board.github.mjs +4 -1
  6. package/assets/checks/check-board.github.mjs +2 -1
  7. package/assets/checks/check-prose-style.mjs +6 -2
  8. package/assets/checks/spec-anchors.mjs +5 -1
  9. package/assets/defaults/gate-map.sh +4 -1
  10. package/assets/defaults/shell.sh +6 -2
  11. package/assets/hooks/claim-guard.sh +42 -13
  12. package/assets/hooks/epic-stop-guard.sh +26 -1
  13. package/assets/hooks/git-guard-delivery-draft.sh +4 -1
  14. package/assets/hooks/git-guard-delivery-epic.sh +11 -1
  15. package/assets/hooks/git-guard-delivery-folder.sh +33 -15
  16. package/assets/hooks/git-guard-delivery-tree.sh +29 -0
  17. package/assets/hooks/git-guard-delivery.sh +6 -6
  18. package/assets/hooks/git-guard-push-tests.sh +10 -1
  19. package/assets/hooks/grill-gate-bypass.sh +61 -0
  20. package/assets/hooks/grill-gate.sh +143 -3
  21. package/assets/hooks/proposal-guard.sh +3 -0
  22. package/assets/hooks/task-flow-context.sh +2 -0
  23. package/assets/hooks/task-flow-guard.sh +27 -0
  24. package/assets/hooks/turn-exit-guard.sh +3 -3
  25. package/assets/hooks/turn-exit-verdict.sh +18 -1
  26. package/assets/patterns/git-workflow-commit.azure.md +4 -0
  27. package/assets/patterns/git-workflow-commit.github.md +15 -0
  28. package/assets/patterns/git-workflow-commit.gitlab.md +4 -0
  29. package/assets/patterns/git-workflow-pr-body.github.md +4 -0
  30. package/assets/patterns/queue-audit-read.github.md +47 -0
  31. package/assets/patterns/spec-driven-rule.md +8 -2
  32. package/assets/patterns/task-flow-close.md +11 -9
  33. package/assets/patterns/task-flow-start.md +21 -22
  34. package/assets/pitfalls/doc-style.md +8 -0
  35. package/assets/pitfalls/turn-conduct.md +14 -0
  36. package/assets/rules/component-structure.md +4 -0
  37. package/assets/rules/doc-style.md +26 -7
  38. package/assets/rules/git-workflow.azure.md +4 -0
  39. package/assets/rules/git-workflow.github.md +7 -24
  40. package/assets/rules/git-workflow.gitlab.md +4 -0
  41. package/assets/rules/queue-audit.github.md +77 -0
  42. package/assets/rules/spec-driven.md +5 -6
  43. package/assets/rules/status-report.md +6 -0
  44. package/assets/rules/task-flow.md +18 -21
  45. package/assets/rules/testing.md +4 -0
  46. package/assets/rules/turn-conduct.md +22 -20
  47. package/lib/commands.d.ts.map +1 -1
  48. package/lib/commands.js +12 -2
  49. package/lib/commands.js.map +1 -1
  50. package/lib/hooks-map.d.ts +14 -0
  51. package/lib/hooks-map.d.ts.map +1 -1
  52. package/lib/hooks-map.js +55 -8
  53. package/lib/hooks-map.js.map +1 -1
  54. package/lib/sync.d.ts +9 -0
  55. package/lib/sync.d.ts.map +1 -1
  56. package/lib/sync.js +6 -1
  57. package/lib/sync.js.map +1 -1
  58. package/package.json +1 -1
  59. package/rt-tools-agent-kit-0.30.0.tgz +0 -0
  60. package/rt-tools-agent-kit-0.29.3.tgz +0 -0
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # The fifth sign of the conversation guard: a question that offers to walk around a check does not
3
+ # leave. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The
4
+ # conversation guard sources it — it was moved out when the guard crossed the file length limit.
5
+ #
6
+ # A red set was explained by a "foreign" cause, and the owner was asked whether to send it past the
7
+ # check. Such a question is a miss by itself, even when the owner answers "yes": a check is fixed at
8
+ # its cause or fixed itself, and a third option is not named. The sign reads the text the owner
9
+ # reads — the menu with its options, or the last reply when it ends with a question — and looks for
10
+ # the forms of a bypass: past the check, a bypass line, a disabled rule, a hook switched off.
11
+ #
12
+ # It expects `$tool`, `$asked_text`, `$transcript` and `$rt_hooks_dir` to be set; it prints the
13
+ # refusal and returns zero when the question offers a bypass, and stays silent otherwise.
14
+ #
15
+ # FAIL-OPEN: no text of a question — the sign stays silent.
16
+
17
+ rt_grill_bypass() {
18
+ local bypass_re offered_text reason deny_tail_text
19
+ bypass_re='мимо (проверк|гейт|хук)|в обход (проверк|гейт|хук)|обойти (проверк|гейт|хук)|bypass|--no-verify|Epic-stop-skip|Docs-skip|Task-folder-skip|# discard:|eslint-disable|stylelint-disable|отключ[а-я]* (проверк|правил|линтер|хук)|в список известных|allowlist'
20
+ if [ -n "$tool" ]; then
21
+ offered_text="$asked_text"
22
+ else
23
+ offered_text="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
24
+ def is_input:
25
+ .type == "user"
26
+ and ((.isCompactSummary // false) | not)
27
+ and ((.isMeta // false) | not)
28
+ and (((.message.content // []) | if type == "array"
29
+ then ([.[] | select(.type == "tool_result")] | length)
30
+ else 0 end) == 0);
31
+ (map(is_input) | rindex(true)) as $i
32
+ | (if $i == null then . else .[$i + 1:] end)
33
+ | [.[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "text") | .text]
34
+ | last // ""
35
+ | if test("\\?[[:space:]]*$") then . else "" end
36
+ ' 2>/dev/null)"
37
+ fi
38
+ [ -n "$offered_text" ] || return 1
39
+ printf '%s' "$offered_text" | grep -qiE "$bypass_re" 2>/dev/null || return 1
40
+
41
+ reason="BLOCKED by grill-gate: the question offers the owner to walk around a check.
42
+
43
+ A question about a bypass is a miss by itself, even when the owner answers «yes». A red check is fixed at its cause — on the machine and in the tree — or the check itself is fixed when it is wrong. A third option is not named, and handing the owner a command to run by hand instead is the same bypass. Ask only the decision the fix needs."
44
+
45
+ # shellcheck disable=SC1090
46
+ [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
47
+ command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
48
+ deny_tail_text="$(rt_deny_tail "")"
49
+ [ -n "$deny_tail_text" ] && reason="${reason}
50
+
51
+ ${deny_tail_text}"
52
+
53
+ if [ -n "$tool" ]; then
54
+ jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
55
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: a question does not offer a bypass of a check."}}\n'
56
+ else
57
+ jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
58
+ || printf '{"decision":"block","reason":"grill-gate: a question does not offer a bypass of a check."}\n'
59
+ fi
60
+ return 0
61
+ }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # Requires: hooks/deny-tail.sh
2
+ # Requires: hooks/deny-tail.sh, hooks/turn-exit-patterns.sh, hooks/grill-gate-bypass.sh
3
3
  # rt-hook: Stop
4
4
  # The conversation guard: the owner is not asked a question until the laws and rules have been read
5
5
  # within the same turn. It judges two events, and that is not duplication; the second is declared
@@ -117,6 +117,17 @@ if command -v skill_for >/dev/null 2>&1 && [ -n "$rules_dir" ]; then
117
117
  | map(select(. != "")) | unique | .[]
118
118
  ' 2>/dev/null)"
119
119
  for path in $edited; do
120
+ # Only this tree's paths make up the area: a draft in the session scratch directory is not
121
+ # work of this tree, and the rule its kind maps to answers no question put to the owner. The
122
+ # rules gate stops at the same root check; a relative path is a path of the tree.
123
+ case "$path" in
124
+ /*)
125
+ case "$path" in
126
+ "${CLAUDE_PROJECT_DIR:-$PWD}"/*) ;;
127
+ *) continue ;;
128
+ esac
129
+ ;;
130
+ esac
120
131
  for rule in $(skill_for edit "$path" '' 2>/dev/null); do
121
132
  case "|$need_re|" in
122
133
  *"|$rule|"*) ;;
@@ -212,7 +223,9 @@ if [ -n "$tool" ]; then
212
223
  else (. // "") end) as $said
213
224
  | ([.[:$i][] | select(.type == "assistant") | (.message.content // [])[]
214
225
  | select(.type == "tool_use") | select(.name == "AskUserQuestion")] | length) as $before
215
- | if $before == 0 or ($said | length) == 0 then "no" else
226
+ # A reply of fewer than five significant words is a command, not a decision: «take task
227
+ # N» shares the number and the words of the subject with any next question about it.
228
+ | if $before == 0 or (($said | words) | length) < 5 then "no" else
216
229
  (($now | words) - (($now | words) - ($said | words))) as $common
217
230
  | if ($common | length) >= 3 then "answered" else "no" end
218
231
  end
@@ -293,6 +306,123 @@ ${deny_tail_text}"
293
306
  fi
294
307
  fi
295
308
 
309
+ # The fifth sign of the same guard: a question that offers to walk around a check does not leave.
310
+ #
311
+ # A red set was explained by a "foreign" cause, and the owner was asked whether to send it past the
312
+ # check. Such a question is a miss by itself, even when the owner answers "yes": a check is fixed at
313
+ # its cause or fixed itself, and a third option is not named. The sign reads the text the owner
314
+ # reads — the menu with its options, or the last reply when it ends with a question — and looks for
315
+ # the forms of a bypass: past the check, a bypass line, a disabled rule, a hook switched off.
316
+ #
317
+ # The sign lies in a file of its own next to the guard; without it the sign stays silent.
318
+ # shellcheck disable=SC1090
319
+ [ -f "$rt_hooks_dir/grill-gate-bypass.sh" ] && . "$rt_hooks_dir/grill-gate-bypass.sh" 2>/dev/null
320
+ command -v rt_grill_bypass >/dev/null 2>&1 && rt_grill_bypass && exit 0
321
+
322
+ # The fourth sign of the same guard: a question after a refusal carries what was done without the
323
+ # answer.
324
+ #
325
+ # A guard refused, the executor ran not one edit and brought the owner a choice "fix or wait". A
326
+ # question is a lawful exit of a turn, so no guard held it, and the owner asked why the work stopped.
327
+ # A refusal removes the step, not the task: the mechanical part of the blocker is done first. So a
328
+ # question after a refusal leaves only with the line the tree names, and with at least one working
329
+ # command after the last refusal — an edit of a file or a command by the work pattern of the exit
330
+ # guard. A read or a status command does not count: it looks like work and moves nothing.
331
+ #
332
+ # The menu and a question in prose are judged alike: one change of form would otherwise walk around
333
+ # the requirement. A turn without a refusal is not judged by this sign.
334
+ #
335
+ # The line is written in the language the tree speaks to its owner: the tree names it by
336
+ # `RT_DONE_WITHOUT_ANSWER` in its profile, and set empty it drops the sign.
337
+ #
338
+ # FAIL-OPEN: no turn record, no parser, no refusal in the turn — the sign stays silent.
339
+ done_marker="${RT_DONE_WITHOUT_ANSWER-Без ответа сделано:}"
340
+ work_re='git (add|commit|push|checkout|merge|rm)|npm run|pnpm (run|exec)|nx (build|test|run)|gh (pr|issue|api|run)|task:(new|move)|mkdir|cp |mv |rm |sed -i|tee '
341
+ # shellcheck disable=SC1090
342
+ [ -f "$rt_hooks_dir/turn-exit-patterns.sh" ] && . "$rt_hooks_dir/turn-exit-patterns.sh" 2>/dev/null
343
+ if [ -n "$done_marker" ]; then
344
+ after_refusal="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re" '
345
+ def is_input:
346
+ .type == "user"
347
+ and ((.isCompactSummary // false) | not)
348
+ and ((.isMeta // false) | not)
349
+ and (((.message.content // []) | if type == "array"
350
+ then ([.[] | select(.type == "tool_result")] | length)
351
+ else 0 end) == 0);
352
+ def refusal:
353
+ .type == "user" and ((.message.content // []) | if type == "array"
354
+ then any(.[]; .type == "tool_result" and (.is_error // false)
355
+ and ((.content | if type == "string" then . elif type == "array"
356
+ then (map(if type == "object" then (.text // "") else "" end) | join(" "))
357
+ else "" end) | test("BLOCKED|Refused|denied")))
358
+ else false end);
359
+ def working:
360
+ .type == "assistant" and ((.message.content // []) | any(.[];
361
+ .type == "tool_use" and (
362
+ ((.name // "") | test("^(Edit|Write|NotebookEdit)$"))
363
+ or ((.name == "Bash") and ((.input.command // "") | test($work))))));
364
+
365
+ (map(is_input) | rindex(true)) as $i
366
+ | (if $i == null then . else .[$i + 1:] end) as $turn
367
+ | ($turn | map(refusal) | rindex(true)) as $r
368
+ | if $r == null then "none"
369
+ elif ($turn[$r + 1:] | map(working) | any) then "worked"
370
+ else "idle" end
371
+ ' 2>/dev/null)"
372
+
373
+ if [ "$after_refusal" = "worked" ] || [ "$after_refusal" = "idle" ]; then
374
+ if [ -n "$tool" ]; then
375
+ question_text="$asked_text"
376
+ else
377
+ question_text="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
378
+ def is_input:
379
+ .type == "user"
380
+ and ((.isCompactSummary // false) | not)
381
+ and ((.isMeta // false) | not)
382
+ and (((.message.content // []) | if type == "array"
383
+ then ([.[] | select(.type == "tool_result")] | length)
384
+ else 0 end) == 0);
385
+ (map(is_input) | rindex(true)) as $i
386
+ | (if $i == null then . else .[$i + 1:] end)
387
+ | [.[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "text") | .text]
388
+ | join("\n")
389
+ ' 2>/dev/null)"
390
+ fi
391
+ asks="no"
392
+ if [ -n "$tool" ]; then
393
+ asks="yes"
394
+ elif printf '%s\n' "$question_text" | grep -qE '\?[[:space:]]*$'; then
395
+ asks="yes"
396
+ fi
397
+ marked="no"
398
+ case "$question_text" in
399
+ *"$done_marker"*) marked="yes" ;;
400
+ esac
401
+ if [ "$asks" = "yes" ] && { [ "$marked" = "no" ] || [ "$after_refusal" = "idle" ]; }; then
402
+ reason="BLOCKED by grill-gate: a guard refused in this turn, and the question to the owner carries nothing done without the answer.
403
+
404
+ A refusal removes the step, not the task. Do the mechanical part of the blocker first — what the linter's fix mode repairs, what the refusal names as fixable — then ask only the decision that is left. The question leaves with the line «$done_marker …» naming the working commands of this turn after the last refusal: an edit of a file or a command that changes the tree. A read or a status command does not count."
405
+
406
+ # shellcheck disable=SC1090
407
+ [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
408
+ command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
409
+ deny_tail_text="$(rt_deny_tail "")"
410
+ [ -n "$deny_tail_text" ] && reason="${reason}
411
+
412
+ ${deny_tail_text}"
413
+
414
+ if [ -n "$tool" ]; then
415
+ jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
416
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: a question after a refusal carries what was done without the answer."}}\n'
417
+ else
418
+ jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
419
+ || printf '{"decision":"block","reason":"grill-gate: a question after a refusal carries what was done without the answer."}\n'
420
+ fi
421
+ exit 0
422
+ fi
423
+ fi
424
+ fi
425
+
296
426
  [ "$verdict" = "ask" ] || exit 0
297
427
 
298
428
  if [ -n "$tool" ]; then
@@ -301,11 +431,21 @@ else
301
431
  head="BLOCKED by grill-gate: the reply carries a question to the owner, and the laws and rules were not read in this turn."
302
432
  fi
303
433
 
304
- reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. Run a search by the words of the subject and answer from what is found; ask only what the documents do not cover:
434
+ # The refusal names the action its own condition accepts. When the turn holds edits, only the rules
435
+ # of their area count, and the advice to search the directories sent the executor round in a
436
+ # circle: the search was made, the same refusal came back, and the executor stopped asking at all.
437
+ if [ -n "$need_re" ]; then
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.
440
+
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
+ else
443
+ reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. Run a search by the words of the subject and answer from what is found; ask only what the documents do not cover:
305
444
 
306
445
  grep -rn -i \"<a word of the subject>\" $laws_dir $rules_dir $specs_dir $plans_dir $archive_dir
307
446
 
308
447
  The guard judges one turn: the next session is not refused."
448
+ fi
309
449
 
310
450
  # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
311
451
  # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
@@ -79,9 +79,12 @@ context_re='пропозал|слою правил|слоя правил|сло
79
79
  #
80
80
  # A 400-line tail: the transcript grows all session long, and only the last turn is judged.
81
81
  verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg asked "$asked_re" --arg ctx "$context_re" '
82
+ # A report of a role and a loaded rule come in under the same role, marked `isMeta`: a role
83
+ # that called its findings «proposal» woke the guard as if the owner had asked for a sending.
82
84
  def is_input:
83
85
  .type == "user"
84
86
  and ((.isCompactSummary // false) | not)
87
+ and ((.isMeta // false) | not)
85
88
  and (((.message.content // []) | if type == "array"
86
89
  then ([.[] | select(.type == "tool_result")] | length)
87
90
  else 0 end) == 0);
@@ -24,6 +24,7 @@
24
24
  # branch with history; otherwise a non-zero code, and the guard exits silently.
25
25
  #
26
26
  # RT_TF_PATH — the application-code path because of which the guard judges at all
27
+ # RT_TF_CANDIDATES — every path the call writes, one per line, as named in the call
27
28
  # RT_TF_BRANCH — the current branch of the edit's working directory
28
29
  # RT_TF_ROOT — the root of the working tree
29
30
  # RT_TF_TASKS_DIR — the task folders directory, as the tree names it
@@ -174,6 +175,7 @@ rt_task_flow_context() {
174
175
  $rt_tf_candidates
175
176
  EOF
176
177
  [ -z "$RT_TF_PATH" ] && return 1
178
+ RT_TF_CANDIDATES="$rt_tf_candidates"
177
179
 
178
180
  # The branch is looked at where the edit will go: a worktree has one of its own.
179
181
  rt_tf_workdir="$(rt_hook_cwd)"
@@ -52,6 +52,33 @@ plan="$RT_TF_PLAN"
52
52
 
53
53
  deny() { rt_task_flow_deny "$@"; }
54
54
 
55
+ # Resolving a merge conflict is the merge itself, not an edit of the product. Main is merged into
56
+ # the epic branch while the work runs, and that branch carries no task folder by the rule — it holds
57
+ # merges, not edits of its own. Refused here, the conflict has no lawful way out: a folder made up
58
+ # for the epic branch would be the very edit the rule forbids in it. So a call passes while a merge
59
+ # stands and every code path it writes is still unmerged. A file already resolved and added, and
60
+ # any other code file of the same merge, is judged as before: the exception is the conflict, not
61
+ # the branch.
62
+ merge_conflict_only() {
63
+ git -C "$root" rev-parse -q --verify MERGE_HEAD >/dev/null 2>&1 || return 1
64
+ seen=0
65
+ while IFS= read -r candidate; do
66
+ [ -z "$candidate" ] && continue
67
+ case "$candidate" in
68
+ /*) ;;
69
+ *) candidate="${CLAUDE_PROJECT_DIR:-.}/$candidate" ;;
70
+ esac
71
+ rt_is_app_code "$candidate" || rt_tf_laid_out "$candidate" || continue
72
+ [ -n "$(git -C "$root" ls-files -u -- "$candidate" 2>/dev/null | head -1)" ] || return 1
73
+ seen=1
74
+ done <<EOF
75
+ ${RT_TF_CANDIDATES:-$RT_TF_PATH}
76
+ EOF
77
+ [ "$seen" = 1 ]
78
+ }
79
+
80
+ merge_conflict_only && exit 0
81
+
55
82
  if rt_needs rt_task_branch_ok task-flow-guard && ! rt_task_branch_ok "$branch"; then
56
83
  deny "BLOCKED by task-flow: an edit of code goes in a branch for a task, and the current branch is '${branch}'. Create a task (npm run task:new -- --title '…' --slug <slug>) and a branch under its number, then repeat. The rule is task-flow."
57
84
  fi
@@ -53,7 +53,7 @@ rt_hook_read
53
53
  rt_te_deny() {
54
54
  # The end of an epic releases the turn whatever tier came here: the epic is read only on this road.
55
55
  command -v rt_te_epic_over >/dev/null 2>&1 && rt_te_epic_over && exit 0
56
- rt_te_reason="$1"
56
+ rt_te_reason="$(printf '%s\n\n%s' "$1" 'The owner said to stop — quote their word in the progress: `- **Waiting for the owner:** «<their words>»`. Where the task folder is gone, quote it in « » in the reply: the guard checks the quote against their message.')"
57
57
  rt_te_short="$2"
58
58
  # shellcheck disable=SC1090
59
59
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
@@ -443,12 +443,12 @@ fi
443
443
  # sign is read without the network and stays silent where there is no reference at all — such
444
444
  # branches are created for a trial too.
445
445
  # Incident analysis — the record "2026-08-25-fifteen-branches-over-one-index" in the intake.
446
- if [ "$worked" = "true" ] && [ "$handed_over" != "true" ]; then
446
+ if [ "$worked" = "true" ] && [ "$handed_over" != "true" ] && [ "${unpushed_named:-false}" != "true" ]; then
447
447
  unpushed="$(git -C "$root" rev-list --count '@{u}..HEAD' 2>/dev/null)"
448
448
  if [ -n "$unpushed" ] && [ "$unpushed" -gt 0 ] 2>/dev/null; then
449
449
  reason="BLOCKED by turn-exit-guard: there was work in the turn, but it stayed in the working tree — commits not handed over: ${unpushed}.
450
450
 
451
- The owner sees the former state and reads it as «nothing was done». Two moves from here: bring the work to the hosting — push the branch and open a request — or remove what was done if it is not needed. What is left in the tree is named with a reason — in the words of the owner, not as a list of leftovers.
451
+ The owner sees the former state and reads it as «nothing was done». Two moves from here: bring the work to the hosting — push the branch and open a request — or remove what was done if it is not needed. What is left in the tree is named with a reason — in the words of the owner, not as a list of leftovers: the line «Не отправлено: <reason>» in the reply releases this tier.
452
452
 
453
453
  The guard judges one turn: the next session is not refused."
454
454
 
@@ -87,6 +87,23 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re
87
87
  | ([$turn[] | select(.type == "assistant") | (.message.content // [])[]
88
88
  | select(.type == "text") | (.text // "")] | last // "") as $last_say
89
89
  | (($last_say | test("\\?[[:space:]]*$")) and $ask_denied) as $asked_in_prose
90
+ # The word of the owner about a stop said a turn earlier holds until a later message of theirs
91
+ # orders work. It is read from the whole session: read from this turn alone, it was lost, and
92
+ # the turn could leave only by a line in the progress of a folder already taken apart. Such a
93
+ # word releases the turn when the reply quotes it in « » and the quote stands in that message.
94
+ | ([.[] | select(is_input) | .message.content
95
+ | if type == "string" then . elif type == "array"
96
+ then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end]) as $owner_said
97
+ | ($owner_said | map(test("останов|стоп|хватит|подожди|не надо|прерв|отложи|не двигайся|не продолжай|прекрати") and (test($standing) | not)) | rindex(true)) as $stop_at
98
+ | (if $stop_at == null then null
99
+ elif ($owner_said[$stop_at + 1:] | map(test("продолжай|работай|делай|бери|давай|вперёд|можно")) | any) then null
100
+ else $owner_said[$stop_at] end) as $stop_word
101
+ | ([$last_say | match("«([^»]+)»"; "g") | .captures[0].string]) as $quotes
102
+ | ($stop_word != null and ($quotes | map(. as $q | $stop_word | contains($q)) | any)) as $quoted_stop
103
+ | ($told_stop or $quoted_stop) as $told_stop
104
+ # What is left in the tree is named with a reason, and the line «Не отправлено: <reason>» in
105
+ # the reply is that naming: without it the only lawful move was a push made to lift the refusal.
106
+ | ($last_say | test("Не отправлено:[[:space:]]*[^[:space:]]")) as $unpushed_named
90
107
  # Waiting for the word of the owner, announced by the executor. That word is read from
91
108
  # the owner: without his word in the turn and without a question to him through the tool, the
92
109
  # phrase "waiting for your word" is a stop announced by the one it suits. The set of patterns is
@@ -110,6 +127,6 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re
110
127
  or (((.name // "") == "Bash") and ([(.input.command // "") | splits($part)] | map(test($work) and (test($read) | not) and (test("^[[:space:]]*([^[:space:]]*/)?git[[:space:]]+(add|commit|push)") | not)) | any))
111
128
  ) | any) as $after_progress
112
129
  | (($last_name == "Bash") and ($last | test($started)) and ($handed_over | not)) as $only_took
113
- | { promised: $promised, only_took: $only_took, asked: $asked, handed_by_hand: ($handed and (($asked or $denied or $told_stop) | not)), standing_work: $standing_work, worked: ($edited or $ran_work), released: ($asked or $denied or $handed or $told_stop), waited: $waited, handed_over: $handed_over, started_next: $started_next, ended_working: $ended_working, asked_in_prose: $asked_in_prose, awaits_word: $awaits_word, progress_edited: $progress_edited, after_progress: $after_progress, launched_last: $launched_last, ran: $ran }
130
+ | { promised: $promised, only_took: $only_took, asked: $asked, handed_by_hand: ($handed and (($asked or $denied or $told_stop) | not)), standing_work: $standing_work, worked: ($edited or $ran_work), released: ($asked or $denied or $handed or $told_stop), waited: $waited, handed_over: $handed_over, started_next: $started_next, ended_working: $ended_working, asked_in_prose: $asked_in_prose, awaits_word: $awaits_word, progress_edited: $progress_edited, after_progress: $after_progress, launched_last: $launched_last, ran: $ran, unpushed_named: $unpushed_named }
114
131
  ' 2>/dev/null)"
115
132
  }
@@ -177,4 +177,8 @@ Docs-skip: правка только в тестах хука, зеркала у
177
177
  off whole at the first miss. The next `git commit --amend` then carries into the commit
178
178
  everything left in the index. The commit contents are read by `git show --stat` right after it,
179
179
  not at PR review.
180
+ - Two commits chained in one call: a commit refused by the message check leaves its files in the
181
+ index, and the next `git commit` takes them under its own subject. One commit is one call, and
182
+ its outcome is read before the next; a swallowed one is split by `git reset --soft HEAD~1` and two
183
+ commits anew.
180
184
  - The owner's edit takes neither the token nor the variables — they are only for machine work.
@@ -74,6 +74,12 @@ body itself and prints the branch line from the branch of the epic; work outside
74
74
  card is created. The epic itself is created by the same command with `--epic`. Author and assignee — the machine account; the command reads the token itself, from
75
75
  a file outside the repository.
76
76
 
77
+ A task created under an epic that has closed since is taken outside the epic, not by reviving
78
+ the epic branch. The delivery guard reads the epic from the line in the task body, and for a closed
79
+ epic it demands a branch in the remote that nobody will send again. The line about the epic is
80
+ replaced in the body by `Работа вне эпика — <слово владельца>`, the shape `--outside-epic` writes,
81
+ and only then is the branch created.
82
+
77
83
  The script under this command is created by the project — the package does not ship it. What it
78
84
  does by `gh` calls:
79
85
 
@@ -269,4 +275,13 @@ Docs-skip: правка только в тестах хука, зеркала у
269
275
  - `gh api graphql --paginate` on a query of board items goes into repeating the first page: the
270
276
  cursor is taken from the answer by hand, and completeness is checked against
271
277
  `items(first: 1) { totalCount }`.
278
+ - Two commits chained in one call: a commit refused by the message check leaves its files in the
279
+ index, and the next `git commit` takes them under its own subject. One commit is one call, and
280
+ its outcome is read before the next; a swallowed one is split by `git reset --soft HEAD~1` and two
281
+ commits anew.
282
+ - The push set listed by hand without the package defaults: the tree profile extends the package
283
+ one through the default function, and sourced alone it calls an undefined function. The error
284
+ goes to a stream nobody reads, and the list loses lint, unit tests, the build and the spec audit
285
+ with a zero exit. The defaults are sourced first, and the line count is compared with the last
286
+ push before the run.
272
287
  - The owner's edit takes neither the token nor the variables — they are only for machine work.
@@ -183,4 +183,8 @@ Docs-skip: правка только в тестах хука, зеркала у
183
183
  off whole at the first miss. The next `git commit --amend` then carries into the commit
184
184
  everything left in the index. The commit contents are read by `git show --stat` right after it,
185
185
  not at MR review.
186
+ - Two commits chained in one call: a commit refused by the message check leaves its files in the
187
+ index, and the next `git commit` takes them under its own subject. One commit is one call, and
188
+ its outcome is read before the next; a swallowed one is split by `git reset --soft HEAD~1` and two
189
+ commits anew.
186
190
  - The owner's edit takes neither the token nor the variables — they are only for machine work.
@@ -159,3 +159,7 @@ the title. The sample is held by whoever writes the body — like the words said
159
159
  - A `Closes` line in a PR whose base is not the main branch, in a tree without a closing pipeline:
160
160
  the task looks attached and stays open after the merge. The body names the task in words, and
161
161
  the cleanup step closes it by hand.
162
+ - Labels read with `join(",")` and split by a shell expansion: zsh does not split an unquoted
163
+ `${L//,/ }` into words, the REST call gets the whole line as one label, and the host creates a
164
+ label with that name. Each label goes as its own `-f 'labels[]=…'`, or is read one per line with
165
+ `--jq '.labels[].name'`.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: queue-audit-read
3
+ kind: pattern
4
+ rule: queue-audit
5
+ description: Pattern of rule queue-audit. Load when the work queue audit has printed lines — running it, and the move that answers each kind of line.
6
+ ---
7
+
8
+ # Reading the work queue audit
9
+
10
+ Pattern of the rule `queue-audit`. What must be true — the law `docs/constitution/delivery.md`.
11
+
12
+ ## When to use
13
+
14
+ - The audit printed lines before a push, on taking a task or after a known merge.
15
+ - A line names a PR or a task, and the move for it is not obvious from the line.
16
+
17
+ ## Running it
18
+
19
+ ```bash
20
+ npm run check:board
21
+ ```
22
+
23
+ Exit code 0 and no lines — the queue matches. Exit code 1 — every line is a discrepancy, and each
24
+ names its own move. The summary lines at the end are not discrepancies: they count what was read
25
+ and what was filtered out.
26
+
27
+ ## What answers which line
28
+
29
+ | The line says | The move |
30
+ | ---------------------------------------------------- | ------------------------------------------------------------- |
31
+ | a PR is open and its task is not in review | `npm run task:move -- <номер> in-review` |
32
+ | a task is in review and has no open PR | open the PR, or move the task back to work |
33
+ | the branch lags behind its base by N commits | merge the base into the branch and push |
34
+ | the PR conflicts with the main branch | merge the main branch in, resolve, push |
35
+ | no run on the tip | a new commit, or close and reopen the PR as the line says |
36
+ | a run pushed out of the queue | read that run's output, then rerun it — both commands are in the line |
37
+ | a draft with a green run | `gh pr ready <номер>` |
38
+ | the PR has no reviewer | request the reviewer by a REST call |
39
+ | the last run of the main branch is red | fix the main branch before new work |
40
+ | a task and its epic name each other one way only | link the task as a sub-issue, or name it in the epic plan |
41
+
42
+ ## Common misses
43
+
44
+ - **A rerun instead of the move.** The second run prints the same line: a line is answered by its
45
+ move.
46
+ - **A summary line read as a discrepancy.** The count of PRs with a base other than the main branch
47
+ is not a discrepancy: it names what the host does not do for them.
@@ -122,8 +122,10 @@ description: Pattern of rule git-workflow. Load for … Not for … — that is
122
122
  ```
123
123
 
124
124
  Sections: `## When to use` · ready-made code · `## Common misses`. A pattern has no binding:
125
- the check does not audit it, because there is nothing to check ready-made code against but
126
- itself.
125
+ there is nothing to check ready-made code against but itself. Its set of sections is checked all
126
+ the same — the suite of the package that ships the texts refuses a pattern without `## When to
127
+ use` and without the section of misses. A consumer tree does not see that refusal; the tree with
128
+ the package sources sees it in the set before a push.
127
129
 
128
130
  ## How the article itself is written
129
131
 
@@ -246,6 +248,10 @@ reference — it changes how a story is written.
246
248
  unbound, and the spec audit is silent about it, because it looks for the line in the table.
247
249
  The line's place is the same as its statement's in the rule: the order of both sides is kept
248
250
  the same, otherwise the statement and its binding stop being found by one another.
251
+ - A binding line came out as one sentence of sixty words. The statement ends at its full stop
252
+ inside the bold, and everything after it — the dash, the anchor, the dash and the explanation —
253
+ is one more sentence to the wording check. The explanation after the anchor is written in
254
+ sentences of its own: the line stays one, the long sentence goes.
249
255
  - The `description` does not say when **not** to load the pattern — the neighbouring pattern of
250
256
  the same rule becomes indistinguishable.
251
257
  - A block of ready-made code was accepted by its look, not by checking against the declaration.
@@ -117,7 +117,9 @@ the progress and into the PR body. The law file is edited after the answer. The
117
117
  application laws: payments, locales and access are the same agreement, only about this application.
118
118
 
119
119
  What was done at this step is written into the PR body: what was re-read, what was changed, and if
120
- nothing was changed — why. The form of the section — pattern `git-workflow-pr-body`.
120
+ nothing was changed — why. The form of the section — pattern `git-workflow-pr-body`. The body fits
121
+ the host's length limit — Azure DevOps takes 4000 characters — so the report is one line per text,
122
+ not prose: a body over the limit refuses the opening call, and it gets cut in a hurry.
121
123
 
122
124
  **Next move:** the updated texts are committed, and in the same turn the task folder is taken apart
123
125
  — by the last commit of the branch, pattern `task-flow-archive`.
@@ -175,19 +177,19 @@ second form: nothing is left to wait for, and the check standing behind it is th
175
177
  ```
176
178
 
177
179
  The section heading and the words of both samples are written in the language of the PR, not the
178
- language of the pattern. The samples are set in the language of this tree's PRs and are carried over
179
- whole — the order of thoughts, the wording and the heading, the heading last. It looks like part of
180
- the form, not part of the text. The same holds for the messages to the owner below: they are
181
- samples of **what** is said, not of which words.
180
+ language of the pattern. The heading is named by the tree in its profile, `RT_PULL_BODY_SECTION`,
181
+ and is taken from there, not from the samples above. What is carried over whole is the order of
182
+ thoughts, not the words. The same holds for the messages to the owner below: they are samples of
183
+ **what** is said, not of which words.
182
184
 
183
185
  The section is neither left empty nor removed altogether: a missing section and "no steps left" read
184
186
  the same and mean different things. The full sample of a PR body — in the pattern for creating a
185
187
  commit and a PR, if the tree laid it out.
186
188
 
187
- The delivery guard holds this, not the writer's memory: it reads the body straight from the opening
188
- command — passed as an argument or as a file — and refuses the call together with everything else
189
- that does not match. The heading sample is named by the tree, because the heading is written in the
190
- PR's language, and the package knows no foreign words; unnamed, the section is not judged at all.
189
+ Where the tree laid out the delivery guard, it reads the body straight from the opening command —
190
+ passed as an argument or as a file — and refuses the call together with everything else that does
191
+ not match. It judges the section by the heading the profile names; unnamed, the section is not
192
+ judged at all. Without the guard the section is held only by whoever writes the body.
191
193
  The work queue audit still does not read the body: the miss is caught at the minute of opening, that
192
194
  is, where one call still fixes it.
193
195
 
@@ -39,25 +39,22 @@ lives only in that session's record: a search over them by the theme's word cost
39
39
  is found is written into the tree in the same turn — into the epic plan if it links tasks, into the
40
40
  progress if it concerns one.
41
41
 
42
- Exploration that found nothing is no permission to ask: the places not yet searched — the epic plan,
43
- the archive, the records of past sessions — are reached first. "Not found in such a place" speaks of
44
- the place, not of the tree, and the question names where the search went.
45
-
46
- Exploration ends with command output, not with a feeling. Before the first question the executor
47
- knows how the repository is arranged (the root memo), what lies in the directory at hand (`ls`), and
48
- whether something is written on the theme (a search over the documentation and the rules).
49
-
50
- Exploration over a created task ends with a reproduced symptom, not a found file. The task body
51
- describes the tree on the day of creation, and exploration by the names from the body confirms only
52
- that the files are in place: a task that has lapsed cannot be told from a live one. Before the first
53
- edit the exploration repeats what the task complains about — calls the procedure, reads the reply,
54
- runs the check that stayed silent. The symptom did not reproduce — the task is closed as lapsed, and
55
- that is a lawful outcome.
56
-
57
- A tree named as a sample is read as a layout whole — by walking the directories two levels deep —
58
- and only then come the questions about techniques. The answer to "how is this done here" gives one
59
- folder, and generalised into a map of the tree it lies: the neighbouring family of directories is
60
- left out, and the owner finds the loss.
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
46
+ hand, a search over the documentation and the rules.
47
+
48
+ A member added beside a list, not into it, is named at every reader of that list: each place that
49
+ walks the list knows only its members. The readers are found by a search of the list's symbol and go
50
+ into the agreement as places to touch; one the search did not return is found after the code.
51
+
52
+ Exploration over a created task ends with a reproduced symptom, not a found file: the body describes
53
+ the tree on the day of creation. Before the first edit the exploration repeats what the task
54
+ complains about; a symptom that did not reproduce closes the task as lapsed, and that is lawful.
55
+
56
+ A tree named as a sample is read as a layout whole — walking the directories two levels deep —
57
+ before questions about techniques: one folder generalised into a map leaves out its neighbours.
61
58
 
62
59
  What was inferred is marked right in the list, together with what confirms it.
63
60
 
@@ -65,9 +62,8 @@ What was inferred is marked right in the list, together with what confirms it.
65
62
  in the trees recorded as samples of its layout. The one found is read whole: it closes the questions
66
63
  about the structure — the source of the numbers, the rows, the screen, the storage.
67
64
 
68
- The six questions are asked minus those the exploration answered: instead of a question with a ready
69
- answer, the grill gets the line "taking such-and-such answer, here is where from". The sign is one —
70
- whether the answer is in the tree; "the task seems clear" is no sign in either direction.
65
+ The six questions are asked minus those the exploration answered; the grill gets the line "taking
66
+ such-and-such answer, here is where from". The sign is whether the answer is in the tree.
71
67
 
72
68
  **Next move:** the findings land in the grill, and in the same turn the first of the six questions
73
69
  goes to the owner. The exploration ended — the state stayed the same, so did the turn.
@@ -285,6 +281,9 @@ Work that does not touch `apps/**` and `libs/**` needs no agreement:
285
281
 
286
282
  An empty reason is not accepted.
287
283
 
284
+ The Specs line of the footprint is filled by the command that names the spec of a resource, run on
285
+ the files of the Code line, not from memory.
286
+
288
287
  **Next move:** under the header the task footprint and the stages are written, the plan is
289
288
  committed, and in the same turn the first stage begins.
290
289
 
@@ -92,6 +92,14 @@ The rule is `doc-style`; the articles that hold the law stand there.
92
92
  shows it, usually later, by the headings of the assembled text. Text is edited with the edit
93
93
  tool; and if a replacement is called anyway, the place it promised to change is reread right
94
94
  after.
95
+ - **A one-liner in the shell is one sentence to the wording check.** The check takes the command
96
+ body whole: the pattern, the replacement and the path stand on one line with no full stop
97
+ between them. Three one-line replacements in a document were refused as sentences of 44, 46
98
+ and 88 words, while the text they wrote was short.
99
+ - **A stream-editor rollback without a line number reaches lines nobody meant.** A test made red
100
+ on purpose was rolled back by a replacement by pattern, the pattern matched neighbouring checks
101
+ too, and they were committed without a run. A rollback goes by the edit tool or by the line
102
+ number, then `git diff` shows what it touched, and any edit of a test is followed by a new run.
95
103
  - **A number obtained from a command is not yet a measurement.** The requirement to recompute a
96
104
  number by a command is met literally — there was a command — and nobody asks whether it
97
105
  measured the number's subject. Output is false in different ways and silently: `grep -E` with