@mycodemap/mycodemap 0.5.0 → 0.5.1

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 (199) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +77 -9
  3. package/dist/cli/commands/analyze.d.ts +18 -0
  4. package/dist/cli/commands/analyze.d.ts.map +1 -1
  5. package/dist/cli/commands/analyze.js +239 -6
  6. package/dist/cli/commands/analyze.js.map +1 -1
  7. package/dist/cli/commands/check.d.ts +22 -0
  8. package/dist/cli/commands/check.d.ts.map +1 -0
  9. package/dist/cli/commands/check.js +168 -0
  10. package/dist/cli/commands/check.js.map +1 -0
  11. package/dist/cli/commands/ci.d.ts +25 -0
  12. package/dist/cli/commands/ci.d.ts.map +1 -1
  13. package/dist/cli/commands/ci.js +139 -36
  14. package/dist/cli/commands/ci.js.map +1 -1
  15. package/dist/cli/commands/complexity.d.ts.map +1 -1
  16. package/dist/cli/commands/complexity.js +6 -0
  17. package/dist/cli/commands/complexity.js.map +1 -1
  18. package/dist/cli/commands/design.d.ts +5 -0
  19. package/dist/cli/commands/design.d.ts.map +1 -1
  20. package/dist/cli/commands/design.js +6 -0
  21. package/dist/cli/commands/design.js.map +1 -1
  22. package/dist/cli/commands/generate.d.ts +1 -0
  23. package/dist/cli/commands/generate.d.ts.map +1 -1
  24. package/dist/cli/commands/generate.js +121 -8
  25. package/dist/cli/commands/generate.js.map +1 -1
  26. package/dist/cli/commands/history.d.ts +26 -0
  27. package/dist/cli/commands/history.d.ts.map +1 -0
  28. package/dist/cli/commands/history.js +92 -0
  29. package/dist/cli/commands/history.js.map +1 -0
  30. package/dist/cli/commands/mcp.d.ts +13 -0
  31. package/dist/cli/commands/mcp.d.ts.map +1 -0
  32. package/dist/cli/commands/mcp.js +108 -0
  33. package/dist/cli/commands/mcp.js.map +1 -0
  34. package/dist/cli/commands/workflow.d.ts.map +1 -1
  35. package/dist/cli/commands/workflow.js +22 -2
  36. package/dist/cli/commands/workflow.js.map +1 -1
  37. package/dist/cli/config-loader.d.ts.map +1 -1
  38. package/dist/cli/config-loader.js +3 -2
  39. package/dist/cli/config-loader.js.map +1 -1
  40. package/dist/cli/contract-checker.d.ts +33 -0
  41. package/dist/cli/contract-checker.d.ts.map +1 -0
  42. package/dist/cli/contract-checker.js +719 -0
  43. package/dist/cli/contract-checker.js.map +1 -0
  44. package/dist/cli/contract-diff-scope.d.ts +14 -0
  45. package/dist/cli/contract-diff-scope.d.ts.map +1 -0
  46. package/dist/cli/contract-diff-scope.js +127 -0
  47. package/dist/cli/contract-diff-scope.js.map +1 -0
  48. package/dist/cli/contract-gate-thresholds.d.ts +14 -0
  49. package/dist/cli/contract-gate-thresholds.d.ts.map +1 -0
  50. package/dist/cli/contract-gate-thresholds.js +19 -0
  51. package/dist/cli/contract-gate-thresholds.js.map +1 -0
  52. package/dist/cli/design-contract-loader.d.ts.map +1 -1
  53. package/dist/cli/design-contract-loader.js +355 -3
  54. package/dist/cli/design-contract-loader.js.map +1 -1
  55. package/dist/cli/design-scope-resolver.d.ts.map +1 -1
  56. package/dist/cli/design-scope-resolver.js +89 -41
  57. package/dist/cli/design-scope-resolver.js.map +1 -1
  58. package/dist/cli/index.js +18 -6
  59. package/dist/cli/index.js.map +1 -1
  60. package/dist/cli/paths.d.ts.map +1 -1
  61. package/dist/cli/paths.js +30 -7
  62. package/dist/cli/paths.js.map +1 -1
  63. package/dist/core/analyzer.d.ts.map +1 -1
  64. package/dist/core/analyzer.js +16 -0
  65. package/dist/core/analyzer.js.map +1 -1
  66. package/dist/domain/entities/CodeGraph.d.ts +5 -1
  67. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  68. package/dist/domain/entities/CodeGraph.js +29 -12
  69. package/dist/domain/entities/CodeGraph.js.map +1 -1
  70. package/dist/domain/entities/Dependency.d.ts +8 -1
  71. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  72. package/dist/domain/entities/Dependency.js +19 -4
  73. package/dist/domain/entities/Dependency.js.map +1 -1
  74. package/dist/domain/entities/Symbol.d.ts +2 -1
  75. package/dist/domain/entities/Symbol.d.ts.map +1 -1
  76. package/dist/domain/entities/Symbol.js +6 -3
  77. package/dist/domain/entities/Symbol.js.map +1 -1
  78. package/dist/infrastructure/storage/StorageFactory.d.ts +1 -0
  79. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  80. package/dist/infrastructure/storage/StorageFactory.js +7 -2
  81. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  82. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +3 -1
  83. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
  84. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +10 -2
  85. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
  86. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +3 -1
  87. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
  88. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +9 -1
  89. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
  90. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +3 -1
  91. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
  92. package/dist/infrastructure/storage/adapters/MemoryStorage.js +9 -1
  93. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
  94. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +53 -0
  95. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -0
  96. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +879 -0
  97. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -0
  98. package/dist/infrastructure/storage/graph-helpers.d.ts +3 -1
  99. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  100. package/dist/infrastructure/storage/graph-helpers.js +90 -0
  101. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  102. package/dist/infrastructure/storage/index.d.ts +1 -1
  103. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  104. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +3 -1
  105. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  106. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  107. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +27 -0
  108. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -0
  109. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +246 -0
  110. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -0
  111. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts +25 -0
  112. package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts.map +1 -0
  113. package/dist/infrastructure/storage/sqlite/perf-thresholds.js +25 -0
  114. package/dist/infrastructure/storage/sqlite/perf-thresholds.js.map +1 -0
  115. package/dist/infrastructure/storage/sqlite/schema.d.ts +4 -0
  116. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
  117. package/dist/infrastructure/storage/sqlite/schema.js +111 -0
  118. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
  119. package/dist/interface/types/design-check.d.ts +73 -0
  120. package/dist/interface/types/design-check.d.ts.map +1 -0
  121. package/dist/interface/types/design-check.js +4 -0
  122. package/dist/interface/types/design-check.js.map +1 -0
  123. package/dist/interface/types/design-contract.d.ts +56 -1
  124. package/dist/interface/types/design-contract.d.ts.map +1 -1
  125. package/dist/interface/types/history-risk.d.ts +90 -0
  126. package/dist/interface/types/history-risk.d.ts.map +1 -0
  127. package/dist/interface/types/history-risk.js +4 -0
  128. package/dist/interface/types/history-risk.js.map +1 -0
  129. package/dist/interface/types/index.d.ts +17 -2
  130. package/dist/interface/types/index.d.ts.map +1 -1
  131. package/dist/interface/types/storage.d.ts +28 -1
  132. package/dist/interface/types/storage.d.ts.map +1 -1
  133. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +10 -0
  134. package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -1
  135. package/dist/orchestrator/adapters/ast-grep-adapter.js +46 -17
  136. package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -1
  137. package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -1
  138. package/dist/orchestrator/adapters/codemap-adapter.js +2 -22
  139. package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -1
  140. package/dist/orchestrator/history-risk-service.d.ts +55 -0
  141. package/dist/orchestrator/history-risk-service.d.ts.map +1 -0
  142. package/dist/orchestrator/history-risk-service.js +680 -0
  143. package/dist/orchestrator/history-risk-service.js.map +1 -0
  144. package/dist/orchestrator/types.d.ts +19 -1
  145. package/dist/orchestrator/types.d.ts.map +1 -1
  146. package/dist/orchestrator/types.js +19 -0
  147. package/dist/orchestrator/types.js.map +1 -1
  148. package/dist/server/mcp/index.d.ts +4 -0
  149. package/dist/server/mcp/index.d.ts.map +1 -0
  150. package/dist/server/mcp/index.js +5 -0
  151. package/dist/server/mcp/index.js.map +1 -0
  152. package/dist/server/mcp/server.d.ts +17 -0
  153. package/dist/server/mcp/server.d.ts.map +1 -0
  154. package/dist/server/mcp/server.js +84 -0
  155. package/dist/server/mcp/server.js.map +1 -0
  156. package/dist/server/mcp/service.d.ts +22 -0
  157. package/dist/server/mcp/service.d.ts.map +1 -0
  158. package/dist/server/mcp/service.js +177 -0
  159. package/dist/server/mcp/service.js.map +1 -0
  160. package/dist/server/mcp/types.d.ts +56 -0
  161. package/dist/server/mcp/types.d.ts.map +1 -0
  162. package/dist/server/mcp/types.js +4 -0
  163. package/dist/server/mcp/types.js.map +1 -0
  164. package/docs/AI_ASSISTANT_SETUP.md +1 -1
  165. package/docs/SETUP_GUIDE.md +6 -6
  166. package/docs/ai-guide/COMMANDS.md +98 -4
  167. package/docs/ai-guide/INTEGRATION.md +137 -433
  168. package/docs/ai-guide/OUTPUT.md +476 -6
  169. package/docs/ai-guide/PATTERNS.md +41 -11
  170. package/docs/ai-guide/PROMPTS.md +11 -6
  171. package/docs/backlog.md +177 -0
  172. package/docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md +231 -0
  173. package/docs/exec-plans/completed/2026-04-17-eatdogfood-codemap-cli.md +103 -0
  174. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +102 -0
  175. package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +47 -0
  176. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +11 -10
  177. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +10 -10
  178. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +17 -12
  179. package/docs/rules/README.md +16 -11
  180. package/docs/rules/architecture-guardrails.md +24 -336
  181. package/docs/rules/code-quality-redlines.md +25 -311
  182. package/docs/rules/engineering-with-codex-openai.md +14 -1
  183. package/docs/rules/validation.md +90 -40
  184. package/mycodemap.config.schema.json +3 -3
  185. package/package.json +7 -2
  186. package/scripts/benchmark-governance-graph.mjs +132 -0
  187. package/scripts/calibrate-contract-gate.mjs +221 -0
  188. package/scripts/capability-report.py +255 -0
  189. package/scripts/qa-rule-control.sh +254 -0
  190. package/scripts/report-high-risk-files.mjs +395 -0
  191. package/scripts/rule-context.mjs +155 -0
  192. package/scripts/smoke-sqlite-impact.mjs +85 -0
  193. package/scripts/sync-analyze-docs.js +1 -0
  194. package/scripts/tests/test_capability_report.py +89 -0
  195. package/scripts/tests/test_rule_control_workflow.py +51 -0
  196. package/scripts/tests/test_validate_rules.py +81 -0
  197. package/scripts/validate-ai-docs.js +283 -1
  198. package/scripts/validate-docs.js +249 -42
  199. package/scripts/validate-rules.py +254 -0
