@boyingliu01/xp-gate 0.38.30 → 0.38.32

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.
@@ -202,7 +202,12 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
202
202
  split(row, f, "\t")
203
203
  if (f[1] == "") continue
204
204
  n++
205
- lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]
205
+ # f[4] is `forbiddenImports`. It was parsed but never loaded, so the
206
+ # field was dead config while reading as enforcement -- the #686 defect
207
+ # shape, inside the fix for #686. A declared-forbidden edge always loses,
208
+ # even when `allowedImports` also names it: an explicit denial must not be
209
+ # silently cancelled by a broader grant.
210
+ lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]; lforb[n] = f[4]
206
211
  # Patterns are compiled once here. layer_of() runs twice per source file
207
212
  # (once for the importer, once per resolved target); recompiling there
208
213
  # meant ~5800 regex builds for this repo and dominated the 2s scan.
@@ -251,6 +256,22 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
251
256
  }
252
257
  return 0
253
258
  }
259
+ # `forbiddenImports` is the inverse of `allowedImports`, evaluated with the
260
+ # SAME two accepted forms (bare layer name or path glob) so a project cannot
261
+ # get enforcement by accident of spelling. It is checked BEFORE the allow
262
+ # list: an explicit denial wins over a broad grant. The alternative -- letting
263
+ # allowedImports cancel a forbiddenImports entry -- would make the stricter
264
+ # declaration the weaker one, which is the opposite of what a denial means.
265
+ function forbidden_hit(idx, tgt, dstname, k, j, p) {
266
+ k = split(lforb[idx], p, ",")
267
+ for (j = 1; j <= k; j++) {
268
+ if (p[j] == "") continue
269
+ if (p[j] == dstname) return 1
270
+ if (p[j] ~ /[*]/ && tgt ~ pat2re(p[j])) return 1
271
+ if (p[j] !~ /[*]/ && (tgt == p[j] || tgt ~ ("^" p[j] "/"))) return 1
272
+ }
273
+ return 0
274
+ }
254
275
  # Resolve a relative specifier against the importing file.
