@boyingliu01/xp-gate 0.38.125 → 0.39.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 (428) hide show
  1. package/README.md +93 -0
  2. package/adapters/gate-3.sh +45 -1
  3. package/adapters/gate-7.sh +15 -6
  4. package/adapters/python.sh +36 -38
  5. package/bin/xp-gate.js +35 -0
  6. package/build-integrity/gate-10-lines.ts +98 -0
  7. package/build-integrity/gate-10.ts +131 -117
  8. package/build-integrity/quote-masker.ts +17 -3
  9. package/gate-3.sh +45 -1
  10. package/gate-registry.sh +3 -1
  11. package/gates/common-process.ts +116 -34
  12. package/gates/common.ts +51 -15
  13. package/gates/gate-3.ts +166 -61
  14. package/gates/gate-8.ts +76 -24
  15. package/gates/gate-9.ts +276 -82
  16. package/gates/pbt-detect.ts +70 -39
  17. package/gates/python-health.ts +236 -98
  18. package/gates/test-layers.ts +103 -30
  19. package/hooks/deploy-manifest.sh +1 -0
  20. package/hooks/gate-3.sh +45 -1
  21. package/hooks/gate-entries/gate-1-entry.sh +44 -24
  22. package/hooks/gate-entries/gate-5-entry.sh +60 -20
  23. package/hooks/gate-entries/gate-6-entry.sh +15 -6
  24. package/hooks/gate-registry.sh +3 -1
  25. package/hooks/lib/gate-status.sh +164 -0
  26. package/hooks/lib/jscpd-run.sh +9 -1
  27. package/hooks/lib/native-path.sh +54 -0
  28. package/hooks/lib/toolchain-path.sh +38 -0
  29. package/hooks/lib/validate-code-walkthrough.cjs +324 -99
  30. package/hooks/pre-commit +52 -0
  31. package/hooks/pre-push +67 -7
  32. package/lib/agent-runtime-journal.js +104 -37
  33. package/lib/arch.js +6 -0
  34. package/lib/baseline.js +329 -201
  35. package/lib/check.js +38 -2
  36. package/lib/deploy-manifest.js +1 -0
  37. package/lib/doctor-constants.js +43 -0
  38. package/lib/doctor-tool-checks.js +129 -0
  39. package/lib/doctor.js +2014 -1038
  40. package/lib/flaky.js +178 -79
  41. package/lib/gate-audit.ts +80 -0
  42. package/lib/gate-runner.js +115 -63
  43. package/lib/init.js +6 -0
  44. package/lib/language-capability-surfaces.js +75 -8
  45. package/lib/language-capability.js +3 -0
  46. package/lib/language-registry.js +608 -0
  47. package/lib/language-tools.js +679 -894
  48. package/lib/phase-transition.js +646 -446
  49. package/lib/prepush-evidence.js +174 -0
  50. package/lib/sprint-audit.js +52 -22
  51. package/lib/sprint-discovery.js +66 -35
  52. package/lib/sprint-format.js +114 -0
  53. package/lib/sprint-init.js +372 -118
  54. package/lib/sprint-status.js +134 -90
  55. package/lib/star-notice.js +346 -0
  56. package/lib/tool-audit.js +729 -0
  57. package/lib/tool-display.js +52 -0
  58. package/lib/tool-install.js +179 -0
  59. package/lib/uninstall.js +331 -188
  60. package/mock-policy/gate-m3.ts +74 -23
  61. package/mock-policy/mock-decision-engine.ts +21 -7
  62. package/mock-policy/scope-scanner.ts +128 -69
  63. package/mutation/detect-ai-test.ts +20 -12
  64. package/mutation/gate-m.ts +6 -2
  65. package/mutation/init-baseline.ts +49 -13
  66. package/mutation/runners/go-mutant-runner.ts +7 -49
  67. package/mutation/runners/gremlins-runner.ts +53 -18
  68. package/mutation/runners/mutmut-runner.ts +455 -163
  69. package/mutation/runners/pitest-runner.ts +85 -131
  70. package/mutation/runners/spawn-with-capture.ts +304 -0
  71. package/mutation/runners/stryker-runner.ts +14 -55
  72. package/mutation/update-baseline.ts +25 -18
  73. package/package.json +20 -8
  74. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  75. package/plugins/claude-code/bin/delphi-review-guard.sh +12 -61
  76. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +6 -11
  77. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  78. package/plugins/claude-code/skills/reinstall-xp-gate/.architecture-skip +8 -0
  79. package/plugins/claude-code/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
  80. package/plugins/claude-code/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
  81. package/plugins/claude-code/skills/reinstall-xp-gate/LICENSE +21 -0
  82. package/plugins/claude-code/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
  83. package/plugins/claude-code/skills/reinstall-xp-gate/README.md +167 -0
  84. package/plugins/claude-code/skills/reinstall-xp-gate/SKILL.md +271 -0
  85. package/plugins/claude-code/skills/reinstall-xp-gate/TODO.md +253 -0
  86. package/plugins/claude-code/skills/reinstall-xp-gate/VERSION +1 -0
  87. package/plugins/claude-code/skills/reinstall-xp-gate/package.json +28 -0
  88. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
  89. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
  90. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
  91. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
  92. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
  93. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
  94. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
  95. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
  96. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
  97. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
  98. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
  99. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
  100. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
  101. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
  102. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
  103. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
  104. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
  105. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
  106. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
  107. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
  108. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
  109. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
  110. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
  111. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
  112. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
  113. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
  114. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
  115. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
  116. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
  117. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
  118. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
  119. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
  120. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
  121. package/plugins/claude-code/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
  122. package/plugins/claude-code/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
  123. package/plugins/claude-code/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
  124. package/plugins/claude-code/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
  125. package/plugins/claude-code/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
  126. package/plugins/claude-code/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
  127. package/plugins/claude-code/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
  128. package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
  129. package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
  130. package/plugins/claude-code/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
  131. package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
  132. package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
  133. package/plugins/claude-code/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
  134. package/plugins/claude-code/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
  135. package/plugins/claude-code/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
  136. package/plugins/claude-code/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
  137. package/plugins/claude-code/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
  138. package/plugins/claude-code/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
  139. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
  140. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
  141. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
  142. package/plugins/claude-code/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
  143. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  144. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  145. package/plugins/dsh/package.json +1 -1
  146. package/plugins/dsh/scripts/prepack.cjs +43 -18
  147. package/plugins/dsh/scripts/verify-skill-provider.mjs +39 -14
  148. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +6 -11
  149. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  150. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  151. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  152. package/plugins/dsh/src/skills.test.ts +9 -0
  153. package/plugins/opencode/index.ts +337 -123
  154. package/plugins/opencode/package.json +1 -1
  155. package/plugins/opencode/scripts/prepack.cjs +41 -16
  156. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +6 -11
  157. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  158. package/plugins/opencode/skills/reinstall-xp-gate/.architecture-skip +8 -0
  159. package/plugins/opencode/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
  160. package/plugins/opencode/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
  161. package/plugins/opencode/skills/reinstall-xp-gate/LICENSE +21 -0
  162. package/plugins/opencode/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
  163. package/plugins/opencode/skills/reinstall-xp-gate/README.md +167 -0
  164. package/plugins/opencode/skills/reinstall-xp-gate/SKILL.md +271 -0
  165. package/plugins/opencode/skills/reinstall-xp-gate/TODO.md +253 -0
  166. package/plugins/opencode/skills/reinstall-xp-gate/VERSION +1 -0
  167. package/plugins/opencode/skills/reinstall-xp-gate/package.json +28 -0
  168. package/plugins/opencode/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
  169. package/plugins/opencode/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
  170. package/plugins/opencode/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
  171. package/plugins/opencode/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
  172. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
  173. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
  174. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
  175. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
  176. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
  177. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
  178. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
  179. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
  180. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
  181. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
  182. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
  183. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
  184. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
  185. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
  186. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
  187. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
  188. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
  189. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
  190. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
  191. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
  192. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
  193. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
  194. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
  195. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
  196. package/plugins/opencode/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
  197. package/plugins/opencode/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
  198. package/plugins/opencode/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
  199. package/plugins/opencode/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
  200. package/plugins/opencode/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
  201. package/plugins/opencode/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
  202. package/plugins/opencode/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
  203. package/plugins/opencode/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
  204. package/plugins/opencode/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
  205. package/plugins/opencode/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
  206. package/plugins/opencode/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
  207. package/plugins/opencode/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
  208. package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
  209. package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
  210. package/plugins/opencode/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
  211. package/plugins/opencode/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
  212. package/plugins/opencode/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
  213. package/plugins/opencode/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
  214. package/plugins/opencode/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
  215. package/plugins/opencode/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
  216. package/plugins/opencode/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
  217. package/plugins/opencode/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
  218. package/plugins/opencode/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
  219. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
  220. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
  221. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
  222. package/plugins/opencode/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
  223. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  224. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  225. package/plugins/qoder/bin/sprint-flow-guard.sh +12 -60
  226. package/plugins/qoder/plugin.json +1 -1
  227. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +6 -11
  228. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  229. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  230. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  231. package/plugins/shared/README.md +3 -0
  232. package/plugins/shared/bin/delphi-review-guard.sh +68 -0
  233. package/principles/adapters/control-nesting.ts +481 -168
  234. package/principles/adapters/cpp.ts +61 -22
  235. package/principles/adapters/csharp.ts +183 -66
  236. package/principles/adapters/dart.ts +11 -1
  237. package/principles/adapters/duplication.ts +49 -16
  238. package/principles/adapters/import-clause.ts +62 -15
  239. package/principles/adapters/java.ts +199 -70
  240. package/principles/adapters/line-comment.ts +18 -0
  241. package/principles/adapters/member-scan.ts +50 -8
  242. package/principles/adapters/php.ts +232 -103
  243. package/principles/adapters/python.ts +25 -18
  244. package/principles/adapters/quote-state.ts +21 -8
  245. package/principles/adapters/typescript-mask.ts +276 -0
  246. package/principles/adapters/typescript.ts +206 -200
  247. package/principles/analyzer.ts +16 -6
  248. package/principles/baseline-prune.ts +18 -8
  249. package/principles/baseline.ts +28 -11
  250. package/principles/boy-scout-usage.ts +26 -0
  251. package/principles/boy-scout.ts +261 -180
  252. package/principles/config.ts +183 -57
  253. package/principles/direct-execution.ts +24 -12
  254. package/principles/lint-baseline.ts +235 -122
  255. package/principles/rules/arch/dependency.ts +34 -25
  256. package/principles/rules/arch/shared.ts +24 -20
  257. package/principles/rules/clean-code/deep-nesting.ts +23 -13
  258. package/principles/rules/clean-code/god-class.ts +67 -41
  259. package/principles/rules/clean-code/large-file.ts +30 -23
  260. package/principles/rules/clean-code/long-function.ts +51 -37
  261. package/principles/rules/clean-code/magic-numbers.ts +51 -36
  262. package/principles/rules/clean-code/many-exports.ts +46 -29
  263. package/principles/rules/clean-code/missing-error-handling.ts +38 -20
  264. package/principles/rules/clean-code/too-many-params.ts +41 -22
  265. package/principles/rules/function-source.ts +62 -0
  266. package/principles/rules/solid/dip.ts +10 -6
  267. package/principles/rules/solid/isp.ts +64 -24
  268. package/principles/rules/solid/lsp.ts +66 -18
  269. package/principles/rules/solid/ocp.ts +29 -13
  270. package/principles/rules/solid/srp.ts +34 -18
  271. package/principles/warnings-count.ts +43 -0
  272. package/scripts/__tests__/prepush-source-classification.test.js +129 -0
  273. package/scripts/delphi-config-read.cjs +245 -0
  274. package/scripts/delphi-external-review.cjs +410 -585
  275. package/scripts/delphi-json-extract.cjs +108 -0
  276. package/scripts/delphi-model-validation.cjs +297 -0
  277. package/scripts/delphi-prompts.cjs +55 -0
  278. package/scripts/delphi-repo-tools.cjs +273 -0
  279. package/scripts/delphi-seat-calibration.cjs +204 -0
  280. package/scripts/run-bats-ci.cjs +240 -97
  281. package/scripts/sync-package-content.js +18 -2
  282. package/skills/delphi-review/.delphi-config.json.example +6 -11
  283. package/skills/delphi-review/AGENTS.md +1 -1
  284. package/skills/sprint-flow/AGENTS.md +1 -1
  285. package/skills/test-specification-alignment/AGENTS.md +1 -1
  286. package/lib/__tests__/agent-runtime-journal.test.js +0 -326
  287. package/lib/__tests__/arch-config-template.test.js +0 -190
  288. package/lib/__tests__/arch.test.js +0 -424
  289. package/lib/__tests__/assertion-debt.test.js +0 -99
  290. package/lib/__tests__/audit-cli-contract.test.ts +0 -117
  291. package/lib/__tests__/audit-log.test.ts +0 -107
  292. package/lib/__tests__/baseline-completeness.test.js +0 -264
  293. package/lib/__tests__/baseline-shell-scope.test.js +0 -60
  294. package/lib/__tests__/baseline-unevaluated.test.js +0 -142
  295. package/lib/__tests__/baseline.test.js +0 -212
  296. package/lib/__tests__/bootstrap.test.js +0 -60
  297. package/lib/__tests__/check-alignment-cli.test.mjs +0 -94
  298. package/lib/__tests__/check-alignment-reasons.test.mjs +0 -101
  299. package/lib/__tests__/check-all-skip-accounting.test.js +0 -171
  300. package/lib/__tests__/check-changed-brief.test.js +0 -63
  301. package/lib/__tests__/check-normalize-exit.test.js +0 -24
  302. package/lib/__tests__/check-single-file.test.js +0 -114
  303. package/lib/__tests__/check-version.test.js +0 -463
  304. package/lib/__tests__/coverage-scope.test.js +0 -140
  305. package/lib/__tests__/coverage-threshold.test.js +0 -80
  306. package/lib/__tests__/crap-cli.test.js +0 -87
  307. package/lib/__tests__/crap.test.js +0 -494
  308. package/lib/__tests__/debt-classify.test.js +0 -78
  309. package/lib/__tests__/delphi-channel-doctor.test.js +0 -116
  310. package/lib/__tests__/delphi-channel-uninstall.test.js +0 -128
  311. package/lib/__tests__/delphi-channel.test.js +0 -109
  312. package/lib/__tests__/delphi-setup.test.js +0 -203
  313. package/lib/__tests__/deploy-manifest-check-wired.test.js +0 -138
  314. package/lib/__tests__/deploy-manifest-completeness.test.js +0 -151
  315. package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +0 -40
  316. package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +0 -74
  317. package/lib/__tests__/deploy-manifest-projection.test.js +0 -66
  318. package/lib/__tests__/deploy-manifest-shell-parity.test.js +0 -108
  319. package/lib/__tests__/deploy-manifest.test.js +0 -97
  320. package/lib/__tests__/detect-deps-dsh-profile.test.js +0 -323
  321. package/lib/__tests__/detect-deps-gate-identity.test.js +0 -135
  322. package/lib/__tests__/detect-deps.test.js +0 -655
  323. package/lib/__tests__/doctor-469-hook-env.test.js +0 -211
  324. package/lib/__tests__/doctor-arch-tools.test.js +0 -169
  325. package/lib/__tests__/doctor-audit-ledger.test.js +0 -61
  326. package/lib/__tests__/doctor-brief.test.js +0 -59
  327. package/lib/__tests__/doctor-delphi.test.js +0 -628
  328. package/lib/__tests__/doctor-drift-direction.test.js +0 -104
  329. package/lib/__tests__/doctor-drift-round2.test.js +0 -215
  330. package/lib/__tests__/doctor-exec-retry.test.js +0 -162
  331. package/lib/__tests__/doctor-executed-surface.test.js +0 -230
  332. package/lib/__tests__/doctor-helpers.test.js +0 -139
  333. package/lib/__tests__/doctor-hook-drift.test.js +0 -329
  334. package/lib/__tests__/doctor-hook-signatures.test.js +0 -65
  335. package/lib/__tests__/doctor-machine-mutation.test.js +0 -116
  336. package/lib/__tests__/doctor-module-drift.test.js +0 -212
  337. package/lib/__tests__/doctor-module-resolution-parity.test.js +0 -463
  338. package/lib/__tests__/doctor-path-equivalence.test.js +0 -70
  339. package/lib/__tests__/doctor-repair-boundary.test.js +0 -52
  340. package/lib/__tests__/doctor-signature-stability.test.js +0 -55
  341. package/lib/__tests__/doctor-spawn-capability.test.js +0 -116
  342. package/lib/__tests__/doctor-timeout-partial.test.js +0 -79
  343. package/lib/__tests__/doctor-tui-skill-freshness.test.js +0 -385
  344. package/lib/__tests__/doctor.test.js +0 -1320
  345. package/lib/__tests__/find-bash-wsl.test.js +0 -121
  346. package/lib/__tests__/flaky.test.js +0 -128
  347. package/lib/__tests__/foreign-hooks-global.test.js +0 -125
  348. package/lib/__tests__/gate-audit-skip.test.ts +0 -81
  349. package/lib/__tests__/gate-audit.test.ts +0 -440
  350. package/lib/__tests__/gate-coverage-hook-floor.test.js +0 -94
  351. package/lib/__tests__/gate-coverage.test.js +0 -204
  352. package/lib/__tests__/gate-entry-provenance.test.js +0 -71
  353. package/lib/__tests__/gate-numbering.test.js +0 -79
  354. package/lib/__tests__/gate-rules.test.js +0 -58
  355. package/lib/__tests__/gate-runner-tsx-invocation.test.js +0 -149
  356. package/lib/__tests__/gate-runner-verdict.test.js +0 -105
  357. package/lib/__tests__/gate-runner.test.js +0 -371
  358. package/lib/__tests__/gate2-verdict.test.js +0 -183
  359. package/lib/__tests__/helpers/lib-sandbox.cjs +0 -55
  360. package/lib/__tests__/hook-health-path.test.js +0 -109
  361. package/lib/__tests__/hook-health.test.js +0 -85
  362. package/lib/__tests__/init-gitignore.test.js +0 -204
  363. package/lib/__tests__/init-gitleaks-notice.test.js +0 -57
  364. package/lib/__tests__/init.test.js +0 -530
  365. package/lib/__tests__/install-cmd.test.js +0 -6
  366. package/lib/__tests__/install-sh-deploy-manifest.test.js +0 -80
  367. package/lib/__tests__/install-skill-full-dir.test.js +0 -194
  368. package/lib/__tests__/install-skill.test.js +0 -416
  369. package/lib/__tests__/issue-519-phase-transition-guard.test.js +0 -233
  370. package/lib/__tests__/issue-566-sync-hooks-backup.test.js +0 -228
  371. package/lib/__tests__/issue-583-hook-deploy-log.test.js +0 -121
  372. package/lib/__tests__/issue-586-principles-cmdline.test.js +0 -218
  373. package/lib/__tests__/issue-589-check-all-gate3.test.js +0 -190
  374. package/lib/__tests__/issue-590-archlint-vacuous-pass.test.js +0 -138
  375. package/lib/__tests__/issue-618-gate-not-run.test.js +0 -100
  376. package/lib/__tests__/jscpd-entry-resolution.test.js +0 -143
  377. package/lib/__tests__/language-capability.test.js +0 -291
  378. package/lib/__tests__/language-tools-build-file-install.test.js +0 -82
  379. package/lib/__tests__/language-tools-detect.test.js +0 -301
  380. package/lib/__tests__/migrate.test.js +0 -232
  381. package/lib/__tests__/mirror-manifest.test.js +0 -64
  382. package/lib/__tests__/mirror-sync.test.js +0 -803
  383. package/lib/__tests__/next-sprint.test.js +0 -231
  384. package/lib/__tests__/npm-package.test.js +0 -140
  385. package/lib/__tests__/phase-transition.test.js +0 -1136
  386. package/lib/__tests__/principles-csharp-coverage.test.js +0 -227
  387. package/lib/__tests__/principles-directory.test.js +0 -87
  388. package/lib/__tests__/qoder-delphi-agents.test.js +0 -316
  389. package/lib/__tests__/retro-gate-m.test.js +0 -144
  390. package/lib/__tests__/retro.test.js +0 -131
  391. package/lib/__tests__/rework.test.js +0 -127
  392. package/lib/__tests__/rollback.test.js +0 -183
  393. package/lib/__tests__/runtime-journal.test.js +0 -164
  394. package/lib/__tests__/sastd-client.test.js +0 -514
  395. package/lib/__tests__/shared-paths-lazy-home.test.js +0 -67
  396. package/lib/__tests__/shared-paths.test.js +0 -130
  397. package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +0 -69
  398. package/lib/__tests__/shared-utils.test.js +0 -180
  399. package/lib/__tests__/skill-flags.test.js +0 -48
  400. package/lib/__tests__/slo.test.js +0 -89
  401. package/lib/__tests__/sprint-audit.test.js +0 -207
  402. package/lib/__tests__/sprint-discovery.test.ts +0 -366
  403. package/lib/__tests__/sprint-state-manager.test.js +0 -310
  404. package/lib/__tests__/sprint-status-rework-704.test.js +0 -149
  405. package/lib/__tests__/sprint-status-rework.test.js +0 -329
  406. package/lib/__tests__/sprint-status.test.js +0 -193
  407. package/lib/__tests__/sprint-status.test.ts +0 -213
  408. package/lib/__tests__/test-alignment-java-702.test.ts +0 -177
  409. package/lib/__tests__/test-alignment-range-guard.test.ts +0 -82
  410. package/lib/__tests__/test-alignment.test.ts +0 -853
  411. package/lib/__tests__/tsconfig.json +0 -8
  412. package/lib/__tests__/tsx-resolution.test.js +0 -89
  413. package/lib/__tests__/ui-detector.test.ts +0 -459
  414. package/lib/__tests__/ui-review.test.ts +0 -132
  415. package/lib/__tests__/uninstall-global-residue.test.js +0 -545
  416. package/lib/__tests__/uninstall-skill.test.js +0 -189
  417. package/lib/__tests__/uninstall.test.js +0 -717
  418. package/lib/__tests__/update-hooks.test.js +0 -737
  419. package/lib/__tests__/update-skill-flags.test.js +0 -78
  420. package/lib/__tests__/update-skill.test.js +0 -644
  421. package/lib/__tests__/upgrade-exec.test.js +0 -273
  422. package/lib/__tests__/upgrade-skill-sync.test.js +0 -65
  423. package/lib/__tests__/upgrade.test.js +0 -78
  424. package/lib/__tests__/windows-bash-probe.test.js +0 -123
  425. package/lib/check-alignment-runner.cjs +0 -97
  426. package/lib/coverage-total.sh +0 -92
  427. package/lib/layer-baseline.cjs +0 -94
  428. package/lib/mattpocock-license-verdict.json +0 -7
