@boyingliu01/xp-gate 0.38.125 → 0.38.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/gate-3.sh +34 -1
- package/adapters/gate-7.sh +15 -6
- package/bin/xp-gate.js +24 -0
- package/build-integrity/gate-10.ts +33 -8
- package/gate-3.sh +34 -1
- package/gate-registry.sh +3 -1
- package/hooks/deploy-manifest.sh +1 -0
- package/hooks/gate-3.sh +34 -1
- package/hooks/gate-entries/gate-1-entry.sh +35 -24
- package/hooks/gate-entries/gate-5-entry.sh +55 -19
- package/hooks/gate-entries/gate-6-entry.sh +15 -6
- package/hooks/gate-registry.sh +3 -1
- package/hooks/lib/gate-status.sh +164 -0
- package/hooks/lib/jscpd-run.sh +9 -1
- package/hooks/lib/native-path.sh +54 -0
- package/hooks/lib/toolchain-path.sh +38 -0
- package/hooks/pre-push +13 -4
- package/lib/__tests__/arch.test.js +7 -1
- package/lib/__tests__/audit-skip-reasons.test.ts +143 -0
- package/lib/__tests__/check-tools-list.test.js +155 -0
- package/lib/__tests__/doctor-tool-delegation.test.js +156 -0
- package/lib/__tests__/install-tools-repair.test.js +263 -0
- package/lib/__tests__/language-capability.test.js +27 -0
- package/lib/__tests__/tool-audit-collect.test.js +184 -0
- package/lib/__tests__/tool-audit-fixtures.js +87 -0
- package/lib/__tests__/tool-audit-latest.test.js +84 -0
- package/lib/__tests__/tool-audit.test.js +428 -0
- package/lib/deploy-manifest.js +1 -0
- package/lib/doctor-tool-checks.js +129 -0
- package/lib/doctor.js +15 -46
- package/lib/gate-audit.ts +80 -0
- package/lib/gate-runner.js +5 -0
- package/lib/language-capability-surfaces.js +70 -6
- package/lib/language-capability.js +3 -0
- package/lib/language-tools.js +409 -93
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/tool-audit.js +729 -0
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/src/skills.test.ts +9 -0
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
package/lib/gate-audit.ts
CHANGED
|
@@ -352,6 +352,86 @@ export function computeStats(
|
|
|
352
352
|
return results;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
export interface SkipReasonBucket {
|
|
356
|
+
/** The reason as recorded (from `detail`, or `(no reason)` when absent). */
|
|
357
|
+
reason: string;
|
|
358
|
+
/**
|
|
359
|
+
* True when the row records a SKIP without a usable reason.
|
|
360
|
+
*
|
|
361
|
+
* `skip_reason=UNRECORDED` is what gate-3 writes when it skipped and had no
|
|
362
|
+
* GATE_3_REASON -- a deliberate marker, not an explanation. Round-1 review
|
|
363
|
+
* (expert A) pointed out that without this flag a downstream counter treats it
|
|
364
|
+
* as just another reason string, so "26 skips explained" and "26 skips, 3 of
|
|
365
|
+
* them unexplained" read the same. An unexplained skip is a defect in the
|
|
366
|
+
* gate, and the aggregate has to be able to say so.
|
|
367
|
+
*/
|
|
368
|
+
unexplained: boolean;
|
|
369
|
+
/** How many SKIP records carried it. */
|
|
370
|
+
count: number;
|
|
371
|
+
/** Which gates skipped for this reason, most frequent first. */
|
|
372
|
+
gates: { gate_id: string; count: number }[];
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Aggregate SKIP reasons across the journal.
|
|
377
|
+
*
|
|
378
|
+
* WHY THIS EXISTS: the journal already records WHY a gate skipped -- in the
|
|
379
|
+
* `detail` field, 142 of 144 SKIP rows carry one. What was missing is a way to
|
|
380
|
+
* READ them as a whole: `audit --stats` prints pass% and average duration per
|
|
381
|
+
* gate, from which a 0% execution rate is visible but its cause is not. A gate
|
|
382
|
+
* that never runs because "no IaC files changed" is healthy; one that never runs
|
|
383
|
+
* because "checker_missing" is a broken install. Both looked identical.
|
|
384
|
+
*
|
|
385
|
+
* The reason is normalised into a KINDS TOKENS rather than raw text, because
|
|
386
|
+
* several gates append a language prefix (`powershell: PSScriptAnalyzer module
|
|
387
|
+
* not installed`) -- grouping by the full string would produce one bucket per
|
|
388
|
+
* language and hide the pattern.
|
|
389
|
+
*
|
|
390
|
+
* @param repoRoot project root containing .xp-gate/audit.jsonl
|
|
391
|
+
* @returns buckets sorted by count desc, then reason
|
|
392
|
+
*/
|
|
393
|
+
/**
|
|
394
|
+
* The marker gate-3 writes when it skipped without recording a reason.
|
|
395
|
+
*
|
|
396
|
+
* Kept as a constant so the writer (githooks/adapters/gate-3.sh) and this reader
|
|
397
|
+
* agree on one spelling; a second literal would let them drift and the flag
|
|
398
|
+
* above would quietly stop matching.
|
|
399
|
+
*/
|
|
400
|
+
const UNEXPLAINED_SKIP_REASON = 'skip_reason=UNRECORDED';
|
|
401
|
+
|
|
402
|
+
export function computeSkipReasons(repoRoot: string = process.cwd()): SkipReasonBucket[] {
|
|
403
|
+
const logPath = join(repoRoot, AUDIT_DIR, AUDIT_FILE);
|
|
404
|
+
const entries = parseAuditEntries(logPath);
|
|
405
|
+
const byReason = new Map<string, { count: number; gates: Map<string, number> }>();
|
|
406
|
+
|
|
407
|
+
for (const e of entries) {
|
|
408
|
+
if (e.gate_status !== 'SKIP') continue;
|
|
409
|
+
const raw = typeof e.detail === 'string' ? e.detail.trim() : '';
|
|
410
|
+
const reason = raw || '(no reason)';
|
|
411
|
+
const bucket = byReason.get(reason) ?? { count: 0, gates: new Map<string, number>() };
|
|
412
|
+
bucket.count += 1;
|
|
413
|
+
bucket.gates.set(e.gate_id, (bucket.gates.get(e.gate_id) ?? 0) + 1);
|
|
414
|
+
byReason.set(reason, bucket);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const out: SkipReasonBucket[] = [];
|
|
418
|
+
for (const [reason, b] of Array.from(byReason.entries())) {
|
|
419
|
+
out.push({
|
|
420
|
+
reason,
|
|
421
|
+
// Substring, not equality: gate-3 records the marker as ONE SEGMENT of a
|
|
422
|
+
// composite detail ("ccn_threshold=5; skip_reason=UNRECORDED"), so an
|
|
423
|
+
// equality test would never fire on the exact rows it was written for.
|
|
424
|
+
unexplained: reason.includes(UNEXPLAINED_SKIP_REASON) || reason === '(no reason)',
|
|
425
|
+
count: b.count,
|
|
426
|
+
gates: Array.from(b.gates.entries())
|
|
427
|
+
.map(([gate_id, count]) => ({ gate_id, count }))
|
|
428
|
+
.sort((a, b2) => b2.count - a.count || a.gate_id.localeCompare(b2.gate_id)),
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
out.sort((a, b) => b.count - a.count || a.reason.localeCompare(b.reason));
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
|
|
355
435
|
export interface AuditAnomalies {
|
|
356
436
|
/** Entries with an explicit duration_anomaly flag (Issue #370). */
|
|
357
437
|
flagged: number;
|
package/lib/gate-runner.js
CHANGED
|
@@ -821,6 +821,11 @@ function jscpdDefaultIgnorePatterns() {
|
|
|
821
821
|
'**/.nuxt/**',
|
|
822
822
|
'**/vendor/**',
|
|
823
823
|
'**/.xp-gate/**',
|
|
824
|
+
// The build mirror. Byte-identical to githooks/, plugins/ and skills/ by
|
|
825
|
+
// construction, so `jscpd` comparing it to them reports the mirror as
|
|
826
|
+
// duplicated code -- 28 s per run and a FAIL nobody can act on (measured
|
|
827
|
+
// 2026-11-24). Mirror drift has its own gate (12b).
|
|
828
|
+
'**/src/npm-package/**',
|
|
824
829
|
'**/*.log',
|
|
825
830
|
'**/*.txt',
|
|
826
831
|
'**/*.yaml',
|
|
@@ -89,6 +89,46 @@ function inspectGate2(deps, lang, exts, ctx) {
|
|
|
89
89
|
* into the state -- it would otherwise make every language absent from this
|
|
90
90
|
* repo report NOT WIRED, which is a fact about the repo, not about the wiring.
|
|
91
91
|
*/
|
|
92
|
+
/**
|
|
93
|
+
* Read a gate family's extension set from the ONE place that defines it.
|
|
94
|
+
*
|
|
95
|
+
* `gate-3.sh` and `gate-4.sh` do not carry literal extension lists: they build
|
|
96
|
+
* their filter from `xp_gate_source_exts ccn|principles`, whose values live in
|
|
97
|
+
* `githooks/lib/file-classifier.sh` as `XP_GATE_*_EXTS`. Scanning only the gate
|
|
98
|
+
* scripts therefore saw no `cs` anywhere and reported csharp's Gate 3 and Gate 4
|
|
99
|
+
* as NOT WIRED -- permanently, for a language whose `.cs` the filter really does
|
|
100
|
+
* accept (verified by feeding `A.cs` through the real regex).
|
|
101
|
+
*
|
|
102
|
+
* A reader that looks in the wrong file reports "not wired" for wired code,
|
|
103
|
+
* which is the false-alarm direction that gets a check switched off.
|
|
104
|
+
*
|
|
105
|
+
* @param {object} ctx reader with `read(rel)`
|
|
106
|
+
* @param {'ccn'|'principles'} family
|
|
107
|
+
* @returns {string[]} alternation bodies from the classifier, empty when absent
|
|
108
|
+
*/
|
|
109
|
+
function classifierExtensionAlternations(ctx, family) {
|
|
110
|
+
const src = ctx.read('githooks/lib/file-classifier.sh');
|
|
111
|
+
if (src === null) return [];
|
|
112
|
+
const varName = family === 'ccn' ? 'XP_GATE_CCN_EXTS' : 'XP_GATE_PRINCIPLES_EXTS';
|
|
113
|
+
const out = [];
|
|
114
|
+
for (const line of src.split('\n')) {
|
|
115
|
+
if (!line.includes(`${varName}=`)) continue;
|
|
116
|
+
// The value is `"${XP_GATE_JS_TS_EXTS}|py|go|...|cs|php"`. The JS/TS part is
|
|
117
|
+
// another variable, so it stays unresolved; an extension that is spelled out
|
|
118
|
+
// here is what `hasExtensionToken` can recognise.
|
|
119
|
+
const m = line.match(/XP_GATE_[A-Z_]+_EXTS="([^"]*)"/);
|
|
120
|
+
if (m) out.push(m[1]);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Does any alternation -- literal in the gate, or declared in the classifier -- name `ext`? */
|
|
126
|
+
function wiredInGate(deps, gateText, exts, ctx, family) {
|
|
127
|
+
if (deps.anyAlternationHas(gateText, exts)) return true;
|
|
128
|
+
return exts.some((ext) =>
|
|
129
|
+
classifierExtensionAlternations(ctx, family).some((alt) => deps.hasExtensionToken(alt, ext)));
|
|
130
|
+
}
|
|
131
|
+
|
|
92
132
|
function inspectGate3(deps, lang, exts, ctx) {
|
|
93
133
|
const gate3 = ctx.read('githooks/adapters/gate-3.sh');
|
|
94
134
|
if (gate3 === null) {
|
|
@@ -96,7 +136,7 @@ function inspectGate3(deps, lang, exts, ctx) {
|
|
|
96
136
|
}
|
|
97
137
|
// Scan the WHOLE file: the extension has been listed in more than one
|
|
98
138
|
// alternation over time and a name-bound reader went silently blank once.
|
|
99
|
-
const wired = deps
|
|
139
|
+
const wired = wiredInGate(deps, gate3, exts, ctx, 'ccn');
|
|
100
140
|
if (!wired) {
|
|
101
141
|
return deps.row(
|
|
102
142
|
'gate-3',
|
|
@@ -137,7 +177,7 @@ function inspectGate4(deps, lang, exts, ctx) {
|
|
|
137
177
|
return deps.row('gate-4', lang, deps.STATE.UNKNOWN, 'src/principles/analyzer.ts unreadable');
|
|
138
178
|
}
|
|
139
179
|
const filterLine = gate.split('\n').find((l) => l.includes('PRINCIPLES_FILES=')) || '';
|
|
140
|
-
const inFilter = deps
|
|
180
|
+
const inFilter = wiredInGate(deps, filterLine, exts, ctx, 'principles');
|
|
141
181
|
const inMap = exts.some((e) => analyzer.includes(`'.${e}':`));
|
|
142
182
|
if (inFilter && inMap) {
|
|
143
183
|
return deps.row('gate-4', lang, deps.STATE.CHECKED, 'filter + analyzer.ts adapterMap both present');
|
|
@@ -186,13 +226,37 @@ function inspectGate6(deps, lang, exts, ctx) {
|
|
|
186
226
|
: deps.row('gate-6', lang, deps.STATE.NOT_IMPLEMENTED, `no "${lang})" arm: falls to the no-detector branch`);
|
|
187
227
|
}
|
|
188
228
|
|
|
189
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Gate 9: build integrity arm.
|
|
231
|
+
*
|
|
232
|
+
* Only TypeScript and Java have a real half. Every OTHER language appears in a
|
|
233
|
+
* `case` whose whole purpose is to MARK ITSELF AS MISSING: it sets
|
|
234
|
+
* `_g9_rx` so the gate can report `<lang>:no_build_integrity_half` when the
|
|
235
|
+
* change set touches that language. The word "csharp" therefore occurs in
|
|
236
|
+
* `gate-9-entry.sh` while no build step for C# exists.
|
|
237
|
+
*
|
|
238
|
+
* A key-presence test cannot tell those apart, and read the marker as an
|
|
239
|
+
* implementation -- exactly the mistake that makes a declared gap look closed.
|
|
240
|
+
* The arm is recognised by the two languages that actually run something, and a
|
|
241
|
+
* language whose only mention is inside the missing-half report is NOT IMPLEMENTED.
|
|
242
|
+
*/
|
|
190
243
|
function inspectGate9(deps, lang, exts, ctx) {
|
|
191
244
|
const src = ctx.read('githooks/gate-entries/gate-9-entry.sh');
|
|
192
245
|
if (src === null) return deps.row('gate-9', lang, deps.STATE.UNKNOWN, 'gate-9-entry.sh unreadable');
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
246
|
+
|
|
247
|
+
// A language has a build half only when the script has a `case` arm that
|
|
248
|
+
// actually DOES something for it. The MISSING-HALF reporter also carries the
|
|
249
|
+
// language name (`csharp) _g9_rx='\.cs$'`), whose entire job is to record
|
|
250
|
+
// "<lang>:no_build_integrity_half" — counting that as an implementation is how
|
|
251
|
+
// a declared gap reads as closed. So the arm must be a real statement line,
|
|
252
|
+
// not the `_g9_rx` selector.
|
|
253
|
+
const armRe = new RegExp(`^\\s*${lang.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\)\\s*(.+)$`, 'm');
|
|
254
|
+
const arm = src.match(armRe);
|
|
255
|
+
const isRealArm = Boolean(arm) && !/^_g9_rx\s*=/.test(arm[1].trim());
|
|
256
|
+
if (isRealArm) {
|
|
257
|
+
return deps.row('gate-9', lang, deps.STATE.CHECKED, `"${lang})" arm present`);
|
|
258
|
+
}
|
|
259
|
+
return deps.row('gate-9', lang, deps.STATE.NOT_IMPLEMENTED, 'no build arm: this language is SKIPped with no verdict');
|
|
196
260
|
}
|
|
197
261
|
|
|
198
262
|
/**
|
|
@@ -320,6 +320,9 @@ function inspectLanguage(lang, ctx) {
|
|
|
320
320
|
STATE,
|
|
321
321
|
hasLanguageKey,
|
|
322
322
|
anyAlternationHas,
|
|
323
|
+
// Exposed so the surfaces can recognise an extension declared in
|
|
324
|
+
// `file-classifier.sh` rather than spelled out inside the gate script.
|
|
325
|
+
hasExtensionToken,
|
|
323
326
|
definitionAndCall,
|
|
324
327
|
SAST_BASELINE_LANGUAGES,
|
|
325
328
|
SURFACES,
|