@boyingliu01/xp-gate 0.38.28 → 0.38.30

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/iac.sh CHANGED
@@ -76,6 +76,112 @@ run_static_analysis() {
76
76
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
77
77
 
78
78
  local exit_code=0
79
+
80
+ # ── Parse/type validation, before the security scanners ────────────────────
81
+ #
82
+ # checkov and tflint are SECURITY scanners. They answer "is this configuration
83
+ # dangerous", never "is this configuration parseable" -- and a file nothing can
84
+ # parse has no dangers to report, so they pass it. Measured on a one-file
85
+ # fixture whose closing brace was missing:
86
+ #
87
+ # checkov: "Parsing errors: 1 / Error parsing file ...\bad.tf" exit 0
88
+ # adapter: "✅ PASSED - Language-specific code quality checks." exit 0
89
+ # terraform: "Error: Unclosed configuration block" exit 1
90
+ #
91
+ # So the gate reported a positive verdict for a file its own toolchain refuses
92
+ # to load. Gate 1 does exactly this parse step for TypeScript (tsc) and C++
93
+ # (the compiler); IaC was the gap.
94
+ #
95
+ # Scope is deliberately narrow:
96
+ # - only when .tf files are in the change set (input short-circuit first)
97
+ # - only when terraform is resolvable locally (no network -- a gate must
98
+ # never install what it was asked to detect)
99
+ # - `-backend=false` so init cannot reach for a remote state backend
100
+ # - a bounded timeout, and a failure to RUN is reported as such rather than
101
+ # scored as "found nothing"
102
+ # `iac_files` is the three-line TERRAFORM:/KUBERNETES:/DOCKER: summary that
103
+ # detect_iac_files returns; take the Terraform line and drop the prefix.
104
+ local _tf_list
105
+ _tf_list=$(printf '%s\n' "$iac_files" | sed -n 's/^TERRAFORM://p')
106
+ if [ -n "${_tf_list// /}" ] && command -v terraform >/dev/null 2>&1; then
107
+ local _tf_attempted=0 _tf_bad=0
108
+ local _tf_dir
109
+ # Validate once per distinct directory: terraform resolves a whole module
110
+ # directory, so validating file by file would re-init the same module N times
111
+ # and report the same error N times.
112
+ #
113
+ # The list is split on whitespace deliberately (detect_iac_files emits
114
+ # space-separated paths) but goes into an ARRAY rather than straight into a
115
+ # `for`, so each element stays one path and a directory name containing a
116
+ # space cannot become two. shellcheck's SC2086 is right that a bare unquoted
117
+ # expansion here would be a latent word-splitting bug.
118
+ local _tf_dirs=()
119
+ local _tf_f
120
+ while IFS= read -r _tf_f; do
121
+ [ -n "$_tf_f" ] || continue
122
+ local _tf_d
123
+ _tf_d=$(dirname "$_tf_f")
124
+ # Dedupe without relying on IFS: compare against what is already there.
125
+ local _tf_seen=0 _tf_e
126
+ for _tf_e in ${_tf_dirs[@]+"${_tf_dirs[@]}"}; do
127
+ [ "$_tf_e" = "$_tf_d" ] && { _tf_seen=1; break; }
128
+ done
129
+ [ "$_tf_seen" -eq 0 ] && _tf_dirs+=("$_tf_d")
130
+ done <<TFEOF
131
+ $(printf '%s\n' "$_tf_list" | tr ' ' '\n' | sed '/^$/d')
132
+ TFEOF
133
+ for _tf_dir in ${_tf_dirs[@]+"${_tf_dirs[@]}"}; do
134
+ [ -d "$_tf_dir" ] || continue
135
+ _tf_attempted=$((_tf_attempted + 1))
136
+ local _tf_out _tf_rc
137
+ # Validate FIRST, without init.
138
+ #
139
+ # `terraform validate` answers the parse/type question on its own; it only
140
+ # needs init to resolve the provider SCHEMA, and a file that does not parse
141
+ # never gets that far. Measured on the unclosed-block fixture:
142
+ #
143
+ # terraform validate, no init 0.27 s -> "Unclosed configuration block"
144
+ # terraform init + validate 4.8 s -> same answer
145
+ #
146
+ # So init was 94% of the cost of a verdict it did not influence. It is run
147
+ # only when validate says it cannot proceed without it ("Missing required
148
+ # provider" / "Module not installed" / an uninitialized-directory warning),
149
+ # which is the clean-file case where the provider schema really is needed.
150
+ #
151
+ # `-backend=false` keeps init off any remote state backend: a gate must
152
+ # never wait on the network.
153
+ if command -v timeout >/dev/null 2>&1; then
154
+ _tf_out=$( cd "$_tf_dir" && timeout 120 terraform validate -no-color 2>&1 )
155
+ _tf_rc=$?
156
+ if [ "$_tf_rc" -ne 0 ] && printf '%s' "$_tf_out" | grep -qiE 'must be initialized|Missing required provider|Module not installed|run .terraform init'; then
157
+ ( cd "$_tf_dir" && timeout 120 terraform init -backend=false -input=false -no-color >/dev/null 2>&1 )
158
+ _tf_out=$( cd "$_tf_dir" && timeout 120 terraform validate -no-color 2>&1 )
159
+ _tf_rc=$?
160
+ fi
161
+ else
162
+ _tf_out=$( cd "$_tf_dir" && terraform validate -no-color 2>&1 )
163
+ _tf_rc=$?
164
+ if [ "$_tf_rc" -ne 0 ] && printf '%s' "$_tf_out" | grep -qiE 'must be initialized|Missing required provider|Module not installed|run .terraform init'; then
165
+ ( cd "$_tf_dir" && terraform init -backend=false -input=false -no-color >/dev/null 2>&1 )
166
+ _tf_out=$( cd "$_tf_dir" && terraform validate -no-color 2>&1 )
167
+ _tf_rc=$?
168
+ fi
169
+ fi
170
+ if [ "$_tf_rc" -ne 0 ]; then
171
+ _tf_bad=$((_tf_bad + 1))
172
+ echo " ❌ terraform validate rejected $_tf_dir:"
173
+ printf '%s\n' "$_tf_out" | grep -vE '^\s*$' | head -12 | sed 's/^/ /'
174
+ fi
175
+ done
176
+ if [ "$_tf_attempted" -gt 0 ] && [ "$_tf_bad" -gt 0 ]; then
177
+ echo " ❌ $_tf_bad Terraform module(s) failed validation."
178
+ exit_code=1
179
+ fi
180
+ if [ "$_tf_attempted" -eq 0 ]; then
181
+ echo " ⚠️ .tf files staged but no containing directory could be resolved;"
182
+ echo " syntax validation did not run."
183
+ fi
184
+ fi
79
185
  # #803: counts scanner/file pairs that actually ran, independent of their
80
186
  # verdict. `exit_code == 0` answers "did anything fail?"; it cannot answer "did
81
187
  # anything run?", and using it for both made a clean scan indistinguishable from
package/lib/gate-audit.ts CHANGED
@@ -286,10 +286,30 @@ export function aggregateByGate(entries: GateAuditEntry[]): Map<string, GateBuck
286
286
  // Issue #370: exclude anomalous durations from ms aggregation. REQ-B: a
287
287
  // null duration is the honest sibling of that flag — deliberately not
288
288
  // measurable, so it stays out of the sums (and out of the denominator).
289
+ //
290
+ // The flag alone is not enough. It was introduced AFTER the field it
291
+ // guards, so rows written before it carry a raw value with no marker:
292
+ // measured 397 such rows (gate-1: 191, gate-11: 206, 2026-07-20 to
293
+ // 2026-10-19) whose duration_ms is an absolute epoch timestamp rather than a
294
+ // duration. They summed into a "gate-1 average 5842895372 ms" — a number no
295
+ // reader can act on and which silently destroys the one table the
296
+ // `audit --stats` command exists to produce.
297
+ //
298
+ // So apply the same plausibility bound the anomaly detector uses, rather
299
+ // than trusting a marker a legacy row was never written with.
289
300
  if (e.duration_anomaly === true) {
290
301
  b.anomaly_count += 1;
291
- } else if (typeof e.duration_ms === 'number') {
302
+ } else if (
303
+ typeof e.duration_ms === 'number'
304
+ && Number.isFinite(e.duration_ms)
305
+ && e.duration_ms >= 0
306
+ && e.duration_ms <= MAX_PLAUSIBLE_DURATION_MS
307
+ ) {
292
308
  b.ms += e.duration_ms;
309
+ } else if (typeof e.duration_ms === 'number') {
310
+ // Present but implausible: counted so the exclusion is visible, never
311
+ // summed.
312
+ b.anomaly_count += 1;
293
313
  }
294
314
  // A malformed/legacy row with a non-numeric issues_found must not turn
295
315
  // the whole gate's average into NaN.
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-19T07:54:43.796Z",
5
+ "checked_at": "2026-11-19T09:45:30.877Z",
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.28",
3
+ "version": "0.38.30",
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.28",
3
+ "version": "0.38.30",
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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28",
3
+ "version": "0.38.30",
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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.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.28.0
6
+ **Version:** 0.38.30.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.