@@ -1,204 +0,0 @@
1
- /**
2
- * @test REQ-636 One command that shows compliance against EVERY gate
3
- * @intent Today the answer to "how healthy is this project against xp-gate's
4
- * gates" takes six commands and mental arithmetic:
5
- *
6
- * xp-gate gate-list && xp-gate check . --all && xp-gate doctor
7
- * node scripts/ccn-report.cjs --check
8
- * node -e "...sum .warnings-baseline.json..."
9
- * gh run list
10
- *
11
- * Every existing command answers "did THIS gate pass". None answers
12
- * "where is the debt and what should I fix first".
13
- *
14
- * The single most important property is that the view has FOUR states,
15
- * not three. `passed / skipped / failed` merges "did not run" into
16
- * "ran and was fine", and that is exactly where technical debt hides.
17
- * A gate that never executed renders identically to a gate that passed
18
- * clean -- a false green, which is the most dangerous output this
19
- * tooling can produce.
20
- *
21
- * Two data hazards drive the rest of the design:
22
- *
23
- * - The artifact emits `gate9_build_integrity` and `gate10_sast`. An
24
- * earlier version of this comment claimed the CLI numbered those the
25
- * other way round and that the two were SWAPPED. That was false: the
26
- * registry, gate-runner.js and the artifact all say 9=Build Integrity,
27
- * 10=SAST. gate-coverage alone disagreed, via a swap table written for
28
- * an inversion that never existed (#738). The table is deleted; the
29
- * table and report keys are now DERIVED from githooks/gate-registry.sh
30
- * so a fresh copy of the mapping cannot reappear here.
31
- *
32
- * - `quality-status/<branch>.json` records the commit it was generated
33
- * from. Rendering it for a different HEAD silently presents stale
34
- * results as current. This repo has had that artifact sit at an old
35
- * commit for days, so staleness must be explicit, not inferred away.
36
- * @covers AC-636-01, AC-636-02, AC-636-03, AC-636-04, AC-636-05, AC-636-06
37
- */
38
- 'use strict';
39
-
40
- const { renderGateCoverage, buildCoverageRows, STATUS } = require('../gate-coverage');
41
-
42
- /** A `quality-status` artifact shaped like the real producer's output. */
43
- function artifact(overrides) {
44
- return {
45
- reportVersion: '2.0',
46
- generatedAt: '2026-10-27T03:06:05Z',
47
- commit: 'a0bceb9c0000000000000000000000000000000',
48
- branch: 'main',
49
- language: 'typescript iac',
50
- overall: {
51
- gatesPassed: 6,
52
- gatesTotal: 12,
53
- gatesSkipped: 6,
54
- gatesWarned: 0,
55
- gatesFailed: 0,
56
- gatesEffective: 6,
57
- effectivePassRate: 100,
58
- scoreAllGates: 5,
59
- score: 10,
60
- verdict: 'PARTIAL',
61
- ...(overrides && overrides.overall ? overrides.overall : {}),
62
- },
63
- gates: {
64
- gate1_static_analysis: { name: 'Static Analysis', status: 'PASS', tool: 'eslint' },
65
- gate9_build_integrity: { name: 'Build Integrity', status: 'PASS', tool: 'tsc' },
66
- gate10_sast: { name: 'SAST Security', status: 'PASS', tool: 'semgrep' },
67
- ...(overrides && overrides.gates ? overrides.gates : {}),
68
- },
69
- };
70
- }
71
-
72
- describe('gate coverage — four states, never a false green (#636)', () => {
73
- it('AC-636-01: a gate that never ran is SKIP with a reason, never folded into PASS', () => {
74
- const rows = buildCoverageRows(artifact(), { headCommit: 'a0bceb9c0000000000000000000000000000000' });
75
- // Gates 0/1/5/11 are hook-only: they exist but the CLI cannot run them.
76
- const version = rows.find((r) => r.gate === 0);
77
- expect(version, 'Gate 0 must appear even though it never ran').toBeDefined();
78
- expect(version.status).toBe(STATUS.SKIP);
79
- // A bare SKIP is the false green. The reason is mandatory.
80
- expect(version.reason).toBeTruthy();
81
- // The reason must say WHY it did not run -- "hook only" and "not run here"
82
- // are both honest; a bare SKIP is not.
83
- expect(version.reason).toMatch(/hook|git commit|not run/i);
84
- });
85
-
86
- it('AC-636-02: gate 9 is Build Integrity and gate 10 is SAST, matching the artifact keys', () => {
87
- // This assertion replaces an earlier one that pinned 9=SAST / 10=Build
88
- // Integrity and called it "the CLI's numbering, not the artifact's". That
89
- // claim was false: githooks/pre-commit emits `gate9_build_integrity` and
90
- // `gate10_sast`, exactly like gate-registry.sh and gate-runner.js. Only
91
- // gate-coverage disagreed, via a swap table asserting the producer numbered
92
- // them "the other way round" (#738).
93
- //
94
- // The old assertion is DELETED rather than inverted in place: an inverted
95
- // assertion would still be a hand-written number->name mapping — a second
96
- // copy of the fact, which is the defect class itself. The expectation now
97
- // comes from the registry through the derived table, and
98
- // scripts/__tests__/gate-identity-cross-surface.test.cjs compares every
99
- // surface so a fresh copy fails a test instead of misleading a reader.
100
- const rows = buildCoverageRows(artifact(), { headCommit: 'a0bceb9c0000000000000000000000000000000' });
101
- const build = rows.find((r) => r.name === 'Build Integrity');
102
- const sast = rows.find((r) => r.name === 'SAST Security');
103
- expect(build, 'Build Integrity row must exist').toBeDefined();
104
- expect(sast, 'SAST row must exist').toBeDefined();
105
- // Evidence: the real artifact keys (hooked at pre-commit:6158/6163).
106
- expect(build.gate).toBe(9);
107
- expect(sast.gate).toBe(10);
108
- });
109
-
110
- it('AC-636-03: a stale artifact is marked STALE instead of presented as current', () => {
111
- const rows = buildCoverageRows(artifact(), { headCommit: 'ffffffffffffffffffffffffffffffffffffffff' });
112
- const rendered = renderGateCoverage(rows, { stale: true, headCommit: 'ffffffffffffffffffffffffffffffffffffffff' });
113
- expect(rendered).toMatch(/STALE/i);
114
- });
115
-
116
- it('AC-636-04: DEBT is observable and quantified, not rendered as a clean PASS', () => {
117
- // Gate 6 holds no warnings of its own; the debt lives in the Boy Scout
118
- // baseline. A view that only reads gate statuses reports "PASS" and hides it.
119
- const rows = buildCoverageRows(artifact(), {
120
- headCommit: 'a0bceb9c0000000000000000000000000000000',
121
- boyScout: { files: 14, warnings: 129 },
122
- });
123
- const boyScout = rows.find((r) => /boy scout/i.test(r.name));
124
- expect(boyScout).toBeDefined();
125
- expect(boyScout.status).toBe(STATUS.DEBT);
126
- expect(String(boyScout.debt)).toMatch(/129/);
127
- expect(boyScout.evidence).toMatch(/warnings-baseline/);
128
- });
129
-
130
- it('AC-636-05: default exit does not fail on DEBT, but --strict does', () => {
131
- const debtRows = [{ gate: 6, name: 'Boy Scout', status: STATUS.DEBT, debt: '1 warning' }];
132
- expect(buildCoverageRows).toBeDefined();
133
- const { exitCodeFor } = require('../gate-coverage');
134
- // Debt is budgeted and known: failing on it by default makes the command
135
- // unusable as a CI dashboard.
136
- expect(exitCodeFor(debtRows, {})).toBe(0);
137
- expect(exitCodeFor(debtRows, { strict: true })).toBe(1);
138
- // A real failure always fails.
139
- expect(exitCodeFor([{ gate: 7, name: 'x', status: STATUS.FAIL }], {})).toBe(1);
140
- });
141
-
142
- it('AC-636-06: every row carries evidence pointing at the artifact that decided it', () => {
143
- const rows = buildCoverageRows(artifact(), { headCommit: 'a0bceb9c0000000000000000000000000000000' });
144
- // Without Evidence the user can only trust a one-line claim; with it they
145
- // can go check. Same reason `doctor` prints paths.
146
- for (const row of rows) {
147
- expect(row.evidence, `Gate ${row.gate} (${row.name}) has no evidence pointer`).toBeTruthy();
148
- }
149
- });
150
- });
151
-
152
- describe('REQ-GATEID-007 — artifact selection is deterministic or fails', () => {
153
- const fs = require('node:fs');
154
- const os = require('node:os');
155
- const pathMod = require('node:path');
156
- const { readQualityStatus } = require('../gate-coverage.js');
157
-
158
- function makeRepo(artifacts) {
159
- const root = fs.mkdtempSync(pathMod.join(os.tmpdir(), 'xp-gate-coverage-'));
160
- const dir = pathMod.join(root, '.xp-gate', 'quality-status');
161
- fs.mkdirSync(dir, { recursive: true });
162
- for (const [name, body] of Object.entries(artifacts)) {
163
- fs.writeFileSync(pathMod.join(dir, `${name}.json`), JSON.stringify(body));
164
- }
165
- return root;
166
- }
167
-
168
- it('AC-GATEID-007-01/04: several artifacts refuse to pick by directory order', () => {
169
- // This is the second cause of the wrong output this sprint fixes: bare
170
- // `xp-gate gate-coverage` used to read whichever file readdirSync returned
171
- // first -- here `land-pr438.json` (commit 33672f6d) rather than the branch's
172
- // own `main.json`. Reading the wrong object beats reading a stale one for
173
- // danger, and the `stale: true` notice masked it.
174
- const root = makeRepo({ 'cam-a': { commit: 'aaa' }, 'cam-b': { commit: 'bbb' } });
175
- const status = readQualityStatus(root);
176
- expect(status.artifact).toBeNull();
177
- expect(status.error).toBeTruthy();
178
- // The migration path must be discoverable from the message itself.
179
- expect(status.error).toMatch(/--branch/);
180
- expect(status.candidates.sort()).toEqual(['cam-a', 'cam-b']);
181
- // Every candidate must be named, not merely "there are several".
182
- expect(status.error).toMatch(/cam-a/);
183
- expect(status.error).toMatch(/cam-b/);
184
- });
185
-
186
- it('AC-GATEID-007-02: a single artifact still works', () => {
187
- const root = makeRepo({ only: { commit: 'ccc', gates: {} } });
188
- const status = readQualityStatus(root);
189
- expect(status.error).toBeUndefined();
190
- expect(status.artifact.commit).toBe('ccc');
191
- });
192
-
193
- it('AC-GATEID-007-03: an explicit --branch that does not exist errors instead of falling back', () => {
194
- const root = makeRepo({ other: { commit: 'ddd', gates: {} } });
195
- const status = readQualityStatus(root, 'missing');
196
- expect(status.artifact).toBeNull();
197
- expect(status.error).toMatch(/missing/);
198
- });
199
-
200
- it('AC-GATEID-007-03: an explicit --branch reads exactly that artifact', () => {
201
- const root = makeRepo({ 'cam-a': { commit: 'aaa' }, 'cam-b': { commit: 'bbb' } });
202
- expect(readQualityStatus(root, 'cam-b').artifact.commit).toBe('bbb');
203
- });
204
- });
@@ -1,71 +0,0 @@
1
- /**
2
- * @test REQ-672
3
- * @intent 门禁的 TypeScript 实现必须**随包走**,不能随被检项目的 cwd 走。
4
- *
5
- * `findTsGateEntry` 曾把 `process.cwd()/src/gates/<gate>.ts` 也列进候选。
6
- * 在开发者布局里这条永远轮不到(前三个候选先命中),所以在本仓跑任何
7
- * 断言都是绿的——**这正是这个缺陷能活下来的原因**。必须在 npm 安装布局
8
- * 下测:前三个候选都不存在,第四条的 cwd 候选才会浮上来。
9
- *
10
- * 后果不是"用错了文件",是**被检方决定门禁怎么判**:那个文件可以是
11
- * `process.exit(0)`,于是任何一个自带该路径的项目都能让自己通过任何门禁。
12
- * 一个能被被检对象改写的门禁不是门禁。
13
- *
14
- * 夹具把 `lib/` 复制到临时目录并**故意不放** `gates/` 兄弟目录,以此复现
15
- * npm 包的布局;被检项目则种下一个 `src/gates/gate-9.ts`。
16
- * @covers AC-672-01
17
- */
18
- 'use strict';
19
-
20
- const { spawnSync } = require('node:child_process');
21
- const fs = require('node:fs');
22
- const os = require('node:os');
23
- const path = require('node:path');
24
-
25
- const LIB_DIR = path.resolve(__dirname, '..');
26
-
27
- /**
28
- * Build an npm-install-shaped fixture and ask it to resolve gate-9.
29
- *
30
- * @returns {{ resolved: string, consumer: string, planted: string }} paths for assertions
31
- */
32
- function resolveInNpmLayout() {
33
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'xpg-provenance-'));
34
- // npm package layout: `lib/` exists, and there is NO `src/gates/` sibling three
35
- // levels up (that is the developer layout, which always wins when it is present).
36
- const pkg = path.join(root, 'node_modules', 'xp-gate');
37
- fs.mkdirSync(path.join(pkg, 'lib'), { recursive: true });
38
- fs.cpSync(LIB_DIR, path.join(pkg, 'lib'), { recursive: true });
39
-
40
- // The party being checked: it plants its own gate implementation.
41
- const consumer = path.join(root, 'consumer');
42
- const planted = path.join(consumer, 'src', 'gates', 'gate-9.ts');
43
- fs.mkdirSync(path.dirname(planted), { recursive: true });
44
- fs.writeFileSync(planted, 'process.exit(0)\n');
45
-
46
- const runner = path.join(pkg, 'lib', 'gate-runner.js');
47
- const script = [
48
- `const { findTsGateEntry } = require(${JSON.stringify(runner)});`,
49
- 'process.stdout.write(String(findTsGateEntry("gate-9")));',
50
- ].join('\n');
51
- const result = spawnSync(process.execPath, ['-e', script], {
52
- cwd: consumer,
53
- encoding: 'utf8',
54
- timeout: 30000,
55
- });
56
- return { resolved: (result.stdout || '').trim(), consumer, planted, root };
57
- }
58
-
59
- describe('findTsGateEntry 不从消费项目解析实现 (#672)', () => {
60
- it('AC-672-01: a project that plants src/gates/gate-9.ts cannot own the gate implementation', () => {
61
- const { resolved, consumer, root } = resolveInNpmLayout();
62
- try {
63
- // Whatever it resolves to (an installed package normally has no gates/ dir at
64
- // all, so `null` is fine), it must never be a file under the checked project:
65
- // that file is data supplied by the party being checked.
66
- expect(resolved.startsWith(consumer)).toBe(false);
67
- } finally {
68
- fs.rmSync(root, { recursive: true, force: true });
69
- }
70
- });
71
- });
@@ -1,79 +0,0 @@
1
- /**
2
- * @test REQ-686
3
- * @intent 验证 CLI 的门禁编号与钩子一致——钩子把 9 号门叫 Build integrity、
4
- * 10 号门叫 SAST,而 CLI 注册表把两者对调了;用户按报错提示单跑对应门
5
- * 会跑到另一道门上去(#677)
6
- * @covers AC-686-01, AC-686-02, AC-686-03
7
- *
8
- * 为什么必须直接断言注册表:这个错误的表现是「跑起来了、报告绿了」。
9
- * `xp-gate check --gates 9` 在编号错位时不会报错,它跑的是 semgrep 并如实报告
10
- * semgrep 的结果——只有拿它和钩子里的门名对照才能看出跑错了门。
11
- */
12
- 'use strict';
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
- const { GATE_REGISTRY, resolveAlias } = require('../gate-runner');
17
-
18
- const REPO_ROOT = path.join(__dirname, '../../../..');
19
-
20
- /**
21
- * Concatenate every file that participates in the pre-commit gate chain: the
22
- * entry point, the ordered driver, and one body per gate.
23
- *
24
- * #798 moved each gate's banner and logic out of pre-commit into
25
- * gate-entries/. Assertions about gate NAMES must therefore read the whole
26
- * chain, or they pass while the names moved to a file nothing sources.
27
- * @returns {string} the chain's source text, newline-joined
28
- */
29
- function readGateChain() {
30
- const parts = [fs.readFileSync(path.join(REPO_ROOT, 'githooks/pre-commit'), 'utf8')];
31
- const driver = path.join(REPO_ROOT, 'githooks/gate-driver.sh');
32
- if (fs.existsSync(driver)) parts.push(fs.readFileSync(driver, 'utf8'));
33
- const entriesDir = path.join(REPO_ROOT, 'githooks/gate-entries');
34
- if (fs.existsSync(entriesDir)) {
35
- for (const f of fs.readdirSync(entriesDir).sort()) {
36
- if (f.endsWith('.sh')) parts.push(fs.readFileSync(path.join(entriesDir, f), 'utf8'));
37
- }
38
- }
39
- return parts.join('\n');
40
- }
41
-
42
- describe('gate numbering matches the hook (#677)', () => {
43
- it('AC-686-01: gate 9 is Build Integrity and gate 10 is SAST Security', () => {
44
- expect(GATE_REGISTRY['9'].name).toBe('Build Integrity');
45
- expect(GATE_REGISTRY['10'].name).toBe('SAST Security');
46
- });
47
-
48
- it('AC-686-02: the hook agrees — its own output names 9 as Build integrity', () => {
49
- // Reads the hook rather than restating the constant: if the hook ever
50
- // renumbers again, this fails and points at which side moved.
51
- //
52
- // #798 moved each gate's banner into its own gate-entries/ file, so the
53
- // assertion reads the whole chain. It deliberately does NOT assert on
54
- // pre-commit alone: that would pass while every banner sat in a file no
55
- // hook sources -- the exact failure #677 was filed about.
56
- const hook = readGateChain();
57
- expect(hook).toMatch(/→ Gate 9: Build integrity/);
58
- expect(hook).toMatch(/GATE 10: Semgrep SAST/);
59
- });
60
-
61
- it('AC-686-03: aliases resolve to the gate the user meant', () => {
62
- expect(resolveAlias('sast')).toBe('10');
63
- expect(resolveAlias('semgrep')).toBe('10');
64
- expect(resolveAlias('build')).toBe('9');
65
- });
66
-
67
- it('AC-686-03: gates 12 and 13 are registered instead of "Unknown gate(s)"', () => {
68
- // Both block commits in the hook. Answering "Unknown gate" for a gate that just
69
- // blocked the user is the same category of wrong as running the wrong one.
70
- expect(GATE_REGISTRY['12'].name).toBe('File Hygiene');
71
- expect(GATE_REGISTRY['13'].name).toBe('Compiler Strictness');
72
- // They are registered as hook-only, with a stated reason -- not as runnable
73
- // stubs that would answer PASS without doing the work.
74
- expect(GATE_REGISTRY['12'].preCommitOnly).toBe(true);
75
- expect(GATE_REGISTRY['13'].preCommitOnly).toBe(true);
76
- expect(GATE_REGISTRY['12'].reason).toBeTruthy();
77
- expect(GATE_REGISTRY['13'].reason).toBeTruthy();
78
- });
79
- });
@@ -1,58 +0,0 @@
1
- /**
2
- * @test REQ-652 BUILD 阶段的门禁清单必须从真相源生成,而非手抄
3
- * @intent #652 的实证是:BUILD 阶段生成代码时,模型对 Boy Scout / CCN / jscpd /
4
- * archlint 完全不可知——不是"知道却不遵守",是**根本不知道规则存在**。
5
- * 后果是 27% 的门禁失败属于静态规则违规,即唯一 100% 可在生成前规避的类别。
6
- *
7
- * 补一页手写的阈值表能解决今天的问题,但会制造明天的问题:`.principlesrc`
8
- * 里 `long-function` 是 50、`deep-nesting` 是 4,一旦有人调成 60/5,那一页
9
- * 手抄的表就开始说谎。**一个说谎的自检清单比没有清单更糟**——它会让人按错的
10
- * 规则写代码,然后在提交时被告知另一套。
11
- *
12
- * 所以这个清单必须从配置文件生成。真相源有几个就在几个里读,不复制。
13
- * @covers AC-652-01, AC-652-02, AC-652-03
14
- */
15
- 'use strict';
16
-
17
- const fs = require('node:fs');
18
- const path = require('node:path');
19
- const { collectGateRules } = require('../gate-rules');
20
-
21
- const REPO = path.join(__dirname, '..', '..', '..', '..');
22
-
23
- describe('BUILD 阶段门禁清单 (#652)', () => {
24
- it('AC-652-01: 从 .principlesrc 读出真实阈值,不是写死的数字', () => {
25
- const rules = collectGateRules({ cwd: REPO });
26
- const longFn = rules.find((r) => r.id === 'clean-code.long-function');
27
- const nesting = rules.find((r) => r.id === 'clean-code.deep-nesting');
28
- expect(longFn).toBeDefined();
29
- expect(nesting).toBeDefined();
30
- // The value must come from the config file. Reading .principlesrc here keeps the
31
- // test honest: if the config changes and the generator does not follow, this fails.
32
- const cfg = JSON.parse(fs.readFileSync(path.join(REPO, '.principlesrc'), 'utf8'));
33
- expect(longFn.threshold).toBe(cfg.rules['clean-code']['long-function'].threshold);
34
- expect(nesting.threshold).toBe(cfg.rules['clean-code']['deep-nesting'].threshold);
35
- });
36
-
37
- it('AC-652-02: 覆盖会阻断提交的每一类规则,而不只是 principles', () => {
38
- const rules = collectGateRules({ cwd: REPO });
39
- const sources = new Set(rules.map((r) => r.source));
40
- // #652 named exactly these four as absent from BUILD docs.
41
- for (const required of ['principles', 'ccn', 'jscpd', 'boy-scout']) {
42
- expect(sources).toContain(required);
43
- }
44
- });
45
-
46
- it('AC-652-03: 生成结果可渲染成一份自检清单,含阈值与出处', () => {
47
- const rules = collectGateRules({ cwd: REPO });
48
- for (const rule of rules) {
49
- expect(typeof rule.id).toBe('string');
50
- expect(typeof rule.source).toBe('string');
51
- // Without the evidence pointer, "the threshold is 50" cannot be checked or
52
- // argued with -- it is indistinguishable from a guess.
53
- expect(typeof rule.evidence).toBe('string');
54
- expect(rule.evidence).not.toBe('');
55
- expect(['block', 'warn', 'info']).toContain(rule.severity);
56
- }
57
- });
58
- });
@@ -1,149 +0,0 @@
1
- /**
2
- * @test REQ-ts-gate-startup tsx 直调(#779)
3
- * @intent 证明 TypeScript 门禁不再经 `npx -y tsx` 启动,而是用当前 node.exe 直接
4
- * 运行 tsx 的 cli.mjs。`npx -y` 每次都要重新解析包位置,实测 4.5-5.8s,而
5
- * node 直调 0.79-0.82s —— 每道 TS 门禁白付约 4 秒。
6
- * @covers AC-TS-GATE-STARTUP-01, AC-TS-GATE-STARTUP-02, AC-TS-GATE-STARTUP-03, AC-TS-GATE-STARTUP-04
7
- */
8
- const fs = require('node:fs');
9
- const path = require('node:path');
10
- const os = require('node:os');
11
- const { resolveTsxInvocation } = require('../gate-runner');
12
-
13
- let tmpDir;
14
-
15
- beforeEach(() => {
16
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'xpgate-tsx-'));
17
- });
18
-
19
- afterEach(() => {
20
- if (tmpDir && fs.existsSync(tmpDir)) {
21
- fs.rmSync(tmpDir, { recursive: true, force: true });
22
- }
23
- });
24
-
25
- /**
26
- * Lay down a fake <root>/node_modules/tsx/dist/cli.mjs that exists and is readable.
27
- *
28
- * Failing here means the FIXTURE broke, not the resolver, so the error names the
29
- * fixture. Swallowing it would let a setup defect surface later as "the resolver
30
- * returned the npx fallback", which is a misleading diagnosis.
31
- */
32
- function plantLocalTsx(root) {
33
- const cli = path.join(root, 'node_modules', 'tsx', 'dist', 'cli.mjs');
34
- try {
35
- fs.mkdirSync(path.dirname(cli), { recursive: true });
36
- fs.writeFileSync(cli, '// fake tsx cli' + String.fromCharCode(10));
37
- } catch (err) {
38
- throw new Error(`fixture: could not plant tsx cli at ${cli}: ${err.message}`);
39
- }
40
- return cli;
41
- }
42
-
43
- describe('resolveTsxInvocation — AC-TS-GATE-STARTUP-01', () => {
44
- it('uses node.exe + tsx/cli.mjs when a local tsx is installed', () => {
45
- const cli = plantLocalTsx(tmpDir);
46
- const { command, args } = resolveTsxInvocation(['gate.ts', '--run'], { cwd: tmpDir });
47
-
48
- expect(command).toBe(process.execPath);
49
- expect(args[0]).toBe(cli);
50
- expect(args.slice(1)).toEqual(['gate.ts', '--run']);
51
- });
52
-
53
- it('never puts `-y` in the argv — that is the npx network-retry flag', () => {
54
- plantLocalTsx(tmpDir);
55
- const { args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
56
- expect(args).not.toContain('-y');
57
- expect(args).not.toContain('tsx');
58
- });
59
- });
60
-
61
- describe('resolveTsxInvocation — AC-TS-GATE-STARTUP-02', () => {
62
- it('walks up parent directories to find a hoisted node_modules/tsx', () => {
63
- const nested = path.join(tmpDir, 'a', 'b', 'c');
64
- fs.mkdirSync(nested, { recursive: true });
65
- const cli = plantLocalTsx(tmpDir);
66
-
67
- const { args } = resolveTsxInvocation(['gate.ts'], { cwd: nested });
68
- expect(args[0]).toBe(cli);
69
- });
70
-
71
- it('falls back to npm npx-cli.js (still no shell) when no tsx is installed', () => {
72
- const { command, args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
73
-
74
- // The fallback keeps the pre-existing no-shell guarantee: node.exe runs npx's
75
- // own JS entry. What must NOT happen is a bare `npx` (unresolvable without a
76
- // shell on Windows) or `shell: true` (cmd.exe's 8191-char ceiling, #586).
77
- expect(command).toBe(process.execPath);
78
- expect(args.some((a) => String(a).includes('npx-cli.js'))).toBe(true);
79
- expect(args).toContain('-y');
80
- });
81
- });
82
-
83
- describe('resolveTsxInvocation — AC-TS-GATE-STARTUP-03', () => {
84
- it('ignores a tsx dir that exists but has no cli.mjs (partial install)', () => {
85
- fs.mkdirSync(path.join(tmpDir, 'node_modules', 'tsx', 'dist'), { recursive: true });
86
- const { args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
87
- expect(args.some((a) => String(a).includes('npx-cli.js'))).toBe(true);
88
- });
89
-
90
- it('produces a spawnable argv: an existing file for args[0] when local', () => {
91
- plantLocalTsx(tmpDir);
92
- const { command, args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
93
- expect(command).toBe(process.execPath);
94
- expect(fs.existsSync(args[0])).toBe(true);
95
- });
96
- });
97
-
98
- describe('resolveTsxInvocation — AC-TS-GATE-STARTUP-04 (npm layout varies by install)', () => {
99
- /**
100
- * Restore `process.execPath` after the probe. Kept as a helper because the
101
- * override is only sound if it is undone even when an assertion throws, and an
102
- * unrestored execPath would corrupt every later test in this process.
103
- */
104
- function withExecPath(fakeNode, fn) {
105
- const real = process.execPath;
106
- Object.defineProperty(process, 'execPath', { value: fakeNode, configurable: true });
107
- try {
108
- return fn();
109
- } finally {
110
- Object.defineProperty(process, 'execPath', { value: real, configurable: true });
111
- delete require.cache[require.resolve('../gate-runner')];
112
- }
113
- }
114
-
115
- it('finds npm under lib/node_modules — the layout actions/setup-node produces on Linux', () => {
116
- // This is the shape CI actually runs on: /opt/hostedtoolcache/node/<v>/x64/bin/node
117
- // with npm's library at <...>/lib/node_modules/npm, not alongside the binary.
118
- // Probe order matters only because the plain layout is tried first; what this
119
- // asserts is that the `lib/` layout is tried at all.
120
- const root = path.join(tmpDir, 'node-install');
121
- const fakeNode = path.join(root, 'x64', 'bin', 'node');
122
- const libNpm = path.join(root, 'x64', 'lib', 'node_modules', 'npm', 'bin', 'npx-cli.js');
123
- fs.mkdirSync(path.dirname(libNpm), { recursive: true });
124
- fs.writeFileSync(libNpm, '');
125
-
126
- withExecPath(fakeNode, () => {
127
- const { command, args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
128
- // A bare `npx` here is the defect: unresolvable without a shell on Windows,
129
- // and a PATH hop that silently runs whatever npx happens to be first.
130
- expect(command).toBe(fakeNode);
131
- expect(args.some((a) => String(a).includes('npx-cli.js'))).toBe(true);
132
- expect(fs.existsSync(args[0])).toBe(true);
133
- });
134
- });
135
-
136
- it('finds npm alongside the binary — the Windows MSI / official tarball layout', () => {
137
- const root = path.join(tmpDir, 'win-install');
138
- const fakeNode = path.join(root, 'node.exe');
139
- const plainNpm = path.join(root, 'node_modules', 'npm', 'bin', 'npx-cli.js');
140
- fs.mkdirSync(path.dirname(plainNpm), { recursive: true });
141
- fs.writeFileSync(plainNpm, '');
142
-
143
- withExecPath(fakeNode, () => {
144
- const { command, args } = resolveTsxInvocation(['gate.ts'], { cwd: tmpDir });
145
- expect(command).toBe(fakeNode);
146
- expect(args.some((a) => String(a).includes('npx-cli.js'))).toBe(true);
147
- });
148
- });
149
- });
@@ -1,105 +0,0 @@
1
- /**
2
- * @test REQ-563 runGate must not discard a synchronous gate verdict
3
- * @intent `runGate()` reports "passed" for every gate whose `run()` returns a
4
- * number instead of a Promise. Four registry entries — gates 3, 7, 8
5
- * and 9 — reach `runTsGate()`, which returns `result.status` as a plain
6
- * number, and the runner's own code path was:
7
- *
8
- * const result = gate.run(targetPath);
9
- * if (result && typeof result.then === 'function') return await result;
10
- * return 0; // <-- the number is dropped here
11
- *
12
- * So a gate that exits 1 in its child process is reported as 0 by
13
- * `xp-gate check`. `checkAllGates()` counts `code !== 0` as a failure, so
14
- * it faithfully counts whatever `runGate` hands back — which is always
15
- * 0 for those four gates. The fail-open is in exactly one place and it
16
- * is silent: nothing in the output says the verdict was manufactured.
17
- *
18
- * Gates 4 and 6 escaped this by returning `Promise.resolve(...)`, and
19
- * gate 2 escaped it because `execFileSync` throws on a non-zero exit and
20
- * the `catch` converts that to 1. Both of those are accidents of how
21
- * each handler was written, not a contract — which is why the fix has to
22
- * be in the runner, not in each handler.
23
- * @covers AC-563-01, AC-563-02, AC-563-03
24
- */
25
- const gateRunner = require('../gate-runner.js');
26
- const { runGate, GATE_REGISTRY } = gateRunner;
27
-
28
- const STUB_GATE_ID = '__stub_gate__';
29
-
30
- /**
31
- * Install a throwaway registry entry and return a cleanup function.
32
- * @param {object} handler - the `run` implementation to install
33
- * @returns {Function} cleanup
34
- */
35
- function withStubGate(handler) {
36
- GATE_REGISTRY[STUB_GATE_ID] = {
37
- name: 'Stub Gate',
38
- description: 'test double',
39
- aliases: [],
40
- run: handler,
41
- };
42
- return () => {
43
- delete GATE_REGISTRY[STUB_GATE_ID];
44
- };
45
- }
46
-
47
- let cleanup = null;
48
-
49
- beforeEach(() => {
50
- // Keep the console quiet: runGate prints a banner for every invocation.
51
- if (!global.__xpGateStubLog) {
52
- global.__xpGateStubLog = console.log;
53
- }
54
- console.log = () => {};
55
- });
56
-
57
- afterEach(() => {
58
- if (cleanup) {
59
- cleanup();
60
- cleanup = null;
61
- }
62
- console.log = global.__xpGateStubLog;
63
- });
64
-
65
- describe('runGate verdict propagation', () => {
66
- test('AC-563-01: a synchronous non-zero verdict is returned, not swallowed', async () => {
67
- // This is the exact shape `runTsGate` has: a plain number, no Promise.
68
- cleanup = withStubGate(() => 1);
69
-
70
- const code = await runGate(STUB_GATE_ID, '.');
71
-
72
- expect(
73
- code,
74
- 'runGate returned a manufactured 0 for a gate whose synchronous handler ' +
75
- 'said 1 — the caller (checkAllGates) cannot distinguish pass from fail'
76
- ).toBe(1);
77
- });
78
-
79
- test('AC-563-02: a synchronous zero verdict still reads as pass', async () => {
80
- // The guard against "fix it by always failing": a genuine 0 must stay 0.
81
- cleanup = withStubGate(() => 0);
82
-
83
- const code = await runGate(STUB_GATE_ID, '.');
84
-
85
- expect(code).toBe(0);
86
- });
87
-
88
- test('AC-563-03: async and throwing handlers keep their existing verdicts', async () => {
89
- // Promise-returning handlers already worked; the fix must not regress them.
90
- cleanup = withStubGate(() => Promise.resolve(2));
91
- expect(await runGate(STUB_GATE_ID, '.')).toBe(2);
92
- cleanup();
93
-
94
- cleanup = withStubGate(() => {
95
- throw new Error('boom');
96
- });
97
- expect(await runGate(STUB_GATE_ID, '.')).toBe(1);
98
- cleanup();
99
-
100
- // An async handler that REJECTS must also fail closed, not propagate an
101
- // unhandled rejection out of runGate.
102
- cleanup = withStubGate(() => Promise.reject(new Error('async boom')));
103
- expect(await runGate(STUB_GATE_ID, '.')).toBe(1);
104
- });
105
- });