@boyingliu01/xp-gate 0.38.126 → 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 (421) hide show
  1. package/README.md +93 -0
  2. package/adapters/gate-3.sh +13 -2
  3. package/adapters/python.sh +36 -38
  4. package/bin/xp-gate.js +11 -0
  5. package/build-integrity/gate-10-lines.ts +98 -0
  6. package/build-integrity/gate-10.ts +98 -109
  7. package/build-integrity/quote-masker.ts +17 -3
  8. package/gate-3.sh +13 -2
  9. package/gates/common-process.ts +116 -34
  10. package/gates/common.ts +51 -15
  11. package/gates/gate-3.ts +166 -61
  12. package/gates/gate-8.ts +76 -24
  13. package/gates/gate-9.ts +276 -82
  14. package/gates/pbt-detect.ts +70 -39
  15. package/gates/python-health.ts +236 -98
  16. package/gates/test-layers.ts +103 -30
  17. package/hooks/gate-3.sh +13 -2
  18. package/hooks/gate-entries/gate-1-entry.sh +10 -1
  19. package/hooks/gate-entries/gate-5-entry.sh +5 -1
  20. package/hooks/lib/validate-code-walkthrough.cjs +324 -99
  21. package/hooks/pre-commit +52 -0
  22. package/hooks/pre-push +54 -3
  23. package/lib/agent-runtime-journal.js +104 -37
  24. package/lib/arch.js +6 -0
  25. package/lib/baseline.js +329 -201
  26. package/lib/check.js +38 -2
  27. package/lib/doctor-constants.js +43 -0
  28. package/lib/doctor.js +2008 -1001
  29. package/lib/flaky.js +178 -79
  30. package/lib/gate-runner.js +110 -63
  31. package/lib/init.js +6 -0
  32. package/lib/language-capability-surfaces.js +5 -2
  33. package/lib/language-registry.js +608 -0
  34. package/lib/language-tools.js +487 -1018
  35. package/lib/phase-transition.js +646 -446
  36. package/lib/prepush-evidence.js +174 -0
  37. package/lib/sprint-audit.js +52 -22
  38. package/lib/sprint-discovery.js +66 -35
  39. package/lib/sprint-format.js +114 -0
  40. package/lib/sprint-init.js +372 -118
  41. package/lib/sprint-status.js +134 -90
  42. package/lib/star-notice.js +346 -0
  43. package/lib/tool-display.js +52 -0
  44. package/lib/tool-install.js +179 -0
  45. package/lib/uninstall.js +331 -188
  46. package/mock-policy/gate-m3.ts +74 -23
  47. package/mock-policy/mock-decision-engine.ts +21 -7
  48. package/mock-policy/scope-scanner.ts +128 -69
  49. package/mutation/detect-ai-test.ts +20 -12
  50. package/mutation/gate-m.ts +6 -2
  51. package/mutation/init-baseline.ts +49 -13
  52. package/mutation/runners/go-mutant-runner.ts +7 -49
  53. package/mutation/runners/gremlins-runner.ts +53 -18
  54. package/mutation/runners/mutmut-runner.ts +455 -163
  55. package/mutation/runners/pitest-runner.ts +85 -131
  56. package/mutation/runners/spawn-with-capture.ts +304 -0
  57. package/mutation/runners/stryker-runner.ts +14 -55
  58. package/mutation/update-baseline.ts +25 -18
  59. package/package.json +20 -8
  60. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  61. package/plugins/claude-code/bin/delphi-review-guard.sh +12 -61
  62. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +6 -11
  63. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  64. package/plugins/claude-code/skills/reinstall-xp-gate/.architecture-skip +8 -0
  65. package/plugins/claude-code/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
  66. package/plugins/claude-code/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
  67. package/plugins/claude-code/skills/reinstall-xp-gate/LICENSE +21 -0
  68. package/plugins/claude-code/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
  69. package/plugins/claude-code/skills/reinstall-xp-gate/README.md +167 -0
  70. package/plugins/claude-code/skills/reinstall-xp-gate/SKILL.md +271 -0
  71. package/plugins/claude-code/skills/reinstall-xp-gate/TODO.md +253 -0
  72. package/plugins/claude-code/skills/reinstall-xp-gate/VERSION +1 -0
  73. package/plugins/claude-code/skills/reinstall-xp-gate/package.json +28 -0
  74. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
  75. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
  76. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
  77. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
  78. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
  79. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
  80. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
  81. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
  82. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
  83. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
  84. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
  85. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
  86. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
  87. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
  88. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
  89. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
  90. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
  91. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
  92. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
  93. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
  94. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
  95. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
  96. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
  97. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
  98. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
  99. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
  100. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
  101. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
  102. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
  103. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
  104. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
  105. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
  106. package/plugins/claude-code/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
  107. package/plugins/claude-code/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
  108. package/plugins/claude-code/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
  109. package/plugins/claude-code/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
  110. package/plugins/claude-code/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
  111. package/plugins/claude-code/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
  112. package/plugins/claude-code/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
  113. package/plugins/claude-code/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
  114. package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
  115. package/plugins/claude-code/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
  116. package/plugins/claude-code/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
  117. package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
  118. package/plugins/claude-code/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
  119. package/plugins/claude-code/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
  120. package/plugins/claude-code/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
  121. package/plugins/claude-code/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
  122. package/plugins/claude-code/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
  123. package/plugins/claude-code/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
  124. package/plugins/claude-code/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
  125. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
  126. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
  127. package/plugins/claude-code/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
  128. package/plugins/claude-code/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
  129. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  130. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  131. package/plugins/dsh/package.json +1 -1
  132. package/plugins/dsh/scripts/prepack.cjs +43 -18
  133. package/plugins/dsh/scripts/verify-skill-provider.mjs +39 -14
  134. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +6 -11
  135. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  136. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  137. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  138. package/plugins/opencode/index.ts +337 -123
  139. package/plugins/opencode/package.json +1 -1
  140. package/plugins/opencode/scripts/prepack.cjs +41 -16
  141. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +6 -11
  142. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  143. package/plugins/opencode/skills/reinstall-xp-gate/.architecture-skip +8 -0
  144. package/plugins/opencode/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
  145. package/plugins/opencode/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
  146. package/plugins/opencode/skills/reinstall-xp-gate/LICENSE +21 -0
  147. package/plugins/opencode/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
  148. package/plugins/opencode/skills/reinstall-xp-gate/README.md +167 -0
  149. package/plugins/opencode/skills/reinstall-xp-gate/SKILL.md +271 -0
  150. package/plugins/opencode/skills/reinstall-xp-gate/TODO.md +253 -0
  151. package/plugins/opencode/skills/reinstall-xp-gate/VERSION +1 -0
  152. package/plugins/opencode/skills/reinstall-xp-gate/package.json +28 -0
  153. package/plugins/opencode/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
  154. package/plugins/opencode/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
  155. package/plugins/opencode/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
  156. package/plugins/opencode/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
  157. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
  158. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
  159. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
  160. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
  161. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
  162. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
  163. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
  164. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
  165. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
  166. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
  167. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
  168. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/probes.mjs +102 -0
  169. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
  170. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
  171. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
  172. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
  173. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
  174. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +161 -0
  175. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
  176. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
  177. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
  178. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
  179. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
  180. package/plugins/opencode/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
  181. package/plugins/opencode/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
  182. package/plugins/opencode/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
  183. package/plugins/opencode/skills/reinstall-xp-gate/scripts/reinstall.mjs +297 -0
  184. package/plugins/opencode/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
  185. package/plugins/opencode/skills/reinstall-xp-gate/scripts/verify.mjs +222 -0
  186. package/plugins/opencode/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
  187. package/plugins/opencode/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
  188. package/plugins/opencode/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
  189. package/plugins/opencode/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
  190. package/plugins/opencode/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
  191. package/plugins/opencode/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
  192. package/plugins/opencode/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
  193. package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
  194. package/plugins/opencode/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
  195. package/plugins/opencode/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
  196. package/plugins/opencode/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
  197. package/plugins/opencode/skills/reinstall-xp-gate/tests/proc.test.mjs +243 -0
  198. package/plugins/opencode/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
  199. package/plugins/opencode/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
  200. package/plugins/opencode/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
  201. package/plugins/opencode/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
  202. package/plugins/opencode/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
  203. package/plugins/opencode/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
  204. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
  205. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
  206. package/plugins/opencode/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
  207. package/plugins/opencode/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
  208. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  209. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  210. package/plugins/qoder/bin/sprint-flow-guard.sh +12 -60
  211. package/plugins/qoder/plugin.json +1 -1
  212. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +6 -11
  213. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  214. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  215. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  216. package/plugins/shared/README.md +3 -0
  217. package/plugins/shared/bin/delphi-review-guard.sh +68 -0
  218. package/principles/adapters/control-nesting.ts +481 -168
  219. package/principles/adapters/cpp.ts +61 -22
  220. package/principles/adapters/csharp.ts +183 -66
  221. package/principles/adapters/dart.ts +11 -1
  222. package/principles/adapters/duplication.ts +49 -16
  223. package/principles/adapters/import-clause.ts +62 -15
  224. package/principles/adapters/java.ts +199 -70
  225. package/principles/adapters/line-comment.ts +18 -0
  226. package/principles/adapters/member-scan.ts +50 -8
  227. package/principles/adapters/php.ts +232 -103
  228. package/principles/adapters/python.ts +25 -18
  229. package/principles/adapters/quote-state.ts +21 -8
  230. package/principles/adapters/typescript-mask.ts +276 -0
  231. package/principles/adapters/typescript.ts +206 -200
  232. package/principles/analyzer.ts +16 -6
  233. package/principles/baseline-prune.ts +18 -8
  234. package/principles/baseline.ts +28 -11
  235. package/principles/boy-scout-usage.ts +26 -0
  236. package/principles/boy-scout.ts +261 -180
  237. package/principles/config.ts +183 -57
  238. package/principles/direct-execution.ts +24 -12
  239. package/principles/lint-baseline.ts +235 -122
  240. package/principles/rules/arch/dependency.ts +34 -25
  241. package/principles/rules/arch/shared.ts +24 -20
  242. package/principles/rules/clean-code/deep-nesting.ts +23 -13
  243. package/principles/rules/clean-code/god-class.ts +67 -41
  244. package/principles/rules/clean-code/large-file.ts +30 -23
  245. package/principles/rules/clean-code/long-function.ts +51 -37
  246. package/principles/rules/clean-code/magic-numbers.ts +51 -36
  247. package/principles/rules/clean-code/many-exports.ts +46 -29
  248. package/principles/rules/clean-code/missing-error-handling.ts +38 -20
  249. package/principles/rules/clean-code/too-many-params.ts +41 -22
  250. package/principles/rules/function-source.ts +62 -0
  251. package/principles/rules/solid/dip.ts +10 -6
  252. package/principles/rules/solid/isp.ts +64 -24
  253. package/principles/rules/solid/lsp.ts +66 -18
  254. package/principles/rules/solid/ocp.ts +29 -13
  255. package/principles/rules/solid/srp.ts +34 -18
  256. package/principles/warnings-count.ts +43 -0
  257. package/scripts/__tests__/prepush-source-classification.test.js +129 -0
  258. package/scripts/delphi-config-read.cjs +245 -0
  259. package/scripts/delphi-external-review.cjs +410 -585
  260. package/scripts/delphi-json-extract.cjs +108 -0
  261. package/scripts/delphi-model-validation.cjs +297 -0
  262. package/scripts/delphi-prompts.cjs +55 -0
  263. package/scripts/delphi-repo-tools.cjs +273 -0
  264. package/scripts/delphi-seat-calibration.cjs +204 -0
  265. package/scripts/run-bats-ci.cjs +240 -97
  266. package/scripts/sync-package-content.js +18 -2
  267. package/skills/delphi-review/.delphi-config.json.example +6 -11
  268. package/skills/delphi-review/AGENTS.md +1 -1
  269. package/skills/sprint-flow/AGENTS.md +1 -1
  270. package/skills/test-specification-alignment/AGENTS.md +1 -1
  271. package/lib/__tests__/agent-runtime-journal.test.js +0 -326
  272. package/lib/__tests__/arch-config-template.test.js +0 -190
  273. package/lib/__tests__/arch.test.js +0 -430
  274. package/lib/__tests__/assertion-debt.test.js +0 -99
  275. package/lib/__tests__/audit-cli-contract.test.ts +0 -117
  276. package/lib/__tests__/audit-log.test.ts +0 -107
  277. package/lib/__tests__/audit-skip-reasons.test.ts +0 -143
  278. package/lib/__tests__/baseline-completeness.test.js +0 -264
  279. package/lib/__tests__/baseline-shell-scope.test.js +0 -60
  280. package/lib/__tests__/baseline-unevaluated.test.js +0 -142
  281. package/lib/__tests__/baseline.test.js +0 -212
  282. package/lib/__tests__/bootstrap.test.js +0 -60
  283. package/lib/__tests__/check-alignment-cli.test.mjs +0 -94
  284. package/lib/__tests__/check-alignment-reasons.test.mjs +0 -101
  285. package/lib/__tests__/check-all-skip-accounting.test.js +0 -171
  286. package/lib/__tests__/check-changed-brief.test.js +0 -63
  287. package/lib/__tests__/check-normalize-exit.test.js +0 -24
  288. package/lib/__tests__/check-single-file.test.js +0 -114
  289. package/lib/__tests__/check-tools-list.test.js +0 -155
  290. package/lib/__tests__/check-version.test.js +0 -463
  291. package/lib/__tests__/coverage-scope.test.js +0 -140
  292. package/lib/__tests__/coverage-threshold.test.js +0 -80
  293. package/lib/__tests__/crap-cli.test.js +0 -87
  294. package/lib/__tests__/crap.test.js +0 -494
  295. package/lib/__tests__/debt-classify.test.js +0 -78
  296. package/lib/__tests__/delphi-channel-doctor.test.js +0 -116
  297. package/lib/__tests__/delphi-channel-uninstall.test.js +0 -128
  298. package/lib/__tests__/delphi-channel.test.js +0 -109
  299. package/lib/__tests__/delphi-setup.test.js +0 -203
  300. package/lib/__tests__/deploy-manifest-check-wired.test.js +0 -138
  301. package/lib/__tests__/deploy-manifest-completeness.test.js +0 -151
  302. package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +0 -40
  303. package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +0 -74
  304. package/lib/__tests__/deploy-manifest-projection.test.js +0 -66
  305. package/lib/__tests__/deploy-manifest-shell-parity.test.js +0 -108
  306. package/lib/__tests__/deploy-manifest.test.js +0 -97
  307. package/lib/__tests__/detect-deps-dsh-profile.test.js +0 -323
  308. package/lib/__tests__/detect-deps-gate-identity.test.js +0 -135
  309. package/lib/__tests__/detect-deps.test.js +0 -655
  310. package/lib/__tests__/doctor-469-hook-env.test.js +0 -211
  311. package/lib/__tests__/doctor-arch-tools.test.js +0 -169
  312. package/lib/__tests__/doctor-audit-ledger.test.js +0 -61
  313. package/lib/__tests__/doctor-brief.test.js +0 -59
  314. package/lib/__tests__/doctor-delphi.test.js +0 -628
  315. package/lib/__tests__/doctor-drift-direction.test.js +0 -104
  316. package/lib/__tests__/doctor-drift-round2.test.js +0 -215
  317. package/lib/__tests__/doctor-exec-retry.test.js +0 -162
  318. package/lib/__tests__/doctor-executed-surface.test.js +0 -230
  319. package/lib/__tests__/doctor-helpers.test.js +0 -139
  320. package/lib/__tests__/doctor-hook-drift.test.js +0 -329
  321. package/lib/__tests__/doctor-hook-signatures.test.js +0 -65
  322. package/lib/__tests__/doctor-machine-mutation.test.js +0 -116
  323. package/lib/__tests__/doctor-module-drift.test.js +0 -212
  324. package/lib/__tests__/doctor-module-resolution-parity.test.js +0 -463
  325. package/lib/__tests__/doctor-path-equivalence.test.js +0 -70
  326. package/lib/__tests__/doctor-repair-boundary.test.js +0 -52
  327. package/lib/__tests__/doctor-signature-stability.test.js +0 -55
  328. package/lib/__tests__/doctor-spawn-capability.test.js +0 -116
  329. package/lib/__tests__/doctor-timeout-partial.test.js +0 -79
  330. package/lib/__tests__/doctor-tool-delegation.test.js +0 -156
  331. package/lib/__tests__/doctor-tui-skill-freshness.test.js +0 -385
  332. package/lib/__tests__/doctor.test.js +0 -1320
  333. package/lib/__tests__/find-bash-wsl.test.js +0 -121
  334. package/lib/__tests__/flaky.test.js +0 -128
  335. package/lib/__tests__/foreign-hooks-global.test.js +0 -125
  336. package/lib/__tests__/gate-audit-skip.test.ts +0 -81
  337. package/lib/__tests__/gate-audit.test.ts +0 -440
  338. package/lib/__tests__/gate-coverage-hook-floor.test.js +0 -94
  339. package/lib/__tests__/gate-coverage.test.js +0 -204
  340. package/lib/__tests__/gate-entry-provenance.test.js +0 -71
  341. package/lib/__tests__/gate-numbering.test.js +0 -79
  342. package/lib/__tests__/gate-rules.test.js +0 -58
  343. package/lib/__tests__/gate-runner-tsx-invocation.test.js +0 -149
  344. package/lib/__tests__/gate-runner-verdict.test.js +0 -105
  345. package/lib/__tests__/gate-runner.test.js +0 -371
  346. package/lib/__tests__/gate2-verdict.test.js +0 -183
  347. package/lib/__tests__/helpers/lib-sandbox.cjs +0 -55
  348. package/lib/__tests__/hook-health-path.test.js +0 -109
  349. package/lib/__tests__/hook-health.test.js +0 -85
  350. package/lib/__tests__/init-gitignore.test.js +0 -204
  351. package/lib/__tests__/init-gitleaks-notice.test.js +0 -57
  352. package/lib/__tests__/init.test.js +0 -530
  353. package/lib/__tests__/install-cmd.test.js +0 -6
  354. package/lib/__tests__/install-sh-deploy-manifest.test.js +0 -80
  355. package/lib/__tests__/install-skill-full-dir.test.js +0 -194
  356. package/lib/__tests__/install-skill.test.js +0 -416
  357. package/lib/__tests__/install-tools-repair.test.js +0 -263
  358. package/lib/__tests__/issue-519-phase-transition-guard.test.js +0 -233
  359. package/lib/__tests__/issue-566-sync-hooks-backup.test.js +0 -228
  360. package/lib/__tests__/issue-583-hook-deploy-log.test.js +0 -121
  361. package/lib/__tests__/issue-586-principles-cmdline.test.js +0 -218
  362. package/lib/__tests__/issue-589-check-all-gate3.test.js +0 -190
  363. package/lib/__tests__/issue-590-archlint-vacuous-pass.test.js +0 -138
  364. package/lib/__tests__/issue-618-gate-not-run.test.js +0 -100
  365. package/lib/__tests__/jscpd-entry-resolution.test.js +0 -143
  366. package/lib/__tests__/language-capability.test.js +0 -318
  367. package/lib/__tests__/language-tools-build-file-install.test.js +0 -82
  368. package/lib/__tests__/language-tools-detect.test.js +0 -301
  369. package/lib/__tests__/migrate.test.js +0 -232
  370. package/lib/__tests__/mirror-manifest.test.js +0 -64
  371. package/lib/__tests__/mirror-sync.test.js +0 -803
  372. package/lib/__tests__/next-sprint.test.js +0 -231
  373. package/lib/__tests__/npm-package.test.js +0 -140
  374. package/lib/__tests__/phase-transition.test.js +0 -1136
  375. package/lib/__tests__/principles-csharp-coverage.test.js +0 -227
  376. package/lib/__tests__/principles-directory.test.js +0 -87
  377. package/lib/__tests__/qoder-delphi-agents.test.js +0 -316
  378. package/lib/__tests__/retro-gate-m.test.js +0 -144
  379. package/lib/__tests__/retro.test.js +0 -131
  380. package/lib/__tests__/rework.test.js +0 -127
  381. package/lib/__tests__/rollback.test.js +0 -183
  382. package/lib/__tests__/runtime-journal.test.js +0 -164
  383. package/lib/__tests__/sastd-client.test.js +0 -514
  384. package/lib/__tests__/shared-paths-lazy-home.test.js +0 -67
  385. package/lib/__tests__/shared-paths.test.js +0 -130
  386. package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +0 -69
  387. package/lib/__tests__/shared-utils.test.js +0 -180
  388. package/lib/__tests__/skill-flags.test.js +0 -48
  389. package/lib/__tests__/slo.test.js +0 -89
  390. package/lib/__tests__/sprint-audit.test.js +0 -207
  391. package/lib/__tests__/sprint-discovery.test.ts +0 -366
  392. package/lib/__tests__/sprint-state-manager.test.js +0 -310
  393. package/lib/__tests__/sprint-status-rework-704.test.js +0 -149
  394. package/lib/__tests__/sprint-status-rework.test.js +0 -329
  395. package/lib/__tests__/sprint-status.test.js +0 -193
  396. package/lib/__tests__/sprint-status.test.ts +0 -213
  397. package/lib/__tests__/test-alignment-java-702.test.ts +0 -177
  398. package/lib/__tests__/test-alignment-range-guard.test.ts +0 -82
  399. package/lib/__tests__/test-alignment.test.ts +0 -853
  400. package/lib/__tests__/tool-audit-collect.test.js +0 -184
  401. package/lib/__tests__/tool-audit-fixtures.js +0 -87
  402. package/lib/__tests__/tool-audit-latest.test.js +0 -84
  403. package/lib/__tests__/tool-audit.test.js +0 -428
  404. package/lib/__tests__/tsconfig.json +0 -8
  405. package/lib/__tests__/tsx-resolution.test.js +0 -89
  406. package/lib/__tests__/ui-detector.test.ts +0 -459
  407. package/lib/__tests__/ui-review.test.ts +0 -132
  408. package/lib/__tests__/uninstall-global-residue.test.js +0 -545
  409. package/lib/__tests__/uninstall-skill.test.js +0 -189
  410. package/lib/__tests__/uninstall.test.js +0 -717
  411. package/lib/__tests__/update-hooks.test.js +0 -737
  412. package/lib/__tests__/update-skill-flags.test.js +0 -78
  413. package/lib/__tests__/update-skill.test.js +0 -644
  414. package/lib/__tests__/upgrade-exec.test.js +0 -273
  415. package/lib/__tests__/upgrade-skill-sync.test.js +0 -65
  416. package/lib/__tests__/upgrade.test.js +0 -78
  417. package/lib/__tests__/windows-bash-probe.test.js +0 -123
  418. package/lib/check-alignment-runner.cjs +0 -97
  419. package/lib/coverage-total.sh +0 -92
  420. package/lib/layer-baseline.cjs +0 -94
  421. package/lib/mattpocock-license-verdict.json +0 -7
