@boyingliu01/xp-gate 0.38.75 → 0.38.77
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/lib/__tests__/mirror-sync.test.js +387 -5
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/mirror-sync.js +202 -15
- 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/lib/hooks.d.ts +10 -1
- package/plugins/dsh/lib/hooks.d.ts.map +1 -1
- package/plugins/dsh/lib/hooks.js +56 -5
- package/plugins/dsh/lib/index.js +6 -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/hooks.test.ts +70 -0
- package/plugins/dsh/src/hooks.ts +66 -5
- package/plugins/dsh/src/index.ts +6 -1
- 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/scripts/generate-mirrors.cjs +10 -0
- 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/mock-policy/__tests__/config.test.ts +0 -292
- package/mock-policy/__tests__/gate-m3.test.ts +0 -379
- package/mock-policy/__tests__/integration.test.ts +0 -600
- package/mock-policy/__tests__/mock-decision-engine.test.ts +0 -231
- package/mock-policy/__tests__/schema.test.ts +0 -239
- package/mock-policy/__tests__/scope-scanner.test.ts +0 -541
- package/mutation/__tests__/detect-ai-test.test.ts +0 -152
- package/mutation/__tests__/gate-m-survivors.test.ts +0 -167
- package/mutation/__tests__/gate-m.test.ts +0 -246
- package/mutation/__tests__/go-mutant-runner.test.ts +0 -288
- package/mutation/__tests__/gremlins-runner.test.ts +0 -167
- package/mutation/__tests__/init-baseline.test.ts +0 -347
- package/mutation/__tests__/mutation-mirror.test.ts +0 -49
- package/mutation/__tests__/mutmut-runner.test.ts +0 -1049
- package/mutation/__tests__/pitest-gradle-availability.test.ts +0 -74
- package/mutation/__tests__/pitest-runner.test.ts +0 -574
- package/mutation/__tests__/runners-index.test.ts +0 -162
- package/mutation/__tests__/stryker-runner.test.ts +0 -455
- package/mutation/__tests__/test-filter-parity.test.ts +0 -40
- package/mutation/__tests__/update-baseline.test.ts +0 -395
- package/principles/__tests__/adapter-metrics.test.ts +0 -292
- package/principles/__tests__/analyze-read-failure.test.ts +0 -70
- package/principles/__tests__/analyzer.test.ts +0 -367
- package/principles/__tests__/baseline-entry-total-warnings.test.ts +0 -76
- package/principles/__tests__/baseline-prune-timeout.test.ts +0 -71
- package/principles/__tests__/baseline-prune.test.ts +0 -399
- package/principles/__tests__/baseline-storage.test.ts +0 -188
- package/principles/__tests__/baseline.test.ts +0 -330
- package/principles/__tests__/boy-scout-init-baseline.test.ts +0 -167
- package/principles/__tests__/boy-scout-integration.test.ts +0 -355
- package/principles/__tests__/boy-scout.test.ts +0 -893
- package/principles/__tests__/cli-files-separators.test.ts +0 -69
- package/principles/__tests__/config-arch-group.test.ts +0 -106
- package/principles/__tests__/config-enforcement.test.ts +0 -470
- package/principles/__tests__/config-git-timeout.test.ts +0 -66
- package/principles/__tests__/config-merge-warnings.test.ts +0 -148
- package/principles/__tests__/config.test.ts +0 -78
- package/principles/__tests__/direct-execution.test.ts +0 -187
- package/principles/__tests__/index.test.ts +0 -94
- package/principles/__tests__/issue-587-java-member-count.test.ts +0 -279
- package/principles/__tests__/issue-588-lsp-java-false-positives.test.ts +0 -213
- package/principles/__tests__/lint-baseline.test.ts +0 -314
- package/principles/__tests__/many-exports-reexport.test.ts +0 -40
- package/principles/__tests__/reporter.test.ts +0 -660
- package/principles/__tests__/types.test.ts +0 -103
- package/principles/__tests__/warnings-baseline-budgets.test.ts +0 -74
- package/principles/adapters/__tests__/base.test.ts +0 -95
- package/principles/adapters/__tests__/cpp-code-block.test.ts +0 -123
- package/principles/adapters/__tests__/cpp-scanner-equivalence.test.ts +0 -67
- package/principles/adapters/__tests__/cpp.test.ts +0 -290
- package/principles/adapters/__tests__/dart.test.ts +0 -84
- package/principles/adapters/__tests__/go.test.ts +0 -68
- package/principles/adapters/__tests__/java.test.ts +0 -385
- package/principles/adapters/__tests__/kotlin.test.ts +0 -76
- package/principles/adapters/__tests__/objectivec.test.ts +0 -453
- package/principles/adapters/__tests__/python.test.ts +0 -84
- package/principles/adapters/__tests__/swift.test.ts +0 -68
- package/principles/adapters/__tests__/typescript-block-comment-lines.test.ts +0 -53
- package/principles/adapters/__tests__/typescript-masking.test.ts +0 -96
- package/principles/adapters/__tests__/typescript.test.ts +0 -116
- package/principles/rules/__tests__/clean-code/code-duplication.test.ts +0 -85
- package/principles/rules/__tests__/clean-code/deep-nesting.test.ts +0 -73
- package/principles/rules/__tests__/clean-code/god-class.test.ts +0 -109
- package/principles/rules/__tests__/clean-code/large-file.test.ts +0 -73
- package/principles/rules/__tests__/clean-code/long-function.test.ts +0 -81
- package/principles/rules/__tests__/clean-code/magic-numbers.test.ts +0 -68
- package/principles/rules/__tests__/clean-code/many-exports.test.ts +0 -123
- package/principles/rules/__tests__/clean-code/missing-error-handling.test.ts +0 -171
- package/principles/rules/__tests__/clean-code/too-many-params.test.ts +0 -58
- package/principles/rules/__tests__/clean-code/unused-imports.test.ts +0 -107
- package/principles/rules/__tests__/index.test.ts +0 -49
- package/principles/rules/__tests__/solid/dip.test.ts +0 -119
- package/principles/rules/__tests__/solid/isp.test.ts +0 -58
- package/principles/rules/__tests__/solid/issue-588-lsp-base-contract.test.ts +0 -252
- package/principles/rules/__tests__/solid/lsp.test.ts +0 -186
- package/principles/rules/__tests__/solid/ocp.test.ts +0 -67
- package/principles/rules/__tests__/solid/srp.test.ts +0 -87
- package/principles/rules/arch/__tests__/dependency.test.ts +0 -180
- package/principles/rules/arch/__tests__/naming.test.ts +0 -133
- package/principles/rules/arch/__tests__/shared.test.ts +0 -113
package/lib/mirror-sync.js
CHANGED
|
@@ -30,6 +30,15 @@ const fs = require('fs');
|
|
|
30
30
|
const path = require('path');
|
|
31
31
|
const { execFileSync } = require('child_process');
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The checkout root, derived from this file's location rather than from the
|
|
35
|
+
* caller's cwd: this module is invoked both from the repo root and from an
|
|
36
|
+
* installed copy, and `process.cwd()` differs between them.
|
|
37
|
+
*
|
|
38
|
+
* `src/npm-package/lib/` -> three levels up.
|
|
39
|
+
*/
|
|
40
|
+
const REPO_ROOT_DIR = path.resolve(__dirname, '..', '..', '..');
|
|
41
|
+
|
|
33
42
|
/**
|
|
34
43
|
* Directory names that are never mirrored, even when tracked.
|
|
35
44
|
*
|
|
@@ -38,6 +47,22 @@ const { execFileSync } = require('child_process');
|
|
|
38
47
|
*/
|
|
39
48
|
const SYNC_EXCLUDES = Object.freeze(['__pycache__', 'node_modules', '.git', '.DS_Store']);
|
|
40
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Directory names never mirrored into the package, for every pair.
|
|
52
|
+
*
|
|
53
|
+
* `__tests__` belongs here rather than in a per-pair `exclude`, because the
|
|
54
|
+
* decision is global and already made once: `sync-package-content.js` puts
|
|
55
|
+
* `__tests__` in its `SKIP_DIRS`, so no mirror ever receives test code.
|
|
56
|
+
*
|
|
57
|
+
* Declaring it per-pair made the same rule exist twice, and the copies drifted.
|
|
58
|
+
* Measured: `skills/sprint-flow/__tests__/` is tracked source, the generator
|
|
59
|
+
* correctly does not copy it, and `sync-mirrors` reported the whole pair as DRIFT
|
|
60
|
+
* on any checkout that has that directory. `src/principles` declared the exclude
|
|
61
|
+
* and stayed green; `skills` and `src/build-integrity` did not declare it and went
|
|
62
|
+
* red. One rule, one place.
|
|
63
|
+
*/
|
|
64
|
+
const MIRROR_EXCLUDES = Object.freeze([...SYNC_EXCLUDES, '__tests__']);
|
|
65
|
+
|
|
41
66
|
/**
|
|
42
67
|
* The canonical -> mirror pairs this repository maintains for whole trees.
|
|
43
68
|
*
|
|
@@ -53,17 +78,113 @@ const SYNC_EXCLUDES = Object.freeze(['__pycache__', 'node_modules', '.git', '.DS
|
|
|
53
78
|
* treating "canonical has it" as "the mirror should have it" where the project
|
|
54
79
|
* never said so.
|
|
55
80
|
*
|
|
56
|
-
* Per-pair `exclude`
|
|
57
|
-
*
|
|
58
|
-
*
|
|
81
|
+
* Per-pair `exclude` stays available for a rule that genuinely applies to one
|
|
82
|
+
* pair only. `__tests__` is not one of those -- see `MIRROR_EXCLUDES`.
|
|
83
|
+
*
|
|
84
|
+
* P1-E step 3: the pairs a generator owns are now DERIVED from that generator
|
|
85
|
+
* instead of being listed again here. Two hand-written lists had already drifted:
|
|
86
|
+
* this table carried five pairs and `generate-mirrors.cjs` carried four (it did
|
|
87
|
+
* not know about `principles`), and neither knew about `mutation` or
|
|
88
|
+
* `mock-policy`, which shipped in the package with no generator at all. A pair
|
|
89
|
+
* that exists in one list and not the other is invisible to exactly the check
|
|
90
|
+
* meant to catch it.
|
|
91
|
+
*
|
|
92
|
+
* A generator tree that cannot be resolved is skipped rather than thrown: this
|
|
93
|
+
* module also runs from an installed copy, where the repository layout it would
|
|
94
|
+
* read does not exist. Skipping reproduces the old hand-listed behaviour for that
|
|
95
|
+
* pair instead of crashing a diagnostic command.
|
|
96
|
+
*/
|
|
97
|
+
function generatedPairs() {
|
|
98
|
+
let trees;
|
|
99
|
+
try {
|
|
100
|
+
trees = require('../scripts/generate-mirrors.cjs').GENERATED_TREES;
|
|
101
|
+
} catch {
|
|
102
|
+
// Not running from a checkout: an installed package ships `lib/` but NOT the
|
|
103
|
+
// `scripts/` tree this module reads its pairs from. Returning [] is correct
|
|
104
|
+
// there -- the canonical trees (`githooks/`, `src/`) are not installed either,
|
|
105
|
+
// so there is nothing to compare and no detection capability is lost.
|
|
106
|
+
//
|
|
107
|
+
// This must stay distinguishable from "the generator exists but yielded
|
|
108
|
+
// nothing", which would be a broken checkout. `assertPairsResolved` below
|
|
109
|
+
// makes that case loud instead of silently reporting zero drift.
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
if (!Array.isArray(trees)) return [];
|
|
113
|
+
const repoRelative = (abs) => path.relative(REPO_ROOT_DIR, abs).split(path.sep).join('/');
|
|
114
|
+
return trees.map((tree) => ({
|
|
115
|
+
canonical: repoRelative(tree.canonical),
|
|
116
|
+
mirror: `src/npm-package/${tree.mirror}`,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Pairs supervised by something OTHER than `GENERATED_TREES`.
|
|
122
|
+
*
|
|
123
|
+
* Empty as of P1-E step 4. `principles` was the last entry: it had a separate
|
|
124
|
+
* generation path and was listed here by hand, then moved into the generator once
|
|
125
|
+
* the workstream editing it in place landed. Keeping the named empty list rather
|
|
126
|
+
* than deleting it gives the next genuinely non-generatable pair an obvious home,
|
|
127
|
+
* instead of someone hand-adding it back to `KNOWN_PAIRS` and recreating the
|
|
128
|
+
* two-lists-that-disagree problem this file just removed.
|
|
59
129
|
*/
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
130
|
+
const HAND_LISTED_PAIRS = Object.freeze([]);
|
|
131
|
+
|
|
132
|
+
const KNOWN_PAIRS = Object.freeze([...generatedPairs(), ...HAND_LISTED_PAIRS]);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Refuse to report a clean result over an empty pair list in a real checkout.
|
|
136
|
+
*
|
|
137
|
+
* Every pair is derived now, so if the generator cannot be resolved AND nothing is
|
|
138
|
+
* hand-listed, `KNOWN_PAIRS` is empty and every query answers "nothing drifted".
|
|
139
|
+
* That is the right answer for an installed package -- but in a checkout it would
|
|
140
|
+
* be a broken tool reporting a perfect score, which is the single failure mode
|
|
141
|
+
* this module exists to eliminate.
|
|
142
|
+
*
|
|
143
|
+
* The distinction is made on whether the generator file EXISTS, not on whether the
|
|
144
|
+
* list is empty: a missing generator in a checkout means the layout moved, while a
|
|
145
|
+
* missing generator outside one is expected. Cheap enough to run per command.
|
|
146
|
+
*
|
|
147
|
+
* CONTRACT -- `null` has two different causes, and callers must not conflate them:
|
|
148
|
+
*
|
|
149
|
+
* - generator absent -> null, because this is not a checkout. A caller that
|
|
150
|
+
* reacts to null as "you are in the wrong directory" is
|
|
151
|
+
* right; a caller that reacts as "your pairs are broken"
|
|
152
|
+
* is wrong.
|
|
153
|
+
* - pairs non-empty -> null, because there is something to compare and the
|
|
154
|
+
* generator was found. This is the silent, healthy case.
|
|
155
|
+
*
|
|
156
|
+
* An empty `pairs` array in a checkout is NEVER silent: it is the broken-tool case
|
|
157
|
+
* the function exists to catch, and it returns the reason string. Review flagged
|
|
158
|
+
* this as a load-bearing but undocumented assumption, which is why it is written
|
|
159
|
+
* down here rather than only implied by the tests.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} root repository root to check
|
|
162
|
+
* @param {ReadonlyArray<object>} [pairs] pair list to judge; defaults to KNOWN_PAIRS
|
|
163
|
+
* so call sites never pass it. Injectable purely so the zero-pair branch is
|
|
164
|
+
* reachable from a test -- a module-level constant cannot be emptied by a fixture.
|
|
165
|
+
* @returns {string|null} an error message, or null when the pair list is usable
|
|
166
|
+
*/
|
|
167
|
+
function assertPairsResolved(root, pairs = KNOWN_PAIRS) {
|
|
168
|
+
const generatorPath = path.join(root, 'src', 'npm-package', 'scripts', 'generate-mirrors.cjs');
|
|
169
|
+
if (!fs.existsSync(generatorPath)) {
|
|
170
|
+
// Not a checkout (installed package, or an unrelated directory). Zero pairs is
|
|
171
|
+
// the correct answer there: the canonical trees are not installed either, so
|
|
172
|
+
// there is nothing to compare and no capability is lost.
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
// `pairs` is a parameter rather than a closed-over constant so the error branch
|
|
176
|
+
// below is REACHABLE. Reading KNOWN_PAIRS directly made it unreachable: that
|
|
177
|
+
// constant is resolved once at require time against this repository, so no
|
|
178
|
+
// fixture could make it empty and no test could ever execute the branch. The
|
|
179
|
+
// default keeps every existing call site unchanged.
|
|
180
|
+
if (pairs.length > 0) return null;
|
|
181
|
+
return (
|
|
182
|
+
'mirror-sync resolved ZERO mirror pairs although ' +
|
|
183
|
+
'src/npm-package/scripts/generate-mirrors.cjs exists. Every pair is derived from its ' +
|
|
184
|
+
'GENERATED_TREES export now, so zero pairs means the export is missing or renamed. ' +
|
|
185
|
+
'Refusing to report "nothing drifted" over an empty set.'
|
|
186
|
+
);
|
|
187
|
+
}
|
|
67
188
|
|
|
68
189
|
/**
|
|
69
190
|
* List files under `dir` relative to `dir`, honouring exclusions.
|
|
@@ -83,7 +204,7 @@ function listFiles(root, dir) {
|
|
|
83
204
|
return;
|
|
84
205
|
}
|
|
85
206
|
for (const entry of entries) {
|
|
86
|
-
if (
|
|
207
|
+
if (MIRROR_EXCLUDES.includes(entry.name)) continue;
|
|
87
208
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
88
209
|
if (entry.isDirectory()) {
|
|
89
210
|
walk(path.join(current, entry.name), rel);
|
|
@@ -96,6 +217,36 @@ function listFiles(root, dir) {
|
|
|
96
217
|
return out.sort();
|
|
97
218
|
}
|
|
98
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Is `dir` excluded from version control by an ignore rule?
|
|
222
|
+
*
|
|
223
|
+
* `--no-index` is required to get a straight answer. Without it, `git check-ignore`
|
|
224
|
+
* reports nothing for paths that ARE tracked, so a tree that is both tracked and
|
|
225
|
+
* matched by an ignore rule answers "not ignored" -- the opposite of what the rule
|
|
226
|
+
* says. Verified in a scratch repo: with the file staged, plain `check-ignore`
|
|
227
|
+
* exits 1 while `--no-index` exits 0.
|
|
228
|
+
*
|
|
229
|
+
* A path that is not ignored exits 1, and so does a path outside any repository.
|
|
230
|
+
* Both mean "cannot claim this tree is generated", which is the safe answer: the
|
|
231
|
+
* caller then keeps the pre-existing tracked comparison.
|
|
232
|
+
*
|
|
233
|
+
* @param {string} root repository root
|
|
234
|
+
* @param {string} dir directory relative to root
|
|
235
|
+
* @returns {boolean}
|
|
236
|
+
*/
|
|
237
|
+
function isIgnored(root, dir) {
|
|
238
|
+
const normalised = dir.replace(/\\/g, '/');
|
|
239
|
+
try {
|
|
240
|
+
execFileSync('git', ['check-ignore', '--no-index', '-q', '--', normalised], {
|
|
241
|
+
cwd: root,
|
|
242
|
+
stdio: 'ignore',
|
|
243
|
+
});
|
|
244
|
+
return true;
|
|
245
|
+
} catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
99
250
|
/**
|
|
100
251
|
* List the files git tracks under `dir` that also exist on disk.
|
|
101
252
|
*
|
|
@@ -107,6 +258,16 @@ function listFiles(root, dir) {
|
|
|
107
258
|
* a plain walk — the caller is then responsible for the artifact caveat, but a
|
|
108
259
|
* check that crashes outside git is worse than one that reports what it sees.
|
|
109
260
|
*
|
|
261
|
+
* P1-E: when `dir` is IGNORED, an empty `git ls-files` result means "nobody tracks
|
|
262
|
+
* this tree", not "this tree is empty". The mirror trees are generated at prepack
|
|
263
|
+
* and gitignored on purpose, so the tracked question has no answer for them, and
|
|
264
|
+
* asking it reports every canonical file as missing from its mirror. Measured on
|
|
265
|
+
* the real repo after P1-E landed: DRIFT for adapters, hooks/lib, build-integrity
|
|
266
|
+
* and skills -- the four trees the generator had just written correctly.
|
|
267
|
+
*
|
|
268
|
+
* The fallback is gated on the ignore RULE, not on an empty result, so a mirror
|
|
269
|
+
* tree someone genuinely emptied still reports its files as missing.
|
|
270
|
+
*
|
|
110
271
|
* @param {string} root repository root
|
|
111
272
|
* @param {string} dir directory relative to root
|
|
112
273
|
* @returns {string[]}
|
|
@@ -126,13 +287,23 @@ function listTrackedFiles(root, dir) {
|
|
|
126
287
|
.map((p) => p.replace(/\\/g, '/'))
|
|
127
288
|
.filter((p) => p.startsWith(`${normalised}/`))
|
|
128
289
|
.map((p) => p.slice(normalised.length + 1))
|
|
129
|
-
.filter((p) => !p.split('/').some((seg) =>
|
|
290
|
+
.filter((p) => !p.split('/').some((seg) => MIRROR_EXCLUDES.includes(seg)));
|
|
130
291
|
} catch {
|
|
131
292
|
return listFiles(root, dir);
|
|
132
293
|
}
|
|
133
294
|
|
|
134
295
|
// Keep only what is actually on disk; a tracked-but-deleted file must read as
|
|
135
296
|
// "missing from this side", which is what the caller then repairs.
|
|
297
|
+
// P1-E: an IGNORED tree has no tracked files by design, so "git tracks nothing
|
|
298
|
+
// here" must not be read as "there are no files here". The walk returns the same
|
|
299
|
+
// set the generator enumerates, and SYNC_EXCLUDES still filters it, so cache
|
|
300
|
+
// directories do not resurface as orphans (the #587/#588 false failure).
|
|
301
|
+
if (tracked.length === 0 && isIgnored(root, dir)) {
|
|
302
|
+
return listFiles(root, dir).filter(
|
|
303
|
+
(p) => !p.split('/').some((seg) => MIRROR_EXCLUDES.includes(seg))
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
136
307
|
return tracked
|
|
137
308
|
.filter((p) => fs.existsSync(path.join(root, dir, p)))
|
|
138
309
|
.sort();
|
|
@@ -142,7 +313,10 @@ function listTrackedFiles(root, dir) {
|
|
|
142
313
|
* Compare a canonical tree against its mirror.
|
|
143
314
|
*
|
|
144
315
|
* Both sides are compared on the tracked file set so an untracked artifact in
|
|
145
|
-
* either tree cannot be mistaken for drift.
|
|
316
|
+
* either tree cannot be mistaken for drift. A tree that is gitignored entirely
|
|
317
|
+
* (a generated mirror) is compared on its disk contents instead -- see
|
|
318
|
+
* `listTrackedFiles` for why. The choice is per tree, so a pair with a tracked
|
|
319
|
+
* canonical tree and a generated mirror behaves correctly on both sides.
|
|
146
320
|
*
|
|
147
321
|
* @param {string} root repository root
|
|
148
322
|
* @param {string} canonical canonical dir (relative)
|
|
@@ -151,7 +325,9 @@ function listTrackedFiles(root, dir) {
|
|
|
151
325
|
* @returns {{inSync: boolean, missing: string[], differing: string[], extra: string[]}}
|
|
152
326
|
*/
|
|
153
327
|
function diffTrees(root, canonical, mirror, options = {}) {
|
|
154
|
-
|
|
328
|
+
// The per-pair list ADDS to the global rule, it does not replace it: a caller
|
|
329
|
+
// passing `exclude: ['dist']` must not silently re-enable `__tests__`.
|
|
330
|
+
const exclude = [...MIRROR_EXCLUDES, ...(options.exclude || [])];
|
|
155
331
|
const keep = (rel) => !rel.split('/').some((seg) => exclude.includes(seg));
|
|
156
332
|
const canonicalFiles = listTrackedFiles(root, canonical).filter(keep);
|
|
157
333
|
const mirrorFiles = listTrackedFiles(root, mirror).filter(keep);
|
|
@@ -282,7 +458,16 @@ function handleSyncMirrors(argv, options = {}) {
|
|
|
282
458
|
|
|
283
459
|
const pairs = collectMirrorPairs(root);
|
|
284
460
|
if (pairs.length === 0) {
|
|
285
|
-
|
|
461
|
+
// Not silently "all in sync": zero pairs means nothing was checked, and an
|
|
462
|
+
// empty verdict must never read as a passing one. The message distinguishes
|
|
463
|
+
// "wrong directory" from "the generator broke", because the second is a real
|
|
464
|
+
// defect in a checkout and the first is a typing mistake.
|
|
465
|
+
const broken = assertPairsResolved(root);
|
|
466
|
+
process.stdout.write(
|
|
467
|
+
broken
|
|
468
|
+
? `sync-mirrors: NOT MEASURABLE\n ${broken}\n`
|
|
469
|
+
: 'sync-mirrors: NOT MEASURABLE (no mirror pairs found — is this the xp-gate repo?)\n'
|
|
470
|
+
);
|
|
286
471
|
return 1;
|
|
287
472
|
}
|
|
288
473
|
|
|
@@ -326,6 +511,8 @@ function handleSyncMirrors(argv, options = {}) {
|
|
|
326
511
|
module.exports = {
|
|
327
512
|
SYNC_EXCLUDES,
|
|
328
513
|
KNOWN_PAIRS,
|
|
514
|
+
HAND_LISTED_PAIRS,
|
|
515
|
+
assertPairsResolved,
|
|
329
516
|
listFiles,
|
|
330
517
|
listTrackedFiles,
|
|
331
518
|
diffTrees,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xp-gate",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.77",
|
|
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.
|
|
6
|
+
**Version:** 0.38.77.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.
|
|
6
|
+
**Version:** 0.38.77.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.
|
|
6
|
+
**Version:** 0.38.77.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|
|
@@ -23,6 +23,11 @@ export interface GuardDenial {
|
|
|
23
23
|
readonly kind: "deny";
|
|
24
24
|
readonly reason: string;
|
|
25
25
|
}
|
|
26
|
+
/** Where a tool call is aimed, when it names a file. */
|
|
27
|
+
export interface GuardTarget {
|
|
28
|
+
/** Absolute or cwd-relative path of the file being written. */
|
|
29
|
+
readonly path?: string;
|
|
30
|
+
}
|
|
26
31
|
/**
|
|
27
32
|
* Can this tool modify the workspace? Anything not proven read-only can.
|
|
28
33
|
*
|
|
@@ -52,6 +57,10 @@ export declare function isCheckablePath(path: string): boolean;
|
|
|
52
57
|
* Decide whether an edit may proceed.
|
|
53
58
|
*
|
|
54
59
|
* Returns undefined to mean "allow" so the caller can `if (denial) return denial`.
|
|
60
|
+
*
|
|
61
|
+
* `target` is what the call is aimed at. When it names a file, that file's worktree
|
|
62
|
+
* decides -- passing the session cwd alone is what let concurrent sprints jail each
|
|
63
|
+
* other; see {@link guardRoot}.
|
|
55
64
|
*/
|
|
56
|
-
export declare function delphiGuardDecision(root: string, toolName: string): GuardDenial | undefined;
|
|
65
|
+
export declare function delphiGuardDecision(root: string, toolName: string, target?: GuardTarget): GuardDenial | undefined;
|
|
57
66
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAyDH,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAyDH,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAoED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKrD;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,WAAW,GAAG,SAAS,CA+BzB"}
|
package/plugins/dsh/lib/hooks.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* aborts the tool call, which is a worse failure than letting an edit through.
|
|
20
20
|
*/
|
|
21
21
|
import { existsSync, readFileSync } from "node:fs";
|
|
22
|
-
import { join } from "node:path";
|
|
22
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
23
23
|
/**
|
|
24
24
|
* Tools the sprint guard must never block. Everything else is gated.
|
|
25
25
|
*
|
|
@@ -70,6 +70,52 @@ const UNGATED_TOOLS = new Set([
|
|
|
70
70
|
/** Where Sprint Flow records the review verdict. */
|
|
71
71
|
const SPRINT_STATE_DIR = ".sprint-state";
|
|
72
72
|
const VERDICT_FILE = "delphi-reviewed.json";
|
|
73
|
+
/**
|
|
74
|
+
* The filesystem root that should be judged for this call.
|
|
75
|
+
*
|
|
76
|
+
* `.sprint-state/` is gitignored, so EVERY worktree carries its own copy and every
|
|
77
|
+
* sprint runs its review inside its own worktree. Judging by the session cwd
|
|
78
|
+
* instead has two consequences, both measured against a real session:
|
|
79
|
+
*
|
|
80
|
+
* - sprints jail each other: one worktree's REQUEST_CHANGES blocked writes into a
|
|
81
|
+
* DIFFERENT worktree that had already reached APPROVED, so only one sprint could
|
|
82
|
+
* be unblocked at a time;
|
|
83
|
+
* - an APPROVED verdict leaks: a session opened in an approved worktree would
|
|
84
|
+
* authorise writes into any other checkout on disk.
|
|
85
|
+
*
|
|
86
|
+
* So the target file decides when there is one. Tools that name no file (`bash`)
|
|
87
|
+
* keep the session cwd, which is the only root they can honestly be attributed to.
|
|
88
|
+
*/
|
|
89
|
+
function guardRoot(cwd, target) {
|
|
90
|
+
if (!target?.path)
|
|
91
|
+
return cwd;
|
|
92
|
+
const absolute = isAbsolute(target.path) ? target.path : resolve(cwd, target.path);
|
|
93
|
+
return findWorktreeRoot(dirname(absolute)) ?? resolveWorktreeRoot(cwd);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Walk up from `start` to the nearest directory holding `.sprint-state`, and report
|
|
97
|
+
* the worktree root that directory belongs to.
|
|
98
|
+
*
|
|
99
|
+
* Stopping at the first `.sprint-state` is what keeps two worktrees apart: each has
|
|
100
|
+
* its own, so the walk finds the closest one rather than a parent checkout's.
|
|
101
|
+
*/
|
|
102
|
+
function findWorktreeRoot(start) {
|
|
103
|
+
let dir = start;
|
|
104
|
+
// Bounded: a malformed tree must not spin, and a real path never needs more.
|
|
105
|
+
for (let depth = 0; depth < 64; depth += 1) {
|
|
106
|
+
if (existsSync(join(dir, SPRINT_STATE_DIR)))
|
|
107
|
+
return dir;
|
|
108
|
+
const parent = dirname(dir);
|
|
109
|
+
if (parent === dir)
|
|
110
|
+
break;
|
|
111
|
+
dir = parent;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
/** The worktree root a cwd sits in, whether or not it has sprint state yet. */
|
|
116
|
+
function resolveWorktreeRoot(cwd) {
|
|
117
|
+
return findWorktreeRoot(cwd) ?? cwd;
|
|
118
|
+
}
|
|
73
119
|
/** The file extensions the principles engine actually covers. */
|
|
74
120
|
const CHECKABLE_EXTENSIONS = new Set([
|
|
75
121
|
".ts",
|
|
@@ -142,13 +188,18 @@ function readVerdict(root) {
|
|
|
142
188
|
* Decide whether an edit may proceed.
|
|
143
189
|
*
|
|
144
190
|
* Returns undefined to mean "allow" so the caller can `if (denial) return denial`.
|
|
191
|
+
*
|
|
192
|
+
* `target` is what the call is aimed at. When it names a file, that file's worktree
|
|
193
|
+
* decides -- passing the session cwd alone is what let concurrent sprints jail each
|
|
194
|
+
* other; see {@link guardRoot}.
|
|
145
195
|
*/
|
|
146
|
-
export function delphiGuardDecision(root, toolName) {
|
|
196
|
+
export function delphiGuardDecision(root, toolName, target) {
|
|
147
197
|
if (!mayModifyFiles(toolName))
|
|
148
198
|
return undefined;
|
|
149
|
-
|
|
199
|
+
const stateRoot = guardRoot(root, target);
|
|
200
|
+
if (!existsSync(join(stateRoot, SPRINT_STATE_DIR)))
|
|
150
201
|
return undefined;
|
|
151
|
-
const verdictFile = join(
|
|
202
|
+
const verdictFile = join(stateRoot, SPRINT_STATE_DIR, VERDICT_FILE);
|
|
152
203
|
if (!existsSync(verdictFile)) {
|
|
153
204
|
return {
|
|
154
205
|
kind: "deny",
|
|
@@ -156,7 +207,7 @@ export function delphiGuardDecision(root, toolName) {
|
|
|
156
207
|
"before modifying code, then retry.",
|
|
157
208
|
};
|
|
158
209
|
}
|
|
159
|
-
const { verdict, unreadable } = readVerdict(
|
|
210
|
+
const { verdict, unreadable } = readVerdict(stateRoot);
|
|
160
211
|
if (unreadable !== undefined) {
|
|
161
212
|
return {
|
|
162
213
|
kind: "deny",
|
package/plugins/dsh/lib/index.js
CHANGED
|
@@ -539,8 +539,13 @@ function registerHooks(ctx, shell, dialect, cfg) {
|
|
|
539
539
|
if (cfg.delphiGuard !== "off") {
|
|
540
540
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
541
541
|
const cwd = sessionCwd(exec) ?? process.cwd();
|
|
542
|
+
// The file decides which worktree is judged when the call names one: sprints
|
|
543
|
+
// run in separate worktrees with their own `.sprint-state`, so judging by the
|
|
544
|
+
// session cwd alone let one sprint block another (and let one APPROVED verdict
|
|
545
|
+
// authorise writes anywhere). See guardRoot in hooks.ts.
|
|
546
|
+
const target = { path: writtenPath(exec.arguments) };
|
|
542
547
|
// Deny before dispatch so the edit never reaches the filesystem.
|
|
543
|
-
return delphiGuardDecision(cwd, exec.name) ?? next();
|
|
548
|
+
return delphiGuardDecision(cwd, exec.name, target) ?? next();
|
|
544
549
|
});
|
|
545
550
|
}
|
|
546
551
|
if (cfg.principlesCheck !== "off") {
|
package/plugins/dsh/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boyingliu01/dsh-plugin-xp-gate",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.77",
|
|
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.
|
|
6
|
+
**Version:** 0.38.77.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.
|
|
6
|
+
**Version:** 0.38.77.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.
|
|
6
|
+
**Version:** 0.38.77.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|
|
@@ -175,3 +175,73 @@ describe("delphiGuardDecision deadlock", () => {
|
|
|
175
175
|
}
|
|
176
176
|
})
|
|
177
177
|
})
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @test REQ-DSH-016 worktrees do not gate each other
|
|
181
|
+
* @intent 复现并锁定「worktree 互锁」:判定只读会话 cwd 下的 .sprint-state,
|
|
182
|
+
* 不看目标文件属于哪个 worktree,导致 A worktree 的未通过评审
|
|
183
|
+
* 拦住 B worktree 的写入(反之亦然)。
|
|
184
|
+
* @covers AC-DSH-016-01 AC-DSH-016-02
|
|
185
|
+
*
|
|
186
|
+
* `.sprint-state/` is gitignored, so every worktree carries its OWN copy and every
|
|
187
|
+
* sprint runs its review inside its own worktree. Measured against a real session
|
|
188
|
+
* before the fix: with the session cwd in a REQUEST_CHANGES worktree, an edit aimed
|
|
189
|
+
* at a *different* worktree that had already reached APPROVED was still denied --
|
|
190
|
+
* the two sprints jailed each other. Only one could be unblocked at a time, and
|
|
191
|
+
* running a second review made it worse rather than better.
|
|
192
|
+
*/
|
|
193
|
+
describe("delphiGuardDecision across worktrees", () => {
|
|
194
|
+
/** Build a checkout-shaped directory with a given verdict. */
|
|
195
|
+
function checkout(verdict: "APPROVED" | "REQUEST_CHANGES" | "none"): string {
|
|
196
|
+
const root = mkdtempSync(join(dir, "wt-"))
|
|
197
|
+
if (verdict === "none") return root
|
|
198
|
+
try {
|
|
199
|
+
mkdirSync(join(root, ".sprint-state"), { recursive: true })
|
|
200
|
+
writeFileSync(
|
|
201
|
+
join(root, ".sprint-state", "delphi-reviewed.json"),
|
|
202
|
+
JSON.stringify({ verdict, timestamp: "2026-10-27T10:00:00.000Z" }),
|
|
203
|
+
"utf8",
|
|
204
|
+
)
|
|
205
|
+
} catch (error) {
|
|
206
|
+
throw new Error(`cannot build scratch worktree: ${(error as Error).message}`)
|
|
207
|
+
}
|
|
208
|
+
return root
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
it("judges the worktree the file belongs to, not the one the session opened in", () => {
|
|
212
|
+
// The failing worktree opened first; the approved one is the actual target.
|
|
213
|
+
const rejected = checkout("REQUEST_CHANGES")
|
|
214
|
+
const approved = checkout("APPROVED")
|
|
215
|
+
const target = join(approved, "src", "impl.ts")
|
|
216
|
+
|
|
217
|
+
expect(
|
|
218
|
+
delphiGuardDecision(rejected, "edit", { path: target }),
|
|
219
|
+
"a write into the APPROVED worktree must not be stopped by another worktree's rejection",
|
|
220
|
+
).toBeUndefined()
|
|
221
|
+
|
|
222
|
+
// And the converse still holds: the rejected worktree stays gated from itself.
|
|
223
|
+
expect(
|
|
224
|
+
delphiGuardDecision(rejected, "edit", { path: join(rejected, "src", "impl.ts") }),
|
|
225
|
+
"the REQUEST_CHANGES worktree must still gate its own writes",
|
|
226
|
+
).toBeDefined()
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it("does not let an approved worktree authorise writes elsewhere", () => {
|
|
230
|
+
// Without this, the fix would be a hole: opening the session in an approved
|
|
231
|
+
// worktree would unlock every other checkout on disk.
|
|
232
|
+
const approved = checkout("APPROVED")
|
|
233
|
+
const rejected = checkout("REQUEST_CHANGES")
|
|
234
|
+
|
|
235
|
+
expect(
|
|
236
|
+
delphiGuardDecision(approved, "edit", { path: join(rejected, "src", "impl.ts") }),
|
|
237
|
+
"an APPROVED verdict must not travel to another worktree",
|
|
238
|
+
).toBeDefined()
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it("keeps the session cwd as the fallback when the tool names no target", () => {
|
|
242
|
+
// `bash` carries no file_path. It must still be judged against the session's
|
|
243
|
+
// worktree, which is the only root the guard can attribute it to.
|
|
244
|
+
const rejected = checkout("REQUEST_CHANGES")
|
|
245
|
+
expect(delphiGuardDecision(rejected, "bash")).toBeDefined()
|
|
246
|
+
})
|
|
247
|
+
})
|