@rt-tools/agent-kit 0.38.0 → 0.39.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.
- package/assets/checks/check-turn-map.mjs +4 -4
- package/assets/checks/decision-table.json +91 -24
- package/assets/checks/flow-data.mjs +22 -23
- package/assets/checks/flow-forecast.mjs +12 -8
- package/assets/checks/flow-guard.mjs +365 -163
- package/assets/checks/flow-step.mjs +188 -58
- package/assets/checks/flow-verdict.mjs +124 -9
- package/assets/checks/record-count.mjs +27 -0
- package/assets/checks/task-flow-script.mjs +33 -7
- package/assets/checks/work-result.mjs +92 -11
- package/assets/commands/night.md +3 -3
- package/assets/defaults/turn-map.md +4 -2
- package/assets/docs/GLOSSARY.md +1 -1
- package/assets/hooks/ask-judge.md +4 -2
- package/assets/hooks/facts.sh +66 -0
- package/assets/hooks/git-guard-delivery-epic.sh +2 -2
- package/assets/hooks/git-guard-delivery-rerun.sh +17 -5
- package/assets/hooks/git-guard-push-ahead.sh +24 -2
- package/assets/hooks/git-guard-push-marks.sh +209 -12
- package/assets/hooks/git-guard-push-tests.sh +29 -2
- package/assets/hooks/pre-push.sh +26 -2
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +31 -8
- package/assets/hooks/turn-exit-guard.sh +1 -1
- package/assets/hooks/turn-judge.md +16 -6
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/task-flow-archive.md +2 -1
- package/assets/pitfalls/task-flow-close.2.md +2 -1
- package/assets/pitfalls/task-flow-owner.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +2 -2
- package/assets/pitfalls/task-flow-start.md +1 -1
- package/assets/pitfalls/turn-conduct.md +1 -1
- package/assets/rules/autonomous-work.md +1 -1
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/task-flow-owner.md +6 -6
- package/assets/rules/turn-conduct.md +22 -19
- package/assets/task-flow/flow.js +10 -14
- package/assets/task-flow/flow.md +7 -8
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/owner.mjs +13 -6
- package/assets/task-flow/measure/session.mjs +92 -15
- package/assets/task-flow/source/git.mjs +179 -11
- package/assets/task-flow/source/host.mjs +105 -0
- package/assets/task-flow/source/owner.mjs +33 -13
- package/assets/task-flow/source/session.mjs +47 -10
- package/lib/agent-checks.d.ts.map +1 -1
- package/lib/agent-checks.js +14 -2
- package/lib/agent-checks.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,35 @@
|
|
|
8
8
|
# FAIL-OPEN: no network, no remote, no git — the base falls back to the main branch or to nothing,
|
|
9
9
|
# and a mark that cannot be read counts as absent. Either way the set runs, never less of it.
|
|
10
10
|
|
|
11
|
+
# Whether a remote branch stands on this one by the own copy `$2`. It does when the copy lies on
|
|
12
|
+
# its first-parent line — it was taken from this one and went on by plain commits — or when no
|
|
13
|
+
# merge of the host brought the copy in: a neighbour took this one in itself. A copy a merge of the
|
|
14
|
+
# host brought in leaves it a base, the merge reached by the first parent or through a merge of a
|
|
15
|
+
# session: that is the branch of an epic a request carried the copy into.
|
|
16
|
+
# A branch under the head or at it is no branch standing on this one: what the head holds already
|
|
17
|
+
# passed the set; nor is one at the commit of the copy: a branch pushed before its first commit
|
|
18
|
+
# still lies at the tip it was taken from. The lists are held in variables and matched by `case`,
|
|
19
|
+
# so a caller with `pipefail` gets the same answer.
|
|
20
|
+
rt_push_base_on_copy() {
|
|
21
|
+
local ref="$1" own host="$3" line merge parent
|
|
22
|
+
own="$(git rev-parse --verify --quiet "$2")" || return 1
|
|
23
|
+
[ "$own" != "$(git rev-parse --verify --quiet "$ref")" ] || return 1
|
|
24
|
+
git merge-base --is-ancestor "$ref" HEAD 2>/dev/null && return 1
|
|
25
|
+
git merge-base --is-ancestor "$own" "$ref" 2>/dev/null || return 1
|
|
26
|
+
line="$(git rev-list --first-parent "$ref" --not "$own^@" 2>/dev/null)"
|
|
27
|
+
case "$line" in *"$own"*) return 0 ;; esac
|
|
28
|
+
# A merge of the host anywhere in the branch whose second side brought the copy keeps it a
|
|
29
|
+
# base: a session that synced its epic with the remote one merged the host's merge in as is.
|
|
30
|
+
for merge in $(git rev-list --merges --fixed-strings --committer="$host" "$ref" --not "$own" 2>/dev/null); do
|
|
31
|
+
git merge-base --is-ancestor "$own" "$merge^1" 2>/dev/null && continue
|
|
32
|
+
line="$(git rev-parse "$merge^@" 2>/dev/null)"
|
|
33
|
+
for parent in ${line#*$'\n'}; do
|
|
34
|
+
git merge-base --is-ancestor "$own" "$parent" 2>/dev/null && return 1
|
|
35
|
+
done
|
|
36
|
+
done
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
11
40
|
# The base the contribution is counted against. Prints `origin/<branch>` or nothing.
|
|
12
41
|
#
|
|
13
42
|
# The base is the remote branch the head has the fewest commits over: what the head carries past
|
|
@@ -26,7 +55,8 @@
|
|
|
26
55
|
#
|
|
27
56
|
# Three kinds of branches are no base, because they are this branch's own content:
|
|
28
57
|
# - its own remote copy — the set answers for the whole contribution, not for the last commit;
|
|
29
|
-
# - a branch that stands on that copy — it
|
|
58
|
+
# - a branch that stands on that copy — it holds the copy on its first-parent line or took it in
|
|
59
|
+
# with no merge of the host bringing it, and lies neither under the head nor at it;
|
|
30
60
|
# - a branch the host merged into this one by a request. Without that the branch of an epic was
|
|
31
61
|
# counted against its last merged task, and nothing checked the epic against the main branch
|
|
32
62
|
# before the push. The host's merge is told by the committer of the commit: the host signs
|
|
@@ -34,13 +64,25 @@
|
|
|
34
64
|
# A tree whose host signs otherwise names the signature in `RT_PUSH_HOST_COMMITTER`.
|
|
35
65
|
#
|
|
36
66
|
# What this trusts: a branch on the remote got there through this set. The answer is read from the
|
|
37
|
-
# remote refs of the working copy after one fetch
|
|
38
|
-
#
|
|
67
|
+
# remote refs of the working copy after one fetch, and it works on the first push, when no request
|
|
68
|
+
# is open yet. A head that is no branch gets the main branch.
|
|
69
|
+
#
|
|
70
|
+
# A ref of the copy is a candidate only while the host still holds its branch: one call of
|
|
71
|
+
# `git ls-remote --heads` per call of this function, the name matched whole. The fetch keeps
|
|
72
|
+
# `--no-prune` — a prune in one copy changes what a neighbouring copy measures — so a branch the
|
|
73
|
+
# host removed after its merge stays as a ref here. Taken as the base, it gave the set one base and
|
|
74
|
+
# the push another once a neighbour pruned the copy: a green set of half an hour was refused as
|
|
75
|
+
# «No green mark». With no answer from the host the refs of the copy decide, and a line on stderr
|
|
76
|
+
# says so.
|
|
39
77
|
rt_push_base() {
|
|
40
|
-
local main="$1" branch own ref name count best best_count merge merged='' host
|
|
78
|
+
local main="$1" branch own ref name count best best_count merge merged='' host live answered=1
|
|
41
79
|
host="${RT_PUSH_HOST_COMMITTER:-GitHub <noreply@github.com>}"
|
|
42
80
|
git fetch --quiet --no-prune origin 2>/dev/null
|
|
43
81
|
git rev-parse --verify --quiet "refs/remotes/origin/$main" >/dev/null 2>&1 || return 0
|
|
82
|
+
live="$(git ls-remote --heads origin 2>/dev/null)" || answered=0
|
|
83
|
+
live="$(printf '%s\n' "$live" | cut -f2)"
|
|
84
|
+
[ "$answered" = 1 ] ||
|
|
85
|
+
printf 'push base: the host did not answer — the base is taken from the refs of the copy\n' >&2
|
|
44
86
|
|
|
45
87
|
best="origin/$main"
|
|
46
88
|
best_count="$(git rev-list --count "refs/remotes/origin/$main..HEAD" 2>/dev/null)"
|
|
@@ -69,10 +111,9 @@ $(git for-each-ref --merged "$merge^2" --no-merged "$merge^1" --format='%(refnam
|
|
|
69
111
|
'' | HEAD | "$main" | "$branch" | *[!A-Za-z0-9._/-]*) continue ;;
|
|
70
112
|
esac
|
|
71
113
|
printf '%s\n' "$merged" | grep -qxF -- "$ref" && continue
|
|
72
|
-
# A branch
|
|
73
|
-
|
|
74
|
-
[ -n "$own" ] &&
|
|
75
|
-
git merge-base --is-ancestor "$own" "$ref" 2>/dev/null && continue
|
|
114
|
+
# A branch the host no longer holds is no base: its ref outlives it in the copy.
|
|
115
|
+
[ "$answered" = 0 ] || printf '%s\n' "$live" | grep -qxF -- "refs/heads/$name" || continue
|
|
116
|
+
[ -n "$own" ] && rt_push_base_on_copy "$ref" "$own" "$host" && continue
|
|
76
117
|
if ! git merge-base --is-ancestor "$ref" HEAD 2>/dev/null; then
|
|
77
118
|
[ -n "$(git rev-list -n 1 --first-parent --merges --fixed-strings --committer="$host" \
|
|
78
119
|
"HEAD..$ref" 2>/dev/null)" ] || continue
|
|
@@ -109,12 +150,14 @@ rt_push_mark_clean() {
|
|
|
109
150
|
# Whether the head adds nothing to its base: every commit of it already lies in that branch on the
|
|
110
151
|
# remote. Such a push sends content the set already judged there, and running the set over it costs
|
|
111
152
|
# its whole length and can find nothing — a branch of an epic just taken from the main branch paid
|
|
112
|
-
# forty minutes for a tree equal to the main one.
|
|
153
|
+
# forty minutes for a tree equal to the main one. The base is a remote ref, or the ref the run ahead
|
|
154
|
+
# pinned at the commit of one; a base that is neither answers «it adds».
|
|
113
155
|
rt_push_adds_nothing() {
|
|
114
|
-
local base="$1" count
|
|
156
|
+
local base="$1" ref count
|
|
115
157
|
[ -n "$base" ] || return 1
|
|
116
|
-
|
|
117
|
-
|
|
158
|
+
case "$base" in refs/rt-kit/push-base/*) ref="$base" ;; *) ref="refs/remotes/$base" ;; esac
|
|
159
|
+
git rev-parse --verify --quiet "$ref" >/dev/null 2>&1 || return 1
|
|
160
|
+
count="$(git rev-list --count "$ref..HEAD" 2>/dev/null)"
|
|
118
161
|
[ "$count" = 0 ]
|
|
119
162
|
}
|
|
120
163
|
|
|
@@ -156,6 +199,160 @@ rt_push_mark_dir() {
|
|
|
156
199
|
printf '%s/rt-kit/push-green' "$common"
|
|
157
200
|
}
|
|
158
201
|
|
|
202
|
+
# The base of the run ahead, pinned for the branch. The run ahead picks the base, puts a ref of its
|
|
203
|
+
# own at its commit and gives the steps of the set that ref, not the remote one: a remote ref moves
|
|
204
|
+
# with every fetch and vanishes with a prune, the pinned one stands until the next run ahead of the
|
|
205
|
+
# branch. A record next to it keeps the tree of the head, the name of the base, its commit and the
|
|
206
|
+
# head commit. The push guard and the git hook take the pinned ref while the record fits the head,
|
|
207
|
+
# and pick the base anew otherwise. A record fits a head with the same tree or a head that lies over
|
|
208
|
+
# the recorded one: a commit after the set — the task folder taken apart, a line in a plan — keeps
|
|
209
|
+
# the marks of the steps that do not read it.
|
|
210
|
+
#
|
|
211
|
+
# Without the record the push picked its base by itself. On 21.11 a set of half an hour took the
|
|
212
|
+
# ref of a branch the host had removed as its base; a neighbouring copy pruned the refs, the push
|
|
213
|
+
# picked the main branch and refused as «No green mark». Records and refs are kept per branch: the
|
|
214
|
+
# branches of a chain run ahead one after another in one copy. The records lie in the directory of
|
|
215
|
+
# the working copy, the refs in the shared refs — a branch is worked in one copy at a time.
|
|
216
|
+
rt_push_base_branch() {
|
|
217
|
+
# shellcheck disable=SC1091
|
|
218
|
+
command -v rt_fact_branch >/dev/null 2>&1 || . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
|
|
219
|
+
rt_fact_branch 2>/dev/null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
# The pinned ref of a branch. It is named by a number, not by the branch: the ref stands in every
|
|
223
|
+
# line of the set that names the base, and the profile reads those lines by words — `visual-gate`,
|
|
224
|
+
# `e2e` — that a branch name may carry. A line of light checks then passed for a heavy one, and its
|
|
225
|
+
# mark outlived a commit of the paths a heavy step does not read.
|
|
226
|
+
rt_push_base_ref() {
|
|
227
|
+
[ -n "$1" ] || return 1
|
|
228
|
+
printf 'refs/rt-kit/push-base/%s' "$(printf '%s' "$1" | cksum | cut -d' ' -f1)"
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# Removes the records and the refs of branches the copy no longer holds: nothing else removes them,
|
|
232
|
+
# and a pinned ref keeps its commits from the collection of garbage.
|
|
233
|
+
rt_push_base_sweep() {
|
|
234
|
+
local dir file branch
|
|
235
|
+
dir="$(git rev-parse --path-format=absolute --git-dir 2>/dev/null)/rt-kit/push-base.d"
|
|
236
|
+
[ -d "$dir" ] || return 0
|
|
237
|
+
find "$dir" -type f 2>/dev/null | while IFS= read -r file; do
|
|
238
|
+
branch="${file#"$dir"/}"
|
|
239
|
+
git show-ref --verify --quiet "refs/heads/$branch" 2>/dev/null && continue
|
|
240
|
+
git update-ref -d "$(rt_push_base_ref "$branch")" 2>/dev/null
|
|
241
|
+
rm -f "$file" 2>/dev/null
|
|
242
|
+
done
|
|
243
|
+
return 0
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
rt_push_base_record_path() {
|
|
247
|
+
local dir branch
|
|
248
|
+
dir="$(git rev-parse --path-format=absolute --git-dir 2>/dev/null)" || return 1
|
|
249
|
+
branch="$(rt_push_base_branch)"
|
|
250
|
+
[ -n "$branch" ] || return 1
|
|
251
|
+
printf '%s/rt-kit/push-base.d/%s' "$dir" "$branch"
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
# Pins the base `$1` for the branch: writes the record and the ref, prints the ref. No branch, or a
|
|
255
|
+
# base with no commit — prints `$1` itself, and the set runs against the remote ref as before.
|
|
256
|
+
rt_push_base_pin() {
|
|
257
|
+
local path tree sha head branch ref
|
|
258
|
+
[ -n "$1" ] || return 0
|
|
259
|
+
branch="$(rt_push_base_branch)"
|
|
260
|
+
tree="$(git rev-parse --verify --quiet 'HEAD^{tree}' 2>/dev/null)"
|
|
261
|
+
head="$(git rev-parse --verify --quiet HEAD 2>/dev/null)"
|
|
262
|
+
sha="$(git rev-parse --verify --quiet "$1^{commit}" 2>/dev/null)"
|
|
263
|
+
path="$(rt_push_base_record_path)"
|
|
264
|
+
ref="$(rt_push_base_ref "$branch")"
|
|
265
|
+
rt_push_base_sweep
|
|
266
|
+
if [ -z "$branch" ] || [ -z "$tree" ] || [ -z "$head" ] || [ -z "$sha" ] || [ -z "$path" ] ||
|
|
267
|
+
! mkdir -p "${path%/*}" 2>/dev/null ||
|
|
268
|
+
! git update-ref "$ref" "$sha" 2>/dev/null ||
|
|
269
|
+
! printf '%s\n%s\n%s\n%s\n' "$tree" "$1" "$sha" "$head" > "$path" 2>/dev/null; then
|
|
270
|
+
printf '%s' "$1"
|
|
271
|
+
return 0
|
|
272
|
+
fi
|
|
273
|
+
printf '%s' "$ref"
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
# Whether the record of the branch fits the head: the same tree, or a head that lies over the
|
|
277
|
+
# recorded one by plain commits. A merge over the recorded head brings content of other branches —
|
|
278
|
+
# the branch of the epic moved and taken in — and the base is picked anew: counted from the old
|
|
279
|
+
# base, that content would pass for this branch's own. Prints the name of the base and its commit
|
|
280
|
+
# on two lines.
|
|
281
|
+
rt_push_base_fits() {
|
|
282
|
+
local path tree name sha head
|
|
283
|
+
path="$(rt_push_base_record_path)" || return 1
|
|
284
|
+
[ -f "$path" ] || return 1
|
|
285
|
+
{ IFS= read -r tree && IFS= read -r name && IFS= read -r sha && IFS= read -r head; } < "$path" || return 1
|
|
286
|
+
case "$name" in origin/?*) ;; *) return 1 ;; esac
|
|
287
|
+
git cat-file -e "$sha^{commit}" 2>/dev/null || return 1
|
|
288
|
+
if [ "$tree" != "$(git rev-parse --verify --quiet 'HEAD^{tree}' 2>/dev/null)" ]; then
|
|
289
|
+
git merge-base --is-ancestor "$head" HEAD 2>/dev/null || return 1
|
|
290
|
+
[ "$(git rev-list --merges --count "$head..HEAD" 2>/dev/null)" = 0 ] || return 1
|
|
291
|
+
fi
|
|
292
|
+
printf '%s\n%s\n' "$name" "$sha"
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
# Prints the pinned ref of the branch when the record fits the head, with the ref put back at the
|
|
296
|
+
# recorded commit if anything moved it. The remote refs are fetched first, as a pick does: light
|
|
297
|
+
# steps read the main branch by its remote ref. No record, or one that does not fit — no answer.
|
|
298
|
+
rt_push_base_recorded() {
|
|
299
|
+
local fit sha ref
|
|
300
|
+
fit="$(rt_push_base_fits)" || return 1
|
|
301
|
+
sha="$(printf '%s\n' "$fit" | sed -n 2p)"
|
|
302
|
+
ref="$(rt_push_base_ref "$(rt_push_base_branch)")" || return 1
|
|
303
|
+
git fetch --quiet --no-prune origin 2>/dev/null
|
|
304
|
+
[ "$(git rev-parse --verify --quiet "$ref" 2>/dev/null)" = "$sha" ] ||
|
|
305
|
+
git update-ref "$ref" "$sha" 2>/dev/null || return 1
|
|
306
|
+
printf '%s' "$ref"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
# The base `$1` picked anew, or the pinned ref when the record names that very base at the commit
|
|
310
|
+
# it stands on now: a record that stopped fitting — an amended commit of unread paths — keeps its
|
|
311
|
+
# marks while the base did not move.
|
|
312
|
+
rt_push_base_same() {
|
|
313
|
+
local path name sha ref
|
|
314
|
+
path="$(rt_push_base_record_path)" || { printf '%s' "$1"; return 0; }
|
|
315
|
+
name="$(sed -n 2p "$path" 2>/dev/null)"
|
|
316
|
+
sha="$(sed -n 3p "$path" 2>/dev/null)"
|
|
317
|
+
ref="$(rt_push_base_ref "$(rt_push_base_branch)")"
|
|
318
|
+
if [ -n "$1" ] && [ "$name" = "$1" ] && [ -n "$sha" ] &&
|
|
319
|
+
[ "$(git rev-parse --verify --quiet "$1^{commit}" 2>/dev/null)" = "$sha" ] &&
|
|
320
|
+
{ [ "$(git rev-parse --verify --quiet "$ref" 2>/dev/null)" = "$sha" ] ||
|
|
321
|
+
git update-ref "$ref" "$sha" 2>/dev/null; }; then
|
|
322
|
+
printf '%s' "$ref"
|
|
323
|
+
return 0
|
|
324
|
+
fi
|
|
325
|
+
printf '%s' "$1"
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
# A base as a person reads it: a pinned ref is named by the remote branch it stands for and its
|
|
329
|
+
# commit, any other base by itself.
|
|
330
|
+
rt_push_base_label() {
|
|
331
|
+
local path
|
|
332
|
+
case "$1" in
|
|
333
|
+
refs/rt-kit/push-base/*)
|
|
334
|
+
path="$(rt_push_base_record_path)" && [ -f "$path" ] &&
|
|
335
|
+
printf '%s pinned at %s' "$(sed -n 2p "$path")" "$(sed -n 3p "$path" | cut -c1-9)" && return 0
|
|
336
|
+
;;
|
|
337
|
+
esac
|
|
338
|
+
printf '%s' "${1:-none}"
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
# The base the last run ahead of this branch judged, for the refusal: the base, and «another
|
|
342
|
+
# history» when the record does not fit the head. No record — nothing.
|
|
343
|
+
rt_push_base_last() {
|
|
344
|
+
local path name
|
|
345
|
+
path="$(rt_push_base_record_path)" || return 0
|
|
346
|
+
[ -f "$path" ] || return 0
|
|
347
|
+
name="$(sed -n 2p "$path" 2>/dev/null)"
|
|
348
|
+
[ -n "$name" ] || return 0
|
|
349
|
+
if rt_push_base_fits >/dev/null; then
|
|
350
|
+
printf '%s pinned at %s' "$name" "$(sed -n 3p "$path" | cut -c1-9)"
|
|
351
|
+
else
|
|
352
|
+
printf '%s (another history)' "$name"
|
|
353
|
+
fi
|
|
354
|
+
}
|
|
355
|
+
|
|
159
356
|
rt_push_mark_has() {
|
|
160
357
|
local key dir
|
|
161
358
|
rt_push_mark_clean || return 1
|
|
@@ -226,7 +226,8 @@ push_sends_head() {
|
|
|
226
226
|
# A head that adds nothing to its base is not judged: the set has nothing new to look at.
|
|
227
227
|
if command -v rt_push_adds_nothing >/dev/null 2>&1 && push_sends_head && rt_push_adds_nothing "$base"; then
|
|
228
228
|
rt_push_gate_note nothing-new
|
|
229
|
-
printf 'the push gate: the head adds no commit to %s — the set is not run\n'
|
|
229
|
+
printf 'the push gate: the head adds no commit to %s — the set is not run\n' \
|
|
230
|
+
"$(command -v rt_push_base_label >/dev/null 2>&1 && rt_push_base_label "$base" || printf '%s' "$base")" >&2
|
|
230
231
|
exit 0
|
|
231
232
|
fi
|
|
232
233
|
|
|
@@ -244,6 +245,24 @@ held="$rt_push_set_held"
|
|
|
244
245
|
ahead="$rt_push_set_ahead"
|
|
245
246
|
ran="$rt_push_set_ran"
|
|
246
247
|
|
|
248
|
+
# The node the tree pins is not on the machine, and PATH gives another one: no step ran, and an empty
|
|
249
|
+
# set must not read as a green one. One line names both versions and the install command.
|
|
250
|
+
if [ -n "${rt_push_set_node:-}" ]; then
|
|
251
|
+
rt_push_gate_note node
|
|
252
|
+
said="$(push_refuse push '{"push_node_pinned":"no"}' "$(jq -cn --arg l "$rt_push_set_node" '{node_line:$l}')")"
|
|
253
|
+
# The decider runs on the node of PATH — the very node that may be too old to run it, or absent:
|
|
254
|
+
# then it answers nothing, and the refusal is said here, or the push would pass unjudged.
|
|
255
|
+
if [ -z "$said" ]; then
|
|
256
|
+
# shellcheck disable=SC1091
|
|
257
|
+
command -v rt_deny_tail >/dev/null 2>&1 || . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
|
|
258
|
+
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
259
|
+
said="$(jq -cn --arg r "BLOCKED: ${rt_push_set_node}. No step of the push set ran. Install the pinned node by that command and push again. $(rt_deny_tail)" \
|
|
260
|
+
'{hookSpecificOutput:{hookEventName:"PreToolUse", permissionDecision:"deny", permissionDecisionReason:$r}}')"
|
|
261
|
+
fi
|
|
262
|
+
printf '%s\n' "$said"
|
|
263
|
+
exit 0
|
|
264
|
+
fi
|
|
265
|
+
|
|
247
266
|
# Heavy steps with no mark are named in one refusal together with the red light ones: the command
|
|
248
267
|
# that runs them ahead goes to the background, where no hook limit cuts it, and the push after it
|
|
249
268
|
# passes from the marks.
|
|
@@ -261,8 +280,16 @@ Red among the light checks:
|
|
|
261
280
|
${failed}
|
|
262
281
|
|
|
263
282
|
$(printf '%s' "$output" | tr -d '\000')"
|
|
283
|
+
# Both bases are named: a mark is keyed by its base, and a push that chose another base than
|
|
284
|
+
# the run ahead looks the same as one with no run at all.
|
|
285
|
+
last_base=""
|
|
286
|
+
command -v rt_push_base_last >/dev/null 2>&1 && last_base="$(rt_push_base_last)"
|
|
287
|
+
command -v rt_push_base_label >/dev/null 2>&1 || rt_push_base_label() { printf '%s' "${1:-none}"; }
|
|
288
|
+
base_line="
|
|
289
|
+
|
|
290
|
+
The base of this push: $(rt_push_base_label "$base"). The base of the last run ahead of this branch: ${last_base:-none recorded}."
|
|
264
291
|
push_refuse push '{"push_marks_green":"no"}' "$(jq -cn --arg a "$ahead" --arg c "$ahead_cmd" --arg d "$dirty_line" --arg r "$red_line" \
|
|
265
|
-
'{ahead:$a, ahead_cmd:$c, dirty_line:$d, red_line:$r}')"
|
|
292
|
+
--arg b "$base_line" '{ahead:$a, ahead_cmd:$c, dirty_line:$d, red_line:$r, base_line:$b}')"
|
|
266
293
|
fi
|
|
267
294
|
|
|
268
295
|
# What was skipped is named aloud even when the set passed: silence about it is exactly the
|
package/assets/hooks/pre-push.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# The checks before a push, as a hook of git itself, not of the agent.
|
|
3
3
|
#
|
|
4
|
-
# Requires: hooks/push-set.sh, hooks/git-guard-push-marks.sh
|
|
4
|
+
# Requires: hooks/push-set.sh, hooks/git-guard-push-marks.sh, hooks/facts.sh, hooks/decide.sh
|
|
5
5
|
#
|
|
6
6
|
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The version control
|
|
7
7
|
# calls it before every push, whatever sent it: the session guard of the push stands only on the
|
|
@@ -89,17 +89,41 @@ command -v rt_push_checks >/dev/null 2>&1 || exit 0
|
|
|
89
89
|
base="$(rt_push_set_base)"
|
|
90
90
|
|
|
91
91
|
if command -v rt_push_adds_nothing >/dev/null 2>&1 && rt_push_adds_nothing "$base"; then
|
|
92
|
-
printf 'pre-push: the head adds no commit to %s — the set is not run\n'
|
|
92
|
+
printf 'pre-push: the head adds no commit to %s — the set is not run\n' \
|
|
93
|
+
"$(command -v rt_push_base_label >/dev/null 2>&1 && rt_push_base_label "$base" || printf '%s' "$base")" >&2
|
|
93
94
|
exit 0
|
|
94
95
|
fi
|
|
95
96
|
|
|
96
97
|
total="$(rt_push_checks "$base" | grep -c .)"
|
|
97
98
|
[ "${total:-0}" -eq 0 ] && exit 0
|
|
98
99
|
|
|
100
|
+
# No installed node serves the pin of the tree, and PATH gives another one or none: no step runs,
|
|
101
|
+
# and the push stops before the line that counts the steps.
|
|
102
|
+
node_line="$(rt_node_pin_mismatch "$repo_root")"
|
|
103
|
+
if [ -n "$node_line" ]; then
|
|
104
|
+
# shellcheck disable=SC1091
|
|
105
|
+
. "$hooks_dir/decide.sh" 2>/dev/null
|
|
106
|
+
if command -v rt_decide >/dev/null 2>&1; then
|
|
107
|
+
rt_decide pre-push.sh push '{"push_sends_tip":"yes","push_node_pinned":"no"}' "$(jq -cn --arg l "$node_line" '{node_line:$l}')" git
|
|
108
|
+
code=$?
|
|
109
|
+
[ "$code" -ne 0 ] && exit "$code"
|
|
110
|
+
fi
|
|
111
|
+
# The decider needs a node, and a client that starts git with no node in PATH reaches none: the
|
|
112
|
+
# line is printed here, and the push stops all the same.
|
|
113
|
+
printf 'pre-push: refused — %s. No step of the set ran.\n' "$node_line" >&2
|
|
114
|
+
exit 1
|
|
115
|
+
fi
|
|
116
|
+
|
|
99
117
|
printf 'pre-push: running the checks before the push, %s of them\n' "$total" >&2
|
|
100
118
|
|
|
101
119
|
rt_push_set_run "$base"
|
|
102
120
|
|
|
121
|
+
# The set judged the node once more and ran no step: an empty set is not a green one.
|
|
122
|
+
if [ -n "${rt_push_set_node:-}" ]; then
|
|
123
|
+
printf 'pre-push: refused — %s. No step of the set ran.\n' "$rt_push_set_node" >&2
|
|
124
|
+
exit 1
|
|
125
|
+
fi
|
|
126
|
+
|
|
103
127
|
[ -n "$rt_push_set_skipped" ] && printf 'pre-push: these checks had nothing to look at:\n%s\n' "$rt_push_set_skipped" >&2
|
|
104
128
|
|
|
105
129
|
if [ -z "$rt_push_set_failed" ]; then
|