@dommaker/harness 2.0.0 → 3.0.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 (645) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +7 -7
  3. package/dist/agents/index.d.ts +1 -2
  4. package/dist/agents/index.d.ts.map +1 -1
  5. package/dist/agents/index.js.map +1 -1
  6. package/dist/agents/lifecycle.d.ts +2 -34
  7. package/dist/agents/lifecycle.d.ts.map +1 -1
  8. package/dist/agents/lifecycle.js +1 -100
  9. package/dist/agents/lifecycle.js.map +1 -1
  10. package/dist/agents/types.d.ts +1 -19
  11. package/dist/agents/types.d.ts.map +1 -1
  12. package/dist/{hooks → bootstrap}/bootstrap.d.ts +9 -3
  13. package/dist/bootstrap/bootstrap.d.ts.map +1 -0
  14. package/dist/{hooks → bootstrap}/bootstrap.js +26 -30
  15. package/dist/bootstrap/bootstrap.js.map +1 -0
  16. package/dist/{hooks → bootstrap}/index.d.ts +3 -2
  17. package/dist/bootstrap/index.d.ts.map +1 -0
  18. package/dist/{hooks → bootstrap}/index.js +3 -2
  19. package/dist/bootstrap/index.js.map +1 -0
  20. package/dist/cli/commands/acceptance.d.ts.map +1 -1
  21. package/dist/cli/commands/acceptance.js +1 -1
  22. package/dist/cli/commands/acceptance.js.map +1 -1
  23. package/dist/cli/commands/check.d.ts +1 -1
  24. package/dist/cli/commands/check.d.ts.map +1 -1
  25. package/dist/cli/commands/check.js +12 -5
  26. package/dist/cli/commands/check.js.map +1 -1
  27. package/dist/cli/commands/command.d.ts.map +1 -1
  28. package/dist/cli/commands/command.js +9 -5
  29. package/dist/cli/commands/command.js.map +1 -1
  30. package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
  31. package/dist/cli/commands/constraints-pack-proposal.js +11 -8
  32. package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
  33. package/dist/cli/commands/constraints-reactivate.d.ts +10 -2
  34. package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
  35. package/dist/cli/commands/constraints-reactivate.js +2 -6
  36. package/dist/cli/commands/constraints-reactivate.js.map +1 -1
  37. package/dist/cli/commands/constraints-retire.d.ts +23 -5
  38. package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
  39. package/dist/cli/commands/constraints-retire.js +17 -8
  40. package/dist/cli/commands/constraints-retire.js.map +1 -1
  41. package/dist/cli/commands/contract.d.ts.map +1 -1
  42. package/dist/cli/commands/contract.js +4 -6
  43. package/dist/cli/commands/contract.js.map +1 -1
  44. package/dist/cli/commands/definitions.d.ts +2 -73
  45. package/dist/cli/commands/definitions.d.ts.map +1 -1
  46. package/dist/cli/commands/definitions.js +2 -7
  47. package/dist/cli/commands/definitions.js.map +1 -1
  48. package/dist/cli/commands/failure.d.ts.map +1 -1
  49. package/dist/cli/commands/failure.js +5 -6
  50. package/dist/cli/commands/failure.js.map +1 -1
  51. package/dist/cli/commands/knowledge/health.d.ts +4 -2
  52. package/dist/cli/commands/knowledge/health.d.ts.map +1 -1
  53. package/dist/cli/commands/knowledge/health.js +25 -19
  54. package/dist/cli/commands/knowledge/health.js.map +1 -1
  55. package/dist/cli/commands/knowledge/import.d.ts +1 -1
  56. package/dist/cli/commands/knowledge/import.js +2 -2
  57. package/dist/cli/commands/knowledge/import.js.map +1 -1
  58. package/dist/cli/commands/knowledge/search.d.ts.map +1 -1
  59. package/dist/cli/commands/knowledge/search.js +1 -2
  60. package/dist/cli/commands/knowledge/search.js.map +1 -1
  61. package/dist/cli/commands/knowledge/store-access.d.ts +25 -0
  62. package/dist/cli/commands/knowledge/store-access.d.ts.map +1 -0
  63. package/dist/cli/commands/knowledge/store-access.js +69 -0
  64. package/dist/cli/commands/knowledge/store-access.js.map +1 -0
  65. package/dist/cli/commands/knowledge-view.d.ts +6 -18
  66. package/dist/cli/commands/knowledge-view.d.ts.map +1 -1
  67. package/dist/cli/commands/knowledge-view.js +10 -61
  68. package/dist/cli/commands/knowledge-view.js.map +1 -1
  69. package/dist/cli/commands/passes-gate.d.ts.map +1 -1
  70. package/dist/cli/commands/passes-gate.js +7 -6
  71. package/dist/cli/commands/passes-gate.js.map +1 -1
  72. package/dist/cli/commands/release.d.ts +1 -1
  73. package/dist/cli/commands/release.d.ts.map +1 -1
  74. package/dist/cli/commands/release.js +12 -18
  75. package/dist/cli/commands/release.js.map +1 -1
  76. package/dist/cli/commands/review.d.ts.map +1 -1
  77. package/dist/cli/commands/review.js +15 -4
  78. package/dist/cli/commands/review.js.map +1 -1
  79. package/dist/cli/commands/security.d.ts.map +1 -1
  80. package/dist/cli/commands/security.js +6 -0
  81. package/dist/cli/commands/security.js.map +1 -1
  82. package/dist/{core → cli/commands}/spec/validator.d.ts +9 -18
  83. package/dist/cli/commands/spec/validator.d.ts.map +1 -0
  84. package/dist/{core → cli/commands}/spec/validator.js +11 -42
  85. package/dist/cli/commands/spec/validator.js.map +1 -0
  86. package/dist/cli/commands/spec-baseline-check.d.ts +8 -41
  87. package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
  88. package/dist/cli/commands/spec-baseline-check.js +31 -238
  89. package/dist/cli/commands/spec-baseline-check.js.map +1 -1
  90. package/dist/cli/commands/spec.d.ts +1 -1
  91. package/dist/cli/commands/spec.d.ts.map +1 -1
  92. package/dist/cli/commands/spec.js +14 -11
  93. package/dist/cli/commands/spec.js.map +1 -1
  94. package/dist/cli/commands/status.d.ts +0 -2
  95. package/dist/cli/commands/status.d.ts.map +1 -1
  96. package/dist/cli/commands/status.js.map +1 -1
  97. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +1 -1
  98. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
  99. package/dist/cli/commands/sync-docs/capabilities-syncer.js +3 -9
  100. package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
  101. package/dist/cli/commands/sync-docs/compact.d.ts.map +1 -1
  102. package/dist/cli/commands/sync-docs/compact.js +15 -15
  103. package/dist/cli/commands/sync-docs/compact.js.map +1 -1
  104. package/dist/cli/commands/sync-docs/main-flow.d.ts +7 -23
  105. package/dist/cli/commands/sync-docs/main-flow.d.ts.map +1 -1
  106. package/dist/cli/commands/sync-docs/main-flow.js +27 -419
  107. package/dist/cli/commands/sync-docs/main-flow.js.map +1 -1
  108. package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
  109. package/dist/cli/commands/sync-docs/project-reader.js +2 -1
  110. package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
  111. package/dist/cli/commands/sync-docs/sync-output.d.ts +15 -0
  112. package/dist/cli/commands/sync-docs/sync-output.d.ts.map +1 -0
  113. package/dist/cli/commands/sync-docs/sync-output.js +217 -0
  114. package/dist/cli/commands/sync-docs/sync-output.js.map +1 -0
  115. package/dist/cli/commands/sync-docs/sync-state.d.ts +71 -0
  116. package/dist/cli/commands/sync-docs/sync-state.d.ts.map +1 -0
  117. package/dist/cli/commands/sync-docs/sync-state.js +274 -0
  118. package/dist/cli/commands/sync-docs/sync-state.js.map +1 -0
  119. package/dist/cli/commands/sync-docs/sync-writes.d.ts +12 -0
  120. package/dist/cli/commands/sync-docs/sync-writes.d.ts.map +1 -0
  121. package/dist/cli/commands/sync-docs/sync-writes.js +72 -0
  122. package/dist/cli/commands/sync-docs/sync-writes.js.map +1 -0
  123. package/dist/cli/commands/validate.d.ts +0 -2
  124. package/dist/cli/commands/validate.d.ts.map +1 -1
  125. package/dist/cli/commands/validate.js +13 -6
  126. package/dist/cli/commands/validate.js.map +1 -1
  127. package/dist/context/index.d.ts +1 -1
  128. package/dist/context/index.d.ts.map +1 -1
  129. package/dist/context/index.js.map +1 -1
  130. package/dist/context/session-manager.d.ts +0 -4
  131. package/dist/context/session-manager.d.ts.map +1 -1
  132. package/dist/context/session-manager.js +0 -36
  133. package/dist/context/session-manager.js.map +1 -1
  134. package/dist/context/types.d.ts +2 -24
  135. package/dist/context/types.d.ts.map +1 -1
  136. package/dist/context/types.js +2 -1
  137. package/dist/context/types.js.map +1 -1
  138. package/dist/core/app-constraints-loader.d.ts +1 -1
  139. package/dist/core/app-constraints-loader.d.ts.map +1 -1
  140. package/dist/core/app-constraints-loader.js +6 -23
  141. package/dist/core/app-constraints-loader.js.map +1 -1
  142. package/dist/core/constraint-lifecycle.d.ts +3 -8
  143. package/dist/core/constraint-lifecycle.d.ts.map +1 -1
  144. package/dist/core/constraint-lifecycle.js +26 -30
  145. package/dist/core/constraint-lifecycle.js.map +1 -1
  146. package/dist/core/constraints/check-cache.d.ts +4 -43
  147. package/dist/core/constraints/check-cache.d.ts.map +1 -1
  148. package/dist/core/constraints/check-cache.js +6 -51
  149. package/dist/core/constraints/check-cache.js.map +1 -1
  150. package/dist/core/constraints/checker.d.ts +0 -16
  151. package/dist/core/constraints/checker.d.ts.map +1 -1
  152. package/dist/core/constraints/checker.js +23 -64
  153. package/dist/core/constraints/checker.js.map +1 -1
  154. package/dist/core/constraints/checkers/capability-sync.js +3 -3
  155. package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
  156. package/dist/core/constraints/checkers/context-doc-sync.js +2 -2
  157. package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
  158. package/dist/core/constraints/checkers/docs-freshness.js +5 -5
  159. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  160. package/dist/core/constraints/checkers/index.d.ts +17 -3
  161. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  162. package/dist/core/constraints/checkers/index.js +22 -10
  163. package/dist/core/constraints/checkers/index.js.map +1 -1
  164. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
  165. package/dist/core/constraints/checkers/no-hardcoded-credentials.js +5 -34
  166. package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
  167. package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
  168. package/dist/core/constraints/checkers/no-test-simplification.js +11 -33
  169. package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
  170. package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -1
  171. package/dist/core/constraints/checkers/templated/exec.js +3 -8
  172. package/dist/core/constraints/checkers/templated/exec.js.map +1 -1
  173. package/dist/core/constraints/checkers/templated/regex-scan.d.ts.map +1 -1
  174. package/dist/core/constraints/checkers/templated/regex-scan.js +8 -26
  175. package/dist/core/constraints/checkers/templated/regex-scan.js.map +1 -1
  176. package/dist/core/constraints/checkers/types.d.ts +10 -33
  177. package/dist/core/constraints/checkers/types.d.ts.map +1 -1
  178. package/dist/core/constraints/checkers/types.js +6 -46
  179. package/dist/core/constraints/checkers/types.js.map +1 -1
  180. package/dist/core/constraints/context-builder.d.ts +8 -26
  181. package/dist/core/constraints/context-builder.d.ts.map +1 -1
  182. package/dist/core/constraints/context-builder.js +9 -81
  183. package/dist/core/constraints/context-builder.js.map +1 -1
  184. package/dist/core/constraints/definitions/{iron-laws.d.ts → errors.d.ts} +1 -2
  185. package/dist/core/constraints/definitions/errors.d.ts.map +1 -0
  186. package/dist/core/constraints/definitions/{iron-laws.js → errors.js} +1 -5
  187. package/dist/core/constraints/definitions/errors.js.map +1 -0
  188. package/dist/core/constraints/definitions/{guidelines.d.ts → warnings.d.ts} +1 -2
  189. package/dist/core/constraints/definitions/warnings.d.ts.map +1 -0
  190. package/dist/core/constraints/definitions/{guidelines.js → warnings.js} +1 -6
  191. package/dist/core/constraints/definitions/warnings.js.map +1 -0
  192. package/dist/core/constraints/definitions.d.ts +2 -1
  193. package/dist/core/constraints/definitions.d.ts.map +1 -1
  194. package/dist/core/constraints/definitions.js +6 -5
  195. package/dist/core/constraints/definitions.js.map +1 -1
  196. package/dist/core/constraints/doc-freshness/runner.d.ts +0 -9
  197. package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
  198. package/dist/core/constraints/doc-freshness/runner.js +0 -1
  199. package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
  200. package/dist/core/constraints/find-constraint.d.ts +14 -0
  201. package/dist/core/constraints/find-constraint.d.ts.map +1 -0
  202. package/dist/core/constraints/find-constraint.js +25 -0
  203. package/dist/core/constraints/find-constraint.js.map +1 -0
  204. package/dist/core/constraints/governance-accessors.d.ts +54 -0
  205. package/dist/core/constraints/governance-accessors.d.ts.map +1 -0
  206. package/dist/core/constraints/governance-accessors.js +62 -0
  207. package/dist/core/constraints/governance-accessors.js.map +1 -0
  208. package/dist/core/constraints/index.d.ts +4 -4
  209. package/dist/core/constraints/index.d.ts.map +1 -1
  210. package/dist/core/constraints/index.js +1 -4
  211. package/dist/core/constraints/index.js.map +1 -1
  212. package/dist/core/constraints/pack-proposal.d.ts.map +1 -1
  213. package/dist/core/constraints/pack-proposal.js +3 -14
  214. package/dist/core/constraints/pack-proposal.js.map +1 -1
  215. package/dist/core/constraints/run-env.d.ts +1 -13
  216. package/dist/core/constraints/run-env.d.ts.map +1 -1
  217. package/dist/core/constraints/run-env.js +2 -23
  218. package/dist/core/constraints/run-env.js.map +1 -1
  219. package/dist/core/constraints/triggers.d.ts +10 -6
  220. package/dist/core/constraints/triggers.d.ts.map +1 -1
  221. package/dist/core/constraints/triggers.js +11 -5
  222. package/dist/core/constraints/triggers.js.map +1 -1
  223. package/dist/core/constraints/usage-report.d.ts +0 -6
  224. package/dist/core/constraints/usage-report.d.ts.map +1 -1
  225. package/dist/core/constraints/usage-report.js +0 -9
  226. package/dist/core/constraints/usage-report.js.map +1 -1
  227. package/dist/core/index.d.ts +5 -4
  228. package/dist/core/index.d.ts.map +1 -1
  229. package/dist/core/index.js +7 -8
  230. package/dist/core/index.js.map +1 -1
  231. package/dist/core/project-config-loader.d.ts +5 -43
  232. package/dist/core/project-config-loader.d.ts.map +1 -1
  233. package/dist/core/project-config-loader.js +4 -49
  234. package/dist/core/project-config-loader.js.map +1 -1
  235. package/dist/core/spec/baseline-check.d.ts +54 -0
  236. package/dist/core/spec/baseline-check.d.ts.map +1 -0
  237. package/dist/core/spec/baseline-check.js +261 -0
  238. package/dist/core/spec/baseline-check.js.map +1 -0
  239. package/dist/core/validators/check-handlers/file.d.ts.map +1 -1
  240. package/dist/core/validators/check-handlers/file.js +49 -5
  241. package/dist/core/validators/check-handlers/file.js.map +1 -1
  242. package/dist/core/validators/checkpoint.d.ts +5 -13
  243. package/dist/core/validators/checkpoint.d.ts.map +1 -1
  244. package/dist/core/validators/checkpoint.js +53 -80
  245. package/dist/core/validators/checkpoint.js.map +1 -1
  246. package/dist/core/validators/cso.d.ts +1 -4
  247. package/dist/core/validators/cso.d.ts.map +1 -1
  248. package/dist/core/validators/cso.js +1 -9
  249. package/dist/core/validators/cso.js.map +1 -1
  250. package/dist/core/validators/passes-gate.d.ts +0 -4
  251. package/dist/core/validators/passes-gate.d.ts.map +1 -1
  252. package/dist/core/validators/passes-gate.js +0 -9
  253. package/dist/core/validators/passes-gate.js.map +1 -1
  254. package/dist/failure/classifier.d.ts +2 -21
  255. package/dist/failure/classifier.d.ts.map +1 -1
  256. package/dist/failure/classifier.js +7 -42
  257. package/dist/failure/classifier.js.map +1 -1
  258. package/dist/failure/error-types.d.ts +48 -0
  259. package/dist/failure/error-types.d.ts.map +1 -0
  260. package/dist/failure/error-types.js +122 -0
  261. package/dist/failure/error-types.js.map +1 -0
  262. package/dist/failure/index.d.ts +4 -3
  263. package/dist/failure/index.d.ts.map +1 -1
  264. package/dist/failure/index.js +8 -10
  265. package/dist/failure/index.js.map +1 -1
  266. package/dist/failure/recorder.d.ts +7 -27
  267. package/dist/failure/recorder.d.ts.map +1 -1
  268. package/dist/failure/recorder.js +11 -64
  269. package/dist/failure/recorder.js.map +1 -1
  270. package/dist/gates/acceptance.d.ts +7 -2
  271. package/dist/gates/acceptance.d.ts.map +1 -1
  272. package/dist/gates/acceptance.js +30 -36
  273. package/dist/gates/acceptance.js.map +1 -1
  274. package/dist/gates/command.d.ts +0 -16
  275. package/dist/gates/command.d.ts.map +1 -1
  276. package/dist/gates/command.js +0 -29
  277. package/dist/gates/command.js.map +1 -1
  278. package/dist/gates/contract.d.ts +0 -8
  279. package/dist/gates/contract.d.ts.map +1 -1
  280. package/dist/gates/contract.js +3 -17
  281. package/dist/gates/contract.js.map +1 -1
  282. package/dist/gates/definitions.d.ts +1 -1
  283. package/dist/gates/performance.d.ts +1 -15
  284. package/dist/gates/performance.d.ts.map +1 -1
  285. package/dist/gates/performance.js +0 -19
  286. package/dist/gates/performance.js.map +1 -1
  287. package/dist/gates/registry.d.ts.map +1 -1
  288. package/dist/gates/registry.js +2 -5
  289. package/dist/gates/registry.js.map +1 -1
  290. package/dist/gates/review.d.ts +1 -9
  291. package/dist/gates/review.d.ts.map +1 -1
  292. package/dist/gates/review.js +22 -19
  293. package/dist/gates/review.js.map +1 -1
  294. package/dist/gates/security.d.ts +2 -9
  295. package/dist/gates/security.d.ts.map +1 -1
  296. package/dist/gates/security.js +7 -35
  297. package/dist/gates/security.js.map +1 -1
  298. package/dist/index.d.ts +12 -12
  299. package/dist/index.d.ts.map +1 -1
  300. package/dist/index.js +5 -16
  301. package/dist/index.js.map +1 -1
  302. package/dist/knowledge/audit-rules.d.ts +2 -0
  303. package/dist/knowledge/audit-rules.d.ts.map +1 -1
  304. package/dist/knowledge/audit-rules.js +10 -7
  305. package/dist/knowledge/audit-rules.js.map +1 -1
  306. package/dist/knowledge/audit.d.ts.map +1 -1
  307. package/dist/knowledge/audit.js +3 -1
  308. package/dist/knowledge/audit.js.map +1 -1
  309. package/dist/knowledge/{import.d.ts → cold-start.d.ts} +2 -3
  310. package/dist/knowledge/cold-start.d.ts.map +1 -0
  311. package/dist/knowledge/{import.js → cold-start.js} +135 -182
  312. package/dist/knowledge/cold-start.js.map +1 -0
  313. package/dist/knowledge/index.d.ts +3 -5
  314. package/dist/knowledge/index.d.ts.map +1 -1
  315. package/dist/knowledge/index.js +3 -9
  316. package/dist/knowledge/index.js.map +1 -1
  317. package/dist/knowledge/ingest.d.ts +29 -1
  318. package/dist/knowledge/ingest.d.ts.map +1 -1
  319. package/dist/knowledge/ingest.js +97 -7
  320. package/dist/knowledge/ingest.js.map +1 -1
  321. package/dist/knowledge/lifecycle.d.ts +0 -5
  322. package/dist/knowledge/lifecycle.d.ts.map +1 -1
  323. package/dist/knowledge/lifecycle.js +12 -19
  324. package/dist/knowledge/lifecycle.js.map +1 -1
  325. package/dist/knowledge/query.js +1 -1
  326. package/dist/knowledge/query.js.map +1 -1
  327. package/dist/knowledge/store.d.ts +4 -7
  328. package/dist/knowledge/store.d.ts.map +1 -1
  329. package/dist/knowledge/store.js +9 -27
  330. package/dist/knowledge/store.js.map +1 -1
  331. package/dist/knowledge/types.d.ts +2 -36
  332. package/dist/knowledge/types.d.ts.map +1 -1
  333. package/dist/knowledge/types.js +2 -3
  334. package/dist/knowledge/types.js.map +1 -1
  335. package/dist/monitoring/analyzer-base.d.ts +1 -10
  336. package/dist/monitoring/analyzer-base.d.ts.map +1 -1
  337. package/dist/monitoring/analyzer-base.js +1 -58
  338. package/dist/monitoring/analyzer-base.js.map +1 -1
  339. package/dist/monitoring/trace-analyzer.d.ts +1 -52
  340. package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
  341. package/dist/monitoring/trace-analyzer.js +2 -131
  342. package/dist/monitoring/trace-analyzer.js.map +1 -1
  343. package/dist/monitoring/traces.d.ts +1 -14
  344. package/dist/monitoring/traces.d.ts.map +1 -1
  345. package/dist/monitoring/traces.js +3 -25
  346. package/dist/monitoring/traces.js.map +1 -1
  347. package/dist/types/command-definition.d.ts +81 -0
  348. package/dist/types/command-definition.d.ts.map +1 -0
  349. package/dist/types/command-definition.js +10 -0
  350. package/dist/types/command-definition.js.map +1 -0
  351. package/dist/types/constraint.d.ts +3 -24
  352. package/dist/types/constraint.d.ts.map +1 -1
  353. package/dist/types/constraint.js.map +1 -1
  354. package/dist/types/failure.d.ts +6 -39
  355. package/dist/types/failure.d.ts.map +1 -1
  356. package/dist/types/failure.js +6 -112
  357. package/dist/types/failure.js.map +1 -1
  358. package/dist/types/spec.d.ts +0 -4
  359. package/dist/types/spec.d.ts.map +1 -1
  360. package/dist/types/trace.d.ts +0 -4
  361. package/dist/types/trace.d.ts.map +1 -1
  362. package/dist/utils/clip.d.ts +8 -0
  363. package/dist/utils/clip.d.ts.map +1 -0
  364. package/dist/utils/clip.js +15 -0
  365. package/dist/utils/clip.js.map +1 -0
  366. package/dist/utils/diff-parse.d.ts +31 -0
  367. package/dist/utils/diff-parse.d.ts.map +1 -0
  368. package/dist/utils/diff-parse.js +72 -0
  369. package/dist/utils/diff-parse.js.map +1 -0
  370. package/dist/utils/guards.d.ts +6 -0
  371. package/dist/utils/guards.d.ts.map +1 -0
  372. package/dist/utils/guards.js +11 -0
  373. package/dist/utils/guards.js.map +1 -0
  374. package/dist/utils/jsonl.d.ts +0 -12
  375. package/dist/utils/jsonl.d.ts.map +1 -1
  376. package/dist/utils/jsonl.js +0 -12
  377. package/dist/utils/jsonl.js.map +1 -1
  378. package/dist/utils/log-rotate.d.ts +14 -0
  379. package/dist/utils/log-rotate.d.ts.map +1 -0
  380. package/dist/utils/log-rotate.js +74 -0
  381. package/dist/utils/log-rotate.js.map +1 -0
  382. package/dist/utils/numeric-flag.d.ts +10 -2
  383. package/dist/utils/numeric-flag.d.ts.map +1 -1
  384. package/dist/utils/numeric-flag.js +17 -2
  385. package/dist/utils/numeric-flag.js.map +1 -1
  386. package/dist/utils/package-json.d.ts +1 -1
  387. package/dist/utils/package-json.js +1 -1
  388. package/package.json +1 -1
  389. package/src/CONTEXT.md +9 -9
  390. package/src/__tests__/app-constraints-loader.test.ts +5 -7
  391. package/src/__tests__/checker-extra.test.ts +12 -80
  392. package/src/__tests__/checker-primitives-sdk.test.ts +3 -18
  393. package/src/__tests__/checker.test.ts +5 -7
  394. package/src/__tests__/checkpoint.test.ts +45 -59
  395. package/src/__tests__/context-files-resolution.test.ts +3 -2
  396. package/src/__tests__/contract-gate.test.ts +0 -32
  397. package/src/__tests__/cso-validator.test.ts +1 -9
  398. package/src/__tests__/effective-constraints.test.ts +1 -3
  399. package/src/__tests__/error-classifier.test.ts +1 -42
  400. package/src/__tests__/failure-recorder.test.ts +45 -114
  401. package/src/__tests__/iron-laws.test.ts +9 -16
  402. package/src/__tests__/layering.test.ts +3 -3
  403. package/src/__tests__/project-config-loader.test.ts +2 -1
  404. package/src/__tests__/public-exports.test.ts +4 -15
  405. package/src/__tests__/public-type-surface.test.ts +1 -22
  406. package/src/__tests__/public-value-surface.test.ts +0 -3
  407. package/src/__tests__/review-gate.test.ts +0 -17
  408. package/src/__tests__/security-gate.test.ts +0 -18
  409. package/src/__tests__/skip-semantics.test.ts +4 -7
  410. package/src/__tests__/trace-analyzer-extra.test.ts +13 -129
  411. package/src/__tests__/trace-analyzer.test.ts +7 -7
  412. package/src/__tests__/trace-collector.test.ts +0 -43
  413. package/src/__tests__/traces.test.ts +7 -39
  414. package/src/agents/CONTEXT.md +2 -4
  415. package/src/agents/__tests__/lifecycle.test.ts +4 -155
  416. package/src/agents/index.ts +0 -3
  417. package/src/agents/lifecycle.ts +1 -114
  418. package/src/agents/types.ts +1 -21
  419. package/src/{hooks → bootstrap}/CONTEXT.md +5 -5
  420. package/src/{hooks → bootstrap}/bootstrap.ts +32 -39
  421. package/src/{hooks → bootstrap}/index.ts +3 -2
  422. package/src/cli/commands/CONTEXT.md +11 -11
  423. package/src/cli/commands/__tests__/check-read-count.test.ts +4 -7
  424. package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -1
  425. package/src/cli/commands/__tests__/command-gate-dead-options.test.ts +7 -5
  426. package/src/cli/commands/__tests__/constraints-pack-proposal.test.ts +0 -1
  427. package/src/cli/commands/__tests__/constraints-report.test.ts +2 -2
  428. package/src/cli/commands/__tests__/contract.test.ts +11 -4
  429. package/src/cli/commands/__tests__/failure.test.ts +9 -9
  430. package/src/cli/commands/__tests__/knowledge-view.test.ts +28 -158
  431. package/src/cli/commands/__tests__/knowledge.test.ts +24 -4
  432. package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +2 -1
  433. package/src/cli/commands/__tests__/passes-gate.test.ts +5 -5
  434. package/src/cli/commands/__tests__/project-path-convention.test.ts +4 -21
  435. package/src/cli/commands/__tests__/registry.test.ts +2 -0
  436. package/src/cli/commands/__tests__/release.test.ts +1 -1
  437. package/src/cli/commands/__tests__/review.test.ts +20 -6
  438. package/src/cli/commands/__tests__/security.test.ts +14 -0
  439. package/src/cli/commands/__tests__/spec-baseline-read-count.test.ts +2 -2
  440. package/src/cli/commands/__tests__/spec.test.ts +33 -23
  441. package/src/cli/commands/__tests__/validate.test.ts +32 -15
  442. package/src/cli/commands/acceptance.ts +1 -1
  443. package/src/cli/commands/check.ts +12 -6
  444. package/src/cli/commands/command.ts +7 -6
  445. package/src/cli/commands/constraints-pack-proposal.ts +10 -8
  446. package/src/cli/commands/constraints-reactivate.ts +13 -9
  447. package/src/cli/commands/constraints-retire.ts +30 -10
  448. package/src/cli/commands/contract.ts +4 -6
  449. package/src/cli/commands/definitions.ts +12 -84
  450. package/src/cli/commands/failure.ts +7 -8
  451. package/src/cli/commands/knowledge/health.ts +25 -21
  452. package/src/cli/commands/knowledge/import.ts +1 -1
  453. package/src/cli/commands/knowledge/search.ts +2 -3
  454. package/src/cli/commands/knowledge/store-access.ts +40 -0
  455. package/src/cli/commands/knowledge-view.ts +8 -32
  456. package/src/cli/commands/passes-gate.ts +9 -8
  457. package/src/cli/commands/release.ts +12 -13
  458. package/src/cli/commands/review.ts +15 -4
  459. package/src/cli/commands/security.ts +7 -0
  460. package/src/{core → cli/commands}/spec/__tests__/validator.test.ts +15 -53
  461. package/src/{core → cli/commands}/spec/validator.ts +15 -54
  462. package/src/cli/commands/spec-baseline-check.ts +36 -313
  463. package/src/cli/commands/spec.ts +15 -11
  464. package/src/cli/commands/status.ts +0 -2
  465. package/src/cli/commands/sync-docs/capabilities-syncer.ts +4 -10
  466. package/src/cli/commands/sync-docs/compact.ts +12 -11
  467. package/src/cli/commands/sync-docs/main-flow.ts +32 -472
  468. package/src/cli/commands/sync-docs/project-reader.ts +2 -1
  469. package/src/cli/commands/sync-docs/sync-output.ts +218 -0
  470. package/src/cli/commands/sync-docs/sync-state.ts +327 -0
  471. package/src/cli/commands/sync-docs/sync-writes.ts +49 -0
  472. package/src/cli/commands/validate.ts +13 -8
  473. package/src/context/CONTEXT.md +2 -2
  474. package/src/context/__tests__/session-manager.test.ts +1 -59
  475. package/src/context/index.ts +0 -5
  476. package/src/context/session-manager.ts +0 -44
  477. package/src/context/types.ts +2 -37
  478. package/src/core/CONTEXT.md +9 -9
  479. package/src/core/app-constraints-loader.ts +5 -23
  480. package/src/core/constraint-lifecycle.ts +30 -39
  481. package/src/core/constraints/__tests__/check-cache.test.ts +2 -124
  482. package/src/core/constraints/__tests__/collect-constraints.test.ts +0 -6
  483. package/src/core/constraints/__tests__/run-env.test.ts +26 -114
  484. package/src/core/constraints/__tests__/triggers.test.ts +3 -2
  485. package/src/core/constraints/__tests__/usage-report.test.ts +3 -6
  486. package/src/core/constraints/check-cache.ts +4 -70
  487. package/src/core/constraints/checker.ts +25 -75
  488. package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +1 -0
  489. package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +0 -1
  490. package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +2 -0
  491. package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +1 -0
  492. package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -0
  493. package/src/core/constraints/checkers/__tests__/input-contract.test.ts +1 -25
  494. package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +3 -2
  495. package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +3 -0
  496. package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +1 -0
  497. package/src/core/constraints/checkers/__tests__/templated-checkers.test.ts +1 -0
  498. package/src/core/constraints/checkers/__tests__/templates-registry.test.ts +0 -2
  499. package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +1 -0
  500. package/src/core/constraints/checkers/capability-sync.ts +2 -2
  501. package/src/core/constraints/checkers/context-doc-sync.ts +1 -1
  502. package/src/core/constraints/checkers/docs-freshness.ts +1 -1
  503. package/src/core/constraints/checkers/index.ts +21 -8
  504. package/src/core/constraints/checkers/no-hardcoded-credentials.ts +5 -32
  505. package/src/core/constraints/checkers/no-test-simplification.ts +10 -32
  506. package/src/core/constraints/checkers/templated/exec.ts +1 -7
  507. package/src/core/constraints/checkers/templated/regex-scan.ts +6 -25
  508. package/src/core/constraints/checkers/types.ts +12 -65
  509. package/src/core/constraints/context-builder.ts +11 -85
  510. package/src/core/constraints/definitions/{iron-laws.ts → errors.ts} +0 -4
  511. package/src/core/constraints/definitions/{guidelines.ts → warnings.ts} +0 -5
  512. package/src/core/constraints/definitions.ts +4 -3
  513. package/src/core/constraints/doc-freshness/runner.ts +63 -70
  514. package/src/core/constraints/find-constraint.ts +24 -0
  515. package/src/core/constraints/governance-accessors.ts +74 -0
  516. package/src/core/constraints/index.ts +0 -5
  517. package/src/core/constraints/pack-proposal.ts +4 -15
  518. package/src/core/constraints/run-env.ts +1 -26
  519. package/src/core/constraints/triggers.ts +11 -6
  520. package/src/core/constraints/usage-report.ts +0 -9
  521. package/src/core/index.ts +5 -10
  522. package/src/core/project-config-loader.ts +5 -68
  523. package/src/core/spec/baseline-check.ts +300 -0
  524. package/src/core/validators/__tests__/http-retry-sleep.test.ts +1 -1
  525. package/src/core/validators/check-handlers/file.ts +48 -5
  526. package/src/core/validators/checkpoint.ts +52 -85
  527. package/src/core/validators/cso.ts +1 -12
  528. package/src/core/validators/passes-gate.ts +0 -10
  529. package/src/failure/CONTEXT.md +1 -1
  530. package/src/failure/__tests__/recorder.test.ts +2 -1
  531. package/src/failure/classifier.ts +2 -42
  532. package/src/failure/error-types.ts +122 -0
  533. package/src/failure/index.ts +9 -9
  534. package/src/failure/recorder.ts +12 -77
  535. package/src/gates/CONTEXT.md +2 -4
  536. package/src/gates/__tests__/command-single-predicate.test.ts +15 -60
  537. package/src/gates/__tests__/command.test.ts +0 -13
  538. package/src/gates/__tests__/gate-interface.test.ts +3 -5
  539. package/src/gates/__tests__/performance.test.ts +5 -51
  540. package/src/gates/__tests__/review.test.ts +27 -50
  541. package/src/gates/__tests__/security-default-scan.test.ts +6 -3
  542. package/src/gates/__tests__/security.test.ts +25 -44
  543. package/src/gates/acceptance.ts +31 -33
  544. package/src/gates/command.ts +0 -33
  545. package/src/gates/contract.ts +1 -18
  546. package/src/gates/definitions.ts +1 -1
  547. package/src/gates/performance.ts +0 -23
  548. package/src/gates/registry.ts +2 -4
  549. package/src/gates/review.ts +30 -21
  550. package/src/gates/security.ts +4 -44
  551. package/src/index.ts +3 -28
  552. package/src/knowledge/CONTEXT.md +14 -20
  553. package/src/knowledge/__tests__/audit.test.ts +1 -1
  554. package/src/knowledge/__tests__/import.test.ts +1 -1
  555. package/src/knowledge/__tests__/ingest-validate-entry.test.ts +235 -0
  556. package/src/knowledge/__tests__/ingest.test.ts +2 -3
  557. package/src/knowledge/__tests__/store.test.ts +2 -4
  558. package/src/knowledge/__tests__/tree-walker.test.ts +5 -13
  559. package/src/knowledge/audit-rules.ts +10 -6
  560. package/src/knowledge/audit.ts +3 -1
  561. package/src/knowledge/{import.ts → cold-start.ts} +148 -191
  562. package/src/knowledge/index.ts +2 -9
  563. package/src/knowledge/ingest.ts +110 -7
  564. package/src/knowledge/lifecycle.ts +11 -19
  565. package/src/knowledge/query.ts +1 -1
  566. package/src/knowledge/store.ts +12 -34
  567. package/src/knowledge/types.ts +2 -48
  568. package/src/monitoring/CONTEXT.md +3 -3
  569. package/src/monitoring/__tests__/skipped-lines-report.test.ts +3 -16
  570. package/src/monitoring/__tests__/traces.test.ts +1 -27
  571. package/src/monitoring/analyzer-base.ts +1 -28
  572. package/src/monitoring/trace-analyzer.ts +2 -161
  573. package/src/monitoring/traces.ts +3 -29
  574. package/src/types/command-definition.ts +85 -0
  575. package/src/types/constraint.ts +3 -32
  576. package/src/types/failure.ts +7 -113
  577. package/src/types/spec.ts +0 -4
  578. package/src/types/trace.ts +0 -6
  579. package/src/utils/__tests__/jsonl-skip-disposition.test.ts +4 -7
  580. package/src/utils/clip.ts +12 -0
  581. package/src/utils/diff-parse.ts +80 -0
  582. package/src/utils/guards.ts +8 -0
  583. package/src/utils/jsonl.ts +0 -30
  584. package/src/utils/log-rotate.ts +43 -0
  585. package/src/utils/numeric-flag.ts +24 -2
  586. package/src/utils/package-json.ts +1 -1
  587. package/dist/cli/commands/knowledge/migrate.d.ts +0 -21
  588. package/dist/cli/commands/knowledge/migrate.d.ts.map +0 -1
  589. package/dist/cli/commands/knowledge/migrate.js +0 -48
  590. package/dist/cli/commands/knowledge/migrate.js.map +0 -1
  591. package/dist/cli/commands/knowledge/sync-rag.d.ts +0 -19
  592. package/dist/cli/commands/knowledge/sync-rag.d.ts.map +0 -1
  593. package/dist/cli/commands/knowledge/sync-rag.js +0 -77
  594. package/dist/cli/commands/knowledge/sync-rag.js.map +0 -1
  595. package/dist/core/constraints/checkers/templates-registry.d.ts +0 -18
  596. package/dist/core/constraints/checkers/templates-registry.d.ts.map +0 -1
  597. package/dist/core/constraints/checkers/templates-registry.js +0 -25
  598. package/dist/core/constraints/checkers/templates-registry.js.map +0 -1
  599. package/dist/core/constraints/definitions/guidelines.d.ts.map +0 -1
  600. package/dist/core/constraints/definitions/guidelines.js.map +0 -1
  601. package/dist/core/constraints/definitions/iron-laws.d.ts.map +0 -1
  602. package/dist/core/constraints/definitions/iron-laws.js.map +0 -1
  603. package/dist/core/spec/validator.d.ts.map +0 -1
  604. package/dist/core/spec/validator.js.map +0 -1
  605. package/dist/gates/checker-gate.d.ts +0 -27
  606. package/dist/gates/checker-gate.d.ts.map +0 -1
  607. package/dist/gates/checker-gate.js +0 -52
  608. package/dist/gates/checker-gate.js.map +0 -1
  609. package/dist/hooks/bootstrap.d.ts.map +0 -1
  610. package/dist/hooks/bootstrap.js.map +0 -1
  611. package/dist/hooks/index.d.ts.map +0 -1
  612. package/dist/hooks/index.js.map +0 -1
  613. package/dist/knowledge/doctor.d.ts +0 -37
  614. package/dist/knowledge/doctor.d.ts.map +0 -1
  615. package/dist/knowledge/doctor.js +0 -81
  616. package/dist/knowledge/doctor.js.map +0 -1
  617. package/dist/knowledge/import.d.ts.map +0 -1
  618. package/dist/knowledge/import.js.map +0 -1
  619. package/dist/knowledge/lint.d.ts +0 -90
  620. package/dist/knowledge/lint.d.ts.map +0 -1
  621. package/dist/knowledge/lint.js +0 -412
  622. package/dist/knowledge/lint.js.map +0 -1
  623. package/dist/knowledge/migration.d.ts +0 -28
  624. package/dist/knowledge/migration.d.ts.map +0 -1
  625. package/dist/knowledge/migration.js +0 -105
  626. package/dist/knowledge/migration.js.map +0 -1
  627. package/dist/knowledge/reference-tracker.d.ts +0 -31
  628. package/dist/knowledge/reference-tracker.d.ts.map +0 -1
  629. package/dist/knowledge/reference-tracker.js +0 -122
  630. package/dist/knowledge/reference-tracker.js.map +0 -1
  631. package/src/__tests__/spec-validator.test.ts +0 -58
  632. package/src/cli/commands/knowledge/migrate.ts +0 -61
  633. package/src/cli/commands/knowledge/sync-rag.ts +0 -48
  634. package/src/core/constraints/checkers/templates-registry.ts +0 -24
  635. package/src/gates/__tests__/checker-gate.test.ts +0 -86
  636. package/src/gates/checker-gate.ts +0 -52
  637. package/src/knowledge/__tests__/doctor.test.ts +0 -300
  638. package/src/knowledge/__tests__/lint.test.ts +0 -536
  639. package/src/knowledge/__tests__/migration.test.ts +0 -185
  640. package/src/knowledge/__tests__/reference-tracker.test.ts +0 -169
  641. package/src/knowledge/doctor.ts +0 -103
  642. package/src/knowledge/lint.ts +0 -460
  643. package/src/knowledge/migration.ts +0 -82
  644. package/src/knowledge/reference-tracker.ts +0 -99
  645. /package/src/{hooks → bootstrap}/__tests__/bootstrap.test.ts +0 -0
