@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,275 @@
1
+ // packages/contracts/src/agent/execution.ts
2
+ //
3
+ // M36 agent execution request and result contracts (ADR-0019 v2, ADR-0020).
4
+ //
5
+ // Design rules:
6
+ // - The request is provider-neutral and capability-scoped. It carries
7
+ // NO provider-specific fields (no model name, no prompt-template id).
8
+ // Provider selection is the gateway's job; the request describes the
9
+ // work and its bounds.
10
+ // - The request references an EXPLICIT ExecutionWorkspace (v2, revision
11
+ // B): an execution never assumes the current process directory is its
12
+ // environment. The workspace is created and owned by the gateway.
13
+ // - The request carries a policyHash (v2, revision D): the hash of the
14
+ // canonical, versioned ExecutionPolicy snapshot in force. Providers
15
+ // echo it in every event so each decision is traceable to the exact
16
+ // policy that authorized it; the gateway rejects mismatched echoes.
17
+ // - Bounds live in an explicit ExecutionBudget (v2, revision C) with
18
+ // per-limit enforcement levels declared by the provider's
19
+ // capabilities. Token or monetary cost enforcement is NEVER claimed
20
+ // where the provider does not expose reliable usage information.
21
+ // - The result's `proposedArtifacts` is INFORMATIONAL — it is what the
22
+ // agent claims it changed. Kit independently inspects git to establish
23
+ // truth. A `completed` result is never sufficient to mark a workflow
24
+ // task complete (ADR-0018: agent claims are not evidence).
25
+ // - A timeout, cancellation, or provider crash MUST be reported with the
26
+ // matching status, never `completed`.
27
+
28
+ import { z } from 'zod';
29
+ import { AgentCapabilitySchema } from './capability.js';
30
+ import { AgentExecutionErrorSchema } from './errors.js';
31
+ import { AgentResumeTokenSchema, AgentSessionIdSchema } from './session.js';
32
+ // Reuse the kit's canonical identifier contract (CONTRACTS.md §1.2) instead
33
+ // of redefining TaskId/RunId here. The agent surface references tasks and
34
+ // runs by their existing Identifier shape; re-exporting parallel types
35
+ // would collide at the contracts barrel.
36
+ import { IdentifierSchema } from '../common/identifier.js';
37
+
38
+ export const AGENT_EXECUTION_SCHEMA_VERSION = 2 as const;
39
+
40
+ // Provider ids are kebab-case (e.g. "claude-code", "codex"). This keeps
41
+ // them filename- and url-safe across config files and CLI flags.
42
+ export const AgentProviderIdSchema = z
43
+ .string()
44
+ .regex(/^[a-z][a-z0-9-]*$/, 'providerId must be kebab-case');
45
+ export type AgentProviderId = z.infer<typeof AgentProviderIdSchema>;
46
+
47
+ export const AgentTaskKindSchema = z.enum([
48
+ 'requirements',
49
+ 'architecture',
50
+ 'planning',
51
+ 'test_authoring',
52
+ 'implementation',
53
+ 'debugging',
54
+ 'code_review',
55
+ 'documentation',
56
+ ]);
57
+ export type AgentTaskKind = z.infer<typeof AgentTaskKindSchema>;
58
+
59
+ export const AgentExecutionStatusSchema = z.enum([
60
+ 'completed',
61
+ 'failed',
62
+ 'cancelled',
63
+ 'timed_out',
64
+ 'interrupted',
65
+ 'needs_approval',
66
+ ]);
67
+ export type AgentExecutionStatus = z.infer<typeof AgentExecutionStatusSchema>;
68
+
69
+ /**
70
+ * Statuses that mean "the agent produced no usable work." A workflow task
71
+ * MUST NOT advance to a completed phase when the execution ended in any of
72
+ * these. This is the contract-level expression of ADR-0018's "agent claims
73
+ * are not evidence": even a `completed` result is insufficient, but these
74
+ * statuses are sufficient to STOP the task.
75
+ */
76
+ export const AGENT_FAILURE_STATUSES: readonly AgentExecutionStatus[] = [
77
+ 'failed',
78
+ 'cancelled',
79
+ 'timed_out',
80
+ 'interrupted',
81
+ ];
82
+
83
+ export const AgentApprovalPolicySchema = z.object({
84
+ // Capabilities that require a human approval before the agent may
85
+ // proceed autonomously. The tool broker enforces these.
86
+ requireApprovalFor: z.array(AgentCapabilitySchema),
87
+ // If false, any approval-required action blocks the execution with
88
+ // status `needs_approval` instead of prompting. CI runs are autonomous
89
+ // but never silent: a blocked run explains what it is waiting for.
90
+ allowAutonomousExecution: z.boolean(),
91
+ });
92
+ export type AgentApprovalPolicy = z.infer<typeof AgentApprovalPolicySchema>;
93
+
94
+ /**
95
+ * How a workspace is isolated (ADR-0020 §7). A git worktree isolates
96
+ * repository changes; it is NOT an OS sandbox — provider processes must
97
+ * additionally run with restricted host permissions or in a container.
98
+ */
99
+ export const ExecutionWorkspaceKindSchema = z.enum(['git-worktree', 'container', 'directory']);
100
+ export type ExecutionWorkspaceKind = z.infer<typeof ExecutionWorkspaceKindSchema>;
101
+
102
+ /**
103
+ * The explicit execution environment (ADR-0019 v2, revision B). A request
104
+ * NEVER assumes the current process directory: the gateway creates the
105
+ * workspace and the request references it. For `git-worktree` (and only
106
+ * that kind) `branch` and `baseCommitSha` are required — the orchestrator
107
+ * uses them to derive clean diffs for evidence.
108
+ */
109
+ export const ExecutionWorkspaceSchema = z
110
+ .object({
111
+ id: z.string().min(1),
112
+ kind: ExecutionWorkspaceKindSchema,
113
+ rootPath: z.string().min(1),
114
+ branch: z.string().min(1).optional(),
115
+ baseCommitSha: z.string().min(1).optional(),
116
+ createdAt: z.string().min(1),
117
+ })
118
+ .superRefine((ws, ctx) => {
119
+ if (ws.kind === 'git-worktree' && (!ws.branch || !ws.baseCommitSha)) {
120
+ ctx.addIssue({
121
+ code: z.ZodIssueCode.custom,
122
+ path: ['branch'],
123
+ message:
124
+ 'a git-worktree workspace requires both branch and baseCommitSha',
125
+ });
126
+ }
127
+ });
128
+ export type ExecutionWorkspace = z.infer<typeof ExecutionWorkspaceSchema>;
129
+
130
+ /**
131
+ * How honestly a budget limit is enforced (ADR-0020 §8, revision C).
132
+ *
133
+ * - `provider-enforced` — the provider reliably enforces or reports it.
134
+ * - `gateway-enforced` — Kit enforces it itself (always true for duration
135
+ * and process bounds: the gateway owns the process).
136
+ * - `best-effort` — reported as such; evidence must state the limit was
137
+ * not hard-enforced.
138
+ *
139
+ * Token or monetary cost enforcement is NEVER declared `provider-enforced`
140
+ * where the provider does not expose reliable usage information.
141
+ */
142
+ export const BudgetEnforcementLevelSchema = z.enum([
143
+ 'provider-enforced',
144
+ 'gateway-enforced',
145
+ 'best-effort',
146
+ ]);
147
+ export type BudgetEnforcementLevel = z.infer<typeof BudgetEnforcementLevelSchema>;
148
+
149
+ /**
150
+ * Execution budget (ADR-0019 v2, revision C). Duration and tool calls are
151
+ * mandatory (the gateway can always enforce them); token and cost limits
152
+ * are optional and only meaningful when the provider declares an
153
+ * enforcement level for them. Exceeding an enforced limit is a
154
+ * BUDGET_EXCEEDED error, never silent continuation.
155
+ */
156
+ export const ExecutionBudgetSchema = z.object({
157
+ maxDurationMs: z.number().int().positive(),
158
+ maxToolCalls: z.number().int().positive(),
159
+ maxInputTokens: z.number().int().positive().optional(),
160
+ maxOutputTokens: z.number().int().positive().optional(),
161
+ maxTotalTokens: z.number().int().positive().optional(),
162
+ maxEstimatedCost: z
163
+ .object({
164
+ amount: z.number().nonnegative(),
165
+ currency: z.string().min(1),
166
+ })
167
+ .optional(),
168
+ });
169
+ export type ExecutionBudget = z.infer<typeof ExecutionBudgetSchema>;
170
+
171
+ export const AgentExecutionRequestSchema = z.object({
172
+ schemaVersion: z.literal(AGENT_EXECUTION_SCHEMA_VERSION),
173
+ executionId: z.string().min(1),
174
+ workflowRunId: IdentifierSchema,
175
+ taskId: IdentifierSchema,
176
+
177
+ providerId: AgentProviderIdSchema,
178
+ taskKind: AgentTaskKindSchema,
179
+
180
+ // Hash of the canonical, versioned ExecutionPolicy snapshot in force
181
+ // (ADR-0020). Providers echo it in every event; the gateway rejects
182
+ // events whose policyHash does not match the execution's policy.
183
+ policyHash: z.string().min(1),
184
+
185
+ // The explicit execution environment (revision B). The workspace is
186
+ // created by the gateway; a request never assumes the cwd.
187
+ workspace: ExecutionWorkspaceSchema,
188
+
189
+ instructions: z.string().min(1),
190
+ context: z.object({
191
+ specificationRef: z.string().optional(),
192
+ planRef: z.string().optional(),
193
+ relevantFiles: z.array(z.string()),
194
+ constraints: z.array(z.string()),
195
+ }),
196
+
197
+ permissions: z.object({
198
+ capabilities: z.array(AgentCapabilitySchema),
199
+ // Paths the agent may write. Must be within the run's isolated
200
+ // workspace (worktree). The tool broker rejects writes outside.
201
+ writablePaths: z.array(z.string().min(1)),
202
+ networkAllowed: z.boolean(),
203
+ }),
204
+
205
+ // Execution bounds (revision C), separated from permissions: grants say
206
+ // WHAT the agent may do; the budget says HOW MUCH.
207
+ budget: ExecutionBudgetSchema,
208
+
209
+ session: z
210
+ .object({
211
+ sessionId: AgentSessionIdSchema,
212
+ resumeToken: AgentResumeTokenSchema.optional(),
213
+ })
214
+ .optional(),
215
+
216
+ approvalPolicy: AgentApprovalPolicySchema,
217
+ });
218
+ export type AgentExecutionRequest = z.infer<typeof AgentExecutionRequestSchema>;
219
+
220
+ export const AgentArtifactOperationSchema = z.enum(['create', 'update', 'delete']);
221
+ export type AgentArtifactOperation = z.infer<typeof AgentArtifactOperationSchema>;
222
+
223
+ export const AgentProposedArtifactSchema = z.object({
224
+ path: z.string().min(1),
225
+ operation: AgentArtifactOperationSchema,
226
+ });
227
+ export type AgentProposedArtifact = z.infer<typeof AgentProposedArtifactSchema>;
228
+
229
+ export const AgentApprovalRequestSchema = z.object({
230
+ approvalId: z.string().min(1),
231
+ action: z.string().min(1),
232
+ reason: z.string().min(1),
233
+ });
234
+ export type AgentApprovalRequest = z.infer<typeof AgentApprovalRequestSchema>;
235
+
236
+ export const AgentUsageSchema = z.object({
237
+ inputTokens: z.number().int().nonnegative().optional(),
238
+ outputTokens: z.number().int().nonnegative().optional(),
239
+ durationMs: z.number().int().nonnegative(),
240
+ estimatedCost: z.number().nonnegative().optional(),
241
+ currency: z.string().optional(),
242
+ });
243
+ export type AgentUsage = z.infer<typeof AgentUsageSchema>;
244
+
245
+ export const AgentExecutionResultSchema = z.object({
246
+ schemaVersion: z.literal(AGENT_EXECUTION_SCHEMA_VERSION),
247
+ executionId: z.string().min(1),
248
+ workflowRunId: IdentifierSchema,
249
+ taskId: IdentifierSchema,
250
+
251
+ providerId: AgentProviderIdSchema,
252
+ status: AgentExecutionStatusSchema,
253
+
254
+ session: z
255
+ .object({
256
+ sessionId: AgentSessionIdSchema,
257
+ resumeToken: AgentResumeTokenSchema.optional(),
258
+ })
259
+ .optional(),
260
+
261
+ // A non-empty summary is required for every result, including failures:
262
+ // a result that explains nothing is suspicious (ADR-0018 honest reporting).
263
+ summary: z.string().min(1),
264
+
265
+ // INFORMATIONAL: what the agent claims it changed. Kit derives truth
266
+ // from git, not from this list (ADR-0018, ADR-0019).
267
+ proposedArtifacts: z.array(AgentProposedArtifactSchema),
268
+
269
+ requestedApprovals: z.array(AgentApprovalRequestSchema),
270
+
271
+ usage: AgentUsageSchema.optional(),
272
+
273
+ errors: z.array(AgentExecutionErrorSchema),
274
+ });
275
+ export type AgentExecutionResult = z.infer<typeof AgentExecutionResultSchema>;
@@ -0,0 +1,19 @@
1
+ // packages/contracts/src/agent/index.ts
2
+ //
3
+ // M36 agent execution surface (ADR-0019, ADR-0020). Provider-neutral
4
+ // contracts for orchestrating AI agent execution: capabilities, sessions,
5
+ // events, requests/results, the provider behavior interface, and the
6
+ // error taxonomy.
7
+ //
8
+ // Architectural invariant (ARCHITECTURE.md §6): this surface imports
9
+ // nothing from sibling @agentic-sdlc-kit/* packages, and a provider SDK
10
+ // (Claude, Codex, ...) MUST NOT be imported here. Provider-specific code
11
+ // lives behind the AgentProvider interface in a provider package.
12
+
13
+ export * from './capability.js';
14
+ export * from './session.js';
15
+ export * from './errors.js';
16
+ export * from './events.js';
17
+ export * from './execution.js';
18
+ export * from './provider.js';
19
+ export * from './policy.js';
@@ -0,0 +1,82 @@
1
+ // packages/contracts/src/agent/policy.ts
2
+ //
3
+ // M36 canonical execution policy snapshot (ADR-0020 §1). There is exactly
4
+ // ONE policy definition in the kit, and it lives here: a normalized,
5
+ // versioned snapshot of everything a policy grants and bounds — the
6
+ // permission grant (capabilities + writable paths + network), the
7
+ // execution budget, and the approval policy. Every agent execution
8
+ // receives one; its stable hash (`policyHash`) is carried by the
9
+ // AgentExecutionRequest and echoed in every AgentExecutionEvent, so each
10
+ // decision and artifact is traceable to the exact policy in force when
11
+ // it was produced.
12
+ //
13
+ // The snapshot COMPOSES the request's policy fields rather than
14
+ // duplicating them: `permissions`, `budget`, and `approvalPolicy` are the
15
+ // same contract objects the request embeds. A snapshot is what the
16
+ // gateway freezes per execution; the request's inline fields are that
17
+ // frozen snapshot rendered into the provider-neutral request.
18
+ //
19
+ // Two enforcement points derive from this one definition (ADR-0020 §2):
20
+ // the gateway (provider-neutral) and the runtime representation (host
21
+ // specific, PR4). Parity between them is a release blocker.
22
+
23
+ import { createHash } from 'node:crypto';
24
+ import { z } from 'zod';
25
+ import { AgentCapabilitySchema } from './capability.js';
26
+ import { AgentApprovalPolicySchema, ExecutionBudgetSchema } from './execution.js';
27
+
28
+ export const AGENT_POLICY_SNAPSHOT_SCHEMA_VERSION = 1 as const;
29
+
30
+ /**
31
+ * The canonical policy snapshot. Field-for-field this is the policy part
32
+ * of an AgentExecutionRequest; the gateway hashes THIS object (not the
33
+ * request) so the hash is independent of non-policy request fields.
34
+ */
35
+ export const AgentPolicySnapshotSchema = z.object({
36
+ schemaVersion: z.literal(AGENT_POLICY_SNAPSHOT_SCHEMA_VERSION),
37
+ permissions: z.object({
38
+ capabilities: z.array(AgentCapabilitySchema).min(1),
39
+ writablePaths: z.array(z.string().min(1)),
40
+ networkAllowed: z.boolean(),
41
+ }),
42
+ budget: ExecutionBudgetSchema,
43
+ approvalPolicy: AgentApprovalPolicySchema,
44
+ });
45
+ export type AgentPolicySnapshot = z.infer<typeof AgentPolicySnapshotSchema>;
46
+
47
+ /**
48
+ * Canonical JSON: object keys sorted recursively, no insignificant
49
+ * whitespace. Sorting makes the serialization — and therefore the hash —
50
+ * independent of property insertion order, so two snapshots that differ
51
+ * only in key order are the SAME policy, as they must be.
52
+ */
53
+ export function canonicalPolicyJson(snapshot: AgentPolicySnapshot): string {
54
+ const canonicalize = (value: unknown): unknown => {
55
+ if (Array.isArray(value)) return value.map(canonicalize);
56
+ if (value !== null && typeof value === 'object') {
57
+ const record = value as Record<string, unknown>;
58
+ const sorted: Record<string, unknown> = {};
59
+ for (const key of Object.keys(record).sort()) {
60
+ sorted[key] = canonicalize(record[key]);
61
+ }
62
+ return sorted;
63
+ }
64
+ return value;
65
+ };
66
+ return JSON.stringify(canonicalize(snapshot));
67
+ }
68
+
69
+ /**
70
+ * Stable hash of a policy snapshot: `sha256:<hex>` of the canonical JSON.
71
+ * This is the value carried by AgentExecutionRequest.policyHash and
72
+ * echoed in every event; the gateway rejects any event whose echo does
73
+ * not match the snapshot frozen for that execution (fail closed,
74
+ * ADR-0020 §4).
75
+ *
76
+ * Implemented with node:crypto — the kit is a Node-only toolchain
77
+ * (engines.node >= 18) and every consumer (CLI, gateway, mods) runs on
78
+ * Node.
79
+ */
80
+ export function computePolicyHash(snapshot: AgentPolicySnapshot): string {
81
+ return `sha256:${createHash('sha256').update(canonicalPolicyJson(snapshot), 'utf8').digest('hex')}`;
82
+ }
@@ -0,0 +1,124 @@
1
+ // packages/contracts/src/agent/provider.ts
2
+ //
3
+ // M36 agent provider behavior contract (ADR-0019 v2, revision A). A
4
+ // provider translates Kit's provider-neutral AgentExecutionRequest into a
5
+ // concrete agent invocation (Claude Code, Codex, ...) and normalizes the
6
+ // result back.
7
+ //
8
+ // Hard rules (ADR-0019 v2, ADR-0020):
9
+ // - A provider MUST NOT bypass Kit policy. It executes within the
10
+ // capabilities and writablePaths granted by the request; the tool
11
+ // broker is the authority, not the provider.
12
+ // - A provider MUST NOT import or depend on any @agentic-sdlc-kit/*
13
+ // package except @agentic-sdlc-kit/contracts. (Architecture gate.)
14
+ // - A provider MUST report timeouts/cancellations/crashes with the
15
+ // matching status, never `completed`.
16
+ // - Execution is HANDLE-BASED (v2, revision A): `start()` returns an
17
+ // AgentExecutionHandle whose `result()` resolves once and whose
18
+ // `events()` is an observability subscription. The gateway holds the
19
+ // original request; `resume()` is addressed by (executionId,
20
+ // resumeToken) only.
21
+ // - RESUME TOKENS ARE CREDENTIALS. They are never logged, never
22
+ // included in ordinary events, and never persisted unencrypted.
23
+ // Compromise of a resume token is treated as compromise of the
24
+ // execution (ADR-0020 §6).
25
+ // - A provider's capabilities() MUST declare budget enforcement levels
26
+ // honestly (revision C): token or cost limits are never declared
27
+ // `provider-enforced` without reliable usage information.
28
+ //
29
+ // This is a behavior interface (no Zod, no implementation). It lives in
30
+ // contracts so the gateway, the orchestrator, and every provider share
31
+ // one canonical type.
32
+
33
+ import type { AgentCapability } from './capability.js';
34
+ import type { BudgetEnforcementLevel } from './execution.js';
35
+ import type { AgentExecutionRequest, AgentExecutionResult, AgentProviderId } from './execution.js';
36
+ import type { AgentEventSink } from './events.js';
37
+
38
+ export interface AgentHealth {
39
+ readonly available: boolean;
40
+ readonly message?: string;
41
+ }
42
+
43
+ /**
44
+ * What a provider can actually do and enforce (revision C). Capabilities
45
+ * are the allowlist subset; budgetEnforcement states, per limit, how
46
+ * honestly the provider can enforce it. The gateway cross-checks a
47
+ * request's budget against these levels before starting an execution: a
48
+ * token limit sent to a provider that cannot report usage is rejected,
49
+ * not silently downgraded.
50
+ */
51
+ export interface AgentProviderCapabilities {
52
+ /** Capabilities this provider can exercise. Must be a subset of AGENT_CAPABILITIES. */
53
+ readonly capabilities: readonly AgentCapability[];
54
+ /**
55
+ * Per-limit enforcement honesty (ADR-0020 §8). Duration is always at
56
+ * least `gateway-enforced` — the gateway owns the provider process.
57
+ */
58
+ readonly budgetEnforcement: {
59
+ readonly maxDurationMs: BudgetEnforcementLevel;
60
+ readonly maxToolCalls: BudgetEnforcementLevel;
61
+ readonly maxInputTokens: BudgetEnforcementLevel;
62
+ readonly maxOutputTokens: BudgetEnforcementLevel;
63
+ readonly maxTotalTokens: BudgetEnforcementLevel;
64
+ readonly maxEstimatedCost: BudgetEnforcementLevel;
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Handle to a running or resumable agent execution (revision A). Returned
70
+ * by start() and resume(); the gateway correlates the handle to the
71
+ * persisted execution it created.
72
+ */
73
+ export interface AgentExecutionHandle {
74
+ /** Correlates to the AgentExecutionRequest that created the execution. */
75
+ readonly executionId: string;
76
+
77
+ /**
78
+ * Final result. Resolves exactly once; rejects only on transport-level
79
+ * failure (provider unreachable, contract violation). Timeouts,
80
+ * cancellations, and crashes are VALUES (`timed_out`, `cancelled`,
81
+ * `interrupted` results), never rejections and never `completed`.
82
+ */
83
+ result(): Promise<AgentExecutionResult>;
84
+
85
+ /**
86
+ * Subscribe to lifecycle events (observability only — an event never
87
+ * authorizes anything). Returns an unsubscribe function. Subscribing
88
+ * after events were emitted may miss them; the gateway persists events
89
+ * independently of this subscription.
90
+ */
91
+ events(onEvent: AgentEventSink): () => void;
92
+ }
93
+
94
+ export interface AgentProvider {
95
+ readonly id: AgentProviderId;
96
+
97
+ /** The capabilities and enforcement levels this provider honestly supports. */
98
+ capabilities(): Promise<AgentProviderCapabilities>;
99
+
100
+ /** Probe provider configuration and connectivity without executing work. */
101
+ healthCheck(): Promise<AgentHealth>;
102
+
103
+ /**
104
+ * Start a bounded execution. The gateway persists the original request
105
+ * BEFORE calling start, so the request can never drift between attempts.
106
+ * If `signal` is already aborted, the handle's result() resolves with a
107
+ * `cancelled` result rather than throwing.
108
+ */
109
+ start(request: AgentExecutionRequest, signal: AbortSignal): Promise<AgentExecutionHandle>;
110
+
111
+ /**
112
+ * Resume a previously interrupted execution. Addressed by
113
+ * (executionId, resumeToken) ONLY — the gateway owns the original
114
+ * request and does not re-submit it. The resumeToken is a credential:
115
+ * it is never logged and never appears in events.
116
+ */
117
+ resume(executionId: string, resumeToken: string): Promise<AgentExecutionHandle>;
118
+
119
+ /**
120
+ * Cancel an in-flight execution. Cancelling an unknown executionId is a
121
+ * no-op (resolves void), not an error — the execution is already stopped.
122
+ */
123
+ cancel(executionId: string): Promise<void>;
124
+ }
@@ -0,0 +1,29 @@
1
+ // packages/contracts/src/agent/session.ts
2
+ //
3
+ // M36 agent session contract (ADR-0019 v2). A session is a resumable provider
4
+ // conversation bound to one workflow task. resumeToken is opaque to Kit;
5
+ // the provider owns its format and rotation.
6
+ //
7
+ // Resume is addressed by (executionId, resumeToken) — NOT by re-passing
8
+ // the full original request. The gateway persists the original request so
9
+ // the provider does not need it re-submitted, which avoids drift between
10
+ // a persisted request and a resubmitted one.
11
+ //
12
+ // SECURITY: a resumeToken is a CREDENTIAL (ADR-0020 §6). It is never
13
+ // logged, never included in ordinary events, and never persisted
14
+ // unencrypted. Compromise of a resume token is treated as compromise of
15
+ // the execution it can resume.
16
+
17
+ import { z } from 'zod';
18
+
19
+ export const AgentSessionIdSchema = z.string().min(1);
20
+ export type AgentSessionId = z.infer<typeof AgentSessionIdSchema>;
21
+
22
+ export const AgentResumeTokenSchema = z.string().min(1);
23
+ export type AgentResumeToken = z.infer<typeof AgentResumeTokenSchema>;
24
+
25
+ export const AgentSessionRefSchema = z.object({
26
+ sessionId: AgentSessionIdSchema,
27
+ resumeToken: AgentResumeTokenSchema.optional(),
28
+ });
29
+ export type AgentSessionRef = z.infer<typeof AgentSessionRefSchema>;
@@ -0,0 +1,47 @@
1
+ // packages/contracts/src/application/application-context.ts
2
+ //
3
+ // Application workflow context (M8 Phase A — M8-01).
4
+ //
5
+ // Carries the artifacts the workflow has produced so far: product brief,
6
+ // PRD, architecture, plan, scaffold manifest, verification reports. Each
7
+ // field is optional because the workflow fills them in as it advances.
8
+ // The validator in core/workflows/application/validators.ts checks that
9
+ // the context matches the current stage (e.g., you cannot be in the
10
+ // `architecture` stage without a `brief` and `requirements`).
11
+
12
+ import { z } from 'zod';
13
+ import { FeatureSpecificationSchema } from '../specification/specification.js';
14
+ import { ImplementationPlanSchema } from '../planning/task.js';
15
+ import { VerificationReportSchema } from '../verification/report.js';
16
+
17
+ export const ApplicationContextSchema = z.object({
18
+ // Filled in during `intake` and `discovery`:
19
+ brief: z.string().optional(),
20
+ // Filled in during `requirements`:
21
+ specification: FeatureSpecificationSchema.optional(),
22
+ // Filled in during `architecture`:
23
+ architectureDecisionIds: z.array(z.string()).optional(),
24
+ // Filled in during `planning`:
25
+ plan: ImplementationPlanSchema.optional(),
26
+ // Filled in during `scaffolding`:
27
+ scaffoldedFilePaths: z.array(z.string()).optional(),
28
+ // Filled in during `implementation` and `verification`:
29
+ verificationReports: z.array(VerificationReportSchema).optional(),
30
+ // Filled in during `review`:
31
+ reviewReportPath: z.string().optional(),
32
+ // Filled in during `release`:
33
+ releaseVersion: z.string().optional(),
34
+ // Unresolved decisions the workflow is blocked on:
35
+ openDecisions: z
36
+ .array(
37
+ z.object({
38
+ id: z.string(),
39
+ question: z.string(),
40
+ stage: z.string(),
41
+ raisedAt: z.string(),
42
+ }),
43
+ )
44
+ .default([]),
45
+ });
46
+
47
+ export type ApplicationContext = z.infer<typeof ApplicationContextSchema>;
@@ -0,0 +1,44 @@
1
+ // packages/contracts/src/application/application-persistence.ts
2
+ //
3
+ // Application workflow persistence and recovery contract (M8 Phase G —
4
+ // M8-38 through M8-42).
5
+ //
6
+ // A developer must be able to close a session and continue the application
7
+ // workflow without regenerating the entire plan. The persisted shape is
8
+ // ApplicationState + ApplicationContext + a change log.
9
+
10
+ import { z } from 'zod';
11
+ import { ApplicationStateSchema } from './application-state.js';
12
+ import { ApplicationContextSchema } from './application-context.js';
13
+
14
+ export const APPLICATION_PERSISTENCE_SCHEMA_VERSION = 1 as const;
15
+
16
+ export const ApplicationPersistenceSchema = z.object({
17
+ schemaVersion: z.literal(APPLICATION_PERSISTENCE_SCHEMA_VERSION),
18
+ state: ApplicationStateSchema,
19
+ context: ApplicationContextSchema,
20
+ changeLog: z.array(
21
+ z.object({
22
+ id: z.string(),
23
+ at: z.string(),
24
+ kind: z.enum([
25
+ 'stage-entered',
26
+ 'stage-exited',
27
+ 'context-updated',
28
+ 'decision-raised',
29
+ 'decision-resolved',
30
+ 'scope-revised',
31
+ 'architecture-revised',
32
+ 'workflow-resumed',
33
+ 'workflow-blocked',
34
+ 'workflow-failed',
35
+ 'workflow-completed',
36
+ ]),
37
+ summary: z.string(),
38
+ details: z.record(z.string(), z.unknown()).optional(),
39
+ }),
40
+ ),
41
+ });
42
+
43
+ export type ApplicationPersistence = z.infer<typeof ApplicationPersistenceSchema>;
44
+ export type ApplicationChangeLogEntry = ApplicationPersistence['changeLog'][number];