@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
@@ -0,0 +1,154 @@
1
+ /**
2
+ * sync-docs --gate 测试(harness#189)
3
+ *
4
+ * 行为契约(票面锁定):
5
+ * 1. 照常先跑 sync-docs 自愈写入(幽灵条目剔除、file 模式自动补行不变);
6
+ * 2. 随后判定被管理文档相对 HEAD 是否产生 diff;
7
+ * 3. 有 diff 即 fail,输出点名缺登记文件(diff 新增行即名单);无 diff → ok。
8
+ * 自愈顺序不变:写入永远在校验之前(2026-08-08 CI 4 连红固化结论)。
9
+ */
10
+
11
+ import * as fs from 'fs';
12
+ import * as path from 'path';
13
+ import * as os from 'os';
14
+ import { execFileSync } from 'child_process';
15
+ import { captureIO } from '../../command-contract';
16
+ import { syncDocs } from '../sync-docs';
17
+
18
+ function git(dir: string, args: string[]): string {
19
+ return execFileSync('git', ['-C', dir, ...args], { encoding: 'utf-8' });
20
+ }
21
+
22
+ function commitAll(dir: string, msg: string): void {
23
+ git(dir, ['add', '-A']);
24
+ git(dir, [
25
+ '-c', 'user.name=test', '-c', 'user.email=test@example.com',
26
+ 'commit', '-m', msg, '--no-gpg-sign',
27
+ ]);
28
+ }
29
+
30
+ /** 建最小 file 模式项目骨架(package.json + src/alpha.ts) */
31
+ function scaffoldProject(dir: string): void {
32
+ fs.mkdirSync(path.join(dir, 'src'), { recursive: true });
33
+ fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ name: 'gate-fixture', version: '0.0.1' }));
34
+ fs.writeFileSync(path.join(dir, 'src', 'alpha.ts'), '/**\n * Alpha module\n */\nexport const alpha = 1;');
35
+ }
36
+
37
+ describe('sync-docs --gate(harness#189)', () => {
38
+ let tempDir: string;
39
+
40
+ beforeEach(() => {
41
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sync-docs-gate-'));
42
+ });
43
+
44
+ afterEach(() => {
45
+ try {
46
+ fs.rmSync(tempDir, { recursive: true, force: true });
47
+ } catch {
48
+ // ignore
49
+ }
50
+ });
51
+
52
+ /** 造一个 HEAD 文档干净的仓库:sync-docs 写入后提交 */
53
+ async function setupCleanRepo(): Promise<void> {
54
+ scaffoldProject(tempDir);
55
+ git(tempDir, ['init']);
56
+ await syncDocs({ projectPath: tempDir }, captureIO());
57
+ commitAll(tempDir, 'baseline');
58
+ }
59
+
60
+ it('file 模式漏登 → fail 且点名缺登记文件,自愈写入已落盘(写入在校验之前)', async () => {
61
+ await setupCleanRepo();
62
+
63
+ // 造漏登:新增已提交但未登记的源文件(开发者忘了跑 sync-docs)
64
+ fs.writeFileSync(path.join(tempDir, 'src', 'newmod.ts'), '/**\n * New module\n */\nexport const n = 1;');
65
+ commitAll(tempDir, 'add newmod without registering');
66
+
67
+ const io = captureIO();
68
+ const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
69
+
70
+ expect(result.kind).toBe('fail');
71
+ // 输出点名缺登记文件(diff 新增行即名单)
72
+ expect(io.outText()).toContain('newmod');
73
+ if (result.kind === 'fail') {
74
+ expect(result.reason).toContain('newmod');
75
+ }
76
+ // 自愈顺序不变:判定失败时写入已落盘
77
+ expect(fs.readFileSync(path.join(tempDir, 'CAPABILITIES.md'), 'utf-8')).toContain('newmod');
78
+ });
79
+
80
+ it('HEAD 文档干净(无需自愈)→ ok', async () => {
81
+ await setupCleanRepo();
82
+
83
+ const io = captureIO();
84
+ const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
85
+
86
+ expect(result).toEqual({ kind: 'ok' });
87
+ });
88
+
89
+ it('幽灵条目剔除也触发门:写入在校验之前', async () => {
90
+ await setupCleanRepo();
91
+
92
+ // 造幽灵条目:CAPABILITIES.md 登记了不存在的 src/ghost.ts 并提交
93
+ const capsPath = path.join(tempDir, 'CAPABILITIES.md');
94
+ const content = fs.readFileSync(capsPath, 'utf-8');
95
+ fs.writeFileSync(capsPath, content + '| ghost | src/ghost.ts | Ghost module |\n');
96
+ commitAll(tempDir, 'register ghost entry');
97
+
98
+ const io = captureIO();
99
+ const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
100
+
101
+ expect(result.kind).toBe('fail');
102
+ expect(io.outText()).toContain('ghost');
103
+ // 自愈照做:幽灵行已被剔除
104
+ expect(fs.readFileSync(capsPath, 'utf-8')).not.toContain('ghost');
105
+ });
106
+
107
+ it('sync-docs 查不出的未提交手改(描述改写)也是 vs HEAD 漂移 → fail', async () => {
108
+ await setupCleanRepo();
109
+
110
+ // 手改 CAPABILITIES.md 散文(不增删登记条目,sync-docs 判定面无漂移)且不提交
111
+ const capsPath = path.join(tempDir, 'CAPABILITIES.md');
112
+ const content = fs.readFileSync(capsPath, 'utf-8');
113
+ fs.writeFileSync(capsPath, content.replace('Alpha module', 'Alpha module v2'));
114
+
115
+ const io = captureIO();
116
+ const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
117
+
118
+ expect(result.kind).toBe('fail');
119
+ expect(io.outText()).toContain('CAPABILITIES.md');
120
+ });
121
+
122
+ it('--agents 时 AGENTS.md 漂移(untracked 新建)也判 fail 并点名', async () => {
123
+ await setupCleanRepo();
124
+
125
+ const io = captureIO();
126
+ const result = await syncDocs({ projectPath: tempDir, gate: true, agents: true }, io);
127
+
128
+ expect(result.kind).toBe('fail');
129
+ expect(io.outText()).toContain('AGENTS.md');
130
+ });
131
+
132
+ it('非 git 仓库 → usage-error,且不做任何写入', async () => {
133
+ scaffoldProject(tempDir);
134
+
135
+ const io = captureIO();
136
+ const result = await syncDocs({ projectPath: tempDir, gate: true }, io);
137
+
138
+ expect(result.kind).toBe('usage-error');
139
+ expect(fs.existsSync(path.join(tempDir, 'CAPABILITIES.md'))).toBe(false);
140
+ });
141
+
142
+ it.each([
143
+ { extra: { check: true }, label: '--check' },
144
+ { extra: { json: true }, label: '--json' },
145
+ { extra: { compact: true }, label: '--compact' },
146
+ ])('--gate 与 $label 互斥 → usage-error', async ({ extra }) => {
147
+ await setupCleanRepo();
148
+
149
+ const io = captureIO();
150
+ const result = await syncDocs({ projectPath: tempDir, gate: true, ...extra }, io);
151
+
152
+ expect(result.kind).toBe('usage-error');
153
+ });
154
+ });
@@ -72,7 +72,7 @@ describe('sync-docs CAPABILITIES.md 表格排版(#171)', () => {
72
72
  fs.rmSync(dir, { recursive: true, force: true });
73
73
  });
