@agentic-sdlc-kit/contracts 0.0.0-stage → 0.9.1

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 (495) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -2
  3. package/dist/agent/capability.d.ts +9 -0
  4. package/dist/agent/capability.d.ts.map +1 -0
  5. package/dist/agent/capability.js +31 -0
  6. package/dist/agent/capability.js.map +1 -0
  7. package/dist/agent/errors.d.ts +30 -0
  8. package/dist/agent/errors.d.ts.map +1 -0
  9. package/dist/agent/errors.js +62 -0
  10. package/dist/agent/errors.js.map +1 -0
  11. package/dist/agent/events.d.ts +222 -0
  12. package/dist/agent/events.d.ts.map +1 -0
  13. package/dist/agent/events.js +92 -0
  14. package/dist/agent/events.js.map +1 -0
  15. package/dist/agent/execution.d.ts +553 -0
  16. package/dist/agent/execution.d.ts.map +1 -0
  17. package/dist/agent/execution.js +229 -0
  18. package/dist/agent/execution.js.map +1 -0
  19. package/dist/agent/index.d.ts +8 -0
  20. package/dist/agent/index.d.ts.map +1 -0
  21. package/dist/agent/index.js +19 -0
  22. package/dist/agent/index.js.map +1 -0
  23. package/dist/agent/policy.d.ts +135 -0
  24. package/dist/agent/policy.d.ts.map +1 -0
  25. package/dist/agent/policy.js +78 -0
  26. package/dist/agent/policy.js.map +1 -0
  27. package/dist/agent/provider.d.ts +82 -0
  28. package/dist/agent/provider.d.ts.map +1 -0
  29. package/dist/agent/provider.js +33 -0
  30. package/dist/agent/provider.js.map +1 -0
  31. package/dist/agent/session.d.ts +17 -0
  32. package/dist/agent/session.d.ts.map +1 -0
  33. package/dist/agent/session.js +23 -0
  34. package/dist/agent/session.js.map +1 -0
  35. package/dist/application/application-context.d.ts +512 -0
  36. package/dist/application/application-context.d.ts.map +1 -0
  37. package/dist/application/application-context.js +42 -0
  38. package/dist/application/application-context.js.map +1 -0
  39. package/dist/application/application-persistence.d.ts +846 -0
  40. package/dist/application/application-persistence.d.ts.map +1 -0
  41. package/dist/application/application-persistence.js +37 -0
  42. package/dist/application/application-persistence.js.map +1 -0
  43. package/dist/application/application-state.d.ts +89 -0
  44. package/dist/application/application-state.d.ts.map +1 -0
  45. package/dist/application/application-state.js +66 -0
  46. package/dist/application/application-state.js.map +1 -0
  47. package/dist/application/application-transitions.d.ts +23 -0
  48. package/dist/application/application-transitions.d.ts.map +1 -0
  49. package/dist/application/application-transitions.js +60 -0
  50. package/dist/application/application-transitions.js.map +1 -0
  51. package/dist/application/index.d.ts +5 -0
  52. package/dist/application/index.d.ts.map +1 -0
  53. package/dist/application/index.js +6 -0
  54. package/dist/application/index.js.map +1 -0
  55. package/dist/architecture/api-contract.d.ts +259 -0
  56. package/dist/architecture/api-contract.d.ts.map +1 -0
  57. package/dist/architecture/api-contract.js +43 -0
  58. package/dist/architecture/api-contract.js.map +1 -0
  59. package/dist/architecture/architecture-approval.d.ts +40 -0
  60. package/dist/architecture/architecture-approval.d.ts.map +1 -0
  61. package/dist/architecture/architecture-approval.js +24 -0
  62. package/dist/architecture/architecture-approval.js.map +1 -0
  63. package/dist/architecture/architecture-options.d.ts +103 -0
  64. package/dist/architecture/architecture-options.d.ts.map +1 -0
  65. package/dist/architecture/architecture-options.js +35 -0
  66. package/dist/architecture/architecture-options.js.map +1 -0
  67. package/dist/architecture/component-map.d.ts +76 -0
  68. package/dist/architecture/component-map.d.ts.map +1 -0
  69. package/dist/architecture/component-map.js +28 -0
  70. package/dist/architecture/component-map.js.map +1 -0
  71. package/dist/architecture/data-model.d.ts +252 -0
  72. package/dist/architecture/data-model.d.ts.map +1 -0
  73. package/dist/architecture/data-model.js +53 -0
  74. package/dist/architecture/data-model.js.map +1 -0
  75. package/dist/architecture/index.d.ts +8 -0
  76. package/dist/architecture/index.d.ts.map +1 -0
  77. package/dist/architecture/index.js +9 -0
  78. package/dist/architecture/index.js.map +1 -0
  79. package/dist/architecture/operational-design.d.ts +134 -0
  80. package/dist/architecture/operational-design.d.ts.map +1 -0
  81. package/dist/architecture/operational-design.js +46 -0
  82. package/dist/architecture/operational-design.js.map +1 -0
  83. package/dist/architecture/security-design.d.ts +107 -0
  84. package/dist/architecture/security-design.d.ts.map +1 -0
  85. package/dist/architecture/security-design.js +40 -0
  86. package/dist/architecture/security-design.js.map +1 -0
  87. package/dist/common/errors.d.ts +40 -0
  88. package/dist/common/errors.d.ts.map +1 -0
  89. package/dist/common/errors.js +45 -0
  90. package/dist/common/errors.js.map +1 -0
  91. package/dist/common/identifier.d.ts +12 -0
  92. package/dist/common/identifier.d.ts.map +1 -0
  93. package/dist/common/identifier.js +21 -0
  94. package/dist/common/identifier.js.map +1 -0
  95. package/dist/common/index.d.ts +4 -0
  96. package/dist/common/index.d.ts.map +1 -0
  97. package/dist/common/index.js +5 -0
  98. package/dist/common/index.js.map +1 -0
  99. package/dist/common/result.d.ts +28 -0
  100. package/dist/common/result.d.ts.map +1 -0
  101. package/dist/common/result.js +33 -0
  102. package/dist/common/result.js.map +1 -0
  103. package/dist/evaluation/benchmark.d.ts +88 -0
  104. package/dist/evaluation/benchmark.d.ts.map +1 -0
  105. package/dist/evaluation/benchmark.js +34 -0
  106. package/dist/evaluation/benchmark.js.map +1 -0
  107. package/dist/evaluation/index.d.ts +3 -0
  108. package/dist/evaluation/index.d.ts.map +1 -0
  109. package/dist/evaluation/index.js +4 -0
  110. package/dist/evaluation/index.js.map +1 -0
  111. package/dist/evaluation/metrics.d.ts +164 -0
  112. package/dist/evaluation/metrics.d.ts.map +1 -0
  113. package/dist/evaluation/metrics.js +64 -0
  114. package/dist/evaluation/metrics.js.map +1 -0
  115. package/dist/evolution/experiment.d.ts +85 -0
  116. package/dist/evolution/experiment.d.ts.map +1 -0
  117. package/dist/evolution/experiment.js +52 -0
  118. package/dist/evolution/experiment.js.map +1 -0
  119. package/dist/evolution/improvement-hypothesis.d.ts +98 -0
  120. package/dist/evolution/improvement-hypothesis.d.ts.map +1 -0
  121. package/dist/evolution/improvement-hypothesis.js +59 -0
  122. package/dist/evolution/improvement-hypothesis.js.map +1 -0
  123. package/dist/evolution/index.d.ts +3 -0
  124. package/dist/evolution/index.d.ts.map +1 -0
  125. package/dist/evolution/index.js +4 -0
  126. package/dist/evolution/index.js.map +1 -0
  127. package/dist/index.d.ts +24 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +43 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/installer/index.d.ts +4 -0
  132. package/dist/installer/index.d.ts.map +1 -0
  133. package/dist/installer/index.js +5 -0
  134. package/dist/installer/index.js.map +1 -0
  135. package/dist/installer/install-plan.d.ts +168 -0
  136. package/dist/installer/install-plan.d.ts.map +1 -0
  137. package/dist/installer/install-plan.js +40 -0
  138. package/dist/installer/install-plan.js.map +1 -0
  139. package/dist/installer/ownership-manifest.d.ts +86 -0
  140. package/dist/installer/ownership-manifest.d.ts.map +1 -0
  141. package/dist/installer/ownership-manifest.js +34 -0
  142. package/dist/installer/ownership-manifest.js.map +1 -0
  143. package/dist/installer/package-manifest.d.ts +55 -0
  144. package/dist/installer/package-manifest.d.ts.map +1 -0
  145. package/dist/installer/package-manifest.js +46 -0
  146. package/dist/installer/package-manifest.js.map +1 -0
  147. package/dist/learning/engineering-lesson.d.ts +84 -0
  148. package/dist/learning/engineering-lesson.d.ts.map +1 -0
  149. package/dist/learning/engineering-lesson.js +47 -0
  150. package/dist/learning/engineering-lesson.js.map +1 -0
  151. package/dist/learning/engineering-memory.d.ts +66 -0
  152. package/dist/learning/engineering-memory.d.ts.map +1 -0
  153. package/dist/learning/engineering-memory.js +44 -0
  154. package/dist/learning/engineering-memory.js.map +1 -0
  155. package/dist/learning/experience-episode.d.ts +176 -0
  156. package/dist/learning/experience-episode.d.ts.map +1 -0
  157. package/dist/learning/experience-episode.js +68 -0
  158. package/dist/learning/experience-episode.js.map +1 -0
  159. package/dist/learning/experience.d.ts +68 -0
  160. package/dist/learning/experience.d.ts.map +1 -0
  161. package/dist/learning/experience.js +22 -0
  162. package/dist/learning/experience.js.map +1 -0
  163. package/dist/learning/hypothesis.d.ts +57 -0
  164. package/dist/learning/hypothesis.d.ts.map +1 -0
  165. package/dist/learning/hypothesis.js +27 -0
  166. package/dist/learning/hypothesis.js.map +1 -0
  167. package/dist/learning/index.d.ts +8 -0
  168. package/dist/learning/index.d.ts.map +1 -0
  169. package/dist/learning/index.js +9 -0
  170. package/dist/learning/index.js.map +1 -0
  171. package/dist/learning/memory.d.ts +42 -0
  172. package/dist/learning/memory.d.ts.map +1 -0
  173. package/dist/learning/memory.js +20 -0
  174. package/dist/learning/memory.js.map +1 -0
  175. package/dist/learning/promotion.d.ts +31 -0
  176. package/dist/learning/promotion.d.ts.map +1 -0
  177. package/dist/learning/promotion.js +16 -0
  178. package/dist/learning/promotion.js.map +1 -0
  179. package/dist/maintenance/bug-fix-workflow.d.ts +57 -0
  180. package/dist/maintenance/bug-fix-workflow.d.ts.map +1 -0
  181. package/dist/maintenance/bug-fix-workflow.js +100 -0
  182. package/dist/maintenance/bug-fix-workflow.js.map +1 -0
  183. package/dist/maintenance/bug-report.d.ts +62 -0
  184. package/dist/maintenance/bug-report.d.ts.map +1 -0
  185. package/dist/maintenance/bug-report.js +49 -0
  186. package/dist/maintenance/bug-report.js.map +1 -0
  187. package/dist/maintenance/index.d.ts +6 -0
  188. package/dist/maintenance/index.d.ts.map +1 -0
  189. package/dist/maintenance/index.js +7 -0
  190. package/dist/maintenance/index.js.map +1 -0
  191. package/dist/maintenance/performance-baseline.d.ts +80 -0
  192. package/dist/maintenance/performance-baseline.d.ts.map +1 -0
  193. package/dist/maintenance/performance-baseline.js +32 -0
  194. package/dist/maintenance/performance-baseline.js.map +1 -0
  195. package/dist/maintenance/refactor-contract.d.ts +158 -0
  196. package/dist/maintenance/refactor-contract.d.ts.map +1 -0
  197. package/dist/maintenance/refactor-contract.js +65 -0
  198. package/dist/maintenance/refactor-contract.js.map +1 -0
  199. package/dist/maintenance/refactor-workflow.d.ts +79 -0
  200. package/dist/maintenance/refactor-workflow.d.ts.map +1 -0
  201. package/dist/maintenance/refactor-workflow.js +100 -0
  202. package/dist/maintenance/refactor-workflow.js.map +1 -0
  203. package/dist/observer/event-schema.d.ts +49 -0
  204. package/dist/observer/event-schema.d.ts.map +1 -0
  205. package/dist/observer/event-schema.js +48 -0
  206. package/dist/observer/event-schema.js.map +1 -0
  207. package/dist/observer/index.d.ts +5 -0
  208. package/dist/observer/index.d.ts.map +1 -0
  209. package/dist/observer/index.js +6 -0
  210. package/dist/observer/index.js.map +1 -0
  211. package/dist/observer/journal.d.ts +83 -0
  212. package/dist/observer/journal.d.ts.map +1 -0
  213. package/dist/observer/journal.js +76 -0
  214. package/dist/observer/journal.js.map +1 -0
  215. package/dist/observer/retention.d.ts +25 -0
  216. package/dist/observer/retention.d.ts.map +1 -0
  217. package/dist/observer/retention.js +21 -0
  218. package/dist/observer/retention.js.map +1 -0
  219. package/dist/observer/run-summary.d.ts +260 -0
  220. package/dist/observer/run-summary.d.ts.map +1 -0
  221. package/dist/observer/run-summary.js +32 -0
  222. package/dist/observer/run-summary.js.map +1 -0
  223. package/dist/patterns/index.d.ts +2 -0
  224. package/dist/patterns/index.d.ts.map +1 -0
  225. package/dist/patterns/index.js +3 -0
  226. package/dist/patterns/index.js.map +1 -0
  227. package/dist/patterns/pattern.d.ts +106 -0
  228. package/dist/patterns/pattern.d.ts.map +1 -0
  229. package/dist/patterns/pattern.js +69 -0
  230. package/dist/patterns/pattern.js.map +1 -0
  231. package/dist/planning/index.d.ts +2 -0
  232. package/dist/planning/index.d.ts.map +1 -0
  233. package/dist/planning/index.js +3 -0
  234. package/dist/planning/index.js.map +1 -0
  235. package/dist/planning/task.d.ts +178 -0
  236. package/dist/planning/task.d.ts.map +1 -0
  237. package/dist/planning/task.js +35 -0
  238. package/dist/planning/task.js.map +1 -0
  239. package/dist/policy/index.d.ts +2 -0
  240. package/dist/policy/index.d.ts.map +1 -0
  241. package/dist/policy/index.js +3 -0
  242. package/dist/policy/index.js.map +1 -0
  243. package/dist/policy/policy.d.ts +83 -0
  244. package/dist/policy/policy.d.ts.map +1 -0
  245. package/dist/policy/policy.js +57 -0
  246. package/dist/policy/policy.js.map +1 -0
  247. package/dist/product/index.d.ts +5 -0
  248. package/dist/product/index.d.ts.map +1 -0
  249. package/dist/product/index.js +6 -0
  250. package/dist/product/index.js.map +1 -0
  251. package/dist/product/mvp-scope.d.ts +25 -0
  252. package/dist/product/mvp-scope.d.ts.map +1 -0
  253. package/dist/product/mvp-scope.js +18 -0
  254. package/dist/product/mvp-scope.js.map +1 -0
  255. package/dist/product/product-brief.d.ts +94 -0
  256. package/dist/product/product-brief.d.ts.map +1 -0
  257. package/dist/product/product-brief.js +44 -0
  258. package/dist/product/product-brief.js.map +1 -0
  259. package/dist/product/requirements.d.ts +251 -0
  260. package/dist/product/requirements.d.ts.map +1 -0
  261. package/dist/product/requirements.js +50 -0
  262. package/dist/product/requirements.js.map +1 -0
  263. package/dist/product/traceability.d.ts +50 -0
  264. package/dist/product/traceability.d.ts.map +1 -0
  265. package/dist/product/traceability.js +20 -0
  266. package/dist/product/traceability.js.map +1 -0
  267. package/dist/project/index.d.ts +3 -0
  268. package/dist/project/index.d.ts.map +1 -0
  269. package/dist/project/index.js +4 -0
  270. package/dist/project/index.js.map +1 -0
  271. package/dist/project/project-profile.d.ts +79 -0
  272. package/dist/project/project-profile.d.ts.map +1 -0
  273. package/dist/project/project-profile.js +53 -0
  274. package/dist/project/project-profile.js.map +1 -0
  275. package/dist/project/repository-scan.d.ts +82 -0
  276. package/dist/project/repository-scan.d.ts.map +1 -0
  277. package/dist/project/repository-scan.js +29 -0
  278. package/dist/project/repository-scan.js.map +1 -0
  279. package/dist/routing/capability-registry.d.ts +87 -0
  280. package/dist/routing/capability-registry.d.ts.map +1 -0
  281. package/dist/routing/capability-registry.js +26 -0
  282. package/dist/routing/capability-registry.js.map +1 -0
  283. package/dist/routing/escalation.d.ts +25 -0
  284. package/dist/routing/escalation.d.ts.map +1 -0
  285. package/dist/routing/escalation.js +21 -0
  286. package/dist/routing/escalation.js.map +1 -0
  287. package/dist/routing/index.d.ts +5 -0
  288. package/dist/routing/index.d.ts.map +1 -0
  289. package/dist/routing/index.js +6 -0
  290. package/dist/routing/index.js.map +1 -0
  291. package/dist/routing/routing-policy.d.ts +103 -0
  292. package/dist/routing/routing-policy.d.ts.map +1 -0
  293. package/dist/routing/routing-policy.js +32 -0
  294. package/dist/routing/routing-policy.js.map +1 -0
  295. package/dist/routing/routing-request.d.ts +63 -0
  296. package/dist/routing/routing-request.d.ts.map +1 -0
  297. package/dist/routing/routing-request.js +46 -0
  298. package/dist/routing/routing-request.js.map +1 -0
  299. package/dist/runtime-guard/action-classification.d.ts +54 -0
  300. package/dist/runtime-guard/action-classification.d.ts.map +1 -0
  301. package/dist/runtime-guard/action-classification.js +90 -0
  302. package/dist/runtime-guard/action-classification.js.map +1 -0
  303. package/dist/runtime-guard/audit-event.d.ts +98 -0
  304. package/dist/runtime-guard/audit-event.d.ts.map +1 -0
  305. package/dist/runtime-guard/audit-event.js +45 -0
  306. package/dist/runtime-guard/audit-event.js.map +1 -0
  307. package/dist/runtime-guard/index.d.ts +4 -0
  308. package/dist/runtime-guard/index.d.ts.map +1 -0
  309. package/dist/runtime-guard/index.js +5 -0
  310. package/dist/runtime-guard/index.js.map +1 -0
  311. package/dist/runtime-guard/policy-schema.d.ts +139 -0
  312. package/dist/runtime-guard/policy-schema.d.ts.map +1 -0
  313. package/dist/runtime-guard/policy-schema.js +50 -0
  314. package/dist/runtime-guard/policy-schema.js.map +1 -0
  315. package/dist/scaffolding/index.d.ts +3 -0
  316. package/dist/scaffolding/index.d.ts.map +1 -0
  317. package/dist/scaffolding/index.js +4 -0
  318. package/dist/scaffolding/index.js.map +1 -0
  319. package/dist/scaffolding/scaffold-contract.d.ts +528 -0
  320. package/dist/scaffolding/scaffold-contract.d.ts.map +1 -0
  321. package/dist/scaffolding/scaffold-contract.js +50 -0
  322. package/dist/scaffolding/scaffold-contract.js.map +1 -0
  323. package/dist/scaffolding/template-manifest.d.ts +105 -0
  324. package/dist/scaffolding/template-manifest.d.ts.map +1 -0
  325. package/dist/scaffolding/template-manifest.js +44 -0
  326. package/dist/scaffolding/template-manifest.js.map +1 -0
  327. package/dist/secret-guard/detection-rule.d.ts +33 -0
  328. package/dist/secret-guard/detection-rule.d.ts.map +1 -0
  329. package/dist/secret-guard/detection-rule.js +153 -0
  330. package/dist/secret-guard/detection-rule.js.map +1 -0
  331. package/dist/secret-guard/finding.d.ts +89 -0
  332. package/dist/secret-guard/finding.d.ts.map +1 -0
  333. package/dist/secret-guard/finding.js +87 -0
  334. package/dist/secret-guard/finding.js.map +1 -0
  335. package/dist/secret-guard/index.d.ts +5 -0
  336. package/dist/secret-guard/index.d.ts.map +1 -0
  337. package/dist/secret-guard/index.js +6 -0
  338. package/dist/secret-guard/index.js.map +1 -0
  339. package/dist/secret-guard/redaction-policy.d.ts +26 -0
  340. package/dist/secret-guard/redaction-policy.d.ts.map +1 -0
  341. package/dist/secret-guard/redaction-policy.js +30 -0
  342. package/dist/secret-guard/redaction-policy.js.map +1 -0
  343. package/dist/secret-guard/scanner-failure.d.ts +59 -0
  344. package/dist/secret-guard/scanner-failure.d.ts.map +1 -0
  345. package/dist/secret-guard/scanner-failure.js +40 -0
  346. package/dist/secret-guard/scanner-failure.js.map +1 -0
  347. package/dist/specification/index.d.ts +2 -0
  348. package/dist/specification/index.d.ts.map +1 -0
  349. package/dist/specification/index.js +3 -0
  350. package/dist/specification/index.js.map +1 -0
  351. package/dist/specification/specification.d.ts +229 -0
  352. package/dist/specification/specification.d.ts.map +1 -0
  353. package/dist/specification/specification.js +67 -0
  354. package/dist/specification/specification.js.map +1 -0
  355. package/dist/stack-pack/index.d.ts +2 -0
  356. package/dist/stack-pack/index.d.ts.map +1 -0
  357. package/dist/stack-pack/index.js +3 -0
  358. package/dist/stack-pack/index.js.map +1 -0
  359. package/dist/stack-pack/manifest.d.ts +88 -0
  360. package/dist/stack-pack/manifest.d.ts.map +1 -0
  361. package/dist/stack-pack/manifest.js +51 -0
  362. package/dist/stack-pack/manifest.js.map +1 -0
  363. package/dist/verification/index.d.ts +2 -0
  364. package/dist/verification/index.d.ts.map +1 -0
  365. package/dist/verification/index.js +3 -0
  366. package/dist/verification/index.js.map +1 -0
  367. package/dist/verification/report.d.ts +95 -0
  368. package/dist/verification/report.d.ts.map +1 -0
  369. package/dist/verification/report.js +57 -0
  370. package/dist/verification/report.js.map +1 -0
  371. package/dist/workflow/index.d.ts +3 -0
  372. package/dist/workflow/index.d.ts.map +1 -0
  373. package/dist/workflow/index.js +4 -0
  374. package/dist/workflow/index.js.map +1 -0
  375. package/dist/workflow/next-action.d.ts +130 -0
  376. package/dist/workflow/next-action.d.ts.map +1 -0
  377. package/dist/workflow/next-action.js +92 -0
  378. package/dist/workflow/next-action.js.map +1 -0
  379. package/dist/workflow/workflow.d.ts +68 -0
  380. package/dist/workflow/workflow.d.ts.map +1 -0
  381. package/dist/workflow/workflow.js +33 -0
  382. package/dist/workflow/workflow.js.map +1 -0
  383. package/package.json +31 -3
  384. package/src/agent/agent.test.ts +451 -0
  385. package/src/agent/capability.ts +35 -0
  386. package/src/agent/errors.ts +69 -0
  387. package/src/agent/events.ts +107 -0
  388. package/src/agent/execution.ts +275 -0
  389. package/src/agent/index.ts +19 -0
  390. package/src/agent/policy.ts +82 -0
  391. package/src/agent/provider.ts +124 -0
  392. package/src/agent/session.ts +29 -0
  393. package/src/application/application-context.ts +47 -0
  394. package/src/application/application-persistence.ts +44 -0
  395. package/src/application/application-state.test.ts +107 -0
  396. package/src/application/application-state.ts +81 -0
  397. package/src/application/application-transitions.ts +71 -0
  398. package/src/application/index.ts +5 -0
  399. package/src/architecture/api-contract.ts +56 -0
  400. package/src/architecture/architecture-approval.ts +27 -0
  401. package/src/architecture/architecture-options.ts +42 -0
  402. package/src/architecture/architecture.test.ts +263 -0
  403. package/src/architecture/component-map.ts +35 -0
  404. package/src/architecture/data-model.ts +66 -0
  405. package/src/architecture/index.ts +8 -0
  406. package/src/architecture/operational-design.ts +55 -0
  407. package/src/architecture/security-design.ts +47 -0
  408. package/src/common/errors.test.ts +46 -0
  409. package/src/common/errors.ts +114 -0
  410. package/src/common/identifier.test.ts +51 -0
  411. package/src/common/identifier.ts +33 -0
  412. package/src/common/index.ts +4 -0
  413. package/src/common/result.test.ts +52 -0
  414. package/src/common/result.ts +50 -0
  415. package/src/evaluation/benchmark.ts +42 -0
  416. package/src/evaluation/index.ts +3 -0
  417. package/src/evaluation/metrics.ts +76 -0
  418. package/src/evolution/experiment.ts +61 -0
  419. package/src/evolution/improvement-hypothesis.ts +67 -0
  420. package/src/evolution/index.ts +3 -0
  421. package/src/index.test.ts +54 -0
  422. package/src/index.ts +53 -0
  423. package/src/installer/index.ts +4 -0
  424. package/src/installer/install-plan.ts +49 -0
  425. package/src/installer/ownership-manifest.ts +40 -0
  426. package/src/installer/package-manifest.ts +54 -0
  427. package/src/learning/engineering-lesson.ts +55 -0
  428. package/src/learning/engineering-memory.ts +51 -0
  429. package/src/learning/experience-episode.ts +76 -0
  430. package/src/learning/experience.ts +27 -0
  431. package/src/learning/hypothesis.ts +33 -0
  432. package/src/learning/index.ts +8 -0
  433. package/src/learning/memory.ts +25 -0
  434. package/src/learning/promotion.ts +19 -0
  435. package/src/maintenance/bug-fix-workflow.ts +119 -0
  436. package/src/maintenance/bug-report.ts +58 -0
  437. package/src/maintenance/index.ts +6 -0
  438. package/src/maintenance/maintenance.test.ts +219 -0
  439. package/src/maintenance/performance-baseline.ts +35 -0
  440. package/src/maintenance/refactor-contract.ts +77 -0
  441. package/src/maintenance/refactor-workflow.ts +121 -0
  442. package/src/observer/event-schema.ts +54 -0
  443. package/src/observer/index.ts +5 -0
  444. package/src/observer/journal.test.ts +73 -0
  445. package/src/observer/journal.ts +84 -0
  446. package/src/observer/retention.ts +24 -0
  447. package/src/observer/run-summary.ts +37 -0
  448. package/src/patterns/index.ts +2 -0
  449. package/src/patterns/pattern.ts +80 -0
  450. package/src/planning/index.ts +2 -0
  451. package/src/planning/task.ts +47 -0
  452. package/src/policy/index.ts +2 -0
  453. package/src/policy/policy.test.ts +50 -0
  454. package/src/policy/policy.ts +67 -0
  455. package/src/product/index.ts +5 -0
  456. package/src/product/mvp-scope.ts +21 -0
  457. package/src/product/product-brief.test.ts +108 -0
  458. package/src/product/product-brief.ts +53 -0
  459. package/src/product/requirements.ts +59 -0
  460. package/src/product/traceability.ts +25 -0
  461. package/src/project/index.ts +3 -0
  462. package/src/project/project-profile.test.ts +98 -0
  463. package/src/project/project-profile.ts +65 -0
  464. package/src/project/repository-scan.ts +34 -0
  465. package/src/routing/capability-registry.ts +31 -0
  466. package/src/routing/escalation.ts +24 -0
  467. package/src/routing/index.ts +5 -0
  468. package/src/routing/routing-policy.ts +38 -0
  469. package/src/routing/routing-request.ts +55 -0
  470. package/src/runtime-guard/action-classification.ts +99 -0
  471. package/src/runtime-guard/audit-event.ts +49 -0
  472. package/src/runtime-guard/index.ts +4 -0
  473. package/src/runtime-guard/policy-schema.ts +56 -0
  474. package/src/runtime-guard/runtime-guard.test.ts +147 -0
  475. package/src/scaffolding/index.ts +3 -0
  476. package/src/scaffolding/scaffold-contract.test.ts +107 -0
  477. package/src/scaffolding/scaffold-contract.ts +63 -0
  478. package/src/scaffolding/template-manifest.ts +52 -0
  479. package/src/secret-guard/detection-rule.ts +168 -0
  480. package/src/secret-guard/finding.ts +95 -0
  481. package/src/secret-guard/index.ts +5 -0
  482. package/src/secret-guard/redaction-policy.ts +34 -0
  483. package/src/secret-guard/scanner-failure.ts +47 -0
  484. package/src/secret-guard/secret-guard.test.ts +130 -0
  485. package/src/specification/index.ts +2 -0
  486. package/src/specification/specification.ts +79 -0
  487. package/src/stack-pack/index.ts +2 -0
  488. package/src/stack-pack/manifest.ts +60 -0
  489. package/src/verification/index.ts +2 -0
  490. package/src/verification/report.test.ts +91 -0
  491. package/src/verification/report.ts +62 -0
  492. package/src/workflow/index.ts +3 -0
  493. package/src/workflow/next-action.test.ts +101 -0
  494. package/src/workflow/next-action.ts +101 -0
  495. package/src/workflow/workflow.ts +49 -0
