@boyingliu01/xp-gate 0.38.45 → 0.38.47

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.
@@ -497,6 +497,31 @@ gate13_count_warnings() {
497
497
  printf '%s\n' "$(( ${warnings:-0} + ${errors:-0} ))"
498
498
  }
499
499
 
500
+ # Count ONLY compiler errors -- a translation unit that does not compile.
501
+ #
502
+ # Separate from gate13_count_warnings on purpose. The two questions are different:
503
+ # gate13_count_warnings -> "is this file worse than clean?" (baseline ratchet)
504
+ # gate13_count_errors -> "does this file compile at all?" (absolute)
505
+ #
506
+ # The ratchet legitimately tolerates a known warning count, and a file with no
507
+ # baseline entry is report-only so that adopting the gate does not mean fixing
508
+ # every pre-existing warning first. Neither exemption may extend to an ERROR:
509
+ # pre-existing errors are not "debt to adopt", and code that does not build has no
510
+ # business being committed.
511
+ #
512
+ # Measured 2026-11-19 with the language matrix, cpp fixture:
513
+ # a.cpp = `int main() { return not_a_symbol; }`
514
+ # g++: "error: 'not_a_symbol' was not declared in this scope"
515
+ # Gate 13: SKIP (no baseline) -> the error was not reported at all
516
+ # The file had a baseline-eligible path only because it was MODIFIED rather than
517
+ # added, which is the ordinary case for every existing project.
518
+ gate13_count_errors() {
519
+ local cc="$1" flags="$2" file="$3" out
520
+ # shellcheck disable=SC2086 # flags is a deliberately word-split flag list
521
+ out=$("$cc" -fsyntax-only $flags "$file" 2>&1)
522
+ printf '%s\n' "$(printf '%s\n' "$out" | grep -E 'error:' | grep -vcE '^\s*$' || true)"
523
+ }
524
+
500
525
  # ============================================================================
501
526
  # JAVA PATH (REQ-004)
502
527
  #