74
74
 
75
- it('撤目录条目行(studio 撤登记形状):同样整行删除', async () => {
75
+ it('撤目录条目行(撤登记形状):同样整行删除', async () => {
76
76
  const dir = makeProject(
77
77
  'dir-entry',
78
78
  ['cli/cli.ts', 'harness/h.ts'],
@@ -171,7 +171,7 @@ describe('sync-docs command', () => {
171
171
  it('描述以 / 结尾的表格行不应被误判为目录条目(check 必须收敛)', async () => {
172
172
  // 回归:JSDoc 首行在 "gitRepo /" 处换行时,生成的描述单元格以 / 结尾,
173
173
  // 旧目录条目正则将其误判为目录 → --check 永远报「包含已删除的模块」
174
- // (2026-08-04 studio PR #44 CI Governance 不收敛事故)
174
+ // (2026-08-04 CI Governance 不收敛事故)
175
175
  const testDir = path.join(tempDir, 'trailing-slash-desc');
176
176
  const srcDir = path.join(testDir, 'src');
177
177
  fs.mkdirSync(srcDir, { recursive: true });
@@ -409,7 +409,7 @@ describe('sync-docs command', () => {
409
409
  const testDir = path.join(tempDir, 'tsx-row');
410
410
  const srcDir = path.join(testDir, 'src', 'components');
411
411
  fs.mkdirSync(srcDir, { recursive: true });
412
- // 复刻 studio 场景:同目录混合 .ts 与 .tsx
412
+ // 复刻下游消费方场景:同目录混合 .ts 与 .tsx
413
413
  fs.writeFileSync(path.join(srcDir, 'statusClasses.ts'), 'export const statuses = {};');
414
414
  fs.writeFileSync(
415
415
  path.join(srcDir, 'DistillProposalCard.tsx'),
@@ -504,7 +504,7 @@ describe('sync-docs command', () => {
504
504
  fs.writeFileSync(path.join(srcA, 'routes.ts'), 'export const routes = 1;');
505
505
 
506
506
  // CAPABILITIES.md 另有一条指向不存在路径的 routes.ts(basename 碰撞,
507
- // 按 basename 对比时永远不可见 —— 2026-08-08 studio CI 4 连红事故)
507
+ // 按 basename 对比时永远不可见 —— 2026-08-08 CI 4 连红事故)
508
508
  fs.writeFileSync(
509
509
  path.join(testDir, 'CAPABILITIES.md'),
510
510
  [
@@ -189,11 +189,11 @@ export async function check(
189
189
  hints.forEach(r => logEvidence(io, r, 'gray', r.id));
190
190
  }
191
191
 
192
- // Skipped:约定未采用 / 证据未接线,未评估(不计通过/失败)
192
+ // Skipped:约定未采用 / 证据未接线 / 输入不可得,未评估(不计通过/失败;harness#182 起原因随行列出)
193
193
  if (skippedResults.length > 0) {
194
- log(io, chalk.gray(`⏭️ 跳过评估: ${skippedResults.length} 条(约定未采用或证据未接线,不计通过/失败)`));
194
+ log(io, chalk.gray(`⏭️ 跳过评估: ${skippedResults.length} 条(未评估,不计通过/失败)`));
195
195
  skippedResults.forEach(r => {
196
- log(io, chalk.gray(` - ${r.id}`));
196
+ log(io, chalk.gray(` - ${r.id}${r.skipReason ? `:${r.skipReason}` : ''}`));
197
197
  });
198
198
  }
199
199
 
@@ -0,0 +1,145 @@
1
+ /**
2
+ * harness constraints disable —— 约束裸禁用(harness#190,ADR-0032 决策 6.6 的另一侧)
3
+ *
4
+ * 裸禁用 = config.yml `constraints.<id>.enabled:false`,无 retired 墓碑、无知识沉淀
5
+ * (墓碑与沉淀是 retire 专有语义)。与 retire 的分工:
6
+ *
7
+ * - disable:临时停用,幂等 already_disabled,不写沉淀;恢复 = 删 enabled 键
8
+ * - retire:永久退役,写 retired 墓碑 + `constraint-retired-<id>` 沉淀;
9
+ * 对裸 disabled 条目会接管补墓碑+沉淀(constraints-retire.ts 头部注释)
10
+ *
11
+ * 语义与下游消费方 applier 的 applyDisable 对齐(经下游裁定
12
+ * config.yml 归 harness,本命令是下游切换的落点):
13
+ * 只认内置 + 应用层(.harness/constraints.yml)check 约束(findRetireTarget 同路径,
14
+ * ADR-0033);写后验证生效集已缩小,失败回滚备份。
15
+ *
16
+ * retired 墓碑不接管不动:已退役条目返回 already_retired(要恢复请 reactivate)。
17
+ * 人确认闸门与 retire/reactivate 同形(ADR-0001 决策 2):直达必须显式 --yes,
18
+ * 不提供交互模式——禁用是低频点对点操作(同 reactivate 定位)。
19
+ */
20
+
21
+ import * as fs from 'fs';
22
+ import * as path from 'path';
23
+ import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
24
+ import chalk from 'chalk';
25
+ import { ProjectConfigLoader } from '../../core/project-config-loader';
26
+ import { isRetiredTombstone } from '../../core/retired-constraints';
27
+ import { getEffectiveConstraints } from '../../core/effective-constraints';
28
+ import { findRetireTarget, logCommitHint, setYamlEntry } from './constraints-retire';
29
+
30
+ export type DisableStatus =
31
+ | 'disabled'
32
+ | 'already_disabled'
33
+ | 'already_retired'
34
+ | 'unknown_id'
35
+ | 'verify_failed';
36
+
37
+ export interface DisableResult {
38
+ id: string;
39
+ status: DisableStatus;
40
+ }
41
+
42
+ export interface ConstraintsDisableOptions {
43
+ projectPath?: string;
44
+ /** 直达模式显式确认(--yes):与 retire/reactivate 同一道人确认闸门,无此 flag 直达拒绝执行 */
45
+ yes?: boolean;
46
+ }
47
+
48
+ /**
49
+ * 执行单条约束裸禁用(纯执行逻辑,无交互)
50
+ *
51
+ * 不存在的 id / 已禁用 / 已退役的 id 通过 status 返回,由调用方提示。
52
+ */
53
+ export function disableConstraint(projectRoot: string, id: string): DisableResult {
54
+ const target = findRetireTarget(id, projectRoot);
55
+ if (!target) {
56
+ return { id, status: 'unknown_id' };
57
+ }
58
+
59
+ // 幂等口径(ADR-0032 决策 6.6):retired 墓碑优先判定——disable 不动墓碑不吞退休语义;
60
+ // 裸 enabled:false 即已禁用。判定谓词唯一实现 = isRetiredTombstone
61
+ const loader = new ProjectConfigLoader(projectRoot);
62
+ loader.load();
63
+ const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
64
+ if (isRetiredTombstone(existing)) {
65
+ return { id, status: 'already_retired' };
66
+ }
67
+ if (existing?.enabled === false) {
68
+ return { id, status: 'already_disabled' };
69
+ }
70
+
71
+ // 1. 落盘裸禁用(config.yml enabled:false,无 retired 段;同文件其他条目不动)
72
+ const configPath = path.join(projectRoot, '.harness', 'config.yml');
73
+ const backup = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf-8') : null;
74
+ setYamlEntry(configPath, 'config.yml', 'constraints', id, { enabled: false });
75
+
76
+ // 2. 写后验证:生效集必须已缩小(与下游 applier 同一纪律),失败回滚备份
77
+ try {
78
+ if (getEffectiveConstraints(projectRoot).some(c => c.id === id)) {
79
+ throw new Error('constraint still present in effective set after disable');
80
+ }
81
+ } catch {
82
+ if (backup !== null) fs.writeFileSync(configPath, backup, 'utf-8');
83
+ else fs.rmSync(configPath, { force: true });
84
+ return { id, status: 'verify_failed' };
85
+ }
86
+
87
+ return { id, status: 'disabled' };
88
+ }
89
+
90
+ /**
91
+ * 打印单条禁用结果
92
+ */
93
+ export function printDisableResult(result: DisableResult, io: CommandIO = processIO, projectRoot?: string): CommandResult {
94
+ switch (result.status) {
95
+ case 'unknown_id':
96
+ log(io, chalk.red(`❌ ${result.id}: 约束不存在(内置与应用层约束中都未找到),未做任何变更`));
97
+ return { kind: 'skip', reason: `${result.id}: 约束不存在,未做任何变更` };
98
+ case 'already_disabled':
99
+ log(io, chalk.yellow(`⚠️ ${result.id}: 已处于禁用状态(config.yml enabled:false 无墓碑),跳过`));
100
+ return { kind: 'skip', reason: `${result.id}: 已处于禁用状态,跳过` };
101
+ case 'already_retired':
102
+ log(io, chalk.yellow(`⚠️ ${result.id}: 已处于退役状态(有 retired 墓碑)——disable 不动墓碑,未做任何变更;要恢复请 harness constraints reactivate ${result.id} --yes`));
103
+ return { kind: 'skip', reason: `${result.id}: 已处于退役状态,未做任何变更` };
104
+ case 'verify_failed':
105
+ logError(io, chalk.red(`❌ ${result.id}: 禁用后约束仍在生效集,写后验证失败,已回滚 config.yml`));
106
+ return { kind: 'fail', reason: `${result.id}: disable 写后验证失败,已回滚 config.yml` };
107
+ case 'disabled': {
108
+ log(io, chalk.green(`✅ ${result.id}: 已禁用(config.yml enabled:false,无 retired 墓碑、无知识沉淀)`));
109
+ log(io, chalk.gray(` disable 是裸禁用不是退役——恢复:删 config.yml constraints.${result.id} 的 enabled 键;要永久退役走 harness constraints retire ${result.id}(会接管补墓碑+沉淀)`));
110
+ if (projectRoot) logCommitHint(projectRoot, io);
111
+ break;
112
+ }
113
+ }
114
+ return { kind: 'ok' };
115
+ }
116
+
117
+ /**
118
+ * CLI handler: harness constraints disable <id>
119
+ *
120
+ * 人确认闸门与 retire/reactivate 同形:直达必须显式 `--yes`,无 `--yes` 报错 +
121
+ * 非零退出码,不落盘任何文件。无交互模式(点对点操作,同 reactivate)。
122
+ */
123
+ export async function constraintsDisable(
124
+ id?: string,
125
+ options: ConstraintsDisableOptions = {},
126
+ io: CommandIO = processIO,
127
+ ): Promise<CommandResult> {
128
+ const projectRoot = options.projectPath || process.cwd();
129
+
130
+ if (!id) {
131
+ logError(io, chalk.red('❌ 用法:harness constraints disable <id> --yes(禁用是点对点操作,无交互模式)'));
132
+ return { kind: 'usage-error', reason: 'disable 缺少约束 id,未做任何变更' };
133
+ }
134
+
135
+ if (!options.yes) {
136
+ logError(io,
137
+ chalk.red(`❌ 直达禁用需要显式人确认(与 retire 同一闸门),未做任何变更\n`) +
138
+ ` 带 --yes 显式确认直达:harness constraints disable ${id} --yes`
139
+ );
140
+ return { kind: 'usage-error', reason: `直达禁用 ${id} 缺少显式 --yes 人确认,未做任何变更` };
141
+ }
142
+
143
+ const result = disableConstraint(projectRoot, id);
144
+ return printDisableResult(result, io, projectRoot);
145
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * harness constraints pack-proposal <id> —— 升级提案材料打包(ADR-0033 决策 4,块 3 子项 5)
3
3
  *
4
- * 升级通道链路:studio 审卡发起/初审 → approve 后由本命令打包脱敏材料 →
4
+ * 升级通道链路:下游审卡发起/初审 → approve 后由本命令打包脱敏材料 →
5
5
  * 人拿材料去 harness 仓开 issue(github 操作留给人,本命令不触网)。
6
6
  *
7
7
  * 材料内容:条文 + severity + checker 模板与参数 + traces.log 使用统计(只有计数)
@@ -16,6 +16,7 @@ import * as path from 'path';
16
16
  import { log, logError, processIO, type CommandIO, type CommandResult } from '../command-contract';
17
17
  import chalk from 'chalk';
18
18
  import { ProjectConfigLoader } from '../../core/project-config-loader';
19
+ import { isRetiredTombstone } from '../../core/retired-constraints';
19
20
  import type { KnowledgeEntry } from '../../knowledge/types';
20
21
  import { openKnowledgeStore } from './knowledge-view';
21
22
  import { findRetireTarget, logCommitHint, removeYamlEntry, type RetireTargetInfo } from './constraints-retire';
@@ -121,11 +122,12 @@ export function reactivateConstraint(
121
122
  return { id, status: 'unknown_id' };
122
123
  }
123
124
 
124
- // 只认 retired 墓碑:裸 disable 与未配置一律 not_retired(与 retire 的幂等口径对偶)
125
+ // 只认 retired 墓碑:裸 disable 与未配置一律 not_retired(与 retire 的幂等口径对偶,
126
+ // 判定谓词唯一实现 = isRetiredTombstone)
125
127
  const loader = new ProjectConfigLoader(projectRoot);
126
128
  loader.load();
127
129
  const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
128
- if (!(existing?.enabled === false && existing.retired)) {
130
+ if (!isRetiredTombstone(existing)) {
129
131
  return { id, status: 'not_retired' };
130
132
  }
131
133
 
@@ -12,8 +12,8 @@
12
12
  * retired: { at, reason, stats: { total, fail, failRate } }
13
13
  *
14
14
  * 每条同时写一条 KnowledgeStore 记录(consumptionMode: 'signal')。
15
- baseDir 不硬编码 projectRoot 拼接,走 openKnowledgeStore 同一解析点(harness#177):
16
- 缺省与 `harness knowledge` 读口同根,KNOWLEDGE_BASE_DIR 覆盖对写口同步生效。
15
+ * baseDir 不硬编码 projectRoot 拼接,走 openKnowledgeStore 同一解析点(harness#177):
16
+ * 缺省与 `harness knowledge` 读口同根,KNOWLEDGE_BASE_DIR 覆盖对写口同步生效。
17
17
  *
18
18
  * ADR-0029:custom 纯文本约束与治理注入段同步已随文本注入层关停一并退役。
19
19
  * ADR-0032 观察名单(块 3 子项 4):零拦截命中先进观察名单(`.harness/.state.json`
@@ -40,6 +40,7 @@ import * as yaml from 'js-yaml';
40
40
  import chalk from 'chalk';
41
41
  import { getConstraint } from '../../core/constraints/definitions';
42
42
  import { ProjectConfigLoader } from '../../core/project-config-loader';
43
+ import { isRetiredTombstone } from '../../core/retired-constraints';
43
44
  import { loadAppConstraints } from '../../core/app-constraints-loader';
44
45
  import type { RunTarget } from '../../core/constraints/run-env';
45
46
  import type { KnowledgeEntry } from '../../knowledge/types';
@@ -60,7 +61,7 @@ export interface RetireExecuteOptions {
60
61
  reason?: string;
61
62
  /** 注入当前时间(测试用) */
62
63
  now?: Date;
63
- /** 知识库路径解析的 io(legacy 兜底告警走 stderr 需要;缺省 processIO) */
64
+ /** 知识库路径解析的 io(注入给 openKnowledgeStore;当前 resolveKnowledgeBaseDir 已不消费,保留注入点与读口签名对齐。缺省 processIO) */
64
65
  io?: CommandIO;
65
66
  }
66
67
 
@@ -135,8 +136,10 @@ export function findRetireTarget(id: string, target?: RunTarget): RetireTargetIn
135
136
  * js-yaml 不保留注释:原文件含注释行时重写会丢失,console 说明(`label` 是给用户看的
136
137
  * 文件名)。落盘字节由 `__tests__/constraints-retire.test.ts`
137
138
  * 的逐字节冻结用例钉住——合并属内部重构,对外产物不得漂移。
139
+ *
140
+ * 导出给 constraints-disable 复用(裸禁用写 `{ enabled: false }` 同一读-改-写口径)。
138
141
  */
139
- function setYamlEntry(
142
+ export function setYamlEntry(
140
143
  filePath: string,
141
144
  label: string,
142
145
  section: string,
@@ -182,11 +185,11 @@ export function removeYamlEntry(filePath: string, section: string, id: string):
182
185
 
183
186
  /**
184
187
  * 落盘后 commit 提示(票 02 断点 4):仅 git 仓内提示,不替用户动 git。
185
- * studio 审卡通道由 applier 自动 commit,本提示面向 CLI 直达/裸项目场景。
188
+ * 下游审卡通道由 applier 自动 commit,本提示面向 CLI 直达/裸项目场景。
186
189
  */
187
190
  export function logCommitHint(projectRoot: string, io: CommandIO): void {
188
191
  if (!fs.existsSync(path.join(projectRoot, '.git'))) return;
189
- log(io, chalk.gray(' 提示:config.yml 已改未提交——git add .harness/config.yml && git commit(studio 审卡通道会自动 commit)'));
192
+ log(io, chalk.gray(' 提示:config.yml 已改未提交——git add .harness/config.yml && git commit(下游审卡通道会自动 commit)'));
190
193
  }
191
194
 
192
195
  /**
@@ -284,9 +287,9 @@ export function retireConstraint(
284
287
 
285
288
  // 已退役保护:只认 retired 墓碑(ADR-0032 决策 6.6,票 02 断点 6)——
286
289
  // 裸 enabled:false 是"禁用"不是"退休",落到下面正常退休流程:覆写墓碑 + 补写沉淀,
287
- // 不让一次裸 disable 吞掉 retire 的知识沉淀。
290
+ // 不让一次裸 disable 吞掉 retire 的知识沉淀。判定谓词唯一实现 = isRetiredTombstone。
288
291
  const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
289
- if (existing?.enabled === false && existing.retired) {
292
+ if (isRetiredTombstone(existing)) {
290
293
  return { id, status: 'already_retired', isError, stats: emptyStats };
291
294
  }
292
295
 
@@ -2,7 +2,7 @@
2
2
  * harness constraints -- 约束集合元数据导出
3
3
  *
4
4
  * 纯数据导出,不调用 LLM,不访问文件系统(除 definitions.ts)。
5
- * 供 Studio 等消费者获取约束的 hash、计数等元数据。
5
+ * 供下游消费方获取约束的 hash、计数等元数据。
6
6
  */
7
7
 
8
8
  import { createHash } from 'crypto';
@@ -223,6 +223,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
223
223
  { flags: '--json', description: '输出 JSON 格式(供 LLM 消费)', defaultValue: false },
224
224
  { flags: '--agents', description: '同步 AGENTS.md(agent 导读;PRESERVE 标记段重新生成时保留)', defaultValue: false },
225
225
  { flags: '--compact', description: '一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目', defaultValue: false },
226
+ { flags: '--gate', description: '门禁模式:自愈写入后判定被管理文档相对 HEAD 的 diff,有 diff 退 1(CI 用;与 --check/--json/--compact 互斥)', defaultValue: false },
226
227
  ],
227
228
  // --check 下的漂移由实现返回 fail(候选7:退出码映射只在 bin 一处),故无需 afterRun
228
229
  action: { module: 'sync-docs', export: 'syncDocs' },
@@ -297,7 +298,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
297
298
  },
298
299
  {
299
300
  command: 'release',
300
- description: 'npm 发布流水线:tsc → dist 验证 → npm version → git push → npm publish → gh release。不依赖 Studio API。',
301
+ description: 'npm 发布流水线:tsc → dist 验证 → npm version → git push → npm publish → gh release。纯 CLI 实现,不依赖外部 API。',
301
302
  options: [
302
303
  { flags: '--bump <type>', description: '版本递增类型', defaultValue: 'patch' },
303
304
  { flags: '--dry-run <bool>', description: '仅模拟执行', defaultValue: 'false' },
@@ -369,6 +370,20 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
369
370
  yes: options.yes,
370
371
  }],
371
372
  },
373
+ {
374
+ command: 'disable',
375
+ argument: '<id>',
376
+ description: '裸禁用约束:config.yml enabled:false 无 retired 墓碑无沉淀(区别于 retire;写后验证生效集已缩小,失败回滚);直达需显式 --yes,幂等 already disabled',
377
+ options: [
378
+ { flags: '-p, --project-path <path>', description: '项目路径' },
379
+ { flags: '-y, --yes', description: '显式确认直达禁用(与 retire 同一道人确认闸门)', defaultValue: false },
380
+ ],
381
+ action: { module: 'constraints-disable', export: 'constraintsDisable' },
382
+ mapActionArgs: (positionals, options) => [positionals[0], {
383
+ projectPath: options.projectPath,
384
+ yes: options.yes,
385
+ }],
386
+ },
372
387
  {
373
388
  command: 'pack-proposal',
374
389
  argument: '<id>',
@@ -10,7 +10,7 @@
10
10
  * - **角色→样式单表 + 键→中文 label 映射**:维度 label、成熟度颜色、规则 label 的唯一权威。
11
11
  * - **json / 人读的唯一分派与退出码**:`--json` 打 `data` 的序列化,否则渲染 display model。
12
12
  * - **路径解析与 store 构造**:`-p` / `KNOWLEDGE_BASE_DIR` / 缺省目录解析只在这一处
13
- * (ADR-0034:旧 ~/.studio/knowledge 兼容沿用已退役,studio 正本由编排侧显式注入)。
13
+ * (ADR-0034:消费方数据区正本由编排侧经 KNOWLEDGE_BASE_DIR 显式注入)。
14
14
  */
15
15
 
16
16
  import chalk from 'chalk';
@@ -176,7 +176,7 @@ export function emitKnowledgeView<T>(io: CommandIO, options: { json?: boolean },
176
176
 
177
177
  // ── 路径解析与 store 构造 ─────────────────────────────────
178
178
 
179
- /** 缺省知识库数据根(相对用户 home)。裸 CLI 项目缺省目录;studio 场景唯一正本 ~/.studio/knowledge 由编排侧经 KNOWLEDGE_BASE_DIR 显式注入(ADR-0034) */
179
+ /** 缺省知识库数据根(相对用户 home)。裸 CLI 项目缺省目录;消费方数据区正本由编排侧经 KNOWLEDGE_BASE_DIR 显式注入(ADR-0034) */
180
180
  const KNOWLEDGE_DATA_DIR = path.join('.harness', 'knowledge');
181
181
 
182
182
  export interface KnowledgePathOptions {
@@ -188,8 +188,8 @@ export interface KnowledgePathOptions {
188
188
 
189
189
  /**
190
190
  * 知识库数据根的唯一解析点。`-p` 优先,其次 KNOWLEDGE_BASE_DIR,
191
- * 最后落到用户 home 缺省目录(ADR-0034 目录收编:旧 ~/.studio/knowledge
192
- * 兼容沿用逻辑已退役——双目录分叉是历史包袱,studio 正本由编排侧显式注入;
191
+ * 最后落到用户 home 缺省目录(ADR-0034 目录收编:消费方数据区正本由
192
+ * 编排侧经 KNOWLEDGE_BASE_DIR 显式注入,本命令不做任何旧目录兼容沿用;
193
193
  * io 参数随兼容提示一并失去用途,签名保留免动全部调用方)。
194
194
  */
195
195
  export function resolveKnowledgeBaseDir(options: KnowledgePathOptions, _io: CommandIO): string {
@@ -2,8 +2,8 @@
2
2
  * harness release 命令
3
3
  *
4
4
  * 完整 npm 发布流水线:tsc → dist 验证 → npm version → git push → npm publish → gh release。
5
- * 与 studio MCP tool `publishPackage` 共享同一逻辑,但此 CLI 命令不依赖 Studio API 运行。
6
- * 当 studio API 因 harness 包损坏而无法启动时,此 CLI 命令仍可用。
5
+ * 纯 CLI 实现,不依赖任何外部 API——下游编排服务因 harness 包损坏而无法启动时,
6
+ * 此 CLI 命令仍可作为发布兜底通道使用。
7
7
  *
8
8
  * 流程:
9
9
  * 1. Verify package
@@ -236,17 +236,15 @@ async function hasKnowledgeDir(projectPath: string): Promise<boolean> {
236
236
  }
237
237
  }
238
238
 
239
- /** 模块上下文正本候选路径(相对项目根):新正本优先,旧正本兼容沿用(免迁移) */
239
+ /** 模块上下文正本候选路径(相对项目根) */
240
240
  const CONTEXT_DOC_PATHS: string[][] = [
241
241
  ['.harness', 'CONTEXT.md'],
242
- ['.studio', 'CONTEXT.md'],
243
242
  ];
244
243
 
245
244
  /**
246
245
  * 定位模块上下文正本(正本模型):
247
246
  * 模块上下文沉淀归并到业务仓单一正本(模块锚点组织)时,知识入口行改指正本,
248
- * 不再输出散置 CONTEXT.md 指引。正本路径缺省 `.harness/CONTEXT.md`;
249
- * 旧正本 `.studio/CONTEXT.md` 在场时兼容沿用,两者同时在场上以 `.harness/` 为准。
247
+ * 不再输出散置 CONTEXT.md 指引。正本路径缺省 `.harness/CONTEXT.md`。
250
248
  * 返回相对 projectPath 的正本路径(posix 分隔符),无正本返回 null。只判存在性,不解析内容。
251
249
  */
252
250
  async function findCanonicalContextDoc(projectPath: string): Promise<string | null> {
@@ -0,0 +1,87 @@
1
+ /**
2
+ * sync-docs --gate 的 vs HEAD 漂移判定(harness#189)
3
+ *
4
+ * 语义等价于流水线内联门(harness#120 方案 A):sync-docs 自愈写入之后,
5
+ * 被管理文档相对 HEAD 有 diff = HEAD 文档过期 → 判 fail;diff 新增行即缺登记名单。
6
+ * tracked 修改与 untracked 新建(本轮自愈补建的 CONTEXT.md / AGENTS.md)都算漂移。
7
+ */
8
+
9
+ import { execFileSync } from 'child_process';
10
+
11
+ /** --gate 判定结果 */
12
+ export interface HeadGateDrift {
13
+ /** 相对 HEAD 有变更的被管理文档(仓库相对路径,含 untracked 新建) */
14
+ files: string[];
15
+ /** CAPABILITIES.md diff 新增行(去 '+' 前缀;缺登记名单) */
16
+ capAdded: string[];
17
+ /** CAPABILITIES.md diff 删除行(去 '-' 前缀;幽灵剔除/计数更新等) */
18
+ capRemoved: string[];
19
+ }
20
+
21
+ function git(projectPath: string, args: string[]): string {
22
+ return execFileSync('git', ['-C', projectPath, ...args], {
23
+ encoding: 'utf-8',
24
+ maxBuffer: 16 * 1024 * 1024,
25
+ });
26
+ }
27
+
28
+ /**
29
+ * gate 前置校验:必须是 git 仓库且 HEAD 存在(vs HEAD 判定的前提),
30
+ * 不满足(git 缺失 / 非仓库 / 无提交)抛 Error,由命令侧译成 usage-error。
31
+ */
32
+ export function assertHeadGateEnv(projectPath: string): void {
33
+ try {
34
+ git(projectPath, ['rev-parse', '--verify', 'HEAD']);
35
+ } catch {
36
+ throw new Error('sync-docs --gate 需要 git 仓库且 HEAD 存在(vs HEAD 漂移判定)');
37
+ }
38
+ }
39
+
40
+ /**
41
+ * 判定被管理文档相对 HEAD 是否有变更。
42
+ * `git status --porcelain` 同时覆盖 tracked 修改与 untracked 新建;
43
+ * CAPABILITIES.md 有漂移时另取 diff 增删行作点名名单。
44
+ */
45
+ export function diffManagedDocsAgainstHead(projectPath: string, managedFiles: string[]): HeadGateDrift {
46
+ const status = git(projectPath, ['status', '--porcelain', '--', ...managedFiles]);
47
+ const files = status.split('\n').filter(Boolean).map((line) => {
48
+ let p = line.slice(3);
49
+ const arrow = p.indexOf(' -> ');
50
+ if (arrow >= 0) p = p.slice(arrow + 4);
51
+ return p;
52
+ });
53
+
54
+ const capAdded: string[] = [];
55
+ const capRemoved: string[] = [];
56
+ if (files.includes('CAPABILITIES.md')) {
57
+ const diff = git(projectPath, ['diff', 'HEAD', '--', 'CAPABILITIES.md']);
58
+ for (const line of diff.split('\n')) {
59
+ if (line.startsWith('+++') || line.startsWith('---')) continue;
60
+ if (line.startsWith('+')) capAdded.push(line.slice(1));
61
+ else if (line.startsWith('-')) capRemoved.push(line.slice(1));
62
+ }
63
+ }
64
+ return { files, capAdded, capRemoved };
65
+ }
66
+
67
+ /**
68
+ * 从 CAPABILITIES.md diff 新增行提取缺登记名单:
69
+ * 表格行取「文件」列(| 模块 | 文件 | 说明 |),非表格行(计数行等)取整行;
70
+ * 表头行与 |---| 分隔行是排版、不是登记条目,滤除。
71
+ */
72
+ export function missingRegistrationNames(addedLines: string[]): string[] {
73
+ const names: string[] = [];
74
+ for (const line of addedLines) {
75
+ const t = line.trim();
76
+ if (!t) continue;
77
+ if (t.startsWith('|')) {
78
+ const cells = t.split('|').map((c) => c.trim()).filter(Boolean);
79
+ if (cells.length > 0 && cells.every((c) => /^:?-+:?$/.test(c))) continue; // 分隔行
80
+ if (cells[0] === '模块' && cells[1] === '文件') continue; // 表头行
81
+ names.push(cells[1] ?? t);
82
+ } else {
83
+ names.push(t);
84
+ }
85
+ }
86
+ return [...new Set(names)];
87
+ }