@dommaker/harness 1.13.0 → 1.15.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 (357) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -2
  3. package/dist/cli/commands/check.js +3 -3
  4. package/dist/cli/commands/check.js.map +1 -1
  5. package/dist/cli/commands/constraints-disable.d.ts +48 -0
  6. package/dist/cli/commands/constraints-disable.d.ts.map +1 -0
  7. package/dist/cli/commands/constraints-disable.js +156 -0
  8. package/dist/cli/commands/constraints-disable.js.map +1 -0
  9. package/dist/cli/commands/constraints-pack-proposal.d.ts +1 -1
  10. package/dist/cli/commands/constraints-pack-proposal.js +1 -1
  11. package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
  12. package/dist/cli/commands/constraints-reactivate.js +4 -2
  13. package/dist/cli/commands/constraints-reactivate.js.map +1 -1
  14. package/dist/cli/commands/constraints-retire.d.ts +14 -4
  15. package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
  16. package/dist/cli/commands/constraints-retire.js +10 -6
  17. package/dist/cli/commands/constraints-retire.js.map +1 -1
  18. package/dist/cli/commands/constraints.d.ts +1 -1
  19. package/dist/cli/commands/constraints.js +1 -1
  20. package/dist/cli/commands/definitions.d.ts.map +1 -1
  21. package/dist/cli/commands/definitions.js +16 -1
  22. package/dist/cli/commands/definitions.js.map +1 -1
  23. package/dist/cli/commands/knowledge-view.d.ts +3 -3
  24. package/dist/cli/commands/knowledge-view.js +4 -4
  25. package/dist/cli/commands/knowledge-view.js.map +1 -1
  26. package/dist/cli/commands/release.d.ts +2 -2
  27. package/dist/cli/commands/release.js +2 -2
  28. package/dist/cli/commands/sync-docs/agents-syncer.js +2 -4
  29. package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
  30. package/dist/cli/commands/sync-docs/head-gate.d.ts +34 -0
  31. package/dist/cli/commands/sync-docs/head-gate.d.ts.map +1 -0
  32. package/dist/cli/commands/sync-docs/head-gate.js +86 -0
  33. package/dist/cli/commands/sync-docs/head-gate.js.map +1 -0
  34. package/dist/cli/commands/sync-docs/index.d.ts +7 -0
  35. package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
  36. package/dist/cli/commands/sync-docs/index.js +51 -1
  37. package/dist/cli/commands/sync-docs/index.js.map +1 -1
  38. package/dist/completion-checkers/contract-presence.d.ts +1 -1
  39. package/dist/completion-checkers/contract-presence.js +1 -1
  40. package/dist/core/app-constraints-loader.d.ts +5 -3
  41. package/dist/core/app-constraints-loader.d.ts.map +1 -1
  42. package/dist/core/app-constraints-loader.js +20 -7
  43. package/dist/core/app-constraints-loader.js.map +1 -1
  44. package/dist/core/constraints/capabilities-parser.js +1 -1
  45. package/dist/core/constraints/check-cache.d.ts +1 -1
  46. package/dist/core/constraints/check-cache.js +1 -1
  47. package/dist/core/constraints/checker.d.ts +5 -3
  48. package/dist/core/constraints/checker.d.ts.map +1 -1
  49. package/dist/core/constraints/checker.js +31 -10
  50. package/dist/core/constraints/checker.js.map +1 -1
  51. package/dist/core/constraints/checkers/capability-sync.d.ts +1 -1
  52. package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
  53. package/dist/core/constraints/checkers/capability-sync.js +22 -9
  54. package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
  55. package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
  56. package/dist/core/constraints/checkers/context-doc-sync.js +7 -1
  57. package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
  58. package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
  59. package/dist/core/constraints/checkers/docs-freshness.js +41 -26
  60. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  61. package/dist/core/constraints/checkers/governance-presence.d.ts +4 -1
  62. package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
  63. package/dist/core/constraints/checkers/governance-presence.js +8 -11
  64. package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
  65. package/dist/core/constraints/checkers/index.d.ts +6 -6
  66. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  67. package/dist/core/constraints/checkers/index.js +16 -11
  68. package/dist/core/constraints/checkers/index.js.map +1 -1
  69. package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +34 -0
  70. package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -0
  71. package/dist/core/constraints/checkers/no-completion-without-verification.js +157 -0
  72. package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -0
  73. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +14 -4
  74. package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
  75. package/dist/core/constraints/checkers/no-hardcoded-credentials.js +134 -30
  76. package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
  77. package/dist/core/constraints/checkers/no-test-simplification.d.ts +16 -2
  78. package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
  79. package/dist/core/constraints/checkers/no-test-simplification.js +115 -15
  80. package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
  81. package/dist/core/constraints/checkers/templated/exec.d.ts +19 -0
  82. package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -0
  83. package/dist/core/constraints/checkers/templated/exec.js +124 -0
  84. package/dist/core/constraints/checkers/templated/exec.js.map +1 -0
  85. package/dist/core/constraints/checkers/templated/index.d.ts +1 -0
  86. package/dist/core/constraints/checkers/templated/index.d.ts.map +1 -1
  87. package/dist/core/constraints/checkers/templated/index.js +3 -1
  88. package/dist/core/constraints/checkers/templated/index.js.map +1 -1
  89. package/dist/core/constraints/checkers/templates-registry.d.ts +2 -1
  90. package/dist/core/constraints/checkers/templates-registry.d.ts.map +1 -1
  91. package/dist/core/constraints/checkers/templates-registry.js +3 -1
  92. package/dist/core/constraints/checkers/templates-registry.js.map +1 -1
  93. package/dist/core/constraints/checkers/types.d.ts +68 -7
  94. package/dist/core/constraints/checkers/types.d.ts.map +1 -1
  95. package/dist/core/constraints/checkers/types.js +52 -7
  96. package/dist/core/constraints/checkers/types.js.map +1 -1
  97. package/dist/core/constraints/context-builder.d.ts.map +1 -1
  98. package/dist/core/constraints/context-builder.js +0 -17
  99. package/dist/core/constraints/context-builder.js.map +1 -1
  100. package/dist/core/constraints/definitions/guidelines.d.ts +1 -0
  101. package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
  102. package/dist/core/constraints/definitions/guidelines.js +5 -1
  103. package/dist/core/constraints/definitions/guidelines.js.map +1 -1
  104. package/dist/core/constraints/definitions/iron-laws.d.ts +1 -0
  105. package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
  106. package/dist/core/constraints/definitions/iron-laws.js +8 -3
  107. package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
  108. package/dist/core/constraints/definitions.d.ts +8 -1
  109. package/dist/core/constraints/definitions.d.ts.map +1 -1
  110. package/dist/core/constraints/definitions.js +11 -1
  111. package/dist/core/constraints/definitions.js.map +1 -1
  112. package/dist/core/constraints/git-evidence.d.ts +10 -0
  113. package/dist/core/constraints/git-evidence.d.ts.map +1 -1
  114. package/dist/core/constraints/git-evidence.js +2 -0
  115. package/dist/core/constraints/git-evidence.js.map +1 -1
  116. package/dist/core/constraints/index.d.ts +3 -1
  117. package/dist/core/constraints/index.d.ts.map +1 -1
  118. package/dist/core/constraints/index.js +8 -1
  119. package/dist/core/constraints/index.js.map +1 -1
  120. package/dist/core/constraints/run-env.d.ts +3 -2
  121. package/dist/core/constraints/run-env.d.ts.map +1 -1
  122. package/dist/core/constraints/run-env.js +5 -4
  123. package/dist/core/constraints/run-env.js.map +1 -1
  124. package/dist/core/constraints/usage-report.d.ts +0 -5
  125. package/dist/core/constraints/usage-report.d.ts.map +1 -1
  126. package/dist/core/constraints/usage-report.js +3 -12
  127. package/dist/core/constraints/usage-report.js.map +1 -1
  128. package/dist/core/effective-constraints.d.ts +1 -1
  129. package/dist/core/effective-constraints.js +1 -1
  130. package/dist/core/index.d.ts +2 -2
  131. package/dist/core/index.d.ts.map +1 -1
  132. package/dist/core/index.js +6 -1
  133. package/dist/core/index.js.map +1 -1
  134. package/dist/core/retired-constraints.d.ts +66 -0
  135. package/dist/core/retired-constraints.d.ts.map +1 -0
  136. package/dist/core/retired-constraints.js +52 -0
  137. package/dist/core/retired-constraints.js.map +1 -0
  138. package/dist/core/validators/checkpoint.d.ts +4 -2
  139. package/dist/core/validators/checkpoint.d.ts.map +1 -1
  140. package/dist/core/validators/checkpoint.js +4 -2
  141. package/dist/core/validators/checkpoint.js.map +1 -1
  142. package/dist/core/validators/passes-gate.d.ts +2 -2
  143. package/dist/core/validators/passes-gate.d.ts.map +1 -1
  144. package/dist/core/validators/passes-gate.js +4 -3
  145. package/dist/core/validators/passes-gate.js.map +1 -1
  146. package/dist/gates/checker-gate.d.ts +8 -4
  147. package/dist/gates/checker-gate.d.ts.map +1 -1
  148. package/dist/gates/checker-gate.js +13 -6
  149. package/dist/gates/checker-gate.js.map +1 -1
  150. package/dist/gates/index.d.ts +1 -1
  151. package/dist/gates/index.js +1 -1
  152. package/dist/index.d.ts +5 -1
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +18 -5
  155. package/dist/index.js.map +1 -1
  156. package/dist/knowledge/audit-scoring.js +1 -1
  157. package/dist/knowledge/audit-scoring.js.map +1 -1
  158. package/dist/monitoring/trace-analyzer.d.ts +2 -2
  159. package/dist/monitoring/trace-analyzer.js +2 -2
  160. package/dist/monitoring/traces.d.ts +1 -1
  161. package/dist/monitoring/traces.js +4 -4
  162. package/dist/monitoring/traces.js.map +1 -1
  163. package/dist/pretool-use-hook.d.ts +1 -1
  164. package/dist/pretool-use-hook.d.ts.map +1 -1
  165. package/dist/pretool-use-hook.js +5 -5
  166. package/dist/pretool-use-hook.js.map +1 -1
  167. package/dist/release/integrity.d.ts +4 -4
  168. package/dist/release/integrity.js +4 -4
  169. package/dist/test-setup/mkdtemp-cleanup.js +1 -1
  170. package/dist/tools/definitions/core/notification/notify.yml +0 -1
  171. package/dist/tools/definitions/ext/browser/browser-close.yml +0 -1
  172. package/dist/tools/definitions/ext/browser/browser-start.yml +0 -1
  173. package/dist/tools/definitions/std/evolution/implement.yml +0 -1
  174. package/dist/tools/definitions/std/evolution/prioritize.yml +0 -1
  175. package/dist/tools/definitions/std/evolution/report-gap.yml +0 -1
  176. package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
  177. package/dist/tools/definitions/std/governance/audit-task.yml +0 -1
  178. package/dist/tools/definitions/std/governance/cast-vote.yml +0 -1
  179. package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -1
  180. package/dist/tools/definitions/std/governance/define-stance.yml +0 -1
  181. package/dist/tools/definitions/std/governance/impeach.yml +0 -1
  182. package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -1
  183. package/dist/tools/definitions/std/governance/rollback.yml +0 -1
  184. package/dist/tools/definitions/std/governance/stance-review.yml +0 -1
  185. package/dist/tools/definitions/std/governance/track-effect.yml +0 -1
  186. package/dist/tools/definitions/std/governance/vote-tally.yml +0 -1
  187. package/dist/tools/definitions/std/planning/split-batch.yml +0 -1
  188. package/dist/tools/definitions/std/planning/split-tasks.yml +0 -1
  189. package/dist/types/constraint.d.ts +32 -9
  190. package/dist/types/constraint.d.ts.map +1 -1
  191. package/dist/types/constraint.js +6 -1
  192. package/dist/types/constraint.js.map +1 -1
  193. package/dist/types/passes-gate.d.ts +7 -0
  194. package/dist/types/passes-gate.d.ts.map +1 -1
  195. package/dist/types/passes-gate.js +8 -0
  196. package/dist/types/passes-gate.js.map +1 -1
  197. package/dist/types/trace.d.ts +7 -0
  198. package/dist/types/trace.d.ts.map +1 -1
  199. package/dist/utils/detect-source-roots.d.ts +1 -1
  200. package/dist/utils/detect-source-roots.d.ts.map +1 -1
  201. package/dist/utils/detect-source-roots.js +2 -21
  202. package/dist/utils/detect-source-roots.js.map +1 -1
  203. package/package.json +1 -2
  204. package/src/CONTEXT.md +3 -3
  205. package/src/__tests__/app-constraints-loader.test.ts +86 -3
  206. package/src/__tests__/checker-extra.test.ts +110 -11
  207. package/src/__tests__/checker-primitives-sdk.test.ts +70 -0
  208. package/src/__tests__/checker.test.ts +16 -14
  209. package/src/__tests__/detect-source-roots.test.ts +5 -4
  210. package/src/__tests__/exec-checker-full-chain.test.ts +118 -0
  211. package/src/__tests__/iron-laws.test.ts +13 -20
  212. package/src/__tests__/no-studio-references.test.ts +54 -0
  213. package/src/__tests__/passes-gate-check.test.ts +1 -1
  214. package/src/__tests__/pretool-use-hook.test.ts +2 -2
  215. package/src/__tests__/public-exports.test.ts +6 -0
  216. package/src/__tests__/public-type-surface.test.ts +24 -2
  217. package/src/__tests__/public-value-surface.test.ts +5 -0
  218. package/src/__tests__/retired-constraints.test.ts +99 -0
  219. package/src/__tests__/skip-semantics.test.ts +16 -33
  220. package/src/__tests__/usage-report-public-export.test.ts +3 -3
  221. package/src/cli/commands/CONTEXT.md +7 -6
  222. package/src/cli/commands/__tests__/check-read-count.test.ts +3 -0
  223. package/src/cli/commands/__tests__/check-skip-output.test.ts +4 -4
  224. package/src/cli/commands/__tests__/check.test.ts +35 -6
  225. package/src/cli/commands/__tests__/constraints-disable.test.ts +229 -0
  226. package/src/cli/commands/__tests__/constraints-report-json-flag.test.ts +1 -1
  227. package/src/cli/commands/__tests__/constraints-report.test.ts +4 -4
  228. package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +1 -1
  229. package/src/cli/commands/__tests__/knowledge.test.ts +3 -3
  230. package/src/cli/commands/__tests__/project-path-anchoring.test.ts +4 -1
  231. package/src/cli/commands/__tests__/project-path-convention.test.ts +1 -1
  232. package/src/cli/commands/__tests__/spec-baseline-index-cap.test.ts +1 -1
  233. package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -24
  234. package/src/cli/commands/__tests__/sync-docs-gate.test.ts +154 -0
  235. package/src/cli/commands/__tests__/sync-docs-table-layout.test.ts +1 -1
  236. package/src/cli/commands/__tests__/sync-docs.test.ts +3 -3
  237. package/src/cli/commands/check.ts +3 -3
  238. package/src/cli/commands/constraints-disable.ts +145 -0
  239. package/src/cli/commands/constraints-pack-proposal.ts +1 -1
  240. package/src/cli/commands/constraints-reactivate.ts +4 -2
  241. package/src/cli/commands/constraints-retire.ts +11 -8
  242. package/src/cli/commands/constraints.ts +1 -1
  243. package/src/cli/commands/definitions.ts +16 -1
  244. package/src/cli/commands/knowledge-view.ts +4 -4
  245. package/src/cli/commands/release.ts +2 -2
  246. package/src/cli/commands/sync-docs/agents-syncer.ts +2 -4
  247. package/src/cli/commands/sync-docs/head-gate.ts +87 -0
  248. package/src/cli/commands/sync-docs/index.ts +62 -1
  249. package/src/completion-checkers/contract-presence.ts +1 -1
  250. package/src/core/CONTEXT.md +9 -8
  251. package/src/core/app-constraints-loader.ts +23 -8
  252. package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +1 -1
  253. package/src/core/constraints/__tests__/check-cache.test.ts +1 -1
  254. package/src/core/constraints/__tests__/collect-constraints.test.ts +42 -18
  255. package/src/core/constraints/__tests__/git-evidence.test.ts +20 -0
  256. package/src/core/constraints/__tests__/run-env.test.ts +9 -7
  257. package/src/core/constraints/__tests__/trace-injection.test.ts +8 -2
  258. package/src/core/constraints/capabilities-parser.ts +1 -1
  259. package/src/core/constraints/check-cache.ts +1 -1
  260. package/src/core/constraints/checker.ts +35 -12
  261. package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +21 -3
  262. package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +20 -12
  263. package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +89 -0
  264. package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +4 -2
  265. package/src/core/constraints/checkers/__tests__/exec-checker.test.ts +99 -0
  266. package/src/core/constraints/checkers/__tests__/fixtures/public-repo-sanitization.mjs +40 -0
  267. package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +24 -3
  268. package/src/core/constraints/checkers/__tests__/input-contract.test.ts +135 -0
  269. package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +208 -0
  270. package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +127 -5
  271. package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +144 -21
  272. package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +6 -2
  273. package/src/core/constraints/checkers/capability-sync.ts +25 -11
  274. package/src/core/constraints/checkers/context-doc-sync.ts +8 -1
  275. package/src/core/constraints/checkers/docs-freshness.ts +44 -26
  276. package/src/core/constraints/checkers/governance-presence.ts +8 -9
  277. package/src/core/constraints/checkers/index.ts +23 -13
  278. package/src/core/constraints/checkers/no-completion-without-verification.ts +126 -0
  279. package/src/core/constraints/checkers/no-hardcoded-credentials.ts +153 -29
  280. package/src/core/constraints/checkers/no-test-simplification.ts +128 -17
  281. package/src/core/constraints/checkers/templated/exec.ts +138 -0
  282. package/src/core/constraints/checkers/templated/index.ts +1 -0
  283. package/src/core/constraints/checkers/templates-registry.ts +4 -2
  284. package/src/core/constraints/checkers/types.ts +107 -10
  285. package/src/core/constraints/context-builder.ts +0 -18
  286. package/src/core/constraints/definitions/guidelines.ts +5 -1
  287. package/src/core/constraints/definitions/iron-laws.ts +8 -3
  288. package/src/core/constraints/definitions.ts +11 -1
  289. package/src/core/constraints/doc-freshness/__tests__/runner.test.ts +3 -3
  290. package/src/core/constraints/git-evidence.ts +13 -0
  291. package/src/core/constraints/index.ts +22 -1
  292. package/src/core/constraints/run-env.ts +6 -5
  293. package/src/core/constraints/usage-report.ts +2 -12
  294. package/src/core/effective-constraints.ts +1 -1
  295. package/src/core/index.ts +16 -1
  296. package/src/core/retired-constraints.ts +77 -0
  297. package/src/core/validators/checkpoint.ts +4 -2
  298. package/src/core/validators/passes-gate.ts +4 -3
  299. package/src/gates/CONTEXT.md +3 -2
  300. package/src/gates/__tests__/checker-gate.test.ts +20 -3
  301. package/src/gates/checker-gate.ts +14 -7
  302. package/src/gates/index.ts +1 -1
  303. package/src/hooks/CONTEXT.md +2 -2
  304. package/src/index.ts +35 -3
  305. package/src/knowledge/CONTEXT.md +2 -2
  306. package/src/knowledge/__tests__/audit.test.ts +1 -1
  307. package/src/knowledge/__tests__/flywheel-metrics.test.ts +1 -1
  308. package/src/knowledge/audit-scoring.ts +1 -1
  309. package/src/monitoring/CONTEXT.md +2 -2
  310. package/src/monitoring/__tests__/skipped-lines-report.test.ts +2 -2
  311. package/src/monitoring/__tests__/traces.test.ts +1 -1
  312. package/src/monitoring/trace-analyzer.ts +2 -2
  313. package/src/monitoring/traces.ts +4 -4
  314. package/src/pretool-use-hook.ts +5 -5
  315. package/src/release/CONTEXT.md +3 -3
  316. package/src/release/integrity.ts +4 -4
  317. package/src/test-setup/__tests__/mkdtemp-cleanup.test.ts +1 -1
  318. package/src/test-setup/mkdtemp-cleanup.ts +1 -1
  319. package/src/tools/CONTEXT.md +3 -3
  320. package/src/tools/__tests__/registry.test.ts +3 -3
  321. package/src/tools/definitions/core/notification/notify.yml +0 -1
  322. package/src/tools/definitions/ext/browser/browser-close.yml +0 -1
  323. package/src/tools/definitions/ext/browser/browser-start.yml +0 -1
  324. package/src/tools/definitions/std/evolution/implement.yml +0 -1
  325. package/src/tools/definitions/std/evolution/prioritize.yml +0 -1
  326. package/src/tools/definitions/std/evolution/report-gap.yml +0 -1
  327. package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
  328. package/src/tools/definitions/std/governance/audit-task.yml +0 -1
  329. package/src/tools/definitions/std/governance/cast-vote.yml +0 -1
  330. package/src/tools/definitions/std/governance/create-voting-session.yml +0 -1
  331. package/src/tools/definitions/std/governance/define-stance.yml +0 -1
  332. package/src/tools/definitions/std/governance/impeach.yml +0 -1
  333. package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -1
  334. package/src/tools/definitions/std/governance/rollback.yml +0 -1
  335. package/src/tools/definitions/std/governance/stance-review.yml +0 -1
  336. package/src/tools/definitions/std/governance/track-effect.yml +0 -1
  337. package/src/tools/definitions/std/governance/vote-tally.yml +0 -1
  338. package/src/tools/definitions/std/planning/split-batch.yml +0 -1
  339. package/src/tools/definitions/std/planning/split-tasks.yml +0 -1
  340. package/src/types/constraint.ts +35 -10
  341. package/src/types/passes-gate.ts +8 -0
  342. package/src/types/trace.ts +8 -0
  343. package/src/utils/detect-source-roots.ts +2 -20
  344. package/bin/harness-knowledge-track.sh +0 -47
  345. package/bin/harness-sensitive-check.sh +0 -67
  346. package/dist/core/constraints/checkers/iron-flags.d.ts +0 -12
  347. package/dist/core/constraints/checkers/iron-flags.d.ts.map +0 -1
  348. package/dist/core/constraints/checkers/iron-flags.js +0 -16
  349. package/dist/core/constraints/checkers/iron-flags.js.map +0 -1
  350. package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +0 -30
  351. package/src/core/constraints/checkers/iron-flags.ts +0 -17
  352. package/templates/nextjs-app/.github/workflows/ci.yml +0 -39
  353. package/templates/node-api/.github/workflows/ci.yml +0 -36
  354. package/templates/node-api/package.json +0 -23
  355. package/templates/node-api/src/index.ts +0 -2
  356. package/templates/node-api/tsconfig.json +0 -19
  357. package/templates/python-api/.github/workflows/ci.yml +0 -39
