@dommaker/harness 1.8.1 → 1.10.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 (299) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +10 -13
  3. package/dist/cli/commands/check.d.ts +3 -3
  4. package/dist/cli/commands/check.d.ts.map +1 -1
  5. package/dist/cli/commands/check.js +41 -78
  6. package/dist/cli/commands/check.js.map +1 -1
  7. package/dist/cli/commands/constraints-report.d.ts +2 -10
  8. package/dist/cli/commands/constraints-report.d.ts.map +1 -1
  9. package/dist/cli/commands/constraints-report.js +4 -57
  10. package/dist/cli/commands/constraints-report.js.map +1 -1
  11. package/dist/cli/commands/constraints-retire.d.ts +9 -23
  12. package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
  13. package/dist/cli/commands/constraints-retire.js +39 -121
  14. package/dist/cli/commands/constraints-retire.js.map +1 -1
  15. package/dist/cli/commands/constraints.d.ts +3 -8
  16. package/dist/cli/commands/constraints.d.ts.map +1 -1
  17. package/dist/cli/commands/constraints.js +8 -23
  18. package/dist/cli/commands/constraints.js.map +1 -1
  19. package/dist/cli/commands/definitions.js +2 -2
  20. package/dist/cli/commands/init.d.ts +0 -32
  21. package/dist/cli/commands/init.d.ts.map +1 -1
  22. package/dist/cli/commands/init.js +7 -149
  23. package/dist/cli/commands/init.js.map +1 -1
  24. package/dist/cli/commands/report.d.ts.map +1 -1
  25. package/dist/cli/commands/report.js +14 -17
  26. package/dist/cli/commands/report.js.map +1 -1
  27. package/dist/cli/commands/scaffold-templates.d.ts +0 -2
  28. package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
  29. package/dist/cli/commands/scaffold-templates.js +2 -37
  30. package/dist/cli/commands/scaffold-templates.js.map +1 -1
  31. package/dist/cli/commands/scaffold.d.ts +0 -2
  32. package/dist/cli/commands/scaffold.d.ts.map +1 -1
  33. package/dist/cli/commands/scaffold.js +0 -10
  34. package/dist/cli/commands/scaffold.js.map +1 -1
  35. package/dist/cli/commands/status.js +10 -10
  36. package/dist/cli/commands/status.js.map +1 -1
  37. package/dist/cli/commands/sync-docs/agents-syncer.d.ts +0 -2
  38. package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
  39. package/dist/cli/commands/sync-docs/agents-syncer.js +4 -23
  40. package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
  41. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +22 -0
  42. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
  43. package/dist/cli/commands/sync-docs/capabilities-syncer.js +113 -8
  44. package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
  45. package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
  46. package/dist/cli/commands/sync-docs/index.js +36 -4
  47. package/dist/cli/commands/sync-docs/index.js.map +1 -1
  48. package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
  49. package/dist/core/constraints/capabilities-parser.js +16 -4
  50. package/dist/core/constraints/capabilities-parser.js.map +1 -1
  51. package/dist/core/constraints/checker.d.ts +15 -24
  52. package/dist/core/constraints/checker.d.ts.map +1 -1
  53. package/dist/core/constraints/checker.js +33 -72
  54. package/dist/core/constraints/checker.js.map +1 -1
  55. package/dist/core/constraints/checkers/docs-freshness.js +1 -1
  56. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  57. package/dist/core/constraints/checkers/governance-presence.d.ts +2 -1
  58. package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
  59. package/dist/core/constraints/checkers/governance-presence.js +4 -3
  60. package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
  61. package/dist/core/constraints/checkers/index.d.ts +1 -1
  62. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  63. package/dist/core/constraints/checkers/index.js +4 -8
  64. package/dist/core/constraints/checkers/index.js.map +1 -1
  65. package/dist/core/constraints/checkers/iron-flags.d.ts +3 -4
  66. package/dist/core/constraints/checkers/iron-flags.d.ts.map +1 -1
  67. package/dist/core/constraints/checkers/iron-flags.js +4 -5
  68. package/dist/core/constraints/checkers/iron-flags.js.map +1 -1
  69. package/dist/core/constraints/checkers/no-test-simplification.js +1 -1
  70. package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
  71. package/dist/core/constraints/checkers/types.d.ts +1 -1
  72. package/dist/core/constraints/checkers/types.js +1 -1
  73. package/dist/core/constraints/definitions/guidelines.d.ts +4 -4
  74. package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
  75. package/dist/core/constraints/definitions/guidelines.js +9 -25
  76. package/dist/core/constraints/definitions/guidelines.js.map +1 -1
  77. package/dist/core/constraints/definitions/iron-laws.d.ts +4 -4
  78. package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
  79. package/dist/core/constraints/definitions/iron-laws.js +10 -81
  80. package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
  81. package/dist/core/constraints/definitions.d.ts +7 -9
  82. package/dist/core/constraints/definitions.d.ts.map +1 -1
  83. package/dist/core/constraints/definitions.js +13 -16
  84. package/dist/core/constraints/definitions.js.map +1 -1
  85. package/dist/core/constraints/index.d.ts +2 -5
  86. package/dist/core/constraints/index.d.ts.map +1 -1
  87. package/dist/core/constraints/index.js +3 -13
  88. package/dist/core/constraints/index.js.map +1 -1
  89. package/dist/core/constraints/injection-writer.d.ts +10 -38
  90. package/dist/core/constraints/injection-writer.d.ts.map +1 -1
  91. package/dist/core/constraints/injection-writer.js +17 -54
  92. package/dist/core/constraints/injection-writer.js.map +1 -1
  93. package/dist/core/constraints/run-env.d.ts +1 -10
  94. package/dist/core/constraints/run-env.d.ts.map +1 -1
  95. package/dist/core/constraints/run-env.js +1 -22
  96. package/dist/core/constraints/run-env.js.map +1 -1
  97. package/dist/core/constraints/usage-report.d.ts +5 -7
  98. package/dist/core/constraints/usage-report.d.ts.map +1 -1
  99. package/dist/core/constraints/usage-report.js +5 -10
  100. package/dist/core/constraints/usage-report.js.map +1 -1
  101. package/dist/core/effective-constraints.d.ts +12 -22
  102. package/dist/core/effective-constraints.d.ts.map +1 -1
  103. package/dist/core/effective-constraints.js +13 -30
  104. package/dist/core/effective-constraints.js.map +1 -1
  105. package/dist/core/index.d.ts +2 -2
  106. package/dist/core/index.d.ts.map +1 -1
  107. package/dist/core/index.js +3 -9
  108. package/dist/core/index.js.map +1 -1
  109. package/dist/core/project-config-loader.d.ts +4 -42
  110. package/dist/core/project-config-loader.d.ts.map +1 -1
  111. package/dist/core/project-config-loader.js +16 -125
  112. package/dist/core/project-config-loader.js.map +1 -1
  113. package/dist/core/validators/passes-gate.d.ts +2 -2
  114. package/dist/core/validators/passes-gate.js +6 -6
  115. package/dist/core/validators/passes-gate.js.map +1 -1
  116. package/dist/hooks/bootstrap.d.ts +9 -12
  117. package/dist/hooks/bootstrap.d.ts.map +1 -1
  118. package/dist/hooks/bootstrap.js +9 -31
  119. package/dist/hooks/bootstrap.js.map +1 -1
  120. package/dist/hooks/index.d.ts +5 -7
  121. package/dist/hooks/index.d.ts.map +1 -1
  122. package/dist/hooks/index.js +4 -10
  123. package/dist/hooks/index.js.map +1 -1
  124. package/dist/index.d.ts +9 -12
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +10 -23
  127. package/dist/index.js.map +1 -1
  128. package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
  129. package/dist/monitoring/trace-analyzer.js +11 -12
  130. package/dist/monitoring/trace-analyzer.js.map +1 -1
  131. package/dist/monitoring/traces.d.ts +4 -4
  132. package/dist/monitoring/traces.d.ts.map +1 -1
  133. package/dist/monitoring/traces.js +8 -8
  134. package/dist/monitoring/traces.js.map +1 -1
  135. package/dist/presets/standard.d.ts +8 -10
  136. package/dist/presets/standard.d.ts.map +1 -1
  137. package/dist/presets/standard.js +10 -16
  138. package/dist/presets/standard.js.map +1 -1
  139. package/dist/types/constraint.d.ts +24 -35
  140. package/dist/types/constraint.d.ts.map +1 -1
  141. package/dist/types/constraint.js +8 -7
  142. package/dist/types/constraint.js.map +1 -1
  143. package/dist/types/passes-gate.d.ts +5 -5
  144. package/dist/types/passes-gate.d.ts.map +1 -1
  145. package/dist/types/project-config.d.ts +8 -66
  146. package/dist/types/project-config.d.ts.map +1 -1
  147. package/dist/types/project-config.js +3 -2
  148. package/dist/types/project-config.js.map +1 -1
  149. package/dist/types/trace.d.ts +8 -10
  150. package/dist/types/trace.d.ts.map +1 -1
  151. package/package.json +2 -2
  152. package/src/CONTEXT.md +3 -3
  153. package/src/__tests__/checker-extra.test.ts +37 -61
  154. package/src/__tests__/checker.test.ts +10 -115
  155. package/src/__tests__/effective-constraints.test.ts +18 -83
  156. package/src/__tests__/iron-laws.test.ts +71 -90
  157. package/src/__tests__/passes-gate-check.test.ts +2 -2
  158. package/src/__tests__/project-config-loader-extra.test.ts +22 -123
  159. package/src/__tests__/project-config-loader.test.ts +5 -33
  160. package/src/__tests__/public-exports.test.ts +31 -11
  161. package/src/__tests__/public-type-surface.test.ts +2 -13
  162. package/src/__tests__/public-value-surface.test.ts +1 -7
  163. package/src/__tests__/skip-semantics.test.ts +21 -37
  164. package/src/__tests__/trace-analyzer-extra.test.ts +14 -14
  165. package/src/__tests__/trace-analyzer.test.ts +21 -21
  166. package/src/__tests__/trace-collector.test.ts +22 -22
  167. package/src/__tests__/traces.test.ts +27 -28
  168. package/src/cli/commands/CONTEXT.md +12 -9
  169. package/src/cli/commands/__tests__/check-read-count.test.ts +4 -15
  170. package/src/cli/commands/__tests__/check-skip-output.test.ts +14 -14
  171. package/src/cli/commands/__tests__/check.test.ts +14 -31
  172. package/src/cli/commands/__tests__/constraints-report.test.ts +12 -80
  173. package/src/cli/commands/__tests__/constraints-retire.test.ts +42 -231
  174. package/src/cli/commands/__tests__/init-governance-io.test.ts +12 -58
  175. package/src/cli/commands/__tests__/init-ondisk.test.ts +12 -20
  176. package/src/cli/commands/__tests__/init.test.ts +0 -11
  177. package/src/cli/commands/__tests__/project-path-anchoring.test.ts +2 -2
  178. package/src/cli/commands/__tests__/registry.test.ts +39 -3
  179. package/src/cli/commands/__tests__/report-extra.test.ts +4 -4
  180. package/src/cli/commands/__tests__/report.test.ts +1 -1
  181. package/src/cli/commands/__tests__/scaffold.test.ts +4 -14
  182. package/src/cli/commands/__tests__/status-analysis-wiring.test.ts +3 -3
  183. package/src/cli/commands/__tests__/status-extra.test.ts +14 -14
  184. package/src/cli/commands/__tests__/status.test.ts +12 -12
  185. package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -1
  186. package/src/cli/commands/__tests__/sync-docs-table-layout.test.ts +259 -0
  187. package/src/cli/commands/check.ts +43 -82
  188. package/src/cli/commands/constraints-report.ts +4 -59
  189. package/src/cli/commands/constraints-retire.ts +49 -154
  190. package/src/cli/commands/constraints.ts +11 -26
  191. package/src/cli/commands/definitions.ts +2 -2
  192. package/src/cli/commands/init.ts +8 -179
  193. package/src/cli/commands/report.ts +19 -23
  194. package/src/cli/commands/scaffold-templates.ts +1 -37
  195. package/src/cli/commands/scaffold.ts +0 -11
  196. package/src/cli/commands/status.ts +10 -10
  197. package/src/cli/commands/sync-docs/agents-syncer.ts +4 -25
  198. package/src/cli/commands/sync-docs/capabilities-syncer.ts +139 -9
  199. package/src/cli/commands/sync-docs/index.ts +41 -4
  200. package/src/core/CONTEXT.md +9 -9
  201. package/src/core/constraints/__tests__/capability-counts.test.ts +5 -5
  202. package/src/core/constraints/__tests__/collect-constraints.test.ts +13 -8
  203. package/src/core/constraints/__tests__/git-evidence.test.ts +4 -7
  204. package/src/core/constraints/__tests__/injection-writer.test.ts +8 -61
  205. package/src/core/constraints/__tests__/run-env.test.ts +5 -34
  206. package/src/core/constraints/__tests__/trace-injection.test.ts +1 -1
  207. package/src/core/constraints/capabilities-parser.ts +17 -5
  208. package/src/core/constraints/checker.ts +39 -88
  209. package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +5 -8
  210. package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -53
  211. package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +5 -25
  212. package/src/core/constraints/checkers/docs-freshness.ts +1 -1
  213. package/src/core/constraints/checkers/governance-presence.ts +4 -3
  214. package/src/core/constraints/checkers/index.ts +4 -10
  215. package/src/core/constraints/checkers/iron-flags.ts +3 -12
  216. package/src/core/constraints/checkers/no-test-simplification.ts +1 -1
  217. package/src/core/constraints/checkers/types.ts +1 -1
  218. package/src/core/constraints/definitions/guidelines.ts +8 -25
  219. package/src/core/constraints/definitions/iron-laws.ts +9 -82
  220. package/src/core/constraints/definitions.ts +14 -15
  221. package/src/core/constraints/index.ts +4 -19
  222. package/src/core/constraints/injection-writer.ts +16 -61
  223. package/src/core/constraints/run-env.ts +1 -33
  224. package/src/core/constraints/usage-report.ts +8 -15
  225. package/src/core/effective-constraints.ts +14 -45
  226. package/src/core/index.ts +3 -10
  227. package/src/core/project-config-loader.ts +20 -145
  228. package/src/core/validators/passes-gate.ts +6 -6
  229. package/src/failure/CONTEXT.md +1 -1
  230. package/src/hooks/CONTEXT.md +12 -22
  231. package/src/hooks/__tests__/bootstrap.test.ts +24 -75
  232. package/src/hooks/bootstrap.ts +9 -48
  233. package/src/hooks/index.ts +5 -20
  234. package/src/index.ts +9 -31
  235. package/src/monitoring/__tests__/trace-file-anchoring.test.ts +1 -1
  236. package/src/monitoring/__tests__/traces.test.ts +22 -22
  237. package/src/monitoring/trace-analyzer.ts +12 -13
  238. package/src/monitoring/traces.ts +8 -8
  239. package/src/presets/__tests__/standard.test.ts +12 -16
  240. package/src/presets/standard.ts +14 -23
  241. package/src/types/__tests__/types.test.ts +3 -3
  242. package/src/types/constraint.ts +26 -40
  243. package/src/types/passes-gate.ts +5 -5
  244. package/src/types/project-config.ts +8 -77
  245. package/src/types/trace.ts +8 -11
  246. package/dist/core/constraints/agent-prompt-renderer.d.ts +0 -32
  247. package/dist/core/constraints/agent-prompt-renderer.d.ts.map +0 -1
  248. package/dist/core/constraints/agent-prompt-renderer.js +0 -55
  249. package/dist/core/constraints/agent-prompt-renderer.js.map +0 -1
  250. package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts +0 -6
  251. package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts.map +0 -1
  252. package/dist/core/constraints/checkers/no-bypass-checkpoint.js +0 -40
  253. package/dist/core/constraints/checkers/no-bypass-checkpoint.js.map +0 -1
  254. package/dist/core/constraints/definitions/prompts.d.ts +0 -12
  255. package/dist/core/constraints/definitions/prompts.d.ts.map +0 -1
  256. package/dist/core/constraints/definitions/prompts.js +0 -400
  257. package/dist/core/constraints/definitions/prompts.js.map +0 -1
  258. package/dist/core/constraints/injection-drift.d.ts +0 -61
  259. package/dist/core/constraints/injection-drift.d.ts.map +0 -1
  260. package/dist/core/constraints/injection-drift.js +0 -131
  261. package/dist/core/constraints/injection-drift.js.map +0 -1
  262. package/dist/core/constraints/injection-renderer.d.ts +0 -23
  263. package/dist/core/constraints/injection-renderer.d.ts.map +0 -1
  264. package/dist/core/constraints/injection-renderer.js +0 -44
  265. package/dist/core/constraints/injection-renderer.js.map +0 -1
  266. package/dist/hooks/config.d.ts +0 -30
  267. package/dist/hooks/config.d.ts.map +0 -1
  268. package/dist/hooks/config.js +0 -34
  269. package/dist/hooks/config.js.map +0 -1
  270. package/dist/hooks/pipeline.d.ts +0 -54
  271. package/dist/hooks/pipeline.d.ts.map +0 -1
  272. package/dist/hooks/pipeline.js +0 -173
  273. package/dist/hooks/pipeline.js.map +0 -1
  274. package/dist/hooks/registry.d.ts +0 -70
  275. package/dist/hooks/registry.d.ts.map +0 -1
  276. package/dist/hooks/registry.js +0 -141
  277. package/dist/hooks/registry.js.map +0 -1
  278. package/dist/hooks/types.d.ts +0 -113
  279. package/dist/hooks/types.d.ts.map +0 -1
  280. package/dist/hooks/types.js +0 -9
  281. package/dist/hooks/types.js.map +0 -1
  282. package/src/__tests__/hooks-pipeline.test.ts +0 -201
  283. package/src/cli/commands/__tests__/check-drift.test.ts +0 -158
  284. package/src/cli/commands/__tests__/init-injection.test.ts +0 -466
  285. package/src/core/constraints/__tests__/agent-prompt-renderer.test.ts +0 -129
  286. package/src/core/constraints/__tests__/injection-drift.test.ts +0 -247
  287. package/src/core/constraints/agent-prompt-renderer.ts +0 -67
  288. package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +0 -76
  289. package/src/core/constraints/checkers/no-bypass-checkpoint.ts +0 -40
  290. package/src/core/constraints/definitions/prompts.ts +0 -414
  291. package/src/core/constraints/injection-drift.ts +0 -142
  292. package/src/core/constraints/injection-renderer.ts +0 -44
  293. package/src/hooks/__tests__/config.test.ts +0 -19
  294. package/src/hooks/__tests__/pipeline.test.ts +0 -195
  295. package/src/hooks/__tests__/registry.test.ts +0 -115
  296. package/src/hooks/config.ts +0 -33
  297. package/src/hooks/pipeline.ts +0 -202
  298. package/src/hooks/registry.ts +0 -166
  299. package/src/hooks/types.ts +0 -120
