@dommaker/harness 0.19.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/bin/harness.js +136 -557
  3. package/dist/cli/commands/check.d.ts.map +1 -1
  4. package/dist/cli/commands/check.js +2 -13
  5. package/dist/cli/commands/check.js.map +1 -1
  6. package/dist/cli/commands/definitions.d.ts +90 -0
  7. package/dist/cli/commands/definitions.d.ts.map +1 -0
  8. package/dist/cli/commands/definitions.js +519 -0
  9. package/dist/cli/commands/definitions.js.map +1 -0
  10. package/dist/cli/commands/knowledge.js.map +1 -1
  11. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +3 -25
  12. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
  13. package/dist/cli/commands/sync-docs/capabilities-syncer.js +3 -93
  14. package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
  15. package/dist/cli/commands/sync-docs/index.d.ts +1 -1
  16. package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
  17. package/dist/cli/commands/sync-docs/index.js +4 -4
  18. package/dist/cli/commands/sync-docs/index.js.map +1 -1
  19. package/dist/context/index.d.ts +1 -5
  20. package/dist/context/index.d.ts.map +1 -1
  21. package/dist/context/index.js +1 -5
  22. package/dist/context/index.js.map +1 -1
  23. package/dist/context/knowledge-injector.d.ts +3 -3
  24. package/dist/context/knowledge-injector.d.ts.map +1 -1
  25. package/dist/context/knowledge-injector.js +1 -1
  26. package/dist/context/session-manager.d.ts +1 -12
  27. package/dist/context/session-manager.d.ts.map +1 -1
  28. package/dist/context/session-manager.js +0 -63
  29. package/dist/context/session-manager.js.map +1 -1
  30. package/dist/context/types.d.ts +1 -39
  31. package/dist/context/types.d.ts.map +1 -1
  32. package/dist/context/types.js +2 -15
  33. package/dist/context/types.js.map +1 -1
  34. package/dist/core/constraints/agent-prompt-renderer.d.ts +1 -1
  35. package/dist/core/constraints/agent-prompt-renderer.js +1 -1
  36. package/dist/core/constraints/capabilities-parser.d.ts +17 -2
  37. package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
  38. package/dist/core/constraints/capabilities-parser.js +84 -2
  39. package/dist/core/constraints/capabilities-parser.js.map +1 -1
  40. package/dist/core/constraints/checker.d.ts +3 -17
  41. package/dist/core/constraints/checker.d.ts.map +1 -1
  42. package/dist/core/constraints/checker.js +7 -47
  43. package/dist/core/constraints/checker.js.map +1 -1
  44. package/dist/core/constraints/definitions.d.ts +0 -7
  45. package/dist/core/constraints/definitions.d.ts.map +1 -1
  46. package/dist/core/constraints/definitions.js +1 -8
  47. package/dist/core/constraints/definitions.js.map +1 -1
  48. package/dist/core/constraints/doc-freshness/runner.d.ts +0 -2
  49. package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
  50. package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
  51. package/dist/core/constraints/index.d.ts +1 -1
  52. package/dist/core/constraints/index.d.ts.map +1 -1
  53. package/dist/core/constraints/index.js +2 -3
  54. package/dist/core/constraints/index.js.map +1 -1
  55. package/dist/core/constraints/interceptor.d.ts.map +1 -1
  56. package/dist/core/constraints/interceptor.js +1 -5
  57. package/dist/core/constraints/interceptor.js.map +1 -1
  58. package/dist/core/effective-constraints.d.ts.map +1 -1
  59. package/dist/core/effective-constraints.js +0 -1
  60. package/dist/core/effective-constraints.js.map +1 -1
  61. package/dist/core/project-config-loader.d.ts.map +1 -1
  62. package/dist/core/project-config-loader.js +1 -8
  63. package/dist/core/project-config-loader.js.map +1 -1
  64. package/dist/dashboard/stats.d.ts.map +1 -1
  65. package/dist/dashboard/stats.js.map +1 -1
  66. package/dist/dashboard/types.d.ts +2 -2
  67. package/dist/dashboard/types.d.ts.map +1 -1
  68. package/dist/failure/constraint-handler.d.ts.map +1 -1
  69. package/dist/failure/constraint-handler.js +0 -2
  70. package/dist/failure/constraint-handler.js.map +1 -1
  71. package/dist/gates/acceptance.d.ts +9 -1
  72. package/dist/gates/acceptance.d.ts.map +1 -1
  73. package/dist/gates/acceptance.js +21 -0
  74. package/dist/gates/acceptance.js.map +1 -1
  75. package/dist/gates/checker-gate.d.ts +23 -0
  76. package/dist/gates/checker-gate.d.ts.map +1 -0
  77. package/dist/gates/checker-gate.js +53 -0
  78. package/dist/gates/checker-gate.js.map +1 -0
  79. package/dist/gates/command.d.ts +9 -2
  80. package/dist/gates/command.d.ts.map +1 -1
  81. package/dist/gates/command.js +10 -0
  82. package/dist/gates/command.js.map +1 -1
  83. package/dist/gates/contract.d.ts +8 -2
  84. package/dist/gates/contract.d.ts.map +1 -1
  85. package/dist/gates/contract.js +9 -0
  86. package/dist/gates/contract.js.map +1 -1
  87. package/dist/gates/decision.d.ts +17 -0
  88. package/dist/gates/decision.d.ts.map +1 -0
  89. package/dist/gates/decision.js +25 -0
  90. package/dist/gates/decision.js.map +1 -0
  91. package/dist/gates/definitions.d.ts +63 -0
  92. package/dist/gates/definitions.d.ts.map +1 -0
  93. package/dist/gates/definitions.js +160 -0
  94. package/dist/gates/definitions.js.map +1 -0
  95. package/dist/gates/effective-gates.d.ts +30 -0
  96. package/dist/gates/effective-gates.d.ts.map +1 -0
  97. package/dist/gates/effective-gates.js +85 -0
  98. package/dist/gates/effective-gates.js.map +1 -0
  99. package/dist/gates/index.d.ts +25 -1
  100. package/dist/gates/index.d.ts.map +1 -1
  101. package/dist/gates/index.js +37 -1
  102. package/dist/gates/index.js.map +1 -1
  103. package/dist/gates/performance.d.ts +8 -2
  104. package/dist/gates/performance.d.ts.map +1 -1
  105. package/dist/gates/performance.js +9 -0
  106. package/dist/gates/performance.js.map +1 -1
  107. package/dist/gates/registry.d.ts +32 -0
  108. package/dist/gates/registry.d.ts.map +1 -0
  109. package/dist/gates/registry.js +90 -0
  110. package/dist/gates/registry.js.map +1 -0
  111. package/dist/gates/review.d.ts +8 -2
  112. package/dist/gates/review.d.ts.map +1 -1
  113. package/dist/gates/review.js +9 -0
  114. package/dist/gates/review.js.map +1 -1
  115. package/dist/gates/runner.d.ts +30 -0
  116. package/dist/gates/runner.d.ts.map +1 -0
  117. package/dist/gates/runner.js +38 -0
  118. package/dist/gates/runner.js.map +1 -0
  119. package/dist/gates/security.d.ts +8 -2
  120. package/dist/gates/security.d.ts.map +1 -1
  121. package/dist/gates/security.js +9 -0
  122. package/dist/gates/security.js.map +1 -1
  123. package/dist/gates/types.d.ts +41 -1
  124. package/dist/gates/types.d.ts.map +1 -1
  125. package/dist/hooks/bootstrap.d.ts.map +1 -1
  126. package/dist/hooks/bootstrap.js +0 -2
  127. package/dist/hooks/bootstrap.js.map +1 -1
  128. package/dist/hooks/config.d.ts +26 -0
  129. package/dist/hooks/config.d.ts.map +1 -0
  130. package/dist/hooks/config.js +30 -0
  131. package/dist/hooks/config.js.map +1 -0
  132. package/dist/hooks/index.d.ts +2 -1
  133. package/dist/hooks/index.d.ts.map +1 -1
  134. package/dist/hooks/index.js +4 -1
  135. package/dist/hooks/index.js.map +1 -1
  136. package/dist/hooks/registry.d.ts +18 -1
  137. package/dist/hooks/registry.d.ts.map +1 -1
  138. package/dist/hooks/registry.js +45 -0
  139. package/dist/hooks/registry.js.map +1 -1
  140. package/dist/hooks/types.d.ts +20 -0
  141. package/dist/hooks/types.d.ts.map +1 -1
  142. package/dist/index.d.ts +4 -8
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +5 -20
  145. package/dist/index.js.map +1 -1
  146. package/dist/knowledge/import.d.ts +2 -2
  147. package/dist/knowledge/import.d.ts.map +1 -1
  148. package/dist/knowledge/ingest.js.map +1 -1
  149. package/dist/knowledge/lifecycle-hooks.d.ts +2 -2
  150. package/dist/knowledge/lifecycle-hooks.d.ts.map +1 -1
  151. package/dist/knowledge/types.d.ts +5 -7
  152. package/dist/knowledge/types.d.ts.map +1 -1
  153. package/dist/knowledge/types.js +1 -1
  154. package/dist/knowledge/types.js.map +1 -1
  155. package/dist/monitoring/constraint-doctor.d.ts +4 -22
  156. package/dist/monitoring/constraint-doctor.d.ts.map +1 -1
  157. package/dist/monitoring/constraint-doctor.js +7 -94
  158. package/dist/monitoring/constraint-doctor.js.map +1 -1
  159. package/dist/presets/standard.d.ts +1 -1
  160. package/dist/presets/standard.d.ts.map +1 -1
  161. package/dist/presets/standard.js +1 -2
  162. package/dist/presets/standard.js.map +1 -1
  163. package/dist/spec/annotation-checker.d.ts.map +1 -1
  164. package/dist/spec/annotation-checker.js +6 -26
  165. package/dist/spec/annotation-checker.js.map +1 -1
  166. package/dist/tools/index.d.ts +0 -4
  167. package/dist/tools/index.d.ts.map +1 -1
  168. package/dist/tools/index.js +0 -4
  169. package/dist/tools/index.js.map +1 -1
  170. package/dist/types/constraint.d.ts +1 -12
  171. package/dist/types/constraint.d.ts.map +1 -1
  172. package/dist/types/constraint.js +0 -3
  173. package/dist/types/constraint.js.map +1 -1
  174. package/dist/types/project-config.d.ts +0 -2
  175. package/dist/types/project-config.d.ts.map +1 -1
  176. package/dist/utils/file-walk.d.ts +2 -2
  177. package/dist/utils/file-walk.js +2 -2
  178. package/package.json +6 -1
  179. package/src/CONTEXT.md +14 -0
  180. package/src/__tests__/checker-extra.test.ts +2 -59
  181. package/src/__tests__/constraint-doctor.test.ts +1 -140
  182. package/src/__tests__/constraint-handler.test.ts +0 -4
  183. package/src/__tests__/project-config-loader-extra.test.ts +0 -20
  184. package/src/__tests__/project-config-loader.test.ts +0 -1
  185. package/src/cli/commands/CONTEXT.md +15 -7
  186. package/src/cli/commands/__tests__/check-drift.test.ts +0 -3
  187. package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -5
  188. package/src/cli/commands/__tests__/check.test.ts +7 -75
  189. package/src/cli/commands/__tests__/registry.test.ts +201 -0
  190. package/src/cli/commands/check.ts +2 -14
  191. package/src/cli/commands/definitions.ts +593 -0
  192. package/src/cli/commands/knowledge.ts +3 -3
  193. package/src/cli/commands/sync-docs/capabilities-syncer.ts +4 -110
  194. package/src/cli/commands/sync-docs/index.ts +8 -5
  195. package/src/context/CONTEXT.md +2 -7
  196. package/src/context/__tests__/session-manager.test.ts +0 -91
  197. package/src/context/index.ts +1 -5
  198. package/src/context/knowledge-injector.ts +3 -3
  199. package/src/context/session-manager.ts +0 -74
  200. package/src/context/types.ts +2 -63
  201. package/src/core/constraints/__tests__/interceptor.test.ts +0 -2
  202. package/src/core/constraints/agent-prompt-renderer.ts +1 -1
  203. package/src/core/constraints/capabilities-parser.ts +95 -2
  204. package/src/core/constraints/checker.ts +8 -53
  205. package/src/core/constraints/definitions.ts +0 -8
  206. package/src/core/constraints/doc-freshness/runner.ts +1 -2
  207. package/src/core/constraints/index.ts +1 -2
  208. package/src/core/constraints/interceptor.ts +1 -6
  209. package/src/core/effective-constraints.ts +0 -1
  210. package/src/core/project-config-loader.ts +1 -7
  211. package/src/dashboard/stats.ts +2 -2
  212. package/src/dashboard/types.ts +2 -2
  213. package/src/failure/constraint-handler.ts +0 -2
  214. package/src/gates/CONTEXT.md +16 -13
  215. package/src/gates/__tests__/checker-gate.test.ts +45 -0
  216. package/src/gates/__tests__/contract.test.ts +73 -0
  217. package/src/gates/__tests__/effective-gates.test.ts +82 -0
  218. package/src/gates/__tests__/gate-interface.test.ts +202 -0
  219. package/src/gates/__tests__/registry.test.ts +87 -0
  220. package/src/gates/__tests__/runner.test.ts +81 -0
  221. package/src/gates/acceptance.ts +24 -1
  222. package/src/gates/checker-gate.ts +54 -0
  223. package/src/gates/command.ts +13 -2
  224. package/src/gates/contract.ts +12 -2
  225. package/src/gates/decision.ts +27 -0
  226. package/src/gates/definitions.ts +207 -0
  227. package/src/gates/effective-gates.ts +106 -0
  228. package/src/gates/index.ts +38 -0
  229. package/src/gates/performance.ts +12 -2
  230. package/src/gates/registry.ts +107 -0
  231. package/src/gates/review.ts +12 -2
  232. package/src/gates/runner.ts +57 -0
  233. package/src/gates/security.ts +12 -2
  234. package/src/gates/types.ts +48 -1
  235. package/src/hooks/CONTEXT.md +12 -2
  236. package/src/hooks/__tests__/bootstrap.test.ts +0 -1
  237. package/src/hooks/__tests__/config.test.ts +19 -0
  238. package/src/hooks/__tests__/pipeline.test.ts +79 -0
  239. package/src/hooks/__tests__/registry.test.ts +67 -0
  240. package/src/hooks/bootstrap.ts +0 -2
  241. package/src/hooks/config.ts +29 -0
  242. package/src/hooks/index.ts +2 -1
  243. package/src/hooks/registry.ts +60 -1
  244. package/src/hooks/types.ts +21 -0
  245. package/src/index.ts +5 -22
  246. package/src/knowledge/import.ts +3 -3
  247. package/src/knowledge/ingest.ts +4 -4
  248. package/src/knowledge/lifecycle-hooks.ts +3 -3
  249. package/src/knowledge/types.ts +5 -8
  250. package/src/monitoring/constraint-doctor.ts +7 -106
  251. package/src/presets/__tests__/standard.test.ts +0 -2
  252. package/src/presets/standard.ts +1 -2
  253. package/src/spec/__tests__/annotation-checker.test.ts +9 -3
  254. package/src/spec/annotation-checker.ts +7 -29
  255. package/src/tools/CONTEXT.md +7 -14
  256. package/src/tools/index.ts +0 -4
  257. package/src/types/constraint.ts +1 -14
  258. package/src/types/project-config.ts +0 -3
  259. package/src/utils/file-walk.ts +2 -2
  260. package/dist/architecture/constraint-engine.d.ts +0 -67
  261. package/dist/architecture/constraint-engine.d.ts.map +0 -1
  262. package/dist/architecture/constraint-engine.js +0 -295
  263. package/dist/architecture/constraint-engine.js.map +0 -1
  264. package/dist/architecture/cross-project-checker.d.ts +0 -54
  265. package/dist/architecture/cross-project-checker.d.ts.map +0 -1
  266. package/dist/architecture/cross-project-checker.js +0 -467
  267. package/dist/architecture/cross-project-checker.js.map +0 -1
  268. package/dist/cli/commands/index.d.ts +0 -30
  269. package/dist/cli/commands/index.d.ts.map +0 -1
  270. package/dist/cli/commands/index.js +0 -91
  271. package/dist/cli/commands/index.js.map +0 -1
  272. package/dist/context/file-budget.d.ts +0 -40
  273. package/dist/context/file-budget.d.ts.map +0 -1
  274. package/dist/context/file-budget.js +0 -147
  275. package/dist/context/file-budget.js.map +0 -1
  276. package/dist/context/progressive-loader.d.ts +0 -109
  277. package/dist/context/progressive-loader.d.ts.map +0 -1
  278. package/dist/context/progressive-loader.js +0 -166
  279. package/dist/context/progressive-loader.js.map +0 -1
  280. package/dist/context/token-pipeline.d.ts +0 -55
  281. package/dist/context/token-pipeline.d.ts.map +0 -1
  282. package/dist/context/token-pipeline.js +0 -220
  283. package/dist/context/token-pipeline.js.map +0 -1
  284. package/dist/context/tool-output-budget.d.ts +0 -59
  285. package/dist/context/tool-output-budget.d.ts.map +0 -1
  286. package/dist/context/tool-output-budget.js +0 -177
  287. package/dist/context/tool-output-budget.js.map +0 -1
  288. package/dist/core/constraints/default-executors.d.ts +0 -10
  289. package/dist/core/constraints/default-executors.d.ts.map +0 -1
  290. package/dist/core/constraints/default-executors.js +0 -120
  291. package/dist/core/constraints/default-executors.js.map +0 -1
  292. package/dist/llm/adapter.d.ts +0 -36
  293. package/dist/llm/adapter.d.ts.map +0 -1
  294. package/dist/llm/adapter.js +0 -118
  295. package/dist/llm/adapter.js.map +0 -1
  296. package/dist/llm/index.d.ts +0 -3
  297. package/dist/llm/index.d.ts.map +0 -1
  298. package/dist/llm/index.js +0 -19
  299. package/dist/llm/index.js.map +0 -1
  300. package/dist/llm/types.d.ts +0 -62
  301. package/dist/llm/types.d.ts.map +0 -1
  302. package/dist/llm/types.js +0 -8
  303. package/dist/llm/types.js.map +0 -1
  304. package/dist/tools/core/index.d.ts +0 -13
  305. package/dist/tools/core/index.d.ts.map +0 -1
  306. package/dist/tools/core/index.js +0 -198
  307. package/dist/tools/core/index.js.map +0 -1
  308. package/dist/tools/loader.d.ts +0 -21
  309. package/dist/tools/loader.d.ts.map +0 -1
  310. package/dist/tools/loader.js +0 -199
  311. package/dist/tools/loader.js.map +0 -1
  312. package/dist/tools/registry.d.ts +0 -59
  313. package/dist/tools/registry.d.ts.map +0 -1
  314. package/dist/tools/registry.js +0 -115
  315. package/dist/tools/registry.js.map +0 -1
  316. package/dist/tools/types.d.ts +0 -38
  317. package/dist/tools/types.d.ts.map +0 -1
  318. package/dist/tools/types.js +0 -6
  319. package/dist/tools/types.js.map +0 -1
  320. package/src/__tests__/architecture-engine.test.ts +0 -619
  321. package/src/__tests__/context/progressive-loader.test.ts +0 -131
  322. package/src/__tests__/cross-project-checker.test.ts +0 -318
  323. package/src/architecture/CONTEXT.md +0 -22
  324. package/src/architecture/constraint-engine.ts +0 -351
  325. package/src/architecture/cross-project-checker.ts +0 -545
  326. package/src/cli/commands/index.ts +0 -30
  327. package/src/context/__tests__/file-budget.test.ts +0 -142
  328. package/src/context/__tests__/progressive-loader.test.ts +0 -264
  329. package/src/context/__tests__/token-pipeline.test.ts +0 -178
  330. package/src/context/__tests__/tool-output-budget.test.ts +0 -95
  331. package/src/context/file-budget.ts +0 -142
  332. package/src/context/progressive-loader.ts +0 -260
  333. package/src/context/token-pipeline.ts +0 -265
  334. package/src/context/tool-output-budget.ts +0 -178
  335. package/src/core/constraints/__tests__/default-executors.test.ts +0 -57
  336. package/src/core/constraints/default-executors.ts +0 -92
  337. package/src/llm/CONTEXT.md +0 -21
  338. package/src/llm/__tests__/adapter.test.ts +0 -172
  339. package/src/llm/adapter.ts +0 -149
  340. package/src/llm/index.ts +0 -2
  341. package/src/llm/types.ts +0 -81
  342. package/src/tools/__tests__/loader.test.ts +0 -252
  343. package/src/tools/__tests__/registry.test.ts +0 -157
  344. package/src/tools/core/__tests__/core.test.ts +0 -122
  345. package/src/tools/core/index.ts +0 -201
  346. package/src/tools/loader.ts +0 -216
  347. package/src/tools/registry.ts +0 -128
  348. package/src/tools/types.ts +0 -46