@@ -1,430 +0,0 @@
1
- /**
2
- * @test REQ-A-05 (#447) xp-gate arch subcommand
3
- * @intent `xp-gate arch` works again: the default path runs the PINNED local
4
- * @archlinter/cli with built-in rules (never `npx -y`), with baseline-ratchet
5
- * verdicts when .architecture-baseline.json exists (Gate 6 parity) and
6
- * zero-tolerance otherwise; `--use-config` is the opt-in legacy config path.
7
- * Anti-noop: the integration tests run the REAL archlint binary and prove a
8
- * planted high-severity violation flips the verdict to non-zero — an exit 0
9
- * is a real scan, not a hardcoded pass.
10
- * @covers AC-A-05-01, AC-A-05-02
11
- */
12
- const fs = require('node:fs');
13
- const os = require('node:os');
14
- const path = require('node:path');
15
- const { spawnSync } = require('node:child_process');
16
-
17
- const archModule = require('../arch.js');
18
- const {
19
- findProjectRoot,
20
- binEntryFromPackageDir,
21
- resolveArchlint,
22
- verdictFromScanJson,
23
- quoteForShell,
24
- stripExtendedPrefix,
25
- } = archModule.__internals;
26
-
27
- const REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..');
28
-
29
- // Verified against @archlinter/cli 0.16.0: a ~198-token duplicated block is
30
- // reported as a High-severity CodeClone (this repo's four High smells are all
31
- // large clones, token_count 112-149). Smaller clones only reach Medium, which
32
- // the high/critical blocking threshold deliberately ignores.
33
- const HIGH_CLONE_BLOCK = [
34
- 'function processAlphaRecords(records) {',
35
- ' const out = [];',
36
- ' for (const r of records) {',
37
- ' if (!r || typeof r !== "object") continue;',
38
- ' const score = (r.alpha || 0) * 2 + (r.beta || 0) * 3 + (r.gamma || 0) * 5;',
39
- ' const tier = score > 100 ? "platinum" : score > 50 ? "gold" : score > 20 ? "silver" : "bronze";',
40
- ' const weighted = score * (r.weight || 1) + (r.penalty || 0);',
41
- ' const bucket = weighted > 200 ? "A" : weighted > 120 ? "B" : weighted > 60 ? "C" : "D";',
42
- ' out.push({ id: r.id, score, weighted, tier, bucket, tags: (r.tags || []).map((t) => t.toLowerCase()) });',
43
- ' }',
44
- ' return out.sort((a, b) => b.weighted - a.weighted);',
45
- '}',
46
- '',
47
- 'function summarizeAlphaBuckets(rows) {',
48
- ' const acc = { A: 0, B: 0, C: 0, D: 0 };',
49
- ' for (const row of rows) {',
50
- ' acc[row.bucket] = (acc[row.bucket] || 0) + 1;',
51
- ' }',
52
- ' return { counts: acc, total: rows.length, average: rows.reduce((s, r) => s + r.weighted, 0) / (rows.length || 1) };',
53
- '}',
54
- '',
55
- ].join('\n');
56
-
57
- let sandbox;
58
-
59
- beforeEach(() => {
60
- sandbox = fs.mkdtempSync(path.join(os.tmpdir(), 'xpgate-arch-'));
61
- // A `.git` marker is load-bearing for RUNTIME, not just for findProjectRoot.
62
- // archlint locates its own project root by walking up from the scan target.
63
- // With no marker anywhere up the chain it settles on the user's home
64
- // directory and walks every one of its trees -- measured on this machine:
65
- // 97,423 ms for an EMPTY temp dir versus 208 ms once a `.git` exists here,
66
- // and `--no-git` does not help (git-history churn is not the cost). Without
67
- // this marker the file's ~20 real-archlint calls paid ~98 s each, which is
68
- // where arch.test.js's 2,146 s came from.
69
- fs.mkdirSync(path.join(sandbox, '.git'), { recursive: true });
70
- });
71
-
72
- afterEach(() => {
73
- fs.rmSync(sandbox, { recursive: true, force: true });
74
- });
75
-
76
- function writeCleanSandbox({ withConfig = false } = {}) {
77
- // Architecture config is REQUIRED before lib/arch.js will scan
78
- // (REQ-GATE6-CONFIG-PARITY, mirroring the hook), so every case that expects a
79
- // scan must declare one. Opt-in rather than unconditional: the --use-config
80
- // group runs `archlint init` and asserts the file appears, and pre-creating it
81
- // made init refuse to overwrite and exit non-zero (measured: that group went
82
- // from green to 1 failed | 34 passed when the config was written here always).
83
- if (withConfig) {
84
- fs.writeFileSync(
85
- path.join(sandbox, '.archlint.yaml'),
86
- ['rules:', ' code-clone:', ' severity: high', ' cyclic-dependency:', ' severity: high', ''].join(String.fromCharCode(10)),
87
- );
88
- }
89
- fs.mkdirSync(path.join(sandbox, 'src'), { recursive: true });
90
- fs.writeFileSync(path.join(sandbox, 'src', 'a.js'), 'module.exports = { a: 1 };\n');
91
- fs.writeFileSync(
92
- path.join(sandbox, 'src', 'b.js'),
93
- 'const { a } = require("./a");\nmodule.exports = { b: a + 1 };\n',
94
- );
95
- }
96
-
97
- function plantHighClone() {
98
- fs.mkdirSync(path.join(sandbox, 'src', 'domain'), { recursive: true });
99
- fs.mkdirSync(path.join(sandbox, 'src', 'infrastructure'), { recursive: true });
100
- fs.writeFileSync(path.join(sandbox, 'src', 'domain', 'user.js'), 'const u = 1;\n' + HIGH_CLONE_BLOCK);
101
- fs.writeFileSync(path.join(sandbox, 'src', 'infrastructure', 'db.js'), 'const d = 2;\n' + HIGH_CLONE_BLOCK);
102
- }
103
-
104
- /**
105
- * Run `arch(args)` in a child node process with cwd set to the sandbox.
106
- * Worker threads forbid process.chdir (ERR_WORKER_UNSUPPORTED_OPERATION), so
107
- * cwd-sensitive behavior is exercised the same way gate-runner.test.js does it:
108
- * a real child process whose exit code IS arch's return code.
109
- */
110
- function runArchInChild(cwd, args) {
111
- const archPath = path.join(__dirname, '..', 'arch.js');
112
- const script = [
113
- `const { arch } = require(${JSON.stringify(archPath)});`,
114
- `arch(${JSON.stringify(args)}).then((code) => process.exit(code));`,
115
- ].join('\n');
116
- const result = spawnSync(process.execPath, ['-e', script], {
117
- cwd,
118
- encoding: 'utf8',
119
- maxBuffer: 64 * 1024 * 1024,
120
- });
121
- return { status: result.status, stdout: result.stdout || '', stderr: result.stderr || '' };
122
- }
123
-
124
- /** Run the REAL pinned archlint (xp-gate's own dependency) inside a sandbox. */
125
- function runRealArchlint(args, cwd) {
126
- const resolved = resolveArchlint(sandbox);
127
- return spawnSync(process.execPath, [resolved.script, ...args], { cwd, encoding: 'utf8' });
128
- }
129
-
130
- describe('findProjectRoot', () => {
131
- it('walks up to the directory containing .git', () => {
132
- fs.mkdirSync(path.join(sandbox, '.git'), { recursive: true });
133
- const nested = path.join(sandbox, 'a', 'b', 'c');
134
- fs.mkdirSync(nested, { recursive: true });
135
- // The walk is purely lexical (dirname chain), so the sandbox path itself
136
- // comes back unchanged — no realpath normalization is applied.
137
- expect(findProjectRoot(nested)).toBe(sandbox);
138
- });
139
-
140
- it('falls back to the start directory when no .git marker exists', () => {
141
- // os.tmpdir() is outside any repository on CI and dev machines alike.
142
- expect(findProjectRoot(sandbox)).toBe(sandbox);
143
- });
144
- });
145
-
146
- describe('binEntryFromPackageDir', () => {
147
- function fakePackage(binValue, { writeEntry = true } = {}) {
148
- const pkgDir = path.join(sandbox, 'node_modules', '@archlinter', 'cli');
149
- fs.mkdirSync(pkgDir, { recursive: true });
150
- fs.writeFileSync(
151
- path.join(pkgDir, 'package.json'),
152
- JSON.stringify({ name: '@archlinter/cli', version: '0.16.0', bin: binValue }),
153
- );
154
- if (writeEntry) {
155
- const entryRel = typeof binValue === 'string' ? binValue : binValue.archlint;
156
- fs.mkdirSync(path.dirname(path.join(pkgDir, entryRel)), { recursive: true });
157
- fs.writeFileSync(path.join(pkgDir, entryRel), '// entry\n');
158
- }
159
- return pkgDir;
160
- }
161
-
162
- it('resolves the archlint JS entry from a bin map', () => {
163
- const pkgDir = fakePackage({ archlint: 'bin/archlint.js' });
164
- expect(binEntryFromPackageDir(pkgDir)).toBe(path.join(pkgDir, 'bin', 'archlint.js'));
165
- });
166
-
167
- it('supports the string form of bin', () => {
168
- const pkgDir = fakePackage('bin/archlint.js');
169
- expect(binEntryFromPackageDir(pkgDir)).toBe(path.join(pkgDir, 'bin', 'archlint.js'));
170
- });
171
-
172
- it('returns null when the package is not installed', () => {
173
- expect(binEntryFromPackageDir(path.join(sandbox, 'node_modules', '@archlinter', 'cli'))).toBeNull();
174
- });
175
-
176
- it('returns null when the bin entry file is missing on disk', () => {
177
- const pkgDir = fakePackage({ archlint: 'bin/archlint.js' }, { writeEntry: false });
178
- expect(binEntryFromPackageDir(pkgDir)).toBeNull();
179
- });
180
-
181
- it('returns null for a manifest without a usable bin', () => {
182
- const pkgDir = path.join(sandbox, 'node_modules', '@archlinter', 'cli');
183
- fs.mkdirSync(pkgDir, { recursive: true });
184
- fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify({ name: '@archlinter/cli' }));
185
- expect(binEntryFromPackageDir(pkgDir)).toBeNull();
186
- });
187
- });
188
-
189
- describe('resolveArchlint', () => {
190
- it('prefers xp-gate\'s own pinned dependency (never the registry latest)', () => {
191
- const resolved = resolveArchlint(sandbox);
192
- expect(resolved.kind).toBe('node-script');
193
- expect(fs.existsSync(resolved.script)).toBe(true);
194
- const pkgDir = path.dirname(path.dirname(resolved.script));
195
- const version = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8')).version;
196
- // Assert against the REPO'S OWN DECLARATION rather than a literal: the
197
- // invariant under test is "the pinned dependency wins over the registry",
198
- // and a hardcoded range turned a routine dependency bump into a red test
199
- // while saying nothing about that invariant.
200
- const declared = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf8'))
201
- .devDependencies['@archlinter/cli'];
202
- expect(version).toMatch(new RegExp(`^${declared.replace(/^[\^~]/, '').replace(/\./g, '\\.')}`));
203
- });
204
-
205
- it('falls back to the project\'s local node_modules when the own dependency is skipped', () => {
206
- const pkgDir = path.join(sandbox, 'node_modules', '@archlinter', 'cli');
207
- fs.mkdirSync(path.join(pkgDir, 'bin'), { recursive: true });
208
- fs.writeFileSync(
209
- path.join(pkgDir, 'package.json'),
210
- JSON.stringify({ name: '@archlinter/cli', version: '9.9.9', bin: { archlint: 'bin/archlint.js' } }),
211
- );
212
- fs.writeFileSync(path.join(pkgDir, 'bin', 'archlint.js'), '// entry\n');
213
- const resolved = resolveArchlint(sandbox, { includeOwnDependency: false });
214
- expect(resolved).toEqual({
215
- kind: 'node-script',
216
- script: path.join(pkgDir, 'bin', 'archlint.js'),
217
- source: 'project node_modules',
218
- });
219
- });
220
-
221
- it('falls back to PATH when no node_modules install is reachable', () => {
222
- const binDir = path.join(sandbox, 'fakebin');
223
- fs.mkdirSync(binDir, { recursive: true });
224
- const originalPath = process.env.PATH;
225
- try {
226
- if (process.platform === 'win32') {
227
- fs.writeFileSync(path.join(binDir, 'archlint.bat'), '@echo off\r\nexit /b 0\r\n');
228
- } else {
229
- const sh = path.join(binDir, 'archlint');
230
- fs.writeFileSync(sh, '#!/bin/sh\nexit 0\n');
231
- fs.chmodSync(sh, 0o755);
232
- }
233
- // Prepend so `where`/`which` themselves still resolve, but archlint
234
- // resolves to the fake first (PATH order).
235
- process.env.PATH = binDir + path.delimiter + originalPath;
236
- const resolved = resolveArchlint(sandbox, { includeOwnDependency: false });
237
- expect(resolved.kind).toBe('binary');
238
- expect(resolved.bin.toLowerCase()).toContain('archlint');
239
- } finally {
240
- process.env.PATH = originalPath;
241
- }
242
- });
243
-
244
- it('falls back to npx --no-install as the last resort (never npx -y)', () => {
245
- // System dirs only: the lookup binaries resolve, archlint does not.
246
- const systemDir =
247
- process.platform === 'win32'
248
- ? path.join(process.env.SystemRoot || 'C:\\Windows', 'System32')
249
- : '/usr/bin:/bin';
250
- const originalPath = process.env.PATH;
251
- try {
252
- process.env.PATH = systemDir;
253
- const resolved = resolveArchlint(sandbox, { includeOwnDependency: false });
254
- expect(resolved).toEqual({ kind: 'npx', source: 'npx --no-install (local only)' });
255
- } finally {
256
- process.env.PATH = originalPath;
257
- }
258
- });
259
- });
260
-
261
- describe('verdictFromScanJson', () => {
262
- const smell = (severity, type = 'SomeSmell') => ({ severity, type, files: ['src/x.js'] });
263
-
264
- it('counts high/critical as blocking and ignores medium/low', () => {
265
- const json = JSON.stringify({
266
- smells: [smell('High'), smell('critical'), smell('Medium'), smell('low'), smell('Medium')],
267
- });
268
- const verdict = verdictFromScanJson(json);
269
- expect(verdict.parseError).toBeNull();
270
- expect(verdict.total).toBe(5);
271
- expect(verdict.blocking).toBe(2);
272
- expect(verdict.blockingDetails).toHaveLength(2);
273
- });
274
-
275
- it('matches severity case-insensitively', () => {
276
- const json = JSON.stringify({ smells: [smell('HIGH'), smell('Critical')] });
277
- expect(verdictFromScanJson(json).blocking).toBe(2);
278
- });
279
-
280
- it('treats a missing smells array as schema drift — parseError, never a silent clean (FC-12)', () => {
281
- const verdict = verdictFromScanJson(JSON.stringify({ summary: {} }));
282
- expect(verdict.parseError).toBeTruthy();
283
- expect(verdict.total).toBe(0);
284
- expect(verdict.blocking).toBe(0);
285
- });
286
-
287
- it('accepts an explicitly empty smells array as a clean scan', () => {
288
- const verdict = verdictFromScanJson(JSON.stringify({ smells: [] }));
289
- expect(verdict.parseError).toBeNull();
290
- expect(verdict.total).toBe(0);
291
- expect(verdict.blocking).toBe(0);
292
- });
293
-
294
- it('reports unparseable output as an error (fail-closed, never "clean")', () => {
295
- const verdict = verdictFromScanJson('not json at all');
296
- expect(verdict.parseError).toBeTruthy();
297
- expect(verdict.blocking).toBe(0);
298
- });
299
-
300
- it('caps the blocking preview at 10 entries', () => {
301
- const json = JSON.stringify({ smells: Array.from({ length: 25 }, () => smell('High')) });
302
- const verdict = verdictFromScanJson(json);
303
- expect(verdict.blocking).toBe(25);
304
- expect(verdict.blockingDetails).toHaveLength(10);
305
- });
306
- });
307
-
308
- describe('quoteForShell', () => {
309
- it('leaves whitespace-free arguments untouched', () => {
310
- expect(quoteForShell('--fail-on')).toBe('--fail-on');
311
- });
312
-
313
- it('quotes arguments containing whitespace for cmd.exe', () => {
314
- expect(quoteForShell('C:\\my configs\\arch.yaml')).toBe('"C:\\my configs\\arch.yaml"');
315
- });
316
-
317
- it('doubles embedded quotes and wraps, so a quote cannot terminate the quoting early (FC-07)', () => {
318
- expect(quoteForShell('a"b.yaml')).toBe('"a""b.yaml"');
319
- expect(quoteForShell('C:\\my configs\\a"b.yaml')).toBe('"C:\\my configs\\a""b.yaml"');
320
- });
321
-
322
- it('wraps a quote-only argument even without whitespace', () => {
323
- expect(quoteForShell('a"b')).toBe('"a""b"');
324
- });
325
- });
326
-
327
- describe('stripExtendedPrefix', () => {
328
- it('strips the plain extended-length prefix', () => {
329
- expect(stripExtendedPrefix('\\\\?\\C:\\repo\\src\\x.js')).toBe('C:\\repo\\src\\x.js');
330
- });
331
-
332
- it('converts the UNC extended prefix to a plain share path (FC-13)', () => {
333
- expect(stripExtendedPrefix('\\\\?\\UNC\\server\\share\\x.js')).toBe('\\\\server\\share\\x.js');
334
- });
335
-
336
- it('leaves ordinary paths untouched', () => {
337
- expect(stripExtendedPrefix('/repo/src/x.js')).toBe('/repo/src/x.js');
338
- expect(stripExtendedPrefix('C:\\repo\\x.js')).toBe('C:\\repo\\x.js');
339
- });
340
- });
341
-
342
- describe('arch — real archlint integration (anti-noop)', () => {
343
- it('exits 0 on a clean sandbox (zero-tolerance mode, no baseline)', () => {
344
- writeCleanSandbox({ withConfig: true });
345
- const run = runArchInChild(sandbox, []);
346
- expect(run.status).toBe(0);
347
- expect(run.stdout).toContain('Zero-tolerance mode');
348
- expect(run.stdout).toContain('✅ arch: no high/critical architecture findings');
349
- }, 60000);
350
-
351
- it('BLOCKS a planted high-severity violation — exit 0 is a real scan, not a no-op', () => {
352
- writeCleanSandbox({ withConfig: true });
353
- plantHighClone();
354
- const run = runArchInChild(sandbox, []);
355
- expect(run.status).toBe(1);
356
- expect(run.stderr).toContain('BLOCKED');
357
- expect(run.stderr).toContain('CodeClone');
358
- }, 60000);
359
-
360
- it('baseline ratchet: snapshot of a clean tree then re-scan exits 0', () => {
361
- writeCleanSandbox({ withConfig: true });
362
- const snapshot = runRealArchlint(['snapshot', '-o', path.join(sandbox, '.architecture-baseline.json'), '-p', sandbox], sandbox);
363
- expect(snapshot.status).toBe(0);
364
- const run = runArchInChild(sandbox, []);
365
- expect(run.status).toBe(0);
366
- expect(run.stdout).toContain('Baseline ratchet mode');
367
- }, 120000);
368
-
369
- it('baseline ratchet: a NEW high finding against the baseline blocks', () => {
370
- writeCleanSandbox({ withConfig: true });
371
- const snapshot = runRealArchlint(['snapshot', '-o', path.join(sandbox, '.architecture-baseline.json'), '-p', sandbox], sandbox);
372
- expect(snapshot.status).toBe(0);
373
- plantHighClone();
374
- const run = runArchInChild(sandbox, []);
375
- expect(run.status).toBe(1);
376
- expect(run.stderr).toContain('BLOCKED');
377
- }, 120000);
378
-
379
- it('exits 0 on this repository (AC-A-05-01: baseline present, no new high findings)', () => {
380
- // Guarded: needs both the committed baseline and the pinned archlint,
381
- // i.e. a full dev/CI checkout (npm ci installs @archlinter/cli).
382
- const baseline = path.join(REPO_ROOT, '.architecture-baseline.json');
383
- if (!fs.existsSync(baseline) || !fs.existsSync(path.join(REPO_ROOT, 'node_modules', '@archlinter', 'cli'))) {
384
- return;
385
- }
386
- const run = runArchInChild(REPO_ROOT, []);
387
- expect(run.status).toBe(0);
388
- expect(run.stdout).toContain('Baseline ratchet mode');
389
- }, 180000);
390
- });
391
-
392
- describe('arch — opt-in config path (--use-config)', () => {
393
- it('passes a valid new-schema config through to archlint (exit 0)', () => {
394
- writeCleanSandbox();
395
- const init = runRealArchlint(['init', '--no-interactive'], sandbox);
396
- expect(init.status).toBe(0);
397
- expect(fs.existsSync(path.join(sandbox, '.archlint.yaml'))).toBe(true);
398
- const run = runArchInChild(sandbox, ['--use-config', '.archlint.yaml']);
399
- expect(run.status).toBe(0);
400
- }, 60000);
401
-
402
- it('accepts --config as a deprecated alias of --use-config', () => {
403
- writeCleanSandbox();
404
- runRealArchlint(['init', '--no-interactive'], sandbox);
405
- const run = runArchInChild(sandbox, ['--config', '.archlint.yaml']);
406
- expect(run.status).toBe(0);
407
- expect(run.stderr).toContain('deprecated');
408
- }, 60000);
409
-
410
- it("surfaces archlint's schema rejection for the repo's pre-0.16 architecture.yaml (no silent pass)", () => {
411
- const run = runArchInChild(REPO_ROOT, ['--use-config', 'architecture.yaml']);
412
- expect(run.status).not.toBe(0);
413
- }, 60000);
414
-
415
- it('rejects a missing config file before spawning archlint', () => {
416
- const run = runArchInChild(sandbox, ['--use-config', 'nope.yaml']);
417
- expect(run.status).toBe(1);
418
- expect(run.stderr).toContain('config file not found');
419
- });
420
-
421
- it('rejects --use-config without a value', () => {
422
- const run = runArchInChild(sandbox, ['--use-config']);
423
- expect(run.status).toBe(1);
424
- });
425
-
426
- it('rejects passing both --use-config and --config', () => {
427
- const run = runArchInChild(sandbox, ['--use-config', 'a.yaml', '--config', 'b.yaml']);
428
- expect(run.status).toBe(1);
429
- });
430
- });
@@ -1,99 +0,0 @@
1
- /**
2
- * @test REQ-668 `xp-gate audit assertions` 必须让存量断言债务可见
3
- * @intent Gate 5d 只检查 **diff 范围内** 的文件。这是有意的——全仓扫描每次提交都跑
4
- * 太慢——但它有个昂贵的副作用:存量债务会在 **无关改动** 时突然阻断,
5
- * 制造错误的因果归因。原作者改了 `writeReport()` 的错误处理,却被
6
- * `test-alignment.test.ts` 里 4 处既有的 `expect(true).toBe(true)` 拦下。
7
- *
8
- * 这个副作用最坏的后果不是那一次误阻断,而是它改变修复者的行为:归因噪音
9
- * 让人以为"先绕过再说",于是倾向加 `@assertion-justified` 而不是真修掉。
10
- * 一个让人更愿意豁免的门禁,比没有门禁更糟。
11
- *
12
- * 所以 `audit assertions` 的价值在于把"存量"变成可批处理的工作队列,
13
- * 而不是让人在无关提交里逐个撞见。
14
- * @covers AC-668-01, AC-668-02, AC-668-03
15
- */
16
- 'use strict';
17
-
18
- const { scanForAssertionDebt, summarizeDebt } = require('../assertion-debt');
19
-
20
- describe('xp-gate audit assertions (#668)', () => {
21
- it('AC-668-01: 列出全仓存量问题,按文件分组', () => {
22
- const results = scanForAssertionDebt({ cwd: process.cwd() });
23
- expect(Array.isArray(results)).toBe(true);
24
- // Grouped by file so a batch fixer can work one file at a time.
25
- for (const entry of results) {
26
- expect(typeof entry.file).toBe('string');
27
- expect(Array.isArray(entry.findings)).toBe(true);
28
- for (const f of entry.findings) {
29
- expect(typeof f.line).toBe('number');
30
- expect(['tautological', 'swallowed-error']).toContain(f.kind);
31
- expect(typeof f.text).toBe('string');
32
- }
33
- }
34
- });
35
-
36
- it('AC-668-02: 识别两类确定性 vacuous 形态', () => {
37
- // These are the two shapes Gate 5d blocks. Both are the ABSENCE of an assertion
38
- // wearing assertion syntax, which is why they are the ones worth a debt list.
39
- const fixture = [
40
- 'test("a", () => {',
41
- ' expect(true).toBe(true);',
42
- ' try { go(); } catch {}',
43
- '});',
44
- 'test("b", () => {',
45
- ' expect(x).toBe(1);',
46
- '});',
47
- ].join('\n');
48
- const findings = scanForAssertionDebt({ source: fixture, file: 'fixture.test.ts' });
49
- const flat = findings.flatMap((f) => f.findings);
50
- expect(flat.some((f) => f.kind === 'tautological')).toBe(true);
51
- expect(flat.some((f) => f.kind === 'swallowed-error')).toBe(true);
52
- // A real assertion must not be reported -- a debt list that flags `expect(x).toBe(1)`
53
- // is a list nobody finishes.
54
- const realLine = flat.find((f) => f.text.includes('expect(x).toBe(1)'));
55
- expect(realLine).toBeUndefined();
56
- });
57
-
58
- it('AC-668-03: 摘要给出可批次清零的数量,而非只是行数', () => {
59
- const fixture = ['expect(true).toBe(true);', 'expect(1).toBe(1);', 'try { x(); } catch {}'].join('\n');
60
- const results = scanForAssertionDebt({ source: fixture, file: 'a.test.ts' });
61
- const summary = summarizeDebt(results);
62
- expect(summary.files).toBe(1);
63
- expect(summary.total).toBe(3);
64
- // Two tautologies and one empty catch: the split matters because they are fixed
65
- // by different edits (rewrite the assertion vs. handle the error).
66
- expect(summary.byKind.tautological).toBe(2);
67
- expect(summary.byKind['swallowed-error']).toBe(1);
68
- });
69
- });
70
-
71
- /**
72
- * @test REQ-668 fixture 不能被当作存量债务
73
- * @intent 这条测试防的是一个**修债务反而删掉测试覆盖**的失败模式。
74
- *
75
- * 测试 Gate 5d 分类器的那批 .bats / .test.ts 文件必然包含
76
- * `'expect(true).toBe(true);'` —— 那是被校验的**输入**,不是断言。
77
- * 若它们被列进"去修掉"的清单,执行清单的人会删掉钉住分类器行为的字符串,
78
- * 于是债务清单本身成了覆盖率的破坏者。
79
- *
80
- * 反例同样重要:真正的裸断言 `expect(true).toBe(true);` 必须仍然被报出来。
81
- * 只做"少报"很容易,难的是**同时**不误报也不漏报。
82
- * @covers AC-668-04
83
- */
84
- describe('fixture 与真实断言的区分 (#668)', () => {
85
- it('AC-668-04: 带引号的 fixture 不报,裸断言照报', () => {
86
- const { classifyLine } = require('../assertion-debt');
87
- // Real code: must be reported.
88
- expect(classifyLine('expect(true).toBe(true);')).toBe('tautological');
89
- expect(classifyLine(' expect(1).toBe(1);')).toBe('tautological');
90
- expect(classifyLine('try { x(); } catch {}')).toBe('swallowed-error');
91
- // Fixture inputs: must not be reported.
92
- expect(classifyLine("' expect(true).toBe(true);',")).toBeNull();
93
- expect(classifyLine('const s = "expect(true).toBe(true)";')).toBeNull();
94
- // Neither is debt.
95
- expect(classifyLine('// expect(true).toBe(true);')).toBeNull();
96
- expect(classifyLine('expect(x).toBe(1);')).toBeNull();
97
- expect(classifyLine('expect(value).toBeTruthy();')).toBeNull();
98
- });
99
- });
@@ -1,117 +0,0 @@
1
- /**
2
- * @test REQ-673
3
- * @intent The four `xp-gate audit` subcommands used to require() a .ts file, which
4
- * Node cannot do, so every one of them died. This pins that they execute,
5
- * that --check still FAILS on a real anomaly (so "it runs" is not mistaken
6
- * for "it passes"), and that --ledger grades the file it was given.
7
- * @covers AC-673-01, AC-673-02, AC-673-03
8
- */
9
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
10
- import { spawnSync } from 'node:child_process';
11
- import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
12
- import { tmpdir } from 'node:os';
13
- import { join } from 'node:path';
14
- import { fileURLToPath } from 'node:url';
15
- import path from 'node:path';
16
-
17
- const HERE = path.dirname(fileURLToPath(import.meta.url));
18
- const CLI = path.resolve(HERE, '..', '..', 'bin', 'xp-gate.js');
19
- const REPO_ROOT = path.resolve(HERE, '..', '..', '..', '..');
20
-
21
- // The audit CLI builds a tsx child process on every call, so the first one pays
22
- // cold-start cost; the per-test timeout has to clear that.
23
- const TEST_TIMEOUT_MS = 200_000;
24
- const CLI_TIMEOUT_MS = 180_000;
25
- const SAMPLE_DURATION_MS = 1200;
26
-
27
- let dir: string;
28
-
29
- beforeAll(() => {
30
- dir = mkdtempSync(join(tmpdir(), 'xpg-audit-cli-'));
31
- });
32
- afterAll(() => {
33
- rmSync(dir, { recursive: true, force: true });
34
- });
35
-
36
- function runAudit(args: string[], cwd: string): ReturnType<typeof spawnSync> {
37
- try {
38
- return spawnSync(process.execPath, [CLI, 'audit', ...args], {
39
- cwd,
40
- encoding: 'utf8',
41
- timeout: CLI_TIMEOUT_MS,
42
- });
43
- } catch (err) {
44
- // A spawn failure (missing binary, EACCES) must surface as itself, not as a
45
- // mysterious "status was undefined" several assertions later.
46
- throw new Error(`failed to run audit ${args.join(' ')}: ${(err as Error).message}`);
47
- }
48
- }
49
-
50
- function ledgerWith(rows: object[]): string {
51
- const file = join(dir, `ledger-${Math.random().toString(36).slice(2)}.jsonl`);
52
- try {
53
- writeFileSync(file, rows.map((r) => JSON.stringify(r)).join('\n') + '\n');
54
- } catch (err) {
55
- throw new Error(`failed to write ledger ${file}: ${(err as Error).message}`);
56
- }
57
- return file;
58
- }
59
-
60
- const ATTRIBUTED = {
61
- timestamp: '2026-12-01T00:00:00.000Z',
62
- gate_id: 'gate-1',
63
- gate_name: 'code-quality',
64
- passed: true,
65
- issues_found: 0,
66
- duration_ms: SAMPLE_DURATION_MS,
67
- trigger: 'commit',
68
- commit_hash: 'abc123def456',
69
- };
70
-
71
- const UNATTRIBUTED = { ...ATTRIBUTED, commit_hash: '' };
72
-
73
- describe('xp-gate audit CLI', () => {
74
- it('AC-673-01: --check runs the TypeScript implementation instead of dying on require()', () => {
75
- const ledger = ledgerWith([ATTRIBUTED]);
76
- const r = runAudit(['--check', '--ledger', ledger], REPO_ROOT);
77
-
78
- // The failure this guards: Node cannot require() a .ts file, so the command
79
- // printed "require is not defined in ES module scope" and exited 1 no matter
80
- // what the ledger held. Assert the command produced a verdict at all.
81
- expect(r.stderr).not.toContain('require is not defined');
82
- expect(r.stdout).toContain('Audit health');
83
- expect(r.stdout).toContain('OK: no new audit anomalies.');
84
- expect(r.status).toBe(0);
85
- }, TEST_TIMEOUT_MS);
86
-
87
- it('AC-673-02: an unattributed commit still fails the check', () => {
88
- // Anti-vacuity for AC-673-01: proving the command runs must not be mistaken
89
- // for proving it passes. A blank commit_hash is the exact defect the check
90
- // exists to catch, so it has to exit non-zero.
91
- const ledger = ledgerWith([ATTRIBUTED, UNATTRIBUTED]);
92
- const r = runAudit(['--check', '--ledger', ledger], REPO_ROOT);
93
-
94
- expect(r.status).not.toBe(0);
95
- expect(r.stdout).toContain('missing commit : 1');
96
- expect(r.stderr).toContain('FAIL: 1 audit anomaly');
97
- }, TEST_TIMEOUT_MS);
98
-
99
- it('AC-673-03: --ledger grades the named file, not the cwd ledger', () => {
100
- // Run from a directory with no .xp-gate/ at all: without --ledger the check
101
- // would scan 0 entries and pass, which would make the flag look harmless
102
- // while testing nothing.
103
- const emptyCwd = mkdtempSync(join(dir, 'cwd-'));
104
- const ledger = ledgerWith([UNATTRIBUTED]);
105
- const r = runAudit(['--check', '--ledger', ledger], emptyCwd);
106
-
107
- expect(r.stdout).toContain('entries scanned : 1');
108
- expect(r.status).not.toBe(0);
109
- }, TEST_TIMEOUT_MS);
110
-
111
- it('AC-673-03: --ledger rejects a missing file instead of scanning nothing', () => {
112
- const r = runAudit(['--check', '--ledger', join(dir, 'does-not-exist.jsonl')], REPO_ROOT);
113
-
114
- expect(r.status).not.toBe(0);
115
- expect(r.stderr).toContain('--ledger file not found');
116
- }, TEST_TIMEOUT_MS);
117
- });