@boyingliu01/xp-gate 0.23.0 → 0.25.0

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.
Files changed (61) hide show
  1. package/adapter-common.sh +51 -2
  2. package/adapters/python.sh +10 -2
  3. package/bin/xp-gate.js +15 -1
  4. package/hooks/adapter-common.sh +51 -2
  5. package/hooks/lib/coverage-total.sh +20 -0
  6. package/hooks/lib/python-test-selection.sh +132 -0
  7. package/hooks/pre-commit +100 -11
  8. package/lib/__tests__/delphi-setup.test.js +203 -0
  9. package/lib/__tests__/doctor-delphi.test.js +244 -0
  10. package/lib/__tests__/init-gitleaks-notice.test.js +57 -0
  11. package/lib/__tests__/issue-519-phase-transition-guard.test.js +233 -0
  12. package/lib/__tests__/qoder-delphi-agents.test.js +31 -0
  13. package/lib/delphi-setup.js +155 -0
  14. package/lib/doctor.js +269 -1
  15. package/lib/init.js +49 -1
  16. package/lib/mattpocock-license-verdict.json +1 -1
  17. package/lib/phase-transition.js +61 -0
  18. package/lib/sprint-state-manager.js +86 -39
  19. package/lib/sprint-state-migrator.js +60 -22
  20. package/mock-policy/AGENTS.md +3 -3
  21. package/mutation/AGENTS.md +3 -3
  22. package/mutation/__tests__/gremlins-runner.test.ts +167 -0
  23. package/mutation/__tests__/mutmut-runner.test.ts +20 -22
  24. package/mutation/__tests__/runners-index.test.ts +31 -3
  25. package/mutation/gate-m.ts +22 -4
  26. package/mutation/runners/gremlins-runner.ts +238 -0
  27. package/mutation/runners/index.ts +9 -1
  28. package/mutation/runners/mutmut-runner.ts +18 -12
  29. package/mutation/runners/types.ts +20 -0
  30. package/package.json +1 -1
  31. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  32. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +24 -1
  33. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  34. package/plugins/claude-code/skills/delphi-review/SKILL.md +43 -0
  35. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  36. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  37. package/plugins/dsh/package.json +1 -1
  38. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +24 -1
  39. package/plugins/dsh/skills/delphi-review/AGENTS.md +3 -3
  40. package/plugins/dsh/skills/delphi-review/SKILL.md +43 -0
  41. package/plugins/dsh/skills/sprint-flow/AGENTS.md +3 -3
  42. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +3 -3
  43. package/plugins/opencode/package.json +1 -1
  44. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +24 -1
  45. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  46. package/plugins/opencode/skills/delphi-review/SKILL.md +43 -0
  47. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  48. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  49. package/plugins/qoder/plugin.json +1 -1
  50. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +24 -1
  51. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  52. package/plugins/qoder/skills/delphi-review/SKILL.md +43 -0
  53. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  54. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  55. package/principles/AGENTS.md +3 -3
  56. package/scripts/delphi-external-review.cjs +166 -14
  57. package/skills/delphi-review/.delphi-config.json.example +24 -1
  58. package/skills/delphi-review/AGENTS.md +3 -3
  59. package/skills/delphi-review/SKILL.md +43 -0
  60. package/skills/sprint-flow/AGENTS.md +3 -3
  61. package/skills/test-specification-alignment/AGENTS.md +3 -3