@@ -63,6 +63,32 @@ function readText(filePath) {
63
63
  return readFileSync(absolutePath, 'utf8');
64
64
  }
65
65
 
66
+ function collectSnippetFailures(
67
+ content,
68
+ requiredSnippets,
69
+ outdatedSnippets,
70
+ ) {
71
+ const snippetFailures = [];
72
+
73
+ if (!content) {
74
+ return snippetFailures;
75
+ }
76
+
77
+ for (const snippet of requiredSnippets) {
78
+ if (!content.includes(snippet)) {
79
+ snippetFailures.push(`missing required snippet: ${snippet}`);
80
+ }
81
+ }
82
+
83
+ for (const snippet of outdatedSnippets) {
84
+ if (content.includes(snippet)) {
85
+ snippetFailures.push(`contains outdated snippet: ${snippet}`);
86
+ }
87
+ }
88
+
89
+ return snippetFailures;
90
+ }
91
+
66
92
  function checkRequiredDocs(failures) {
67
93
  console.log('Checking required AI documents...\n');
68
94
 
@@ -194,7 +220,7 @@ function checkCrossReferences(failures) {
194
220
  // CLAUDE.md 必须链接到 AI 文档
195
221
  const claude = readText('CLAUDE.md');
196
222
  if (claude) {
197
- if (!claude.includes('AI_GUIDE.md') || !claude.includes('docs/ai-guide/')) {
223
+ if (!claude.includes('AI_GUIDE.md')) {
198
224
  failures.push('CLAUDE.md must reference AI docs');
199
225
  console.log(' ❌ CLAUDE.md missing AI docs references');
200
226
  } else {
@@ -314,6 +340,258 @@ function checkAnalyzeContractConsistency(failures) {
314
340
  }
315
341
  }
316
342
 
343
+ function checkPhase25DogfoodContractConsistency(failures) {
344
+ console.log('\nChecking Phase 25 dogfood contract consistency...\n');
345
+
346
+ const phase25Checks = [
347
+ {
348
+ file: 'AI_GUIDE.md',
349
+ requiredSnippets: [
350
+ 'query -S "XXX" -j',
351
+ 'partialFailure',
352
+ '`rtk` 不是 CodeMap 产品功能',
353
+ ],
354
+ outdatedSnippets: [],
355
+ },
356
+ {
357
+ file: 'docs/ai-guide/COMMANDS.md',
358
+ requiredSnippets: [
359
+ 'mycodemap analyze -i find -k "SourceLocation" --json --structured',
360
+ 'mycodemap complexity -f "src/cli/index.ts" -j',
361
+ 'mycodemap ci assess-risk --files "changed.ts" --json',
362
+ 'mycodemap workflow start "inspect analyze find" --json',
363
+ 'JSON 默认包含 `passed` 与 `summary`',
364
+ '`workflow` 只保留 `find → read → link → show` 四个分析阶段',
365
+ ],
366
+ outdatedSnippets: [
367
+ '`workflow` 同时包含 analyze、实现、CI、ship 等多个阶段',
368
+ ],
369
+ },
370
+ {
371
+ file: 'docs/ai-guide/OUTPUT.md',
372
+ requiredSnippets: [
373
+ 'interface AnalyzeDiagnostics',
374
+ '"partialFailure"',
375
+ 'diagnostics.status = "success"',
376
+ 'diagnostics.status = "failure"',
377
+ ],
378
+ outdatedSnippets: [],
379
+ },
380
+ ];
381
+
382
+ for (const { file, requiredSnippets, outdatedSnippets } of phase25Checks) {
383
+ const content = readText(file);
384
+ if (!content) {
385
+ continue;
386
+ }
387
+
388
+ const docFailures = collectSnippetFailures(content, requiredSnippets, outdatedSnippets);
389
+ if (docFailures.length > 0) {
390
+ failures.push(`${file}: ${docFailures.join(', ')}`);
391
+ console.log(` ❌ ${file}`);
392
+ for (const docFailure of docFailures) {
393
+ console.log(` - ${docFailure}`);
394
+ }
395
+ continue;
396
+ }
397
+
398
+ console.log(` ✅ ${file}`);
399
+ }
400
+ }
401
+
402
+ function checkStorageContractConsistency(failures) {
403
+ console.log('\nChecking storage contract consistency...\n');
404
+
405
+ const storageDocChecks = [
406
+ {
407
+ file: 'AI_GUIDE.md',
408
+ requiredSnippets: [
409
+ '`storage.type = "auto"` 当前优先选择 `sqlite`;若运行时缺少 `better-sqlite3` 或 Node.js `<20` 导致 SQLite 不可用,则 warning 后回退到 `filesystem`。'
410
+ ],
411
+ outdatedSnippets: [],
412
+ },
413
+ {
414
+ file: 'docs/ai-guide/COMMANDS.md',
415
+ requiredSnippets: [
416
+ '- `storage.type` 支持 `filesystem`、`sqlite`、`memory`、`auto`;默认是 `filesystem`。',
417
+ '- 旧的 `neo4j` / `kuzudb` 配置会直接报迁移错误;显式选择 `sqlite` 但运行时缺少 `better-sqlite3` 或 Node.js `<20` 时也会直接报错,不会静默 fallback 到 `filesystem`。',
418
+ ],
419
+ outdatedSnippets: [],
420
+ },
421
+ {
422
+ file: 'docs/ai-guide/PATTERNS.md',
423
+ requiredSnippets: [
424
+ '- 旧的 `neo4j` / `kuzudb` 配置现在应该直接报迁移错误;显式 `sqlite` 但运行时不满足条件时也应看到显式错误,而不是静默 fallback。',
425
+ '- `storage.type = "auto"` 当前优先落到 `sqlite`;只有 SQLite 不可用时才回退 `filesystem`,不要把阈值字段误读成更复杂的调度器。',
426
+ ],
427
+ outdatedSnippets: [],
428
+ },
429
+ {
430
+ file: 'docs/ai-guide/INTEGRATION.md',
431
+ requiredSnippets: [
432
+ '`UNSUPPORTED_STORAGE_TYPE` / `STORAGE_BACKEND_MIGRATED` / `SQLITE_NOT_AVAILABLE`',
433
+ '`better-sqlite3`',
434
+ 'Node.js `>=20`',
435
+ 'SQLite 不可用时会 warning 后回退 `filesystem`',
436
+ ],
437
+ outdatedSnippets: [
438
+ 'KUZU_INIT_FAILED',
439
+ '安装 `kuzu`',
440
+ ],
441
+ },
442
+ ];
443
+
444
+ for (const { file, requiredSnippets, outdatedSnippets } of storageDocChecks) {
445
+ const content = readText(file);
446
+ if (!content) {
447
+ continue;
448
+ }
449
+
450
+ const docFailures = collectSnippetFailures(content, requiredSnippets, outdatedSnippets);
451
+ if (docFailures.length > 0) {
452
+ failures.push(`${file}: ${docFailures.join(', ')}`);
453
+ console.log(` ❌ ${file}`);
454
+ for (const docFailure of docFailures) {
455
+ console.log(` - ${docFailure}`);
456
+ }
457
+ continue;
458
+ }
459
+
460
+ console.log(` ✅ ${file}`);
461
+ }
462
+ }
463
+
464
+ function checkHistoryRiskContractConsistency(failures) {
465
+ console.log('\nChecking history risk contract consistency...\n');
466
+
467
+ const historyRiskChecks = [
468
+ {
469
+ file: 'AI_GUIDE.md',
470
+ requiredSnippets: [
471
+ '`history --symbol <name>`',
472
+ '`check` / `ci assess-risk` / `history` 现在共用同一套 Git history risk truth;history unavailable 时会显式给出 `unavailable` / `confidence=low`',
473
+ 'interface HistoryCommandResult {',
474
+ ],
475
+ outdatedSnippets: [],
476
+ },
477
+ {
478
+ file: 'docs/ai-guide/COMMANDS.md',
479
+ requiredSnippets: [
480
+ '## history - 符号级 Git history / risk 查询',
481
+ '`ci assess-risk` 现在输出 `status / confidence / freshness / source / score / level`',
482
+ 'history 不可用,会显式给出 `unavailable` / warning',
483
+ ],
484
+ outdatedSnippets: [],
485
+ },
486
+ {
487
+ file: 'docs/ai-guide/OUTPUT.md',
488
+ requiredSnippets: [
489
+ 'interface HistoryCommandResult {',
490
+ '"git-history-unsupported-intent"',
491
+ 'Git history risk 是 additive enrichment:它补充 `history` 与 `violations[].risk`',
492
+ ],
493
+ outdatedSnippets: [],
494
+ },
495
+ {
496
+ file: 'docs/ai-guide/PATTERNS.md',
497
+ requiredSnippets: [
498
+ 'node dist/cli/index.js history --symbol createCheckCommand',
499
+ '`ci assess-risk`、`check`、`history` 共用同一套 Git history risk truth',
500
+ ],
501
+ outdatedSnippets: [],
502
+ },
503
+ ];
504
+
505
+ for (const { file, requiredSnippets, outdatedSnippets } of historyRiskChecks) {
506
+ const content = readText(file);
507
+ if (!content) {
508
+ continue;
509
+ }
510
+
511
+ const docFailures = collectSnippetFailures(content, requiredSnippets, outdatedSnippets);
512
+ if (docFailures.length > 0) {
513
+ failures.push(`${file}: ${docFailures.join(', ')}`);
514
+ console.log(` ❌ ${file}`);
515
+ for (const docFailure of docFailures) {
516
+ console.log(` - ${docFailure}`);
517
+ }
518
+ continue;
519
+ }
520
+
521
+ console.log(` ✅ ${file}`);
522
+ }
523
+ }
524
+
525
+ function checkContractGateAnnotationConsistency(failures) {
526
+ console.log('\nChecking contract gate annotation consistency...\n');
527
+
528
+ const contractGateChecks = [
529
+ {
530
+ file: 'AI_GUIDE.md',
531
+ requiredSnippets: [
532
+ '--annotation-format github',
533
+ 'node scripts/calibrate-contract-gate.mjs --max-changed-files 10 --max-false-positive-rate 0.10',
534
+ 'changed files <= 10',
535
+ 'warn-only / fallback',
536
+ ],
537
+ outdatedSnippets: [],
538
+ },
539
+ {
540
+ file: 'docs/ai-guide/COMMANDS.md',
541
+ requiredSnippets: [
542
+ '--annotation-format github',
543
+ '--annotation-format gitlab --annotation-file gl-code-quality-report.json',
544
+ 'changed files <= 10',
545
+ 'false-positive rate >10%',
546
+ 'warn-only / fallback',
547
+ ],
548
+ outdatedSnippets: [],
549
+ },
550
+ {
551
+ file: 'docs/ai-guide/OUTPUT.md',
552
+ requiredSnippets: [
553
+ 'details?: Record<string, string | number | boolean | null>;',
554
+ 'diagnostic?: {',
555
+ 'scope: "line" | "file" | "general";',
556
+ 'Annotation-friendly diagnostics',
557
+ 'gl-code-quality-report.json',
558
+ 'warn-only / fallback',
559
+ ],
560
+ outdatedSnippets: [],
561
+ },
562
+ {
563
+ file: 'docs/ai-guide/PATTERNS.md',
564
+ requiredSnippets: [
565
+ 'node scripts/calibrate-contract-gate.mjs --max-changed-files 10 --max-false-positive-rate 0.10',
566
+ '--annotation-format github',
567
+ '--annotation-format gitlab --annotation-file gl-code-quality-report.json',
568
+ 'changed files <= 10',
569
+ 'warn-only / fallback',
570
+ ],
571
+ outdatedSnippets: [],
572
+ },
573
+ ];
574
+
575
+ for (const { file, requiredSnippets, outdatedSnippets } of contractGateChecks) {
576
+ const content = readText(file);
577
+ if (!content) {
578
+ continue;
579
+ }
580
+
581
+ const docFailures = collectSnippetFailures(content, requiredSnippets, outdatedSnippets);
582
+ if (docFailures.length > 0) {
583
+ failures.push(`${file}: ${docFailures.join(', ')}`);
584
+ console.log(` ❌ ${file}`);
585
+ for (const docFailure of docFailures) {
586
+ console.log(` - ${docFailure}`);
587
+ }
588
+ continue;
589
+ }
590
+
591
+ console.log(` ✅ ${file}`);
592
+ }
593
+ }
594
+
317
595
  function validateAIDocs() {
318
596
  console.log('========================================');
319
597
  console.log('AI Documentation Guardrails Check');
@@ -327,6 +605,10 @@ function validateAIDocs() {
327
605
  checkPromptsLibrary(failures);
328
606
  checkDecisionTrees(failures);
329
607
  checkAnalyzeContractConsistency(failures);
608
+ checkPhase25DogfoodContractConsistency(failures);
609
+ checkStorageContractConsistency(failures);
610
+ checkHistoryRiskContractConsistency(failures);
611
+ checkContractGateAnnotationConsistency(failures);
330
612
 
331
613
  console.log('\n========================================');
332
614