forgedock 1.51.0 → 1.53.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/bin/engine/outcome-codes.mjs +3 -0
- package/bin/engine/telemetry-seam.mjs +4 -2
- package/bin/engine-cli.mjs +61 -17
- package/bin/experiment.mjs +58 -6
- package/bin/forge-utils.mjs +6 -2
- package/bin/forgedock.mjs +25 -1
- package/bin/lean/account-watch.mjs +28 -0
- package/bin/lean/account-watch.test.mjs +30 -0
- package/bin/lean/activation.mjs +20 -0
- package/bin/lean/activation.test.mjs +14 -1
- package/bin/lean/basered.mjs +115 -0
- package/bin/lean/basered.test.mjs +66 -0
- package/bin/lean/batch-health.mjs +40 -6
- package/bin/lean/batch-health.test.mjs +34 -1
- package/bin/lean/batch.mjs +41 -2
- package/bin/lean/batch.test.mjs +104 -2
- package/bin/lean/checkpoint-reconcile.mjs +43 -0
- package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
- package/bin/lean/conformance.e2e.test.mjs +1 -1
- package/bin/lean/conformance.mjs +205 -23
- package/bin/lean/conformance.test.mjs +164 -3
- package/bin/lean/context.mjs +27 -17
- package/bin/lean/context.test.mjs +15 -0
- package/bin/lean/effects.mjs +11 -7
- package/bin/lean/execution.mjs +19 -3
- package/bin/lean/execution.test.mjs +39 -0
- package/bin/lean/findinglabel.mjs +16 -0
- package/bin/lean/findinglabel.test.mjs +39 -0
- package/bin/lean/heavy.mjs +6 -3
- package/bin/lean/hostload.mjs +78 -0
- package/bin/lean/hostload.test.mjs +117 -0
- package/bin/lean/hotspots-remote.e2e.test.mjs +71 -0
- package/bin/lean/issuewatch-release.mjs +6 -2
- package/bin/lean/issuewatch-release.test.mjs +16 -0
- package/bin/lean/issuewatch.mjs +11 -1
- package/bin/lean/lanelock.mjs +14 -0
- package/bin/lean/lean.mjs +171 -36
- package/bin/lean/lean.test.mjs +302 -10
- package/bin/lean/light.mjs +48 -7
- package/bin/lean/light.test.mjs +37 -3
- package/bin/lean/limits.test.mjs +142 -9
- package/bin/lean/orchestrate-cancel.test.mjs +143 -0
- package/bin/lean/orchestrate.mjs +110 -26
- package/bin/lean/postdeploy-check.test.mjs +39 -0
- package/bin/lean/prompts.mjs +8 -7
- package/bin/lean/quota.mjs +39 -0
- package/bin/lean/recovery.test.mjs +10 -0
- package/bin/lean/relaxation.mjs +73 -0
- package/bin/lean/relaxation.test.mjs +54 -0
- package/bin/lean/release-postmerge.mjs +119 -0
- package/bin/lean/release-rehearsal.mjs +63 -0
- package/bin/lean/release-rehearsal.test.mjs +93 -0
- package/bin/lean/release-review.e2e.test.mjs +77 -0
- package/bin/lean/release-review.mjs +198 -0
- package/bin/lean/release-review.test.mjs +180 -0
- package/bin/lean/release.mjs +228 -0
- package/bin/lean/release.test.mjs +292 -0
- package/bin/lean/rotator.mjs +150 -31
- package/bin/lean/rotator.test.mjs +105 -2
- package/bin/lean/sandbox-remote.mjs +9 -2
- package/bin/lean/schedd.mjs +56 -6
- package/bin/lean/schedd.test.mjs +108 -6
- package/bin/lean/verifier.mjs +3 -2
- package/bin/lean/verify.mjs +2 -1
- package/bin/lean/verify.test.mjs +6 -0
- package/bin/pool/agent.mjs +18 -4
- package/bin/pool/router.mjs +68 -25
- package/bin/review-staging.mjs +23 -0
- package/bin/stats/conformance-outcomes.mjs +208 -0
- package/bin/stats/conformance-outcomes.test.mjs +188 -0
- package/bin/stats/depth.mjs +218 -0
- package/bin/stats/depth.test.mjs +133 -0
- package/bin/stats/experiment.mjs +7 -5
- package/bin/stats/github-source.mjs +2 -2
- package/bin/stats/index.mjs +64 -2
- package/bin/stats/local-source.mjs +11 -0
- package/bin/stats/query.mjs +69 -0
- package/bin/stats/selffiled.mjs +52 -0
- package/bin/stats/selffiled.test.mjs +71 -0
- package/commands/orchestrate.md +1 -1
- package/commands/review-pr-agents/security.md +4 -0
- package/commands/review-pr-staging.md +2 -0
- package/commands/work-on/build.md +4 -6
- package/docs/CONFIG.md +66 -8
- package/docs/ISSUE-WATCH.md +2 -0
- package/docs/OUTCOME-CODES.md +3 -0
- package/docs/STATS.md +44 -0
- package/docs/TELEMETRY.md +1 -1
- package/package.json +1 -1
- package/pool/README.md +1 -1
- package/pool/image/cs-cred +14 -1
- package/pool/install/install-agent.ps1 +6 -2
- package/scripts/backfill-finding-labels.mjs +50 -0
- package/scripts/backfill-finding-labels.test.mjs +36 -0
- package/scripts/doctor-pipeline-state.sh +21 -6
- package/scripts/file-deferred-followups.sh +60 -238
- package/scripts/file-deferred-followups.test.sh +99 -187
- package/scripts/followup-route.mjs +12 -0
- package/scripts/hotspots.sh +12 -8
- package/scripts/hotspots.test.sh +22 -0
- package/scripts/owner-route-parity.test.sh +17 -1
- package/scripts/prior-attempts.test.mjs +1 -1
- package/scripts/review-pr-side-effects.test.sh +40 -0
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# file-deferred-followups.sh — file the deferred out-of-
|
|
2
|
+
# file-deferred-followups.sh — file the deferred out-of-lane items of one build into the batch AGGREGATES (never a per-parent issue).
|
|
3
3
|
# SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
4
4
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
6
|
+
# #5207: engineering work is never deferred. A row of class engineering or backlog (an explicit class, `[bucket:new-issue]`, or
|
|
7
|
+
# a why with no class prefix) is rejected (stderr `engineering deferral: build it in-lane (#5207)`, DEFERRED_TSV=INVALID, exit 2,
|
|
8
|
+
# nothing filed): the lane builds it. What remains goes to ONE of three aggregates, never to a per-parent follow-up:
|
|
9
|
+
# post-deploy (and verify-now, date, owner:orchestrator / owner:promote / post-promotion text) -> the release-lane rollup,
|
|
10
|
+
# found by `<!-- FORGE:POSTDEPLOY_ROLLUP: <lane> -->` (or the lowest open trusted issue labelled FORGE_ROLLUP_LABEL,
|
|
11
|
+
# forge.yaml followups.rollup_issue_label); env FORGE_RELEASE_LANE (default `default`), FORGE_RELEASE_SHA (informational).
|
|
12
|
+
# external and ops (credentials, spend, an account, a third party or a customer) -> ONE aggregate per batch, found by
|
|
13
|
+
# `<!-- FORGE:EXTERNAL_BATCH: <FORGE_BATCH_ID or adhoc> -->` (labels followup:external, external-prerequisite, needs-human).
|
|
14
|
+
# host (read-only production data or capture, work needed before promotion) -> ONE host aggregate per batch, found by
|
|
15
|
+
# `<!-- FORGE:HOST_BATCH: <batch> -->` (labels followup:host + host-task, never needs-human, #5078).
|
|
16
|
+
# Every lane appends its items under a `### #<root parent>` heading (a follow-up of a follow-up is filed under the root parent),
|
|
17
|
+
# deduplicated on normalized text across parents; the lowest open trusted aggregate is canonical (a concurrent duplicate is closed).
|
|
18
|
+
# Existing per-parent follow-ups (`FORGE:DEFERRED_FROM`) of older runs are never read, edited, reopened or closed here (no migration).
|
|
13
19
|
#
|
|
14
20
|
# Usage: file-deferred-followups.sh --parent N --repo OWNER/REPO [--items FILE|-] [--folded N]
|
|
15
21
|
# items TSV, one per line: <path|-> TAB <why> TAB <known-flaw flag: known-flaw|1|yes|true, else empty> [TAB <class> [TAB <label>]]
|
|
16
22
|
# Column 1 must look like a path (any legal path characters; spaced values need a `/` or extension) or be `-` (a requirement-level item): requirement text or an `R<n>:` prefix there is a usage
|
|
17
23
|
# error (exit 2, DEFERRED_TSV=INVALID, nothing filed). The label (default: the path) is the item's identity in the checklist
|
|
18
24
|
# and in the stdout rows; repeated `R<n>: R<m>:` prefixes in it collapse to the first. Class: column 4, else the why's
|
|
19
|
-
# `post-deploy:|external:|ops:` prefix, else engineering.
|
|
25
|
+
# `post-deploy:|external:|ops:|host:` prefix, else engineering (rejected).
|
|
20
26
|
# #4724 buckets: a why carrying `[bucket:<kind>]` is routed by it (#5078): `owner` is class external only for credentials, spend,
|
|
21
27
|
# an account, a third party or a customer; `owner: orchestrator`, `owner: promote...` and post-promotion text join the rollup and
|
|
22
|
-
# read-only production data or capture is class host
|
|
23
|
-
# the parent's engineering follow-up when the run has one. External items go to ONE aggregate per batch, found by
|
|
24
|
-
# `<!-- FORGE:EXTERNAL_BATCH: <FORGE_BATCH_ID or adhoc> -->` (an older per-parent external follow-up is still appended to).
|
|
25
|
-
# The rollup may also be the lowest open trusted issue labelled FORGE_ROLLUP_LABEL (forge.yaml followups.rollup_issue_label).
|
|
26
|
-
# `new-issue` engineering, `verify-now` (the parent is already on the default branch) its own per-parent follow-up class
|
|
27
|
-
# `verify-now` that the gate releases at once, and `post-deploy`/`date` go to the ONE open rollup of the release lane.
|
|
28
|
-
# The rollup (class post-deploy) is found by `<!-- FORGE:POSTDEPLOY_ROLLUP: <lane> -->`, not by parent: every lane appends
|
|
29
|
-
# its items under a `### #<root parent>` heading (a follow-up of a follow-up is filed under the root parent), deduplicated
|
|
30
|
-
# on normalized text across parents. Env: FORGE_RELEASE_LANE (the deploy lane, default `default`), FORGE_RELEASE_SHA (informational).
|
|
28
|
+
# read-only production data or capture is class host; `host` post-promotion text joins the rollup (#5186).
|
|
31
29
|
# A post-deploy why starts `post-deploy: [check:<id>] ...` (#4626); the token is kept verbatim in the checklist line.
|
|
32
30
|
# Env: DRY_RUN (non-empty: no create/edit, issue number 0), FORGE_TRAIL_TRUSTED_ASSOCIATIONS (default
|
|
33
31
|
# OWNER,MEMBER,COLLABORATOR), FORGE_TRAIL_TRUSTED_LOGINS (default empty), FORGE_DEFERRED_RETRY_SLEEP (secs),
|
|
34
32
|
# FORGE_FOLLOWUP_MILESTONE (the parent's milestone title; default: read from the parent), FORGE_FOLLOWUPS_DEFAULT_MILESTONE
|
|
35
|
-
# (forge.yaml followups.default_milestone), FORGE_EXTERNAL_PREREQ (issue number
|
|
33
|
+
# (forge.yaml followups.default_milestone; a shipped milestone moves to the next open one), FORGE_EXTERNAL_PREREQ (issue number
|
|
34
|
+
# the external aggregate links to), FORGE_BATCH_ID.
|
|
36
35
|
# Stdout: `identity<TAB>issue` per item, then DEFERRED_TELEMETRY deferred_items=N folded=N batched_into=#M[,#M2] filed=N classes=a,b buckets=kind:N,...
|
|
37
36
|
# Exit: 0 ok | 2 usage or malformed TSV row | 3 lookup failed (DEFERRED_LOOKUP=FAILED) | 4 create/append failed (DEFERRED_FILE=FAILED).
|
|
38
37
|
# A failed lookup is never "none found". bash 3.2 portable.
|
|
@@ -62,20 +61,22 @@ if [ "$ITEMS" = "-" ]; then cat > "$TMP/items.raw"; else cat "$ITEMS" > "$TMP/it
|
|
|
62
61
|
# Internal file uses a non-whitespace separator (US, \x1f): a tab IFS collapses an empty `why` and drops the known-flaw flag.
|
|
63
62
|
# Fields: identity, why, flag, path (`-` when none), class.
|
|
64
63
|
SEP=$(printf '\037')
|
|
65
|
-
CLASSES="engineering post-deploy external ops verify-now host"
|
|
66
|
-
# #5078: an owner
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
CLASSES="engineering post-deploy external ops verify-now host backlog"
|
|
65
|
+
# #5078/#5186/#5197: routing of an owner or host item (post-deploy rollup, host task, external) has ONE source: ownerRoute and
|
|
66
|
+
# hostRoute in bin/lean/conformance.mjs, reached through scripts/followup-route.mjs. No regex is mirrored here. A missing node
|
|
67
|
+
# or route CLI aborts the run (exit 2) rather than guessing a route.
|
|
68
|
+
ROUTE_CLI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/followup-route.mjs"
|
|
69
|
+
[ -f "$ROUTE_CLI" ] || { echo "file-deferred-followups: route helper not found: $ROUTE_CLI" >&2; exit 2; }
|
|
70
|
+
command -v node >/dev/null 2>&1 || { echo "file-deferred-followups: node is required for routing" >&2; exit 2; }
|
|
71
|
+
route() { # kind why -> route (aborts the run on failure)
|
|
72
|
+
local out; out=$(node "$ROUTE_CLI" "$1" "$2") || { echo "file-deferred-followups: routing failed for kind $1" >&2; exit 2; }
|
|
73
|
+
printf '%s' "$out"
|
|
74
|
+
}
|
|
73
75
|
owner_route() { # why -> post-deploy | host | external
|
|
74
76
|
case "$1" in "owner: orchestrator"*|"owner: promote"*) echo "post-deploy"; return 0 ;; esac
|
|
75
|
-
|
|
76
|
-
elif printf '%s' "$1" | grep -qiE "$ROPROD_ERE" && ! printf '%s' "$1" | grep -qiE "$EXTNEED_ERE"; then echo "host"
|
|
77
|
-
else echo "external"; fi
|
|
77
|
+
route owner "$1"
|
|
78
78
|
}
|
|
79
|
+
host_route() { route host "$1"; } # why -> post-deploy | host
|
|
79
80
|
: > "$TMP/items"
|
|
80
81
|
BAD=0; ROW=0
|
|
81
82
|
bad_row() { BAD=$((BAD+1)); echo "file-deferred-followups: row $ROW: $1" >&2; }
|
|
@@ -106,28 +107,24 @@ while IFS= read -r line || [ -n "$line" ]; do
|
|
|
106
107
|
if [ -z "$c" ]; then
|
|
107
108
|
case "$w" in post-deploy:*) c="post-deploy" ;; external:*) c="external" ;; ops:*) c="ops" ;; host:*) c="host" ;; *) c="engineering" ;; esac
|
|
108
109
|
fi
|
|
109
|
-
case " $CLASSES " in *" $c "*) ;; *) bad_row "unknown class \`$c\` (
|
|
110
|
-
# #4724: the bucket token decides the class: owner actions never join the post-deploy rollup
|
|
110
|
+
case " $CLASSES " in *" $c "*) ;; *) bad_row "unknown class \`$c\` (post-deploy|external|ops|host)"; continue ;; esac
|
|
111
|
+
# #4724: the bucket token decides the class: owner actions never join the post-deploy rollup.
|
|
111
112
|
case "$w" in
|
|
112
|
-
*"[bucket:owner]"*) [ "$c" = "ops" ] || c=$(owner_route "$w") ;;
|
|
113
|
-
*"[bucket:host]"*) c
|
|
114
|
-
*"[bucket:new-issue]"*)
|
|
115
|
-
*"[bucket:verify-now]"*)
|
|
113
|
+
*"[bucket:owner]"*) [ "$c" = "ops" ] || c=$(owner_route "$w") || exit 2 ;;
|
|
114
|
+
*"[bucket:host]"*) c=$(host_route "$w") || exit 2 ;;
|
|
115
|
+
*"[bucket:new-issue]"*) c="engineering" ;; # #5207: in-lane work, rejected below
|
|
116
|
+
*"[bucket:verify-now]"*) case "$c" in engineering|verify-now) c="post-deploy" ;; esac ;;
|
|
116
117
|
esac
|
|
118
|
+
[ "$c" = "verify-now" ] && c="post-deploy" # #5207: verify-now joins the rollup (no per-parent issue)
|
|
119
|
+
# #5207: engineering work is built in-lane, never deferred into an issue.
|
|
120
|
+
case "$c" in engineering|backlog) bad_row "engineering deferral: build it in-lane (#5207) (\`$id\`)"; continue ;; esac
|
|
117
121
|
if cut -d "$SEP" -f1 "$TMP/items" | grep -qxF -- "$id"; then continue; fi
|
|
118
122
|
case "${k:-}" in known-flaw|1|yes|true) k="known-flaw" ;; *) k="" ;; esac
|
|
119
123
|
printf '%s%s%s%s%s%s%s%s%s\n' "$id" "$SEP" "$w" "$SEP" "$k" "$SEP" "${p:--}" "$SEP" "$c" >> "$TMP/items"
|
|
120
124
|
done < "$TMP/items.raw"
|
|
121
125
|
if [ "$BAD" -gt 0 ]; then echo "DEFERRED_TSV=INVALID"; exit 2; fi
|
|
122
|
-
# #5078: host items join the parent's engineering follow-up of this run (dependent items together; it gets `host-task`).
|
|
123
|
-
HOST_JOIN=""
|
|
124
|
-
if awk -F"$SEP" '$5 == "engineering" { e = 1 } $5 == "host" { h = 1 } END { exit !(e && h) }' "$TMP/items"; then
|
|
125
|
-
HOST_JOIN=1
|
|
126
|
-
awk -F"$SEP" -v OFS="$SEP" '$5 == "host" { $5 = "engineering" } { print }' "$TMP/items" > "$TMP/items.j" && mv "$TMP/items.j" "$TMP/items"
|
|
127
|
-
fi
|
|
128
126
|
TOTAL=$(wc -l < "$TMP/items" | tr -d ' ')
|
|
129
127
|
|
|
130
|
-
MARKER="<!-- FORGE:DEFERRED_FROM: #${PARENT} -->"
|
|
131
128
|
TRUSTED_ASSOC="${FORGE_TRAIL_TRUSTED_ASSOCIATIONS-OWNER,MEMBER,COLLABORATOR}"
|
|
132
129
|
TRUSTED_LOGINS="${FORGE_TRAIL_TRUSTED_LOGINS-}"
|
|
133
130
|
|
|
@@ -147,64 +144,11 @@ finish() { # $1 = batched_into numbers (space separated) or empty, $2 = filed co
|
|
|
147
144
|
fi
|
|
148
145
|
}
|
|
149
146
|
|
|
150
|
-
# --- Trusted
|
|
151
|
-
# Sources, in order: (1) claim markers `<!-- FORGE:DEFERRED_ISSUE: #M -->` on the parent's REST comments (read-after-write
|
|
152
|
-
# consistent), (2) a search over ALL issue states (eventually consistent, so only a fallback). Every candidate is then
|
|
153
|
-
# verified by number over REST (trusted author, DEFERRED_FROM marker, not a PR); the lowest number is canonical.
|
|
147
|
+
# --- Trusted author predicate (applied before any marker match) -------------------------------------------------------
|
|
154
148
|
JQ_PRE='def lst: split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(length > 0));
|
|
155
149
|
def trusted: ((.author_association // "") as $x | ($assoc | lst) | index($x) != null)
|
|
156
150
|
or ((.user.type // "") == "Bot")
|
|
157
151
|
or ((.user.login // "") as $x | ($logins | lst) | index($x) != null);'
|
|
158
|
-
CLAIM_RE='^\s*<!-- FORGE:DEFERRED_ISSUE: #(?<n>[0-9]+)(?: class=[a-z-]+)? -->'
|
|
159
|
-
claim_nums() {
|
|
160
|
-
gh api --paginate "repos/${REPO}/issues/${PARENT}/comments" 2>/dev/null \
|
|
161
|
-
| jq -s -r --arg assoc "$TRUSTED_ASSOC" --arg logins "$TRUSTED_LOGINS" --arg re "$CLAIM_RE" "$JQ_PRE"'
|
|
162
|
-
[.[][] | select(trusted) | (.body // "") | capture($re) | .n | tonumber] | unique | .[]' 2>/dev/null
|
|
163
|
-
}
|
|
164
|
-
search_nums() {
|
|
165
|
-
gh api -X GET search/issues -f per_page=50 \
|
|
166
|
-
-f q="\"FORGE:DEFERRED_FROM: #${PARENT}\" in:body repo:${REPO} is:issue" 2>/dev/null \
|
|
167
|
-
| jq -r --arg assoc "$TRUSTED_ASSOC" --arg logins "$TRUSTED_LOGINS" --arg m "$MARKER" "$JQ_PRE"'
|
|
168
|
-
[.items[] | select(trusted) | select((.body // "") | contains($m)) | .number] | sort | .[]' 2>/dev/null
|
|
169
|
-
}
|
|
170
|
-
verify_num() { # number -> `number<TAB>state` when a trusted, non-PR issue of class $CLS carries the marker (a closed one only if completed and not resolved by a person); empty when not (a 404 is "not it")
|
|
171
|
-
local out rc
|
|
172
|
-
out=$(gh api "repos/${REPO}/issues/$1" 2>"$TMP/verr"); rc=$?
|
|
173
|
-
if [ "$rc" -ne 0 ]; then grep -qE '404|Not Found|410' "$TMP/verr" 2>/dev/null && return 0; return 1; fi
|
|
174
|
-
out=$(printf '%s' "$out" | jq -r --arg assoc "$TRUSTED_ASSOC" --arg logins "$TRUSTED_LOGINS" --arg m "$MARKER" --arg cls "$CLS" "$JQ_PRE"'
|
|
175
|
-
select(.pull_request == null) | select(trusted) | select((.body // "") | contains($m))
|
|
176
|
-
| select((((.body // "") | capture("FORGE:DEFERRED_CLASS: (?<c>[a-z-]+)") | .c) // "engineering") == $cls)
|
|
177
|
-
| select(.state != "closed" or .state_reason == "completed")
|
|
178
|
-
| "\(.number)\t\(.state)"' 2>/dev/null) || return 1
|
|
179
|
-
# #4924: a closed tracker was resolved on purpose when a person had the last word (fold, supersede, invalid): not reusable.
|
|
180
|
-
case "$out" in *$'\t'closed)
|
|
181
|
-
local last
|
|
182
|
-
last=$(gh api "repos/${REPO}/issues/$1/comments?per_page=100" 2>/dev/null | jq -r 'if type == "array" and length > 0 then (last | .user.type // "") else "" end' 2>/dev/null) || return 1
|
|
183
|
-
[ -z "$last" ] || [ "$last" = "Bot" ] || out="" ;;
|
|
184
|
-
esac
|
|
185
|
-
printf '%s' "$out"
|
|
186
|
-
}
|
|
187
|
-
CANON=""; CSTATE=""
|
|
188
|
-
pick_verified() { # numbers... ; sets CANON/CSTATE from the first verified one; non-zero only when a fetch failed
|
|
189
|
-
local n r
|
|
190
|
-
for n in "$@"; do
|
|
191
|
-
r=$(verify_num "$n") || return 1
|
|
192
|
-
if [ -n "$r" ]; then CANON="${r%%$'\t'*}"; CSTATE="${r#*$'\t'}"; return 0; fi
|
|
193
|
-
done
|
|
194
|
-
return 0
|
|
195
|
-
}
|
|
196
|
-
find_canonical() {
|
|
197
|
-
local cands
|
|
198
|
-
CANON=""; CSTATE=""
|
|
199
|
-
cands=$(claim_nums) || return 1
|
|
200
|
-
# shellcheck disable=SC2086
|
|
201
|
-
pick_verified $cands || return 1
|
|
202
|
-
[ -n "$CANON" ] && return 0
|
|
203
|
-
cands=$(search_nums) || return 1
|
|
204
|
-
# shellcheck disable=SC2086
|
|
205
|
-
pick_verified $cands || return 1
|
|
206
|
-
return 0
|
|
207
|
-
}
|
|
208
152
|
# --- #4724: the post-deploy rollup: ONE open issue per release lane, found by marker (not by parent) ------------------
|
|
209
153
|
# #5078: the same shape holds every external item of one batch (`FORGE:EXTERNAL_BATCH: <batch>`), and the rollup may also
|
|
210
154
|
# be a repo's own open issue carrying forge.yaml `followups.rollup_issue_label` (FORGE_ROLLUP_LABEL) when no marked one is open.
|
|
@@ -213,7 +157,8 @@ ROLLUP_MARKER="<!-- FORGE:POSTDEPLOY_ROLLUP: ${RELEASE_LANE} -->"
|
|
|
213
157
|
BATCH="${FORGE_BATCH_ID:-adhoc}"
|
|
214
158
|
EXTERNAL_MARKER="<!-- FORGE:EXTERNAL_BATCH: ${BATCH} -->"
|
|
215
159
|
ROLLUP_LABEL="${FORGE_ROLLUP_LABEL:-}"
|
|
216
|
-
|
|
160
|
+
HOST_MARKER="<!-- FORGE:HOST_BATCH: ${BATCH} -->"
|
|
161
|
+
agg_marker() { case "$1" in post-deploy) printf '%s' "$ROLLUP_MARKER" ;; host) printf '%s' "$HOST_MARKER" ;; *) printf '%s' "$EXTERNAL_MARKER" ;; esac; }
|
|
217
162
|
verify_rollup() { # number [marker] -> `number<TAB>open` when a trusted, open, non-PR issue carries the marker
|
|
218
163
|
local out rc m="${2:-$ROLLUP_MARKER}"
|
|
219
164
|
out=$(gh api "repos/${REPO}/issues/$1" 2>"$TMP/verr"); rc=$?
|
|
@@ -230,7 +175,7 @@ verify_labelled() { # number -> `number<TAB>open` when a trusted, open, non-PR i
|
|
|
230
175
|
select(.pull_request == null) | select(trusted) | select(.state == "open") | select(any(.labels[]?; (.name // .) == $l))
|
|
231
176
|
| "\(.number)\t\(.state)"' 2>/dev/null
|
|
232
177
|
}
|
|
233
|
-
find_aggregate() { # kind (post-deploy|external) ; sets CANON/CSTATE to the lowest open one; non-zero only when a lookup failed
|
|
178
|
+
find_aggregate() { # kind (post-deploy|external|host) ; sets CANON/CSTATE to the lowest open one; non-zero only when a lookup failed
|
|
234
179
|
local kind="$1" m q cands n r
|
|
235
180
|
CANON=""; CSTATE=""
|
|
236
181
|
m=$(agg_marker "$kind"); q="${m#<!-- }"; q="${q% -->}"
|
|
@@ -286,7 +231,7 @@ rollup_append() { # number ; non-zero = failure
|
|
|
286
231
|
else gh issue edit "$num" -R "$REPO" --body-file "$TMP/newbody" >/dev/null 2>&1 || return 1; fi
|
|
287
232
|
return 0
|
|
288
233
|
}
|
|
289
|
-
file_rollup() { # items in $ITEMS_F,
|
|
234
|
+
file_rollup() { # items in $ITEMS_F, aggregate $CLS (post-deploy: the release-lane rollup; external: the batch aggregate, #5078; host: the batch host aggregate, #5207); sets FILED_N, FILED_NEW
|
|
290
235
|
local n_items; n_items=$(wc -l < "$ITEMS_F" | tr -d ' ')
|
|
291
236
|
local m title what lbls
|
|
292
237
|
FILED_N=""; FILED_NEW=0
|
|
@@ -299,6 +244,8 @@ file_rollup() { # items in $ITEMS_F, class $CLS (post-deploy: the release-lane r
|
|
|
299
244
|
m=$(agg_marker "$CLS")
|
|
300
245
|
if [ "$CLS" = "post-deploy" ]; then
|
|
301
246
|
title="post-deploy: release checklist (${RELEASE_LANE})"; what="post-deploy rollup ${RELEASE_LANE}"; lbls="followup:post-deploy"
|
|
247
|
+
elif [ "$CLS" = "host" ]; then
|
|
248
|
+
title="host: tasks of batch ${BATCH}"; what="host aggregate of batch ${BATCH}"; lbls="followup:host host-task"
|
|
302
249
|
else
|
|
303
250
|
title="external: prerequisites of batch ${BATCH}"; what="external aggregate of batch ${BATCH}"; lbls="followup:external external-prerequisite needs-human"
|
|
304
251
|
fi
|
|
@@ -306,6 +253,8 @@ file_rollup() { # items in $ITEMS_F, class $CLS (post-deploy: the release-lane r
|
|
|
306
253
|
{
|
|
307
254
|
if [ "$CLS" = "post-deploy" ]; then
|
|
308
255
|
printf '## Problem\n\nPost-deploy checklist of release lane `%s`%s. Every merged lane appends its post-deploy items under a `### #<parent>` heading (deduplicated), so one read-only verification works through this one issue per release.\n\n' "$RELEASE_LANE" "${FORGE_RELEASE_SHA:+ (deploy target at $FORGE_RELEASE_SHA)}"
|
|
256
|
+
elif [ "$CLS" = "host" ]; then
|
|
257
|
+
printf '## Problem\n\nHost tasks of batch `%s`: every item below is work the host can run (read-only production data or capture) before promotion. Every lane of the batch appends its items under a `### #<parent>` heading (deduplicated), so the batch has ONE host issue.\n\n' "$BATCH"
|
|
309
258
|
else
|
|
310
259
|
printf '## Problem\n\nExternal prerequisites of batch `%s`: every item below waits on something outside the repo (credentials, spend, an account, a third party or a customer). Every lane of the batch appends its items under a `### #<parent>` heading (deduplicated), so the batch has ONE external issue.' "$BATCH"
|
|
311
260
|
[ -n "${FORGE_EXTERNAL_PREREQ:-}" ] && printf ' Linked prerequisite: #%s.' "${FORGE_EXTERNAL_PREREQ#\#}"
|
|
@@ -326,6 +275,7 @@ file_rollup() { # items in $ITEMS_F, class $CLS (post-deploy: the release-lane r
|
|
|
326
275
|
case "$l" in
|
|
327
276
|
needs-human) gh label create "$l" -R "$REPO" --color D93F0B --description "Needs a human decision or action." >/dev/null 2>&1 || true ;; # never --force: the repo's own label wins
|
|
328
277
|
external-prerequisite) gh label create "$l" -R "$REPO" --force --color E99695 --description "External prerequisite. Managed by ForgeDock." >/dev/null 2>&1 || true ;;
|
|
278
|
+
host-task) gh label create "$l" -R "$REPO" --color 0E8A16 --description "Work the host can run (read-only production access)." >/dev/null 2>&1 || true ;;
|
|
329
279
|
*) gh label create "$l" -R "$REPO" --force --color BFD4F2 --description "Deferred follow-up (${CLS}). Managed by ForgeDock." >/dev/null 2>&1 || true ;;
|
|
330
280
|
esac
|
|
331
281
|
args+=(--label "$l")
|
|
@@ -356,36 +306,23 @@ file_rollup() { # items in $ITEMS_F, class $CLS (post-deploy: the release-lane r
|
|
|
356
306
|
FILED_N="$NUM"; FILED_NEW=1
|
|
357
307
|
}
|
|
358
308
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
CKIND="agg"
|
|
365
|
-
case "$CLS" in
|
|
366
|
-
post-deploy) find_aggregate post-deploy ;;
|
|
367
|
-
external)
|
|
368
|
-
find_aggregate external || return 1
|
|
369
|
-
[ -n "$CANON" ] && return 0
|
|
370
|
-
find_canonical || return 1
|
|
371
|
-
[ -n "$CANON" ] && CKIND="legacy"
|
|
372
|
-
return 0 ;;
|
|
373
|
-
*) CKIND="class"; find_canonical ;;
|
|
374
|
-
esac
|
|
375
|
-
}
|
|
376
|
-
# Phase 1: look up the canonical follow-up of every class before filing anything (a failed lookup files nothing).
|
|
309
|
+
# #5207: the aggregate of each class: ops shares the external batch aggregate.
|
|
310
|
+
agg_of() { case "$1" in ops) echo external ;; *) echo "$1" ;; esac; }
|
|
311
|
+
CLS_LIST=$(cut -d "$SEP" -f5 "$TMP/items" | while IFS= read -r c; do agg_of "$c"; done | sort -u)
|
|
312
|
+
CLS=""
|
|
313
|
+
# Phase 1: look up the canonical aggregate of every kind before filing anything (a failed lookup files nothing).
|
|
377
314
|
for CLS in $CLS_LIST; do
|
|
378
315
|
LOOKUP_OK=""
|
|
379
316
|
for attempt in 1 2; do
|
|
380
|
-
if
|
|
317
|
+
if find_aggregate "$CLS"; then LOOKUP_OK=1; break; fi
|
|
381
318
|
[ "$attempt" = 1 ] && sleep "${FORGE_DEFERRED_RETRY_SLEEP:-2}"
|
|
382
319
|
done
|
|
383
320
|
if [ -z "$LOOKUP_OK" ]; then
|
|
384
321
|
echo "DEFERRED_LOOKUP=FAILED"
|
|
385
322
|
exit 3
|
|
386
323
|
fi
|
|
387
|
-
printf '%s\t%s\
|
|
388
|
-
awk -F"$SEP" -v c="$CLS" '$5 == c' "$TMP/items" > "$TMP/items.$CLS"
|
|
324
|
+
printf '%s\t%s\n' "$CANON" "$CSTATE" > "$TMP/canon.$CLS"
|
|
325
|
+
awk -F"$SEP" -v c="$CLS" '$5 == c || (c == "external" && $5 == "ops")' "$TMP/items" > "$TMP/items.$CLS"
|
|
389
326
|
done
|
|
390
327
|
|
|
391
328
|
# Checklist line for one item. Path always backticked so review-pr 6B.5 `contains` verification holds.
|
|
@@ -395,41 +332,6 @@ entry() { # path why flag
|
|
|
395
332
|
[ -n "$2" ] && l="$l — $2"
|
|
396
333
|
printf '%s\n' "$l"
|
|
397
334
|
}
|
|
398
|
-
has_entry() { # body-file path : exact checklist-line match, not substring
|
|
399
|
-
grep -qE '^- \[[ xX]\] `' "$1" 2>/dev/null || return 1
|
|
400
|
-
grep -F -- "\`$2\`" "$1" | grep -qE "^- \[[ xX]\] \`$(printf '%s' "$2" | sed 's/[][\.*^$+?(){}|]/\\&/g')\`( |\$)"
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
# Append the missing items to follow-up $1 (state $2), then reopen it when closed (review-finalize needs it open).
|
|
404
|
-
append_items() { # number state ; non-zero = failure
|
|
405
|
-
local num="$1" state="$2" note=""
|
|
406
|
-
# Re-read the body immediately before editing (parallel builds of the same parent), then append what is missing.
|
|
407
|
-
gh api "repos/${REPO}/issues/${num}" --jq '.body // ""' > "$TMP/body" 2>/dev/null || return 1
|
|
408
|
-
: > "$TMP/add"
|
|
409
|
-
while IFS="$SEP" read -r p w k fp cl; do
|
|
410
|
-
has_entry "$TMP/body" "$p" || entry "$p" "$w" "$k" >> "$TMP/add"
|
|
411
|
-
done < "$ITEMS_F"
|
|
412
|
-
[ "$state" = "closed" ] && note=" (follow-up was closed; reopened)"
|
|
413
|
-
if [ -s "$TMP/add" ]; then
|
|
414
|
-
{ cat "$TMP/body"; printf '\n### Added by a later build of #%s%s\n\n' "$PARENT" "$note"; cat "$TMP/add"; } > "$TMP/newbody"
|
|
415
|
-
if [ -n "${DRY_RUN:-}" ]; then
|
|
416
|
-
echo "DRY_RUN: gh issue edit $num (append $(wc -l < "$TMP/add" | tr -d ' ') item(s))" >&2
|
|
417
|
-
else
|
|
418
|
-
gh issue edit "$num" -R "$REPO" --body-file "$TMP/newbody" >/dev/null 2>&1 || return 1
|
|
419
|
-
fi
|
|
420
|
-
# #4924: reopen only for new items, and say why.
|
|
421
|
-
if [ "$state" = "closed" ]; then
|
|
422
|
-
if [ -n "${DRY_RUN:-}" ]; then echo "DRY_RUN: gh issue reopen $num" >&2
|
|
423
|
-
else
|
|
424
|
-
gh issue reopen "$num" -R "$REPO" >/dev/null 2>&1 || return 1
|
|
425
|
-
gh issue comment "$num" -R "$REPO" --body "$(printf '<!-- FORGE:FOLLOWUP_REOPENED -->\nReopened by the run of #%s%s: it deferred new items not yet tracked here:\n\n%s' "$PARENT" "${FORGE_RUN_ID:+ (run \`$FORGE_RUN_ID\`)}" "$(cat "$TMP/add")")" >/dev/null 2>&1 \
|
|
426
|
-
|| echo "file-deferred-followups: warning: could not post reopen comment on #${num}" >&2
|
|
427
|
-
fi
|
|
428
|
-
fi
|
|
429
|
-
fi
|
|
430
|
-
return 0
|
|
431
|
-
}
|
|
432
|
-
|
|
433
335
|
MS_DONE=""; MS_TITLE=""
|
|
434
336
|
resolve_milestone() { # sets MS_TITLE (empty = none): the parent's milestone, or for a shipped one the next open milestone, else the configured default
|
|
435
337
|
[ -n "$MS_DONE" ] && return 0
|
|
@@ -445,93 +347,13 @@ resolve_milestone() { # sets MS_TITLE (empty = none): the parent's milestone, or
|
|
|
445
347
|
| if $next != "" then $next elif ($d != "" and ($all | map(select(.title == $d and .state == "open")) | length) > 0) then $d else "" end) end' 2>/dev/null) || MS_TITLE="$t"
|
|
446
348
|
}
|
|
447
349
|
|
|
448
|
-
# File one class ($CLS, items in $ITEMS_F): append to its canonical follow-up, or create one. Sets FILED_N, FILED_NEW.
|
|
449
|
-
file_class() {
|
|
450
|
-
local n_items; n_items=$(wc -l < "$ITEMS_F" | tr -d ' ')
|
|
451
|
-
FILED_N=""; FILED_NEW=0
|
|
452
|
-
CANON=$(cut -f1 "$TMP/canon.$CLS"); CSTATE=$(cut -f2 "$TMP/canon.$CLS")
|
|
453
|
-
if [ -n "$CANON" ]; then
|
|
454
|
-
append_items "$CANON" "$CSTATE" || { echo "DEFERRED_FILE=FAILED"; exit 4; }
|
|
455
|
-
if [ "$CLS" = "engineering" ] && [ -n "$HOST_JOIN" ]; then
|
|
456
|
-
if [ -n "${DRY_RUN:-}" ]; then echo "DRY_RUN: gh issue edit $CANON (add label host-task)" >&2
|
|
457
|
-
else gh issue edit "$CANON" -R "$REPO" --add-label host-task >/dev/null 2>&1 || echo "file-deferred-followups: warning: could not label #${CANON} host-task" >&2; fi
|
|
458
|
-
fi
|
|
459
|
-
FILED_N="$CANON"; return 0
|
|
460
|
-
fi
|
|
461
|
-
local claim="<!-- FORGE:DEFERRED_ISSUE: #%s -->" title="follow-up: ${n_items} deferred item(s) (deferred from #${PARENT})"
|
|
462
|
-
if [ "$CLS" != "engineering" ]; then claim="<!-- FORGE:DEFERRED_ISSUE: #%s class=${CLS} -->"; title="follow-up (${CLS}): ${n_items} deferred item(s) (deferred from #${PARENT})"; fi
|
|
463
|
-
local paths; paths=$(awk -F"$SEP" '$4 != "-" { print $4 }' "$ITEMS_F" | awk '!seen[$0]++')
|
|
464
|
-
{
|
|
465
|
-
printf '## Problem\n\n'
|
|
466
|
-
printf 'Deferred from #%s: the items below were declared out of scope in its contract and are tracked here, in one issue per class (%s), instead of surfacing later as review findings.\n\n' "$PARENT" "$CLS"
|
|
467
|
-
printf '**Parent**: #%s\n\n' "$PARENT"
|
|
468
|
-
if [ "$CLS" = "external" ]; then
|
|
469
|
-
printf 'External prerequisite of #%s: these items wait on something outside the repo (credentials, an account, a third party).' "$PARENT"
|
|
470
|
-
[ -n "${FORGE_EXTERNAL_PREREQ:-}" ] && printf ' Linked prerequisite: #%s.' "${FORGE_EXTERNAL_PREREQ#\#}"
|
|
471
|
-
printf '\n\n'
|
|
472
|
-
fi
|
|
473
|
-
printf '## Affected Files\n\n'
|
|
474
|
-
if [ -n "$paths" ]; then printf '%s\n' "$paths" | while IFS= read -r fp; do printf -- '- `%s`\n' "$fp"; done
|
|
475
|
-
else printf -- '- None (requirement-level items, see the checklist)\n'; fi
|
|
476
|
-
printf '\n## Acceptance Criteria\n\n'
|
|
477
|
-
while IFS="$SEP" read -r p w k fp cl; do entry "$p" "$w" "$k"; done < "$ITEMS_F"
|
|
478
|
-
printf '\n%s\n<!-- FORGE:DEFERRED_CLASS: %s -->\n' "$MARKER" "$CLS"
|
|
479
|
-
} > "$TMP/newissue"
|
|
480
|
-
local NUM
|
|
481
|
-
if [ -n "${DRY_RUN:-}" ]; then
|
|
482
|
-
echo "DRY_RUN: gh issue create (follow-up ${CLS}: ${n_items} deferred item(s) from #${PARENT})" >&2
|
|
483
|
-
NUM=0
|
|
484
|
-
else
|
|
485
|
-
resolve_milestone
|
|
486
|
-
local lbl="followup:${CLS}" args=() URL
|
|
487
|
-
gh label create "$lbl" -R "$REPO" --force --color BFD4F2 --description "Deferred follow-up (${CLS}). Managed by ForgeDock." >/dev/null 2>&1 || true
|
|
488
|
-
args=(--label "$lbl")
|
|
489
|
-
if [ "$CLS" = "external" ]; then
|
|
490
|
-
gh label create external-prerequisite -R "$REPO" --force --color E99695 --description "External prerequisite. Managed by ForgeDock." >/dev/null 2>&1 || true
|
|
491
|
-
args+=(--label external-prerequisite)
|
|
492
|
-
fi
|
|
493
|
-
if [ "$CLS" = "host" ] || { [ "$CLS" = "engineering" ] && [ -n "$HOST_JOIN" ]; }; then # #5078: never needs-human
|
|
494
|
-
gh label create host-task -R "$REPO" --color 0E8A16 --description "Work the host can run (read-only production access)." >/dev/null 2>&1 || true
|
|
495
|
-
args+=(--label host-task)
|
|
496
|
-
fi
|
|
497
|
-
[ -n "$MS_TITLE" ] && args+=(--milestone "$MS_TITLE")
|
|
498
|
-
URL=$(gh issue create -R "$REPO" --title "$title" --body-file "$TMP/newissue" "${args[@]}" 2>/dev/null) || URL=""
|
|
499
|
-
NUM=$(printf '%s' "$URL" | grep -oE '[0-9]+$' | tail -n 1)
|
|
500
|
-
[ -n "$NUM" ] || { echo "DEFERRED_FILE=FAILED"; exit 4; }
|
|
501
|
-
fi
|
|
502
|
-
if [ -z "${DRY_RUN:-}" ]; then
|
|
503
|
-
# Claim the follow-up on the parent (REST comments are read-after-write consistent; best effort, the search still finds it).
|
|
504
|
-
# shellcheck disable=SC2059
|
|
505
|
-
gh issue comment "$PARENT" -R "$REPO" --body "$(printf "$claim" "$NUM")" >/dev/null 2>&1 \
|
|
506
|
-
|| echo "file-deferred-followups: warning: could not post claim marker for #${NUM} on #${PARENT}" >&2
|
|
507
|
-
# Post-create re-check: a concurrent build may have filed first. The lowest trusted number is canonical; the newer one is closed.
|
|
508
|
-
if find_canonical; then
|
|
509
|
-
if [ -n "$CANON" ] && [ "$CANON" -lt "$NUM" ]; then
|
|
510
|
-
if append_items "$CANON" "$CSTATE"; then
|
|
511
|
-
gh issue close "$NUM" -R "$REPO" --reason "not planned" --comment "Duplicate of #${CANON}: deferred items of #${PARENT} are tracked there." >/dev/null 2>&1 \
|
|
512
|
-
|| echo "file-deferred-followups: warning: could not close duplicate #${NUM}" >&2
|
|
513
|
-
NUM="$CANON"
|
|
514
|
-
else
|
|
515
|
-
echo "file-deferred-followups: warning: could not move items to #${CANON}; keeping #${NUM}" >&2
|
|
516
|
-
fi
|
|
517
|
-
fi
|
|
518
|
-
else
|
|
519
|
-
echo "file-deferred-followups: warning: post-create re-check failed; keeping #${NUM}" >&2
|
|
520
|
-
fi
|
|
521
|
-
fi
|
|
522
|
-
FILED_N="$NUM"; FILED_NEW=1
|
|
523
|
-
}
|
|
524
|
-
|
|
525
350
|
[ "$TOTAL" -gt 0 ] || { finish "" 0; exit 0; }
|
|
526
351
|
|
|
527
|
-
# Phase 2: one
|
|
352
|
+
# Phase 2: one aggregate per kind.
|
|
528
353
|
INTO=""; FILED=0
|
|
529
354
|
for CLS in $CLS_LIST; do
|
|
530
355
|
ITEMS_F="$TMP/items.$CLS"
|
|
531
|
-
|
|
532
|
-
post-deploy:*|external:agg) file_rollup ;;
|
|
533
|
-
*) file_class ;;
|
|
534
|
-
esac
|
|
356
|
+
file_rollup
|
|
535
357
|
case " $INTO " in *" $FILED_N "*) ;; *) INTO="${INTO:+$INTO }$FILED_N" ;; esac
|
|
536
358
|
FILED=$((FILED + FILED_NEW))
|
|
537
359
|
while IFS="$SEP" read -r p w k fp cl; do printf '%s\t%s\n' "$p" "$FILED_N"; done < "$ITEMS_F"
|