@@ -0,0 +1,238 @@
1
+ // @no-test-required: gremlins wrapper — tested via gremlins-runner.test.ts + pre-push Gate M
2
+ import { spawn, execSync, type ChildProcess } from 'child_process';
3
+ import { dirname } from 'path';
4
+ import type {
5
+ MutationRunner,
6
+ RunMutationOptions,
7
+ MutationRunOutcome,
8
+ MutationRunResult,
9
+ } from './types';
10
+
11
+ /**
12
+ * pytest-gremlins mutation runner for Python files (#410).
13
+ *
14
+ * Why a second Python engine exists: mutmut 3.x is built on fork(), so on
15
+ * Windows it can only run under WSL — a native Windows user had a structural
16
+ * deadlock (installed => `mutmut run` exits 1 => push blocked; uninstalled =>
17
+ * Gate M skips). pytest-gremlins uses mutation *switching* (instrument once,
18
+ * flip an env var per mutant) with no fork and no per-mutant file I/O, making
19
+ * it natively cross-platform. It also matches Gate M's needs: coverage-guided
20
+ * test selection, an incremental content-hash cache, parallel workers and
21
+ * console/HTML/JSON reports.
22
+ *
23
+ * Constraint: pytest-gremlins requires Python >= 3.11. On older interpreters
24
+ * the import probe simply fails and the caller keeps the mutmut path (or
25
+ * SKIPs) — no new hard dependency.
26
+ */
27
+ /**
28
+ * How long to wait after SIGTERM before escalating to SIGKILL. pytest-gremlins
29
+ * runs a whole pytest session per invocation, so a child that ignores SIGTERM
30
+ * (stuck in a C extension) still needs a hard backstop.
31
+ */
32
+ const SIGKILL_ESCALATION_MS = 5000;
33
+
34
+ /** Bound on the one-shot import probe; a hung interpreter must not stall Gate M. */
35
+ const PROBE_TIMEOUT_MS = 10000;
36
+
37
+ /**
38
+ * Exactly-once resolve bookkeeping for a spawned mutation run.
39
+ *
40
+ * A child can report `close`, `error`, a timeout, and the SIGKILL escalation in
41
+ * any interleaving; without a single latched gate the Promise resolves twice
42
+ * (subsequent resolves are silent no-ops, but the *first* one wins, which can
43
+ * be the wrong verdict). `settled` makes the ordering irrelevant. Extracted
44
+ * from `spawnGremlins` so that function stays under the long-function budget.
45
+ *
46
+ * A factory rather than a class: it holds no collaborators to inject, and the
47
+ * SOLID analyzer flags `new X()` as a dependency-inversion smell regardless of
48
+ * whether the type is injectable.
49
+ */
50
+ function createSettleGuard(resolve: (o: MutationRunOutcome) => void) {
51
+ let settled = false;
52
+ let escalationId: NodeJS.Timeout | undefined;
53
+ let timeoutId: NodeJS.Timeout | undefined;
54
+
55
+ const escalateToKill = (child: ChildProcess): void => {
56
+ if (!settled) child.kill('SIGKILL');
57
+ };
58
+
59
+ const guard = {
60
+ timedOut: false,
61
+ /** SIGTERM at `timeoutMs`, escalating to SIGKILL if the child ignores it. */
62
+ armTimeout(child: ChildProcess, timeoutMs: number): void {
63
+ timeoutId = setTimeout(() => {
64
+ guard.timedOut = true;
65
+ child.kill('SIGTERM');
66
+ if (settled) return;
67
+ escalationId = setTimeout(() => escalateToKill(child), SIGKILL_ESCALATION_MS);
68
+ }, timeoutMs);
69
+ },
70
+ settle(outcome: MutationRunOutcome): void {
71
+ if (settled) return;
72
+ settled = true;
73
+ if (timeoutId) clearTimeout(timeoutId);
74
+ if (escalationId) clearTimeout(escalationId);
75
+ resolve(outcome);
76
+ },
77
+ };
78
+ return guard;
79
+ }
80
+
81
+ export class GremlinsRunner implements MutationRunner {
82
+ readonly name = 'pytest-gremlins';
83
+ readonly extensions = ['py'];
84
+
85
+ async isAvailable(): Promise<boolean> {
86
+ try {
87
+ execSync('python -c "import pytest_gremlins"', {
88
+ stdio: 'pipe',
89
+ timeout: PROBE_TIMEOUT_MS,
90
+ });
91
+ return true;
92
+ } catch {
93
+ return false;
94
+ }
95
+ }
96
+
97
+ async run(options: RunMutationOptions): Promise<MutationRunOutcome> {
98
+ if (!(await this.isAvailable())) {
99
+ return { report: null, timedOut: false };
100
+ }
101
+
102
+ // Spawning can throw synchronously (e.g. ENOENT on a broken interpreter
103
+ // shim); that must surface as a null report, never as an unhandled
104
+ // rejection that aborts the whole Gate M orchestration.
105
+ try {
106
+ return await this.spawnGremlins(options);
107
+ } catch (err) {
108
+ return {
109
+ report: null,
110
+ timedOut: false,
111
+ error: err instanceof Error ? err.message : String(err),
112
+ };
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Build the argv for `python -m pytest`.
118
+ *
119
+ * `-m pytest` rather than a bare `pytest`: the import probe in
120
+ * `isAvailable()` already proved *this* interpreter carries the plugin, so
121
+ * running through the same interpreter is the only way to be sure the plugin
122
+ * is actually loaded.
123
+ */
124
+ private gremlinsArgs(options: RunMutationOptions): string[] {
125
+ return [
126
+ '-m',
127
+ 'pytest',
128
+ '--gremlins',
129
+ `--gremlin-targets=${buildTargets(options.files)}`,
130
+ '--gremlin-report=console',
131
+ '--gremlin-parallel',
132
+ '--gremlin-cache',
133
+ ];
134
+ }
135
+
136
+ /** Spawn the child and settle exactly once, on close or on error. */
137
+ private spawnGremlins(options: RunMutationOptions): Promise<MutationRunOutcome> {
138
+ return new Promise((resolve) => {
139
+ const guard = createSettleGuard(resolve);
140
+ let child: ChildProcess;
141
+ try {
142
+ child = spawn('python', this.gremlinsArgs(options), {
143
+ stdio: 'pipe',
144
+ cwd: options.cwd,
145
+ });
146
+ } catch (err) {
147
+ guard.settle({
148
+ report: null,
149
+ timedOut: false,
150
+ error: err instanceof Error ? err.message : String(err),
151
+ });
152
+ return;
153
+ }
154
+
155
+ let stdout = '';
156
+ let stderr = '';
157
+ guard.armTimeout(child, options.timeoutMs);
158
+
159
+ child.stdout?.on('data', (data: Buffer) => {
160
+ stdout += data.toString();
161
+ });
162
+ child.stderr?.on('data', (data: Buffer) => {
163
+ stderr += data.toString();
164
+ });
165
+
166
+ child.on('close', (code) => {
167
+ // A missing report is NOT a failure verdict: parse returns null and the
168
+ // orchestrator keeps its non-blocking semantics (same contract as the
169
+ // mutmut runner's null report).
170
+ guard.settle({
171
+ report: parseConsoleReport(stdout),
172
+ timedOut: guard.timedOut,
173
+ error: code !== 0 ? stderr || stdout : undefined,
174
+ });
175
+ });
176
+
177
+ child.on('error', (err) => {
178
+ guard.settle({ report: null, timedOut: guard.timedOut, error: err.message });
179
+ });
180
+ });
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Comma-separated mutate targets, deduplicated, derived from the changed
186
+ * files' directories — `--gremlin-targets` accepts files OR directories, and
187
+ * the directories keep the mutant count bounded to the touched area.
188
+ *
189
+ * Module-level and pure so it is directly testable without instantiating the
190
+ * runner.
191
+ */
192
+ function buildTargets(files: string[]): string {
193
+ const dirs = new Set<string>();
194
+ for (const file of files) {
195
+ const dir = dirname(file);
196
+ dirs.add(dir && dir !== '.' ? dir : file);
197
+ }
198
+ return Array.from(dirs).join(',');
199
+ }
200
+
201
+ /**
202
+ * Parse pytest-gremlins' console report.
203
+ *
204
+ * The report prints two lines (plus a banner):
205
+ * Zapped: 142 gremlins (89%)
206
+ * Survived: 18 gremlins (11%)
207
+ *
208
+ * Returns null when neither line is present — a run that never got to the
209
+ * report (import failure, collection error, timeout) must not be reported as
210
+ * a 0% score, which would be a fabricated verdict. `Zapped` maps to killed,
211
+ * `Survived` to survived; the totals are their sum, matching the mutmut
212
+ * runner's normalization exactly.
213
+ */
214
+ export function parseConsoleReport(stdout: string): MutationRunResult | null {
215
+ const zapped = extractCount(stdout, /Zapped:\s*(\d+)\s*gremlins?/i);
216
+ const survived = extractCount(stdout, /Survived:\s*(\d+)\s*gremlins?/i);
217
+
218
+ if (zapped === null && survived === null) return null;
219
+
220
+ const nrOfKilledMutants = zapped ?? 0;
221
+ const nrOfSurvivedMutants = survived ?? 0;
222
+ const nrOfMutants = nrOfKilledMutants + nrOfSurvivedMutants;
223
+ if (nrOfMutants === 0) return null;
224
+
225
+ return {
226
+ mutationScore: (nrOfKilledMutants / nrOfMutants) * 100,
227
+ nrOfMutants,
228
+ nrOfKilledMutants,
229
+ nrOfSurvivedMutants,
230
+ };
231
+ }
232
+
233
+ function extractCount(text: string, pattern: RegExp): number | null {
234
+ const match = text.match(pattern);
235
+ if (!match?.[1]) return null;
236
+ const value = parseInt(match[1], 10);
237
+ return Number.isNaN(value) ? null : value;
238
+ }
@@ -7,15 +7,17 @@ export type {
7
7
  MutationRunner,
8
8
  } from './types';
9
9
 
10
- export { registerRunner, resolveRunner, runnerRegistry } from './types';
10
+ export { registerRunner, resolveRunner, resolveRunners, runnerRegistry } from './types';
11
11
 
12
12
  export { StrykerRunner } from './stryker-runner';
13
13
  export { MutmutRunner } from './mutmut-runner';
14
+ export { GremlinsRunner } from './gremlins-runner';
14
15
  export { GoMutantRunner } from './go-mutant-runner';
15
16
  export { PitestRunner } from './pitest-runner';
16
17
 
17
18
  import { StrykerRunner } from './stryker-runner';
18
19
  import { MutmutRunner } from './mutmut-runner';
20
+ import { GremlinsRunner } from './gremlins-runner';
19
21
  import { GoMutantRunner } from './go-mutant-runner';
20
22
  import { PitestRunner } from './pitest-runner';
21
23
  import { registerRunner } from './types';
@@ -23,6 +25,12 @@ import { registerRunner } from './types';
23
25
  /** Auto-register all known runners. */
24
26
  export function registerAllRunners(): void {
25
27
  registerRunner(new StrykerRunner());
28
+ // Registration order decides the `py` winner (resolveRunner returns the
29
+ // FIRST runner whose extensions include the ext). pytest-gremlins is
30
+ // registered before mutmut deliberately (#410): it is natively
31
+ // cross-platform, so when both are installed it is the better default —
32
+ // mutmut stays reachable via its own runner on Unix-only setups.
33
+ registerRunner(new GremlinsRunner());
26
34
  registerRunner(new MutmutRunner());
27
35
  registerRunner(new GoMutantRunner());
28
36
  registerRunner(new PitestRunner());
@@ -33,25 +33,31 @@ export class MutmutRunner implements MutationRunner {
33
33
  constructor(private readonly platform: Platform = process.platform) {}
34
34
 
35
35
  async isAvailable(): Promise<boolean> {
36
- try {
37
- execSync('mutmut --version', { stdio: 'pipe', timeout: 5000 });
38
- this.route = 'native';
39
- return true;
40
- } catch {
41
- if (this.platform !== 'win32') {
42
- this.route = 'unavailable';
43
- return false;
44
- }
45
-
36
+ if (this.platform !== 'win32') {
46
37
  try {
47
- execSync('wsl mutmut --version', { stdio: 'pipe', timeout: 5000 });
48
- this.route = 'wsl';
38
+ execSync('mutmut --version', { stdio: 'pipe', timeout: 5000 });
39
+ this.route = 'native';
49
40
  return true;
50
41
  } catch {
51
42
  this.route = 'unavailable';
52
43
  return false;
53
44
  }
54
45
  }
46
+
47
+ // Windows: mutmut 3.x is fork()-based and can ONLY run under WSL. A native
48
+ // `mutmut --version` succeeding therefore proves nothing about `mutmut run`
49
+ // — reporting route='native' here is exactly the #410 deadlock: every push
50
+ // reached `mutmut run`, which exits 1 with "please use the WSL", and the
51
+ // gate blocked on a structurally unachievable check. The route is decided
52
+ // by the WSL probe alone so an unavailable WSL yields a clean SKIP.
53
+ try {
54
+ execSync('wsl mutmut --version', { stdio: 'pipe', timeout: 10000 });
55
+ this.route = 'wsl';
56
+ return true;
57
+ } catch {
58
+ this.route = 'unavailable';
59
+ return false;
60
+ }
55
61
  }
56
62
 
57
63
  async run(options: RunMutationOptions): Promise<MutationRunOutcome> {
@@ -90,6 +90,11 @@ export function registerRunner(runner: MutationRunner): void {
90
90
  /**
91
91
  * Resolve the correct runner for a given file extension.
92
92
  * Returns undefined if no runner supports this extension.
93
+ *
94
+ * Registration order decides the winner when several runners share an
95
+ * extension. This is a synchronous fast-path (used by file filtering); the
96
+ * availability-aware fallback that honors "first AVAILABLE runner" lives in
97
+ * {@link resolveRunners}.
93
98
  */
94
99
  export function resolveRunner(ext: string): MutationRunner | undefined {
95
100
  const normalized = ext.replace(/^\./, '');
@@ -98,3 +103,18 @@ export function resolveRunner(ext: string): MutationRunner | undefined {
98
103
  }
99
104
  return undefined;
100
105
  }
106
+
107
+ /**
108
+ * Resolve ALL runners supporting an extension, in registration (priority)
109
+ * order — e.g. for `.py` that is [pytest-gremlins, mutmut] (#410).
110
+ *
111
+ * The gate walks this list and uses the first runner whose `isAvailable()`
112
+ * returns true, so a pure-mutmut environment (no gremlins installed) still
113
+ * gets mutation testing instead of a silent SKIP. This is the actual
114
+ * implementation of the design contract "gremlins 可用 → GremlinsRunner,
115
+ * 否则 MutmutRunner".
116
+ */
117
+ export function resolveRunners(ext: string): MutationRunner[] {
118
+ const normalized = ext.replace(/^\./, '');
119
+ return Array.from(runnerRegistry.values()).filter(r => r.extensions.includes(normalized));
120
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
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.21.0",
3
+ "version": "0.25.0",
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": {
@@ -66,5 +66,28 @@
66
66
  "max_review_rounds": 5,
67
67
  "distinct_models_required": true,
68
68
  "cross_provider_required": true
69
- }
69
+ },
70
+
71
+ "$comment_seat_fields": [
72
+ "Optional per-seat fields (#481). The prompt ceiling is a seat x model route",
73
+ "property, not a global constant: max_prompt_bytes (UTF-8 bytes, default 40000)",
74
+ "is the hard pre-send gate; prompt_calibration carries the measured bounds used",
75
+ "to classify a pre-response drop as SIZE_EXCEEDED instead of a network fault.",
76
+ "Recalibrate (binary search 3-5 probes in [last_pass, last_fail]) whenever the",
77
+ "model or gateway changes. See docs/plans/2026-10-14-sprint-c-design.md section 2.",
78
+ "Example expert entry:",
79
+ " \"architecture\": {",
80
+ " \"provider\": \"bailian-tp\",",
81
+ " \"model\": \"qwen-plus\",",
82
+ " \"seat_id\": \"architecture\",",
83
+ " \"max_prompt_bytes\": 26624,",
84
+ " \"prompt_calibration\": {",
85
+ " \"measured_at\": \"2026-10-05\",",
86
+ " \"model_id\": \"qwen-plus\",",
87
+ " \"gateway\": \"bailian\",",
88
+ " \"last_pass_bytes\": 26624,",
89
+ " \"last_fail_bytes\": 36897",
90
+ " }",
91
+ " }"
92
+ ]
70
93
  }
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.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.
@@ -329,6 +329,15 @@ Each round MUST output a structured round marker:
329
329
 
330
330
  #### Qoder 平台(Custom Agent 模式 — 只能做到同模型三角色)
331
331
 
332
+ **通道契约(native-first + external fallback,#414)**:每轮评审开始先探测 native 通道——三个 Custom Agent(`delphi-architecture/technical/feasibility`)是否存在且绑定互异(`xp-gate doctor delphi` 一条命令给出全部判定)。但 **native 通道已被实测证伪**(见下):subagent 派发采纳 agent 提示词、丢弃 model 绑定,三席永远是会话模型。因此 Qoder 的通道决策表实际收敛为:
333
+
334
+ | 探测结果 | 通道 | 处置 |
335
+ |---|---|---|
336
+ | 需要 distinct-models 证据的评审 | **external** | `.delphi-config.json` + `scripts/delphi-external-review.cjs`(外部 provider 三模型) |
337
+ | 仅需同模型三角色自查(不计入共识证据) | native | 三 Custom Agent 并行,报告中注明「同模型自查,不构成多模型凭据」 |
338
+
339
+ 降级证据落盘 `delphi-reviewed.json`:`channel`(native/external)、`fallback_reason`(如 `qoder_native_drops_model_binding`)、`probe_evidence`(doctor/日志摘录)。两通道同不变量:三专家齐全、`requested_model` 互异(external)、consensus ≥90%、**无单专家路径**。
340
+
332
341
  Qoder 的内置模型**没有本地推理端点**:推理请求由 Qoder 客户端经服务端代理发出,凭证是一次性 job token。所以不能照搬 OpenCode 的 `base_url + api_key` 直连方式;Qoder 侧内置模型的唯一入口是 **Custom Agent** —— 每个专家一个独立 agent 文件,frontmatter 用 `model` 字段声明模型。
333
342
 
334
343
  **契约结论(先说结论)**:这条路径**不满足**"三个不同可执行模型 ID"契约。2026-09-23 做过一次排除混杂因素的复测:先把 `~/.qoder/agents/delphi-*.md` 三份文件绑成三个不同的 0.1× 内置模型(`qfmodel` / `dfmodel` / `gfmodel`;架构角与会话模型同名,所以真正有判别力的是技术角与可行性角),**再**新开会话——新 CLI 进程,`session.config.loaded` 记录 `model: "qfmodel"`,注册表加载的必然是已修好的绑定——然后只派发三个 subagent,各回一句话、不调工具。结果:三个独立的 `is_subagent: true` turn,`turn.started` / `model.request.started` / `model.response.completed` 三处的 `model` 全为会话模型 `qfmodel`,`dfmodel` / `gfmodel` 出现 0 次;同时三份回复分别命中架构 / 技术 / 可行性视角,说明角色提示词确实生效、agent 也确实被加载。即 `subagent_type` 派发路径采纳 Custom Agent 的提示词,但**丢弃**它的 `model` 绑定。
@@ -408,6 +417,20 @@ delphi-review(
408
417
  > (1) `dsh-tool-subagent` 的 `modelSelectionSettings: true`(仅能力开关),
409
418
  > (2) 宿主设置 `SubagentModelSelectionConfig.enabled = true` 且 `allowedModels` ≥3 个不同模型。
410
419
  > 该路线依赖宿主配置,CI / 一次性会话不可靠,故不作为默认路径。
420
+
421
+ **DSH 双通道契约(native-first + external fallback,#443)**:评审开始先探测 native 通道,两层开关缺一不可——
422
+
423
+ | 探测步骤 | 方法 | 判定 |
424
+ |---|---|---|
425
+ | ① 工具 schema | 当前会话 `subagent` 工具的参数里是否暴露 `provider` / `model` 字段 | 无 → native 不可用(`enabled` 默认 `false`) |
426
+ | ② 模型清单 | `list_subagent_models` 工具是否注册;可用时返回条数是否 ≥3 且互异 | 未注册或 <3 条 → native 不可用 |
427
+ | ③ 运行时兜底 | 上述任一不满足时调用 subagent 会抛 `child model selection is disabled` | 直接判定,不试错 |
428
+
429
+ - **native 可用**:三个专家并行派发,每个显式传 `model`(取自 `allowedModels` 三个互异条目);`resolved_model` 以平台日志/回执为准,无日志时按 #437 过渡标准注明「执行层验证待平台支持」。
430
+ - **native 不可用**:降级 **external**(本 skill 的 `delphi-review` 插件工具,或 `.delphi-config.json` + `scripts/delphi-external-review.cjs`)。缺 API key 时必须给出明确指引(导出环境变量),不得静默失败。
431
+ - 降级证据落盘 `delphi-reviewed.json`:`channel`、`fallback_reason`(如 `dsh_subagent_model_selection_disabled`)、`probe_evidence`(①②③ 的实测摘录)。
432
+ - 两通道同不变量:三专家齐全、`requested_model` 互异、consensus ≥90%、**无单专家路径**。
433
+ - 可用性探测可用 `xp-gate doctor delphi` 复核(DSH 环境下含 `subagentModelSelection` 持久化设置检查)。
411
434
  #### WorkBuddy 平台(Expert 团队模式)
412
435
 
413
436
  WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `~/.workbuddy/plugins/marketplaces/my-experts/plugins/`,创建方式见 [docs/platform-workbuddy.md](../../docs/platform-workbuddy.md))承载评审,触发本技能后按此路由执行:
@@ -432,6 +455,26 @@ WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `
432
455
 
433
456
  **成本**:3 专家合计 x0.17/轮;主理人选 local 会话模型则零 credits。
434
457
 
458
+ ### 席位 prompt 上限与降序裁剪(强制 — #481)
459
+
460
+ prompt 字节上限是 **席位×模型路由 属性**,不是全局安全值(2026-10-05 实测:同一网关下
461
+ `g-glm-5.3-flash` 席 32-39KB 连续 6 次断连,他席 36KB 一次通过)。编排规则:
462
+
463
+ 1. **发送前硬闸**:runner 按 expert 条目的 `max_prompt_bytes`(默认 40000 字节,UTF-8 计)
464
+ 拒发超限请求,输出 `error_type: "prompt_budget_exceeded"`。
465
+ 2. **失败分类**:响应前断连且字节数超过该席位标定的 `last_pass_bytes` →
466
+ `error_type: "SIZE_EXCEEDED"`(不是网络故障,重试同一 payload 无意义);
467
+ 其余失败输出 `network_error` / `retryable_error`,编排层按 `error_type` 字段断言,不解析散文。
468
+ 3. **超限时按降序裁剪,每步只做一步**:
469
+ ① 去附录(探针填充、日志附录、非必需长引用)→ ② 去非本轮 AC 原文 →
470
+ ③ 去测试清单(枚举 → 计数)→ ④ 拆分两次调用(按 diff 对半,同报告合并)→
471
+ ⑤ 仍失败 → `PROCESS_BLOCK` 交人裁定。**不得以两席结果冒充 3/3 共识。**
472
+ 4. **标定**:上限按「固定语义核心 + 确定性填充附录」构造探针,在
473
+ `[last_pass, last_fail]` 区间二分 3-5 次测得;记录行含
474
+ `seat_id × model_id × gateway × max_passing_bytes × measured_at`;
475
+ 模型或网关变更即重标。协议全文与种子标定表见
476
+ [docs/plans/2026-10-14-sprint-c-design.md](../../docs/plans/2026-10-14-sprint-c-design.md) §2。
477
+
435
478
  ### 共识阈值
436
479
 
437
480
  | 阈值 | 说明 |
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.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, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/dsh-plugin-xp-gate",
3
- "version": "0.21.0",
3
+ "version": "0.25.0",
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",
@@ -66,5 +66,28 @@
66
66
  "max_review_rounds": 5,
67
67
  "distinct_models_required": true,
68
68
  "cross_provider_required": true
69
- }
69
+ },
70
+
71
+ "$comment_seat_fields": [
72
+ "Optional per-seat fields (#481). The prompt ceiling is a seat x model route",
73
+ "property, not a global constant: max_prompt_bytes (UTF-8 bytes, default 40000)",
74
+ "is the hard pre-send gate; prompt_calibration carries the measured bounds used",
75
+ "to classify a pre-response drop as SIZE_EXCEEDED instead of a network fault.",
76
+ "Recalibrate (binary search 3-5 probes in [last_pass, last_fail]) whenever the",
77
+ "model or gateway changes. See docs/plans/2026-10-14-sprint-c-design.md section 2.",
78
+ "Example expert entry:",
79
+ " \"architecture\": {",
80
+ " \"provider\": \"bailian-tp\",",
81
+ " \"model\": \"qwen-plus\",",
82
+ " \"seat_id\": \"architecture\",",
83
+ " \"max_prompt_bytes\": 26624,",
84
+ " \"prompt_calibration\": {",
85
+ " \"measured_at\": \"2026-10-05\",",
86
+ " \"model_id\": \"qwen-plus\",",
87
+ " \"gateway\": \"bailian\",",
88
+ " \"last_pass_bytes\": 26624,",
89
+ " \"last_fail_bytes\": 36897",
90
+ " }",
91
+ " }"
92
+ ]
70
93
  }
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.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.
@@ -329,6 +329,15 @@ Each round MUST output a structured round marker:
329
329
 
330
330
  #### Qoder 平台(Custom Agent 模式 — 只能做到同模型三角色)
331
331
 
332
+ **通道契约(native-first + external fallback,#414)**:每轮评审开始先探测 native 通道——三个 Custom Agent(`delphi-architecture/technical/feasibility`)是否存在且绑定互异(`xp-gate doctor delphi` 一条命令给出全部判定)。但 **native 通道已被实测证伪**(见下):subagent 派发采纳 agent 提示词、丢弃 model 绑定,三席永远是会话模型。因此 Qoder 的通道决策表实际收敛为:
333
+
334
+ | 探测结果 | 通道 | 处置 |
335
+ |---|---|---|
336
+ | 需要 distinct-models 证据的评审 | **external** | `.delphi-config.json` + `scripts/delphi-external-review.cjs`(外部 provider 三模型) |
337
+ | 仅需同模型三角色自查(不计入共识证据) | native | 三 Custom Agent 并行,报告中注明「同模型自查,不构成多模型凭据」 |
338
+
339
+ 降级证据落盘 `delphi-reviewed.json`:`channel`(native/external)、`fallback_reason`(如 `qoder_native_drops_model_binding`)、`probe_evidence`(doctor/日志摘录)。两通道同不变量:三专家齐全、`requested_model` 互异(external)、consensus ≥90%、**无单专家路径**。
340
+
332
341
  Qoder 的内置模型**没有本地推理端点**:推理请求由 Qoder 客户端经服务端代理发出,凭证是一次性 job token。所以不能照搬 OpenCode 的 `base_url + api_key` 直连方式;Qoder 侧内置模型的唯一入口是 **Custom Agent** —— 每个专家一个独立 agent 文件,frontmatter 用 `model` 字段声明模型。
333
342
 
334
343
  **契约结论(先说结论)**:这条路径**不满足**"三个不同可执行模型 ID"契约。2026-09-23 做过一次排除混杂因素的复测:先把 `~/.qoder/agents/delphi-*.md` 三份文件绑成三个不同的 0.1× 内置模型(`qfmodel` / `dfmodel` / `gfmodel`;架构角与会话模型同名,所以真正有判别力的是技术角与可行性角),**再**新开会话——新 CLI 进程,`session.config.loaded` 记录 `model: "qfmodel"`,注册表加载的必然是已修好的绑定——然后只派发三个 subagent,各回一句话、不调工具。结果:三个独立的 `is_subagent: true` turn,`turn.started` / `model.request.started` / `model.response.completed` 三处的 `model` 全为会话模型 `qfmodel`,`dfmodel` / `gfmodel` 出现 0 次;同时三份回复分别命中架构 / 技术 / 可行性视角,说明角色提示词确实生效、agent 也确实被加载。即 `subagent_type` 派发路径采纳 Custom Agent 的提示词,但**丢弃**它的 `model` 绑定。
@@ -408,6 +417,20 @@ delphi-review(
408
417
  > (1) `dsh-tool-subagent` 的 `modelSelectionSettings: true`(仅能力开关),
409
418
  > (2) 宿主设置 `SubagentModelSelectionConfig.enabled = true` 且 `allowedModels` ≥3 个不同模型。
410
419
  > 该路线依赖宿主配置,CI / 一次性会话不可靠,故不作为默认路径。
420
+
421
+ **DSH 双通道契约(native-first + external fallback,#443)**:评审开始先探测 native 通道,两层开关缺一不可——
422
+
423
+ | 探测步骤 | 方法 | 判定 |
424
+ |---|---|---|
425
+ | ① 工具 schema | 当前会话 `subagent` 工具的参数里是否暴露 `provider` / `model` 字段 | 无 → native 不可用(`enabled` 默认 `false`) |
426
+ | ② 模型清单 | `list_subagent_models` 工具是否注册;可用时返回条数是否 ≥3 且互异 | 未注册或 <3 条 → native 不可用 |
427
+ | ③ 运行时兜底 | 上述任一不满足时调用 subagent 会抛 `child model selection is disabled` | 直接判定,不试错 |
428
+
429
+ - **native 可用**:三个专家并行派发,每个显式传 `model`(取自 `allowedModels` 三个互异条目);`resolved_model` 以平台日志/回执为准,无日志时按 #437 过渡标准注明「执行层验证待平台支持」。
430
+ - **native 不可用**:降级 **external**(本 skill 的 `delphi-review` 插件工具,或 `.delphi-config.json` + `scripts/delphi-external-review.cjs`)。缺 API key 时必须给出明确指引(导出环境变量),不得静默失败。
431
+ - 降级证据落盘 `delphi-reviewed.json`:`channel`、`fallback_reason`(如 `dsh_subagent_model_selection_disabled`)、`probe_evidence`(①②③ 的实测摘录)。
432
+ - 两通道同不变量:三专家齐全、`requested_model` 互异、consensus ≥90%、**无单专家路径**。
433
+ - 可用性探测可用 `xp-gate doctor delphi` 复核(DSH 环境下含 `subagentModelSelection` 持久化设置检查)。
411
434
  #### WorkBuddy 平台(Expert 团队模式)
412
435
 
413
436
  WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `~/.workbuddy/plugins/marketplaces/my-experts/plugins/`,创建方式见 [docs/platform-workbuddy.md](../../docs/platform-workbuddy.md))承载评审,触发本技能后按此路由执行:
@@ -432,6 +455,26 @@ WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `
432
455
 
433
456
  **成本**:3 专家合计 x0.17/轮;主理人选 local 会话模型则零 credits。
434
457
 
458
+ ### 席位 prompt 上限与降序裁剪(强制 — #481)
459
+
460
+ prompt 字节上限是 **席位×模型路由 属性**,不是全局安全值(2026-10-05 实测:同一网关下
461
+ `g-glm-5.3-flash` 席 32-39KB 连续 6 次断连,他席 36KB 一次通过)。编排规则:
462
+
463
+ 1. **发送前硬闸**:runner 按 expert 条目的 `max_prompt_bytes`(默认 40000 字节,UTF-8 计)
464
+ 拒发超限请求,输出 `error_type: "prompt_budget_exceeded"`。
465
+ 2. **失败分类**:响应前断连且字节数超过该席位标定的 `last_pass_bytes` →
466
+ `error_type: "SIZE_EXCEEDED"`(不是网络故障,重试同一 payload 无意义);
467
+ 其余失败输出 `network_error` / `retryable_error`,编排层按 `error_type` 字段断言,不解析散文。
468
+ 3. **超限时按降序裁剪,每步只做一步**:
469
+ ① 去附录(探针填充、日志附录、非必需长引用)→ ② 去非本轮 AC 原文 →
470
+ ③ 去测试清单(枚举 → 计数)→ ④ 拆分两次调用(按 diff 对半,同报告合并)→
471
+ ⑤ 仍失败 → `PROCESS_BLOCK` 交人裁定。**不得以两席结果冒充 3/3 共识。**
472
+ 4. **标定**:上限按「固定语义核心 + 确定性填充附录」构造探针,在
473
+ `[last_pass, last_fail]` 区间二分 3-5 次测得;记录行含
474
+ `seat_id × model_id × gateway × max_passing_bytes × measured_at`;
475
+ 模型或网关变更即重标。协议全文与种子标定表见
476
+ [docs/plans/2026-10-14-sprint-c-design.md](../../docs/plans/2026-10-14-sprint-c-design.md) §2。
477
+
435
478
  ### 共识阈值
436
479
 
437
480
  | 阈值 | 说明 |
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.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, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-10-13
4
- **Commit:** 05a08fcf
3
+ **Generated:** 2026-10-14
4
+ **Commit:** a757d625
5
5
  **Branch:** main
6
- **Version:** 0.21.0.0
6
+ **Version:** 0.25.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.