@@ -3,7 +3,10 @@
3
3
  */
4
4
 
5
5
  /**
6
- * 门禁结果
6
+ * 门禁结果(报告结构,保留)
7
+ *
8
+ * 统一 Gate 接口后 GateResult 仍是每个门禁产出的报告层;
9
+ * 决策层见 GateDecision。
7
10
  */
8
11
  export interface GateResult {
9
12
  gate: string;
@@ -14,6 +17,44 @@ export interface GateResult {
14
17
  duration?: number;
15
18
  }
16
19
 
20
+ /**
21
+ * 门禁决策三态(守卫/门禁统一,G1)
22
+ *
23
+ * - deny:阻断。单调语义——一旦出现,下游门禁不得改回 allow。
24
+ * - abstain:弃权/放行。不阻断,也不否决。
25
+ * - ask:需要人裁决。枚举预留,暂无实现;无实现时 fail-closed 按 deny 计。
26
+ */
27
+ export type GateDecisionStatus = 'deny' | 'abstain' | 'ask';
28
+
29
+ /**
30
+ * 门禁决策:统一 Gate 接口的返回值
31
+ *
32
+ * status 是三态决策;result 携带 GateResult 报告结构。
33
+ * 决策对象由 decisionFromResult / runGates 浅冻结——不可变是
34
+ * deny 单调语义的接口契约。
35
+ */
36
+ export interface GateDecision {
37
+ /** 三态决策 */
38
+ status: GateDecisionStatus;
39
+ /** 报告结构(GateResult 保留为报告层,不删) */
40
+ result: GateResult;
41
+ }
42
+
43
+ /**
44
+ * 统一门禁接口(G1)
45
+ *
46
+ * 统一的是决策协议(id / 声明式 order / evaluate → 三态决策),
47
+ * 各门禁执行细节(gh pr view / 正则黑名单 / OpenAPI diff / benchmark…)私有。
48
+ */
49
+ export interface Gate {
50
+ /** 门禁 id(与 gates/definitions.ts 定义一致,注册表闭环校验) */
51
+ readonly id: string;
52
+ /** 声明式顺序(config.yml `gates.order` 可覆盖),小者先执行 */
53
+ order: number;
54
+ /** 决策协议:返回三态 GateDecision */
55
+ evaluate(ctx: GateContext): Promise<GateDecision> | GateDecision;
56
+ }
57
+
17
58
  /**
18
59
  * 门禁上下文
19
60
  */
@@ -39,6 +80,12 @@ export interface GateContext {
39
80
  oldContractPath?: string;
40
81
  newContractPath?: string;
41
82
  openApiSpec?: string;
83
+
84
+ // Command Gate
85
+ command?: string;
86
+
87
+ // Acceptance Gate
88
+ tasksPath?: string;
42
89
 
43
90
  // 通用
44
91
  timeout?: number;
@@ -3,9 +3,16 @@
3
3
  ## 职责
4
4
  通用 Hook 管线:注册 → 排序 → 错误隔离 → 采样执行。无业务逻辑,consumer 自行定义 hook 名称和语义。
5
5
 
6
+ H5(#44)起增加两个机制(G2/G7):
7
+ - **注册表闭环**:`assertHookRegistryClosed(configs, hooks)` 声明(HookConfig)↔ 实现(HookDefinition)双向校验——引用未注册/注册无定义/重复均抛错,复制 checker 闭环模式;断言限构建/测试期,不进运行时热路径
8
+ - **配置归一**:`HookConfig { name, enabled, errorStrategy }` 为 per-hook 配置唯一真相;`toErrorStrategy(blocking)` 承载 studio `blocking` → errorStrategy 的无损映射
9
+
6
10
  ## 核心导出
7
- - `HookRegistry` — Hook 注册表
8
- - `HookPipeline` — Hook 执行管线(注册/排序/错误隔离/采样)
11
+ - `HookRegistry` — Hook 注册表(register/get/getEnabled/setEnabled/clear/listAll)
12
+ - `HookPipeline` — Hook 执行管线(注册/排序/错误隔离/采样;errorStrategy block/warn/ignore)
13
+ - `assertHookRegistryClosed` — 注册表闭环双向校验(构建/测试期)
14
+ - `HookConfig`(type)— per-hook 配置声明(归一后形状)
15
+ - `toErrorStrategy` — blocking → errorStrategy 无损映射(G7)
9
16
  - `bootstrapHarness` / `bootstrapHarnessSync` — Harness 启动引导
10
17
 
11
18
  ## 依赖关系
@@ -16,8 +23,11 @@
16
23
  ## 约定
17
24
  - 无业务逻辑,只提供管线能力
18
25
  - Consumer 自行定义 hook 名称和触发时机
26
+ - **闭环**:声明配置与注册实现必须一一对应,缺一抛错(消灭「hook 定义不注册 = 死代码」类人记规矩)
27
+ - **映射语义**:blocking=true → 'block'(失败阻断管线,停止后续 hook、passed=false);blocking=false → 'warn'(记录警告继续);未声明 strategy 静默跳过(历史行为保留)
19
28
  - 错误隔离:单个 hook 失败不影响其他 hook
20
29
 
21
30
  ## 注意事项
22
31
  - 通用管线设计,不绑定特定生命周期
23
32
  - 采样执行用于高频 hook(减少性能影响)
33
+ - 闭环断言是纯函数,由 consumer 在其注册点/测试中调用;harness 无内置 hook 定义,不自动断言
@@ -124,7 +124,6 @@ describe('bootstrapHarnessSync', () => {
124
124
  // Check that mergedConstraints has the expected structure
125
125
  expect(result.mergedConstraints).toHaveProperty('ironLaws');
126
126
  expect(result.mergedConstraints).toHaveProperty('guidelines');
127
- expect(result.mergedConstraints).toHaveProperty('tips');
128
127
  });
129
128
 
130
129
  it('registers hook definitions when provided', () => {
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Hook 配置归一映射语义测试(G7)
3
+ *
4
+ * blocking → errorStrategy 无损映射:
5
+ * - blocking=true → 'block'(失败阻断管线)
6
+ * - blocking=false → 'warn'(记录警告继续)
7
+ */
8
+
9
+ import { toErrorStrategy } from '../config';
10
+
11
+ describe('toErrorStrategy(blocking → errorStrategy 无损映射,G7)', () => {
12
+ it('blocking=true → block(失败阻断管线)', () => {
13
+ expect(toErrorStrategy(true)).toBe('block');
14
+ });
15
+
16
+ it('blocking=false → warn(记录警告继续)', () => {
17
+ expect(toErrorStrategy(false)).toBe('warn');
18
+ });
19
+ });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * HookPipeline errorStrategy 语义测试(G7 映射语义确认)
3
+ *
4
+ * block/warn 行为是 studio safeCallHook 语义在管线侧的无损承载面:
5
+ * - 'block':hook 失败 → passed=false、blockedBy 记名、停止执行后续 hook
6
+ * - 'warn':hook 失败 → 记录警告、继续执行后续 hook、passed 不受影响
7
+ * - 'ignore'/未声明:静默跳过(历史行为保留)
8
+ */
9
+
10
+ import { HookPipeline } from '../pipeline';
11
+ import { HookRegistry } from '../registry';
12
+ import type { HookDefinition } from '../types';
13
+
14
+ function makeRegistry(hooks: HookDefinition[]): { registry: HookRegistry; pipeline: HookPipeline } {
15
+ const registry = new HookRegistry();
16
+ registry.registerAll(hooks);
17
+ return { registry, pipeline: new HookPipeline(registry) };
18
+ }
19
+
20
+ describe('HookPipeline errorStrategy 语义', () => {
21
+ it('block:失败阻断管线(passed=false、blockedBy 记名、停止后续 hook)', async () => {
22
+ const second = jest.fn().mockResolvedValue({ passed: true });
23
+ const { pipeline } = makeRegistry([
24
+ { name: 'first', phase: 'before', errorStrategy: 'block', execute: async () => ({ passed: false, error: 'boom' }) },
25
+ { name: 'second', phase: 'before', execute: second },
26
+ ]);
27
+
28
+ const result = await pipeline.run('before', {});
29
+
30
+ expect(result.passed).toBe(false);
31
+ expect(result.blockedBy).toEqual(['first']);
32
+ expect(second).not.toHaveBeenCalled();
33
+ });
34
+
35
+ it('warn:失败记录警告并继续(passed 不受影响、后续 hook 照常执行)', async () => {
36
+ const second = jest.fn().mockResolvedValue({ passed: true });
37
+ const { pipeline } = makeRegistry([
38
+ { name: 'first', phase: 'before', errorStrategy: 'warn', execute: async () => ({ passed: false, error: 'soft' }) },
39
+ { name: 'second', phase: 'before', execute: second },
40
+ ]);
41
+
42
+ const result = await pipeline.run('before', {});
43
+
44
+ expect(result.passed).toBe(true);
45
+ expect(result.warnings).toEqual(['first']);
46
+ expect(result.blockedBy).toEqual([]);
47
+ expect(second).toHaveBeenCalled();
48
+ });
49
+
50
+ it('block 失败停在当前 phase,不改变其它 phase 的 hook', async () => {
51
+ const afterHook = jest.fn().mockResolvedValue({ passed: true });
52
+ const { pipeline } = makeRegistry([
53
+ { name: 'blocker', phase: 'before', errorStrategy: 'block', execute: async () => ({ passed: false }) },
54
+ { name: 'afterHook', phase: 'after', execute: afterHook },
55
+ ]);
56
+
57
+ const before = await pipeline.run('before', {});
58
+ expect(before.passed).toBe(false);
59
+
60
+ const after = await pipeline.run('after', {});
61
+ expect(after.passed).toBe(true);
62
+ expect(afterHook).toHaveBeenCalled();
63
+ });
64
+
65
+ it('未声明 errorStrategy:静默跳过(历史行为保留)', async () => {
66
+ const second = jest.fn().mockResolvedValue({ passed: true });
67
+ const { pipeline } = makeRegistry([
68
+ { name: 'first', phase: 'before', execute: async () => ({ passed: false }) },
69
+ { name: 'second', phase: 'before', execute: second },
70
+ ]);
71
+
72
+ const result = await pipeline.run('before', {});
73
+
74
+ expect(result.passed).toBe(true);
75
+ expect(result.blockedBy).toEqual([]);
76
+ expect(result.warnings).toEqual([]);
77
+ expect(second).toHaveBeenCalled();
78
+ });
79
+ });
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Hook 注册表闭环双向校验测试(H5,复制 checker 闭环模式)
3
+ *
4
+ * 两个失败方向 + 重复声明/注册都必须抛错;闭环通过时不抛错。
5
+ */
6
+
7
+ import { assertHookRegistryClosed, HookRegistry } from '../registry';
8
+ import type { HookConfig, HookDefinition } from '../types';
9
+
10
+ function makeHook(name: string): HookDefinition {
11
+ return {
12
+ name,
13
+ phase: 'before',
14
+ execute: async () => ({ passed: true }),
15
+ };
16
+ }
17
+
18
+ function makeConfig(name: string): HookConfig {
19
+ return { name, enabled: true, errorStrategy: 'block' };
20
+ }
21
+
22
+ describe('assertHookRegistryClosed', () => {
23
+ it('声明与注册一一对应时通过', () => {
24
+ const configs = [makeConfig('beforeAgentExecute'), makeConfig('afterReview')];
25
+ const hooks = [makeHook('beforeAgentExecute'), makeHook('afterReview')];
26
+ expect(() => assertHookRegistryClosed(configs, hooks)).not.toThrow();
27
+ });
28
+
29
+ it('空声明 + 空注册通过(无 hook 的 consumer 合法)', () => {
30
+ expect(() => assertHookRegistryClosed([], [])).not.toThrow();
31
+ });
32
+
33
+ it('引用未注册 → 抛错:声明了配置但没有注册实现', () => {
34
+ const configs = [makeConfig('beforeAgentExecute'), makeConfig('ghostHook')];
35
+ const hooks = [makeHook('beforeAgentExecute')];
36
+ expect(() => assertHookRegistryClosed(configs, hooks)).toThrow(
37
+ /hook 配置 "ghostHook" 引用的实现未注册/
38
+ );
39
+ });
40
+
41
+ it('注册无定义 → 抛错:注册了实现但没有配置声明', () => {
42
+ const configs = [makeConfig('beforeAgentExecute')];
43
+ const hooks = [makeHook('beforeAgentExecute'), makeHook('orphanHook')];
44
+ expect(() => assertHookRegistryClosed(configs, hooks)).toThrow(
45
+ /hook "orphanHook" 注册了实现但没有对应配置声明/
46
+ );
47
+ });
48
+
49
+ it('重复声明 → 抛错', () => {
50
+ const configs = [makeConfig('dup'), makeConfig('dup')];
51
+ const hooks = [makeHook('dup')];
52
+ expect(() => assertHookRegistryClosed(configs, hooks)).toThrow(/重复声明/);
53
+ });
54
+
55
+ it('重复注册 → 抛错', () => {
56
+ const configs = [makeConfig('dup')];
57
+ const hooks = [makeHook('dup'), makeHook('dup')];
58
+ expect(() => assertHookRegistryClosed(configs, hooks)).toThrow(/重复注册/);
59
+ });
60
+
61
+ it('与 HookRegistry.listAll 组合可用(consumer 注册点用法)', () => {
62
+ const registry = new HookRegistry();
63
+ registry.registerAll([makeHook('beforeAgentExecute')]);
64
+ expect(() => assertHookRegistryClosed([makeConfig('beforeAgentExecute')], registry.listAll()))
65
+ .not.toThrow();
66
+ });
67
+ });
@@ -74,7 +74,6 @@ export async function bootstrapHarness(
74
74
 
75
75
  // 2. 初始化核心组件
76
76
  const checker = ConstraintChecker.getInstance();
77
- checker.setCustomConfig(mergedConstraints);
78
77
  checker.setTraceRecorder(getTraceCollector());
79
78
 
80
79
  const sessions = new SessionManager(resolvedPath);
@@ -112,7 +111,6 @@ export function bootstrapHarnessSync(
112
111
  const mergedConstraints = loader.mergeConstraints();
113
112
 
114
113
  const checker = ConstraintChecker.getInstance();
115
- checker.setCustomConfig(mergedConstraints);
116
114
  checker.setTraceRecorder(getTraceCollector());
117
115
 
118
116
  const sessions = new SessionManager(resolvedPath);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Hook 配置归一(G7)
3
+ *
4
+ * studio 侧 per-hook 运行时配置(`blocking: boolean`)与 harness 侧
5
+ * `HookDefinition.errorStrategy` 双轨归一:以 errorStrategy 为唯一真相,
6
+ * `blocking` → errorStrategy 为无损映射。
7
+ *
8
+ * 映射语义(确认于 H5):
9
+ * - blocking=true → 'block':hook 失败阻断管线(停止执行后续 hook,
10
+ * 管线结果 passed=false、blockedBy 记名)——对应 studio safeCallHook 抛错
11
+ * - blocking=false → 'warn':hook 失败记录警告并继续执行后续 hook
12
+ * (管线结果 warnings 记名,passed 不受影响)——对应 studio safeCallHook
13
+ * console.warn 继续
14
+ *
15
+ * studio 侧随动(studio #150 A4):hooks/config.ts 删 DEFAULTS/safeCallHook,
16
+ * blocking→errorStrategy 无损映射进 toHookDef;HARNESS_HOOK_DISABLE 保留 studio。
17
+ */
18
+
19
+ import type { HookErrorStrategy } from './types';
20
+
21
+ /**
22
+ * blocking 布尔 → errorStrategy 无损映射(block/warn)
23
+ *
24
+ * @param blocking studio 侧「失败是否阻断」语义
25
+ * @returns 'block'(阻断)| 'warn'(警告继续)
26
+ */
27
+ export function toErrorStrategy(blocking: boolean): Extract<HookErrorStrategy, 'block' | 'warn'> {
28
+ return blocking ? 'block' : 'warn';
29
+ }
@@ -6,8 +6,9 @@
6
6
  */
7
7
 
8
8
  export * from './types';
9
- export { HookRegistry } from './registry';
9
+ export { HookRegistry, assertHookRegistryClosed } from './registry';
10
10
  export { HookPipeline } from './pipeline';
11
+ export { toErrorStrategy } from './config';
11
12
  export {
12
13
  bootstrapHarness,
13
14
  bootstrapHarnessSync,
@@ -4,7 +4,66 @@
4
4
  * 纯簿记,无执行逻辑。线程不安全(Node.js 单线程)。
5
5
  */
6
6
 
7
- import type { HookDefinition, HookPhase } from './types';
7
+ import type { HookConfig, HookDefinition, HookPhase } from './types';
8
+
9
+ /**
10
+ * 注册表闭环双向校验(H5,复制 checker 闭环模式)
11
+ *
12
+ * 声明(HookConfig,consumer 的 per-hook 配置表)↔ 实现(注册的
13
+ * HookDefinition)加载期双向校验,任一不满足即抛错,拒绝静默缺失:
14
+ * - 引用未注册 → 抛错(声明了配置但没有注册实现 = 死配置)
15
+ * - 注册无定义 → 抛错(注册了实现但没有配置声明 = 死代码)
16
+ * - 重复声明 / 重复注册 → 抛错
17
+ *
18
+ * 断言限构建/测试期调用(harness 无内置 hook 定义,加载期闭环由
19
+ * consumer 在其注册点/测试中调用本函数),不进入运行时热路径,
20
+ * 不破坏 --help/--version 懒加载。消灭「hook 定义不注册 = 死代码」
21
+ * 类 prompt 规矩(studio 侧随动)。
22
+ *
23
+ * @throws 任一方向不满足时抛错
24
+ */
25
+ export function assertHookRegistryClosed<C = unknown, R = unknown>(
26
+ configs: readonly HookConfig[],
27
+ hooks: readonly HookDefinition<C, R>[]
28
+ ): void {
29
+ const configNames = new Set<string>();
30
+ for (const config of configs) {
31
+ if (configNames.has(config.name)) {
32
+ throw new Error(
33
+ `[harness] hook 注册表闭环校验失败:hook 配置 "${config.name}" 重复声明。`
34
+ );
35
+ }
36
+ configNames.add(config.name);
37
+ }
38
+
39
+ const hookNames = new Set<string>();
40
+ for (const hook of hooks) {
41
+ if (hookNames.has(hook.name)) {
42
+ throw new Error(
43
+ `[harness] hook 注册表闭环校验失败:hook "${hook.name}" 重复注册。`
44
+ );
45
+ }
46
+ hookNames.add(hook.name);
47
+ }
48
+
49
+ for (const config of configs) {
50
+ if (!hookNames.has(config.name)) {
51
+ throw new Error(
52
+ `[harness] hook 注册表闭环校验失败:hook 配置 "${config.name}" 引用的实现未注册。` +
53
+ `请注册同名 HookDefinition,或删除该配置声明。`
54
+ );
55
+ }
56
+ }
57
+
58
+ for (const hook of hooks) {
59
+ if (!configNames.has(hook.name)) {
60
+ throw new Error(
61
+ `[harness] hook 注册表闭环校验失败:hook "${hook.name}" 注册了实现但没有对应配置声明。` +
62
+ `请补齐 HookConfig 声明,或移除该实现。`
63
+ );
64
+ }
65
+ }
66
+ }
8
67
 
9
68
  export class HookRegistry<C = unknown, R = unknown> {
10
69
  private hooks: Map<string, HookDefinition<C, R>> = new Map();
@@ -15,6 +15,27 @@ export type HookPhase = 'before' | 'after' | 'around';
15
15
  */
16
16
  export type HookErrorStrategy = 'block' | 'warn' | 'ignore';
17
17
 
18
+ /**
19
+ * Hook 配置(G7 归一后形状:consumer 侧的 per-hook 声明表)
20
+ *
21
+ * 声明与实现构成注册表闭环(assertHookRegistryClosed 双向校验):
22
+ * - 声明(HookConfig)是「定义」侧:引用未注册实现 → 抛错
23
+ * - 注册(HookDefinition)是「实现」侧:注册无对应声明 → 抛错
24
+ *
25
+ * 对应 studio 侧 per-hook 运行时配置(hooks/config.ts 的 DEFAULTS)语义:
26
+ * blocking:true ↔ errorStrategy 'block'(失败阻断管线),
27
+ * blocking:false ↔ errorStrategy 'warn'(记录警告继续)——无损映射见
28
+ * config.ts 的 toErrorStrategy。
29
+ */
30
+ export interface HookConfig {
31
+ /** Hook 唯一名称(须与注册的 HookDefinition.name 一致) */
32
+ name: string;
33
+ /** 是否启用(false 时不进入管线) */
34
+ enabled: boolean;
35
+ /** 错误策略:block=失败阻断管线,warn=记录警告继续 */
36
+ errorStrategy: 'block' | 'warn';
37
+ }
38
+
18
39
  /**
19
40
  * Hook 定义
20
41
  *
package/src/index.ts CHANGED
@@ -3,10 +3,9 @@
3
3
  *
4
4
  * 通用工程约束框架
5
5
  *
6
- * 三层约束体系:
7
- * - Iron Laws:绝对禁止,无例外
8
- * - Guidelines:优先建议,有例外
9
- * - Tips:信息性提示,可忽略
6
+ * 约束体系(ADR-0001 kind 二元):
7
+ * - check:可执行检查(Iron Laws 阻断 / Guidelines 告警)
8
+ * - prompt:纯文本注入,不参与检查
10
9
  *
11
10
  * 门禁系统:
12
11
  * - PassesGate:测试门控
@@ -42,12 +41,6 @@ export * from './monitoring';
42
41
  // ========================================
43
42
  export * from './failure';
44
43
 
45
- // ========================================
46
- // 架构约束导出
47
- // ========================================
48
- export * from './architecture/constraint-engine';
49
- export * from './architecture/cross-project-checker';
50
-
51
44
  // ========================================
52
45
  // Spec 检查导出
53
46
  // ========================================
@@ -79,16 +72,7 @@ export * from './verification';
79
72
  export * from './dashboard';
80
73
 
81
74
  // ========================================
82
- // LLM 适配器导出
83
- // ========================================
84
- export * from './llm';
85
-
86
- // ========================================
87
- // 治理模块导出
88
- // ========================================
89
-
90
- // ========================================
91
- // 工具注册表导出
75
+ // 工具路径导出
92
76
  // ========================================
93
77
  export * from './tools';
94
78
 
@@ -171,7 +155,7 @@ export function registerExecutor(
171
155
  }
172
156
 
173
157
  /**
174
- * 检查约束(三层)
158
+ * 检查约束(check 层)
175
159
  *
176
160
  * @param context - 约束上下文
177
161
  * @param options.onTrace - 每条约束检查后的回调(用于记录 trace 到外部存储)
@@ -184,7 +168,6 @@ export async function checkConstraints(
184
168
  if (options?.onTrace) {
185
169
  for (const r of result.ironLaws) options.onTrace(r);
186
170
  for (const r of result.guidelines) options.onTrace(r);
187
- for (const r of result.tips) options.onTrace(r);
188
171
  }
189
172
  return result;
190
173
  }
@@ -13,7 +13,7 @@
13
13
 
14
14
  import * as fs from 'fs';
15
15
  import * as path from 'path';
16
- import type { KnowledgeEntry, KnowledgeType, StorageLayer } from './types';
16
+ import type { KnowledgeEntry, KnowledgeSubsystem, StorageLayer } from './types';
17
17
  import type { KnowledgeStore } from './store';
18
18
 
19
19
  // ── 导入源 ───────────────────────────────────────────────
@@ -62,7 +62,7 @@ export interface ImportConfig {
62
62
  manualEntries?: Array<{
63
63
  title: string;
64
64
  content: string;
65
- type: KnowledgeType;
65
+ type: KnowledgeSubsystem;
66
66
  tags?: string[];
67
67
  }>;
68
68
  /** 是否跳过已导入的 */
@@ -366,7 +366,7 @@ export class ColdStartImporter {
366
366
  private createEntry(params: {
367
367
  title: string;
368
368
  content: string;
369
- type: KnowledgeType;
369
+ type: KnowledgeSubsystem;
370
370
  tags: string[];
371
371
  layer: StorageLayer;
372
372
  }): KnowledgeEntry {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import type {
9
9
  KnowledgeEntry,
10
- KnowledgeType,
10
+ KnowledgeSubsystem,
11
11
  IngestOptions,
12
12
  SourceRef,
13
13
  } from './types';
@@ -176,19 +176,19 @@ export class KnowledgeIngest {
176
176
  };
177
177
  }
178
178
 
179
- private generateId(type: KnowledgeType): string {
179
+ private generateId(type: KnowledgeSubsystem): string {
180
180
  const prefix = type.toUpperCase().slice(0, 3);
181
181
  const existing = this.store.list({ types: [type] });
182
182
  const seq = String(existing.length + 1).padStart(3, '0');
183
183
  return `${prefix}-${seq}`;
184
184
  }
185
185
 
186
- private inferType(_options: IngestOptions): KnowledgeType {
186
+ private inferType(_options: IngestOptions): KnowledgeSubsystem {
187
187
  // Default to 'guideline' if type can't be inferred
188
188
  return 'guideline';
189
189
  }
190
190
 
191
- private findDuplicate(title: string, content: string, type: KnowledgeType): KnowledgeEntry | undefined {
191
+ private findDuplicate(title: string, content: string, type: KnowledgeSubsystem): KnowledgeEntry | undefined {
192
192
  // A1: Read from disk directly to avoid stale index causing dedup failure
193
193
  const all = this.store.readEntriesFromDisk().filter(e => e.type === type);
194
194
 
@@ -6,7 +6,7 @@
6
6
  * - 完成时提取新知识
7
7
  */
8
8
 
9
- import type { KnowledgeEntry, KnowledgeType } from './types';
9
+ import type { KnowledgeEntry, KnowledgeSubsystem } from './types';
10
10
  import type { KnowledgeStore } from './store';
11
11
  import { KnowledgeQuery } from './query';
12
12
  import type { ContextSource } from '../context/types';
@@ -48,7 +48,7 @@ export class KnowledgeLifecycleHooks {
48
48
  onSessionStart(options?: {
49
49
  phase?: string;
50
50
  budget?: number;
51
- focusTypes?: KnowledgeType[];
51
+ focusTypes?: KnowledgeSubsystem[];
52
52
  exclude?: string[];
53
53
  }): ContextSource[] {
54
54
  const budget = options?.budget ?? this.config.injectionBudget ?? 800;
@@ -173,7 +173,7 @@ export class KnowledgeLifecycleHooks {
173
173
  private createExtractionEntry(params: {
174
174
  title: string;
175
175
  content: string;
176
- type: KnowledgeType;
176
+ type: KnowledgeSubsystem;
177
177
  tags: string[];
178
178
  }): KnowledgeEntry {
179
179
  return {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Three orthogonal dimensions:
5
5
  * - StorageLayer: where knowledge lives (shared boundary)
6
- * - KnowledgeType: what knowledge describes (MECE)
6
+ * - KnowledgeSubsystem: what knowledge describes (MECE)
7
7
  * - MaturityLevel: how trusted (lifecycle)
8
8
  */
9
9
 
@@ -11,9 +11,6 @@
11
11
 
12
12
  export type KnowledgeSubsystem = 'model' | 'decision' | 'guideline' | 'pitfall' | 'process' | 'architecture';
13
13
 
14
- /** @deprecated Use KnowledgeSubsystem */
15
- export type KnowledgeType = KnowledgeSubsystem;
16
-
17
14
  export type MaturityLevel = 'draft' | 'verified' | 'proven' | 'archived' | 'active' | 'deprecated';
18
15
 
19
16
  export type StorageLayer = 'personal' | 'team' | 'tech' | 'domain' | 'project' | 'system';
@@ -28,7 +25,7 @@ export type KnowledgeOrigin = 'human' | 'agent' | 'external' | 'system';
28
25
 
29
26
  export interface KnowledgeEntry {
30
27
  id: string;
31
- type: KnowledgeType;
28
+ type: KnowledgeSubsystem;
32
29
  title: string;
33
30
  content: string;
34
31
  maturity: MaturityLevel;
@@ -81,7 +78,7 @@ export interface QueryBudget {
81
78
  phase: string;
82
79
  maxTokens: number;
83
80
  maxEntries: number;
84
- focusTypes: KnowledgeType[];
81
+ focusTypes: KnowledgeSubsystem[];
85
82
  }
86
83
 
87
84
  export interface QueryResult {
@@ -92,7 +89,7 @@ export interface QueryResult {
92
89
  }
93
90
 
94
91
  export interface QueryFilter {
95
- types?: KnowledgeType[];
92
+ types?: KnowledgeSubsystem[];
96
93
  maturity?: MaturityLevel[];
97
94
  layers?: StorageLayer[];
98
95
  tags?: string[];
@@ -180,7 +177,7 @@ export interface ReferenceRecord {
180
177
 
181
178
  export interface IndexEntry {
182
179
  id: string;
183
- type: KnowledgeType;
180
+ type: KnowledgeSubsystem;
184
181
  title: string;
185
182
  maturity: MaturityLevel;
186
183
  layer: StorageLayer;