@boyingliu01/xp-gate 0.38.9 → 0.38.11

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 (50) hide show
  1. package/adapters/shell.sh +87 -2
  2. package/hooks/gate-entries/gate-0-entry.sh +48 -3
  3. package/hooks/gate-entries/gate-12-entry.sh +20 -1
  4. package/hooks/gate-entries/gate-5-entry.sh +56 -2
  5. package/hooks/pre-commit +40 -0
  6. package/lib/__tests__/baseline-completeness.test.js +264 -0
  7. package/lib/baseline.js +265 -86
  8. package/lib/mattpocock-license-verdict.json +1 -1
  9. package/mock-policy/AGENTS.md +85 -83
  10. package/mutation/AGENTS.md +87 -61
  11. package/package.json +1 -1
  12. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  13. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  14. package/plugins/claude-code/skills/ralph-loop/SKILL.md +1 -1
  15. package/plugins/claude-code/skills/ralph-loop/references/components.md +1 -1
  16. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  17. package/plugins/claude-code/skills/sprint-flow/__tests__/sprint-flow.test.cjs +25 -7
  18. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +3 -3
  19. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  20. package/plugins/dsh/package.json +1 -1
  21. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  22. package/plugins/dsh/skills/ralph-loop/SKILL.md +1 -1
  23. package/plugins/dsh/skills/ralph-loop/references/components.md +1 -1
  24. package/plugins/dsh/skills/sprint-flow/AGENTS.md +3 -3
  25. package/plugins/dsh/skills/sprint-flow/__tests__/sprint-flow.test.cjs +25 -7
  26. package/plugins/dsh/skills/sprint-flow/references/phase-overview.md +3 -3
  27. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  28. package/plugins/opencode/package.json +1 -1
  29. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  30. package/plugins/opencode/skills/ralph-loop/SKILL.md +1 -1
  31. package/plugins/opencode/skills/ralph-loop/references/components.md +1 -1
  32. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  33. package/plugins/opencode/skills/sprint-flow/__tests__/sprint-flow.test.cjs +25 -7
  34. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +3 -3
  35. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  36. package/plugins/qoder/plugin.json +1 -1
  37. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  38. package/plugins/qoder/skills/ralph-loop/SKILL.md +1 -1
  39. package/plugins/qoder/skills/ralph-loop/references/components.md +1 -1
  40. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  41. package/plugins/qoder/skills/sprint-flow/__tests__/sprint-flow.test.cjs +25 -7
  42. package/plugins/qoder/skills/sprint-flow/references/phase-overview.md +3 -3
  43. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  44. package/principles/AGENTS.md +103 -97
  45. package/skills/delphi-review/AGENTS.md +1 -1
  46. package/skills/ralph-loop/SKILL.md +1 -1
  47. package/skills/ralph-loop/references/components.md +1 -1
  48. package/skills/sprint-flow/AGENTS.md +3 -3
  49. package/skills/sprint-flow/references/phase-overview.md +3 -3
  50. package/skills/test-specification-alignment/AGENTS.md +1 -1
@@ -27,14 +27,14 @@ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what ma
27
27
  |-----------|-----------------|-------------|
28
28
  | **Context Continuity** | Each skill starts fresh; lost design decisions between phases | Phase summaries + sprint-state.json maintain full traceability across 6 phases |
29
29
  | **Gate Enforcement** | No enforcement — easy to skip Delphi, skip TDD, skip UAT | HARD-GATE: design must be APPROVED (≥90% Delphi consensus) before coding; UAT is mandatory (no bypass) |
30
- | **Token Efficiency** | Linear context accumulation across phases — ~150K+ tokens | Ralph-loop default: 40-67% token savings via clean REQ-level contexts |
30
+ | **Context Growth** | Linear context accumulation across phases — one growing shared context | Ralph-loop default: each REQ starts from a clean context instead of inheriting everything before it |
31
31
  | **Emergent Requirements** | Discovered late, silently ignored or merged | Phase 6 CLOSE explicitly captures emergent issues via template; triggers Sprint 2 for critical issues |
32
32
  | **Quality Ecosystem** | No integration with quality gates | Integrated with xp-gate's full quality ecosystem: Gate 5 (coverage), Gate M2 (mock density), Delphi code-walkthrough |
33
33
  | **Progress Tracking** | Ad-hoc, memory-based | `.sprint-state/` persistence with phase history, timing, and metrics — `--status` renders progress dashboard |
