@boyingliu01/xp-gate 0.36.1 → 0.37.1
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/cpp.sh +78 -10
- package/adapters/csharp.sh +58 -3
- package/adapters/gate-3.sh +15 -5
- package/adapters/gate-8.sh +131 -9
- package/adapters/typescript.sh +32 -8
- package/build-integrity/__tests__/import-resolver.test.ts +257 -0
- package/build-integrity/__tests__/quote-masker.test.ts +177 -0
- package/build-integrity/gate-10.ts +127 -9
- package/build-integrity/quote-masker.ts +266 -0
- package/gate-10.sh +66 -0
- package/gate-12-file-hygiene.sh +15 -7
- package/gate-13-compiler-strictness.sh +81 -1
- package/gate-3.sh +15 -5
- package/gate-6-layers.sh +375 -0
- package/gate-8.sh +131 -9
- package/hooks/gate-10.sh +66 -0
- package/hooks/gate-12-file-hygiene.sh +15 -7
- package/hooks/gate-13-compiler-strictness.sh +81 -1
- package/hooks/gate-3.sh +15 -5
- package/hooks/gate-6-layers.sh +375 -0
- package/hooks/gate-8.sh +131 -9
- package/hooks/gate-registry.sh +2 -2
- package/hooks/hook-module-resolution.sh +1 -1
- package/hooks/lib/assertion-quality.sh +8 -2
- package/hooks/lib/ccn-ratchet.sh +10 -0
- package/hooks/lib/layer-baseline.cjs +88 -0
- package/hooks/lib/typecheck.sh +28 -5
- package/hooks/pre-commit +376 -53
- package/hooks/pre-push +46 -13
- package/lib/__tests__/agent-runtime-journal.test.js +1 -1
- package/lib/__tests__/arch.test.js +9 -0
- package/lib/__tests__/audit-cli-contract.test.ts +1 -1
- package/lib/__tests__/check-alignment-reasons.test.mjs +11 -1
- package/lib/__tests__/check-all-skip-accounting.test.js +1 -1
- package/lib/__tests__/detect-deps-gate-identity.test.js +135 -0
- package/lib/__tests__/detect-deps.test.js +2 -1
- package/lib/__tests__/doctor-469-hook-env.test.js +7 -1
- package/lib/__tests__/doctor-arch-tools.test.js +169 -0
- package/lib/__tests__/doctor-delphi.test.js +1 -1
- package/lib/__tests__/doctor-drift-round2.test.js +4 -1
- package/lib/__tests__/doctor-executed-surface.test.js +45 -24
- package/lib/__tests__/doctor-module-drift.test.js +13 -7
- package/lib/__tests__/doctor-module-resolution-parity.test.js +74 -2
- package/lib/__tests__/doctor-tui-skill-freshness.test.js +21 -6
- package/lib/__tests__/doctor.test.js +17 -0
- package/lib/__tests__/gate-runner-tsx-invocation.test.js +149 -0
- package/lib/__tests__/gate-runner.test.js +23 -7
- package/lib/__tests__/init-gitignore.test.js +204 -0
- package/lib/__tests__/init.test.js +24 -3
- package/lib/__tests__/language-tools-build-file-install.test.js +82 -0
- package/lib/__tests__/language-tools-detect.test.js +61 -0
- package/lib/__tests__/mirror-sync.test.js +2 -0
- package/lib/__tests__/phase-transition.test.js +19 -1
- package/lib/__tests__/sprint-status-rework.test.js +32 -12
- package/lib/__tests__/test-alignment-range-guard.test.ts +82 -0
- package/lib/__tests__/test-alignment.test.ts +13 -3
- package/lib/__tests__/update-skill.test.js +2 -2
- package/lib/detect-deps.js +7 -1
- package/lib/doctor.js +81 -17
- package/lib/gate-runner.js +101 -7
- package/lib/hook-module-resolution.js +18 -6
- package/lib/init.js +136 -1
- package/lib/language-tools.js +217 -1
- package/lib/layer-baseline.cjs +88 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/principles.js +21 -6
- package/lib/test-alignment.ts +452 -55
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +2 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/delphi-review/INSTALL.md +29 -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/.delphi-config.json.example +34 -24
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/delphi-review/INSTALL.md +29 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/src/client.test.ts +1 -1
- package/plugins/dsh/src/command.test.ts +1 -1
- package/plugins/dsh/src/contract.test.ts +1 -1
- package/plugins/dsh/src/credentials.test.ts +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/delphi-review/INSTALL.md +29 -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/.delphi-config.json.example +34 -24
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/delphi-review/INSTALL.md +29 -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/__tests__/config-arch-group.test.ts +106 -0
- package/principles/__tests__/config-enforcement.test.ts +1 -1
- package/principles/adapters/control-nesting.ts +572 -0
- package/principles/adapters/csharp.ts +73 -42
- package/principles/adapters/java.ts +9 -5
- package/principles/adapters/typescript.ts +138 -176
- package/principles/config.ts +37 -2
- package/principles/index.ts +57 -4
- package/principles/reporter.ts +99 -65
- package/principles/rules/arch/__tests__/dependency.test.ts +180 -0
- package/principles/rules/arch/__tests__/naming.test.ts +133 -0
- package/principles/rules/arch/__tests__/shared.test.ts +113 -0
- package/principles/rules/arch/dependency.ts +264 -0
- package/principles/rules/arch/naming.ts +188 -0
- package/principles/rules/arch/shared.ts +169 -0
- package/principles/rules/exports.ts +26 -0
- package/principles/rules/index.ts +11 -18
- package/scripts/__tests__/sync-package-content.test.js +23 -1
- package/scripts/sync-package-content.js +8 -2
- package/skills/delphi-review/.delphi-config.json.example +34 -24
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/delphi-review/INSTALL.md +29 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
package/hooks/pre-commit
CHANGED
|
@@ -229,13 +229,19 @@ fi
|
|
|
229
229
|
PROJECT_GITHOOKS="$(run_without_git_context git rev-parse --show-toplevel 2>/dev/null)/githooks"
|
|
230
230
|
GATES_DIR="$SCRIPT_DIR/gates"
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
232
|
+
# ADAPTER_DIR decides which tree every later lookup searches, so its ORDER comes
|
|
233
|
+
# from HOOK_ADAPTER_DIR_TIERS (generated from lib/hook-module-resolution.js) and
|
|
234
|
+
# never from a cascade typed here. This block used to be a hand-written
|
|
235
|
+
# `if global ... elif project ...`, which meant the generated table was loaded and
|
|
236
|
+
# then ignored: flipping the spec to project-first changed nothing at runtime
|
|
237
|
+
# while the data file and doctor both already reported the new order.
|
|
238
|
+
#
|
|
239
|
+
# _hook_resolve, not _hook_resolve_dir: the ADAPTER table's third field is the
|
|
240
|
+
# probe FILENAME ('adapter-common.sh'), so resolving it as a module template is
|
|
241
|
+
# what yields "<tier_dir>/adapter-common.sh". _hook_resolve_dir treats that field
|
|
242
|
+
# as a directory suffix and would build "<tier_dir>adapter-common.sh/...".
|
|
243
|
+
ADAPTER_DIR="$(_hook_resolve 'adapter-common' HOOK_ADAPTER_DIR_TIERS)" || ADAPTER_DIR="$SCRIPT_DIR"
|
|
244
|
+
ADAPTER_DIR="${ADAPTER_DIR%/adapter-common.sh}"
|
|
239
245
|
source "$ADAPTER_DIR/adapter-common.sh" 2>/dev/null || {
|
|
240
246
|
echo "Error: Cannot source adapter-common.sh from $ADAPTER_DIR"
|
|
241
247
|
echo "Run: xp-gate init (per-project) or xp-gate setup-global (all projects)"
|
|
@@ -558,6 +564,48 @@ gate_start_ms() {
|
|
|
558
564
|
now_ms
|
|
559
565
|
}
|
|
560
566
|
|
|
567
|
+
# ── A2: run a SUBSET of gates, for iteration speed ────────────────────────
|
|
568
|
+
#
|
|
569
|
+
# A full commit takes ~26 s on an idle box, and the time is spread evenly across
|
|
570
|
+
# gates that have nothing to do with each other (measured: startup 3.5 s,
|
|
571
|
+
# Gate 1 4.8 s, Gate 2 3.1 s, Gate 4 4.2 s, Gate 5 2.1 s). While iterating on one
|
|
572
|
+
# gate you re-run all of them to re-check one, which is the single largest
|
|
573
|
+
# avoidable cost in the edit→commit loop.
|
|
574
|
+
#
|
|
575
|
+
# XP_GATE_ONLY_GATE=4,5 git commit ... # run only Gates 4 and 5
|
|
576
|
+
# XP_GATE_ONLY_GATE=1 git commit ... # re-check lint only
|
|
577
|
+
#
|
|
578
|
+
# Everything not named is reported as SKIP with detail "not_selected", and the
|
|
579
|
+
# SKIP goes through record_gate_audit exactly like every other skip — so the
|
|
580
|
+
# journal can never read a deselected gate as a passing one. That is the whole
|
|
581
|
+
# point: a filter that silently dropped gates would produce green history for
|
|
582
|
+
# checks that never ran.
|
|
583
|
+
#
|
|
584
|
+
# Deliberately NOT offered on protected branches: the escape-valve precedent in
|
|
585
|
+
# this file is that narrowing what a commit is checked against is a local
|
|
586
|
+
# iteration tool, not something that reaches main.
|
|
587
|
+
XP_GATE_ONLY_GATE_STATE=""
|
|
588
|
+
gate_selection_active() {
|
|
589
|
+
if [ -z "$XP_GATE_ONLY_GATE_STATE" ]; then
|
|
590
|
+
if [ -n "${XP_GATE_ONLY_GATE:-}" ]; then
|
|
591
|
+
XP_GATE_ONLY_GATE_STATE="active"
|
|
592
|
+
else
|
|
593
|
+
XP_GATE_ONLY_GATE_STATE="inactive"
|
|
594
|
+
fi
|
|
595
|
+
fi
|
|
596
|
+
[ "$XP_GATE_ONLY_GATE_STATE" = "active" ]
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
# True when gate $1 should run in this invocation. Empty XP_GATE_ONLY_GATE means
|
|
600
|
+
# "run everything", which is the only state a real commit should be in.
|
|
601
|
+
gate_enabled() {
|
|
602
|
+
gate_selection_active || return 0
|
|
603
|
+
case ",${XP_GATE_ONLY_GATE//[[:space:]]/}," in
|
|
604
|
+
*",$1,"*) return 0 ;;
|
|
605
|
+
*) return 1 ;;
|
|
606
|
+
esac
|
|
607
|
+
}
|
|
608
|
+
|
|
561
609
|
# ---------------------------------------------------------------------------
|
|
562
610
|
# #537: per-language coverage classification.
|
|
563
611
|
#
|
|
@@ -890,6 +938,25 @@ for branch in $PROTECTED_BRANCHES; do
|
|
|
890
938
|
fi
|
|
891
939
|
done
|
|
892
940
|
|
|
941
|
+
# A2 guard: narrowing the gate set is a local iteration tool, never a way to
|
|
942
|
+
# commit onto a protected branch with fewer checks. Same reasoning as
|
|
943
|
+
# SKIP_GATE_5A_BLOCK's main/master refusal further down, and refused outright
|
|
944
|
+
# rather than silently ignored so a scripted `XP_GATE_ONLY_GATE=1 git commit` on
|
|
945
|
+
# main cannot quietly appear to have run the full chain.
|
|
946
|
+
if gate_selection_active && [ "$is_protected" = true ]; then
|
|
947
|
+
echo ""
|
|
948
|
+
echo "❌ BLOCKED - XP_GATE_ONLY_GATE=${XP_GATE_ONLY_GATE} is not allowed on protected branch '$CURRENT_BRANCH'."
|
|
949
|
+
echo " Run the full gate chain here: unset XP_GATE_ONLY_GATE."
|
|
950
|
+
exit 1
|
|
951
|
+
fi
|
|
952
|
+
|
|
953
|
+
if gate_selection_active; then
|
|
954
|
+
echo ""
|
|
955
|
+
echo "⚠️ PARTIAL GATE RUN — XP_GATE_ONLY_GATE=${XP_GATE_ONLY_GATE} (branch: $CURRENT_BRANCH)"
|
|
956
|
+
echo " Gates not named are recorded as SKIP/not_selected, never as PASS."
|
|
957
|
+
echo " This commit has NOT been checked against the gates it skips."
|
|
958
|
+
fi
|
|
959
|
+
|
|
893
960
|
has_version_change=false
|
|
894
961
|
has_changelog_change=false
|
|
895
962
|
|
|
@@ -916,7 +983,11 @@ export XP_STAGED_ACM
|
|
|
916
983
|
if [ "$is_protected" = "true" ]; then
|
|
917
984
|
# Env var bypass: SKIP_VERSION_CHECK=1 skips Gate 0 entirely
|
|
918
985
|
# Useful for: SKIP_VERSION_CHECK=1 git commit -m "chore: ..."
|
|
919
|
-
if
|
|
986
|
+
if ! gate_enabled 0; then
|
|
987
|
+
echo "⏭️ SKIPPED - Gate 0: Version consistency (not selected by XP_GATE_ONLY_GATE)"
|
|
988
|
+
GATE_0_STATUS="SKIP"
|
|
989
|
+
GATE_0_DETAIL="not_selected"
|
|
990
|
+
elif [ "${SKIP_VERSION_CHECK:-}" = "1" ]; then
|
|
920
991
|
echo "⏭️ SKIPPED - Gate 0: Version consistency (SKIP_VERSION_CHECK=1 env var)"
|
|
921
992
|
else
|
|
922
993
|
for file in $STAGED_FILES; do
|
|
@@ -1650,7 +1721,11 @@ fi
|
|
|
1650
1721
|
GATE_1_START=$(gate_start_ms)
|
|
1651
1722
|
GATE_1_STATUS="PASS"
|
|
1652
1723
|
GATE_1_DETAIL=""
|
|
1653
|
-
if !
|
|
1724
|
+
if ! gate_enabled 1; then
|
|
1725
|
+
echo "⏭️ SKIPPED - Gate 1: Code quality (not selected by XP_GATE_ONLY_GATE)"
|
|
1726
|
+
GATE_1_STATUS="SKIP"
|
|
1727
|
+
GATE_1_DETAIL="not_selected"
|
|
1728
|
+
elif ! any_changed_files_match "\.(ts|tsx|js|jsx|py|go|java|kt|cpp|c|swift|m|mm|dart|sh|ps1|psm1)$" "\.ya?ml$" "\.json$" "Dockerfile" "\.tf$"; then
|
|
1654
1729
|
echo "✅ PASSED - No code files changed, skipping lint."
|
|
1655
1730
|
GATE_1_STATUS="SKIP"
|
|
1656
1731
|
GATE_1_DETAIL="no_matching_files"
|
|
@@ -2252,47 +2327,100 @@ else
|
|
|
2252
2327
|
;;
|
|
2253
2328
|
|
|
2254
2329
|
*)
|
|
2255
|
-
# Route to appropriate adapter for other languages
|
|
2330
|
+
# Route to appropriate adapter for other languages.
|
|
2331
|
+
#
|
|
2332
|
+
# #776: this arm used to PRINT findings and then leave GATE_1_STATUS
|
|
2333
|
+
# untouched. An adapter returning 1 -- "I ran and found violations" -- got
|
|
2334
|
+
# one cosmetic "may be non-blocking" line, then `⏭️ SKIPPED ... (tools
|
|
2335
|
+
# unavailable or failed)`, and the gate ended PASS. Every language without
|
|
2336
|
+
# its own arm above (C#, C/C++, Objective-C, Swift, Kotlin, Go, Python,
|
|
2337
|
+
# Dart, Flutter) was therefore fail-open, and the java/powershell arms' one
|
|
2338
|
+
# hard-won verdict protocol (#507 S1, #547, #717) was reachable by exactly
|
|
2339
|
+
# two languages.
|
|
2340
|
+
#
|
|
2341
|
+
# Why that matters for adoption, measured in a real project: a net8.0
|
|
2342
|
+
# project with TreatWarningsAsErrors=true + WarningLevel=9999 whose
|
|
2343
|
+
# `dotnet format --verify-no-changes` FAILED produced the three lines above
|
|
2344
|
+
# and a PASS. The project's own build.sh hard-failed on the identical tree,
|
|
2345
|
+
# so the gate was strictly weaker than the compiler it was meant to
|
|
2346
|
+
# institutionalise -- the exact opposite of the purpose of a shared gate.
|
|
2347
|
+
#
|
|
2348
|
+
# The protocol now applies here verbatim, per adapter verdict:
|
|
2349
|
+
# 0 = PASS 1 = BLOCK (ran, found problems) 2 = BLOCK (could not
|
|
2350
|
+
# execute, fail-closed) 3 = WARN (skipped for a stated reason, stays in
|
|
2351
|
+
# the scoring denominator so an unmeasured language is visible).
|
|
2352
|
+
#
|
|
2353
|
+
# Two mechanics are load-bearing and copied together, because either one
|
|
2354
|
+
# alone is a defect:
|
|
2355
|
+
# - The verdict is captured into a variable, NOT read from `cmd | head`.
|
|
2356
|
+
# #706 fixed `$?` becoming head's status; the java arm documents the
|
|
2357
|
+
# remaining trap: a long report makes the writer die of SIGPIPE, so the
|
|
2358
|
+
# verdict would depend on how much output happened to be produced. The
|
|
2359
|
+
# `|| G1R_EXIT=$?` form (not a bare assignment) keeps a non-zero verdict
|
|
2360
|
+
# from aborting the host hook under set -e before it is mapped.
|
|
2361
|
+
# - Reasons cross the command-substitution subshell as `XP_G1_REASON:`
|
|
2362
|
+
# stdout lines, since an `export` in the adapter can never reach this
|
|
2363
|
+
# process (#507 Delphi round-1 B-MAJOR-1).
|
|
2256
2364
|
ADAPTER_FILE=$(resolve_adapter_path "$CURRENT_LANG")
|
|
2257
2365
|
if [ -n "$ADAPTER_FILE" ] && source "$ADAPTER_FILE" 2>/dev/null; then
|
|
2258
2366
|
echo "Running static analysis for $CURRENT_LANG..."
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
# PASSED. PIPESTATUS[0] carries the adapter's real status.
|
|
2266
|
-
run_static_analysis | head -30 2>/dev/null
|
|
2267
|
-
ANALYSIS_EXIT=${PIPESTATUS[0]}
|
|
2268
|
-
if [ "$ANALYSIS_EXIT" -ne 0 ]; then
|
|
2269
|
-
echo "⚠️ Static analysis had issues (may be non-blocking)"
|
|
2367
|
+
G1A_OUTPUT=""
|
|
2368
|
+
G1A_EXIT=0
|
|
2369
|
+
G1A_OUTPUT=$(run_static_analysis 2>&1) || G1A_EXIT=$?
|
|
2370
|
+
G1A_REASON=$(printf '%s\n' "$G1A_OUTPUT" | sed -n 's/^XP_G1_REASON: //p' | head -1)
|
|
2371
|
+
if [ -n "$G1A_REASON" ]; then
|
|
2372
|
+
G1A_OUTPUT=$(printf '%s\n' "$G1A_OUTPUT" | grep -v '^XP_G1_REASON: ')
|
|
2270
2373
|
fi
|
|
2374
|
+
[ -n "$G1A_OUTPUT" ] && printf '%s\n' "$G1A_OUTPUT" | head -30
|
|
2271
2375
|
|
|
2272
2376
|
echo "Running lint check for $CURRENT_LANG..."
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
#
|
|
2280
|
-
#
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
# named in the log instead of implied.
|
|
2286
|
-
if [ "$ANALYSIS_EXIT" -eq 2 ] || [ "$LINT_EXIT" -eq 2 ]; then
|
|
2287
|
-
echo "⏭️ SKIPPED - Code quality (${CURRENT_LANG} toolchain could not execute — NOT a pass)"
|
|
2288
|
-
fi
|
|
2377
|
+
G1L_OUTPUT=""
|
|
2378
|
+
G1L_EXIT=0
|
|
2379
|
+
G1L_OUTPUT=$(run_lint 2>&1) || G1L_EXIT=$?
|
|
2380
|
+
[ -n "$G1L_OUTPUT" ] && printf '%s\n' "$G1L_OUTPUT" | head -30
|
|
2381
|
+
|
|
2382
|
+
# The stricter of the two verdicts wins. Note 3 (WARN) must not mask a 1
|
|
2383
|
+
# or 2 from the other command: a clean formatter plus a failing analyzer
|
|
2384
|
+
# is still a failing source tree.
|
|
2385
|
+
case "${G1L_EXIT}" in
|
|
2386
|
+
1|2) G1_VERDICT="$G1L_EXIT" ;;
|
|
2387
|
+
*) G1_VERDICT="$G1A_EXIT" ;;
|
|
2388
|
+
esac
|
|
2289
2389
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2390
|
+
case "$G1_VERDICT" in
|
|
2391
|
+
0)
|
|
2392
|
+
echo "✅ PASSED - Language-specific code quality checks."
|
|
2393
|
+
;;
|
|
2394
|
+
1)
|
|
2395
|
+
echo "❌ BLOCKED - ${CURRENT_LANG} code quality violations (fix or add suppressions)"
|
|
2396
|
+
GATE_1_STATUS="BLOCK"
|
|
2397
|
+
GATE_1_DETAIL="${CURRENT_LANG}: analyzer findings"
|
|
2398
|
+
exit 1
|
|
2399
|
+
;;
|
|
2400
|
+
2)
|
|
2401
|
+
# The substring "(… could not execute — NOT a pass)" is kept from the
|
|
2402
|
+
# #717 wording: issue-717-mirror-parity.test.bats asserts that exact
|
|
2403
|
+
# text in the npm mirror. An earlier draft of this rewrite dropped it
|
|
2404
|
+
# and turned a green main red — the contract is the string, not the
|
|
2405
|
+
# author's preference for how to phrase it.
|
|
2406
|
+
echo "❌ BLOCKED - ${CURRENT_LANG} toolchain could not execute — NOT a pass (fail-closed): ${G1A_REASON:-unknown}"
|
|
2407
|
+
echo " A tool that could not run is not a clean tree. Install the toolchain,"
|
|
2408
|
+
echo " or set the adapter's documented escape valve if you accept the risk."
|
|
2409
|
+
GATE_1_STATUS="BLOCK"
|
|
2410
|
+
GATE_1_DETAIL="${CURRENT_LANG}: ${G1A_REASON:-unusable}"
|
|
2411
|
+
exit 1
|
|
2412
|
+
;;
|
|
2413
|
+
3)
|
|
2414
|
+
echo "⚠️ WARN - ${CURRENT_LANG} code quality NOT verified: ${G1A_REASON:-adapter reported a non-blocking skip}"
|
|
2415
|
+
GATE_1_STATUS="WARN"
|
|
2416
|
+
GATE_1_DETAIL="${CURRENT_LANG}: ${G1A_REASON:-unavailable (warn)}"
|
|
2417
|
+
;;
|
|
2418
|
+
*)
|
|
2419
|
+
echo "⚠️ WARN - ${CURRENT_LANG} code quality NOT verified (unexpected verdict $G1_VERDICT)"
|
|
2420
|
+
GATE_1_STATUS="WARN"
|
|
2421
|
+
GATE_1_DETAIL="${CURRENT_LANG}: unexpected verdict $G1_VERDICT"
|
|
2422
|
+
;;
|
|
2423
|
+
esac
|
|
2296
2424
|
else
|
|
2297
2425
|
# If no adapter exists for this language, skip
|
|
2298
2426
|
echo "ℹ️ No specific adapter for $CURRENT_LANG — using generic checks if any"
|
|
@@ -2319,7 +2447,12 @@ record_gate_audit "gate-1" "code-quality" "$GATE_1_STATUS" "0" "$GATE_1_START" "
|
|
|
2319
2447
|
GATE_2_START=$(gate_start_ms)
|
|
2320
2448
|
GATE_2_STATUS="PASS"
|
|
2321
2449
|
|
|
2322
|
-
if
|
|
2450
|
+
if ! gate_enabled 2; then
|
|
2451
|
+
echo "⏭️ SKIPPED - Gate 2: Duplicate code (not selected by XP_GATE_ONLY_GATE)"
|
|
2452
|
+
GATE_2_STATUS="SKIP"
|
|
2453
|
+
GATE_2_DETAIL="not_selected"
|
|
2454
|
+
|
|
2455
|
+
elif [ "$PROJECT_LANG" = "documentation-only" ] || [ "$DOCS_ONLY_COMMIT" = true ]; then
|
|
2323
2456
|
echo "⏭️ SKIPPED - Duplicate code (documentation-only ${DOCS_ONLY_COMMIT:+commit})."
|
|
2324
2457
|
GATE_2_STATUS="SKIP"
|
|
2325
2458
|
# GATE_2_DETAIL feeds record_gate_audit's detail field. The previous
|
|
@@ -2479,13 +2612,42 @@ record_gate_audit "gate-2" "duplicate-code" "$GATE_2_STATUS" "0" "$GATE_2_START"
|
|
|
2479
2612
|
# GATE 3: Cyclomatic Complexity Check
|
|
2480
2613
|
# Extracted to gate-3.sh for maintainability
|
|
2481
2614
|
# ============================================================================
|
|
2482
|
-
|
|
2615
|
+
#
|
|
2616
|
+
# A2 gates the SOURCE, not a branch inside gate-3.sh. GATE_DIR resolves through
|
|
2617
|
+
# three tiers and, on an installed machine, lands on
|
|
2618
|
+
# ~/.config/xp-gate/adapters/ -- a COPY that predates this change. An edit
|
|
2619
|
+
# inside gate-N.sh is therefore inert exactly where it matters most, which is
|
|
2620
|
+
# the same trap githooks/AGENTS.md documents for the hooks themselves (verified:
|
|
2621
|
+
# a build here reports GATE_DIR=/c/Users/think/.config/xp-gate/adapters, whose
|
|
2622
|
+
# gate-4.sh has none of this change). Checking here works against either copy.
|
|
2623
|
+
if gate_enabled 3; then
|
|
2624
|
+
source "$GATE_DIR/gate-3.sh"
|
|
2625
|
+
else
|
|
2626
|
+
echo ""
|
|
2627
|
+
echo "→ Gate 3: Cyclomatic complexity..."
|
|
2628
|
+
echo "⏭️ SKIPPED - Gate 3: Complexity (not selected by XP_GATE_ONLY_GATE)"
|
|
2629
|
+
GATE_3_START=$(gate_start_ms)
|
|
2630
|
+
GATE_3_STATUS="SKIP"
|
|
2631
|
+
GATE_3_REASON="not_selected"
|
|
2632
|
+
record_gate_audit "gate-3" "complexity" "$GATE_3_STATUS" "0" "$GATE_3_START" "not_selected"
|
|
2633
|
+
fi
|
|
2483
2634
|
|
|
2484
2635
|
# ============================================================================
|
|
2485
2636
|
# GATE 4: Principles Checker (Clean Code + SOLID)
|
|
2486
2637
|
# Extracted to gate-4.sh for maintainability
|
|
2487
2638
|
# ============================================================================
|
|
2488
|
-
|
|
2639
|
+
if gate_enabled 4; then
|
|
2640
|
+
source "$GATE_DIR/gate-4.sh"
|
|
2641
|
+
else
|
|
2642
|
+
echo ""
|
|
2643
|
+
echo "→ Gate 4: Principles checker..."
|
|
2644
|
+
echo "⏭️ SKIPPED - Gate 4: Principles (not selected by XP_GATE_ONLY_GATE)"
|
|
2645
|
+
GATE_4_START=$(gate_start_ms)
|
|
2646
|
+
GATE_4_STATUS="SKIP"
|
|
2647
|
+
GATE_4_REASON="not_selected"
|
|
2648
|
+
WARNING_COUNT=0
|
|
2649
|
+
record_gate_audit "gate-4" "principles" "$GATE_4_STATUS" "0" "$GATE_4_START" "not_selected"
|
|
2650
|
+
fi
|
|
2489
2651
|
|
|
2490
2652
|
# ============================================================================
|
|
2491
2653
|
# GATE 5: Tests & Coverage Combined (Combines Old Gates 3 - Tests and 4 - Coverage)
|
|
@@ -2509,7 +2671,12 @@ GATE_5_START=$(gate_start_ms)
|
|
|
2509
2671
|
# assign at all.
|
|
2510
2672
|
GATE_5_STATUS=""
|
|
2511
2673
|
|
|
2512
|
-
if
|
|
2674
|
+
if ! gate_enabled 5; then
|
|
2675
|
+
echo "⏭️ SKIPPED - Gate 5: Tests & coverage (not selected by XP_GATE_ONLY_GATE)"
|
|
2676
|
+
GATE_5_STATUS="SKIP"
|
|
2677
|
+
GATE_5_DETAIL="not_selected"
|
|
2678
|
+
|
|
2679
|
+
elif [ "$PROJECT_LANG" = "documentation-only" ] || [ "$DOCS_ONLY_COMMIT" = true ]; then
|
|
2513
2680
|
echo "⏭️ SKIPPED - Tests & coverage (documentation-only commit — no code changed to test)."
|
|
2514
2681
|
GATE_5_STATUS="SKIP"
|
|
2515
2682
|
GATE_5_DETAIL="docs_only_change"
|
|
@@ -3042,7 +3209,13 @@ else
|
|
|
3042
3209
|
# or similar non-code files, skip the test run entirely.
|
|
3043
3210
|
# Gate 5a (new file pairing) and 5b (mock density) are cheap and still run.
|
|
3044
3211
|
# ============================================================================
|
|
3045
|
-
|
|
3212
|
+
# #763: `cs`/`csx` were missing from this list, so a commit touching ONLY C#
|
|
3213
|
+
# files produced an empty CHANGED_CODE_FILES and took the "no code files
|
|
3214
|
+
# changed" early skip below -- the full test suite never ran, and the absence
|
|
3215
|
+
# of a test result was reported as the absence of a need for one. The
|
|
3216
|
+
# Principles extensions list got `.cs` in ac214d38; this one was left behind,
|
|
3217
|
+
# which is why the C# arm looked like it worked while Gate 5 stood down.
|
|
3218
|
+
CODE_EXTENSIONS="\.(ts|tsx|js|jsx|mjs|cjs|py|go|java|kt|kts|cs|csx|cpp|cc|cxx|c|h|hpp|swift|m|mm|dart|sh|ps1)$"
|
|
3046
3219
|
CHANGED_CODE_FILES=$(echo "$CHANGED_FILES" | grep -E "$CODE_EXTENSIONS" || true)
|
|
3047
3220
|
if [ -z "$CHANGED_CODE_FILES" ]; then
|
|
3048
3221
|
# #554: this branch DID stand down deliberately, but "PASS" is a claim that
|
|
@@ -3131,6 +3304,7 @@ else
|
|
|
3131
3304
|
handle_test_failure "$TESTS_OUTPUT" "full test suite" || exit 1
|
|
3132
3305
|
else
|
|
3133
3306
|
echo "✅ PASSED - Full test suite passed (with coverage)."
|
|
3307
|
+
TESTS_RAN_ANY=true
|
|
3134
3308
|
fi
|
|
3135
3309
|
elif [ "$CHANGED_TEST_FILE_COUNT" -gt 0 ] 2>/dev/null; then
|
|
3136
3310
|
# Run only changed test files with coverage
|
|
@@ -3148,6 +3322,7 @@ else
|
|
|
3148
3322
|
handle_test_failure "$TESTS_OUTPUT" "changed test files" || exit 1
|
|
3149
3323
|
else
|
|
3150
3324
|
echo "✅ PASSED - Changed test files passed (with coverage)."
|
|
3325
|
+
TESTS_RAN_ANY=true
|
|
3151
3326
|
fi
|
|
3152
3327
|
elif [ "$CHANGED_SRC_COUNT" -gt 0 ] 2>/dev/null; then
|
|
3153
3328
|
# Source files changed but no test files → find related tests or run full
|
|
@@ -3190,6 +3365,7 @@ else
|
|
|
3190
3365
|
handle_test_failure "$TESTS_OUTPUT" "related test files" || exit 1
|
|
3191
3366
|
else
|
|
3192
3367
|
echo "✅ PASSED - Related test files passed (with coverage)."
|
|
3368
|
+
TESTS_RAN_ANY=true
|
|
3193
3369
|
fi
|
|
3194
3370
|
else
|
|
3195
3371
|
# No related tests found → full run is safest
|
|
@@ -3201,6 +3377,7 @@ else
|
|
|
3201
3377
|
handle_test_failure "$TESTS_OUTPUT" "full test suite" || exit 1
|
|
3202
3378
|
else
|
|
3203
3379
|
echo "✅ PASSED - Full test suite passed (with coverage)."
|
|
3380
|
+
TESTS_RAN_ANY=true
|
|
3204
3381
|
fi
|
|
3205
3382
|
fi
|
|
3206
3383
|
else
|
|
@@ -3254,6 +3431,9 @@ else
|
|
|
3254
3431
|
fi
|
|
3255
3432
|
else
|
|
3256
3433
|
echo "✅ PASSED - Unit tests passed."
|
|
3434
|
+
# #760: a runner really executed for this language, so the coverage
|
|
3435
|
+
# guard below must not treat this pass as "nothing was measured".
|
|
3436
|
+
TESTS_RAN_ANY=true
|
|
3257
3437
|
fi
|
|
3258
3438
|
fi
|
|
3259
3439
|
fi
|
|
@@ -3268,7 +3448,25 @@ else
|
|
|
3268
3448
|
fi # End: if [ -n "$CHANGED_CODE_FILES" ] (Issue #312 early skip)
|
|
3269
3449
|
|
|
3270
3450
|
# Next, run coverage check (skip if tests were skipped — Issue #312)
|
|
3271
|
-
|
|
3451
|
+
#
|
|
3452
|
+
# #760: TESTS_SKIPPED is one global flag written inside the per-language test
|
|
3453
|
+
# loop, but it is read HERE, outside that loop. A project that resolves to
|
|
3454
|
+
# several languages therefore had its coverage check cancelled by whichever
|
|
3455
|
+
# language stood down first -- and the loop order is the detection order, not
|
|
3456
|
+
# a statement about which language matters.
|
|
3457
|
+
#
|
|
3458
|
+
# Measured on a real repo (.xp-gate-config.json -> typescript, shell, csharp):
|
|
3459
|
+
# the typescript arm found no changed .ts file, set TESTS_SKIPPED=true, and the
|
|
3460
|
+
# csharp arm's dotnet test result (139 passing, full coverage data present) was
|
|
3461
|
+
# then discarded with "Test run was skipped — skipping coverage check". Gate 5
|
|
3462
|
+
# reported a PASS on a coverage floor it never evaluated.
|
|
3463
|
+
#
|
|
3464
|
+
# The flag now only speaks for language selection that produced nothing at all:
|
|
3465
|
+
# if any language actually RAN tests, coverage is evaluated for every language
|
|
3466
|
+
# that has an adapter. Languages that ran nothing fall through to their own
|
|
3467
|
+
# adapter's coverage branch, which already distinguishes "no evidence" (a
|
|
3468
|
+
# documented failure) from "not applicable" (iac).
|
|
3469
|
+
if [ "${TESTS_SKIPPED:-false}" = "true" ] && [ "${TESTS_RAN_ANY:-false}" != "true" ]; then
|
|
3272
3470
|
echo "ℹ️ Test run was skipped — skipping coverage check."
|
|
3273
3471
|
else
|
|
3274
3472
|
echo "Running coverage check..."
|
|
@@ -3908,6 +4106,52 @@ else
|
|
|
3908
4106
|
# Simple fallback: check lcov for coverage percentage
|
|
3909
4107
|
COVERAGE_PERCENT=$(grep -oP 'coverage: \K[0-9]+%' coverage/lcov.info 2>/dev/null | head -1 | tr -d '%') || COVERAGE_PERCENT=""
|
|
3910
4108
|
fi
|
|
4109
|
+
else
|
|
4110
|
+
# #768: Cobertura is what the .NET/C# and several JVM toolchains actually
|
|
4111
|
+
# emit -- `dotnet test --collect:"XPlat Code Coverage"` writes ONE
|
|
4112
|
+
# cobertura XML per test target under TestResults/<guid>/coverage.cobertura.xml,
|
|
4113
|
+
# never coverage-summary.json or lcov.info. This branch only knew the two
|
|
4114
|
+
# JS-oriented filenames, so a C# project with full coverage data fell into
|
|
4115
|
+
# "Could not determine coverage percentage" and was BLOCKED with an
|
|
4116
|
+
# instruction to "produce coverage data" it had already produced.
|
|
4117
|
+
#
|
|
4118
|
+
# Discovery order: the conventional root file first, then the newest
|
|
4119
|
+
# TestResults artifact, so both `coverlet`'s default layout and a
|
|
4120
|
+
# hand-placed report work. Newest-first matters because TestResults
|
|
4121
|
+
# accumulates one directory per run and an old report must not win.
|
|
4122
|
+
_cob_file=""
|
|
4123
|
+
for _candidate in coverage/cobertura.xml coverage.cobertura.xml coverage/coverage.cobertura.xml; do
|
|
4124
|
+
if [ -f "$_candidate" ]; then _cob_file="$_candidate"; break; fi
|
|
4125
|
+
done
|
|
4126
|
+
if [ -z "$_cob_file" ]; then
|
|
4127
|
+
_cob_file=$(find . -name 'coverage.cobertura.xml' \
|
|
4128
|
+
-path '*TestResults*' -not -path './.git/*' 2>/dev/null \
|
|
4129
|
+
| while IFS= read -r _f; do printf '%s\t%s\n' "$(stat -c %Y "$_f" 2>/dev/null || stat -f %m "$_f" 2>/dev/null || echo 0)" "$_f"; done \
|
|
4130
|
+
| sort -rn | head -1 | cut -f2-)
|
|
4131
|
+
fi
|
|
4132
|
+
if [ -n "$_cob_file" ] && [ -f "$_cob_file" ]; then
|
|
4133
|
+
# Cobertura's root <coverage line-rate="..."> is the fraction covered
|
|
4134
|
+
# (0..1) and is authoritative; summing per-class lines double-counts.
|
|
4135
|
+
# A report that exists but has no parseable line-rate is `parse_error`,
|
|
4136
|
+
# which the caller treats as "no evidence" rather than 0% -- 0% would
|
|
4137
|
+
# be a *measured* value and block with the wrong reason.
|
|
4138
|
+
COVERAGE_PERCENT=$(node -e "
|
|
4139
|
+
try {
|
|
4140
|
+
const fs = require('fs');
|
|
4141
|
+
const xml = fs.readFileSync(process.argv[1], 'utf8');
|
|
4142
|
+
const root = xml.match(/<coverage\b[^>]*>/);
|
|
4143
|
+
if (!root) { console.log('parse_error'); process.exit(0); }
|
|
4144
|
+
const rate = root[0].match(/line-rate\s*=\s*[\"']([0-9.]+)[\"']/);
|
|
4145
|
+
if (!rate) { console.log('parse_error'); process.exit(0); }
|
|
4146
|
+
const value = Number(rate[1]);
|
|
4147
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) { console.log('parse_error'); process.exit(0); }
|
|
4148
|
+
console.log(Math.round(value * 100));
|
|
4149
|
+
} catch (e) { console.log('parse_error'); }
|
|
4150
|
+
" "$_cob_file" 2>/dev/null) || COVERAGE_PERCENT=""
|
|
4151
|
+
if [ -n "$COVERAGE_PERCENT" ] && [ "$COVERAGE_PERCENT" != "parse_error" ]; then
|
|
4152
|
+
echo " (coverage source: $_cob_file)"
|
|
4153
|
+
fi
|
|
4154
|
+
fi
|
|
3911
4155
|
fi
|
|
3912
4156
|
# #579: `-ge 0`, not `-gt 0`. A measured 0% is DATA -- coverage.py ran and
|
|
3913
4157
|
# covered nothing -- not a missing value. Folding it into the
|
|
@@ -4109,10 +4353,71 @@ else
|
|
|
4109
4353
|
# return "supported" no matter what. File presence is the only honest input.
|
|
4110
4354
|
GATE_6_LAYERS_UNCHECKED=0
|
|
4111
4355
|
if [ -f "$PROJECT_ROOT/architecture.yaml" ] || [ -f "$PROJECT_ROOT/.architecturerc" ]; then
|
|
4356
|
+
# The declaration is now read by a checker of our own, so the warning
|
|
4357
|
+
# below is no longer "nothing looked at this" — it is "archlint did not".
|
|
4358
|
+
# The verdict on layer boundaries comes from gate-6-layers.sh; this flag
|
|
4359
|
+
# only records that archlint's generic-smell pass measured no layers.
|
|
4112
4360
|
GATE_6_LAYERS_UNCHECKED=1
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4361
|
+
fi
|
|
4362
|
+
|
|
4363
|
+
# Layer-boundary enforcement (#686 / #691 / #728).
|
|
4364
|
+
# This runs in addition to archlint, not instead of it: archlint checks
|
|
4365
|
+
# generic smells (cycles, god modules, dead code) and its layer_violation
|
|
4366
|
+
# detector is a measured no-op, so the dependency direction has to be
|
|
4367
|
+
# checked directly. The checker always builds the whole-repo import graph —
|
|
4368
|
+
# a layer violation is an edge between two directories, so an incremental
|
|
4369
|
+
# per-directory scan structurally cannot see one.
|
|
4370
|
+
LAYER_CHECKER=""
|
|
4371
|
+
if [ -f "$GATE_DIR/gate-6-layers.sh" ]; then
|
|
4372
|
+
LAYER_CHECKER="$GATE_DIR/gate-6-layers.sh"
|
|
4373
|
+
elif [ -f "$(git rev-parse --show-toplevel 2>/dev/null)/githooks/gate-6-layers.sh" ]; then
|
|
4374
|
+
LAYER_CHECKER="$(git rev-parse --show-toplevel)/githooks/gate-6-layers.sh"
|
|
4375
|
+
fi
|
|
4376
|
+
if [ -n "$LAYER_CHECKER" ]; then
|
|
4377
|
+
LAYER_OUT=$(cd "$PROJECT_ROOT" && bash "$LAYER_CHECKER" 2>&1)
|
|
4378
|
+
LAYER_RC=$?
|
|
4379
|
+
printf '%s\n' "$LAYER_OUT" | sed 's/^/ /'
|
|
4380
|
+
case "$LAYER_RC" in
|
|
4381
|
+
0)
|
|
4382
|
+
GATE_6_LAYER_STATUS="PASS"
|
|
4383
|
+
;;
|
|
4384
|
+
1)
|
|
4385
|
+
GATE_6_LAYER_STATUS="FAIL"
|
|
4386
|
+
GATE_6_STATUS="FAIL"
|
|
4387
|
+
;;
|
|
4388
|
+
2)
|
|
4389
|
+
# Config present but unusable: fail closed. Reporting PASS here is the
|
|
4390
|
+
# exact defect #686 documented, one level deeper.
|
|
4391
|
+
GATE_6_LAYER_STATUS="BLOCK"
|
|
4392
|
+
GATE_6_STATUS="FAIL"
|
|
4393
|
+
;;
|
|
4394
|
+
3)
|
|
4395
|
+
# WARN (no layer config, or only baselined violations).
|
|
4396
|
+
GATE_6_LAYER_STATUS="WARN"
|
|
4397
|
+
;;
|
|
4398
|
+
*)
|
|
4399
|
+
# Any other exit means the checker itself did not complete: 126/127
|
|
4400
|
+
# (not executable / not found), 137 (killed), or a bash error. Mapping
|
|
4401
|
+
# those to WARN would let a crashed checker pass as "not checked",
|
|
4402
|
+
# which is #686's defect one level deeper — the gate would look like it
|
|
4403
|
+
# covered layers while nothing ran. Fail closed.
|
|
4404
|
+
GATE_6_LAYER_STATUS="BLOCK"
|
|
4405
|
+
GATE_6_STATUS="FAIL"
|
|
4406
|
+
GATE_6_LAYER_REASON="layer_checker_crashed_rc_${LAYER_RC}"
|
|
4407
|
+
GATE_6_LAYER_CRASHED=1
|
|
4408
|
+
;;
|
|
4409
|
+
esac
|
|
4410
|
+
GATE_6_LAYER_REASON=${GATE_6_LAYER_REASON:-$(printf '%s\n' "$LAYER_OUT" | sed -n 's/^ *reason: *//p' | head -1)}
|
|
4411
|
+
else
|
|
4412
|
+
# The checker is missing, so the dimension is unmeasured — say so rather
|
|
4413
|
+
# than letting the gate look like it covered layers.
|
|
4414
|
+
GATE_6_LAYER_STATUS="WARN"
|
|
4415
|
+
GATE_6_LAYER_REASON="layer_checker_missing"
|
|
4416
|
+
echo " ⚠️ [WARN:LAYER_CHECKER_MISSING] gate-6-layers.sh not found — layer boundaries NOT checked."
|
|
4417
|
+
fi
|
|
4418
|
+
if [ "${GATE_6_LAYER_CRASHED:-0}" = "1" ]; then
|
|
4419
|
+
echo " ❌ [BLOCK:LAYER_CHECKER_CRASHED] gate-6-layers.sh exited $LAYER_RC without a verdict."
|
|
4420
|
+
echo " A checker that did not finish has not checked anything — fail closed."
|
|
4116
4421
|
fi
|
|
4117
4422
|
# #537: per-language reason bookkeeping. Gate 3/4 are single-language gates
|
|
4118
4423
|
# and get away with one scalar reason; Gate 6 loops, so a scalar would lose
|
|
@@ -5064,7 +5369,14 @@ fi
|
|
|
5064
5369
|
# first place.
|
|
5065
5370
|
# ============================================================================
|
|
5066
5371
|
MIRROR_STAGED=$(git diff --cached --name-only --diff-filter=ACMR 2>/dev/null || true)
|
|
5067
|
-
|
|
5372
|
+
# `src/npm-package/` is in this filter because a mirror-only edit is the
|
|
5373
|
+
# dangerous direction, not the harmless one. Keying off the canonical paths
|
|
5374
|
+
# alone meant staging just the mirror skipped the whole block, so a fix written
|
|
5375
|
+
# into the published copy could be committed while its source stayed wrong --
|
|
5376
|
+
# v0.27.3 shipped exactly that (#542). The reverse mapping below resolves each
|
|
5377
|
+
# staged mirror back to its canonical file and compares the pair either way.
|
|
5378
|
+
if [ -n "$MIRROR_STAGED" ] && printf '%s
|
|
5379
|
+
' "$MIRROR_STAGED" | grep -qE '^(githooks/|plugins/[^/]+/src/|src/npm-package/(adapters|hooks|principles|build-integrity)/)'; then
|
|
5068
5380
|
# Reuse PROJECT_ROOT: `git rev-parse` costs ~90ms per fork on Windows and this
|
|
5069
5381
|
# gate must not add two of them to every commit (#640).
|
|
5070
5382
|
MIRROR_REPO_ROOT="${PROJECT_ROOT:-}"
|
|
@@ -5096,6 +5408,15 @@ if [ -n "$MIRROR_STAGED" ] && printf '%s\n' "$MIRROR_STAGED" | grep -qE '^(githo
|
|
|
5096
5408
|
githooks/adapters/*) _mm="src/npm-package/adapters/${_mf#githooks/adapters/}" ;;
|
|
5097
5409
|
githooks/*) _mm="src/npm-package/hooks/${_mf#githooks/}" ;;
|
|
5098
5410
|
plugins/*/src/*) _mm=$(printf '%s' "$_mf" | sed 's|^plugins/\([^/]*\)/src/|src/npm-package/plugins/\1/src/|') ;;
|
|
5411
|
+
# Reverse direction: the staged file IS the mirror. Resolve it back to
|
|
5412
|
+
# the canonical file and let the same comparison below decide. Without
|
|
5413
|
+
# this arm the widened filter above matches nothing and the gate stays
|
|
5414
|
+
# blind to a mirror-only edit -- the v0.27.3 shape (#542).
|
|
5415
|
+
src/npm-package/adapters/*) _mf="githooks/adapters/${_mf#src/npm-package/adapters/}"; _mm="src/npm-package/adapters/${_mf#githooks/adapters/}" ;;
|
|
5416
|
+
src/npm-package/hooks/lib/*) _mf="githooks/lib/${_mf#src/npm-package/hooks/lib/}"; _mm="src/npm-package/hooks/lib/${_mf#githooks/lib/}" ;;
|
|
5417
|
+
src/npm-package/hooks/*) _mf="githooks/${_mf#src/npm-package/hooks/}"; _mm="src/npm-package/hooks/${_mf#githooks/}" ;;
|
|
5418
|
+
src/npm-package/principles/*) _mf="src/principles/${_mf#src/npm-package/principles/}"; _mm="src/npm-package/principles/${_mf#src/principles/}" ;;
|
|
5419
|
+
src/npm-package/build-integrity/*) _mf="src/build-integrity/${_mf#src/npm-package/build-integrity/}"; _mm="src/npm-package/build-integrity/${_mf#src/build-integrity/}" ;;
|
|
5099
5420
|
*) continue ;;
|
|
5100
5421
|
esac
|
|
5101
5422
|
if [ ! -f "$MIRROR_REPO_ROOT/$_mm" ]; then
|
|
@@ -5532,6 +5853,8 @@ generate_quality_report() {
|
|
|
5532
5853
|
"status": "${GATE_10_STATUS:-SKIP}",
|
|
5533
5854
|
"reason": "${GATE_10_REASON:-}",
|
|
5534
5855
|
"scanned_files": ${GATE_10_SCANNED_FILES:-0},
|
|
5856
|
+
"path": "${GATE_10_SEMGREP_PATH:-direct}",
|
|
5857
|
+
"degraded": ${GATE_10_SASTD_DEGRADED:-0},
|
|
5535
5858
|
"tool": "semgrep"
|
|
5536
5859
|
},
|
|
5537
5860
|
"gate11_sprint_flow": {
|