@boyingliu01/xp-gate 0.38.5 → 0.38.7
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/adapters/gate-7.sh +7 -2
- package/build-integrity/gate-10.ts +45 -27
- package/gate-7.sh +7 -2
- package/hooks/gate-7.sh +7 -2
- package/hooks/gate-entries/gate-0-entry.sh +249 -28
- package/hooks/gate-entries/gate-1-entry.sh +81 -3
- package/hooks/gate-entries/gate-10-entry.sh +7 -0
- package/hooks/gate-entries/gate-11-entry.sh +7 -0
- package/hooks/gate-entries/gate-12-entry.sh +7 -0
- package/hooks/gate-entries/gate-12b-entry.sh +7 -0
- package/hooks/gate-entries/gate-12c-entry.sh +7 -0
- package/hooks/gate-entries/gate-13-entry.sh +7 -0
- package/hooks/gate-entries/gate-5-entry.sh +48 -2
- package/hooks/gate-entries/gate-6-entry.sh +93 -2
- package/hooks/gate-entries/gate-7-entry.sh +7 -0
- package/hooks/gate-entries/gate-8-entry.sh +7 -0
- package/hooks/gate-entries/gate-9-entry.sh +7 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/AGENTS.md +1 -1
- package/principles/analyzer.ts +12 -1
- package/principles/config.ts +179 -0
- package/scripts/generate-mirrors.cjs +85 -28
- package/scripts/sync-package-content.js +5 -0
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/build-integrity/__tests__/ccn-refactor-gate10.test.ts +0 -133
- package/build-integrity/__tests__/gate-10.test.ts +0 -340
- package/build-integrity/__tests__/import-resolver.test.ts +0 -747
- package/build-integrity/__tests__/orchestrator.test.ts +0 -302
- package/build-integrity/__tests__/quote-masker.test.ts +0 -177
- package/skills/sprint-flow/__tests__/sprint-flow.test.cjs +0 -457
- package/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +0 -70
package/adapters/gate-7.sh
CHANGED
|
@@ -16,8 +16,13 @@ IAC_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep -
|
|
|
16
16
|
# shellcheck disable=SC2034
|
|
17
17
|
GATE_7_SCANNED_FILES=0
|
|
18
18
|
if [ -z "$IAC_FILES" ]; then
|
|
19
|
-
|
|
20
|
-
GATE_7_STATUS=
|
|
19
|
+
# #800: "nothing to scan" must never be rendered as "scanned and clean".
|
|
20
|
+
# This branch used to print PASSED and set GATE_7_STATUS=PASS, while the report
|
|
21
|
+
# simultaneously carried scanned_files=0 -- the gate contradicted itself, and
|
|
22
|
+
# the PASS was what downstream consumers read. A change set with no IaC file is
|
|
23
|
+
# a SKIP with a reason, exactly like the no-adapter branch below.
|
|
24
|
+
echo "⏭️ SKIPPED - IaC security (no IaC files in this change set)."
|
|
25
|
+
GATE_7_STATUS="SKIP"
|
|
21
26
|
else
|
|
22
27
|
# Consumed by the sourcing parent, not here (see #548).
|
|
23
28
|
# shellcheck disable=SC2034
|
|
@@ -605,37 +605,55 @@ async function packPrecondition(projectRoot: string): Promise<string | null> {
|
|
|
605
605
|
if (!pkgJson.files || !Array.isArray(pkgJson.files)) {
|
|
606
606
|
return 'package.json has no files field — skipping pack check';
|
|
607
607
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
608
|
+
return missingDeclaredArtifacts(projectRoot, pkgJson.files);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* #786: a `files` allowlist that names an output directory (`dist`, `lib`,
|
|
613
|
+
* `build`) describes an artifact a BUILD produces, not something already in the
|
|
614
|
+
* tree. With `noEmit` in tsconfig -- a normal choice when a bundler or a separate
|
|
615
|
+
* build step owns the output -- nothing writes that directory, so `npm pack`
|
|
616
|
+
* ships only package.json, `inspectPackedFiles` reports "only package.json
|
|
617
|
+
* included", and the gate BLOCKS forever with no way out.
|
|
618
|
+
*
|
|
619
|
+
* Absent artifacts are therefore a SKIP with the reason spelled out, not a FAIL:
|
|
620
|
+
* this gate's subject is build integrity, and it cannot judge a package whose
|
|
621
|
+
* inputs were never built. The message also has to name the remedy -- "build
|
|
622
|
+
* first" is the whole fix, and the old text never said it.
|
|
623
|
+
*
|
|
624
|
+
* Extracted from packPrecondition rather than inlined: the inline version took
|
|
625
|
+
* that function to CCN=11 against a recorded 5 (block threshold 10), which Gate 3
|
|
626
|
+
* caught on CI. A ratchet that is satisfied by pushing one function over the line
|
|
627
|
+
* is not satisfied.
|
|
628
|
+
*/
|
|
629
|
+
async function missingDeclaredArtifacts(
|
|
630
|
+
projectRoot: string,
|
|
631
|
+
files: unknown[]
|
|
632
|
+
): Promise<string | null> {
|
|
633
|
+
const declaredEntries = files.filter(
|
|
620
634
|
(entry): entry is string =>
|
|
621
635
|
typeof entry === 'string' && entry !== '' && !entry.startsWith('!') && !entry.includes('*')
|
|
622
636
|
);
|
|
623
|
-
if (declaredEntries.length
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
+
if (declaredEntries.length === 0) {
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
const presence = await Promise.all(
|
|
641
|
+
declaredEntries.map((entry) => pathExists(path.join(projectRoot, entry)))
|
|
642
|
+
);
|
|
643
|
+
if (presence.some(Boolean)) {
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
return `package.json files entries (${declaredEntries.join(', ')}) do not exist on disk — run the build that produces them, then re-run`;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** Existence probe that reports absence instead of throwing. */
|
|
650
|
+
async function pathExists(target: string): Promise<boolean> {
|
|
651
|
+
try {
|
|
652
|
+
await fs.access(target);
|
|
653
|
+
return true;
|
|
654
|
+
} catch {
|
|
655
|
+
return false;
|
|
637
656
|
}
|
|
638
|
-
return null;
|
|
639
657
|
}
|
|
640
658
|
|
|
641
659
|
interface PackFailure {
|
package/gate-7.sh
CHANGED
|
@@ -16,8 +16,13 @@ IAC_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep -
|
|
|
16
16
|
# shellcheck disable=SC2034
|
|
17
17
|
GATE_7_SCANNED_FILES=0
|
|
18
18
|
if [ -z "$IAC_FILES" ]; then
|
|
19
|
-
|
|
20
|
-
GATE_7_STATUS=
|
|
19
|
+
# #800: "nothing to scan" must never be rendered as "scanned and clean".
|
|
20
|
+
# This branch used to print PASSED and set GATE_7_STATUS=PASS, while the report
|
|
21
|
+
# simultaneously carried scanned_files=0 -- the gate contradicted itself, and
|
|
22
|
+
# the PASS was what downstream consumers read. A change set with no IaC file is
|
|
23
|
+
# a SKIP with a reason, exactly like the no-adapter branch below.
|
|
24
|
+
echo "⏭️ SKIPPED - IaC security (no IaC files in this change set)."
|
|
25
|
+
GATE_7_STATUS="SKIP"
|
|
21
26
|
else
|
|
22
27
|
# Consumed by the sourcing parent, not here (see #548).
|
|
23
28
|
# shellcheck disable=SC2034
|
package/hooks/gate-7.sh
CHANGED
|
@@ -16,8 +16,13 @@ IAC_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep -
|
|
|
16
16
|
# shellcheck disable=SC2034
|
|
17
17
|
GATE_7_SCANNED_FILES=0
|
|
18
18
|
if [ -z "$IAC_FILES" ]; then
|
|
19
|
-
|
|
20
|
-
GATE_7_STATUS=
|
|
19
|
+
# #800: "nothing to scan" must never be rendered as "scanned and clean".
|
|
20
|
+
# This branch used to print PASSED and set GATE_7_STATUS=PASS, while the report
|
|
21
|
+
# simultaneously carried scanned_files=0 -- the gate contradicted itself, and
|
|
22
|
+
# the PASS was what downstream consumers read. A change set with no IaC file is
|
|
23
|
+
# a SKIP with a reason, exactly like the no-adapter branch below.
|
|
24
|
+
echo "⏭️ SKIPPED - IaC security (no IaC files in this change set)."
|
|
25
|
+
GATE_7_STATUS="SKIP"
|
|
21
26
|
else
|
|
22
27
|
# Consumed by the sourcing parent, not here (see #548).
|
|
23
28
|
# shellcheck disable=SC2034
|
|
@@ -43,18 +43,45 @@ GATE_0_STATUS="PASS"
|
|
|
43
43
|
|
|
44
44
|
CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null) || CURRENT_BRANCH=""
|
|
45
45
|
CURRENT_BRANCH=$(printf '%s' "$CURRENT_BRANCH" | tr -d '\r\n'); [ -n "$CURRENT_BRANCH" ] || CURRENT_BRANCH="HEAD"
|
|
46
|
-
|
|
46
|
+
# #806 D1: `main` was missing from this list, so the gate ran its check on ZERO
|
|
47
|
+
# commits in any repo whose default branch is `main` -- which is git's own modern
|
|
48
|
+
# default, GitHub's default, and this repository's current branch. Measured on
|
|
49
|
+
# this repo: a commit staging production source with VERSION/CHANGELOG untouched
|
|
50
|
+
# printed "PASSED - Version Consistency Check (non-protected branch: main)".
|
|
51
|
+
# The literal list stays as the baseline for the historical names, but the
|
|
52
|
+
# authoritative answer for "what is the default branch" is git's own local
|
|
53
|
+
# `origin/HEAD`, consulted below -- a repo that renames its default (or inits
|
|
54
|
+
# with `git init -b trunk`) then needs no edit here. Read locally on purpose:
|
|
55
|
+
# `git remote show origin` would hit the network, and a gate must never wait on
|
|
56
|
+
# the network.
|
|
57
|
+
PROTECTED_BRANCHES="main master develop trunk mainline"
|
|
47
58
|
# #711: same shape as the branch/commit captures above — `git rev-parse` can
|
|
48
59
|
# print a partial line before failing, so `|| echo "."` can yield "<something>\n."
|
|
49
60
|
# and every later `cd "$ROOT_DIR"` / path join would silently use a two-line value.
|
|
50
61
|
ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null) || ROOT_DIR=""
|
|
51
62
|
ROOT_DIR=$(printf '%s' "$ROOT_DIR" | tr -d '\r\n'); [ -n "$ROOT_DIR" ] || ROOT_DIR="."
|
|
52
63
|
|
|
64
|
+
# The default branch as this clone records it. `symbolic-ref` resolves the local
|
|
65
|
+
# ref only, so this is free and offline; it is absent in a repo that never
|
|
66
|
+
# fetched (a fresh `git init` has no origin), in which case the literal list above
|
|
67
|
+
# is all the information there is.
|
|
68
|
+
ORIGIN_DEFAULT_BRANCH=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null) || ORIGIN_DEFAULT_BRANCH=""
|
|
69
|
+
# Strip the remote prefix: "origin/main" -> "main".
|
|
70
|
+
ORIGIN_DEFAULT_BRANCH="${ORIGIN_DEFAULT_BRANCH#origin/}"
|
|
71
|
+
ORIGIN_DEFAULT_BRANCH=$(printf '%s' "$ORIGIN_DEFAULT_BRANCH" | tr -d '\r\n')
|
|
72
|
+
|
|
53
73
|
# Optional: project-level .protected-branches config file
|
|
54
74
|
if [ -f "$ROOT_DIR/.protected-branches" ]; then
|
|
55
75
|
PROTECTED_BRANCHES="$PROTECTED_BRANCHES $(cat "$ROOT_DIR/.protected-branches" | tr '\n' ' ')"
|
|
56
76
|
fi
|
|
57
77
|
|
|
78
|
+
# Derived last so an explicit .protected-branches entry cannot be shadowed by a
|
|
79
|
+
# probe failure, and empty values are dropped rather than added as a blank token
|
|
80
|
+
# that would make `[ "$CURRENT_BRANCH" = "" ]` true for a detached HEAD.
|
|
81
|
+
if [ -n "$ORIGIN_DEFAULT_BRANCH" ]; then
|
|
82
|
+
PROTECTED_BRANCHES="$PROTECTED_BRANCHES $ORIGIN_DEFAULT_BRANCH"
|
|
83
|
+
fi
|
|
84
|
+
|
|
58
85
|
is_protected=false
|
|
59
86
|
for branch in $PROTECTED_BRANCHES; do
|
|
60
87
|
if [ "$CURRENT_BRANCH" = "$branch" ]; then
|
|
@@ -113,6 +140,13 @@ if [ "$is_protected" = "true" ]; then
|
|
|
113
140
|
GATE_0_DETAIL="not_selected"
|
|
114
141
|
elif [ "${SKIP_VERSION_CHECK:-}" = "1" ]; then
|
|
115
142
|
echo "⏭️ SKIPPED - Gate 0: Version consistency (SKIP_VERSION_CHECK=1 env var)"
|
|
143
|
+
# #806 D2: this arm used to only echo, so GATE_0_STATUS kept its
|
|
144
|
+
# initialization value of PASS. The report (gate-13-entry.sh) counts PASS and
|
|
145
|
+
# SKIP in different buckets, so a skipped gate inflated the passed count and
|
|
146
|
+
# "skipped" was indistinguishable from "verified" -- the same defect class as
|
|
147
|
+
# #800, which rendered a Gate 7 SKIP as PASSED. Set it explicitly.
|
|
148
|
+
GATE_0_STATUS="SKIP"
|
|
149
|
+
GATE_0_DETAIL="skip_version_check_env"
|
|
116
150
|
else
|
|
117
151
|
for file in $STAGED_FILES; do
|
|
118
152
|
case "$file" in
|
|
@@ -149,61 +183,248 @@ if [ "$is_protected" = "true" ]; then
|
|
|
149
183
|
SYNC_STAGED=$((SYNC_STAGED + 1))
|
|
150
184
|
fi
|
|
151
185
|
done
|
|
152
|
-
# Stage AGENTS.md files with header-only modifications
|
|
186
|
+
# Stage AGENTS.md files with header-only modifications.
|
|
187
|
+
#
|
|
188
|
+
# #806 D4: this used to be `if ! git diff --quiet -- "$agents_file";
|
|
189
|
+
# then git add "$agents_file"; fi`, i.e. ANY modification was treated as
|
|
190
|
+
# a header refresh. A developer with a half-written AGENTS.md section
|
|
191
|
+
# would have it silently folded into an unrelated VERSION-bump commit.
|
|
192
|
+
# The comment said "headers" but the code never checked.
|
|
193
|
+
#
|
|
194
|
+
# sync-version rewrites exactly one line per AGENTS.md -- the pattern
|
|
195
|
+
# `/^\*\*Version:\*\*.*$/m` in scripts/sync-version.cjs -- so the
|
|
196
|
+
# legitimate diff is a single changed line matching that shape. Anything
|
|
197
|
+
# else means the working tree carries edits this commit did not intend to
|
|
198
|
+
# include, and `git add` would commit them on the user's behalf.
|
|
199
|
+
#
|
|
200
|
+
# The check is on the diff's changed lines (`^-`/`^+`, excluding the
|
|
201
|
+
# +++/--- file headers), not on the file content: a body line that happens
|
|
202
|
+
# to start with `**Version:**` is not a header refresh either.
|
|
153
203
|
while IFS= read -r -d '' agents_file; do
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
204
|
+
git diff --quiet -- "$agents_file" 2>/dev/null && continue
|
|
205
|
+
# Changed lines only. `--unified=0` keeps the hunks tight, and the
|
|
206
|
+
# file-header lines are dropped so they cannot be mistaken for content.
|
|
207
|
+
_changed_lines=$(git diff --unified=0 -- "$agents_file" 2>/dev/null \
|
|
208
|
+
| grep -E '^[+-]' | grep -vE '^(\+\+\+|---)')
|
|
209
|
+
if [ -z "$_changed_lines" ]; then
|
|
210
|
+
continue
|
|
211
|
+
fi
|
|
212
|
+
# Every changed line must be a version header (mode change adds none,
|
|
213
|
+
# so an empty diff is already handled above).
|
|
214
|
+
if printf '%s\n' "$_changed_lines" | grep -qvE '^[+-]\*\*Version:\*\*'; then
|
|
215
|
+
echo " ⚠️ NOT auto-staged: $agents_file has changes beyond the version header."
|
|
216
|
+
echo " Stage it yourself if you intend to include them: git add '$agents_file'"
|
|
217
|
+
continue
|
|
157
218
|
fi
|
|
219
|
+
git add "$agents_file"
|
|
220
|
+
SYNC_STAGED=$((SYNC_STAGED + 1))
|
|
158
221
|
done < <(find "$ROOT_DIR" -name 'AGENTS.md' -not -path '*/node_modules/*' -not -path '*/.git/*' -print0)
|
|
159
222
|
echo " auto-staged $SYNC_STAGED file(s) from sync-version (package.json × ≤6 + AGENTS.md headers)"
|
|
160
223
|
else
|
|
161
|
-
|
|
224
|
+
# #806 D3b: this used to warn and CONTINUE, then fall through to
|
|
225
|
+
# "✅ PASSED - (VERSION/CHANGELOG staged)". The step that just failed is
|
|
226
|
+
# exactly the fan-out this branch exists to perform, so continuing meant
|
|
227
|
+
# committing a half-updated version surface under a green Gate 0 -- the
|
|
228
|
+
# failure the gate is named after, reported as success. A version bump
|
|
229
|
+
# whose fan-out did not happen is not a version bump.
|
|
230
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
231
|
+
VERSION CONSISTENCY CHECK (Gate 0)
|
|
232
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
233
|
+
❌ BLOCKED - VERSION is staged but sync-version FAILED, so the version
|
|
234
|
+
surface is only half updated.
|
|
235
|
+
|
|
236
|
+
See the log for the cause:
|
|
237
|
+
/tmp/xp-gate-sync-version.log
|
|
238
|
+
|
|
239
|
+
Fix the failure and retry, or bump the version with the HUD:
|
|
240
|
+
node scripts/sync-version.cjs
|
|
241
|
+
"
|
|
242
|
+
GATE_0_STATUS="BLOCK"
|
|
243
|
+
record_gate_audit "gate-0" "version-consistency" "$GATE_0_STATUS" "1" "$GATE_0_START" "sync_version_failed"
|
|
244
|
+
return 1
|
|
245
|
+
fi
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
# ── #806 D3a: the consistency check the gate is NAMED after ──────────────
|
|
249
|
+
#
|
|
250
|
+
# Everything above only verified that VERSION or CHANGELOG.md was STAGED.
|
|
251
|
+
# Nothing compared the version literals, so the exact drift this gate exists
|
|
252
|
+
# to prevent could sit in a clean checkout while Gate 0 reported PASS.
|
|
253
|
+
# Measured when this was written: the repository WAS consistent
|
|
254
|
+
# (VERSION=0.38.5.0, package.json=0.38.5.0, package-lock.json=0.38.5.0,
|
|
255
|
+
# npm-package + plugin manifests=0.38.5) and nothing asserted it.
|
|
256
|
+
#
|
|
257
|
+
# Two formats, because scripts/sync-version.cjs defines two:
|
|
258
|
+
# FULL --- MAJOR.MINOR.PATCH.MICRO (4 parts) for VERSION, root
|
|
259
|
+
# package.json, and package-lock.json (top-level AND packages[""]).
|
|
260
|
+
# NPM --- the same string minus MICRO (3 parts) for the npm-package and
|
|
261
|
+
# plugin manifests, which npm requires to be semver.
|
|
262
|
+
# Comparing the 3-part group against the 4-part VERSION would flag EVERY
|
|
263
|
+
# correct repository, so the expectation is computed per file, not once.
|
|
264
|
+
_full_version=$(tr -d ' \t\r\n' < "$ROOT_DIR/VERSION" 2>/dev/null)
|
|
265
|
+
if [ -n "$_full_version" ]; then
|
|
266
|
+
# MICRO-stripped form, mirroring `FULL_VERSION.replace(/\.\d+$/, '')`.
|
|
267
|
+
_npm_version=$(printf '%s' "$_full_version" | sed -E 's/\.[0-9]+$//')
|
|
268
|
+
_version_drift=""
|
|
269
|
+
|
|
270
|
+
# A missing file is not drift -- not every project has every manifest, and
|
|
271
|
+
# inventing a failure for an absent optional file would block repositories
|
|
272
|
+
# that legitimately do not carry it. Only a WRONG value is drift.
|
|
273
|
+
for _vf in package.json src/npm-package/package.json \
|
|
274
|
+
plugins/claude-code/.claude-plugin/plugin.json \
|
|
275
|
+
plugins/opencode/package.json plugins/qoder/plugin.json \
|
|
276
|
+
plugins/dsh/package.json; do
|
|
277
|
+
[ -f "$ROOT_DIR/$_vf" ] || continue
|
|
278
|
+
case "$_vf" in
|
|
279
|
+
package.json) _expected="$_full_version" ;;
|
|
280
|
+
*) _expected="$_npm_version" ;;
|
|
281
|
+
esac
|
|
282
|
+
# Extract the top-level "version" string with node when available (JSON
|
|
283
|
+
# is not parseable with sed reliably), falling back to a narrow grep that
|
|
284
|
+
# only accepts a top-level-looking `"version": "x"` on its own line.
|
|
285
|
+
_actual=""
|
|
286
|
+
if command -v node >/dev/null 2>&1; then
|
|
287
|
+
_actual=$(node -e '
|
|
288
|
+
try {
|
|
289
|
+
const j = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"));
|
|
290
|
+
if (j && typeof j.version === "string") process.stdout.write(j.version);
|
|
291
|
+
} catch (e) { /* unparseable: leave empty, reported below */ }
|
|
292
|
+
' "$ROOT_DIR/$_vf" 2>/dev/null)
|
|
293
|
+
fi
|
|
294
|
+
if [ -z "$_actual" ]; then
|
|
295
|
+
# Fallback for environments without node. Deliberately NOT anchored to
|
|
296
|
+
# `^[[:space:]]*"version"`: that only matches pretty-printed JSON, and
|
|
297
|
+
# a minified manifest (`{"version":"1.0.0"}`) then produced "no version
|
|
298
|
+
# field found" for a file that has one -- measured while writing this,
|
|
299
|
+
# where every fixture manifest is minified and the check reported drift
|
|
300
|
+
# on all of them.
|
|
301
|
+
#
|
|
302
|
+
# `grep -m1` limits LINES, not matches: on a minified single-line file
|
|
303
|
+
# it returned every `"version"` occurrence (top-level and any nested
|
|
304
|
+
# one), so the value came back as two concatenated lines and never
|
|
305
|
+
# matched. `head -1` after the extraction keeps exactly the first.
|
|
306
|
+
_actual=$(grep -oE '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$ROOT_DIR/$_vf" 2>/dev/null \
|
|
307
|
+
| head -1 \
|
|
308
|
+
| sed -E 's/.*:[[:space:]]*"([^"]*)"$/\1/')
|
|
309
|
+
fi
|
|
310
|
+
if [ -z "$_actual" ]; then
|
|
311
|
+
_version_drift="${_version_drift}
|
|
312
|
+
- $_vf: no version field found (expected $_expected)"
|
|
313
|
+
elif [ "$_actual" != "$_expected" ]; then
|
|
314
|
+
_version_drift="${_version_drift}
|
|
315
|
+
- $_vf: $_actual (expected $_expected)"
|
|
316
|
+
fi
|
|
317
|
+
done
|
|
318
|
+
|
|
319
|
+
# package-lock.json carries the version twice: the top-level field and
|
|
320
|
+
# packages[""]. Both must match, because npm reads the latter for the root
|
|
321
|
+
# entry and a stale one is the classic half-synced lockfile.
|
|
322
|
+
if [ -f "$ROOT_DIR/package-lock.json" ]; then
|
|
323
|
+
if command -v node >/dev/null 2>&1; then
|
|
324
|
+
_lock_versions=$(node -e '
|
|
325
|
+
try {
|
|
326
|
+
const j = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"));
|
|
327
|
+
const out = [];
|
|
328
|
+
if (j && typeof j.version === "string") out.push("top:" + j.version);
|
|
329
|
+
if (j && j.packages && j.packages[""] && typeof j.packages[""].version === "string") {
|
|
330
|
+
out.push("root:" + j.packages[""].version);
|
|
331
|
+
}
|
|
332
|
+
process.stdout.write(out.join("\n"));
|
|
333
|
+
} catch (e) { /* unparseable: reported as missing below */ }
|
|
334
|
+
' "$ROOT_DIR/package-lock.json" 2>/dev/null)
|
|
335
|
+
if [ -n "$_lock_versions" ]; then
|
|
336
|
+
while IFS= read -r _lv; do
|
|
337
|
+
[ -n "$_lv" ] || continue
|
|
338
|
+
_where="${_lv%%:*}"
|
|
339
|
+
_value="${_lv#*:}"
|
|
340
|
+
if [ "$_value" != "$_full_version" ]; then
|
|
341
|
+
case "$_where" in
|
|
342
|
+
top) _label="package-lock.json (top-level version)" ;;
|
|
343
|
+
root) _label="package-lock.json (packages[\"\"].version)" ;;
|
|
344
|
+
*) _label="package-lock.json ($_where)" ;;
|
|
345
|
+
esac
|
|
346
|
+
_version_drift="${_version_drift}
|
|
347
|
+
- $_label: $_value (expected $_full_version)"
|
|
348
|
+
fi
|
|
349
|
+
done <<EOF
|
|
350
|
+
$_lock_versions
|
|
351
|
+
EOF
|
|
352
|
+
fi
|
|
353
|
+
fi
|
|
354
|
+
fi
|
|
355
|
+
|
|
356
|
+
if [ -n "$_version_drift" ]; then
|
|
357
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
358
|
+
VERSION CONSISTENCY CHECK (Gate 0)
|
|
359
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
360
|
+
❌ BLOCKED - VERSION is $_full_version but these files disagree:$_version_drift
|
|
361
|
+
|
|
362
|
+
Run the fan-out to repair them:
|
|
363
|
+
node scripts/sync-version.cjs
|
|
364
|
+
|
|
365
|
+
#806 D3a: this check exists because the gate is named for it. Before it was
|
|
366
|
+
added, the gate only verified that VERSION was STAGED, so a forgotten
|
|
367
|
+
sync-version left a drifted checkout under a green Gate 0.
|
|
368
|
+
"
|
|
369
|
+
GATE_0_STATUS="BLOCK"
|
|
370
|
+
record_gate_audit "gate-0" "version-consistency" "$GATE_0_STATUS" "1" "$GATE_0_START" "version_drift"
|
|
371
|
+
return 1
|
|
162
372
|
fi
|
|
163
373
|
fi
|
|
164
|
-
|
|
374
|
+
|
|
375
|
+
echo "✅ PASSED - Gate 0: Version Consistency Check (VERSION/CHANGELOG staged, versions consistent)"
|
|
165
376
|
else
|
|
166
377
|
# Check for doc-only changes (no source code files)
|
|
167
378
|
#
|
|
168
379
|
# The extension list must cover every language an adapter supports, not just
|
|
169
380
|
# the C-family languages this repo happens to be written in. It previously
|
|
170
381
|
# stopped at `*.java`, so a staged .kt/.cs/.swift/.dart/.sh/.ps1 file made
|
|
171
|
-
# Gate 0 report "doc-only changes" — and
|
|
172
|
-
#
|
|
173
|
-
# reading green. Found once the Kotlin fixtures
|
|
174
|
-
# (the skips had hidden it): kotlin-gate reported
|
|
175
|
-
# fixture whose only staged file was BadCode.kt.
|
|
382
|
+
# Gate 0 report "doc-only changes" — and every downstream gate that asks
|
|
383
|
+
# "did any code file change?" then said no, so a Kotlin-only commit ran no
|
|
384
|
+
# code gate at all while reading green. Found once the Kotlin fixtures
|
|
385
|
+
# stopped skipping themselves (the skips had hidden it): kotlin-gate reported
|
|
386
|
+
# Gate 0 "doc-only" for a fixture whose only staged file was BadCode.kt.
|
|
387
|
+
#
|
|
388
|
+
# #806 D6: this comment used to say "the doc-only path skips the REST OF THE
|
|
389
|
+
# CHAIN", which is not how it works and would send a maintainer to the wrong
|
|
390
|
+
# place. Gate 0 does not skip anything -- it returns 0 and the driver
|
|
391
|
+
# continues. The skipping happens in each downstream gate, which asks the
|
|
392
|
+
# shared `changed-file-matcher` predicates whether the change set contains
|
|
393
|
+
# anything it should scan (see changed-file-matcher.test.bats: "doc-only
|
|
394
|
+
# staged files skip code, IaC, and SAST gates").
|
|
176
395
|
#
|
|
177
396
|
# Keep this identical to gate-5-entry.sh's CODE_EXTENSIONS, which is the list
|
|
178
397
|
# the coverage gate already trusts. A second hand-maintained copy is exactly
|
|
179
398
|
# how these two drifted apart.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
has_source=true
|
|
190
|
-
;;
|
|
191
|
-
esac
|
|
192
|
-
done
|
|
193
|
-
|
|
194
|
-
# Check for build-tooling-only changes (adapters, scripts, hooks)
|
|
399
|
+
# ONE loop computes both flags.
|
|
400
|
+
#
|
|
401
|
+
# #806 D5: these were two loops over $STAGED_FILES carrying a byte-identical
|
|
402
|
+
# extension list, so the second list could drift from the first without
|
|
403
|
+
# anything noticing -- the same failure mode this block's own comment warns
|
|
404
|
+
# about ("a second hand-maintained copy is exactly how these two drifted
|
|
405
|
+
# apart"). The only difference between them is the build-tooling path
|
|
406
|
+
# carve-out, which belongs to `has_real_source`, so it is applied inline.
|
|
407
|
+
has_source=false
|
|
195
408
|
has_real_source=false
|
|
196
409
|
for file in $STAGED_FILES; do
|
|
197
410
|
case "$file" in
|
|
411
|
+
# Build tooling is source for `has_source` (it is code) but not for
|
|
412
|
+
# `has_real_source` (it needs no VERSION bump) -- so `continue` here
|
|
413
|
+
# skips only the second flag, keeping the single extension list below.
|
|
198
414
|
src/npm-package/adapters/*|src/npm-package/scripts/*|src/npm-package/hooks/*|scripts/*|githooks/adapters/*)
|
|
199
|
-
|
|
415
|
+
has_source=true
|
|
416
|
+
continue
|
|
417
|
+
;;
|
|
200
418
|
*.ts|*.tsx|*.js|*.jsx|*.mjs|*.cjs|*.py|*.go|*.java|*.kt|*.kts|*.cs|*.csx)
|
|
419
|
+
has_source=true
|
|
201
420
|
has_real_source=true
|
|
202
421
|
;;
|
|
203
422
|
*.cpp|*.cc|*.cxx|*.c|*.h|*.hpp|*.swift|*.m|*.mm|*.dart|*.sh|*.ps1)
|
|
423
|
+
has_source=true
|
|
204
424
|
has_real_source=true
|
|
205
425
|
;;
|
|
206
426
|
*.css|*.scss|*.rs)
|
|
427
|
+
has_source=true
|
|
207
428
|
has_real_source=true
|
|
208
429
|
;;
|
|
209
430
|
esac
|
|
@@ -285,7 +285,16 @@ else
|
|
|
285
285
|
# resolver probe, so there is exactly one place that decides it.
|
|
286
286
|
echo "ℹ️ Biome config found but biome is not installed — SKIP Gate 1 Biome."
|
|
287
287
|
echo " Install it with: npm install --save-dev @biomejs/biome"
|
|
288
|
-
return 0
|
|
288
|
+
# #806 G1a: this branch used to `return 0`, which does not "skip the TS
|
|
289
|
+
# Biome half" -- it aborts gate_1_run entirely, so in a multi-language
|
|
290
|
+
# repo every language AFTER typescript was never examined. Measured on a
|
|
291
|
+
# fixture with PROJECT_LANGS="typescript python" and biome absent: the
|
|
292
|
+
# log contained `── Checking typescript ──` and never
|
|
293
|
+
# `── Checking python ──`, while the run reported success. Record the
|
|
294
|
+
# skip and let the loop continue.
|
|
295
|
+
GATE_1_STATUS="SKIP"
|
|
296
|
+
GATE_1_DETAIL="typescript: biome not installed"
|
|
297
|
+
continue
|
|
289
298
|
fi
|
|
290
299
|
if [ "$BIOME_STATUS" -ne 0 ]; then
|
|
291
300
|
# Biome exits 1 with `internalError/io - No files were processed` when the
|
|
@@ -365,6 +374,11 @@ else
|
|
|
365
374
|
if ! command -v ruff &> /dev/null; then
|
|
366
375
|
echo "ℹ️ ruff not available — skipping Python linting"
|
|
367
376
|
echo "⏭️ SKIPPED - Code quality (ruff not available, run: pip install ruff)"
|
|
377
|
+
# #806 G1a: printed a skip but left GATE_1_STATUS at its initial PASS, so the
|
|
378
|
+
# journal recorded "passed" for a check that never ran. The Java branch ten
|
|
379
|
+
# lines away sets WARN for the same situation; this is the same decision.
|
|
380
|
+
GATE_1_STATUS="SKIP"
|
|
381
|
+
GATE_1_DETAIL="python: ruff not installed"
|
|
368
382
|
else
|
|
369
383
|
# Run Ruff (includes syntax check, linting)
|
|
370
384
|
echo "Running Ruff linting (syntax + lint)..."
|
|
@@ -525,6 +539,11 @@ else
|
|
|
525
539
|
if ! command -v golangci-lint &> /dev/null; then
|
|
526
540
|
echo "ℹ️ golangci-lint not available — skipping Go linting"
|
|
527
541
|
echo "⏭️ SKIPPED - Code quality (golangci-lint not available)"
|
|
542
|
+
# #806 G1a: same inherited-PASS defect as the Python arm above. Verified by
|
|
543
|
+
# driving gate_1_run with golangci-lint absent: the skip printed and
|
|
544
|
+
# GATE_1_STATUS stayed "PASS" with an empty DETAIL.
|
|
545
|
+
GATE_1_STATUS="SKIP"
|
|
546
|
+
GATE_1_DETAIL="go: golangci-lint not installed"
|
|
528
547
|
else
|
|
529
548
|
# #534: run golangci-lint over ONLY the staged .go files (incremental),
|
|
530
549
|
# not the whole repo. `golangci-lint run` with no args scans every package
|
|
@@ -795,8 +814,62 @@ else
|
|
|
795
814
|
echo "Running lint check for $CURRENT_LANG..."
|
|
796
815
|
G1L_OUTPUT=""
|
|
797
816
|
G1L_EXIT=0
|
|
798
|
-
|
|
799
|
-
|
|
817
|
+
# #806 G1c: some adapters define `run_lint() { run_static_analysis; }`
|
|
818
|
+
# verbatim (kotlin, cpp, csharp, objectivec), so this arm executed the
|
|
819
|
+
# SAME analysis twice and printed the identical findings twice. Measured
|
|
820
|
+
# on the Kotlin fixture: a single detekt+ktlint pass takes 1.7-2.2 s and
|
|
821
|
+
# the total Gate 1 run took 6.6 s, i.e. roughly 2 s (30%) was pure
|
|
822
|
+
# duplication.
|
|
823
|
+
#
|
|
824
|
+
# Detected by comparing the two function DEFINITIONS, not by naming the
|
|
825
|
+
# languages: a language list here would be hand-maintained and would miss
|
|
826
|
+
# the next adapter that aliases the two -- the same way Gate 0's two
|
|
827
|
+
# hand-copied extension lists drifted apart (#806 D5). `declare -f`
|
|
828
|
+
# prints the body, so identical bodies compare equal.
|
|
829
|
+
#
|
|
830
|
+
# Errs toward doing the work: anything the gate cannot prove identical
|
|
831
|
+
# runs twice, which costs time but never skips verification.
|
|
832
|
+
#
|
|
833
|
+
# `declare -f` prints the function NAME plus its body, so comparing the
|
|
834
|
+
# two outputs directly can never be equal -- measured: kotlin's
|
|
835
|
+
# run_lint declaration is 42 bytes ("run_lint () { run_static_analysis; }")
|
|
836
|
+
# against run_static_analysis's 1710. The name line is therefore stripped
|
|
837
|
+
# from run_lint's declaration and the remaining body is compared with
|
|
838
|
+
# run_static_analysis' BODY. Two shapes have to be recognised, because an
|
|
839
|
+
# alias in this codebase is written both ways:
|
|
840
|
+
# run_lint() { run_static_analysis; } -> body is the call
|
|
841
|
+
# run_lint() { return run_static_analysis; } -> body is `return <call>`
|
|
842
|
+
# Anything else runs normally.
|
|
843
|
+
# Normalise to one line with no blanks. `tr -d ' \t\n'` collapses
|
|
844
|
+
# everything INCLUDING newlines, so no separator can be left behind.
|
|
845
|
+
# The first attempt ended with `tr '\n' ' '`, which left a trailing space
|
|
846
|
+
# ("[run_static_analysis ]") that compared unequal to the expected token,
|
|
847
|
+
# so the detection silently never fired while `bash -n` stayed clean.
|
|
848
|
+
G1_RUN_LINT_BODY=$(declare -f run_lint 2>/dev/null \
|
|
849
|
+
| sed -e '1d' -e '/^[[:space:]]*[{}][[:space:]]*$/d' \
|
|
850
|
+
| tr -d ' \t\n' | sed -e 's/;$//')
|
|
851
|
+
G1_ANALYSIS_BODY=$(declare -f run_static_analysis 2>/dev/null \
|
|
852
|
+
| sed -e '1d' -e '/^[[:space:]]*[{}][[:space:]]*$/d' \
|
|
853
|
+
| tr -d ' \t\n' | sed -e 's/;$//')
|
|
854
|
+
G1_LINT_IS_ANALYSIS=0
|
|
855
|
+
if [ -n "$G1_RUN_LINT_BODY" ]; then
|
|
856
|
+
if [ "$G1_RUN_LINT_BODY" = "run_static_analysis" ] \
|
|
857
|
+
|| [ "$G1_RUN_LINT_BODY" = "returnrun_static_analysis" ]; then
|
|
858
|
+
G1_LINT_IS_ANALYSIS=1
|
|
859
|
+
elif [ -n "$G1_ANALYSIS_BODY" ] && [ "$G1_RUN_LINT_BODY" = "$G1_ANALYSIS_BODY" ]; then
|
|
860
|
+
# A literal copy of the analysis body is also "the same check".
|
|
861
|
+
G1_LINT_IS_ANALYSIS=1
|
|
862
|
+
fi
|
|
863
|
+
fi
|
|
864
|
+
if [ "$G1_LINT_IS_ANALYSIS" -eq 1 ]; then
|
|
865
|
+
# Same check: reuse the verdict already obtained above instead of
|
|
866
|
+
# paying for a second identical tool invocation.
|
|
867
|
+
G1L_EXIT="$G1A_EXIT"
|
|
868
|
+
echo " (lint and static analysis are the same check for $CURRENT_LANG — ran once)"
|
|
869
|
+
else
|
|
870
|
+
G1L_OUTPUT=$(run_lint 2>&1) || G1L_EXIT=$?
|
|
871
|
+
[ -n "$G1L_OUTPUT" ] && printf '%s\n' "$G1L_OUTPUT" | head -30
|
|
872
|
+
fi
|
|
800
873
|
|
|
801
874
|
# The stricter of the two verdicts wins. Note 3 (WARN) must not mask a 1
|
|
802
875
|
# or 2 from the other command: a clean formatter plus a failing analyzer
|
|
@@ -844,6 +917,11 @@ else
|
|
|
844
917
|
# If no adapter exists for this language, skip
|
|
845
918
|
echo "ℹ️ No specific adapter for $CURRENT_LANG — using generic checks if any"
|
|
846
919
|
echo "⏭️ SKIPPED - Code quality (no specific checks for $CURRENT_LANG)"
|
|
920
|
+
# #806 G1a: an unhandled language reported SKIP in prose and PASS in the
|
|
921
|
+
# journal. This is the arm that covers every language xp-gate has no
|
|
922
|
+
# adapter for, so it was the single widest inherited-PASS hole in Gate 1.
|
|
923
|
+
GATE_1_STATUS="SKIP"
|
|
924
|
+
GATE_1_DETAIL="${CURRENT_LANG}: no adapter"
|
|
847
925
|
fi
|
|
848
926
|
;;
|
|
849
927
|
esac
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
# stop: see scripts/wrap-gate-entries.cjs for why the two are equivalent
|
|
28
28
|
# here, and why sub-shell exits are deliberately left as `exit`.
|
|
29
29
|
gate_10_run() {
|
|
30
|
+
if ! gate_enabled 10; then
|
|
31
|
+
echo "⏭️ SKIPPED - Gate 10: SAST security (not selected by XP_GATE_ONLY_GATE)"
|
|
32
|
+
GATE_10_STATUS="SKIP"
|
|
33
|
+
GATE_10_DETAIL="not_selected"
|
|
34
|
+
return 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
30
37
|
if any_changed_files_match "\.(ts|tsx|js|jsx|py|go|java|kt|cpp|c|swift|m|dart|sh|ps1|psm1|cs|csx|fs|vb|rs|php|rb|lua|pl)$"; then
|
|
31
38
|
if [ -f "$GATE_DIR/gate-10.sh" ]; then
|
|
32
39
|
source "$GATE_DIR/gate-10.sh"
|
|
@@ -26,6 +26,13 @@
|
|
|
26
26
|
# stop: see scripts/wrap-gate-entries.cjs for why the two are equivalent
|
|
27
27
|
# here, and why sub-shell exits are deliberately left as `exit`.
|
|
28
28
|
gate_11_run() {
|
|
29
|
+
if ! gate_enabled 11; then
|
|
30
|
+
echo "⏭️ SKIPPED - Gate 11: Sprint flow (not selected by XP_GATE_ONLY_GATE)"
|
|
31
|
+
GATE_11_STATUS="SKIP"
|
|
32
|
+
GATE_11_DETAIL="not_selected"
|
|
33
|
+
return 0
|
|
34
|
+
fi
|
|
35
|
+
|
|
29
36
|
GATE_11_START=$(gate_start_ms)
|
|
30
37
|
GATE_11_STATUS="PASS"
|
|
31
38
|
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
# stop: see scripts/wrap-gate-entries.cjs for why the two are equivalent
|
|
28
28
|
# here, and why sub-shell exits are deliberately left as `exit`.
|
|
29
29
|
gate_12_run() {
|
|
30
|
+
if ! gate_enabled 12; then
|
|
31
|
+
echo "⏭️ SKIPPED - Gate 12: File hygiene (not selected by XP_GATE_ONLY_GATE)"
|
|
32
|
+
GATE_12_STATUS="SKIP"
|
|
33
|
+
GATE_12_DETAIL="not_selected"
|
|
34
|
+
return 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
30
37
|
if [ -f "$GATE_DIR/gate-12-file-hygiene.sh" ]; then
|
|
31
38
|
source "$GATE_DIR/gate-12-file-hygiene.sh"
|
|
32
39
|
elif [ -f "$(git rev-parse --show-toplevel 2>/dev/null)/githooks/gate-12-file-hygiene.sh" ]; then
|