34
34
 
35
35
  ### Key Differentiators
36
36
 
37
- 1. **40-67% Token Savings via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with clean context, avoiding the linear context accumulation that costs 150K+ tokens in parallel mode.
37
+ 1. **No Cross-REQ Context Accumulation via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with a clean context, instead of carrying every earlier REQ in one growing context as parallel mode does. The benefit is qualitative — earlier REQs stop competing for room with the current one — and no measured token figure is claimed here.
38
38
 
39
39
  2. **HARD-GATE Discipline**: Design must pass Delphi review with all three expert roles executed successfully, three distinct requested model IDs verified, and ≥90% aggregate consensus within five rounds before Phase 3 BUILD can start. This is enforced both in SKILL.md instructions and via the Claude Code plugin's PreToolUse hook.
40
40
 
@@ -190,7 +190,7 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
190
190
  2. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
191
191
  3. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
192
192
  4. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
193
- 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
193
+ 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,每个 REQ 独立干净上下文,不与之前的 REQ 累积),可选 `--mode parallel`
194
194
  6. **Skill 步骤**: BUILD-ENTRY-CONTRACT → hooks-install → TDD-GATE → TDD (RED/GREEN/REFACTOR) → blind-review (read-only subagent, tools: [Read, Grep, Glob]) → verification-before-completion → 成本监控 → learnings.md 写入
195
195
  7. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
196
196
 
@@ -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.9.0
6
+ **Version:** 0.38.11.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": "xp-gate",
3
- "version": "0.38.9",
3
+ "version": "0.38.11",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Qoder. 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.9.0
6
+ **Version:** 0.38.11.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.
@@ -7,7 +7,7 @@ maturity: stable
7
7
 
8
8
  # Ralph Loop — Default REQ-Level Iterative Build
9
9
 
10
- Core principles: **isolated context per REQ**, **TDD-first**, **full regression every iteration**, **token efficiency** (40-67% savings vs parallel).
10
+ Core principles: **isolated context per REQ**, **TDD-first**, **full regression every iteration**, **no cross-REQ context accumulation** (each REQ starts clean instead of inheriting an ever-growing shared context).
11
11
 
12
12
  ## Triggers
13
13
 
@@ -5,7 +5,7 @@
5
5
  | # | 原则 | 说明 |
6
6
  |---|------|------|
7
7
  | 1 | 逐 REQ 迭代 | 一次处理一个 REQ/切片,干净上下文,避免上下文线性膨胀 |
8
- | 2 | Token 节约 | 比旧并行模式节约 40-67% token |
8
+ | 2 | 上下文不累积 | 比旧的并行模式少一层**线性累积**:并行模式下所有 REQ 共享同一条不断变长的上下文,逐 REQ 模式每个 REQ 从干净上下文开始 |
9
9
  | 3 | 全量回归 | 每个 REQ 完成后跑全量测试 |
10
10
  | 4 | 进度持久化 | progress.log 持久化 learnings/permanent/contextual |
11
11
  | 5 | 可中断续传 | 中断后可从最后完成 REQ 继续 |
@@ -3,10 +3,10 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.9.0
6
+ **Version:** 0.38.11.0
7
7
 
8
8
  ## OVERVIEW
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.
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.
10
10
 