@@ -1388,6 +1413,28 @@ gate13_run_cpp_analysis() {
1388
1413
  if [ -z "$base" ]; then
1389
1414
  baseline_seen=1
1390
1415
  cnt=$(gate13_count_warnings "$cxx" "$flags" "$f")
1416
+ # Report-only applies to the RATCHET, not to compilability. A modified file
1417
+ # with no baseline entry is exempt from "no worse than before", because
1418
+ # adopting the gate must not mean clearing every pre-existing warning first.
1419
+ # It is not exempt from compiling: an error is not inherited debt, it is a
1420
+ # file that does not build.
1421
+ #
1422
+ # Measured 2026-11-19 (language matrix, cpp fixture):
1423
+ # a.cpp = int main() { return not_a_symbol; }
1424
+ # g++ "error: 'not_a_symbol' was not declared in this scope"
1425
+ # gate: "0 warning(s) (no baseline entry, report-only)" -> commit allowed
1426
+ _g13_errs=$(gate13_count_errors "$cxx" "$flags" "$f")
1427
+ _g13_errs=${_g13_errs:-0}
1428
+ if [ "$_g13_errs" -gt 0 ]; then
1429
+ findings=$((findings + _g13_errs))
1430
+ if [ "$tier" = "warn-only" ]; then
1431
+ echo " ⚠️ ${f}: does NOT compile (${_g13_errs} error(s)); warn-only tier, not blocking"
1432
+ else
1433
+ echo " ❌ ${f}: does NOT compile (${_g13_errs} error(s)) — a missing baseline is no excuse"
1434
+ blocking=$((blocking + 1))
1435
+ fi
1436
+ continue
1437
+ fi
1391
1438
  echo " ℹ️ ${f}: ${cnt:-0} warning(s) (no baseline entry, report-only)"
1392
1439
  continue
1393
1440
  fi
@@ -28,7 +28,72 @@ gate8_cleanup() {
28
28
  rm -f "${GATE8_TEMP[@]}" 2>/dev/null
29
29
  fi
30
30
  }
31
- trap gate8_cleanup EXIT
31
+ # CHAIN the previous EXIT trap instead of replacing it.
32
+ #
33
+ # Measured 2026-11-19: `trap gate8_cleanup EXIT` overwrote whatever trap was
34
+ # already installed. pre-commit installs `_quality_report_on_exit` at its top
35
+ # precisely so that a BLOCKED commit still writes its report, and Gate 8 runs
36
+ # before the blocking gates -- so from the moment Gate 8 ran, that trap was gone.
37
+ #
38
+ # The consequence is the worst possible shape: a commit that PASSES writes its
39
+ # report (the epilogue calls generate_quality_report directly), and a commit that
40
+ # is BLOCKED writes nothing. The one run an operator needs to diagnose is the one
41
+ # with no record.
42
+ #
43
+ # Reproduced in a go fixture: the chain stopped at Gate 5, and
44
+ #
45
+ # ls .xp-gate/reports/pre-commit | wc -l -> 0
46
+ #
47
+ # while the same fixture with XP_GATE_ONLY_GATE=8 (chain completes) produced 1.
48
+ # Reading the live trap at the end of the hook showed `trap -- 'gate8_cleanup'
49
+ # EXIT` -- the report trap had been replaced, not chained.
50
+ #
51
+ # `trap -p EXIT` prints a form that can be eval'd back, which is the same
52
+ # technique pre-commit's own source_gate_lib uses to survive a sourced library
53
+ # that installs a trap. The difference here: that library wants to REINSTALL the
54
+ # old trap, whereas this gate has to RUN it, so only the command body is kept.
55
+ #
56
+ # Stripping matters and was caught by the test, not by reading: evaluating the
57
+ # whole string ("trap -- 'cmd' EXIT") reinstalls the old trap instead of invoking
58
+ # it, so the chain silently did nothing and the report still went missing.
59
+ _GATE8_PREV_EXIT_TRAP=""
60
+ _gate8_raw_trap="$(trap -p EXIT 2>/dev/null || true)"
61
+ if [ -n "$_gate8_raw_trap" ]; then
62
+ _gate8_body="${_gate8_raw_trap#trap -- }" # drop 'trap -- '
63
+ _gate8_body="${_gate8_body% EXIT}" # drop the trailing ' EXIT'
64
+ _gate8_body="${_gate8_body#\'}" # drop the surrounding quotes
65
+ _gate8_body="${_gate8_body%\'}"
66
+ _GATE8_PREV_EXIT_TRAP="$_gate8_body"
67
+ fi
68
+
69
+ gate8_cleanup_and_chain() {
70
+ # CAPTURE $? FIRST, then RESTORE it before handing control on.
71
+ #
72
+ # pre-commit's `_quality_report_on_exit` reads `$?` as its very first statement
73
+ # and exits with that status -- that is what makes the hook exit non-zero when a
74
+ # gate blocked. Running cleanup first overwrote $? with the status of `rm`, so
75
+ # the chained trap saw 0 and the hook exited 0.
76
+ #
77
+ # Measured 2026-11-19, go fixture, Gate 5 blocked (coverage 0%):
78
+ # before any fix : commit refused (rc=1), report NOT written
79
+ # chain without restoring : commit ALLOWED (rc=0), report written
80
+ #
81
+ # The second row is a WORSE bug than the one being fixed -- a chain that
82
+ # preserves the report by letting blocked commits through. `( exit N )` on its
83
+ # own does not help (the subshell's status is discarded), but it does set $? to
84
+ # N for the next command in this shell, which is what the eval below observes.
85
+ # Verified directly: a chained trap reading $? after this sequence sees the
86
+ # original status, and the hook still exits with it.
87
+ local _g8_saved=$?
88
+ gate8_cleanup
89
+ if [ -n "${_GATE8_PREV_EXIT_TRAP:-}" ]; then
90
+ (exit "$_g8_saved")
91
+ eval "$_GATE8_PREV_EXIT_TRAP"
92
+ return "$_g8_saved"
93
+ fi
94
+ return "$_g8_saved"
95
+ }
96
+ trap gate8_cleanup_and_chain EXIT
32
97
 
33
98
  # Gitleaks availability check
34
99
  GITLEAKS_CMD=""
@@ -90,9 +155,13 @@ GITLEAKS_REPORT="${TMPDIR:-/tmp}/gitleaks-report.json"
90
155
  rm -f "$GITLEAKS_REPORT"
91
156
  if [ "${GATE_SCOPE:-diff}" = "all" ]; then
92
157
  echo " Scope: --all (scanning the working tree, not the index)"
158
+ # GITLEAKS_CONFIG is either empty or a single --config=PATH token; quoting it
159
+ # would pass an empty argument to gitleaks. It is split on purpose.
160
+ # shellcheck disable=SC2086
93
161
  GITLEAKS_OUTPUT=$($GITLEAKS_CMD dir --no-git --redact --no-banner $GITLEAKS_CONFIG --report-format=json --report-path="$GITLEAKS_REPORT" 2>&1)
94
162
  GITLEAKS_EXIT=$?
95
163
  else
164
+ # shellcheck disable=SC2086 # see above: empty or one --config= token
96
165
  GITLEAKS_OUTPUT=$($GITLEAKS_CMD git --staged --redact --no-banner $GITLEAKS_CONFIG --report-format=json --report-path="$GITLEAKS_REPORT" 2>&1)
97
166
  GITLEAKS_EXIT=$?
98
167
  fi
@@ -380,7 +380,26 @@ ENDJSON
380
380
  fi
381
381
 
382
382
  # ── Persistent per-run report (Issue #101) ────────────────────────────────────────
383
- local REPORTS_DIR=".xp-gate/reports/pre-commit"
383
+ #
384
+ # The report directory is resolved against the REPOSITORY ROOT, not the current
385
+ # working directory.
386
+ #
387
+ # Measured 2026-11-19: this was `local REPORTS_DIR=".xp-gate/reports/pre-commit"`.
388
+ # It worked in the repository it was written in -- and silently wrote the report
389
+ # into /d/projects/xp-gate/.xp-gate/ when the hook ran from a different project
390
+ # (a fixture under /tmp). The commit itself was graded correctly; only the report
391
+ # went somewhere nobody would look, so a reader of the fixture saw "no report"
392
+ # and concluded the gates never ran.
393
+ #
394
+ # That is the same failure shape as the rest of this file: the behaviour was
395
+ # right and the record was unreachable. `generate_quality_report` is called from
396
+ # the EXIT trap, where the working directory is whatever the last gate left
397
+ # behind -- it is not a place to depend on relativity.
398
+ local _xp_report_root="${PROJECT_ROOT:-}"
399
+ if [ -z "$_xp_report_root" ] || [ ! -d "$_xp_report_root" ]; then
400
+ _xp_report_root=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
401
+ fi
402
+ local REPORTS_DIR="${_xp_report_root}/.xp-gate/reports/pre-commit"
384
403
  local REPORT_TS
385
404
  REPORT_TS=$(date -u +"%Y-%m-%d-%H%M%S")
386
405
  local PERSISTED_REPORT_FILE="${REPORTS_DIR}/${REPORT_TS}.json"
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-19T18:14:45.056Z",
5
+ "checked_at": "2026-11-19T19:10:14.898Z",
6
6
  "source": "network"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.38.45",
3
+ "version": "0.38.47",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.38.45",
3
+ "version": "0.38.47",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/dsh-plugin-xp-gate",
3
- "version": "0.38.45",
3
+ "version": "0.38.47",
4
4
  "description": "XP-Gate deterministic quality gates + AI workflow skills as a DeepSeek Harness (DSH) native plugin: gate-check / gate-principles / gate-arch tools + 12 SKILL.md skills",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.38.45",
3
+ "version": "0.38.47",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.45.0
6
+ **Version:** 0.38.47.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.