@@ -1,26 +1,22 @@
1
1
  /**
2
- * 生效约束集(ADR-0001)
2
+ * 生效约束集(ADR-0029,链路承自 ADR-0001)
3
3
  *
4
4
  * `getEffectiveConstraints(projectRoot)` 是全仓唯一的生效集来源:
5
- * 内置 → preset → config.yml 禁用 → custom 追加 → scenes 过滤。
6
- * init 注入、`harness check`、外部消费者(studio 等)全部消费它,
7
- * 不再直接读 IRON_LAWS/GUIDELINES/PROMPTS 全集。
5
+ * 内置 → preset → config.yml 禁用。
6
+ * `harness check`、外部消费者(studio 等)全部消费它,
7
+ * 不再直接读 CONSTRAINTS 全集。
8
8
  */
9
9
 
10
10
  import type { Constraint } from '../types/constraint';
11
11
  import type { MergedConstraintsConfig } from '../types/project-config';
12
- import { PROMPTS } from './constraints/definitions';
13
12
  import { ProjectConfigLoader } from './project-config-loader';
14
13
  import type { RunTarget } from './constraints/run-env';
15
14
 
16
15
  /**
17
- * 获取项目当前生效的约束集(check + prompt,带 kind)
16
+ * 获取项目当前生效的约束集(check 全量,带 kind/severity
18
17
  *
19
18
  * 生效集链路同 getMergedConstraintsConfig:内置 → preset 裁剪 → config.yml
20
- * `constraints.<id>.enabled:false` 删除(内置与 custom 同效)→ custom-constraints
21
- * 追加(禁用/已退役的 custom 不追加)→ scenes 过滤
22
- * (带 appliesTo 的 prompt 仅当 config.yml `scenes` 与其交集非空时保留,
23
- * 缺省 scenes=[] 即场景专属 prompt 默认不进入生效集)。
19
+ * `constraints.<id>.enabled:false` 删除。
24
20
  *
25
21
  * @param target 项目根路径,或本 run 的运行级观察面(缺省 process.cwd())
26
22
  * 传观察面 = config.yml 读取与本 run 其余消费方共用同一份(ADR-0023 决策 2)
@@ -37,22 +33,18 @@ export function getEffectiveConstraints(
37
33
  /**
38
34
  * 从已算好的合并配置取出生效集清单(与 getEffectiveConstraints 同一形状)
39
35
  *
40
- * 给已经持有 `MergedConstraintsConfig` 的消费方复用(CLI check 把这一份同时交给
41
- * 漂移检测,避免生效集链路在一次运行里算两遍,ADR-0023 步骤 4.5)。
36
+ * 给已经持有 `MergedConstraintsConfig` 的消费方复用(CLI check 复用这一份,
37
+ * 避免生效集链路在一次运行里算两遍,ADR-0023 步骤 4.5)。
42
38
  */