11
11
  > **v2.0 Compact Redesign (Issue #290)**: Merged from 11 phases to 6. PREP = old ISOLATE + AUTO-ESTIMATE. DESIGN = old THINK + PLAN. BUILD = old BUILD. VERIFY = old REVIEW + FEEDBACK. SHIP = old SHIP + LAND. CLOSE = old USER ACCEPTANCE + CLEANUP.
12
12
 
@@ -63,7 +63,7 @@ skills/sprint-flow/
63
63
  | 6/6 | CLOSE | USER ACCEPT + CLEANUP | Manual UAT → emergent issues → cleanup | HARD-GATE: UAT mandatory manual |
64
64
 
65
65
  ## CONVENTIONS
66
- - **ralph-loop is Phase 3/6 BUILD default**. Each REQ runs in a clean context, saving 40-67% tokens.
66
+ - **ralph-loop is Phase 3/6 BUILD default**. Each REQ runs in a clean context, so context does not accumulate across REQs.
67
67
  - **delphi-review HARD-GATE in Phase 2/6 DESIGN**: all three expert roles must execute with three distinct requested model IDs, then aggregate ≥90% consensus within 5 rounds. Unapproved or unverifiable → BLOCK coding.
68
68
  - **`learn` is called twice**: once per REQ in Phase 3/6 (ralph-loop internal) and once in Phase 4/6 VERIFY (Sprint-level retro).
69
69
  - **Phase isolation**: each phase has explicit entry/exit criteria documented in its `references/phase-*.md` file.
@@ -260,12 +260,30 @@ function testUniqueValuePropositionExists() {
260
260
  console.log(' ✓ Unique Value Proposition section exists');
261
261
  }
262
262
 
263
- function testUvpMentionsTokenSavings() {
263
+ function testUvpMentionsContextIsolation() {
264
264
  const section = contentSplit('Unique Value Proposition');
265
- if (!section.includes('40') || !section.includes('67') || !section.includes('token')) {
266
- throw new Error('Unique Value Proposition must mention 40-67% token savings');
267
- }
268
- console.log(' ✓ UVP mentions 40-67% token savings');
265
+ // Guards the MECHANISM, not a number. This assertion used to require the
266
+ // literal '40' and '67' -- a figure with no measurement behind it anywhere in
267
+ // the repo, copied between docs and pinned here so it could never be corrected.
268
+ // What actually distinguishes ralph-loop is that a REQ starts from a clean
269
+ // context instead of inheriting one: that is checkable and does not rot.
270
+ const mentionsIsolation =
271
+ /clean context|context (?:does not|doesn't) accumulate|no cross-REQ context accumulation|Context Growth/i.test(
272
+ section
273
+ );
274
+ if (!mentionsIsolation) {
275
+ throw new Error(
276
+ 'Unique Value Proposition must explain the per-REQ clean-context mechanism'
277
+ );
278
+ }
279
+ // And it must not resurrect an unsourced percentage as if it were measured.
280
+ const unsourcedPercentage = /\b\d{1,3}\s*[-–]\s*\d{1,3}%\s*(?:token|Token)/.test(section);
281
+ if (unsourcedPercentage) {
282
+ throw new Error(
283
+ 'UVP states a token-savings percentage range; no measurement backs it, so do not reinstate one without data'
284
+ );
285
+ }
286
+ console.log(' ✓ UVP explains per-REQ clean context without an unsourced figure');
269
287
  }
270
288
 
271
289
  function testUvpMentionsHardGate() {
@@ -353,7 +371,7 @@ function runTests(opts = {}) {
353
371
  { name: 'force-levels.md exists with three levels', fn: testForceLevelsDocumentExists },
354
372
  { name: 'force-levels.md requires Delphi review', fn: testForceLevelsRequiresDelphi },
355
373
  { name: 'Unique Value Proposition exists', fn: testUniqueValuePropositionExists },
356
- { name: 'UVP mentions 40-67% token savings', fn: testUvpMentionsTokenSavings },
374
+ { name: 'UVP explains per-REQ clean context (no unsourced figure)', fn: testUvpMentionsContextIsolation },
357
375
  { name: 'UVP mentions HARD-GATE', fn: testUvpMentionsHardGate },
358
376
  { name: 'UVP mentions emergent requirements', fn: testUvpMentionsEmergentRequirements },
359
377
  { name: 'Timing & Stability section exists', fn: testTimingSectionExists },
@@ -436,7 +454,7 @@ describe('sprint-flow SKILL.md', () => {
436
454
  { name: 'force-levels.md exists with three levels', fn: testForceLevelsDocumentExists },
437
455
  { name: 'force-levels.md requires Delphi review', fn: testForceLevelsRequiresDelphi },
438
456
  { name: 'Unique Value Proposition exists', fn: testUniqueValuePropositionExists },
439
- { name: 'UVP mentions 40-67% token savings', fn: testUvpMentionsTokenSavings },
457
+ { name: 'UVP explains per-REQ clean context (no unsourced figure)', fn: testUvpMentionsContextIsolation },
440
458
  { name: 'UVP mentions HARD-GATE', fn: testUvpMentionsHardGate },
441
459
  { name: 'UVP mentions emergent requirements', fn: testUvpMentionsEmergentRequirements },
442
460
  { name: 'Timing & Stability section exists', fn: testTimingSectionExists },
@@ -27,14 +27,14 @@ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what ma
27
27
  |-----------|-----------------|-------------|
28
28
  | **Context Continuity** | Each skill starts fresh; lost design decisions between phases | Phase summaries + sprint-state.json maintain full traceability across 6 phases |
29
29
  | **Gate Enforcement** | No enforcement — easy to skip Delphi, skip TDD, skip UAT | HARD-GATE: design must be APPROVED (≥90% Delphi consensus) before coding; UAT is mandatory (no bypass) |
30
- | **Token Efficiency** | Linear context accumulation across phases — ~150K+ tokens | Ralph-loop default: 40-67% token savings via clean REQ-level contexts |
30
+ | **Context Growth** | Linear context accumulation across phases — one growing shared context | Ralph-loop default: each REQ starts from a clean context instead of inheriting everything before it |
31
31
  | **Emergent Requirements** | Discovered late, silently ignored or merged | Phase 6 CLOSE explicitly captures emergent issues via template; triggers Sprint 2 for critical issues |
32
32
  | **Quality Ecosystem** | No integration with quality gates | Integrated with xp-gate's full quality ecosystem: Gate 5 (coverage), Gate M2 (mock density), Delphi code-walkthrough |
33
33
  | **Progress Tracking** | Ad-hoc, memory-based | `.sprint-state/` persistence with phase history, timing, and metrics — `--status` renders progress dashboard |
34
34
 
35
35
  ### Key Differentiators
36
36
 
37
- 1. **40-67% Token Savings via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with clean context, avoiding the linear context accumulation that costs 150K+ tokens in parallel mode.
37
+ 1. **No Cross-REQ Context Accumulation via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with a clean context, instead of carrying every earlier REQ in one growing context as parallel mode does. The benefit is qualitative — earlier REQs stop competing for room with the current one — and no measured token figure is claimed here.
38
38
 
39
39
  2. **HARD-GATE Discipline**: Design must pass Delphi review with all three expert roles executed successfully, three distinct requested model IDs verified, and ≥90% aggregate consensus within five rounds before Phase 3 BUILD can start. This is enforced both in SKILL.md instructions and via the Claude Code plugin's PreToolUse hook.
40
40
 
@@ -190,7 +190,7 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
190
190
  2. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
191
191
  3. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
192
192
  4. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
193
- 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
193
+ 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,每个 REQ 独立干净上下文,不与之前的 REQ 累积),可选 `--mode parallel`
194
194
  6. **Skill 步骤**: BUILD-ENTRY-CONTRACT → hooks-install → TDD-GATE → TDD (RED/GREEN/REFACTOR) → blind-review (read-only subagent, tools: [Read, Grep, Glob]) → verification-before-completion → 成本监控 → learnings.md 写入
195
195
  7. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
196
196
 
@@ -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.9.0
6
+ **Version:** 0.38.11.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,112 +1,118 @@
1
1
  # PRINCIPLES CHECKER MODULE
2
2
 
3
- **Generated:** 2026-11-04
4
- **Commit:** eb2097b0
5
- **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.9.0
3
+ **Updated:** 2026-11-17
7
4
 
8
- ## OVERVIEW
9
- Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
5
+ > **Scope.** This is the TypeScript engine behind the Clean-Code/SOLID gate and
6
+ > the Boy Scout enforcement. What follows is the design intent and the rules you
7
+ > cannot read off the code.
8
+ >
9
+ > Rule lists, adapter counts and file trees were here before and were wrong: the
10
+ > doc claimed "9 language adapters" in three places while the directory held
11
+ > more, and that wrong figure propagated outward into the CLI's own hardcoded
12
+ > help text. Ask the code:
13
+ >
14
+ > | Question | Answer |
15
+ > |---|---|
16
+ > | Every rule, its severity and limit | `xp-gate gate-rules` |
17
+ > | Rule implementations | `rules/clean-code/`, `rules/solid/` |
18
+ > | Language coverage | `adapters/` (language adapters sit beside shared helpers — see TRAPS) |
19
+ > | Effective thresholds | `.principlesrc` plus built-in defaults |
10
20
 
11
- ## STRUCTURE
12
- ```
13
- src/principles/
14
- ├── adapters/ # 9 language adapters
15
- │ ├── base.ts # Shared base class
16
- │ ├── typescript.ts
17
- │ ├── python.ts
18
- │ ├── go.ts
19
- │ ├── java.ts
20
- │ ├── kotlin.ts
21
- │ ├── dart.ts
22
- │ ├── swift.ts
23
- │ ├── cpp.ts # Regex-based C++ extraction (handles .cpp AND .c files)
24
- │ └── objectivec.ts # Regex-based ObjC extraction
25
- ├── rules/
26
- │ ├── clean-code/ # 9 Clean Code rules
27
- │ │ ├── long-function.ts (≤50 lines)
28
- │ │ ├── large-file.ts
29
- │ │ ├── god-class.ts
30
- │ │ ├── deep-nesting.ts (≤4 levels)
31
- │ │ ├── magic-numbers.ts
32
- │ │ ├── missing-error-handling.ts
33
- │ │ ├── too-many-params.ts (≤4 params)
34
- │ │ ├── unused-imports.ts
35
- │ │ └── code-duplication.ts
36
- │ └── solid/ # 5 SOLID rules: srp, ocp, lsp, isp, dip
37
- ├── analyzer.ts # Rule orchestration engine
38
- ├── boy-scout.ts # Differential warning enforcement (Gate 6)
39
- ├── baseline.ts # Warning history (.warnings-baseline.json)
40
- ├── reporter.ts # Console / JSON / SARIF 2.1.0 output
41
- ├── config.ts # .principlesrc loader
42
- ├── index.ts # CLI entry — `getAllRules()` aggregates all 14
43
- ├── types.ts # Type definitions
44
- └── __tests__/ # Unit tests across adapters, rules, core
45
- ```
21
+ ## DESIGN INTENT
22
+
23
+ ### Two tiers of language coverage, and the divergence is deliberate
24
+
25
+ This engine only covers languages it can **parse meaningfully**. The shell
26
+ adapters cover languages it can **lint or test**. The two sets do not match, and
27
+ that mismatch is correct: a language with no TS-side rule support still gets
28
+ gated, just by different means. Do not "close the gap" by inventing shallow
29
+ adapters — a rule that reports noise is worse than no rule.
30
+
31
+ ### Rules are IDs, and IDs are contracts
32
+
33
+ Rule IDs are dot-namespaced and stable (`clean-code.long-function`,
34
+ `solid.srp`). They appear in config, in baselines, in SARIF and in suppression
35
+ records. Renaming one silently invalidates every baseline entry that referenced
36
+ it — the warning count appears to drop because the rule no longer matches, not
37
+ because the code improved.
38
+
39
+ ### Severity has three meanings
40
+
41
+ - `error` — blocks.
42
+ - `warning` — blocks under Boy Scout **if the count increased**.
43
+ - `info` — logged only.
44
+
45
+ The middle one is the subtle case: a warning does not block, but *one more of
46
+ them than yesterday* does. This is why baselines are load-bearing.
47
+
48
+ ### Boy Scout is differential, not absolute
49
+
50
+ The rule is not "no warnings". It is: **you may not leave more warnings than you
51
+ found.** Modified files are compared against the baseline; new files start from
52
+ zero. That comparison is what makes the gate adoptable in an imperfect codebase —
53
+ an absolute rule would block all work immediately and be switched off within a
54
+ day.
55
+
56
+ Consequence worth knowing: the baseline must be regenerated when rule behaviour
57
+ changes legitimately, or every subsequent commit inherits phantom debt.
46
58
 
47
- ## WHERE TO LOOK
48
- | Task | Location | Notes |
49
- |------|----------|-------|
50
- | Rule engine | analyzer.ts | Orchestrates 14 rules × 9 adapters |
51
- | CLI entry | index.ts | `getAllRules()` returns the full rule set |
52
- | Output | reporter.ts | Emits Console, JSON, or SARIF 2.1.0 |
53
- | Thresholds | config.ts + .principlesrc | Defaults + project overrides |
54
- | Boy Scout enforcement | boy-scout.ts | classifyFiles → calculateDelta → enforceBoyScoutRule |
55
- | Baseline lifecycle | boy-scout.ts | loadBaseline, saveBaseline, initBaseline |
56
- | Baseline storage | baseline.ts | BaselineStorage (size/timeout/batch guards) + filterBaselineWarnings |
57
- | Adapter for new language | adapters/base.ts + add `<lang>.ts` | Subclass base; export via index |
58
- | C / C++ extraction | adapters/cpp.ts | Regex-based; handles both `.cpp` and `.c` |
59
- | Tests | __tests__/ | Adapter, rule, and core tests |
60
-
61
- ## CODE MAP
62
- | Symbol | Type | Location | Role |
63
- |--------|------|----------|------|
64
- | getAllRules | Function | index.ts | Aggregates 9 clean-code + 5 SOLID rules |
65
- | analyze | Function | analyzer.ts | Walks files × rules × adapters; collects violations |
66
- | report | Function | reporter.ts | Picks Console / JSON / SARIF emitter |
67
- | loadConfig | Function | config.ts | Reads `.principlesrc`; merges with built-in defaults |
68
- | classifyFiles | Function | boy-scout.ts | new / modified / untouched bucket assignment |
69
- | calculateDelta | Function | boy-scout.ts | Diff vs `.warnings-baseline.json` |
70
- | enforceBoyScoutRule | Function | boy-scout.ts | Block when modified-file warnings increase |
71
- | loadBaseline | Function | boy-scout.ts | Read `.warnings-baseline.json` |
72
- | saveBaseline | Function | boy-scout.ts | Write updated baseline after successful commit |
73
- | initBaseline | Function | boy-scout.ts | First-time auto-snapshot (≤5 warnings ⇒ must clear to zero) |
59
+ ### Per-path severity overrides exist, and only relax
60
+
61
+ Project config may relax a rule's severity for specific path globs. Overrides are
62
+ **relax-only by design**: a path-scoped entry can downgrade, never escalate. That
63
+ direction is what keeps the override mechanism from becoming a second, invisible
64
+ gate policy — anything that raises severity must be visible in the rule
65
+ definition, where a reviewer will see it.
66
+
67
+ This exists because the alternative was worse: without it, projects add blanket
68
+ suppressions for test trees, which also silence production code.
69
+
70
+ ### Parse where possible, regex where necessary, and say which
71
+
72
+ AST-based analysis is preferred. Regex fallbacks are limited to languages the AST
73
+ tooling does not reach (C/C++, Objective-C), where they are **known to be
74
+ approximate**. A regex adapter that reports a confident finding it cannot verify
75
+ is the failure mode to avoid — prefer under-reporting to fabricating.
76
+
77
+ ## TRAPS
78
+
79
+ - **`adapters/` holds two kinds of file.** Language adapters sit beside shared
80
+ extraction helpers (`base`, `duplication`, `member-scan`, `quote-state`,
81
+ `control-nesting`, `import-clause`, `position-analysis`). Counting files in that
82
+ directory does not give a language count — which is exactly how the "9
83
+ language adapters" figure went wrong.
84
+ - **C++ handles C.** There is no separate C adapter; one adapter covers both. Do
85
+ not add one.
86
+ - **Suppression is easy to over-apply.** A config entry that turns off a rule for
87
+ a directory also turns it off for everything added there later.
88
+ - **Baselines go stale.** A baseline captured before a rule change encodes the old
89
+ rule's opinions; comparing against it produces findings that have nothing to do
90
+ with the change under review.
91
+ - **The extension point is the rule registry in `index.ts`.** A rule file that
92
+ exists but is not registered simply never runs, silently.
74
93
 
75
94
  ## CONVENTIONS
76
- - **Rule ID format**: `clean-code.long-function`, `solid.srp`. Stable, dot-namespaced.
77
- - **Severity**: `error` (block), `warning` (block under Boy Scout if increased), `info` (log only).
78
- - **SARIF 2.1.0** output includes rule descriptions + default level mapping for GitHub Code Scanning.
79
- - **Boy Scout Rule**: auto-baseline on first touch. Modified files cannot increase warning count vs `.warnings-baseline.json`. New files: zero warnings required. Initial baseline ≤5 warnings must clear to zero on next modification.
80
- - **Test annotations mandatory**: every test file declares `@test REQ-XXX`, `@intent ...`, `@covers AC-XXX` in JSDoc. Missing tags ⇒ test rejected.
81
- - **Mock-first**: inline mocks only, no separate fixture files.
82
- - **ast-grep preferred** for AST work; regex fallback only where ast-grep doesn't reach (cpp / objc).
83
-
84
- ## ANTI-PATTERNS
85
- - Do NOT use `as any`, `@ts-ignore`, or `@ts-expect-error` in rule implementations.
86
- - Do NOT suppress violations via config for production code paths.
87
- - Do NOT skip `ast-grep` installation — regex fallback is intentionally limited.
88
- - Do NOT introduce a new rule without: (a) ID under `rules/<category>/`, (b) unit tests, (c) listing in `index.ts`, (d) SARIF rule description in `reporter.ts`.
89
-
90
- ## UNIQUE STYLES
91
- - **9 language adapters** here vs **13 shell adapters** in `githooks/adapters/` — divergence is intentional. Principles engine covers what can be parsed; shell adapters cover what can be linted/tested. Languages in shell-only set (shell, powershell, flutter, iac) don't have TS-side rule support.
92
- - **C++ adapter handles C** via regex — no standalone `c.ts`.
93
- - **SARIF 2.1.0** chosen for GitHub Code Scanning compatibility.
95
+
96
+ - **Never weaken types to satisfy a rule** — no `as any`, `@ts-ignore`,
97
+ `@ts-expect-error` in rule implementations. The analyzer is trusted by every
98
+ gate that reads its output.
99
+ - **Every test declares its traceability tags** (`@test REQ-XXX`, `@intent`,
100
+ `@covers`); untagged tests are rejected.
101
+ - **Mocks are inline**, not fixture files — a rule test should read as one
102
+ self-contained claim about one rule.
103
+ - **New rules are four-part changes**: the implementation, its tests, its
104
+ registration, and its user-facing description. Any three without the fourth
105
+ produces a rule nobody can interpret.
94
106
 
95
107
  ## COMMANDS
108
+
96
109
  ```bash
97
- # Console output
98
110
  npx tsx src/principles/index.ts --files "src/**/*.ts" --format console
99
-
100
- # SARIF for GitHub Actions
101
111
  npx tsx src/principles/index.ts --files "src/**/*.ts" --format sarif > results.sarif
102
-
103
- # Custom config
104
112
  npx tsx src/principles/index.ts --files "src/**/*.ts" --config .principlesrc
105
113
  ```
106
114
 
107
- ## NOTES
108
- - Gate 4 of pre-commit (one of 10 numbered gates; see root `AGENTS.md` GATES section).
109
- - Boy Scout enforcement runs separately as Gate 6 in `githooks/pre-commit`.
110
- - Performance: ~95ms for 28 files; ~340ms estimated for 100 files. Memory: ~102 MB (Node.js baseline).
111
- - `getAllRules()` is the stable extension point — register new rules there.
112
-
115
+ Output formats exist because two different consumers read the same findings: a
116
+ human at a terminal and a code-scanning service ingesting SARIF. Keep both
117
+ faithful to the same verdict — a rule that reports differently through the two
118
+ channels is worse than one that reports only one.
@@ -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.9.0
6
+ **Version:** 0.38.11.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.
@@ -7,7 +7,7 @@ maturity: stable
7
7
 
8
8
  # Ralph Loop — Default REQ-Level Iterative Build
9
9
 
10
- Core principles: **isolated context per REQ**, **TDD-first**, **full regression every iteration**, **token efficiency** (40-67% savings vs parallel).
10
+ Core principles: **isolated context per REQ**, **TDD-first**, **full regression every iteration**, **no cross-REQ context accumulation** (each REQ starts clean instead of inheriting an ever-growing shared context).
11
11
 
12
12
  ## Triggers
13
13
 
@@ -5,7 +5,7 @@
5
5
  | # | 原则 | 说明 |
6
6
  |---|------|------|
7
7
  | 1 | 逐 REQ 迭代 | 一次处理一个 REQ/切片,干净上下文,避免上下文线性膨胀 |
8
- | 2 | Token 节约 | 比旧并行模式节约 40-67% token |
8
+ | 2 | 上下文不累积 | 比旧的并行模式少一层**线性累积**:并行模式下所有 REQ 共享同一条不断变长的上下文,逐 REQ 模式每个 REQ 从干净上下文开始 |
9
9
  | 3 | 全量回归 | 每个 REQ 完成后跑全量测试 |
10
10
  | 4 | 进度持久化 | progress.log 持久化 learnings/permanent/contextual |
11
11
  | 5 | 可中断续传 | 中断后可从最后完成 REQ 继续 |
@@ -3,10 +3,10 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.9.0
6
+ **Version:** 0.38.11.0
7
7
 
8
8
  ## OVERVIEW
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.
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.
10
10
 
11
11
  > **v2.0 Compact Redesign (Issue #290)**: Merged from 11 phases to 6. PREP = old ISOLATE + AUTO-ESTIMATE. DESIGN = old THINK + PLAN. BUILD = old BUILD. VERIFY = old REVIEW + FEEDBACK. SHIP = old SHIP + LAND. CLOSE = old USER ACCEPTANCE + CLEANUP.
12
12
 
@@ -63,7 +63,7 @@ skills/sprint-flow/
63
63
  | 6/6 | CLOSE | USER ACCEPT + CLEANUP | Manual UAT → emergent issues → cleanup | HARD-GATE: UAT mandatory manual |
64
64
 
65
65
  ## CONVENTIONS
66
- - **ralph-loop is Phase 3/6 BUILD default**. Each REQ runs in a clean context, saving 40-67% tokens.
66
+ - **ralph-loop is Phase 3/6 BUILD default**. Each REQ runs in a clean context, so context does not accumulate across REQs.
67
67
  - **delphi-review HARD-GATE in Phase 2/6 DESIGN**: all three expert roles must execute with three distinct requested model IDs, then aggregate ≥90% consensus within 5 rounds. Unapproved or unverifiable → BLOCK coding.
68
68
  - **`learn` is called twice**: once per REQ in Phase 3/6 (ralph-loop internal) and once in Phase 4/6 VERIFY (Sprint-level retro).
69
69
  - **Phase isolation**: each phase has explicit entry/exit criteria documented in its `references/phase-*.md` file.
@@ -27,14 +27,14 @@ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what ma
27
27
  |-----------|-----------------|-------------|
28
28
  | **Context Continuity** | Each skill starts fresh; lost design decisions between phases | Phase summaries + sprint-state.json maintain full traceability across 6 phases |
29
29
  | **Gate Enforcement** | No enforcement — easy to skip Delphi, skip TDD, skip UAT | HARD-GATE: design must be APPROVED (≥90% Delphi consensus) before coding; UAT is mandatory (no bypass) |
30
- | **Token Efficiency** | Linear context accumulation across phases — ~150K+ tokens | Ralph-loop default: 40-67% token savings via clean REQ-level contexts |
30
+ | **Context Growth** | Linear context accumulation across phases — one growing shared context | Ralph-loop default: each REQ starts from a clean context instead of inheriting everything before it |
31
31
  | **Emergent Requirements** | Discovered late, silently ignored or merged | Phase 6 CLOSE explicitly captures emergent issues via template; triggers Sprint 2 for critical issues |
32
32
  | **Quality Ecosystem** | No integration with quality gates | Integrated with xp-gate's full quality ecosystem: Gate 5 (coverage), Gate M2 (mock density), Delphi code-walkthrough |
33
33
  | **Progress Tracking** | Ad-hoc, memory-based | `.sprint-state/` persistence with phase history, timing, and metrics — `--status` renders progress dashboard |
34
34
 
35
35
  ### Key Differentiators
36
36
 
37
- 1. **40-67% Token Savings via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with clean context, avoiding the linear context accumulation that costs 150K+ tokens in parallel mode.
37
+ 1. **No Cross-REQ Context Accumulation via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with a clean context, instead of carrying every earlier REQ in one growing context as parallel mode does. The benefit is qualitative — earlier REQs stop competing for room with the current one — and no measured token figure is claimed here.
38
38
 
39
39
  2. **HARD-GATE Discipline**: Design must pass Delphi review with all three expert roles executed successfully, three distinct requested model IDs verified, and ≥90% aggregate consensus within five rounds before Phase 3 BUILD can start. This is enforced both in SKILL.md instructions and via the Claude Code plugin's PreToolUse hook.
40
40
 
@@ -190,7 +190,7 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
190
190
  2. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
191
191
  3. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
192
192
  4. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
193
- 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
193
+ 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,每个 REQ 独立干净上下文,不与之前的 REQ 累积),可选 `--mode parallel`
194
194
  6. **Skill 步骤**: BUILD-ENTRY-CONTRACT → hooks-install → TDD-GATE → TDD (RED/GREEN/REFACTOR) → blind-review (read-only subagent, tools: [Read, Grep, Glob]) → verification-before-completion → 成本监控 → learnings.md 写入
195
195
  7. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
196
196
 
@@ -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.9.0
6
+ **Version:** 0.38.11.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.