@@ -297,68 +297,34 @@ export class ConstraintChecker {
297
297
  // context.operation 为主触发条件,extraTriggers 为次级推断(ADR-0001),任一命中即匹配
298
298
  const operations = [context.operation, ...(context.extraTriggers ?? [])];
299
299
 
300
- // 1. error 级: block 模式首个违规即抛;collect 模式全量收集
301
- // (ADR-0035:channel 非 gate 的条目不进入检查分发,两级循环同口径过滤)
302
- for (const constraint of Object.values(constraints).filter(c => c.severity === 'error' && isGateConstraint(c))) {
303
- if (!matchesTrigger(constraint, operations)) continue;
304
-
305
- const checkResult = await this.check(constraint, context, run, env);
306
- result.errors.push(checkResult);
307
- this.recordTrace(constraint, checkResult, context);
308
-
309
- if (!checkResult.satisfied) {
310
- result.passed = false;
311
- if (mode === 'block') {
312
- throw new ConstraintViolationError(checkResult);
300
+ // error 级先行(block 模式首个违规即抛),warning 级随后记警告——单循环按 severity
301
+ // 分桶(原两个同构循环合一,执行顺序不变)。
302
+ // (ADR-0035:channel 非 gate 的条目不进入检查分发,两级同口径过滤)
303
+ for (const severity of ['error', 'warning'] as const) {
304
+ const bucket = severity === 'error' ? result.errors : result.warnings;
305
+ for (const constraint of Object.values(constraints).filter(c => c.severity === severity && isGateConstraint(c))) {
306
+ if (!matchesTrigger(constraint, operations)) continue;
307
+
308
+ const checkResult = await this.check(constraint, context, run, env);
309
+ bucket.push(checkResult);
310
+ this.recordTrace(constraint, checkResult, context);
311
+
312
+ if (!checkResult.satisfied) {
313
+ if (severity === 'error') {
314
+ result.passed = false;
315
+ if (mode === 'block') {
316
+ throw new ConstraintViolationError(checkResult);
317
+ }
318
+ } else {
319
+ result.warningCount++;
320
+ }
313
321
  }
314
322
  }
315
323
  }
316
324
 
317
- // 2. warning 级: 记录警告
318
- for (const constraint of Object.values(constraints).filter(c => c.severity === 'warning' && isGateConstraint(c))) {
319
- if (!matchesTrigger(constraint, operations)) continue;
320
-
321
- const checkResult = await this.check(constraint, context, run, env);
322
- result.warnings.push(checkResult);
323
- this.recordTrace(constraint, checkResult, context);
324
-
325
- if (!checkResult.satisfied) {
326
- result.warningCount++;
327
- }
328
- }
329
-
330
325
  return result;
331
326
  }
332
327
 
333
- /**
334
- * 执行前检查(仅检查 severity='error' 的约束)
335
- *
336
- * @param context 约束上下文
337
- * @param customConfig 可选,per-request 自定义配置(避免多请求间的单例状态污染)
338
- * @param evidence 可选,本次检查共用的 git 证据 adapter(#87,同 checkConstraints)
339
- * @throws ConstraintViolationError 如果有 error 级违规
340
- */
341
- async beforeExecution(
342
- context: ConstraintContext,
343
- customConfig?: MergedConstraintsConfig | null,
344
- evidence?: GitEvidence
345
- ): Promise<void> {
346
- const projectPath = context.projectPath || process.cwd();
347
- const run = evidence ?? createGitEvidence(projectPath);
348
- // 独立 run 入口(ADR-0023):本函数内所有 checker 共用一枚观察面
349
- const env = createRunEnv(projectPath);
350
- const constraints = this.getConstraints(customConfig);
351
- const operations = [context.operation, ...(context.extraTriggers ?? [])];
352
-
353
- for (const constraint of Object.values(constraints).filter(c => c.severity === 'error' && isGateConstraint(c))) {
354
- if (!matchesTrigger(constraint, operations)) continue;
355
-
356
- const result = await this.check(constraint, context, run, env);
357
- if (!result.satisfied) {
358
- throw new ConstraintViolationError(result);
359
- }
360
- }
361
- }
362
328
  }
363
329
 
364
330
  // ========================================
@@ -381,13 +347,10 @@ export async function checkConstraint(
381
347
  const constraint = constraints[constraintId];
382
348
 
383
349
  if (!constraint) {
384
- return {
385
- id: constraintId,
386
- severity: 'warning',
387
- satisfied: false,
388
- message: `未知的约束: ${constraintId}`,
389
- checkedAt: new Date(),
390
- };
350
+ // 注册表闭环同款口径(ADR-0035):未知 id 是调用方 bug,抛错而非回假结果
351
+ throw new Error(
352
+ `[harness] 未知的约束: ${constraintId}(未在内置约束集与 customConfig 中注册)。`
353
+ );
391
354
  }
392
355
 
393
356
  return checker.check(constraint, context);
@@ -441,18 +404,5 @@ export async function collectConstraints(
441
404
  return result;
442
405
  }
443
406
 
444
- /**
445
- * 快捷函数:执行前检查
446
- *
447
- * @param context 约束上下文
448
- * @param customConfig 可选,per-request 自定义配置
449
- */
450
- export async function checkBeforeExecution(
451
- context: ConstraintContext,
452
- customConfig?: MergedConstraintsConfig | null
453
- ): Promise<void> {
454
- return ConstraintChecker.getInstance().beforeExecution(context, customConfig);
455
- }
456
-
457
407
  // 导出单例(未接线记录器:只评估约束,不写 trace;写 trace 由组合根自行 new)
458
408
  export const constraintChecker = ConstraintChecker.getInstance();
@@ -44,6 +44,7 @@ function makeEnv(
44
44
  stagedDiffNames: async () => staged.join('\n'),
45
45
  srcScan: (root: string) =>
46
46
  scan ? scan[root] ?? [] : collectSourceFiles(projectPath, [root]),
47
+ available: () => true,
47
48
  });
48
49
  }
49
50
 
@@ -22,7 +22,6 @@ import type { MergedConstraintsConfig } from '../../../../types/project-config';
22
22
 
23
23
  const CAPABILITY_SYNC: Constraint = {
24
24
  id: 'capability_sync',
25
- kind: 'check',
26
25
  severity: 'warning',
27
26
  rule: 'CODE CHANGES MUST UPDATE CAPABILITIES.MD',
28
27
  message: '核心模块变更必须同步功能清单',
@@ -49,6 +49,7 @@ describe('docs_freshness — FreshnessRunner 异常 → fail-open 但发声', ()
49
49
  stagedDiff: async () => '',
50
50
  stagedDiffNames: async () => '',
51
51
  srcScan: () => [],
52
+ available: () => true,
52
53
  });
53
54
 
54
55
  const outcome = normalizeCheckOutcome(await docsFreshness.evaluate(env));
@@ -72,6 +73,7 @@ describe('docs_freshness — FreshnessRunner 异常 → fail-open 但发声', ()
72
73
  const env = buildCheckEnv(context, {
73
74
  stagedDiff: async () => '',
74
75
  stagedDiffNames: async () => '',
76
+ available: () => true,
75
77
  srcScan: () => {
76
78
  throw new Error('scan boom');
77
79
  },
@@ -34,6 +34,7 @@ function makeEnv(projectPath: string): ReturnType<typeof buildCheckEnv> {
34
34
  stagedDiff: async () => '',
35
35
  stagedDiffNames: async () => '',
36
36
  srcScan: (root: string) => collectSourceFiles(projectPath, [root]),
37
+ available: () => true,
37
38
  });
38
39
  }
39
40
 
@@ -27,6 +27,7 @@ function makeEnv(projectPath: string): CheckEnv {
27
27
  stagedDiff: async () => '',
28
28
  stagedDiffNames: async () => '',
29
29
  srcScan: () => [],
30
+ evidenceAvailable: () => true,
30
31
  };
31
32
  }
32
33
 
@@ -2,7 +2,7 @@
2
2
  * 检查器输入契约测试(harness#182)
3
3
  *
4
4
  * 「检查器失效 ≠ 对象合规」的接缝锁定:
5
- * - findMissingInputs:checker 声明的 needs 与环境供给比对(缺证据 / flag 未接线)
5
+ * - findMissingInputs:checker 声明的 needs 与环境供给比对(缺证据)
6
6
  * - 编排层降级:git 取证失败 → 带原因的 skipped,不进入 evaluate(不再对空 diff 假 pass)
7
7
  * - skipReason 落 ConstraintResult 与 ExecutionTrace(可统计的失效信号)
8
8
  */
@@ -14,7 +14,6 @@ import {
14
14
  buildCheckEnv,
15
15
  findMissingInputs,
16
16
  normalizeCheckOutcome,
17
- type ConstraintCheck,
18
17
  } from '../types';
19
18
  import { noTestSimplification } from '../no-test-simplification';
20
19
  import type { Constraint, ConstraintContext } from '../../../../types/constraint';
@@ -23,7 +22,6 @@ import type { ExecutionTrace } from '../../../../types/trace';
23
22
 
24
23
  const NO_TEST_SIMPLIFICATION: Constraint = {
25
24
  id: 'no_test_simplification',
26
- kind: 'check',
27
25
  severity: 'error',
28
26
  rule: 'DO NOT DELETE TESTS',
29
27
  message: '禁止简化测试绕过困难',
@@ -52,28 +50,6 @@ describe('findMissingInputs — needs 与环境供给比对', () => {
52
50
  expect(missing).toEqual(['staged diff 不可得(git 取证失败或未接线)']);
53
51
  });
54
52
 
55
- it('contextFlags 为 undefined → 缺项点名标志', () => {
56
- const check: ConstraintCheck = {
57
- id: 'flag-check',
58
- needs: { contextFlags: ['hasFailingTest'] },
59
- evaluate: () => true,
60
- };
61
- expect(findMissingInputs(check, envOf(CONTEXT, {}))).toEqual([
62
- '证据标志 hasFailingTest 未接线',
63
- ]);
64
- expect(
65
- findMissingInputs(check, envOf({ ...CONTEXT, hasFailingTest: false }, {}))
66
- ).toEqual([]);
67
- });
68
-
69
- it('手写 env 未提供 evidenceAvailable → 按全部可得(旧形状兼容)', () => {
70
- const env = buildCheckEnv(CONTEXT, {
71
- stagedDiff: async () => '',
72
- stagedDiffNames: async () => '',
73
- srcScan: () => [],
74
- });
75
- expect(findMissingInputs(noTestSimplification, env)).toEqual([]);
76
- });
77
53
  });
78
54
 
79
55
  describe('normalizeCheckOutcome — CheckSkip 归一', () => {
@@ -200,10 +200,11 @@ describe('no_completion_without_verification(harness#183 证据源重构)',
200
200
  expect(result.satisfied).toBe(true);
201
201
  });
202
202
 
203
- it('flag 退役:不再声明 contextFlags 输入契约(证据判定在 checker 体内)', () => {
203
+ it('flag 退役:不声明任何上下文证据标志输入契约(证据判定在 checker 体内)', () => {
204
204
  const check = getConstraintCheck('no_completion_without_verification');
205
205
  expect(check).toBeDefined();
206
- expect(check!.needs?.contextFlags ?? []).not.toContain('hasVerificationEvidence');
206
+ // contextFlags 契约面已整体删除;checker 只声明 git 证据需求
207
+ expect(check!.needs?.evidence ?? []).toEqual([]);
207
208
  });
208
209
 
209
210
  it('端到端:PassesGate 真跑验证命令 → 证据落盘 → checker pass', async () => {
@@ -23,6 +23,7 @@ function makeEnv(stagedDiff: string): CheckEnv {
23
23
  stagedDiff: async () => stagedDiff,
24
24
  stagedDiffNames: async () => '',
25
25
  srcScan: () => [],
26
+ evidenceAvailable: () => true,
26
27
  };
27
28
  }
28
29
 
@@ -44,6 +45,7 @@ async function textHitsCredential(text: string): Promise<boolean> {
44
45
  stagedDiff: async () => '',
45
46
  stagedDiffNames: async () => '',
46
47
  srcScan: () => [],
48
+ evidenceAvailable: () => true,
47
49
  };
48
50
  return (await noHardcodedCredentials.evaluate(env)) !== true;
49
51
  }
@@ -209,6 +211,7 @@ describe('noHardcodedCredentials checker', () => {
209
211
  stagedDiff: async () => '',
210
212
  stagedDiffNames: async () => '',
211
213
  srcScan: () => [],
214
+ evidenceAvailable: () => true,
212
215
  };
213
216
  }
214
217
 
@@ -22,6 +22,7 @@ function evaluate(diff: string | (() => Promise<string>)) {
22
22
  stagedDiff,
23
23
  stagedDiffNames: async () => '',
24
24
  srcScan: () => [],
25
+ available: () => true,
25
26
  })
26
27
  );
27
28
  }
@@ -29,6 +29,7 @@ function makeEnv(
29
29
  stagedDiff: async () => opts.diff ?? '',
30
30
  stagedDiffNames: async () => (opts.changedFiles ?? []).join('\n'),
31
31
  srcScan: () => [],
32
+ available: () => true,
32
33
  });