43
39
  export function constraintsFromMerged(merged: MergedConstraintsConfig): Constraint[] {
44
- return [
45
- ...Object.values(merged.ironLaws),
46
- ...Object.values(merged.guidelines),
47
- ...Object.values(merged.prompts ?? {}),
48
- ];
40
+ return Object.values(merged.constraints);
49
41
  }
50
42
 
51
43
  /**
52
- * 获取项目当前生效的合并约束配置(ADR-0001 唯一来源的完整形状)
44
+ * 获取项目当前生效的合并约束配置(唯一来源的完整形状)
53
45
  *
54
46
  * 与 getEffectiveConstraints 同一生效集链路,返回完整 MergedConstraintsConfig
55
- * (含 disabled/custom/unknownIds),供 check 等需要诊断信息的消费方使用。
47
+ * (含 disabled/unknownIds),供 check 等需要诊断信息的消费方使用。
56
48
  *
57
49
  * options.preset(CLI --preset)仅在项目无自定义配置时覆盖 config.yml 的
58
50
  * preset(工单 23 语义:项目自定义配置优先于 CLI 预设);不传 preset 时
@@ -77,24 +69,15 @@ export function getMergedConstraintsConfig(
77
69
  */
78
70
  export interface EffectiveConfigLint {
79
71
  /**
80
- * config.yml `constraints.<id>` 中既非内置也非自定义的未知 id
72
+ * config.yml `constraints.<id>` 中非内置的未知 id
81
73
  * (如禁用了已被本版移除的约束的残留配置)。生效集计算静默忽略,
82
74
  * 在此列出供 report 提示。
83
75
  */
84
76
  unknownIds: string[];
85
-
86
- /** 项目配置的场景标签(config.yml `scenes`,缺省 []) */
87
- scenes: string[];
88
-
89
- /**
90
- * 因 scenes 过滤而未进入生效集的场景专属 prompt id
91
- * (已被 preset/config 禁用的不重复列出)
92
- */
93
- sceneExcluded: string[];
94
77
  }