@@ -42,10 +42,29 @@ describe('ConstraintChecker - 补充覆盖', () => {
42
42
  afterAll(() => {
43
43
  try {
44
44
  fs.rmSync(tempDir, { recursive: true, force: true });
45
+ for (const dir of evidenceFixtures) fs.rmSync(dir, { recursive: true, force: true });
45
46
  } catch {
46
47
  // ignore
47
48
  }
48
49
  });
50
+
51
+ /**
52
+ * 证据夹具(harness#183:验证证据 = .harness/evidence 落盘,不再是 context flag)
53
+ * projectWithEvidence = 有证据(新鲜度无所依即有证据即过);projectWithoutEvidence = 无证据
54
+ */
55
+ const evidenceFixtures: string[] = [];
56
+ function projectWithEvidence(): string {
57
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-evidence-'));
58
+ fs.mkdirSync(path.join(dir, '.harness', 'evidence'), { recursive: true });
59
+ fs.writeFileSync(path.join(dir, '.harness', 'evidence', 'test.log'), 'ok');
60
+ evidenceFixtures.push(dir);
61
+ return dir;
62
+ }
63
+ function projectWithoutEvidence(): string {
64
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-no-evidence-'));
65
+ evidenceFixtures.push(dir);
66
+ return dir;
67
+ }
49
68
  describe('findApplicableConstraints', () => {
50
69
  it('应该过滤出匹配 trigger 的约束', () => {
51
70
  const context: ConstraintContext = {
@@ -78,8 +97,9 @@ describe('ConstraintChecker - 补充覆盖', () => {
78
97
  it('通过检查不应该抛出异常', async () => {
79
98
  const context: ConstraintContext = {
80
99
  operation: 'code_implementation',
100
+ projectPath: projectWithEvidence(),
101
+ changedFiles: [],
81
102
  hasTest: true,
82
- hasVerificationEvidence: true,
83
103
  hasRequirement: true,
84
104
  taskDescription: 'Test task — single focused change',
85
105
  hasSingleTask: true,
@@ -92,8 +112,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
92
112
  it('违规应该抛出 ConstraintViolationError', async () => {
93
113
  const context: ConstraintContext = {
94
114
  operation: 'code_implementation',
115
+ projectPath: projectWithoutEvidence(),
95
116
  hasTest: false,
96
- hasVerificationEvidence: false,
97
117
  };
98
118
 
99
119
  await expect(checkBeforeExecution(context)).rejects.toThrow();
@@ -102,8 +122,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
102
122
  it('customConfig 应替换内置集(空配置不检查内置 error 级约束)', async () => {
103
123
  const context: ConstraintContext = {
104
124
  operation: 'code_implementation',
125
+ projectPath: projectWithoutEvidence(),
105
126
  hasTest: false,
106
- hasVerificationEvidence: false,
107
127
  };
108
128
 
109
129
  // 内置 error 级约束下违规抛错
@@ -147,7 +167,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
147
167
  it('checkConstraint 带 customConfig 应命中配置内约束', async () => {
148
168
  const context: ConstraintContext = {
149
169
  operation: 'code_implementation',
150
- hasVerificationEvidence: true,
170
+ projectPath: projectWithEvidence(),
171
+ changedFiles: [],
151
172
  };
152
173
  const customConfig = {
153
174
  constraints: {
@@ -180,7 +201,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
180
201
  it('check 结果带约束定义的 severity', async () => {
181
202
  const context: ConstraintContext = {
182
203
  operation: 'code_implementation',
183
- hasVerificationEvidence: true,
204
+ projectPath: projectWithEvidence(),
205
+ changedFiles: [],
184
206
  };
185
207
 
186
208
  const result = await checker.check(
@@ -218,7 +240,8 @@ describe('ConstraintChecker - 补充覆盖', () => {
218
240
 
219
241
  const context: ConstraintContext = {
220
242
  operation: 'code_implementation',
221
- hasVerificationEvidence: true,
243
+ projectPath: projectWithEvidence(),
244
+ changedFiles: [],
222
245
  };
223
246
 
224
247
  const result = await checkConstraint('no_completion_without_verification', context);
@@ -231,13 +254,67 @@ describe('ConstraintChecker - 补充覆盖', () => {
231
254
  it('error 级违规应该抛出 ConstraintViolationError', async () => {
232
255
  const context: ConstraintContext = {
233
256
  operation: 'code_implementation',
257
+ projectPath: projectWithoutEvidence(),
234
258
  hasTest: false,
235
- hasVerificationEvidence: false,
236
259
  };
237
260
 
238
261
  await expect(checkConstraints(context)).rejects.toThrow();
239
262
  });
240
263
  });
264
+
265
+ describe('channel 通道分发过滤(ADR-0035)', () => {
266
+ const disciplineEntry = {
267
+ id: 'app_discipline_rule',
268
+ kind: 'check' as const,
269
+ channel: 'discipline' as const,
270
+ severity: 'error' as const,
271
+ rule: 'DISCIPLINE RECORD',
272
+ message: '纪律登记记录',
273
+ trigger: 'code_implementation',
274
+ enforcement: '',
275
+ source: 'app' as const,
276
+ };
277
+ const customConfig = {
278
+ constraints: { app_discipline_rule: disciplineEntry },
279
+ disabled: [] as string[],
280
+ };
281
+ const context: ConstraintContext = { operation: 'code_implementation' };
282
+
283
+ it('非 gate 条目不进入 checker 分发、不触发注册表闭环抛错', async () => {
284
+ const result = await checker.checkConstraints(context, customConfig);
285
+ expect(result.passed).toBe(true);
286
+ expect(result.errors).toHaveLength(0);
287
+ expect(result.warnings).toHaveLength(0);
288
+ });
289
+
290
+ it('findApplicableConstraints 同样过滤非 gate 条目', () => {
291
+ const applicable = checker.findApplicableConstraints(context, customConfig);
292
+ expect(applicable.errors).toHaveLength(0);
293
+ expect(applicable.warnings).toHaveLength(0);
294
+ });
295
+
296
+ it('beforeExecution 跳过非 gate 条目', async () => {
297
+ await expect(checkBeforeExecution(context, customConfig)).resolves.not.toThrow();
298
+ });
299
+
300
+ it('非 gate 条目漏到 check() 单条入口 → 抛错(编排层过滤缺失不静默)', async () => {
301
+ await expect(checker.check(disciplineEntry, context)).rejects.toThrow(/不进入检查分发/);
302
+ });
303
+
304
+ it('channel: gate 且无 checker 的条目依旧当场抛错(闭环不松绑)', async () => {
305
+ const gateNoChecker = {
306
+ id: 'no_such_builtin_constraint',
307
+ kind: 'check' as const,
308
+ channel: 'gate' as const,
309
+ severity: 'error' as const,
310
+ rule: 'GATE WITHOUT CHECKER',
311
+ message: 'gate 无 checker',
312
+ trigger: 'code_implementation',
313
+ enforcement: '',
314
+ };
315
+ await expect(checker.check(gateNoChecker, context)).rejects.toThrow(/未注册 checker/);
316
+ });
317
+ });
241
318
  });
242
319
 
243
320
  describe('buildCheckEnv - 证据接线契约', () => {
@@ -263,10 +340,32 @@ describe('buildCheckEnv - 证据接线契约', () => {
263
340
  expect(env.srcScan('src')).toEqual(['src/x.ts']);
264
341
  });
265
342
 
266
- it("'none' env 下 evidence flag 未接线的 checker 返回 'skip'", async () => {
267
- // 「没接证据 → skip」由注释固化为可执行契约
268
- const check = contextEvidenceFlag('test-flag', (ctx) => ctx.hasVerificationEvidence);
343
+ it("'none' env 下 evidence flag 未接线的 checker 返回带原因的 skip(harness#182)", async () => {
344
+ // 「没接证据 → skip」由注释固化为可执行契约;原因进结果面
345
+ const check = contextEvidenceFlag('test-flag', 'hasFailingTest');
346
+ const env = buildCheckEnv(context, 'none');
347
+ expect(await check.evaluate(env)).toEqual({
348
+ skip: true,
349
+ reason: '证据标志 hasFailingTest 未接线',
350
+ });
351
+ });
352
+
353
+ it("'none' 变体:证据输入一律报不可得(输入契约的降级依据)", () => {
269
354
  const env = buildCheckEnv(context, 'none');
270
- expect(await check.evaluate(env)).toBe('skip');
355
+ expect(env.evidenceAvailable!('stagedDiff')).toBe(false);
356
+ expect(env.evidenceAvailable!('stagedDiffNames')).toBe(false);
357
+ });
358
+
359
+ it('providers 变体:缺省报全部可得;自定义 available 原样生效', () => {
360
+ const providers = {
361
+ stagedDiff: async () => '',
362
+ stagedDiffNames: async () => '',
363
+ srcScan: () => [] as string[],
364
+ };
365
+ const env = buildCheckEnv(context, providers);
366
+ expect(env.evidenceAvailable!('stagedDiff')).toBe(true);
367
+
368
+ const degraded = buildCheckEnv(context, { ...providers, available: () => false });
369
+ expect(degraded.evidenceAvailable!('stagedDiffNames')).toBe(false);
271
370
  });
272
371
  });
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 检查器原语 SDK 公共面(harness#181 第二半)
3
+ *
4
+ * 导出纪律 = 只导出存量:CheckOutcome / buildCheckEnv / normalizeCheckOutcome +
5
+ * 现有 checker 真实在用的辅助件(formatEvidence / contextFlag / contextEvidenceFlag
6
+ * 与接缝类型)。本套件从包根 import 原语组装一个「事实 ↔ 期望」式业务 checker,
7
+ * 验证导出真实可用;三处 barrel 清单与三道冻结钉见 public-exports /
8
+ * public-value-surface / public-type-surface。
9
+ */
10
+
11
+ import { describe, it, expect } from '@jest/globals';
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+ import {
15
+ buildCheckEnv,
16
+ contextEvidenceFlag,
17
+ contextFlag,
18
+ formatEvidence,
19
+ normalizeCheckOutcome,
20
+ type CheckOutcome,
21
+ type ConstraintCheck,
22
+ } from '../index';
23
+ import {
24
+ buildCheckEnv as buildCheckEnvFromCore,
25
+ contextFlag as contextFlagFromCore,
26
+ normalizeCheckOutcome as normalizeFromCore,
27
+ } from '../core';
28
+ import { createProjectFixture } from '../test-setup/project-fixture';
29
+
30
+ describe('检查器原语 SDK(harness#181)', () => {
31
+ it('包根与 ./core 子路径同源导出', () => {
32
+ expect(buildCheckEnvFromCore).toBe(buildCheckEnv);
33
+ expect(contextFlagFromCore).toBe(contextFlag);
34
+ expect(normalizeFromCore).toBe(normalizeCheckOutcome);
35
+ });
36
+
37
+ it('原语组装业务 checker:事实 ↔ 期望的几行绑定', async () => {
38
+ const root = createProjectFixture({
39
+ name: 'sdk-compose',
40
+ files: { 'docs/a.md': 'x' },
41
+ });
42
+ // 事实 = 项目根下文件存在性;期望 = 必需文件都在(业务知识留在业务侧绑定里)
43
+ const check: ConstraintCheck = {
44
+ id: 'app_demo',
45
+ evaluate: (env): CheckOutcome => {
46
+ const missing = ['docs/a.md', 'docs/b.md']
47
+ .filter((f) => !fs.existsSync(path.join(env.projectPath, f)));
48
+ return missing.length > 0
49
+ ? { pass: false, evidence: formatEvidence('必需文件不存在', missing) }
50
+ : true;
51
+ },
52
+ };
53
+ const env = buildCheckEnv({ operation: 'commit', projectPath: root }, 'none');
54
+ const outcome = normalizeCheckOutcome(await check.evaluate(env));
55
+ expect(outcome.satisfied).toBe(false);
56
+ expect(outcome.evidence.join('\n')).toContain('docs/b.md');
57
+ expect(outcome.evidence.join('\n')).not.toContain('docs/a.md');
58
+ });
59
+
60
+ it('谓词件 contextFlag / contextEvidenceFlag 经公共面照常工作', async () => {
61
+ const env = buildCheckEnv({ operation: 'commit', projectPath: '/nonexistent' }, 'none');
62
+ const flagCheck = contextFlag('app_flag', (ctx) => ctx.operation === 'commit');
63
+ expect(normalizeCheckOutcome(await flagCheck.evaluate(env)).satisfied).toBe(true);
64
+
65
+ const evidenceCheck = contextEvidenceFlag('app_evidence', 'hasFailingTest');
66
+ const skipped = normalizeCheckOutcome(await evidenceCheck.evaluate(env));
67
+ expect(skipped.skipped).toBe(true);
68
+ expect(skipped.skipReason).toContain('hasFailingTest');
69
+ });
70
+ });
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { ConstraintChecker, checkConstraint } from '../core/constraints/checker';
9
9
  import type { ConstraintContext } from '../types/constraint';
10
- import { rmSync, mkdtempSync } from 'fs';
10
+ import { rmSync, mkdtempSync, mkdirSync, writeFileSync } from 'fs';
11
11
  import { join } from 'path';
12
12
  import { tmpdir } from 'os';
13
13
 
@@ -31,14 +31,22 @@ describe('ConstraintChecker', () => {
31
31
 
32
32
  describe('error 级约束', () => {
33
33
  it('should check no_completion_without_verification', async () => {
34
+ // harness#183:验证证据 = .harness/evidence 落盘(独立链路),不再是 context flag
35
+ const withEvidence = join(tempDir, 'with-evidence');
36
+ mkdirSync(join(withEvidence, '.harness', 'evidence'), { recursive: true });
37
+ writeFileSync(join(withEvidence, '.harness', 'evidence', 'test.log'), 'ok');
38
+ const withoutEvidence = join(tempDir, 'without-evidence');
39
+ mkdirSync(withoutEvidence, { recursive: true });
40
+
34
41
  const contextWithEvidence: ConstraintContext = {
35
42
  operation: 'code_implementation',
36
- hasVerificationEvidence: true,
43
+ projectPath: withEvidence,
44
+ changedFiles: [],
37
45
  };
38
46
 
39
47
  const contextWithoutEvidence: ConstraintContext = {
40
48
  operation: 'code_implementation',
41
- hasVerificationEvidence: false,
49
+ projectPath: withoutEvidence,
42
50
  };
43
51
 
44
52
  const resultWithEvidence = await checker.check(
@@ -86,22 +94,16 @@ describe('ConstraintChecker', () => {
86
94
 
87
95
  describe('Helper functions', () => {
88
96
  it('should check single constraint via checkConstraint', async () => {
97
+ const withEvidence = join(tempDir, 'helper-with-evidence');
98
+ mkdirSync(join(withEvidence, '.harness', 'evidence'), { recursive: true });
99
+ writeFileSync(join(withEvidence, '.harness', 'evidence', 'test.log'), 'ok');
89
100
  const context: ConstraintContext = {
90
101
  operation: 'code_implementation',
91
- hasVerificationEvidence: true,
92
- };
93
-
94
- const result = await checkConstraint('no_completion_without_verification', context);
95
- expect(result.satisfied).toBe(true);
96
- });
97
-
98
- it('prompt 约束经 checkConstraint 短路通过', async () => {
99
- const context: ConstraintContext = {
100
- operation: 'code_implementation',
102
+ projectPath: withEvidence,
103
+ changedFiles: [],
101
104
  };
102
105
 
103
106
  const result = await checkConstraint('no_completion_without_verification', context);
104
- expect(result.id).toBe('no_completion_without_verification');
105
107
  expect(result.satisfied).toBe(true);
106
108
  });
107
109
 
@@ -55,12 +55,13 @@ describe('detectSourceRoots', () => {
55
55
  expect(roots).toContain('packages/mylib/lib');
56
56
  });
57
57
 
58
- it('monorepo: apps/*/src/modules/*', () => {
58
+ it('monorepo: apps/*/src(不再下探 modules 层)', () => {
59
59
  touchFile(join(tempDir, 'apps', 'api', 'src', 'modules', 'auth'), 'index.ts');
60
60
  touchFile(join(tempDir, 'apps', 'api', 'src', 'modules', 'users'), 'handler.ts');
61
61
  const roots = detectSourceRoots(tempDir);
62
- expect(roots).toContain('apps/api/src/modules/auth');
63
- expect(roots).toContain('apps/api/src/modules/users');
62
+ expect(roots).toContain('apps/api/src');
63
+ expect(roots).not.toContain('apps/api/src/modules/auth');
64
+ expect(roots).not.toContain('apps/api/src/modules/users');
64
65
  });
65
66
 
66
67
  it('排除 .d.ts 文件(只有类型声明不视为源码目录)', () => {
@@ -93,6 +94,6 @@ describe('detectSourceRoots', () => {
93
94
  const roots = detectSourceRoots(tempDir);
94
95
  expect(roots).toContain('src');
95
96
  expect(roots).toContain('packages/core/src');
96
- expect(roots).toContain('apps/api/src/modules/auth');
97
+ expect(roots).toContain('apps/api/src');
97
98
  });
98
99
  });
@@ -0,0 +1,118 @@
1
+ /**
2
+ * exec 执行协议全链验收(harness#181 第一半)
3
+ *
4
+ * 示例业务检查器 fixtures/public-repo-sanitization.mjs(场景原型 = 下游消费方安全底线
5
+ * public_repo_sanitization,ADR-0032 ①;占位符豁免谓词是模板填参表达不了的业务判定)
6
+ * 走完整链:编写(fixtures 脚本)→ 名册登记(.harness/constraints.yml 写
7
+ * checker: exec + params.command)→ 执行(loadAppConstraints → ConstraintChecker 分发)
8
+ * → 违规上报(证据行进 ConstraintResult,error 级经 checkConstraints 抛
9
+ * ConstraintViolationError——接入现有 severity/channel 体系)。
10
+ */
11
+
12
+ import { describe, it, expect } from '@jest/globals';
13
+ import * as path from 'path';
14
+ import { loadAppConstraints } from '../core/app-constraints-loader';
15
+ import { ConstraintChecker } from '../core/constraints/checker';
16
+ import { ConstraintViolationError, type ConstraintContext } from '../types/constraint';
17
+ import { createProjectFixture } from '../test-setup/project-fixture';
18
+
19
+ const SCRIPT = path.join(
20
+ __dirname, '..', 'core', 'constraints', 'checkers', '__tests__', 'fixtures',
21
+ 'public-repo-sanitization.mjs',
22
+ );
23
+
24
+ const DIRTY_DOC = [
25
+ '部署参考 /Users/alice/projects/demo 的配置。',
26
+ '占位符写法 /Users/<you>/projects 不算残留。',
27
+ '另一个现场 /home/bob/work/app 也要拦。',
28
+ ].join('\n');
29
+
30
+ const CLEAN_DOC = '部署参考 /Users/<you>/projects/demo 的配置。\n';
31
+
32
+ function constraintsYml(severity: 'error' | 'warning'): string {
33
+ return [
34
+ 'constraints:',
35
+ ' - id: app_public_repo_sanitization',
36
+ ' rule: 公开发布仓的受跟踪文本不得残留开发机现场绝对路径',
37
+ ' checker: exec',
38
+ ' params:',
39
+ ` command: 'node "${SCRIPT}" docs/guide.md'`,
40
+ ` severity: ${severity}`,
41
+ ' message: 检出开发机现场路径',
42
+ '',
43
+ ].join('\n');
44
+ }
45
+
46
+ function project(doc: string, severity: 'error' | 'warning'): string {
47
+ return createProjectFixture({
48
+ name: 'exec-chain',
49
+ files: {
50
+ [path.join('.harness', 'constraints.yml')]: constraintsYml(severity),
51
+ 'docs/guide.md': doc,
52
+ },
53
+ });
54
+ }
55
+
56
+ describe('exec 业务检查器全链(编写 → 名册登记 → 执行 → 违规上报)', () => {
57
+ it('名册登记:checker: exec + params.command 经加载期校验实例化为 gate 约束', () => {
58
+ const constraints = loadAppConstraints(project(DIRTY_DOC, 'error'));
59
+ expect(constraints).toHaveLength(1);
60
+ expect(constraints[0]).toMatchObject({
61
+ id: 'app_public_repo_sanitization',
62
+ source: 'app',
63
+ channel: 'gate',
64
+ checker: 'exec',
65
+ });
66
+ });
67
+
68
+ it('违规上报:检出残留路径 → satisfied=false,证据可归因到文件与命中,占位符豁免', async () => {
69
+ const root = project(DIRTY_DOC, 'error');
70
+ const [constraint] = loadAppConstraints(root);
71
+ const context: ConstraintContext = { operation: 'commit', projectPath: root };
72
+
73
+ const result = await new ConstraintChecker().check(constraint, context);
74
+ expect(result.satisfied).toBe(false);
75
+ const text = (result.evidence ?? []).join('\n');
76
+ expect(text).toContain('docs/guide.md');
77
+ expect(text).toContain('/Users/alice/');
78
+ expect(text).toContain('/home/bob/');
79
+ expect(text).not.toContain('<you>');
80
+ });
81
+
82
+ it('severity 分发:error 级违规经 checkConstraints 抛 ConstraintViolationError', async () => {
83
+ const root = project(DIRTY_DOC, 'error');
84
+ const [constraint] = loadAppConstraints(root);
85
+ const context: ConstraintContext = { operation: 'commit', projectPath: root };
86
+
87
+ await expect(
88
+ new ConstraintChecker().checkConstraints(context, {
89
+ constraints: { [constraint.id]: constraint },
90
+ disabled: [],
91
+ }),
92
+ ).rejects.toBeInstanceOf(ConstraintViolationError);
93
+ });
94
+
95
+ it('warning 级违规进 result.warnings、不抛(severity 语义与内置一致)', async () => {
96
+ const root = project(DIRTY_DOC, 'warning');
97
+ const [constraint] = loadAppConstraints(root);
98
+ const context: ConstraintContext = { operation: 'commit', projectPath: root };
99
+
100
+ const report = await new ConstraintChecker().collectConstraints(context, {
101
+ constraints: { [constraint.id]: constraint },
102
+ disabled: [],
103
+ });
104
+ expect(report.warningCount).toBe(1);
105
+ expect(report.warnings[0].satisfied).toBe(false);
106
+ expect((report.warnings[0].evidence ?? []).join('\n')).toContain('/Users/alice/');
107
+ });
108
+
109
+ it('对象合规(脚本退出码 0)→ 满足', async () => {
110
+ const root = project(CLEAN_DOC, 'error');
111
+ const [constraint] = loadAppConstraints(root);
112
+ const context: ConstraintContext = { operation: 'commit', projectPath: root };
113
+
114
+ const result = await new ConstraintChecker().check(constraint, context);
115
+ expect(result.satisfied).toBe(true);
116
+ expect(result.skipped).not.toBe(true);
117
+ });
118
+ });
@@ -12,6 +12,9 @@ import {
12
12
  import { constraintChecker } from '../core/constraints/checker';
13
13
  import { getConstraintCheck, registeredCheckCount } from '../core/constraints/checkers';
14
14
  import type { ConstraintContext } from '../types/constraint';
15
+ import * as fs from 'fs';
16
+ import * as path from 'path';
17
+ import * as os from 'os';
15
18
 
16
19
  describe('Constraint System', () => {
17
20
  describe('清单构成(ADR-0029:16 → 7,全部 kind=check)', () => {
@@ -188,36 +191,26 @@ describe('Constraint Checker', () => {
188
191
  });
189
192
 
190
193
  it('should check all constraints', async () => {
194
+ // harness#183:验证证据 = .harness/evidence 落盘(独立链路),不再是 context flag
195
+ const projectPath = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-iron-laws-'));
196
+ fs.mkdirSync(path.join(projectPath, '.harness', 'evidence'), { recursive: true });
197
+ fs.writeFileSync(path.join(projectPath, '.harness', 'evidence', 'test.log'), 'ok');
191
198
  const context: ConstraintContext = {
192
199
  operation: 'code_implementation',
200
+ projectPath,
201
+ changedFiles: [],
193
202
  hasRequirement: true,
194
- hasVerificationEvidence: true,
195
203
  hasSingleTask: true,
196
204
  };
197
205
 
198
206
  const result = await constraintChecker.checkConstraints(context);
199
207
  expect(result.errors.length + result.warnings.length).toBeGreaterThan(0);
208
+ fs.rmSync(projectPath, { recursive: true, force: true });
200
209
  });
201
210
 
202
- it('should skip no_completion_without_verification when hasVerificationEvidence is undefined(未接线不评估)', async () => {
203
- const context: ConstraintContext = {
204
- operation: 'code_implementation',
205
- };
206
-
207
- const result = await constraintChecker.check(CONSTRAINTS['no_completion_without_verification'], context);
208
- expect(result.skipped).toBe(true);
209
- expect(result.satisfied).toBe(true);
210
- });
211
-
212
- it('should pass no_completion_without_verification when hasVerificationEvidence is true', async () => {
213
- const context: ConstraintContext = {
214
- operation: 'code_implementation',
215
- hasVerificationEvidence: true,
216
- };
217
-
218
- const result = await constraintChecker.check(CONSTRAINTS['no_completion_without_verification'], context);
219
- expect(result.satisfied).toBe(true);
220
- });
211
+ // harness#183:flag 三态(未接线 skip / false fail / true pass)随证据源重构退役,
212
+ // 判定收进 checker 体内(读 .harness/evidence),语义钉子见
213
+ // checkers/__tests__/no-completion-without-verification.test.ts
221
214
  });
222
215
 
223
216
  describe('Constraint Severity', () => {
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 防回归:src/ 与 bin/ 不得再出现特定下游仓名引用
3
+ *
4
+ * harness 是通用约束框架,不得残留任何特定下游消费方的名字(历史清理票落地)。
5
+ * 递归扫描 src/ 与 bin/ 全部文本文件,逐行断言无目标词命中,
6
+ * 命中即 fail 并列出 文件:行。二进制文件(含 NUL 字节)跳过。
7
+ *
8
+ * 目标词经拼接构造、本文件名以外的内容不出现其字面量——
9
+ * 保证仓级全文检索(grep -ri)对本测试自身也零命中。
10
+ */
11
+
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+
15
+ const REPO_ROOT = path.join(__dirname, '..', '..');
16
+ const SCAN_DIRS = ['src', 'bin'];
17
+ const WORD = ['stu', 'dio'].join('');
18
+ const TARGET = new RegExp(`\\b${WORD}\\b`, 'i');
19
+
20
+ function listFiles(dir: string): string[] {
21
+ const out: string[] = [];
22
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
23
+ const full = path.join(dir, entry.name);
24
+ if (entry.isDirectory()) {
25
+ out.push(...listFiles(full));
26
+ } else if (entry.isFile()) {
27
+ out.push(full);
28
+ }
29
+ }
30
+ return out;
31
+ }
32
+
33
+ function isText(buf: Buffer): boolean {
34
+ return !buf.includes(0);
35
+ }
36
+
37
+ describe(`no ${WORD} references`, () => {
38
+ it('src/ 与 bin/ 全部文本文件零命中', () => {
39
+ const hits: string[] = [];
40
+ for (const dir of SCAN_DIRS) {
41
+ for (const file of listFiles(path.join(REPO_ROOT, dir))) {
42
+ const buf = fs.readFileSync(file);
43
+ if (!isText(buf)) continue;
44
+ const lines = buf.toString('utf-8').split('\n');
45
+ lines.forEach((line, i) => {
46
+ if (TARGET.test(line)) {
47
+ hits.push(`${path.relative(REPO_ROOT, file)}:${i + 1}`);
48
+ }
49
+ });
50
+ }
51
+ }
52
+ expect(hits).toEqual([]);
53
+ });
54
+ });
@@ -97,7 +97,7 @@ describe('PassesGate.check()', () => {
97
97
  /**
98
98
  * AC-007(ADR-0022 改写):零消费者方法已从公共面删除
99
99
  *
100
- * 原用例断言「保留 setPasses() 向后兼容」——兼容对象经 harness+studio 双仓
100
+ * 原用例断言「保留 setPasses() 向后兼容」——兼容对象经双仓
101
101
  * 核实不存在,ADR-0022 明确推翻该 AC。`@ts-expect-error` 在编译期钉住删除,
102
102
  * 运行期断言同时钉住形状(方法不存在于原型)。
103
103
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
- * pretool-use-hook 测试(studio#153)
2
+ * pretool-use-hook 测试
3
3
  *
4
- * 验收口径:block/warn/audit 行为与 studio-agent 生成版脚本一致——
4
+ * 验收口径:block/warn/audit 行为与下游消费方生成版脚本一致——
5
5
  * block 级 exit 2 阻断,warn/audit 放行,坏输入 fail-open。
6
6
  *
7
7
  * P1-7(ADR-0031,wayfinder 票08):命中留痕走 traces 通道——整个套件 chdir 到
@@ -69,6 +69,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
69
69
  'assertGateRegistryClosed',
70
70
  'bootstrapHarness',
71
71
  'bootstrapHarnessSync',
72
+ 'buildCheckEnv',
72
73
  'buildConstraintsUsageReport',
73
74
  'checkBeforeExecution',
74
75
  'checkConstraint',
@@ -77,6 +78,8 @@ const EXPECTED_RUNTIME_EXPORTS = [
77
78
  'classifyError',
78
79
  'collectUsageByConstraint',
79
80
  'configureTraceCollector',
81
+ 'contextEvidenceFlag',
82
+ 'contextFlag',
80
83
  'createAnalyzer',
81
84
  'createCheckerGate',
82
85
  'createCommandGate',
@@ -92,6 +95,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
92
95
  'diagnoseRetireCandidates',
93
96
  'extractCodeStructure',
94
97
  'findConstraintsByTrigger',
98
+ 'formatEvidence',
95
99
  'getAllConstraints',
96
100
  'getCommandGate',
97
101
  'getCommandRiskLevel',
@@ -106,9 +110,11 @@ const EXPECTED_RUNTIME_EXPORTS = [
106
110
  'isCommandAllowed',
107
111
  'lintEffectiveConfig',
108
112
  'listRegisteredGates',
113
+ 'listRetiredConstraints',
109
114
  'matchAnyGlob',
110
115
  'matchGlob',
111
116
  'migrateKnowledgeEntries',
117
+ 'normalizeCheckOutcome',
112
118
  'readProjectTraces',
113
119
  'readProjectTracesReport',
114
120
  'registeredGateCount',