yadflow 4.6.0 → 4.8.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/CHANGELOG.md +259 -0
- package/README.md +46 -4
- package/bin/commands.mjs +9 -2
- package/bin/yad.mjs +309 -30
- package/cli/agent-guard.mjs +511 -0
- package/cli/agent-guide.mjs +83 -0
- package/cli/agent-rules.mjs +381 -0
- package/cli/argv-flags.mjs +7 -0
- package/cli/artifact-status.mjs +88 -20
- package/cli/build.mjs +1372 -0
- package/cli/checkpoint.mjs +2 -2
- package/cli/ci-check.mjs +492 -0
- package/cli/commit.mjs +1 -0
- package/cli/dial.mjs +21 -1
- package/cli/docs.mjs +7 -2
- package/cli/doctor.mjs +176 -33
- package/cli/epic-state.mjs +360 -12
- package/cli/errors.mjs +3 -0
- package/cli/find-product.mjs +36 -2
- package/cli/fold.mjs +9 -5
- package/cli/gate-local.mjs +9 -1
- package/cli/gate.mjs +364 -22
- package/cli/guide.mjs +549 -0
- package/cli/history.mjs +22 -2
- package/cli/hook.mjs +35 -4
- package/cli/index-command.mjs +2 -2
- package/cli/ledger.mjs +60 -0
- package/cli/lib.mjs +46 -0
- package/cli/lifecycle/defaults/2.json +124 -0
- package/cli/lifecycle/lifecycle.schema.json +5 -2
- package/cli/lifecycle.mjs +16 -3
- package/cli/manifest.mjs +75 -0
- package/cli/marked-block.mjs +48 -0
- package/cli/members.mjs +19 -5
- package/cli/migrate.mjs +17 -19
- package/cli/next.mjs +35 -12
- package/cli/openpr.mjs +81 -5
- package/cli/plan.mjs +326 -22
- package/cli/platform.mjs +21 -0
- package/cli/pr-list.mjs +5 -3
- package/cli/product-index.mjs +6 -3
- package/cli/product-token.mjs +186 -0
- package/cli/productcommit.mjs +33 -0
- package/cli/protection.mjs +50 -0
- package/cli/recommend.mjs +3 -1
- package/cli/reconcile.mjs +187 -26
- package/cli/repo-publish.mjs +2 -2
- package/cli/report.mjs +62 -14
- package/cli/run-checks.mjs +586 -0
- package/cli/setup.mjs +244 -25
- package/cli/ship-drift.mjs +49 -18
- package/cli/signing.mjs +377 -0
- package/cli/standup.mjs +1 -1
- package/cli/status.mjs +282 -0
- package/cli/test-agents-file.mjs +993 -0
- package/cli/test-build.mjs +1559 -0
- package/cli/test-ci-check.mjs +616 -0
- package/cli/test-guide.mjs +1267 -0
- package/cli/test-node.mjs +129 -0
- package/cli/test-run-checks.mjs +603 -0
- package/cli/test-setup-agent.mjs +352 -0
- package/cli/test-signing.mjs +524 -0
- package/cli/test-worktree.mjs +520 -0
- package/cli/thread.mjs +4 -0
- package/cli/tidy.mjs +2 -2
- package/cli/toolbox.mjs +37 -6
- package/cli/update-commit.mjs +313 -11
- package/cli/workspace.mjs +38 -10
- package/cli/worktree-record.mjs +53 -0
- package/cli/worktree.mjs +379 -0
- package/package.json +6 -4
- package/skills/sdlc/config.yaml +5 -5
- package/skills/sdlc/module-help.csv +2 -1
- package/skills/yad-backfill/templates/checks/backfill-check.sh +9 -9
- package/skills/yad-change/SKILL.md +5 -1
- package/skills/yad-checks/SKILL.md +61 -12
- package/skills/yad-checks/references/check-gates.md +78 -14
- package/skills/yad-checks/templates/checks/build-test-lint.sh +22 -3
- package/skills/yad-checks/templates/checks/commit-message.sh +8 -2
- package/skills/yad-checks/templates/checks/contract-check.sh +61 -33
- package/skills/yad-checks/templates/checks/epic-open.sh +87 -14
- package/skills/yad-checks/templates/checks/ledger-guard.sh +3 -3
- package/skills/yad-checks/templates/checks/lineage-check.sh +88 -15
- package/skills/yad-checks/templates/checks/member-check.mjs +206 -35
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -5
- package/skills/yad-checks/templates/checks/product-checkout.sh +161 -13
- package/skills/yad-checks/templates/checks/reconcile-debt-check.sh +94 -15
- package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
- package/skills/yad-checks/templates/checks/spec-link.sh +63 -4
- package/skills/yad-checks/templates/checks/verified-commits.sh +23 -5
- package/skills/yad-checks/templates/github/yad-checks.yml +9 -9
- package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +4 -1
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +5 -5
- package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +16 -3
- package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +5 -1
- package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +5 -1
- package/skills/yad-checks/templates/hooks/agent-guard.mjs +116 -0
- package/skills/yad-commit/SKILL.md +8 -5
- package/skills/yad-connect-repos/SKILL.md +5 -3
- package/skills/yad-connect-repos/references/code-context.md +2 -1
- package/skills/yad-connect-repos/references/repos-registry.md +2 -1
- package/skills/yad-docs/templates/app/package-lock.json +395 -106
- package/skills/yad-docs/templates/app/package.json +2 -2
- package/skills/yad-docs-overview/references/pipeline-model.md +2 -2
- package/skills/yad-engineer-review/SKILL.md +55 -25
- package/skills/yad-engineer-review/references/ship-and-record.md +49 -12
- package/skills/yad-epic/SKILL.md +2 -1
- package/skills/yad-epic/references/state-schema.md +76 -17
- package/skills/yad-guide/SKILL.md +192 -0
- package/skills/yad-implement/SKILL.md +75 -13
- package/skills/yad-implement/references/implement-conventions.md +8 -1
- package/skills/yad-implement/templates/.gitmessage +3 -0
- package/skills/yad-open-pr/SKILL.md +21 -0
- package/skills/yad-pair-review/SKILL.md +14 -5
- package/skills/yad-pr-template/SKILL.md +6 -2
- package/skills/yad-pr-template/templates/checks/pr-template.sh +85 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +1 -1
- package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -1
- package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -1
- package/skills/yad-product-bridge/SKILL.md +44 -12
- package/skills/yad-product-bridge/references/bridge.md +11 -5
- package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +2 -2
- package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +9 -4
- package/skills/yad-reconcile/SKILL.md +9 -3
- package/skills/yad-report/SKILL.md +15 -0
- package/skills/yad-review-companion/SKILL.md +5 -3
- package/skills/yad-review-gate/SKILL.md +16 -8
- package/skills/yad-review-gate/references/gating.md +26 -1
- package/skills/yad-run/SKILL.md +61 -33
- package/skills/yad-run/references/run-loop.md +44 -22
- package/skills/yad-spec/SKILL.md +137 -16
- package/skills/yad-spec/references/spec-handoff.md +50 -3
- package/skills/yad-status/SKILL.md +7 -0
- package/skills/yad-stories/references/story-schema.md +1 -1
- package/skills/yad-sync-repos/SKILL.md +2 -1
- package/skills/yad-ui/SKILL.md +2 -2
|
@@ -14,7 +14,7 @@ readonly YAD_NPM_SHRINKWRAP="npm-shrinkwrap.json"
|
|
|
14
14
|
# 20.19 / 22.14 — predates the 2025 npm registry key rotation and rejects anything published since
|
|
15
15
|
# with a raw "Cannot find matching keyid". A declared packageManager without a working Corepack must
|
|
16
16
|
# say so instead of dying with "command not found" or that error in the middle of the job.
|
|
17
|
-
readonly YAD_COREPACK_LINES="set YAD_NODE_VERSION to a current
|
|
17
|
+
readonly YAD_COREPACK_LINES="set YAD_NODE_VERSION to a current 22 or 24 line, or install a current Corepack first (npm install -g corepack)"
|
|
18
18
|
yad_require_corepack() {
|
|
19
19
|
if command -v corepack >/dev/null 2>&1; then return 0; fi
|
|
20
20
|
echo "FAIL [package-manager]: package.json#packageManager is set but corepack is not on PATH (Node 25+ no longer bundles it) — $YAD_COREPACK_LINES." >&2
|
|
@@ -85,11 +85,43 @@ yad_package_manager_spec() {
|
|
|
85
85
|
# shellcheck disable=SC2016
|
|
86
86
|
node --input-type=module -e '
|
|
87
87
|
import fs from "node:fs";
|
|
88
|
-
|
|
88
|
+
// Characters that must never reach the CI log as they are: control characters (an ESC starts a
|
|
89
|
+
// terminal colour code), line and paragraph separators, text-direction marks (U+202E shows the
|
|
90
|
+
// rest of the line backwards) and zero-width characters. The same list as cli/detect.mjs UNSAFE.
|
|
91
|
+
const UNSAFE = /[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/;
|
|
92
|
+
let text, pkg;
|
|
89
93
|
// npm strips a UTF-8 byte-order mark before parsing (Windows editors often write one); do the same
|
|
90
94
|
// so a manifest npm itself installs from is not rejected here.
|
|
91
|
-
try {
|
|
92
|
-
catch
|
|
95
|
+
try { text = fs.readFileSync("package.json", "utf8").replace(/^\uFEFF/, ""); }
|
|
96
|
+
catch (error) {
|
|
97
|
+
process.stderr.write(`FAIL [package-manager]: package.json could not be read (${String(error.code ?? error.message).replace(new RegExp(`${UNSAFE.source}+`, "g"), " ")}) — let the CI user read the file.\n`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
try { pkg = JSON.parse(text); }
|
|
101
|
+
catch (error) {
|
|
102
|
+
// The parser message can quote bytes of the file: control characters and line separators become
|
|
103
|
+
// spaces and it is cut short, so a crafted package.json cannot start a second line in the CI log.
|
|
104
|
+
// Node words the place as "… in JSON at position N" or "… after JSON at position N"; Node 22+
|
|
105
|
+
// adds its own "(line X column Y)", which is dropped so every Node line prints the same text.
|
|
106
|
+
// Read only at the end of the message: an "Unexpected token" message quotes the file, and the
|
|
107
|
+
// file could hold the words "at position".
|
|
108
|
+
const place = / at position (\d+)(?: \(line \d+ column \d+\))?$/;
|
|
109
|
+
const position = place.exec(error.message);
|
|
110
|
+
const reason = error.message.replace(place, "").replace(/ in JSON$/, "")
|
|
111
|
+
.replace(new RegExp(`${UNSAFE.source}+`, "g"), " ").trim().slice(0, 200);
|
|
112
|
+
let where = "";
|
|
113
|
+
if (position) {
|
|
114
|
+
// JSON allows CRLF, LF and a bare CR between values; an editor counts each as a new line.
|
|
115
|
+
const lines = text.slice(0, Number(position[1])).split(/\r\n|\r|\n/);
|
|
116
|
+
const line = lines.length;
|
|
117
|
+
// Counted in characters, not UTF-16 units, so an emoji is one column, as in an editor.
|
|
118
|
+
const column = [...lines[line - 1]].length + 1;
|
|
119
|
+
where = ` at line ${line}, column ${column}`;
|
|
120
|
+
}
|
|
121
|
+
const fix = where ? "fix package.json at that place" : "fix package.json; the parser message says what it found";
|
|
122
|
+
process.stderr.write(`FAIL [package-manager]: package.json is not valid JSON${where} (${reason}) — ${fix}.\n`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
93
125
|
if (pkg === null || typeof pkg !== "object" || Array.isArray(pkg)) {
|
|
94
126
|
process.stderr.write("FAIL [package-manager]: package.json must be a JSON object.\n"); process.exit(1);
|
|
95
127
|
}
|
|
@@ -97,7 +129,12 @@ yad_package_manager_spec() {
|
|
|
97
129
|
process.stderr.write("FAIL [package-manager]: packageManager must be a string.\n"); process.exit(1);
|
|
98
130
|
}
|
|
99
131
|
if (pkg.packageManager && /[\r\n]/.test(pkg.packageManager)) {
|
|
100
|
-
process.stderr.write(
|
|
132
|
+
process.stderr.write("FAIL [package-manager]: packageManager holds a line break — remove it, so the value is one line like pnpm@9.15.0.\n");
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
// The value is printed in later messages, so an UNSAFE character in it is refused.
|
|
136
|
+
if (pkg.packageManager && UNSAFE.test(pkg.packageManager)) {
|
|
137
|
+
process.stderr.write("FAIL [package-manager]: packageManager holds an invisible or control character — remove it, so the value is plain text like pnpm@9.15.0.\n");
|
|
101
138
|
process.exit(1);
|
|
102
139
|
}
|
|
103
140
|
process.stdout.write(pkg.packageManager || "");
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
# the BASE, never as the PR leaves it: a PR must not choose what CI clones, or where.
|
|
8
8
|
#
|
|
9
9
|
# Needs the YAD_PRODUCT_TOKEN secret (a token that can read the Product: a GitHub fine-grained token or
|
|
10
|
-
# App token, a GitLab project/group access token). Without it
|
|
11
|
-
#
|
|
12
|
-
#
|
|
10
|
+
# App token, a GitLab project/group access token). Without it nothing is cloned and the gates defer. A PR
|
|
11
|
+
# from a fork never gets a secret, so there that is a note; on any other PR in CI the record says the team
|
|
12
|
+
# wants the Product read, so a missing token is a loud WARNING (#345) — still not a failure. With a token,
|
|
13
|
+
# a clone that fails FAILS the job: a broken setup must not read like a deferral. Before the clone, one
|
|
14
|
+
# call to the Product host's API with the token reads its expiry date, so CI warns 30 days before the
|
|
15
|
+
# token stops working and says "rejected" when the platform refuses it (#345).
|
|
13
16
|
set -euo pipefail
|
|
14
17
|
|
|
15
18
|
# --- shared Product settings file (byte-identical across the gates; they are standalone by design, so
|
|
@@ -29,7 +32,7 @@ product_config() {
|
|
|
29
32
|
if [ -n "${SDLC_PRODUCT_CONFIG:-}" ]; then printf '%s' "$SDLC_PRODUCT_CONFIG"; return 0; fi
|
|
30
33
|
if [ -n "${SDLC_HUB_CONFIG:-}" ]; then printf '%s' "$SDLC_HUB_CONFIG"; return 0; fi
|
|
31
34
|
if [ -f .sdlc/product.json ] && [ -f .sdlc/hub.json ] && ! cmp -s .sdlc/product.json .sdlc/hub.json; then
|
|
32
|
-
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5.
|
|
35
|
+
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. In the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`) to choose the copy to keep, then commit both files." >&2
|
|
33
36
|
return 1
|
|
34
37
|
fi
|
|
35
38
|
if [ -f .sdlc/product.json ]; then printf '%s' .sdlc/product.json; else printf '%s' .sdlc/hub.json; fi
|
|
@@ -62,7 +65,7 @@ resolve_base() {
|
|
|
62
65
|
BASE="${1:-${SDLC_BASE:-$(resolve_base)}}"
|
|
63
66
|
[ -n "${1:-}" ] || [ -n "${SDLC_BASE:-}" ] || echo "note [product-checkout]: no base given — reading the record from '${BASE}'."
|
|
64
67
|
if ! git rev-parse --verify --quiet "${BASE}^{commit}" >/dev/null; then
|
|
65
|
-
echo "FAIL [product-checkout]: base ref '${BASE}' not found —
|
|
68
|
+
echo "FAIL [product-checkout]: base ref '${BASE}' not found — check the code out with full history (GitHub: actions/checkout with fetch-depth: 0; GitLab: GIT_DEPTH: \"0\"), and give a base that names a fetched branch (the first argument, or SDLC_BASE)."
|
|
66
69
|
exit 1
|
|
67
70
|
fi
|
|
68
71
|
|
|
@@ -77,8 +80,43 @@ url="$(field git_url)"
|
|
|
77
80
|
dest="$(field path)"
|
|
78
81
|
branch="$(field default_branch)"
|
|
79
82
|
|
|
83
|
+
# A warning the CI shows as one: a GitHub annotation on the run (and its PR), and a WARNING line in the log
|
|
84
|
+
# on every platform (GitLab has no annotation from a script).
|
|
85
|
+
warn() {
|
|
86
|
+
echo "WARNING [product-checkout]: $1"
|
|
87
|
+
[ "${GITHUB_ACTIONS:-}" != true ] || echo "::warning title=product-checkout::$1"
|
|
88
|
+
}
|
|
89
|
+
# The record read whole, for the two "set, but written so field cannot read it" tests below. Matched in
|
|
90
|
+
# bash (grep -q under pipefail can end the pipe early); byte by byte, as field reads it, since the script
|
|
91
|
+
# runs under LC_ALL=C (above), which `yad run checks` matches.
|
|
92
|
+
_raw="$(git show "${BASE}:${rec}" 2>/dev/null | tr -d '\n\r')" || _raw=""
|
|
93
|
+
_is_set() { local re="\"$1\"[[:space:]]*:[[:space:]]*\"[^\"]"; [[ "$_raw" =~ $re ]]; }
|
|
94
|
+
# Before the token: a url this check cannot read is the thing to fix first, with or without a token.
|
|
95
|
+
if [ -z "$url" ] && _is_set git_url; then
|
|
96
|
+
# yad check --fix compares the parsed value, so it keeps an escaped url that decodes to the same one.
|
|
97
|
+
echo "note [product-checkout]: ${rec} on ${BASE} names a git_url this check cannot read (it is written with a JSON escape, a quote or a backslash) — the Product is not checked out."
|
|
98
|
+
echo " Write git_url in ${rec} without escapes, and merge that change first."
|
|
99
|
+
exit 0
|
|
100
|
+
fi
|
|
80
101
|
if [ -z "${YAD_PRODUCT_TOKEN:-}" ]; then
|
|
102
|
+
# Whether this PR comes from a fork, which never gets a secret: GitHub's workflow passes YAD_PR_FORK
|
|
103
|
+
# (head repo != this repo); GitLab names both projects. Outside CI nothing is known, and it is a note.
|
|
104
|
+
_fork=""
|
|
105
|
+
if [ "${GITHUB_ACTIONS:-}" = true ]; then _fork="${YAD_PR_FORK:-}"
|
|
106
|
+
elif [ "${GITLAB_CI:-}" = true ] && [ -n "${CI_MERGE_REQUEST_PROJECT_ID:-}" ]; then
|
|
107
|
+
# A pipeline that runs OUTSIDE the MR's target project (a fork's own pipeline) never gets the target's
|
|
108
|
+
# variables; a fork's MR pipeline a maintainer runs IN the target project does (review 1).
|
|
109
|
+
if [ "${CI_PROJECT_ID:-}" != "${CI_MERGE_REQUEST_PROJECT_ID}" ]; then _fork=true; else _fork=false; fi
|
|
110
|
+
fi
|
|
111
|
+
if [ -n "$url" ] && { [ "${GITHUB_ACTIONS:-}" = true ] || [ "${GITLAB_CI:-}" = true ]; } && [ "$_fork" != true ]; then
|
|
112
|
+
warn "no YAD_PRODUCT_TOKEN secret — the Product is not checked out, so contract-check, lineage-check, epic-open and reconcile-debt-check cannot read it and only defer on this PR."
|
|
113
|
+
echo " ${rec} on ${BASE} names the Product, so this repo is meant to read it in CI. Add a token that can read the Product"
|
|
114
|
+
echo " as the YAD_PRODUCT_TOKEN secret (GitHub: Actions secret; GitLab: a masked, NOT protected CI/CD variable on this project)."
|
|
115
|
+
[ "${GITHUB_ACTOR:-}" != 'dependabot[bot]' ] || echo " This run is a Dependabot PR, which gets Dependabot secrets only: add the token there too."
|
|
116
|
+
exit 0
|
|
117
|
+
fi
|
|
81
118
|
echo "note [product-checkout]: no YAD_PRODUCT_TOKEN secret — the Product is not checked out, and the gates defer."
|
|
119
|
+
[ "$_fork" != true ] || echo " This PR comes from a fork, which is never given secrets."
|
|
82
120
|
echo " To check it out here, add a token that can read the Product as the YAD_PRODUCT_TOKEN secret (CI variable)."
|
|
83
121
|
exit 0
|
|
84
122
|
fi
|
|
@@ -89,11 +127,38 @@ if [ -z "$url" ]; then
|
|
|
89
127
|
fi
|
|
90
128
|
# Inside the repo, and not the repo itself: CI can only place a checkout in the workspace, and the gates
|
|
91
129
|
# read an UNTRACKED folder there as CI's checkout.
|
|
130
|
+
_bad=false
|
|
92
131
|
case "/${dest}/" in
|
|
93
|
-
//|/./|*/../*|//*|/.git/*|/.git)
|
|
94
|
-
echo "FAIL [product-checkout]: ${rec} on ${BASE} says path '${dest}' — it must be a folder inside this repo, such as .yad/product."
|
|
95
|
-
exit 1 ;;
|
|
132
|
+
//|/./|*/../*|//*|/.git/*|/.git) _bad=true ;;
|
|
96
133
|
esac
|
|
134
|
+
# A path of only spaces names no folder either (yad run checks refuses it too).
|
|
135
|
+
case "$dest" in *[![:space:]]*) ;; *) _bad=true ;; esac
|
|
136
|
+
# As yad run checks reads it: a path of only `.` parts (`./`) is the repo itself, and a `.git` part in any
|
|
137
|
+
# case is the git folder on a disk that ignores case.
|
|
138
|
+
_lc="$(printf '%s' "$dest" | tr '[:upper:]' '[:lower:]')"
|
|
139
|
+
case "/${_lc}/" in */.git/*) _bad=true ;; esac
|
|
140
|
+
_named=false
|
|
141
|
+
_r="$dest"
|
|
142
|
+
while [ -n "$_r" ]; do
|
|
143
|
+
_q="${_r%%/*}"
|
|
144
|
+
[ "$_q" = "$_r" ] && _r="" || _r="${_r#*/}"
|
|
145
|
+
case "$_q" in ""|.) ;; *) _named=true ;; esac
|
|
146
|
+
done
|
|
147
|
+
[ "$_named" = true ] || _bad=true
|
|
148
|
+
if [ "$_bad" = true ]; then
|
|
149
|
+
# The record is read from the base, so a fix on the PR's branch does not count until it merges. A
|
|
150
|
+
# missing path is one `yad check --fix --push` writes; a path that is set is kept by it, so a person
|
|
151
|
+
# changes that one. `field` reads a value written with an escape, a quote or a backslash as empty:
|
|
152
|
+
# that path is set.
|
|
153
|
+
if [ -n "$dest" ]; then
|
|
154
|
+
echo "FAIL [product-checkout]: ${rec} on ${BASE} says path '${dest}' — it must be a folder inside this repo. Change path in ${rec} to one, such as .yad/product, and merge that change first: this check reads the record from ${BASE}, so changing it in this PR does not help."
|
|
155
|
+
elif _is_set path; then
|
|
156
|
+
echo "FAIL [product-checkout]: ${rec} on ${BASE} names a path this check cannot read (it is written with a JSON escape, a quote or a backslash) — change path in ${rec} to a plain folder such as .yad/product, and merge that change first: this check reads the record from ${BASE}."
|
|
157
|
+
else
|
|
158
|
+
echo "FAIL [product-checkout]: ${rec} on ${BASE} names no path — run yad check --fix --push from the Product, on a machine that has this repo cloned and on its default branch; it writes path .yad/product to ${rec} there. Or set path yourself and merge that change first."
|
|
159
|
+
fi
|
|
160
|
+
exit 1
|
|
161
|
+
fi
|
|
97
162
|
# And no symlink on the way (review 1): the text above is only text, and a PR can track `.yad` as a link
|
|
98
163
|
# to `../elsewhere` — git clone follows it, so the clone (with the token) would land where the PR chose.
|
|
99
164
|
_p=""
|
|
@@ -110,7 +175,9 @@ while [ -n "$_rest" ]; do
|
|
|
110
175
|
done
|
|
111
176
|
# Tracked first (review 2): a tracked folder is also "already there", and read that way it passed.
|
|
112
177
|
if [ -n "$(git ls-files -- "$dest" 2>/dev/null | head -1)" ]; then
|
|
113
|
-
|
|
178
|
+
# The command is printed for a person to paste, so a quote in the path is written the shell's way.
|
|
179
|
+
_qd="$(printf '%s' "$dest" | sed "s/'/'\\\\''/g")"
|
|
180
|
+
echo "FAIL [product-checkout]: '${dest}' holds files this repo tracks — the Product cannot be checked out there. Untrack them only if they do not belong in this repo (git rm -r --cached -- '${_qd}', and add the folder to .gitignore), or change path in ${rec} to an untracked folder such as .yad/product and merge that change first (the record is read from ${BASE})."
|
|
114
181
|
exit 1
|
|
115
182
|
fi
|
|
116
183
|
if [ -e "$dest" ]; then
|
|
@@ -123,19 +190,100 @@ case "$url" in
|
|
|
123
190
|
git@*:*) _h="${url#git@}"; url="https://${_h%%:*}/${_h#*:}" ;;
|
|
124
191
|
ssh://git@*) _h="${url#ssh://git@}"; _hp="${_h%%/*}"; url="https://${_hp%%:*}/${_h#*/}" ;; # an ssh port is not the https one
|
|
125
192
|
https://*|file://*) ;;
|
|
126
|
-
http://*) echo "FAIL [product-checkout]: ${rec} on ${BASE} has an http:// git_url — the token is not sent over plain http.
|
|
127
|
-
*) echo "FAIL [product-checkout]: ${rec} on ${BASE} has a git_url git cannot clone over https: '${url}'."; exit 1 ;;
|
|
193
|
+
http://*) echo "FAIL [product-checkout]: ${rec} on ${BASE} has an http:// git_url — the token is not sent over plain http. Set the Product's git_url to the https url, then run yad check --fix --push from the Product, on a machine that has this repo cloned and on its default branch; it rewrites the record there."; exit 1 ;;
|
|
194
|
+
*) echo "FAIL [product-checkout]: ${rec} on ${BASE} has a git_url git cannot clone over https: '${url}' — set the Product's git_url to an https:// or git@host:org/repo form, then run yad check --fix --push from the Product, on a machine that has this repo cloned and on its default branch; it rewrites the record there."; exit 1 ;;
|
|
128
195
|
esac
|
|
196
|
+
# --- the token's expiry (#345) ---
|
|
197
|
+
# One call to the Product host's API with the token: GitHub answers a personal access token's expiry in
|
|
198
|
+
# the `github-authentication-token-expiration` header of any call; GitLab answers a personal, project or
|
|
199
|
+
# group access token's `expires_at` at /personal_access_tokens/self (GitLab 15.5+). The token goes to curl
|
|
200
|
+
# in a header FILE (`-H @file`), never on its command line. Anything this cannot read is a note and the
|
|
201
|
+
# clone goes on: only the clone decides whether the job fails. A file:// url (a local test) has no API.
|
|
202
|
+
days_from_civil() { # YYYY-MM-DD -> days since 1970-01-01, in shell arithmetic (GNU and BSD date differ)
|
|
203
|
+
local y=$((10#${1:0:4})) m=$((10#${1:5:2})) d=$((10#${1:8:2}))
|
|
204
|
+
[ "$m" -le 2 ] && y=$((y - 1))
|
|
205
|
+
local era=$(( (y >= 0 ? y : y - 399) / 400 ))
|
|
206
|
+
local yoe=$(( y - era * 400 ))
|
|
207
|
+
local mp=$(( m > 2 ? m - 3 : m + 9 ))
|
|
208
|
+
local doy=$(( (153 * mp + 2) / 5 + d - 1 ))
|
|
209
|
+
local doe=$(( yoe * 365 + yoe / 4 - yoe / 100 + doy ))
|
|
210
|
+
echo $(( era * 146097 + doe - 719468 ))
|
|
211
|
+
}
|
|
212
|
+
_rejected=""
|
|
213
|
+
_host=""
|
|
214
|
+
case "$url" in https://*) _h="${url#https://}"; _host="${_h%%/*}"; _host="${_host##*@}" ;; esac
|
|
215
|
+
_api=""
|
|
216
|
+
_kind=""
|
|
217
|
+
# Which API, from the Product's HOST first (review 1: a GitHub-run code repo can read a GitLab Product),
|
|
218
|
+
# and only for a host that names neither platform, from the CI it runs in. Always the Product's own host
|
|
219
|
+
# (or api.github.com / api.<sub>.ghe.com for GitHub's cloud): the token goes nowhere the clone does not.
|
|
220
|
+
_hn="$(printf '%s' "${_host%%:*}" | tr '[:upper:]' '[:lower:]')"
|
|
221
|
+
if [ -n "$_hn" ]; then
|
|
222
|
+
case "$_hn" in
|
|
223
|
+
github.com) _api="https://api.github.com/rate_limit"; _kind=github ;;
|
|
224
|
+
*.ghe.com) _api="https://api.${_hn}/rate_limit"; _kind=github ;;
|
|
225
|
+
gitlab.com|*gitlab*) _api="https://${_host}/api/v4/personal_access_tokens/self"; _kind=gitlab ;;
|
|
226
|
+
*) if [ "${GITLAB_CI:-}" = true ]; then _api="https://${_host}/api/v4/personal_access_tokens/self"; _kind=gitlab
|
|
227
|
+
elif [ "${GITHUB_ACTIONS:-}" = true ]; then _api="https://${_host}/api/v3/rate_limit"; _kind=github
|
|
228
|
+
fi ;;
|
|
229
|
+
esac
|
|
230
|
+
fi
|
|
231
|
+
if [ -n "$_api" ] && command -v curl >/dev/null 2>&1; then
|
|
232
|
+
_tmp="$(mktemp -d)"
|
|
233
|
+
trap 'rm -rf "$_tmp"' EXIT
|
|
234
|
+
( umask 077
|
|
235
|
+
if [ "$_kind" = github ]; then printf 'Authorization: Bearer %s\n' "$YAD_PRODUCT_TOKEN"; else printf 'PRIVATE-TOKEN: %s\n' "$YAD_PRODUCT_TOKEN"; fi > "$_tmp/h" )
|
|
236
|
+
_code="$(curl -sS --max-time 15 -o "$_tmp/body" -D "$_tmp/head" -w '%{http_code}' -H @"$_tmp/h" -- "$_api" 2>/dev/null)" || _code=""
|
|
237
|
+
rm -f "$_tmp/h"
|
|
238
|
+
_exp=""
|
|
239
|
+
if [ "$_code" = 200 ]; then
|
|
240
|
+
if [ "$_kind" = github ]; then
|
|
241
|
+
_exp="$(tr -d '\r' < "$_tmp/head" | sed -nE 's/^[Gg][Ii][Tt][Hh][Uu][Bb]-[Aa][Uu][Tt][Hh][Ee][Nn][Tt][Ii][Cc][Aa][Tt][Ii][Oo][Nn]-[Tt][Oo][Kk][Ee][Nn]-[Ee][Xx][Pp][Ii][Rr][Aa][Tt][Ii][Oo][Nn]:[[:space:]]*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/p' | head -1)" || _exp=""
|
|
242
|
+
else
|
|
243
|
+
_exp="$(tr -d '\n\r' < "$_tmp/body" | sed -nE 's/.*"expires_at"[[:space:]]*:[[:space:]]*"([0-9]{4}-[0-9]{2}-[0-9]{2})[^"]*".*/\1/p')" || _exp=""
|
|
244
|
+
fi
|
|
245
|
+
if [ -n "$_exp" ]; then
|
|
246
|
+
_left=$(( $(days_from_civil "$_exp") - $(days_from_civil "$(date -u +%Y-%m-%d)") ))
|
|
247
|
+
if [ "$_left" -le 30 ]; then
|
|
248
|
+
warn "YAD_PRODUCT_TOKEN expires on ${_exp} (in ${_left} day(s)) — renew it before then, or every Product-reading gate on this repo fails its checkout."
|
|
249
|
+
else
|
|
250
|
+
echo "note [product-checkout]: YAD_PRODUCT_TOKEN expires on ${_exp}."
|
|
251
|
+
fi
|
|
252
|
+
else
|
|
253
|
+
echo "note [product-checkout]: the platform did not say when YAD_PRODUCT_TOKEN expires (a token with no expiry date, or an app token)."
|
|
254
|
+
fi
|
|
255
|
+
elif [ "$_code" = 401 ]; then
|
|
256
|
+
_rejected=1
|
|
257
|
+
elif [ "$_code" = 403 ] && [ "$_kind" = gitlab ]; then
|
|
258
|
+
# A clone-only token (read_repository) may not call GitLab's API at all: its expiry is then read by
|
|
259
|
+
# `yad doctor`, from the Product's own list of access tokens.
|
|
260
|
+
echo "note [product-checkout]: ${_host} would not tell this token its own expiry date (HTTP 403 — a token with only read_repository cannot use the API); \`yad doctor\` warns about the Product's project access tokens that expire soon."
|
|
261
|
+
else
|
|
262
|
+
echo "note [product-checkout]: could not read YAD_PRODUCT_TOKEN's expiry date from ${_host} (${_code:+HTTP }${_code:-no answer}); going on with the clone."
|
|
263
|
+
fi
|
|
264
|
+
fi
|
|
265
|
+
|
|
129
266
|
# The token never goes on a command line or into a URL, so no process list or log line shows it; git
|
|
130
267
|
# reads the header from its environment (GIT_CONFIG_COUNT, git 2.31+). GitHub is told to mask the
|
|
131
268
|
# encoded form too — it only masks the secret as written.
|
|
132
|
-
|
|
269
|
+
# The user name the host expects with a token: by the host's kind when the API choice above named one
|
|
270
|
+
# (review 2), else by the CI this runs in.
|
|
271
|
+
case "${_kind:-}" in
|
|
272
|
+
gitlab) _user=oauth2 ;;
|
|
273
|
+
github) _user=x-access-token ;;
|
|
274
|
+
*) case "${GITLAB_CI:-}" in true) _user=oauth2 ;; *) _user=x-access-token ;; esac ;;
|
|
275
|
+
esac
|
|
133
276
|
_auth="$(printf '%s:%s' "$_user" "$YAD_PRODUCT_TOKEN" | base64 | tr -d '\n')"
|
|
134
277
|
[ "${GITHUB_ACTIONS:-}" != true ] || echo "::add-mask::${_auth}"
|
|
135
278
|
if ! GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0="Authorization: Basic ${_auth}" \
|
|
136
279
|
GIT_TERMINAL_PROMPT=0 git clone --quiet --depth 1 ${branch:+--branch "$branch"} -- "$url" "$dest"; then
|
|
137
280
|
echo "FAIL [product-checkout]: could not clone the Product from ${url}${branch:+ (${branch})} into '${dest}'."
|
|
138
|
-
|
|
281
|
+
if [ -n "$_rejected" ]; then
|
|
282
|
+
echo " ${_host} rejected YAD_PRODUCT_TOKEN (HTTP 401): it has expired or been revoked. Make a new token that can read the Product and set it as the secret."
|
|
283
|
+
else
|
|
284
|
+
echo " Check that YAD_PRODUCT_TOKEN can read that repo, and that git_url and default_branch in ${rec} are right."
|
|
285
|
+
fi
|
|
139
286
|
exit 1
|
|
140
287
|
fi
|
|
288
|
+
[ -z "$_rejected" ] || warn "${_host} rejected YAD_PRODUCT_TOKEN on its API (HTTP 401), though the clone worked — check that it has not expired or been revoked."
|
|
141
289
|
echo "note [product-checkout]: the Product is checked out at '${dest}'${branch:+ (${branch})} — the gates read it there."
|
|
@@ -27,7 +27,7 @@ product_config() {
|
|
|
27
27
|
if [ -n "${SDLC_PRODUCT_CONFIG:-}" ]; then printf '%s' "$SDLC_PRODUCT_CONFIG"; return 0; fi
|
|
28
28
|
if [ -n "${SDLC_HUB_CONFIG:-}" ]; then printf '%s' "$SDLC_HUB_CONFIG"; return 0; fi
|
|
29
29
|
if [ -f .sdlc/product.json ] && [ -f .sdlc/hub.json ] && ! cmp -s .sdlc/product.json .sdlc/hub.json; then
|
|
30
|
-
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5.
|
|
30
|
+
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. In the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`) to choose the copy to keep, then commit both files." >&2
|
|
31
31
|
return 1
|
|
32
32
|
fi
|
|
33
33
|
if [ -f .sdlc/product.json ]; then printf '%s' .sdlc/product.json; else printf '%s' .sdlc/hub.json; fi
|
|
@@ -60,7 +60,7 @@ BASE="${1:-${SDLC_BASE:-$(resolve_base)}}"
|
|
|
60
60
|
[ -n "${1:-}" ] || [ -n "${SDLC_BASE:-}" ] || echo "note [reconcile-debt]: no base given — diffing against '${BASE}'."
|
|
61
61
|
|
|
62
62
|
if ! git rev-parse --verify --quiet "${BASE}^{commit}" >/dev/null; then
|
|
63
|
-
echo "FAIL [reconcile-debt]: base ref '${BASE}' not found —
|
|
63
|
+
echo "FAIL [reconcile-debt]: base ref '${BASE}' not found — check the code out with full history (GitHub: actions/checkout with fetch-depth: 0; GitLab: GIT_DEPTH: \"0\"), and give a base that names a fetched branch (the first argument, or SDLC_BASE)."
|
|
64
64
|
exit 1
|
|
65
65
|
fi
|
|
66
66
|
RANGE="${BASE}..HEAD"
|
|
@@ -135,7 +135,7 @@ record_path() {
|
|
|
135
135
|
}
|
|
136
136
|
product_for() {
|
|
137
137
|
_link="specs/$1/link.md"
|
|
138
|
-
prod=""; prod_note=""; prod_fail=""
|
|
138
|
+
prod=""; prod_note=""; prod_fail=""; _fix_where="product-repo in specs/$1/link.md"; _fix_when=""; _src="product-repo"; _fix_eg="../../.yad/product, from the story's folder"
|
|
139
139
|
yad_tmp # here, in this shell: a $(…) below would set it, and its EXIT trap, in a subshell only
|
|
140
140
|
product_rel="$(link_val product-repo "$_link")"
|
|
141
141
|
_from="$_link"
|
|
@@ -188,6 +188,17 @@ SIBLINGS
|
|
|
188
188
|
}${_link} names product-repo '${product_rel}', but ${_from} on ${BASE} says '${_base_rel}' — the Product is read from the base value; a new one counts once it merges."
|
|
189
189
|
product_rel="$_base_rel"
|
|
190
190
|
fi
|
|
191
|
+
# What a failure below tells the person to change (#351): the source that was read. Only on a first
|
|
192
|
+
# spec (the base names no Product) is it this PR's own link.md, which counts at once; anything else is
|
|
193
|
+
# read from the base, so a change to it counts only after it merges.
|
|
194
|
+
if [ -n "$_use_rec" ]; then
|
|
195
|
+
_src="path '${_rec}' in .sdlc/product-link.json"; _fix_eg=".yad/product, from the repo root"
|
|
196
|
+
_fix_where="path in .sdlc/product-link.json"; _fix_when=", and merge that change on its own first: a value counts once ${BASE} has it"
|
|
197
|
+
elif [ -n "$_base_rel" ]; then
|
|
198
|
+
_fix_where="product-repo in ${_from}"; _fix_when=", and merge that change on its own first: a value counts once ${BASE} has it"
|
|
199
|
+
else
|
|
200
|
+
_fix_where="product-repo in ${_link}"; _fix_when=" in this pull request"
|
|
201
|
+
fi
|
|
191
202
|
# A Product this repo keeps, asked of the base first (see above). Both joins resolve_product may pick.
|
|
192
203
|
case "$product_rel" in
|
|
193
204
|
'') _cands="" ;;
|
|
@@ -217,7 +228,7 @@ CANDS
|
|
|
217
228
|
case "$prod" in /*) _pc="$prod" ;; *) _pc="./$prod" ;; esac
|
|
218
229
|
_phys="$(cd -P "$_pc" 2>/dev/null && pwd -P)" || _phys=""
|
|
219
230
|
if [ -z "$_phys" ]; then
|
|
220
|
-
prod_fail="
|
|
231
|
+
prod_fail="${_src} resolves to '${prod}', a folder the gate cannot enter to check where it really is — so it is not read. Point ${_fix_where} at a folder the job can read${_fix_when}."
|
|
221
232
|
return 0
|
|
222
233
|
fi
|
|
223
234
|
# Not inside this repo's own git folder (review 7). git never lists `.git/` as tracked, yet a PR
|
|
@@ -230,7 +241,7 @@ CANDS
|
|
|
230
241
|
_p="$_phys"
|
|
231
242
|
while :; do
|
|
232
243
|
if [ "$_p" -ef "$_gd" ]; then
|
|
233
|
-
prod_fail="
|
|
244
|
+
prod_fail="${_src} resolves to '${prod}', inside this repo's own git folder — what is there is git's, shaped by branch names, not a Product. Point ${_fix_where} at the Product checkout (${_fix_eg})${_fix_when}."
|
|
234
245
|
return 0
|
|
235
246
|
fi
|
|
236
247
|
case "$_p" in /|'') break ;; esac
|
|
@@ -262,15 +273,18 @@ CANDS
|
|
|
262
273
|
$_kept
|
|
263
274
|
KEPT
|
|
264
275
|
[ -n "$_kept_here" ] || return 0
|
|
265
|
-
if [ -n "$
|
|
276
|
+
if [ -n "$_use_rec" ]; then _what="path '${_rec}' in .sdlc/product-link.json reaches nothing"
|
|
277
|
+
elif [ -n "$product_rel" ]; then _what="product-repo '${product_rel}' reaches nothing"; else _what="link.md names no product-repo"; fi
|
|
266
278
|
if [ "$(printf '%s' "$_kept_here" | grep -c .)" -gt 1 ]; then
|
|
267
|
-
prod_fail="${_what}, and ${BASE} keeps more than one Product holding ${_epic_of} ($(printf '%s' "$_kept_here" | tr '\n' ' ' | sed -E 's/ +$//')) — the gate cannot tell which is meant."
|
|
279
|
+
prod_fail="${_what}, and ${BASE} keeps more than one Product holding ${_epic_of} ($(printf '%s' "$_kept_here" | tr '\n' ' ' | sed -E 's/ +$//')) — the gate cannot tell which is meant. Set ${_fix_where} to one of them${_fix_when}."
|
|
268
280
|
return 0
|
|
269
281
|
fi
|
|
270
282
|
_k="$(printf '%s' "$_kept_here" | head -1)"
|
|
271
283
|
prod_note="${prod_note:+$prod_note
|
|
272
284
|
}${_what} here; the Product this repo keeps at '${_k}' on ${BASE} holds ${_epic_of}, so that one is read."
|
|
273
285
|
product_rel="$_k"
|
|
286
|
+
# The value read did not resolve to it: the gate picked it. Say so in what base_product prints.
|
|
287
|
+
_src="${_what}, so the Product this repo keeps"
|
|
274
288
|
[ "$_k" != . ] || _k=""
|
|
275
289
|
base_product "$_k"
|
|
276
290
|
return 0
|
|
@@ -282,12 +296,12 @@ KEPT
|
|
|
282
296
|
tracked_verdict() {
|
|
283
297
|
case "$1" in
|
|
284
298
|
entry:*)
|
|
285
|
-
prod_fail="
|
|
299
|
+
prod_fail="${_src} reaches the Product through '${1#*:}', a symlink, submodule or file this repo tracks — what is behind it is this PR's to choose. Point ${_fix_where} at the Product itself${_fix_when}."
|
|
286
300
|
return 0 ;;
|
|
287
301
|
tree:*)
|
|
288
302
|
_r="${1#*:}"
|
|
289
303
|
if git cat-file -e "${BASE}:${_r:+$_r/}.sdlc/product.json" 2>/dev/null || git cat-file -e "${BASE}:${_r:+$_r/}.sdlc/hub.json" 2>/dev/null; then base_product "$_r"; return 0; fi
|
|
290
|
-
prod_fail="
|
|
304
|
+
prod_fail="${_src} resolves to '${_r:-.}', which holds files this repo tracks, but ${BASE} does not track '${_r:+$_r/}.sdlc/product.json' (or the older hub.json) there, so it is not a Product kept in this repo. Untrack those files (git rm -r --cached '${_r:-.}'), or point ${_fix_where} at the Product${_fix_when}."
|
|
291
305
|
return 0 ;;
|
|
292
306
|
esac
|
|
293
307
|
return 1
|
|
@@ -320,7 +334,7 @@ KEPT
|
|
|
320
334
|
base_product() {
|
|
321
335
|
_r="$1"; _e="${_r:+$_r/}epics"
|
|
322
336
|
if [ "$(git cat-file -t "${BASE}:${_e}" 2>/dev/null)" != tree ]; then
|
|
323
|
-
prod_fail="
|
|
337
|
+
prod_fail="${_src} resolves to '${_r:-.}', a Product this repo keeps, and ${BASE} has no '${_e}' folder — there is nothing on the base to read. Merge that Product's epics into ${BASE} first, or point ${_fix_where} at the Product checkout${_fix_when}."
|
|
324
338
|
return 0
|
|
325
339
|
fi
|
|
326
340
|
# (awk reads to the end rather than stopping at the first hit: stopping left `tr` writing into a
|
|
@@ -349,7 +363,7 @@ base_product() {
|
|
|
349
363
|
GIT_INDEX_FILE="${_arch_dir}.idx" git ls-files -z -- ':(glob)**/.gitattributes' |
|
|
350
364
|
GIT_INDEX_FILE="${_arch_dir}.idx" xargs -0 git update-index --force-remove -- &&
|
|
351
365
|
GIT_WORK_TREE="${_arch_dir}/${_e}" GIT_INDEX_FILE="${_arch_dir}.idx" git checkout-index -a -f; } >/dev/null 2>&1; then
|
|
352
|
-
prod_fail="
|
|
366
|
+
prod_fail="${_src} resolves to '${_r:-.}', a Product this repo keeps, and '${_e}' could not be read from ${BASE} — run the job again; if it repeats, check the code out with full history and no partial-clone filter (GitHub: actions/checkout with fetch-depth: 0; GitLab: GIT_DEPTH: \"0\")."
|
|
353
367
|
return 0
|
|
354
368
|
fi
|
|
355
369
|
_arch_key="x$_r"
|
|
@@ -474,6 +488,61 @@ open_debt_on_thread() {
|
|
|
474
488
|
done
|
|
475
489
|
}
|
|
476
490
|
|
|
491
|
+
# --- shared SHA exemption (byte-identical in spec-link / lineage-check / epic-open / reconcile-debt-check;
|
|
492
|
+
# --- the gates are deliberately standalone, so it is duplicated, not sourced) ---
|
|
493
|
+
# A commit already on a shared branch cannot be reworded without rewriting that branch, so one bad trailer
|
|
494
|
+
# would fail every later PR whose range still holds it — and a release PR to the default branch walks the
|
|
495
|
+
# whole release, so it fails again on every release until that commit reaches the base. `.sdlc/gate-exempt`
|
|
496
|
+
# names such commits, one full SHA per line, `#` comments allowed; every per-commit gate passes
|
|
497
|
+
# them, so a commit is waived once, in a reviewed change, instead of on every pipeline. A listed commit
|
|
498
|
+
# skips EVERY check of the gate, not only its trailer's — a sealed epic or a frozen thread included. SDLC_GATE_EXEMPT
|
|
499
|
+
# names another path in the repo. It comes from the pipeline config, which a PR may change where the PR's
|
|
500
|
+
# own pipeline runs; it still names a file on the BASE whose every entry must be a full SHA, so it cannot
|
|
501
|
+
# list the PR's own commits — and a PR that changes the pipeline could drop the gates anyway, which
|
|
502
|
+
# required checks and branch protection, not this script, prevent. The list is read from the BASE, never from this PR — a PR that could
|
|
503
|
+
# list its own commits would wave itself past every gate; an entry counts once it merges. An entry must be
|
|
504
|
+
# a FULL hex SHA: git reads 40 hex characters (64 in a SHA-256 repo) as a commit, but looks a short one up as a tag or branch name
|
|
505
|
+
# first — so a tag named like a listed short SHA would stand in for another commit, and a short SHA also
|
|
506
|
+
# grows ambiguous as the repo grows. An entry that is not one, or names no commit here, exempts nothing;
|
|
507
|
+
# both are said as notes, so a typo is visible.
|
|
508
|
+
GATE_EXEMPT_FILE="${SDLC_GATE_EXEMPT:-.sdlc/gate-exempt}"
|
|
509
|
+
exempt_shas=''
|
|
510
|
+
load_exempt_shas() {
|
|
511
|
+
# Three dots: against the merge base, so a base that moved on is not mistaken for this PR's change.
|
|
512
|
+
# Only exit 1 means "it changed"; an error (no merge base) says nothing about the file.
|
|
513
|
+
_ex_rc=0
|
|
514
|
+
git diff --quiet "${BASE}...HEAD" -- "$GATE_EXEMPT_FILE" 2>/dev/null || _ex_rc=$?
|
|
515
|
+
if [ "$_ex_rc" -eq 1 ]; then
|
|
516
|
+
echo "note [$1]: ${GATE_EXEMPT_FILE} changes in this PR — the list is read from ${BASE}, not from this PR; the new one counts once it merges."
|
|
517
|
+
fi
|
|
518
|
+
git cat-file -e "${BASE}:${GATE_EXEMPT_FILE}" 2>/dev/null || return 0
|
|
519
|
+
_ex_list="$(git show "${BASE}:${GATE_EXEMPT_FILE}" 2>/dev/null | sed -E 's/#.*//; s/^[[:space:]]+//; s/[[:space:]]+$//')" || _ex_list=""
|
|
520
|
+
while IFS= read -r _ex; do
|
|
521
|
+
[ -z "$_ex" ] && continue
|
|
522
|
+
case "$_ex" in
|
|
523
|
+
*[!0123456789abcdef]*) echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not a lowercase hex SHA — it exempts nothing." ; continue ;;
|
|
524
|
+
esac
|
|
525
|
+
if [ "${#_ex}" -ne 40 ] && [ "${#_ex}" -ne 64 ]; then
|
|
526
|
+
echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not a full SHA (40 characters, or 64 in a SHA-256 repo) — it exempts nothing (a short one could be taken over by a tag or branch of that name)."
|
|
527
|
+
continue
|
|
528
|
+
fi
|
|
529
|
+
_ex_full="$(git rev-parse --verify --quiet "${_ex}^{commit}" 2>/dev/null)" || _ex_full=""
|
|
530
|
+
# Only an entry git reads back as exactly itself: hex of the other hash's length (64 in a SHA-1 repo,
|
|
531
|
+
# 40 in a SHA-256 one) is looked up as a tag or branch name first, so a ref of that name would stand in;
|
|
532
|
+
# and an annotated tag's own SHA peels to its commit's — the list names commits, as rev-list walks them.
|
|
533
|
+
if [ -z "$_ex_full" ] || [ "$_ex_full" != "$_ex" ]; then
|
|
534
|
+
echo "note [$1]: ${GATE_EXEMPT_FILE} entry '${_ex}' is not the full SHA of a commit here — it exempts nothing."
|
|
535
|
+
continue
|
|
536
|
+
fi
|
|
537
|
+
exempt_shas="${exempt_shas}${_ex_full}
|
|
538
|
+
"
|
|
539
|
+
done <<EXEMPT_LIST
|
|
540
|
+
$_ex_list
|
|
541
|
+
EXEMPT_LIST
|
|
542
|
+
}
|
|
543
|
+
is_exempt_sha() { [ -n "$exempt_shas" ] && printf '%s' "$exempt_shas" | grep -qxF "$1"; }
|
|
544
|
+
load_exempt_shas reconcile-debt
|
|
545
|
+
|
|
477
546
|
commits="$(git rev-list --no-merges "$RANGE")"
|
|
478
547
|
if [ -z "$commits" ]; then
|
|
479
548
|
echo "PASS [reconcile-debt]: no non-merge commits in ${RANGE}"
|
|
@@ -487,6 +556,10 @@ while IFS= read -r sha; do
|
|
|
487
556
|
short="$(git log -1 --format=%h "$sha")"
|
|
488
557
|
subject="$(git log -1 --format=%s "$sha")"
|
|
489
558
|
task="$(git log -1 --format='%(trailers:key=Task,valueonly)' "$sha" | awk '!f && length($0) { print; f = 1 }')"
|
|
559
|
+
if is_exempt_sha "$sha"; then
|
|
560
|
+
echo "PASS [reconcile-debt]: ${short} '${subject}' — SHA exemption (${GATE_EXEMPT_FILE} on ${BASE})"
|
|
561
|
+
continue
|
|
562
|
+
fi
|
|
490
563
|
# The type exemption waives the REQUIREMENT for an owning epic, not the VALIDITY of one that is
|
|
491
564
|
# claimed — same rule spec-link applies. Exempting on the subject alone would let `chore(x): …` plus
|
|
492
565
|
# a Task trailer ship a change onto a thread that is frozen for open hotfix debt.
|
|
@@ -524,7 +597,7 @@ while IFS= read -r sha; do
|
|
|
524
597
|
# A Product that WAS reached with no such epic is an orphan story link, as lineage-check and epic-open
|
|
525
598
|
# say — not "not reachable" (E117 review 2).
|
|
526
599
|
if [ ! -d "$ep_dir" ]; then
|
|
527
|
-
echo "FAIL [reconcile-debt]: ${short} ${task} -> epic ${epic} does not exist in the product repo (orphan story link)."
|
|
600
|
+
echo "FAIL [reconcile-debt]: ${short} ${task} -> epic ${epic} does not exist in the product repo (orphan story link). Check the story id in the Task trailer; if ${epic} is new, merge its Shape review PRs into the Product's default branch first."
|
|
528
601
|
rc=1
|
|
529
602
|
continue
|
|
530
603
|
fi
|
|
@@ -538,9 +611,15 @@ while IFS= read -r sha; do
|
|
|
538
611
|
blockers="$(open_debt_on_thread "$prod" "$thread" "$epic")"
|
|
539
612
|
if [ -n "$blockers" ]; then
|
|
540
613
|
echo "FAIL [reconcile-debt]: thread ${thread} carries OPEN hotfix debt:"
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
614
|
+
# Each owning epic with the full path of its ledger in the Product, so the entry is found at once (#386).
|
|
615
|
+
while IFS= read -r _owner; do
|
|
616
|
+
[ -n "$_owner" ] && echo " ${_owner} — epics/${_owner}/.sdlc/reconcile-debt.json"
|
|
617
|
+
done <<DEBT_OWNERS
|
|
618
|
+
$blockers
|
|
619
|
+
DEBT_OWNERS
|
|
620
|
+
echo " -> Pay it first: update the Shape artifacts + add the regression test, then set each open entry's"
|
|
621
|
+
echo " \"status\" to \"paid\" in each file listed above, in the Product (\`yad reconcile check\` there lists every open entry)."
|
|
622
|
+
echo " The thread is frozen for new changes until then."
|
|
544
623
|
rc=1
|
|
545
624
|
continue
|
|
546
625
|
fi
|
|
@@ -111,7 +111,7 @@ product_config() {
|
|
|
111
111
|
if [ -n "${SDLC_PRODUCT_CONFIG:-}" ]; then printf '%s' "$SDLC_PRODUCT_CONFIG"; return 0; fi
|
|
112
112
|
if [ -n "${SDLC_HUB_CONFIG:-}" ]; then printf '%s' "$SDLC_HUB_CONFIG"; return 0; fi
|
|
113
113
|
if [ -f .sdlc/product.json ] && [ -f .sdlc/hub.json ] && ! cmp -s .sdlc/product.json .sdlc/hub.json; then
|
|
114
|
-
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5.
|
|
114
|
+
echo "FAIL [product-settings]: .sdlc/product.json and .sdlc/hub.json say different things — they are one file under two names until v5. In the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`) to choose the copy to keep, then commit both files." >&2
|
|
115
115
|
return 1
|
|
116
116
|
fi
|
|
117
117
|
if [ -f .sdlc/product.json ]; then printf '%s' .sdlc/product.json; else printf '%s' .sdlc/hub.json; fi
|
|
@@ -120,7 +120,7 @@ product_config() {
|
|
|
120
120
|
# that disagree fail the other gates, but here they are a note, and neither is read.
|
|
121
121
|
# `--level` answers in one line on stdout, so there the note goes to stderr.
|
|
122
122
|
if ! PRODUCT_CONFIG="$(product_config 2>/dev/null)"; then
|
|
123
|
-
_drift="note [risk-map]: .sdlc/product.json and .sdlc/hub.json say different things (or SDLC_PRODUCT_CONFIG and SDLC_HUB_CONFIG do) — neither is read; run \`yad migrate\`
|
|
123
|
+
_drift="note [risk-map]: .sdlc/product.json and .sdlc/hub.json say different things (or SDLC_PRODUCT_CONFIG and SDLC_HUB_CONFIG do) — neither is read; in the Product, run \`yad migrate --apply --keep product\` (or \`--keep hub\`)."
|
|
124
124
|
if [ "$LEVEL_ONLY" = 1 ]; then echo "$_drift" >&2; else echo "$_drift"; fi
|
|
125
125
|
# An empty file, so `resolve_base` reads no default_branch and falls back like a repo with no settings.
|
|
126
126
|
PRODUCT_CONFIG=/dev/null
|