95
78
 
96
79
  /**
97
- * 诊断项目约束配置:未知 id 残留、scenes 生效情况
80
+ * 诊断项目约束配置:未知 id 残留
98
81
  *
99
82
  * 不抛错、不修改任何文件,供 report / check 的诊断输出使用。
100
83
  *
@@ -102,23 +85,9 @@ export interface EffectiveConfigLint {
102
85
  */
103
86
  export function lintEffectiveConfig(projectRoot: string = process.cwd()): EffectiveConfigLint {
104
87
  const loader = new ProjectConfigLoader(projectRoot);
105
- const config = loader.load();
88
+ loader.load();
106
89
  const merged = loader.mergeConstraints();
107
- const scenes = config.scenes ?? [];
108
-
109
- const sceneExcluded = Object.values(PROMPTS)
110
- .filter(
111
- c =>
112
- c.appliesTo &&
113
- c.appliesTo.length > 0 &&
114
- !c.appliesTo.some(scene => scenes.includes(scene)) &&
115
- !merged.disabled.includes(c.id)
116
- )
117
- .map(c => c.id);
118
-
119
90
  return {
120
91
  unknownIds: merged.unknownIds ?? [],
121
- scenes,
122
- sceneExcluded,
123
92
  };
124
93
  }
package/src/core/index.ts CHANGED
@@ -5,11 +5,9 @@
5
5
  * 不再暴露位置参数版。