@@ -0,0 +1,61 @@
1
+ // packages/contracts/src/evolution/experiment.ts
2
+ //
3
+ // M32 Evolution Lab experiment (RESEARCH.md §7). An isolated candidate
4
+ // test against a pinned baseline.
5
+
6
+ import { z } from 'zod';
7
+
8
+ export const EXPERIMENT_SCHEMA_VERSION = 1 as const;
9
+
10
+ export const AutonomyLevelSchema = z.enum(['L0', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6']);
11
+
12
+ export const ExperimentSpecSchema = z.object({
13
+ schemaVersion: z.literal(EXPERIMENT_SCHEMA_VERSION),
14
+ id: z.string(),
15
+ // The hypothesis this experiment tests.
16
+ hypothesisId: z.string(),
17
+ // The baseline kit version (pinned).
18
+ baselineKitVersion: z.string().min(1),
19
+ // The candidate kit version (isolated branch).
20
+ candidateKitVersion: z.string().min(1),
21
+ // The benchmark suite to run.
22
+ benchmarkSuiteId: z.string(),
23
+ benchmarkSuiteVersion: z.string(),
24
+ // The number of repetitions (for variance).
25
+ repetitions: z.number().int().min(1).max(10).default(3),
26
+ // The autonomy level this experiment is authorized for.
27
+ autonomyLevel: AutonomyLevelSchema,
28
+ // Whether to use held-out cases (generalization test).
29
+ useHeldOut: z.boolean().default(true),
30
+ createdAt: z.string(),
31
+ });
32
+
33
+ export type AutonomyLevel = z.infer<typeof AutonomyLevelSchema>;
34
+ export type ExperimentSpec = z.infer<typeof ExperimentSpecSchema>;
35
+
36
+ /**
37
+ * Promotion request (M33). When an experiment's candidate beats the
38
+ * baseline and passes guardrails, the engine opens a promotion request.
39
+ *
40
+ * INVARIANT (RESEARCH.md §8): promotion to production requires human
41
+ * approval (L5). The evolution engine MUST NOT merge its own PRs.
42
+ */
43
+ export const PromotionRequestSchema = z.object({
44
+ schemaVersion: z.literal(1),
45
+ experimentId: z.string(),
46
+ hypothesisId: z.string(),
47
+ // The comparison report that justifies promotion.
48
+ comparisonReportId: z.string(),
49
+ // The PR that was opened (url or local path).
50
+ prRef: z.string().min(1),
51
+ // The autonomy level required to approve this promotion.
52
+ requiredAutonomyLevel: AutonomyLevelSchema,
53
+ // Whether human approval has been granted.
54
+ approved: z.boolean().default(false),
55
+ approvedBy: z.string().optional(),
56
+ approvedAt: z.string().optional(),
57
+ // Rollback plan: how to undo this promotion if it causes regressions.
58
+ rollbackPlan: z.string().min(1),
59
+ });
60
+
61
+ export type PromotionRequest = z.infer<typeof PromotionRequestSchema>;
@@ -0,0 +1,67 @@
1
+ // packages/contracts/src/evolution/improvement-hypothesis.ts
2
+ //
3
+ // M31 improvement hypothesis (RESEARCH.md §6). Every proposed improvement
4
+ // must describe a measurable problem and a testable solution.
5
+ //
6
+ // The engine is also allowed to recommend doing nothing.
7
+
8
+ import { z } from 'zod';
9
+
10
+ export const HYPOTHESIS_SCHEMA_VERSION = 1 as const;
11
+
12
+ export const ImprovementCategorySchema = z.enum([
13
+ 'knowledge',
14
+ 'skill',
15
+ 'agent',
16
+ 'workflow',
17
+ 'script',
18
+ 'pattern',
19
+ 'routing',
20
+ 'core',
21
+ 'security',
22
+ ]);
23
+
24
+ export const ImprovementHypothesisSchema = z.object({
25
+ schemaVersion: z.literal(HYPOTHESIS_SCHEMA_VERSION),
26
+ id: z.string().regex(/^[A-Z]+-[0-9]{3,}$/, 'id must match EVO-NNN'),
27
+ title: z.string().min(1),
28
+ category: ImprovementCategorySchema,
29
+ // The observed problem (with evidence).
30
+ observedProblem: z.string().min(1),
31
+ // The episodes that evidence the problem.
32
+ evidenceEpisodeIds: z.array(z.string()).min(1),
33
+ // The hypothesis: what change might fix the problem.
34
+ hypothesis: z.string().min(1),
35
+ // The proposed change (file paths, content, etc.).
36
+ proposedChange: z.string().min(1),
37
+ // The success metric that would confirm the improvement.
38
+ successMetric: z.object({
39
+ metric: z.string().min(1),
40
+ // The threshold the candidate must beat.
41
+ threshold: z.number(),
42
+ direction: z.enum(['higher-is-better', 'lower-is-better']),
43
+ }),
44
+ // Guardrails: things the candidate must NOT regress.
45
+ guardrails: z
46
+ .array(
47
+ z.object({
48
+ metric: z.string().min(1),
49
+ threshold: z.number(),
50
+ direction: z.enum(['higher-is-better', 'lower-is-better']),
51
+ }),
52
+ )
53
+ .default([]),
54
+ // Estimated impact, cost, and risk (for prioritization).
55
+ estimatedImpact: z.enum(['low', 'medium', 'high']),
56
+ estimatedCost: z.enum(['low', 'medium', 'high']),
57
+ estimatedRisk: z.enum(['low', 'medium', 'high']),
58
+ // Priority score (higher = more important to attempt).
59
+ priorityScore: z.number().min(0),
60
+ status: z
61
+ .enum(['proposed', 'experimenting', 'approved', 'rejected', 'needs-revision'])
62
+ .default('proposed'),
63
+ createdAt: z.string(),
64
+ });
65
+
66
+ export type ImprovementCategory = z.infer<typeof ImprovementCategorySchema>;
67
+ export type ImprovementHypothesis = z.infer<typeof ImprovementHypothesisSchema>;
@@ -0,0 +1,3 @@
1
+ // packages/contracts/src/evolution/index.ts
2
+ export * from './improvement-hypothesis.js';
3
+ export * from './experiment.js';
@@ -0,0 +1,54 @@
1
+ // packages/contracts/src/index.test.ts
2
+ //
3
+ // Smoke test that proves:
4
+ // 1. Every public symbol is exported from the barrel.
5
+ // 2. The package has no internal cycle (imports resolve without error).
6
+ //
7
+ // This is the contract-test referenced in TESTING.md §4.1.
8
+
9
+ import { describe, expect, it } from 'vitest';
10
+ import * as contracts from './index.js';
11
+
12
+ describe('contracts barrel', () => {
13
+ it('exports the common surface', () => {
14
+ expect(typeof contracts.ok).toBe('function');
15
+ expect(typeof contracts.err).toBe('function');
16
+ expect(typeof contracts.Errors).toBe('object');
17
+ expect(typeof contracts.IdentifierSchema).toBe('object');
18
+ expect(typeof contracts.isValidIdentifier).toBe('function');
19
+ });
20
+
21
+ it('exports the project surface', () => {
22
+ expect(typeof contracts.ProjectProfileSchema).toBe('object');
23
+ expect(typeof contracts.RepositoryScanSchema).toBe('object');
24
+ expect(contracts.PROJECT_PROFILE_SCHEMA_VERSION).toBe(1);
25
+ });
26
+
27
+ it('exports the workflow surface', () => {
28
+ expect(typeof contracts.WorkflowModeSchema).toBe('object');
29
+ expect(typeof contracts.WorkflowStatusSchema).toBe('object');
30
+ expect(typeof contracts.WorkflowStateSchema).toBe('object');
31
+ });
32
+
33
+ it('exports the specification surface', () => {
34
+ expect(typeof contracts.FeatureSpecificationSchema).toBe('object');
35
+ expect(typeof contracts.BddScenarioSchema).toBe('object');
36
+ });
37
+
38
+ it('exports the planning surface', () => {
39
+ expect(typeof contracts.TaskSchema).toBe('object');
40
+ expect(typeof contracts.ImplementationPlanSchema).toBe('object');
41
+ });
42
+
43
+ it('exports the verification surface', () => {
44
+ expect(typeof contracts.VerificationReportSchema).toBe('object');
45
+ expect(typeof contracts.rollupReportStatus).toBe('function');
46
+ expect(contracts.VERIFICATION_REPORT_SCHEMA_VERSION).toBe(1);
47
+ });
48
+
49
+ it('exports the policy surface', () => {
50
+ expect(typeof contracts.PolicyDecisionSchema).toBe('object');
51
+ expect(typeof contracts.PolicyActionSchema).toBe('object');
52
+ expect(typeof contracts.ApprovalSchema).toBe('object');
53
+ });
54
+ });
package/src/index.ts ADDED
@@ -0,0 +1,53 @@
1
+ // packages/contracts/src/index.ts
2
+ //
3
+ // Barrel for @agentic-sdlc-kit/contracts.
4
+ //
5
+ // Architectural invariant (ARCHITECTURE.md §6): this package imports
6
+ // nothing from sibling packages. Adding an import here from any other
7
+ // @agentic-sdlc-kit/* package is a Critical bug and fails the
8
+ // scripts/check-architecture.ts gate.
9
+
10
+ // M1 surface:
11
+ export * from './common/index.js';
12
+ export * from './project/index.js';
13
+ export * from './workflow/index.js';
14
+ export * from './specification/index.js';
15
+ export * from './planning/index.js';
16
+ export * from './verification/index.js';
17
+ export * from './policy/index.js';
18
+
19
+ // M8 surface:
20
+ export * from './application/index.js';
21
+ export * from './product/index.js';
22
+ export * from './architecture/index.js';
23
+ export * from './scaffolding/index.js';
24
+
25
+ // M9 surface:
26
+ export * from './maintenance/index.js';
27
+
28
+ // M10–M11 shared security surface:
29
+ export * from './runtime-guard/index.js';
30
+ export * from './secret-guard/index.js';
31
+
32
+ // M12 routing surface:
33
+ export * from './routing/index.js';
34
+
35
+ // M13 observer surface:
36
+ export * from './observer/index.js';
37
+
38
+ // M14 stack packs + patterns surface:
39
+ export * from './stack-pack/index.js';
40
+ export * from './patterns/index.js';
41
+
42
+ // M15 installer surface:
43
+ export * from './installer/index.js';
44
+
45
+ // M19 evaluation surface:
46
+ export * from './evaluation/index.js';
47
+
48
+ // M27–M35 self-evolution surface:
49
+ export * from './learning/index.js';
50
+ export * from './evolution/index.js';
51
+
52
+ // M36 agent execution surface (ADR-0019, ADR-0020):
53
+ export * from './agent/index.js';
@@ -0,0 +1,4 @@
1
+ // packages/contracts/src/installer/index.ts
2
+ export * from './package-manifest.js';
3
+ export * from './ownership-manifest.js';
4
+ export * from './install-plan.js';
@@ -0,0 +1,49 @@
1
+ // packages/contracts/src/installer/install-plan.ts
2
+ //
3
+ // M15 install plan and uninstall plan (M15-04, M15-08). The installer
4
+ // produces a plan BEFORE executing, so the user can review and approve.
5
+
6
+ import { z } from 'zod';
7
+ import { PackageManifestSchema } from './package-manifest.js';
8
+
9
+ export const InstallOperationKindSchema = z.enum([
10
+ 'create', // new file
11
+ 'skip-existing', // file exists; preserve=true
12
+ 'overwrite-approved', // file exists; user approved overwrite
13
+ 'upgrade', // file exists; kit-owned; replace with new version
14
+ ]);
15
+
16
+ export const InstallOperationSchema = z.object({
17
+ packageId: z.string(),
18
+ path: z.string().min(1),
19
+ kind: InstallOperationKindSchema,
20
+ reason: z.string().optional(),
21
+ });
22
+
23
+ export const InstallPlanSchema = z.object({
24
+ schemaVersion: z.literal(1),
25
+ scope: z.enum(['project', 'user']),
26
+ profile: z.string(),
27
+ packages: z.array(PackageManifestSchema),
28
+ operations: z.array(InstallOperationSchema),
29
+ // Validation errors (e.g., version conflicts, missing dependencies).
30
+ validationErrors: z.array(z.string()).default([]),
31
+ // Whether this is a dry-run (no execution).
32
+ dryRun: z.boolean().default(true),
33
+ });
34
+
35
+ export const UninstallPlanSchema = z.object({
36
+ schemaVersion: z.literal(1),
37
+ scope: z.enum(['project', 'user']),
38
+ // Files that will be removed (only kit-owned files).
39
+ removePaths: z.array(z.string()),
40
+ // Files that will be preserved (user-owned or modified).
41
+ preservePaths: z.array(z.string()),
42
+ // Whether this is a dry-run.
43
+ dryRun: z.boolean().default(true),
44
+ });
45
+
46
+ export type InstallOperationKind = z.infer<typeof InstallOperationKindSchema>;
47
+ export type InstallOperation = z.infer<typeof InstallOperationSchema>;
48
+ export type InstallPlan = z.infer<typeof InstallPlanSchema>;
49
+ export type UninstallPlan = z.infer<typeof UninstallPlanSchema>;
@@ -0,0 +1,40 @@
1
+ // packages/contracts/src/installer/ownership-manifest.ts
2
+ //
3
+ // M15 ownership manifest (M15-06). Tracks which files the kit owns in a
4
+ // target installation so uninstall (M15-09) removes only kit-owned files.
5
+
6
+ import { z } from 'zod';
7
+
8
+ export const OWNERSHIP_MANIFEST_SCHEMA_VERSION = 1 as const;
9
+
10
+ export const OwnershipEntrySchema = z.object({
11
+ // The package that owns this file.
12
+ packageId: z.string(),
13
+ packageVersion: z.string(),
14
+ // The relative path within the target installation.
15
+ path: z.string().min(1),
16
+ // SHA-256 of the file content at install time (so we can detect
17
+ // modifications by the user).
18
+ sha256: z.string().regex(/^[0-9a-f]{64}$/),
19
+ // When the file was installed.
20
+ installedAt: z.string(),
21
+ // Whether the file was preserved (not overwritten) on upgrade.
22
+ preserved: z.boolean().default(false),
23
+ // For symlink entries: the absolute path the link pointed to when the kit
24
+ // created or verified it. Uninstall removes the link only while it still
25
+ // points here. Absent on manifests written before this field existed.
26
+ target: z.string().optional(),
27
+ });
28
+
29
+ export const OwnershipManifestSchema = z.object({
30
+ schemaVersion: z.literal(OWNERSHIP_MANIFEST_SCHEMA_VERSION),
31
+ // The installation root.
32
+ root: z.string().min(1),
33
+ // The scope: project (relative to a project root) or user (relative to
34
+ // a user home directory).
35
+ scope: z.enum(['project', 'user']),
36
+ entries: z.array(OwnershipEntrySchema),
37
+ });
38
+
39
+ export type OwnershipEntry = z.infer<typeof OwnershipEntrySchema>;
40
+ export type OwnershipManifest = z.infer<typeof OwnershipManifestSchema>;
@@ -0,0 +1,54 @@
1
+ // packages/contracts/src/installer/package-manifest.ts
2
+ //
3
+ // M15 package manifest (M15-01) and installation profiles (M15-02).
4
+
5
+ import { z } from 'zod';
6
+
7
+ export const INSTALLER_SCHEMA_VERSION = 1 as const;
8
+
9
+ export const InstallationProfileSchema = z.enum([
10
+ 'minimal',
11
+ 'full-sdlc',
12
+ 'runtime',
13
+ 'stack-specific',
14
+ ]);
15
+
16
+ export const PackageManifestSchema = z.object({
17
+ schemaVersion: z.literal(INSTALLER_SCHEMA_VERSION),
18
+ // The package id (e.g., "sdlc-guard", "node-typescript-pack").
19
+ id: z.string().regex(/^[a-z][a-z0-9-]*$/),
20
+ // Human-readable name.
21
+ name: z.string().min(1),
22
+ version: z.string().regex(/^\d+\.\d+\.\d+$/, 'semver'),
23
+ description: z.string().min(1),
24
+ // What kind of package this is.
25
+ kind: z.enum([
26
+ 'core',
27
+ 'mod',
28
+ 'skill-pack',
29
+ 'agent-pack',
30
+ 'command-pack',
31
+ 'stack-pack',
32
+ 'pattern-pack',
33
+ 'policy-pack',
34
+ ]),
35
+ // Which profiles include this package by default.
36
+ profiles: z.array(InstallationProfileSchema).default([]),
37
+ // Required kit compatibility.
38
+ kitCompatibility: z.string().min(1),
39
+ // Files this package owns (relative paths within the target installation).
40
+ files: z
41
+ .array(
42
+ z.object({
43
+ path: z.string().min(1),
44
+ // True if the file should never be overwritten on upgrade.
45
+ preserve: z.boolean().default(false),
46
+ }),
47
+ )
48
+ .default([]),
49
+ // Dependencies on other packages.
50
+ dependsOn: z.array(z.string()).default([]),
51
+ });
52
+
53
+ export type PackageManifest = z.infer<typeof PackageManifestSchema>;
54
+ export type InstallationProfile = z.infer<typeof InstallationProfileSchema>;
@@ -0,0 +1,55 @@
1
+ // packages/contracts/src/learning/engineering-lesson.ts
2
+ //
3
+ // M30 engineering lesson (RESEARCH.md §9). A lesson is a verified claim
4
+ // derived from repeated episodes. It must include evidence, scope,
5
+ // confidence, and counterexamples.
6
+ //
7
+ // INVARIANT (RESEARCH.md §9): "An AI's explanation of a failure is not
8
+ // necessarily the actual root cause." Lessons must include evidence and
9
+ // are classified by confidence level.
10
+
11
+ import { z } from 'zod';
12
+
13
+ export const LESSON_SCHEMA_VERSION = 1 as const;
14
+
15
+ export const LessonClassificationSchema = z.enum([
16
+ 'verified', // multiple independent evidence sources; high confidence
17
+ 'probable', // some evidence; medium confidence
18
+ 'hypothesis', // proposed; not yet validated
19
+ 'rejected', // invalidated by counterexamples
20
+ ]);
21
+
22
+ export const EngineeringLessonSchema = z.object({
23
+ schemaVersion: z.literal(LESSON_SCHEMA_VERSION),
24
+ id: z.string(),
25
+ title: z.string().min(1),
26
+ // The claim this lesson makes.
27
+ claim: z.string().min(1),
28
+ // The scope where this lesson applies.
29
+ scope: z.object({
30
+ project: z.string().optional(),
31
+ stacks: z.array(z.string()).default([]),
32
+ workflows: z.array(z.string()).default([]),
33
+ }),
34
+ // Evidence supporting the claim (episode ids + evidence references).
35
+ evidence: z.array(
36
+ z.object({
37
+ episodeId: z.string(),
38
+ evidenceRef: z.string().min(1),
39
+ }),
40
+ ),
41
+ // Confidence (0.0 to 1.0); supported by evidence count and independence.
42
+ confidence: z.number().min(0).max(1),
43
+ // The classification (verified / probable / hypothesis / rejected).
44
+ classification: LessonClassificationSchema,
45
+ // Where this lesson applies.
46
+ applicability: z.array(z.string()).default([]),
47
+ // Episodes that contradict the claim (must be tracked honestly).
48
+ counterexamples: z.array(z.string()).default([]),
49
+ createdAt: z.string(),
50
+ lastValidatedAt: z.string().optional(),
51
+ expiresAt: z.string().optional(),
52
+ });
53
+
54
+ export type LessonClassification = z.infer<typeof LessonClassificationSchema>;
55
+ export type EngineeringLesson = z.infer<typeof EngineeringLessonSchema>;
@@ -0,0 +1,51 @@
1
+ // packages/contracts/src/learning/engineering-memory.ts
2
+ //
3
+ // M29 hierarchical engineering memory (RESEARCH.md §4). Four levels:
4
+ // 1. Episodic — what happened (individual runs).
5
+ // 2. Semantic — what we know (verified facts, conventions).
6
+ // 3. Procedural — how to do it (Skills, recipes, strategies).
7
+ // 4. Meta — how to learn (relevance, staleness, retrieval strategy).
8
+ //
9
+ // Memory scope (RESEARCH.md §10): project, organization, global. Private
10
+ // application code or organization-specific information must not be merged
11
+ // into a public knowledge base without explicit contribution permissions.
12
+
13
+ import { z } from 'zod';
14
+
15
+ export const MEMORY_SCOPE_SCHEMA_VERSION = 1 as const;
16
+
17
+ export const MemoryLevelSchema = z.enum(['episodic', 'semantic', 'procedural', 'meta']);
18
+ export const MemoryScopeSchema = z.enum(['project', 'organization', 'global']);
19
+
20
+ export const EngineeringMemoryEntrySchema = z.object({
21
+ schemaVersion: z.literal(MEMORY_SCOPE_SCHEMA_VERSION),
22
+ id: z.string(),
23
+ level: MemoryLevelSchema,
24
+ scope: MemoryScopeSchema,
25
+ // The scope identifier (project id, organization id, or "global").
26
+ scopeId: z.string().min(1),
27
+ // A short title for retrieval.
28
+ title: z.string().min(1),
29
+ // The memory content (markdown).
30
+ content: z.string().min(1),
31
+ // Provenance: where this memory came from.
32
+ source: z.object({
33
+ // The episode(s) this memory was derived from.
34
+ episodeIds: z.array(z.string()).default([]),
35
+ // Whether this was automatically derived or manually contributed.
36
+ derivation: z.enum(['automatic', 'manual', 'approved-pr']),
37
+ }),
38
+ // Confidence (0.0 to 1.0); must be supported by evidence.
39
+ confidence: z.number().min(0).max(1),
40
+ // When this memory was created and last validated.
41
+ createdAt: z.string(),
42
+ lastValidatedAt: z.string().optional(),
43
+ // When this memory expires (staleness horizon).
44
+ expiresAt: z.string().optional(),
45
+ // Tags for retrieval.
46
+ tags: z.array(z.string()).default([]),
47
+ });
48
+
49
+ export type MemoryLevel = z.infer<typeof MemoryLevelSchema>;
50
+ export type MemoryScope = z.infer<typeof MemoryScopeSchema>;
51
+ export type EngineeringMemoryEntry = z.infer<typeof EngineeringMemoryEntrySchema>;
@@ -0,0 +1,76 @@
1
+ // packages/contracts/src/learning/experience-episode.ts
2
+ //
3
+ // M28 experience episode (M28-01 through M28-08). Every completed workflow
4
+ // produces an ExperienceEpisode record that the learning engine consumes.
5
+ //
6
+ // Per RESEARCH.md §3.2: keep sensitive source code, secrets, private
7
+ // prompts and user data out of shared learning records unless explicitly
8
+ // required and authorized. Store evidence references and minimal summaries
9
+ // by default.
10
+
11
+ import { z } from 'zod';
12
+
13
+ export const EXPERIENCE_EPISODE_SCHEMA_VERSION = 1 as const;
14
+
15
+ export const WorkflowKindSchema = z.enum(['app', 'feature', 'fix', 'refactor', 'release']);
16
+
17
+ export const EpisodeOutcomeSchema = z.enum(['success', 'partial', 'failed']);
18
+
19
+ export const ExperienceEpisodeSchema = z.object({
20
+ schemaVersion: z.literal(EXPERIENCE_EPISODE_SCHEMA_VERSION),
21
+ id: z.string(),
22
+ // The run this episode came from.
23
+ runId: z.string(),
24
+ // Scope: where this episode is allowed to be shared.
25
+ scope: z.object({
26
+ organizationId: z.string().optional(),
27
+ projectId: z.string().optional(),
28
+ stacks: z.array(z.string()).default([]),
29
+ }),
30
+ // The workflow that produced this episode.
31
+ workflow: WorkflowKindSchema,
32
+ // A content-derived fingerprint of the task (so we can detect duplicates
33
+ // and correlate similar tasks). NOT the raw prompt.
34
+ taskFingerprint: z.string().min(1),
35
+ // The kit version that produced this episode.
36
+ kitVersion: z.string().min(1),
37
+ // The runtime version (if known).
38
+ runtimeVersion: z.string().optional(),
39
+ // Component versions in effect when the episode ran.
40
+ components: z.object({
41
+ skillVersions: z.record(z.string(), z.string()).default({}),
42
+ agentVersions: z.record(z.string(), z.string()).default({}),
43
+ modVersions: z.record(z.string(), z.string()).default({}),
44
+ stackPackVersions: z.record(z.string(), z.string()).default({}),
45
+ }),
46
+ // The outcome.
47
+ outcome: z.object({
48
+ status: EpisodeOutcomeSchema,
49
+ acceptanceCriteriaPassed: z.number().int().nonnegative(),
50
+ acceptanceCriteriaFailed: z.number().int().nonnegative(),
51
+ regressionDetected: z.boolean(),
52
+ }),
53
+ // Evidence references (paths/ids; never raw secret content).
54
+ evidence: z.object({
55
+ verificationReportId: z.string().optional(),
56
+ reviewReportId: z.string().optional(),
57
+ affectedFiles: z.array(z.string()).default([]),
58
+ }),
59
+ // Human feedback (optional).
60
+ feedback: z
61
+ .object({
62
+ humanRating: z.number().min(1).max(5).optional(),
63
+ corrections: z.array(z.string()).default([]),
64
+ approved: z.boolean().optional(),
65
+ })
66
+ .optional(),
67
+ // Timestamps.
68
+ timestamps: z.object({
69
+ startedAt: z.string(),
70
+ completedAt: z.string(),
71
+ }),
72
+ });
73
+
74
+ export type WorkflowKind = z.infer<typeof WorkflowKindSchema>;
75
+ export type EpisodeOutcome = z.infer<typeof EpisodeOutcomeSchema>;
76
+ export type ExperienceEpisode = z.infer<typeof ExperienceEpisodeSchema>;
@@ -0,0 +1,27 @@
1
+ // packages/contracts/src/learning/experience.ts
2
+ //
3
+ // M27/M28 Experience contracts: structured telemetry from workflow executions,
4
+ // verification reports, and human corrections for continuous learning.
5
+
6
+ import { z } from 'zod';
7
+
8
+ export const ExperiencePhaseSchema = z.object({
9
+ name: z.string().min(1),
10
+ status: z.enum(['passed', 'failed']),
11
+ durationMs: z.number().nonnegative(),
12
+ });
13
+
14
+ export const ExperienceRecordSchema = z.object({
15
+ id: z.string().min(1),
16
+ workflowId: z.string().min(1),
17
+ featureId: z.string().min(1),
18
+ stack: z.string().min(1),
19
+ outcome: z.enum(['success', 'failure', 'partial']),
20
+ phases: z.array(ExperiencePhaseSchema),
21
+ failureSummary: z.string().optional(),
22
+ humanCorrection: z.string().optional(),
23
+ timestamp: z.string().min(1),
24
+ });
25
+
26
+ export type ExperiencePhase = z.infer<typeof ExperiencePhaseSchema>;
27
+ export type ExperienceRecord = z.infer<typeof ExperienceRecordSchema>;
@@ -0,0 +1,33 @@
1
+ // packages/contracts/src/learning/hypothesis.ts
2
+ //
3
+ // M31/M32 Improvement Hypothesis & Evolution Lab contracts.
4
+
5
+ import { z } from 'zod';
6
+
7
+ export const SkillImprovementHypothesisSchema = z.object({
8
+ id: z.string().min(1),
9
+ targetSkill: z.string().min(1),
10
+ problemObserved: z.string().min(1),
11
+ proposedChange: z.string().min(1),
12
+ expectedBenefit: z.string().min(1),
13
+ riskLevel: z.enum(['low', 'medium', 'high']),
14
+ benchmarkTasks: z.array(z.string()).min(1),
15
+ });
16
+
17
+ export type SkillImprovementHypothesis = z.infer<typeof SkillImprovementHypothesisSchema>;
18
+
19
+ export const ExperimentReportSchema = z.object({
20
+ hypothesisId: z.string().min(1),
21
+ baselinePassRate: z.number().min(0).max(1),
22
+ candidatePassRate: z.number().min(0).max(1),
23
+ heldOutGain: z.number(),
24
+ learningCostTokens: z.number().nonnegative(),
25
+ regressions: z.number().int().nonnegative(),
26
+ // 'not-run': the benchmark environment was unavailable, so nothing was
27
+ // measured. It must never be reported as a completed experiment
28
+ // (ADR-0018: honest reporting over theater).
29
+ verdict: z.enum(['promoted', 'rejected', 'inconclusive', 'not-run']),
30
+ completedAt: z.string().min(1),
31
+ });
32
+
33
+ export type ExperimentReport = z.infer<typeof ExperimentReportSchema>;
@@ -0,0 +1,8 @@
1
+ // packages/contracts/src/learning/index.ts
2
+ export * from './experience.js';
3
+ export * from './memory.js';
4
+ export * from './hypothesis.js';
5
+ export * from './promotion.js';
6
+ export * from './experience-episode.js';
7
+ export * from './engineering-memory.js';
8
+ export * from './engineering-lesson.js';
@@ -0,0 +1,25 @@
1
+ // packages/contracts/src/learning/memory.ts
2
+ //
3
+ // M29 Hierarchical Memory contracts: episodic, semantic, and procedural memories
4
+ // derived from accumulated engineering experience.
5
+
6
+ import { z } from 'zod';
7
+
8
+ export const MemoryTypeSchema = z.enum(['episodic', 'semantic', 'procedural']);
9
+ export type MemoryType = z.infer<typeof MemoryTypeSchema>;
10
+
11
+ export const MemoryEntrySchema = z.object({
12
+ id: z.string().min(1),
13
+ type: MemoryTypeSchema,
14
+ domain: z.string().min(1),
15
+ summary: z.string().min(1),
16
+ content: z.string().min(1),
17
+ confidence: z.number().min(0).max(1),
18
+ provenance: z.array(z.string()),
19
+ appliedCount: z.number().int().nonnegative().default(0),
20
+ successCount: z.number().int().nonnegative().default(0),
21
+ createdAt: z.string().min(1),
22
+ updatedAt: z.string().min(1),
23
+ });
24
+
25
+ export type MemoryEntry = z.infer<typeof MemoryEntrySchema>;