33
34
  }
34
35
 
@@ -29,7 +29,6 @@ const fakeFactory: TemplatedCheckerFactory = {
29
29
  function appConstraint(overrides: Partial<Constraint> = {}): Constraint {
30
30
  return {
31
31
  id: 'app_fake',
32
- kind: 'check',
33
32
  rule: 'r',
34
33
  message: 'm',
35
34
  severity: 'warning',
@@ -55,7 +54,6 @@ describe('getConstraintCheck 两层分发', () => {
55
54
  it('内置约束对象按 id 查找(source 缺省 = builtin)', () => {
56
55
  const builtin: Constraint = {
57
56
  id: 'capability_sync',
58
- kind: 'check',
59
57
  rule: 'r',
60
58
  message: 'm',
61
59
  severity: 'warning',
@@ -58,6 +58,7 @@ function evalDocsFreshness(dir: string) {
58
58
  stagedDiff: async () => '',
59
59
  stagedDiffNames: async () => '',
60
60
  srcScan: (root: string) => collectSourceFiles(dir, [root]),
61
+ available: () => true,
61
62
  })
62
63
  );
63
64
  }
@@ -32,7 +32,7 @@
32
32
 
33
33
  import { existsSync } from 'fs';
34
34
  import { join } from 'path';
35
- import { getCapabilitiesMode } from '../../project-config-loader';
35
+ import { getCapabilitiesMode } from '../governance-accessors';
36
36
  import {
37
37
  collectPopulationFiles,
38
38
  isCoveredByEntries,
@@ -66,7 +66,7 @@ export const capabilitySync: ConstraintCheck = {
66
66
  // 增量维度的输入可得性(harness#182):git 取证失败时 stagedDiffNames 归空串不抛错,
67
67
  // uncoveredChanges 恒空 = Step 1 静默失效——放行路径必须带降级提示,不假「已核对」。
68
68
  // 不声明 needs 改走编排层 skip:全量扫描(Step 2)不依赖 git,非 git 项目照出漂移提示
69
- const diffNamesAvailable = env.evidenceAvailable?.('stagedDiffNames') ?? true;
69
+ const diffNamesAvailable = env.evidenceAvailable('stagedDiffNames');
70
70
  const degradedNote = diffNamesAvailable
71
71
  ? []
72
72
  : ['增量检查降级:staged 变更清单不可得(git 取证失败),本次未核对变更文件的文档登记'];
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { existsSync } from 'fs';
11
11
  import { join } from 'path';
12
- import { resolveContextFiles } from '../../project-config-loader';
12
+ import { resolveContextFiles } from '../governance-accessors';
13
13
  import { formatEvidence, type ConstraintCheck } from './types';
14
14
 
15
15
  export const contextDocSync: ConstraintCheck = {
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { existsSync } from 'fs';
11
11
  import { join } from 'path';
12
- import { getGovernanceConfig, resolveContextFiles } from '../../project-config-loader';
12
+ import { getGovernanceConfig, resolveContextFiles } from '../governance-accessors';
13
13
  import { FreshnessRunner, type FreshnessCheckResult } from '../doc-freshness/runner';
14
14
  import { collectPopulationFiles } from '../capabilities-reconcile';
15
15
  import { CAPABILITIES_FILE_REL } from '../run-env';
@@ -24,7 +24,8 @@ import { contextDocSync } from './context-doc-sync';
24
24
  import { docsFreshness } from './docs-freshness';
25
25
  import { noHardcodedCredentials } from './no-hardcoded-credentials';
26
26
  import { governancePresence } from './governance-presence';
27
- import { TEMPLATES } from './templates-registry';
27
+ import { regexScan, fileExists, execScript } from './templated';
28
+ import type { TemplatedCheckerFactory } from './types';
28
29
 
29
30
  const CHECKS: ConstraintCheck[] = [
30
31
  // severity='error'
@@ -44,15 +45,30 @@ const registry = new Map<string, ConstraintCheck>(CHECKS.map(c => [c.id, c]));
44
45
  // 模板注册表(ADR-0033,应用层约束用)
45
46
  // ========================================
46
47
 
47
- // TEMPLATES 住在 ./templates-registry(独立模块防值级循环,见该文件头注释);
48
- // 此处 re-export 供编排层与测试单口取数
49
- export { TEMPLATES } from './templates-registry';
48
+ /**
49
+ * 模板注册表(模板 id → 工厂);测试可注册替身模板,用后须注销。
50
+ *
51
+ * 闭环语义:模板 id 未注册即不可用——加载期由 app-constraints-loader 校验,
52
+ * 运行期由本模块 getConstraintCheck 抛错兜底。
53
+ *
54
+ * 首批模板:regex-scan(正则扫描)/ file-exists(文件存在性),块 3 子项 2;
55
+ * exec(外部命令执行协议,harness#181,ADR-0035 决策 3 exec 档)。
56
+ *
57
+ * 历史:曾独立成 ./templates-registry 防 loader↔checker 值级循环;governance 访问器族
58
+ * 下移 constraints/governance-accessors 后内置 checker 不再回头依赖 project-config-loader,
59
+ * 环已解开,注册表并回本桶(ADR-0040 Phase 3)。
60
+ */
61
+ export const TEMPLATES = new Map<string, TemplatedCheckerFactory>([
62
+ ['regex-scan', regexScan],
63
+ ['file-exists', fileExists],
64
+ ['exec', execScript],
65
+ ]);
50
66
 
51
67
  // ========================================
52
68
  // 注册表闭环校验(加载期)
53
69
  // ========================================
54
70
 
55
- const checkConstraints = getAllConstraints().filter(c => c.kind === 'check' && isGateConstraint(c));
71
+ const checkConstraints = getAllConstraints().filter(isGateConstraint);
56
72
 
57
73
  for (const c of checkConstraints) {
58
74
  if (!registry.has(c.id)) {
@@ -111,8 +127,6 @@ export {
111
127
  findMissingInputs,
112
128
  degradeForMissingInputs,
113
129
  formatEvidence,
114
- contextFlag,
115
- contextEvidenceFlag,
116
130
  } from './types';
117
131
  export type {
118
132
  ConstraintCheck,
@@ -123,7 +137,6 @@ export type {
123
137
  CheckSkip,
124
138
  CheckInputNeeds,
125
139
  CheckEvidenceInput,
126
- ContextEvidenceFlag,
127
140
  NormalizedOutcome,
128
141
  EvidenceProviders,
129
142
  } from './types';
@@ -20,6 +20,7 @@
20
20
  import { readFileSync } from 'fs';
21
21
  import { join } from 'path';
22
22
  import { formatEvidence, type CheckDetail, type ConstraintCheck } from './types';
23
+ import { parseUnifiedDiff } from '../../../utils/diff-parse';
23
24
 
24
25
  /** 私钥/令牌指纹模式(命中即违规,无例外) */
25
26
  const FINGERPRINT_PATTERNS: RegExp[] = [
@@ -126,39 +127,11 @@ interface AddedLine {
126
127
  text: string;
127
128
  }
128
129
 
129
- /** 从 unified diff 中取新增行:按 +++ b/<path> 归属文件,按 @@ +n @@ 推算新文件行号 */
130
+ /** 从 unified diff 中取新增行:文件归属与行号推算见 utils/diff-parse 正本 */
130
131
  function collectAddedLines(diff: string): AddedLine[] {
131
- const out: AddedLine[] = [];
132
- let file = '';
133
- let newLine = 0;
134
- for (const raw of diff.split('\n')) {
135
- if (raw.startsWith('diff --git')) {
136
- file = '';
137
- newLine = 0;
138
- continue;
139
- }
140
- if (raw.startsWith('+++ b/')) {
141
- file = raw.slice('+++ b/'.length);
142
- continue;
143
- }
144
- if (raw.startsWith('+++')) {
145
- file = '';
146
- continue;
147
- }
148
- if (raw.startsWith('@@')) {
149
- const m = raw.match(/@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
150
- newLine = m ? parseInt(m[1], 10) : 0;
151
- continue;
152
- }
153
- if (!file || newLine === 0) continue;
154
- if (raw.startsWith('+')) {
155
- out.push({ file, lineNo: newLine, text: raw.slice(1) });
156
- newLine++;
157
- } else if (!raw.startsWith('-') && !raw.startsWith('\\')) {
158
- newLine++;
159
- }
160
- }
161
- return out;
132
+ return parseUnifiedDiff(diff)
133
+ .filter(l => l.kind === 'added' && l.file !== '' && l.newLineNo !== 0)
134
+ .map(l => ({ file: l.file, lineNo: l.newLineNo, text: l.text }));
162
135
  }
163
136
 
164
137
  function failDetail(hits: Hit[]): CheckDetail {
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { formatEvidence, type CheckDetail, type ConstraintCheck } from './types';
20
+ import { parseUnifiedDiff } from '../../../utils/diff-parse';
20
21
 
21
22
  /** 测试文件判定:`.test.`/`.spec.` 后缀段或 `__tests__/` 目录段 */
22
23
  function isTestFile(path: string): boolean {
@@ -44,15 +45,13 @@ interface FileTally {
44
45
  const UNATTRIBUTED = '(无文件归属的 diff 行)';
45
46
 
46
47
  /**
47
- * 按文件归集 diff 增删行:`-`/`+` 行计入当前文件,文件头按 `--- a/`(删除
48
- * 文件时 `+++ /dev/null` 回落到它)与 `+++ b/` 归属;`\` 行(No newline)忽略。
48
+ * 按文件归集 diff 增删行:文件归属(含 `+++ /dev/null` 回落旧文件名)见
49
+ * utils/diff-parse 正本;无归属行挂兜底键(fail-closed 照判),`\` 行正本已忽略。
49
50
  */
50
51
  function tallyDiff(diff: string): Map<string, FileTally> {
51
52
  const tallies = new Map<string, FileTally>();
52
- let file = '';
53
- let oldName = '';
54
53
 
55
- const tally = (): FileTally => {
54
+ const tally = (file: string): FileTally => {
56
55
  const key = file || UNATTRIBUTED;
57
56
  let t = tallies.get(key);
58
57
  if (!t) {
@@ -62,34 +61,13 @@ function tallyDiff(diff: string): Map<string, FileTally> {
62
61
  return t;
63
62
  };
64
63
 
65
- for (const raw of diff.split('\n')) {
66
- if (raw.startsWith('diff --git')) {
67
- file = '';
68
- oldName = '';
69
- continue;
70
- }
71
- if (raw.startsWith('--- a/')) {
72
- oldName = raw.slice('--- a/'.length);
73
- continue;
74
- }
75
- if (raw.startsWith('+++ b/')) {
76
- file = raw.slice('+++ b/'.length);
77
- continue;
78
- }
79
- if (raw.startsWith('+++')) {
80
- // 整文件删除(+++ /dev/null):归属到被删文件,删测试文件 = 净删除
81
- file = oldName;
82
- continue;
83
- }
84
- const added = raw.startsWith('+');
85
- const deleted = raw.startsWith('-');
86
- if (!added && !deleted) continue;
87
- const text = raw.slice(1);
88
- const t = tally();
89
- if (added && SKIP_ONLY_PATTERN.test(text)) t.skipOnlyLines.push(text.trim());
64
+ for (const line of parseUnifiedDiff(diff)) {
65
+ if (line.kind === 'context') continue;
66
+ const t = tally(line.file);
67
+ if (line.kind === 'added' && SKIP_ONLY_PATTERN.test(line.text)) t.skipOnlyLines.push(line.text.trim());
90
68
  NET_DELETE_CATEGORIES.forEach((cat, i) => {
91
- if (!cat.pattern.test(text)) return;
92
- if (deleted) t.counts[i].deleted++;
69
+ if (!cat.pattern.test(line.text)) return;
70
+ if (line.kind === 'deleted') t.counts[i].deleted++;
93
71
  else t.counts[i].added++;
94
72
  });
95
73
  }
@@ -22,13 +22,12 @@ import {
22
22
  type ConstraintCheck,
23
23
  type TemplatedCheckerFactory,
24
24
  } from '../types';
25
+ import { clip } from '../../../../utils/clip';
25
26
 
26
27
  const DEFAULT_TIMEOUT_MS = 30_000;
27
28
  const MAX_TIMEOUT_MS = 600_000;
28
29
  /** stdout/stderr 各自保留的字符上限(超出只记截断标记,不拖垮证据面与 trace) */
29
30
  const MAX_STREAM_CHARS = 8_192;
30
- /** 证据行单行长度上限(与 regex-scan 同口径) */
31
- const MAX_LINE = 120;
32
31
 
33
32
  interface CommandResult {
34
33
  code: number | null;
@@ -85,11 +84,6 @@ function runCommand(command: string, cwd: string, timeoutMs: number): Promise<Co
85
84
  });
86
85
  }
87
86
 
88
- function clip(line: string): string {
89
- const t = line.trim();
90
- return t.length > MAX_LINE ? `${t.slice(0, MAX_LINE)}…` : t;
91
- }
92
-
93
87
  /** 失败原因一行话(自描述,进证据首行) */
94
88
  function failureReason(command: string, result: CommandResult, timeoutMs: number): string {
95
89
  if (result.spawnError) return `命令启动失败(${result.spawnError}):${command}`;
@@ -15,33 +15,19 @@ import { readFileSync } from 'fs';
15
15
  import { join } from 'path';
16
16
  import { formatEvidence, type CheckDetail, type CheckEnv, type ConstraintCheck, type TemplatedCheckerFactory } from '../types';
17
17
  import { matchGlob } from './glob';
18
-
19
- /** 证据行单行长度上限(命中行可能是整行配置/长文本) */
20
- const MAX_LINE = 120;
18
+ import { parseUnifiedDiff } from '../../../../utils/diff-parse';
19
+ import { clip } from '../../../../utils/clip';
21
20
 
22
21
  interface AddedLine {
23
22
  file: string;
24
23
  line: string;
25
24
  }
26
25
 
27
- /** 从 unified diff 中取新增行(按 +++ b/<path> 归属文件,glob 过滤文件集) */
26
+ /** 从 unified diff 中取新增行(文件归属见 utils/diff-parse 正本,glob 过滤文件集) */
28
27
  function collectAddedLines(diff: string, inScope: (file: string) => boolean): AddedLine[] {
29
- const out: AddedLine[] = [];
30
- let file = '';
31
- for (const raw of diff.split('\n')) {
32
- if (raw.startsWith('+++ b/')) {
33
- file = raw.slice('+++ b/'.length);
34
- continue;
35
- }
36
- if (raw.startsWith('+++') || raw.startsWith('diff --git')) {
37
- if (raw.startsWith('diff --git')) file = '';
38
- continue;
39
- }
40
- if (raw.startsWith('+') && file && inScope(file)) {
41
- out.push({ file, line: raw.slice(1) });
42
- }
43
- }
44
- return out;
28
+ return parseUnifiedDiff(diff)
29
+ .filter(l => l.kind === 'added' && l.file !== '' && inScope(l.file))
30
+ .map(l => ({ file: l.file, line: l.text }));
45
31
  }
46
32
 
47
33
  function hitEvidence(pattern: RegExp, hits: string[]): CheckDetail {
@@ -51,11 +37,6 @@ function hitEvidence(pattern: RegExp, hits: string[]): CheckDetail {
51
37
  };
52
38
  }
53
39
 
54
- function clip(line: string): string {
55
- const t = line.trim();
56
- return t.length > MAX_LINE ? `${t.slice(0, MAX_LINE)}…` : t;
57
- }
58
-
59
40
  export const regexScan: TemplatedCheckerFactory = {
60
41
  validateParams(params) {
61
42
  const errors: string[] = [];