6
6
  */
7
7
 
8
- // 约束系统(三层:Iron Laws / Guidelines / Tips
8
+ // 约束系统(severity 显式模型,ADR-0029
9
9
  export {
10
- IRON_LAWS,
11
- GUIDELINES,
12
- PROMPTS,
10
+ CONSTRAINTS,
13
11
  getAllConstraints,
14
12
  findConstraintsByTrigger,
15
13
  getConstraint,
@@ -18,21 +16,16 @@ export {
18
16
  checkConstraints,
19
17
  checkBeforeExecution,
20
18
  constraintChecker,
21
- CONSTRAINTS_START_MARKER,
22
- CONSTRAINTS_END_MARKER,
23
- renderConstraintsSection,
24
19
  CheckCache,
25
- renderConstraintsByTrigger,
26
20
  ConstraintViolationError,
27
21
  } from './constraints';
28
22
  export type {
29
23
  CheckConstraintsOptions,
30
24
  CheckCacheConfig,
31
25
  CheckSamplingConfig,
32
- RenderConstraintsByTriggerOptions,
33
26
  ConstraintId,
34
27
  ConstraintKind,
35
- ConstraintLevel,
28
+ ConstraintSeverity,
36
29
  ConstraintTrigger,
37
30
  Constraint,
38
31
  ConstraintResult,
@@ -6,15 +6,14 @@
6
6
  * ADR-0023 决策 2),一次运行内各至多读一次。
7
7
  */
8
8
 
9
- import type { Constraint, ConstraintTrigger } from '../types/constraint';
9
+ import type { Constraint } from '../types/constraint';
10
10
  import type {
11
11
  ProjectConfig,
12
- CustomConstraintDefinition,
13
12
  MergedConstraintsConfig,
14
13
  CapabilitiesConfig,
15
14
  GovernanceConfig,
16
15
  } from '../types/project-config';
17
- import { IRON_LAWS, GUIDELINES, PROMPTS } from './constraints/definitions';
16
+ import { CONSTRAINTS } from './constraints/definitions';
18
17
  import { PRESETS_BY_NAME, STANDARD_PRESET } from '../presets';
19
18
  import { filterEnabledEntries } from './effective-set';
20
19
  import { resolveRunEnv, type RunEnv, type RunTarget } from './constraints/run-env';
@@ -24,7 +23,6 @@ import { resolveRunEnv, type RunEnv, type RunTarget } from './constraints/run-en
24
23
  */
25
24
  const DEFAULT_CONFIG: ProjectConfig = {
26
25
  preset: 'standard',
27
- custom_constraints_file: 'custom-constraints.yml',
28
26
  };
29
27
 
30
28
  /**
@@ -103,25 +101,6 @@ export function getCapabilitiesMode(target: RunTarget): CapabilitiesMode {
103
101
  return 'file';
104
102
  }
105
103
 
106
- /**
107
- * 退役判定单点(studio#82 D6 一处真相)
108
- *
109
- * 两个落点合成一条规则:禁用(config.yml `constraints.<id>.enabled: false`,内置约束的
110
- * 退役落点)或 custom 条目自带 `retired` 元数据(custom 约束的退役落点,不拆 config.yml
111
- * 第二处)。`mergeConstraints` 的 custom 追加跳过与 `harness constraints retire` 的
112
- * already_retired 检查共用本函数——后者此前是这条规则的手写复印(harness#137 收口)。
113
- *
114
- * `disabled` 由调用方给:mergeConstraints 传的是含 preset 裁剪的完整禁用集,
115
- * retire 传的是 config.yml 单点(退役落点只有这一处,preset 语义不掺进退役判定)。
116
- * `retired` 按 truthiness 判,与 mergeConstraints 历史口径逐字一致。
117
- */
118
- export function isConstraintRetired(
119
- customDef: { retired?: unknown } | undefined,
120
- disabled: boolean
121
- ): boolean {
122
- return disabled || Boolean(customDef?.retired);
123
- }
124
-
125
104
  /**
126
105
  * 项目配置加载器
127
106
  */
@@ -129,7 +108,6 @@ export class ProjectConfigLoader {
129
108
  private env: RunEnv;
130
109
  private projectPath: string;
131
110
  private config: ProjectConfig;
132
- private customConstraints: Record<string, CustomConstraintDefinition>;
133
111
 
134
112
  /**
135
113
  * @param target 项目根路径,或本 run 已构造的运行级观察面(ADR-0023 决策 2)
@@ -139,51 +117,23 @@ export class ProjectConfigLoader {
139
117
  this.env = resolveRunEnv(target);
140
118
  this.projectPath = this.env.projectPath;
141
119
  this.config = { ...DEFAULT_CONFIG };
142
- this.customConstraints = {};
143
120
  }
144
121
 
145
122
  /**
146
- * 加载项目配置
123
+ * 加载项目配置(run 内 memo 在观察面上,同一份解析结果供全部消费方共用)
147
124
  */
148
125
  load(): ProjectConfig {
149
- // 1. 加载主配置(run 内 memo 在观察面上,同一份解析结果供全部消费方共用)
150
126
  const raw = this.env.rawConfig();
151
127
  if (raw) {
152
128
  this.config = { ...DEFAULT_CONFIG, ...(raw as Partial<ProjectConfig>) };
153
129
  }
154
-
155
- // 2. 加载自定义约束
156
- this.loadCustomConstraints();
157
-
158
130
  return this.config;
159
131
  }
160
132
 
161
133
  /**
162
- * 加载自定义约束
163
- *
164
- * 文件读取经观察面(ADR-0023 决策 2):同一次运行内多个加载器共用同一份内容,
165
- * 「哪个文件名算数」与合并顺序仍由本函数决定(方式 1 文件 → 方式 2 主配置内联,后者覆盖)。
166
- */
167
- private loadCustomConstraints(): void {
168
- // 方式 1:从单独文件加载
169
- if (this.config.custom_constraints_file) {
170
- const defs = this.env.customConstraints(this.config.custom_constraints_file);
171
- this.customConstraints = { ...this.customConstraints, ...defs };
172
- }
173
-
174
- // 方式 2:从主配置文件中加载
175
- if (this.config.custom_constraints) {
176
- this.customConstraints = { ...this.customConstraints, ...this.config.custom_constraints };
177
- }
178
- }
179
-
180
- /**
181
- * 合并内置约束和自定义约束(ADR-0001 生效集完整链路)
134
+ * 合并内置约束(生效集完整链路,ADR-0029)
182
135
  *
183
- * 合并顺序:内置 → preset 裁剪 → config.yml `constraints.<id>.enabled:false`
184
- * 删除(对内置与 custom 同效)→ custom-constraints 追加
185
- * (禁用/已退役的 custom 不追加)→ scenes 过滤
186
- * (带 appliesTo 的 prompt 仅当 scenes 交集非空时保留)。
136
+ * 合并顺序:内置 → preset 裁剪 → config.yml `constraints.<id>.enabled:false` 删除。
187
137
  *
188
138
  * config.yml 中未知约束 id(如已移除约束的禁用残留)静默忽略,
189
139
  * 记录在结果 unknownIds 中供诊断。
@@ -199,6 +149,9 @@ export class ProjectConfigLoader {
199
149
  console.error(`[harness] 未知预设 "${presetName}",已回落 standard`);
200
150
  preset = STANDARD_PRESET;
201
151
  }
152
+ // preset 按 severity 分键;展开为「id → 是否启用」的单桶视图
153
+ const bySeverity = (severity: 'error' | 'warning'): Record<string, Constraint> =>
154
+ Object.fromEntries(Object.entries(CONSTRAINTS).filter(([, c]) => c.severity === severity));
202
155
  const pick = (
203
156
  source: Record<string, Constraint>,
204
157
  ids: string[] | null
@@ -215,104 +168,36 @@ export class ProjectConfigLoader {
215
168
  ids: string[] | null
216
169
  ): string[] => (ids === null ? [] : Object.keys(source).filter(id => !ids.includes(id)));
217
170
 
171
+ const errorConstraints = bySeverity('error');
172
+ const warningConstraints = bySeverity('warning');
173
+
218
174
  const unknownIds: string[] = [];
219
175
  const result: MergedConstraintsConfig = {
220
- ironLaws: pick(IRON_LAWS, preset.ironLaws),
221
- guidelines: pick(GUIDELINES, preset.guidelines),
222
- prompts: pick(PROMPTS, preset.prompts),
176
+ constraints: {
177
+ ...pick(errorConstraints, preset.errors),
178
+ ...pick(warningConstraints, preset.warnings),
179
+ },
223
180
  disabled: [
224
- ...presetDisabled(IRON_LAWS, preset.ironLaws),
225
- ...presetDisabled(GUIDELINES, preset.guidelines),
226
- ...presetDisabled(PROMPTS, preset.prompts),
181
+ ...presetDisabled(errorConstraints, preset.errors),
182
+ ...presetDisabled(warningConstraints, preset.warnings),
227
183
  ],
228
- custom: [],
229
184
  unknownIds,
230
185
  };
231
186
 
232
187
  // 1. 处理启用/禁用配置(未知 id 静默忽略,记录供诊断)
233
188
  if (this.config.constraints) {
234
- const knownIds = new Set([
235
- ...Object.keys(IRON_LAWS),
236
- ...Object.keys(GUIDELINES),
237
- ...Object.keys(PROMPTS),
238
- ...Object.keys(this.customConstraints),
239
- ]);
189
+ const knownIds = new Set(Object.keys(CONSTRAINTS));
240
190
  const filtered = filterEnabledEntries(knownIds, this.config.constraints);
241
191
  unknownIds.push(...filtered.unknownIds);
242
192
  for (const constraintId of filtered.disabledIds) {
243
193
  result.disabled.push(constraintId);
244
- // 从对应层级中移除
245
- delete result.ironLaws[constraintId];
246
- delete result.guidelines[constraintId];
247
- delete result.prompts![constraintId];
248
- }
249
- }
250
-
251
- // 2. 添加自定义约束(config.yml 禁用的 id 不追加:step 1 已将其
252
- // 收集进 disabled,custom 在 step 1 时尚未入桶,须在此兜底跳过;
253
- // 条目带 retired 元数据的同样不追加——studio#82 D6 退役落点在条目自身)
254
- for (const [id, customDef] of Object.entries(this.customConstraints)) {
255
- if (isConstraintRetired(customDef, result.disabled.includes(id))) {
256
- continue;
257
- }
258
- const constraint = this.toConstraint(customDef, id);
259
-
260
- result.custom.push(id);
261
-
262
- const level = customDef.level || 'guideline';
263
- switch (level) {
264
- case 'iron_law':
265
- result.ironLaws[id] = constraint;
266
- break;
267
- case 'guideline':
268
- result.guidelines[id] = constraint;
269
- break;
270
- case 'prompt':
271
- result.prompts![id] = constraint;
272
- break;
273
- }
274
- }
275
-
276
- // 3. scenes 过滤(ADR-0001):带 appliesTo 标签的 prompt 仅当项目 scenes
277
- // 与其交集非空时保留;无 appliesTo 的条目不受影响。缺省 scenes=[] 即
278
- // 场景专属 prompt 默认不进入生效集。
279
- const scenes = this.config.scenes ?? [];
280
- for (const [id, constraint] of Object.entries(result.prompts!)) {
281
- if (
282
- constraint.appliesTo &&
283
- constraint.appliesTo.length > 0 &&
284
- !constraint.appliesTo.some(scene => scenes.includes(scene))
285
- ) {
286
- delete result.prompts![id];
194
+ delete result.constraints[constraintId];
287
195
  }
288
196
  }
289
197
 
290
198
  return result;
291
199
  }
292
200
 
293
- /**
294
- * 将自定义约束定义转换为 Constraint
295
- *
296
- * kind 推导(ADR-0001):自定义约束没有注册表中的 checker,统一归为
297
- * kind='prompt'(不执行 checker,check() 短路通过),level 仅决定其所在
298
- * 桶与严重性行为,保持与历史"未注册默认通过"相同的执行语义。
299
- */
300
- private toConstraint(def: CustomConstraintDefinition, defaultId: string): Constraint {
301
- const level = def.level || 'guideline';
302
- return {
303
- id: def.id || defaultId,
304
- kind: 'prompt',
305
- level,
306
- rule: def.rule || '',
307
- message: def.message || '',
308
- trigger: (def.trigger || 'manual') as ConstraintTrigger | ConstraintTrigger[],
309
- description: def.description,
310
- promptInjection: def.promptInjection,
311
- enabled: def.enabled !== false,
312
- enforcement: 'custom',
313
- };
314
- }
315
-
316
201
  /**
317
202
  * 获取当前配置
318
203
  */
@@ -320,20 +205,10 @@ export class ProjectConfigLoader {
320
205
  return this.config;
321
206
  }
322
207
 
323
- /**
324
- * 获取自定义约束
325
- */
326
- getCustomConstraints(): Record<string, CustomConstraintDefinition> {
327
- return this.customConstraints;
328
- }
329
-
330
208
  /**
331
209
  * 检查是否有自定义配置
332
210
  */
333
211
  hasCustomConfig(): boolean {
334
- return (
335
- Object.keys(this.customConstraints).length > 0 ||
336
- (this.config.constraints !== undefined && Object.keys(this.config.constraints).length > 0)
337
- );
212
+ return this.config.constraints !== undefined && Object.keys(this.config.constraints).length > 0;
338
213
  }
339
214
  }
@@ -97,7 +97,7 @@ export class PassesGate {
97
97
  * - 业务层自己运行测试,传入结果
98
98
  *
99
99
  * @param testResult 测试结果(由业务层运行测试后传入)
100
- * @returns 验证结果(是否允许标记完成 + Iron Law 违规)
100
+ * @returns 验证结果(是否允许标记完成 + 阻断级违规)
101
101
  *
102
102
  * @example
103
103
  * ```typescript
@@ -107,7 +107,7 @@ export class PassesGate {
107
107
  *
108
108
  * if (!passesResult.allowed) {
109
109
  * return res.status(400).json({
110
- * error: 'Iron Law 违规',
110
+ * error: '约束违规',
111
111
  * violations: passesResult.violations,
112
112
  * });
113
113
  * }
@@ -116,23 +116,23 @@ export class PassesGate {
116
116
  check(testResult: TestResult): PassesGateCheckResult {
117
117
  const violations: PassesGateViolation[] = [];
118
118
 
119
- // 1. 测试未通过 → Iron Law #2: NO SELF APPROVAL WITHOUT TEST EVIDENCE
119
+ // 1. 测试未通过 → NO SELF APPROVAL WITHOUT TEST EVIDENCE
120
120
  if (!testResult.passed) {
121
121
  violations.push({
122
122
  id: 'no_self_approval',
123
123
  rule: 'NO SELF APPROVAL WITHOUT TEST EVIDENCE',
124
124
  message: '测试未通过',
125
- level: 'iron_law',
125
+ severity: 'error',
126
126
  });
127
127
  }
128
128
 
129
- // 2. 缺少证据 → Iron Law #3: NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION
129
+ // 2. 缺少证据 → NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION
130
130
  if (this.config.requireEvidence && !testResult.evidence) {
131
131
  violations.push({
132
132
  id: 'no_completion_without_verification',
133
133
  rule: 'NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION',
134
134
  message: '缺少测试证据',
135
- level: 'iron_law',
135
+ severity: 'error',
136
136
  });
137
137
  }
138
138
 
@@ -22,6 +22,6 @@
22
22
  - 分类器基于规则匹配,不调用 LLM
23
23
  - S4 约束违规处理策略模块(ConstraintViolationHandler / executeWithBlock /
24
24
  executeWithCollect / executeWithSafeBoolean)已删除(架构评审候选1):
25
- COLLECT 对真实 checker 结构上不可交付(checker 首个铁律违规即 throw,
25
+ COLLECT 对真实 checker 结构上不可交付(checker 首个 error 级违规即 throw,
26
26
  handler 的 catch 只能吞证据造假绿)。语义归宿——阻断 = `checkConstraints` 本体,
27
27
  收集 = `checker.collectConstraints`(report 直调);BLOCK/SAFE_BOOLEAN 零生产消费者随迁
@@ -1,34 +1,24 @@
1
1
  # hooks/
2
2
 
3
3
  ## 职责
4
- 通用 Hook 管线:注册 → 排序 → 错误隔离 → 采样执行。无业务逻辑,consumer 自行定义 hook 名称和语义。
4
+ Harness 运行环境的组合根:一次调用装配起约束检查器、会话管理器与 trace 记录器,并加载项目配置。
5
5
 
6
- H5(#44)起增加两个机制(G2/G7):
7
- - **注册表闭环**:`assertHookRegistryClosed(configs, hooks)` 声明(HookConfig)↔ 实现(HookDefinition)双向校验——引用未注册/注册无定义/重复均抛错,复制 checker 闭环模式;断言限构建/测试期,不进运行时热路径
8
- - **配置归一**:`HookConfig { name, enabled, errorStrategy }` 为 per-hook 配置唯一真相,且自 #159 起是 `enabled` / `errorStrategy` 的**唯一声明点**——`HookDefinition` 不再携带这两个字段,注册环节以配置表填充有效值(`EffectiveHook`),声明一处、读取一处,两侧矛盾在构造上不可能出现;`toErrorStrategy(blocking)` 承载 studio `blocking` → errorStrategy 的无损映射
6
+ ADR-0027(#170)起本层只剩 bootstrap 一个面。原先的通用 hook 管线(`registry` / `pipeline` / `config` / `types` 四文件:注册 → 排序 → 错误隔离 → 采样执行)双仓零生产消费者,整体删除——裁决记录 `docs/adr/0027-hooks-pipeline-surface-trim.md`,事实前提 studio#562(studio 侧 hooks 层删除)。目录名沿用历史,不再表示「提供 hook 能力」。
9
7
 
10
8
  ## 核心导出
11
- - `HookRegistry` — Hook 注册表(register/registerAll/unregister/get/getEnabled/listNames/listAll/setEnabled/clear;register HookConfig 填充有效值)
12
- - `HookPipeline` — Hook 执行管线(注册/排序/错误隔离/采样;errorStrategy block/warn;`run(phase)` 时机粒度、`runFull` 全套、`runOne(name)` 按名执行单个 hook——#167 新增:enabled:false 返回 skipped:true 记录且实现体零调用,block 失败抛错 / warn 失败返回 passed:false 记录,未知名抛错(口径同注册表闭环),采样与错误隔离复用 executeOne 单路径)
13
- - `assertHookRegistryClosed` 注册表闭环双向校验(构建/测试期)
14
- - `HookConfig`(type)— per-hook 配置声明(enabled / errorStrategy 唯一声明点)
15
- - `EffectiveHook`(type)— HookDefinition + 配置填充的有效 enabled / errorStrategy(管线与注册表判定只读它)
16
- - `toErrorStrategy` — blocking → errorStrategy 无损映射(G7)
17
- - `bootstrapHarness` / `bootstrapHarnessSync` — Harness 启动引导;也是 trace 记录器的组合根:`new ConstraintChecker(new TraceCollector({ projectPath }))`(harness#88 接线,core 不上行依赖 monitoring,故由本层接线;#139 收根:两个入口本就收 projectPath,落点随之锚定,不再取 cwd 锚定的 `getTraceCollector()` 单例)
9
+ - `bootstrapHarness` — 异步组合根(S9:配置异步加载,不阻塞事件循环);也是 trace 记录器的接线点:`new ConstraintChecker(new TraceCollector({ projectPath }))`(harness#88:core 不上行依赖 monitoring,故由本层接线;#139 收根:两个入口本就收 projectPath,落点随之锚定,不再取 cwd 锚定的 `getTraceCollector()` 单例)
10
+ - `bootstrapHarnessSync` — 同形状的同步版,配置走 `readFileSync`,供不支持 top-level await 的环境与 `bootstrapHarness` 失败时的回落路径
11
+ - `HarnessBootstrap`(type)— 返回值形状 `{ checker, sessions, projectPath, mergedConstraints }`
18
12
 
19
13
  ## 依赖关系
20
- - 类型正本在**本模块** `src/hooks/types.ts`(`HookPhase`/`HookErrorStrategy`/`HookConfig`/`HookDefinition`/`EffectiveHook`/`HookResult`/`PipelineResult`);`src/types/` 里没有 hook 类型,本层只从 `src/types/project-config` 取 `MergedConstraintsConfig` 类型
21
- - 向下依赖(仅 `bootstrap.ts` 组合根):`core/constraints/checker`、`core/project-config-loader`、`context/session-manager`、`monitoring/traces`——`registry/pipeline/config/types` 四文件零上层依赖,是纯管线
22
- - 消费方:包根 `src/index.ts` 的 `./hooks` 出口与下游项目(studio 的 hook 装配)。**harness 内部无生产消费方**——core/cli 侧的调用边已随零消费者清账删除(harness#141 同判据,ADR-0022),「被 core 核心引擎/CLI 初始化流程消费」的旧说法已失效(harness#142 核对)
14
+ - 向下依赖:`core/constraints/checker`、`core/project-config-loader`、`context/session-manager`、`monitoring/traces`;类型面只从 `src/types/project-config` 取 `MergedConstraintsConfig`
15
+ - 消费方:包根 `src/index.ts` 的 bootstrap 三符号出口,与下游项目的运行环境初始化。生产唯一调用方是 studio(经 studio-shared `runtime/bootstrap.ts`,**无参调用**、只以类型持有 `HarnessBootstrap`)。**harness 内部无生产消费方**——core/cli 侧的调用边已随零消费者清账删除(harness#141 同判据,ADR-0022)
23
16
 
24
17
  ## 约定
25
- - 无业务逻辑,只提供管线能力
26
- - Consumer 自行定义 hook 名称和触发时机
27
- - **闭环**:声明配置与注册实现必须一一对应,缺一抛错(消灭「hook 定义不注册 = 死代码」类人记规矩)
28
- - **映射语义**:blocking=true → 'block'(失败阻断管线,停止后续 hook、passed=false);blocking=false → 'warn'(记录警告继续);有效策略集合仅 'block' | 'warn'(#159 起原 'ignore' 与「未声明 strategy」形态退出有效面——策略由 HookConfig 必填声明)
29
- - 错误隔离:单个 hook 失败不影响其他 hook
18
+ - 参数面只有 `projectPath`(缺省 `process.cwd()`):不给 hook 定义、不给配置表,`hookDefinitions` / `hookConfigs` 与注册闭环语义随管线面一同退场
19
+ - 组合根只做装配不做判定,`mergedConstraints` 原样透出,用不用由调用方决定
20
+ - 本层无内置 hook 定义,也不再提供 hook 管线能力;provider 侧的 PreToolUse 执法入口是 `src/pretool-use-hook.ts`(门禁 CLI 的另一条路),与本目录无关
30
21
 
31
22
  ## 注意事项
32
- - 通用管线设计,不绑定特定生命周期
33
- - 采样执行用于高频 hook(减少性能影响)
34
- - 闭环断言是纯函数,由 consumer 在其注册点/测试中调用;harness 无内置 hook 定义,不自动断言
23
+ - 无 unload/dispose:`SessionManager` 与 `TraceCollector` 随进程生命周期,本层不提供逆操作(口径同 `src/CONTEXT.md` 术语「文件驱动 CLI」)
24
+ - 删除属公共面 breaking:包根不再可达的符号有 4 个值符号(注册表、管线、闭环断言、blocking 映射)与 8 个类型,迁移路径 = 删引用;可达性负钉在 `src/__tests__/public-exports.test.ts`,两道全量清单闸(`public-exports` / `public-type-surface`)的条目已同步收缩