255
276
  function resolve(from, spec, np, i, dir, res, k, pp, trail, sx) {
256
277
  sub(/[.](ts|tsx|js|jsx|mjs|cjs)$/, "", spec)
@@ -286,16 +307,35 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
286
307
  # // in http:// inside string literals.
287
308
  if (line ~ /^[ \t]*(\/\/|[#]|[*]|\/\*)/) next
288
309
  rest = line
289
- while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047/)) {
310
+ # Two specifier forms are scanned, alternating so both are found in one pass:
311
+ # ES/TS import ... from "x"
312
+ # CJS require("x") (single-quoted form is scanned too)
313
+ # The `require(` form was missing entirely, which left every .cjs file and its
314
+ # dependencies unscanned. This repo holds 28 of them, several importing from
315
+ # the generated mirror -- so the checker reported a clean tree while the very
316
+ # edge its own config forbids existed on disk. A scanner that reads one of the
317
+ # two import syntaxes is a scanner that can pass without looking.
318
+ while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047|require\([ \t]*"[^"]+"[ \t]*\)|require\([ \t]*\047[^\047]+\047[ \t]*\)/)) {
290
319
  spec = substr(rest, RSTART, RLENGTH)
291
- sub(/^from[ \t]+["\047]/, "", spec)
292
- sub(/["\047]$/, "", spec)
293
320
  rest = substr(rest, RSTART + RLENGTH)
321
+ if (spec ~ /^from/) {
322
+ sub(/^from[ \t]+["\047]/, "", spec)
323
+ sub(/["\047]$/, "", spec)
324
+ } else {
325
+ sub(/^require\([ \t]*["\047]/, "", spec)
326
+ sub(/["\047][ \t]*\)$/, "", spec)
327
+ }
294
328
  if (src == 0 || spec == "") continue
295
329
  tgt = resolve(file, spec)
296
330
  if (tgt == "") continue
297
331
  dst = layer_of(tgt)
298
332
  if (dst == 0 || dst == src) continue
333
+ # Denial before grant: an explicit forbiddenImports entry is never
334
+ # cancelled by a broader allowedImports entry.
335
+ if (forbidden_hit(src, tgt, lname[dst])) {
336
+ printf "%s\t%s\t%s\t%s\tforbidden\n", file, lname[src], lname[dst], tgt
337
+ continue
338
+ }
299
339
  if (allowed_ok(src, tgt, lname[dst])) continue
300
340
  printf "%s\t%s\t%s\t%s\n", file, lname[src], lname[dst], tgt
301
341
  }
@@ -364,12 +404,23 @@ if [ "$NEW_COUNT" -eq 0 ]; then
364
404
  fi
365
405
 
366
406
  _layers_say "❌ BLOCKED - $NEW_COUNT new layer violation(s) (of $TOTAL total):"
367
- printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t; do
368
- _layers_say " - $f [$s -> $d] imports $t"
407
+ # A forbidden edge and an unlisted edge are different diagnoses -- one says the
408
+ # import is explicitly denied, the other says nobody declared it -- and the fix
409
+ # differs (remove the import vs declare it). Name which one fired.
410
+ FORBIDDEN_SEEN=$(printf '%s\n' "$NEW_FINDINGS" | awk -F'\t' '$5=="forbidden"' | grep -c . || true)
411
+ printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t why; do
412
+ if [ "$why" = "forbidden" ]; then
413
+ _layers_say " - $f [$s -> $d] imports $t (forbiddenImports)"
414
+ else
415
+ _layers_say " - $f [$s -> $d] imports $t"
416
+ fi
369
417
  done
370
418
  if [ "$NEW_COUNT" -gt 10 ]; then
371
419
  _layers_say " ... and $((NEW_COUNT - 10)) more"
372
420
  fi
421
+ if [ "${FORBIDDEN_SEEN:-0}" -gt 0 ]; then
422
+ _layers_say " Some edges are listed in a layer's forbiddenImports, an explicit denial."
423
+ fi
373
424
  _layers_say " A layer may import only what its allowedImports lists."
374
425
  _layers_say " To accept an existing violation, record it in $LAYER_BASELINE."
375
426
  exit 1
package/gate-6-layers.sh CHANGED
@@ -202,7 +202,12 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
202
202
  split(row, f, "\t")
203
203
  if (f[1] == "") continue
204
204
  n++
205
- lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]
205
+ # f[4] is `forbiddenImports`. It was parsed but never loaded, so the
206
+ # field was dead config while reading as enforcement -- the #686 defect
207
+ # shape, inside the fix for #686. A declared-forbidden edge always loses,
208
+ # even when `allowedImports` also names it: an explicit denial must not be
209
+ # silently cancelled by a broader grant.
210
+ lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]; lforb[n] = f[4]
206
211
  # Patterns are compiled once here. layer_of() runs twice per source file
207
212
  # (once for the importer, once per resolved target); recompiling there
208
213
  # meant ~5800 regex builds for this repo and dominated the 2s scan.
@@ -251,6 +256,22 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
251
256
  }
252
257
  return 0
253
258
  }
259
+ # `forbiddenImports` is the inverse of `allowedImports`, evaluated with the
260
+ # SAME two accepted forms (bare layer name or path glob) so a project cannot
261
+ # get enforcement by accident of spelling. It is checked BEFORE the allow
262
+ # list: an explicit denial wins over a broad grant. The alternative -- letting
263
+ # allowedImports cancel a forbiddenImports entry -- would make the stricter
264
+ # declaration the weaker one, which is the opposite of what a denial means.
265
+ function forbidden_hit(idx, tgt, dstname, k, j, p) {
266
+ k = split(lforb[idx], p, ",")
267
+ for (j = 1; j <= k; j++) {
268
+ if (p[j] == "") continue
269
+ if (p[j] == dstname) return 1
270
+ if (p[j] ~ /[*]/ && tgt ~ pat2re(p[j])) return 1
271
+ if (p[j] !~ /[*]/ && (tgt == p[j] || tgt ~ ("^" p[j] "/"))) return 1
272
+ }
273
+ return 0
274
+ }
254
275
  # Resolve a relative specifier against the importing file.
255
276
  function resolve(from, spec, np, i, dir, res, k, pp, trail, sx) {
256
277
  sub(/[.](ts|tsx|js|jsx|mjs|cjs)$/, "", spec)
@@ -286,16 +307,35 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
286
307
  # // in http:// inside string literals.
287
308
  if (line ~ /^[ \t]*(\/\/|[#]|[*]|\/\*)/) next
288
309
  rest = line
289
- while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047/)) {
310
+ # Two specifier forms are scanned, alternating so both are found in one pass:
311
+ # ES/TS import ... from "x"
312
+ # CJS require("x") (single-quoted form is scanned too)
313
+ # The `require(` form was missing entirely, which left every .cjs file and its
314
+ # dependencies unscanned. This repo holds 28 of them, several importing from
315
+ # the generated mirror -- so the checker reported a clean tree while the very
316
+ # edge its own config forbids existed on disk. A scanner that reads one of the
317
+ # two import syntaxes is a scanner that can pass without looking.
318
+ while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047|require\([ \t]*"[^"]+"[ \t]*\)|require\([ \t]*\047[^\047]+\047[ \t]*\)/)) {
290
319
  spec = substr(rest, RSTART, RLENGTH)
291
- sub(/^from[ \t]+["\047]/, "", spec)
292
- sub(/["\047]$/, "", spec)
293
320
  rest = substr(rest, RSTART + RLENGTH)
321
+ if (spec ~ /^from/) {
322
+ sub(/^from[ \t]+["\047]/, "", spec)
323
+ sub(/["\047]$/, "", spec)
324
+ } else {
325
+ sub(/^require\([ \t]*["\047]/, "", spec)
326
+ sub(/["\047][ \t]*\)$/, "", spec)
327
+ }
294
328
  if (src == 0 || spec == "") continue
295
329
  tgt = resolve(file, spec)
296
330
  if (tgt == "") continue
297
331
  dst = layer_of(tgt)
298
332
  if (dst == 0 || dst == src) continue
333
+ # Denial before grant: an explicit forbiddenImports entry is never
334
+ # cancelled by a broader allowedImports entry.
335
+ if (forbidden_hit(src, tgt, lname[dst])) {
336
+ printf "%s\t%s\t%s\t%s\tforbidden\n", file, lname[src], lname[dst], tgt
337
+ continue
338
+ }
299
339
  if (allowed_ok(src, tgt, lname[dst])) continue
300
340
  printf "%s\t%s\t%s\t%s\n", file, lname[src], lname[dst], tgt
301
341
  }
@@ -364,12 +404,23 @@ if [ "$NEW_COUNT" -eq 0 ]; then
364
404
  fi
365
405
 
366
406
  _layers_say "❌ BLOCKED - $NEW_COUNT new layer violation(s) (of $TOTAL total):"
367
- printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t; do
368
- _layers_say " - $f [$s -> $d] imports $t"
407
+ # A forbidden edge and an unlisted edge are different diagnoses -- one says the
408
+ # import is explicitly denied, the other says nobody declared it -- and the fix
409
+ # differs (remove the import vs declare it). Name which one fired.
410
+ FORBIDDEN_SEEN=$(printf '%s\n' "$NEW_FINDINGS" | awk -F'\t' '$5=="forbidden"' | grep -c . || true)
411
+ printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t why; do
412
+ if [ "$why" = "forbidden" ]; then
413
+ _layers_say " - $f [$s -> $d] imports $t (forbiddenImports)"
414
+ else
415
+ _layers_say " - $f [$s -> $d] imports $t"
416
+ fi
369
417
  done
370
418
  if [ "$NEW_COUNT" -gt 10 ]; then
371
419
  _layers_say " ... and $((NEW_COUNT - 10)) more"
372
420
  fi
421
+ if [ "${FORBIDDEN_SEEN:-0}" -gt 0 ]; then
422
+ _layers_say " Some edges are listed in a layer's forbiddenImports, an explicit denial."
423
+ fi
373
424
  _layers_say " A layer may import only what its allowedImports lists."
374
425
  _layers_say " To accept an existing violation, record it in $LAYER_BASELINE."
375
426
  exit 1
@@ -202,7 +202,12 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
202
202
  split(row, f, "\t")
203
203
  if (f[1] == "") continue
204
204
  n++
205
- lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]
205
+ # f[4] is `forbiddenImports`. It was parsed but never loaded, so the
206
+ # field was dead config while reading as enforcement -- the #686 defect
207
+ # shape, inside the fix for #686. A declared-forbidden edge always loses,
208
+ # even when `allowedImports` also names it: an explicit denial must not be
209
+ # silently cancelled by a broader grant.
210
+ lname[n] = f[1]; lpat[n] = f[2]; lallow[n] = f[3]; lforb[n] = f[4]
206
211
  # Patterns are compiled once here. layer_of() runs twice per source file
207
212
  # (once for the importer, once per resolved target); recompiling there
208
213
  # meant ~5800 regex builds for this repo and dominated the 2s scan.
@@ -251,6 +256,22 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
251
256
  }
252
257
  return 0
253
258
  }
259
+ # `forbiddenImports` is the inverse of `allowedImports`, evaluated with the
260
+ # SAME two accepted forms (bare layer name or path glob) so a project cannot
261
+ # get enforcement by accident of spelling. It is checked BEFORE the allow
262
+ # list: an explicit denial wins over a broad grant. The alternative -- letting
263
+ # allowedImports cancel a forbiddenImports entry -- would make the stricter
264
+ # declaration the weaker one, which is the opposite of what a denial means.
265
+ function forbidden_hit(idx, tgt, dstname, k, j, p) {
266
+ k = split(lforb[idx], p, ",")
267
+ for (j = 1; j <= k; j++) {
268
+ if (p[j] == "") continue
269
+ if (p[j] == dstname) return 1
270
+ if (p[j] ~ /[*]/ && tgt ~ pat2re(p[j])) return 1
271
+ if (p[j] !~ /[*]/ && (tgt == p[j] || tgt ~ ("^" p[j] "/"))) return 1
272
+ }
273
+ return 0
274
+ }
254
275
  # Resolve a relative specifier against the importing file.
255
276
  function resolve(from, spec, np, i, dir, res, k, pp, trail, sx) {
256
277
  sub(/[.](ts|tsx|js|jsx|mjs|cjs)$/, "", spec)
@@ -286,16 +307,35 @@ FINDINGS=$(XP_LAYER_TSV="$LAYER_TSV_FILE" XP_LAYER_STATS="$LAYER_STATS_FILE" awk
286
307
  # // in http:// inside string literals.
287
308
  if (line ~ /^[ \t]*(\/\/|[#]|[*]|\/\*)/) next
288
309
  rest = line
289
- while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047/)) {
310
+ # Two specifier forms are scanned, alternating so both are found in one pass:
311
+ # ES/TS import ... from "x"
312
+ # CJS require("x") (single-quoted form is scanned too)
313
+ # The `require(` form was missing entirely, which left every .cjs file and its
314
+ # dependencies unscanned. This repo holds 28 of them, several importing from
315
+ # the generated mirror -- so the checker reported a clean tree while the very
316
+ # edge its own config forbids existed on disk. A scanner that reads one of the
317
+ # two import syntaxes is a scanner that can pass without looking.
318
+ while (match(rest, /from[ \t]+"[^"]+"|from[ \t]+\047[^\047]+\047|require\([ \t]*"[^"]+"[ \t]*\)|require\([ \t]*\047[^\047]+\047[ \t]*\)/)) {
290
319
  spec = substr(rest, RSTART, RLENGTH)
291
- sub(/^from[ \t]+["\047]/, "", spec)
292
- sub(/["\047]$/, "", spec)
293
320
  rest = substr(rest, RSTART + RLENGTH)
321
+ if (spec ~ /^from/) {
322
+ sub(/^from[ \t]+["\047]/, "", spec)
323
+ sub(/["\047]$/, "", spec)
324
+ } else {
325
+ sub(/^require\([ \t]*["\047]/, "", spec)
326
+ sub(/["\047][ \t]*\)$/, "", spec)
327
+ }
294
328
  if (src == 0 || spec == "") continue
295
329
  tgt = resolve(file, spec)
296
330
  if (tgt == "") continue
297
331
  dst = layer_of(tgt)
298
332
  if (dst == 0 || dst == src) continue
333
+ # Denial before grant: an explicit forbiddenImports entry is never
334
+ # cancelled by a broader allowedImports entry.
335
+ if (forbidden_hit(src, tgt, lname[dst])) {
336
+ printf "%s\t%s\t%s\t%s\tforbidden\n", file, lname[src], lname[dst], tgt
337
+ continue
338
+ }
299
339
  if (allowed_ok(src, tgt, lname[dst])) continue
300
340
  printf "%s\t%s\t%s\t%s\n", file, lname[src], lname[dst], tgt
301
341
  }
@@ -364,12 +404,23 @@ if [ "$NEW_COUNT" -eq 0 ]; then
364
404
  fi
365
405
 
366
406
  _layers_say "❌ BLOCKED - $NEW_COUNT new layer violation(s) (of $TOTAL total):"
367
- printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t; do
368
- _layers_say " - $f [$s -> $d] imports $t"
407
+ # A forbidden edge and an unlisted edge are different diagnoses -- one says the
408
+ # import is explicitly denied, the other says nobody declared it -- and the fix
409
+ # differs (remove the import vs declare it). Name which one fired.
410
+ FORBIDDEN_SEEN=$(printf '%s\n' "$NEW_FINDINGS" | awk -F'\t' '$5=="forbidden"' | grep -c . || true)
411
+ printf '%s\n' "$NEW_FINDINGS" | head -10 | while IFS="$(printf '\t')" read -r f s d t why; do
412
+ if [ "$why" = "forbidden" ]; then
413
+ _layers_say " - $f [$s -> $d] imports $t (forbiddenImports)"
414
+ else
415
+ _layers_say " - $f [$s -> $d] imports $t"
416
+ fi
369
417
  done
370
418
  if [ "$NEW_COUNT" -gt 10 ]; then
371
419
  _layers_say " ... and $((NEW_COUNT - 10)) more"
372
420
  fi
421
+ if [ "${FORBIDDEN_SEEN:-0}" -gt 0 ]; then
422
+ _layers_say " Some edges are listed in a layer's forbiddenImports, an explicit denial."
423
+ fi
373
424
  _layers_say " A layer may import only what its allowedImports lists."
374
425
  _layers_say " To accept an existing violation, record it in $LAYER_BASELINE."
375
426
  exit 1
@@ -53,7 +53,13 @@ function filterFindings(raw, known) {
53
53
  return raw
54
54
  .split('\n')
55
55
  .filter(Boolean)
56
- .filter(line => !known.has(line));
56
+ // A finding may carry a 5th diagnostic field (`forbidden`, added when
57
+ // forbiddenImports became enforced). A ledger records WHERE the edge is, not
58
+ // WHY it was reported, so the key is the first four fields only. Comparing
59
+ // whole lines made every ledgered entry stop matching the moment the 5th
60
+ // column appeared, silently turning accepted debt back into blocking
61
+ // violations -- caught as two red tests, not by reading the code.
62
+ .filter((line) => !known.has(line.split('\t').slice(0, 4).join('\t')));
57
63
  }
58
64
 
59
65
  function main() {
@@ -97,16 +97,62 @@ run_test_file_pass() {
97
97
  else
98
98
  echo "Checking test files for type errors..."
99
99
  local temp_tsconfig=".tsconfig.withtests.json"
100
+ # `exclude` and `include` do NOT accept the same globs. TypeScript allows a
101
+ # trailing `**` in `exclude` but rejects it in `include` with TS5010
102
+ # ("File specification cannot end in a recursive directory wildcard").
103
+ #
104
+ # This block used to push `src/**/__tests__/**` -- copied from the exclude
105
+ # list, where it is legal and common -- into `include`. The generated config
106
+ # was therefore ALWAYS invalid, and tsc aborted before checking a single
107
+ # file. Every commit in a project with the standard
108
+ #
109
+ # "exclude": ["src/**/__tests__/**", ...]
110
+ #
111
+ # was blocked with "❌ TYPE ERRORS in test files" while its code was clean.
112
+ # A checker that cannot run was reporting as if it had run and found
113
+ # problems -- the failure mode this whole gate exists to remove.
114
+ #
115
+ # `src/**/__tests__/*` reaches the same files and is a legal include form.
100
116
  node -e "
101
117
  const cfg = JSON.parse(require('fs').readFileSync('tsconfig.json','utf8'));
102
118
  delete cfg.exclude;
103
119
  cfg.include = cfg.include || ['src/**/*'];
104
- cfg.include.push('src/**/__tests__/**','src/**/*.test.ts','src/**/*.spec.ts');
120
+ cfg.include.push('src/**/__tests__/*','src/**/*.test.ts','src/**/*.spec.ts');
105
121
  require('fs').writeFileSync('$temp_tsconfig', JSON.stringify(cfg, null, 2));
106
122
  " 2>/dev/null
107
- _tsc_command --noEmit --project "$temp_tsconfig" --skipLibCheck 2>&1 | head -30
108
- test_pass_exit=${PIPESTATUS[0]}
123
+ local tsc_out tsc_exit
124
+ tsc_out=$(_tsc_command --noEmit --project "$temp_tsconfig" --skipLibCheck 2>&1)
125
+ tsc_exit=$?
126
+ # The shared verdict below reads test_pass_exit; both tsc branches must feed
127
+ # it or this one silently inherits whatever the previous branch left behind.
128
+ test_pass_exit=$tsc_exit
129
+ printf '%s\n' "$tsc_out" | head -30
109
130
  rm -f "$temp_tsconfig"
131
+ # Distinguish "tsc evaluated the project and found type errors" from "tsc
132
+ # rejected the config we generated and evaluated nothing". The verdict
133
+ # contract requires those to be different states; conflating them spends the
134
+ # user's time on our config and hides the real answer.
135
+ #
136
+ # Measured: with an INVALID config, tsc still checks every file it can see
137
+ # and reports real errors ALONGSIDE the config complaint. So a TS5xxx line
138
+ # alone does not mean "nothing was checked" -- it means nothing was checked
139
+ # only when it is the ONLY thing reported. Which is why the test below is
140
+ # "config error AND no type error", not "config error".
141
+ if [ "$tsc_exit" -ne 0 ] && printf '%s\n' "$tsc_out" | grep -qE 'TS5[0-9][0-9][0-9]'; then
142
+ # grep -E has no negative lookahead, so count instead of excluding:
143
+ # every diagnostic is `error TS<digits>`, and a 5xxx code is a
144
+ # configuration complaint rather than a type finding. If the totals match,
145
+ # the only thing tsc said was "your config is bad".
146
+ local all_err code_err
147
+ all_err=$(printf '%s\n' "$tsc_out" | grep -cE 'error TS[0-9]+')
148
+ code_err=$(printf '%s\n' "$tsc_out" | grep -cE 'error TS5[0-9][0-9][0-9]')
149
+ if [ "$all_err" -gt 0 ] && [ "$all_err" -eq "$code_err" ]; then
150
+ echo ""
151
+ echo "⚠️ Gate 1: the generated test tsconfig was rejected by tsc — test files NOT checked."
152
+ echo " This is a defect in xp-gate's test-file pass, not in your code."
153
+ return 2
154
+ fi
155
+ fi
110
156
  fi
111
157
 
112
158
  if [ "$test_pass_exit" -ne 0 ]; then
@@ -53,7 +53,13 @@ function filterFindings(raw, known) {
53
53
  return raw
54
54
  .split('\n')
55
55
  .filter(Boolean)
56
- .filter(line => !known.has(line));
56
+ // A finding may carry a 5th diagnostic field (`forbidden`, added when
57
+ // forbiddenImports became enforced). A ledger records WHERE the edge is, not
58
+ // WHY it was reported, so the key is the first four fields only. Comparing
59
+ // whole lines made every ledgered entry stop matching the moment the 5th
60
+ // column appeared, silently turning accepted debt back into blocking
61
+ // violations -- caught as two red tests, not by reading the code.
62
+ .filter((line) => !known.has(line.split('\t').slice(0, 4).join('\t')));
57
63
  }
58
64
 
59
65
  function main() {
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-19T09:45:30.877Z",
5
+ "checked_at": "2026-11-19T09:52:42.581Z",
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.30",
3
+ "version": "0.38.32",
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.30",
3
+ "version": "0.38.32",
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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30",
3
+ "version": "0.38.32",
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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.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.30.0
6
+ **Version:** 0.38.32.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.