@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,107 @@
1
+ // packages/contracts/src/application/application-state.test.ts
2
+ import { describe, expect, it } from 'vitest';
3
+ import { ApplicationStateSchema } from './application-state.js';
4
+ import {
5
+ COMPLETABLE_STAGES,
6
+ STAGE_ORDER,
7
+ TARGET_STATUS,
8
+ TRANSITIONS_BY_STATUS,
9
+ revisableFrom,
10
+ } from './application-transitions.js';
11
+
12
+ describe('ApplicationStateSchema', () => {
13
+ it('accepts a fresh pending state at the intake stage', () => {
14
+ const r = ApplicationStateSchema.safeParse({
15
+ schemaVersion: 1,
16
+ runId: 'RUN-001',
17
+ status: 'pending',
18
+ stage: 'intake',
19
+ stageHistory: [],
20
+ revisions: [],
21
+ });
22
+ expect(r.success).toBe(true);
23
+ });
24
+ it('rejects an unknown stage', () => {
25
+ const r = ApplicationStateSchema.safeParse({
26
+ schemaVersion: 1,
27
+ runId: 'RUN-001',
28
+ status: 'pending',
29
+ stage: 'bogus',
30
+ stageHistory: [],
31
+ revisions: [],
32
+ });
33
+ expect(r.success).toBe(false);
34
+ });
35
+ it('rejects an unknown status', () => {
36
+ const r = ApplicationStateSchema.safeParse({
37
+ schemaVersion: 1,
38
+ runId: 'RUN-001',
39
+ status: 'paused',
40
+ stage: 'intake',
41
+ stageHistory: [],
42
+ revisions: [],
43
+ });
44
+ expect(r.success).toBe(false);
45
+ });
46
+ });
47
+
48
+ describe('STAGE_ORDER', () => {
49
+ it('lists all 10 stages in canonical order', () => {
50
+ expect(STAGE_ORDER).toEqual([
51
+ 'intake',
52
+ 'discovery',
53
+ 'requirements',
54
+ 'architecture',
55
+ 'planning',
56
+ 'scaffolding',
57
+ 'implementation',
58
+ 'verification',
59
+ 'review',
60
+ 'release',
61
+ ]);
62
+ });
63
+ });
64
+
65
+ describe('TRANSITIONS_BY_STATUS', () => {
66
+ it('allows start only from pending', () => {
67
+ expect(TRANSITIONS_BY_STATUS.pending).toEqual(['start']);
68
+ });
69
+ it('allows advance/block/complete/fail/revise from in_progress', () => {
70
+ expect(TRANSITIONS_BY_STATUS.in_progress).toContain('advance');
71
+ expect(TRANSITIONS_BY_STATUS.in_progress).toContain('block');
72
+ expect(TRANSITIONS_BY_STATUS.in_progress).toContain('complete');
73
+ expect(TRANSITIONS_BY_STATUS.in_progress).toContain('fail');
74
+ expect(TRANSITIONS_BY_STATUS.in_progress).toContain('revise');
75
+ });
76
+ it('makes completed and failed terminal', () => {
77
+ expect(TRANSITIONS_BY_STATUS.completed).toEqual([]);
78
+ expect(TRANSITIONS_BY_STATUS.failed).toEqual([]);
79
+ });
80
+ });
81
+
82
+ describe('TARGET_STATUS', () => {
83
+ it('maps every transition to a status', () => {
84
+ expect(TARGET_STATUS.start).toBe('in_progress');
85
+ expect(TARGET_STATUS.advance).toBe('in_progress');
86
+ expect(TARGET_STATUS.block).toBe('blocked');
87
+ expect(TARGET_STATUS.resume).toBe('in_progress');
88
+ expect(TARGET_STATUS.complete).toBe('completed');
89
+ expect(TARGET_STATUS.fail).toBe('failed');
90
+ expect(TARGET_STATUS.revise).toBe('in_progress');
91
+ });
92
+ });
93
+
94
+ describe('COMPLETABLE_STAGES', () => {
95
+ it('only allows complete from the release stage', () => {
96
+ expect(COMPLETABLE_STAGES).toEqual(['release']);
97
+ });
98
+ });
99
+
100
+ describe('revisableFrom', () => {
101
+ it('returns all prior stages for a given stage', () => {
102
+ expect(revisableFrom('architecture')).toEqual(['intake', 'discovery', 'requirements']);
103
+ });
104
+ it('returns an empty array for the first stage', () => {
105
+ expect(revisableFrom('intake')).toEqual([]);
106
+ });
107
+ });
@@ -0,0 +1,81 @@
1
+ // packages/contracts/src/application/application-state.ts
2
+ //
3
+ // Application workflow state (M8 Phase A — M8-01, M8-02).
4
+ //
5
+ // The /kit:app workflow has a richer lifecycle than the generic feature
6
+ // workflow because it covers product discovery, architecture, scaffolding,
7
+ // and release — not just implementation. The state machine is defined
8
+ // here; the transition table is in application-transitions.ts and is
9
+ // enforced by core/workflows/application/transitions.ts.
10
+ //
11
+ // INVARIANT (ADR-0010): completed and failed are terminal. No transition
12
+ // may turn failed back into completed without a new run.
13
+ //
14
+ // See post-M7 roadmap §2.2 and ADR-0010.
15
+
16
+ import { z } from 'zod';
17
+ import type { RunId, TaskId } from '../common/identifier.js';
18
+
19
+ export const APPLICATION_STAGE = z.enum([
20
+ 'intake', // product brief captured
21
+ 'discovery', // problem & user analysis
22
+ 'requirements', // PRD + functional + non-functional
23
+ 'architecture', // ADRs + component map + data model + API + security
24
+ 'planning', // vertical-slice plan
25
+ 'scaffolding', // initial project structure
26
+ 'implementation', // M5 engine drives incremental slices
27
+ 'verification', // M6 engine drives verification
28
+ 'review', // independent review
29
+ 'release', // release readiness
30
+ ]);
31
+ export type ApplicationStage = z.infer<typeof APPLICATION_STAGE>;
32
+
33
+ export const APPLICATION_STATUS = z.enum([
34
+ 'pending', // workflow created, not started
35
+ 'in_progress', // a stage is currently executing
36
+ 'blocked', // waiting on approval or unresolved decision
37
+ 'completed', // release shipped and verified
38
+ 'failed', // a stage failed or verification failed
39
+ ]);
40
+ export type ApplicationStatus = z.infer<typeof APPLICATION_STATUS>;
41
+
42
+ export const APPLICATION_TRANSITION = z.enum([
43
+ 'start', // pending → in_progress
44
+ 'advance', // in_progress → in_progress (next stage)
45
+ 'block', // in_progress → blocked
46
+ 'resume', // blocked → in_progress
47
+ 'complete', // in_progress → completed (after release stage)
48
+ 'fail', // in_progress|blocked → failed
49
+ 'revise', // in_progress → in_progress (revisit prior stage)
50
+ ]);
51
+ export type ApplicationTransition = z.infer<typeof APPLICATION_TRANSITION>;
52
+
53
+ export const ApplicationStateSchema = z.object({
54
+ schemaVersion: z.literal(1),
55
+ runId: z.string(),
56
+ status: APPLICATION_STATUS,
57
+ stage: APPLICATION_STAGE,
58
+ startedAt: z.string().optional(),
59
+ currentTaskId: z.string().optional(),
60
+ stageHistory: z.array(
61
+ z.object({
62
+ stage: APPLICATION_STAGE,
63
+ enteredAt: z.string(),
64
+ exitedAt: z.string().optional(),
65
+ outcome: z
66
+ .enum(['pending', 'advanced', 'blocked', 'completed', 'failed', 'revised'])
67
+ .optional(),
68
+ }),
69
+ ),
70
+ revisions: z.array(
71
+ z.object({
72
+ fromStage: APPLICATION_STAGE,
73
+ toStage: APPLICATION_STAGE,
74
+ reason: z.string(),
75
+ revisedAt: z.string(),
76
+ }),
77
+ ),
78
+ });
79
+
80
+ export type ApplicationState = z.infer<typeof ApplicationStateSchema>;
81
+ export type { RunId, TaskId };
@@ -0,0 +1,71 @@
1
+ // packages/contracts/src/application/application-transitions.ts
2
+ //
3
+ // Application workflow transition table (M8 Phase A — M8-02).
4
+ //
5
+ // Allowed transitions and their target stage. This is the *contract*; the
6
+ // pure-function enforcement lives in core/workflows/application/transitions.ts.
7
+ //
8
+ // See post-M7 roadmap §2.2 and ADR-0010.
9
+
10
+ import type {
11
+ ApplicationStage,
12
+ ApplicationStatus,
13
+ ApplicationTransition,
14
+ } from './application-state.js';
15
+
16
+ /**
17
+ * Stages in canonical order. `advance` moves to the next stage in this
18
+ * list. `revise` may move to any prior stage.
19
+ */
20
+ export const STAGE_ORDER: ReadonlyArray<ApplicationStage> = [
21
+ 'intake',
22
+ 'discovery',
23
+ 'requirements',
24
+ 'architecture',
25
+ 'planning',
26
+ 'scaffolding',
27
+ 'implementation',
28
+ 'verification',
29
+ 'review',
30
+ 'release',
31
+ ];
32
+
33
+ /**
34
+ * Per-status allowed transitions.
35
+ */
36
+ export const TRANSITIONS_BY_STATUS: Readonly<
37
+ Record<ApplicationStatus, ReadonlyArray<ApplicationTransition>>
38
+ > = {
39
+ pending: ['start'],
40
+ in_progress: ['advance', 'block', 'complete', 'fail', 'revise'],
41
+ blocked: ['resume', 'fail'],
42
+ completed: [],
43
+ failed: [],
44
+ };
45
+
46
+ /**
47
+ * The target status for a transition (independent of stage).
48
+ */
49
+ export const TARGET_STATUS: Readonly<Record<ApplicationTransition, ApplicationStatus>> = {
50
+ start: 'in_progress',
51
+ advance: 'in_progress',
52
+ block: 'blocked',
53
+ resume: 'in_progress',
54
+ complete: 'completed',
55
+ fail: 'failed',
56
+ revise: 'in_progress',
57
+ };
58
+
59
+ /**
60
+ * The release stage is the only stage from which `complete` is allowed.
61
+ */
62
+ export const COMPLETABLE_STAGES: ReadonlyArray<ApplicationStage> = ['release'];
63
+
64
+ /**
65
+ * Stages reachable via `revise` from a given stage = all earlier stages.
66
+ */
67
+ export function revisableFrom(stage: ApplicationStage): ReadonlyArray<ApplicationStage> {
68
+ const idx = STAGE_ORDER.indexOf(stage);
69
+ if (idx <= 0) return [];
70
+ return STAGE_ORDER.slice(0, idx);
71
+ }
@@ -0,0 +1,5 @@
1
+ // packages/contracts/src/application/index.ts
2
+ export * from './application-state.js';
3
+ export * from './application-context.js';
4
+ export * from './application-transitions.js';
5
+ export * from './application-persistence.js';
@@ -0,0 +1,56 @@
1
+ // packages/contracts/src/architecture/api-contract.ts
2
+ //
3
+ // API design contract (M8 Phase C — M8-15).
4
+ //
5
+ // The kit uses a minimal, OpenAPI-flavored contract rather than a full
6
+ // OpenAPI 3.1 document. This keeps the contract reviewable and lets a
7
+ // later stage emit a full OpenAPI document if needed.
8
+
9
+ import { z } from 'zod';
10
+
11
+ export const HttpMethodSchema = z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
12
+
13
+ export const ParameterLocationSchema = z.enum(['path', 'query', 'header', 'body']);
14
+
15
+ export const ParameterSchema = z.object({
16
+ name: z.string().min(1),
17
+ location: ParameterLocationSchema,
18
+ type: z.string().min(1),
19
+ required: z.boolean(),
20
+ description: z.string().min(1),
21
+ });
22
+
23
+ export const ResponseSchema = z.object({
24
+ status: z.number().int().min(100).max(599),
25
+ description: z.string().min(1),
26
+ // Reference to a DataModel entity or a free-form shape name.
27
+ bodyRef: z.string().optional(),
28
+ });
29
+
30
+ export const EndpointSchema = z.object({
31
+ id: z.string(),
32
+ method: HttpMethodSchema,
33
+ path: z.string().min(1).startsWith('/'),
34
+ operationId: z.string().min(1),
35
+ summary: z.string().min(1),
36
+ parameters: z.array(ParameterSchema).default([]),
37
+ responses: z.array(ResponseSchema).min(1),
38
+ // Authentication required?
39
+ requiresAuth: z.boolean().default(true),
40
+ // Required role(s) if any.
41
+ requiredRoles: z.array(z.string()).default([]),
42
+ });
43
+
44
+ export const ApiContractSchema = z.object({
45
+ schemaVersion: z.literal(1),
46
+ briefId: z.string(),
47
+ baseUrl: z.string().optional(),
48
+ endpoints: z.array(EndpointSchema),
49
+ });
50
+
51
+ export type HttpMethod = z.infer<typeof HttpMethodSchema>;
52
+ export type ParameterLocation = z.infer<typeof ParameterLocationSchema>;
53
+ export type Parameter = z.infer<typeof ParameterSchema>;
54
+ export type Response = z.infer<typeof ResponseSchema>;
55
+ export type Endpoint = z.infer<typeof EndpointSchema>;
56
+ export type ApiContract = z.infer<typeof ApiContractSchema>;
@@ -0,0 +1,27 @@
1
+ // packages/contracts/src/architecture/architecture-approval.ts
2
+ //
3
+ // Architecture approval contract (M8 Phase C — M8-19).
4
+ //
5
+ // Once an architecture option is selected, the kit freezes the design
6
+ // baseline as a set of ADR references. Any subsequent revision must go
7
+ // through `revise` transition and produce a new ADR.
8
+
9
+ import { z } from 'zod';
10
+
11
+ export const ArchitectureApprovalSchema = z.object({
12
+ schemaVersion: z.literal(1),
13
+ briefId: z.string(),
14
+ selectedOptionId: z.string(),
15
+ // ADR IDs that document the approved decisions.
16
+ adrIds: z.array(z.string()),
17
+ // References to the architecture sub-artifacts.
18
+ componentMapId: z.string(),
19
+ dataModelId: z.string(),
20
+ apiContractId: z.string(),
21
+ securityDesignId: z.string(),
22
+ operationalDesignId: z.string(),
23
+ approvedBy: z.string(),
24
+ approvedAt: z.string(),
25
+ });
26
+
27
+ export type ArchitectureApproval = z.infer<typeof ArchitectureApprovalSchema>;
@@ -0,0 +1,42 @@
1
+ // packages/contracts/src/architecture/architecture-options.ts
2
+ //
3
+ // Architecture options contract (M8 Phase C — M8-12).
4
+ //
5
+ // The kit proposes alternative architecture options; the developer picks
6
+ // one. The choice is recorded as an ADR. The kit MUST NOT default to
7
+ // microservices or distributed infrastructure; every option must be
8
+ // justified by actual requirements.
9
+
10
+ import { z } from 'zod';
11
+
12
+ export const ArchitectureOptionKindSchema = z.enum([
13
+ 'modular-monolith',
14
+ 'microservices',
15
+ 'modular-monolith-with-bounded-contexts',
16
+ 'serverless',
17
+ 'other',
18
+ ]);
19
+
20
+ export const ArchitectureOptionSchema = z.object({
21
+ id: z.string(),
22
+ kind: ArchitectureOptionKindSchema,
23
+ name: z.string().min(1),
24
+ rationale: z.string().min(1),
25
+ pros: z.array(z.string()),
26
+ cons: z.array(z.string()),
27
+ // Requirements that justify this option (must trace to a real requirement).
28
+ justifiedBy: z.array(z.string()),
29
+ rejected: z.boolean().default(false),
30
+ rejectionReason: z.string().optional(),
31
+ });
32
+
33
+ export const ArchitectureOptionsSchema = z.object({
34
+ schemaVersion: z.literal(1),
35
+ briefId: z.string(),
36
+ options: z.array(ArchitectureOptionSchema).min(2, 'at least two options required'),
37
+ selectedOptionId: z.string(),
38
+ });
39
+
40
+ export type ArchitectureOptionKind = z.infer<typeof ArchitectureOptionKindSchema>;
41
+ export type ArchitectureOption = z.infer<typeof ArchitectureOptionSchema>;
42
+ export type ArchitectureOptions = z.infer<typeof ArchitectureOptionsSchema>;
@@ -0,0 +1,263 @@
1
+ // packages/contracts/src/architecture/architecture.test.ts
2
+ import { describe, expect, it } from 'vitest';
3
+ import { ArchitectureOptionsSchema } from './architecture-options.js';
4
+ import { ComponentMapSchema } from './component-map.js';
5
+ import { DataModelSchema } from './data-model.js';
6
+ import { ApiContractSchema } from './api-contract.js';
7
+ import { SecurityDesignSchema } from './security-design.js';
8
+ import { OperationalDesignSchema } from './operational-design.js';
9
+ import { ArchitectureApprovalSchema } from './architecture-approval.js';
10
+
11
+ describe('ArchitectureOptionsSchema', () => {
12
+ it('accepts at least two options and a selection', () => {
13
+ expect(
14
+ ArchitectureOptionsSchema.safeParse({
15
+ schemaVersion: 1,
16
+ briefId: 'BRIEF-001',
17
+ options: [
18
+ {
19
+ id: 'OPT-1',
20
+ kind: 'modular-monolith',
21
+ name: 'Modular Monolith',
22
+ rationale: 'small team, fast iteration',
23
+ pros: ['simple deploy'],
24
+ cons: ['scaling limits'],
25
+ justifiedBy: ['FR-1'],
26
+ rejected: false,
27
+ },
28
+ {
29
+ id: 'OPT-2',
30
+ kind: 'microservices',
31
+ name: 'Microservices',
32
+ rationale: 'independent scaling',
33
+ pros: ['scale independently'],
34
+ cons: ['operational complexity'],
35
+ justifiedBy: ['NFR-perf'],
36
+ rejected: true,
37
+ rejectionReason: 'team too small',
38
+ },
39
+ ],
40
+ selectedOptionId: 'OPT-1',
41
+ }).success,
42
+ ).toBe(true);
43
+ });
44
+ it('rejects a single-option set', () => {
45
+ expect(
46
+ ArchitectureOptionsSchema.safeParse({
47
+ schemaVersion: 1,
48
+ briefId: 'BRIEF-001',
49
+ options: [
50
+ {
51
+ id: 'OPT-1',
52
+ kind: 'modular-monolith',
53
+ name: 'x',
54
+ rationale: 'y',
55
+ pros: [],
56
+ cons: [],
57
+ justifiedBy: [],
58
+ },
59
+ ],
60
+ selectedOptionId: 'OPT-1',
61
+ }).success,
62
+ ).toBe(false);
63
+ });
64
+ });
65
+
66
+ describe('ComponentMapSchema', () => {
67
+ it('accepts a valid map', () => {
68
+ expect(
69
+ ComponentMapSchema.safeParse({
70
+ schemaVersion: 1,
71
+ briefId: 'BRIEF-001',
72
+ components: [
73
+ {
74
+ id: 'C-1',
75
+ kind: 'backend',
76
+ name: 'API',
77
+ responsibility: 'serves REST',
78
+ dependsOn: [],
79
+ filePaths: [],
80
+ },
81
+ ],
82
+ }).success,
83
+ ).toBe(true);
84
+ });
85
+ });
86
+
87
+ describe('DataModelSchema', () => {
88
+ it('accepts a valid model with a reference field', () => {
89
+ expect(
90
+ DataModelSchema.safeParse({
91
+ schemaVersion: 1,
92
+ briefId: 'BRIEF-001',
93
+ entities: [
94
+ {
95
+ id: 'E-1',
96
+ name: 'User',
97
+ fields: [
98
+ { name: 'id', type: 'uuid', required: true, unique: true, indexed: true },
99
+ {
100
+ name: 'orgId',
101
+ type: 'reference',
102
+ required: true,
103
+ unique: false,
104
+ indexed: false,
105
+ references: 'Org',
106
+ },
107
+ ],
108
+ conventions: [],
109
+ },
110
+ ],
111
+ relationships: [
112
+ {
113
+ id: 'R-1',
114
+ fromEntityId: 'E-1',
115
+ toEntityId: 'E-2',
116
+ kind: 'many-to-one',
117
+ enforcedAt: 'database',
118
+ },
119
+ ],
120
+ }).success,
121
+ ).toBe(false); // 'many-to-one' is not a valid RelationshipKind
122
+ });
123
+ it('accepts with a valid relationship kind', () => {
124
+ expect(
125
+ DataModelSchema.safeParse({
126
+ schemaVersion: 1,
127
+ briefId: 'BRIEF-001',
128
+ entities: [
129
+ {
130
+ id: 'E-1',
131
+ name: 'User',
132
+ fields: [{ name: 'id', type: 'uuid', required: true, unique: true, indexed: true }],
133
+ conventions: [],
134
+ },
135
+ ],
136
+ relationships: [
137
+ {
138
+ id: 'R-1',
139
+ fromEntityId: 'E-1',
140
+ toEntityId: 'E-2',
141
+ kind: 'one-to-many',
142
+ enforcedAt: 'database',
143
+ },
144
+ ],
145
+ }).success,
146
+ ).toBe(true);
147
+ });
148
+ });
149
+
150
+ describe('ApiContractSchema', () => {
151
+ it('accepts a valid contract', () => {
152
+ expect(
153
+ ApiContractSchema.safeParse({
154
+ schemaVersion: 1,
155
+ briefId: 'BRIEF-001',
156
+ endpoints: [
157
+ {
158
+ id: 'EP-1',
159
+ method: 'GET',
160
+ path: '/users',
161
+ operationId: 'listUsers',
162
+ summary: 'List users',
163
+ parameters: [],
164
+ responses: [{ status: 200, description: 'ok' }],
165
+ requiresAuth: true,
166
+ requiredRoles: ['admin'],
167
+ },
168
+ ],
169
+ }).success,
170
+ ).toBe(true);
171
+ });
172
+ it('rejects a path that does not start with /', () => {
173
+ expect(
174
+ ApiContractSchema.safeParse({
175
+ schemaVersion: 1,
176
+ briefId: 'BRIEF-001',
177
+ endpoints: [
178
+ {
179
+ id: 'EP-1',
180
+ method: 'GET',
181
+ path: 'users',
182
+ operationId: 'listUsers',
183
+ summary: 'List users',
184
+ parameters: [],
185
+ responses: [{ status: 200, description: 'ok' }],
186
+ },
187
+ ],
188
+ }).success,
189
+ ).toBe(false);
190
+ });
191
+ });
192
+
193
+ describe('SecurityDesignSchema', () => {
194
+ it('accepts a valid design', () => {
195
+ expect(
196
+ SecurityDesignSchema.safeParse({
197
+ schemaVersion: 1,
198
+ briefId: 'BRIEF-001',
199
+ authentication: {
200
+ method: 'jwt',
201
+ rationale: 'stateless, mobile-friendly',
202
+ credentialStore: 'env',
203
+ },
204
+ authorization: {
205
+ model: 'rbac',
206
+ roles: ['admin', 'user'],
207
+ protectedResources: ['/admin'],
208
+ },
209
+ threats: [
210
+ {
211
+ id: 'T-1',
212
+ threat: 'token theft',
213
+ severity: 'high',
214
+ mitigation: 'short TTL + refresh rotation',
215
+ },
216
+ ],
217
+ secrets: { loader: 'env', rotationPolicy: 'manual quarterly' },
218
+ }).success,
219
+ ).toBe(true);
220
+ });
221
+ });
222
+
223
+ describe('OperationalDesignSchema', () => {
224
+ it('accepts a valid design', () => {
225
+ expect(
226
+ OperationalDesignSchema.safeParse({
227
+ schemaVersion: 1,
228
+ briefId: 'BRIEF-001',
229
+ deployment: {
230
+ target: 'container-orchestrated',
231
+ rationale: 'auto-scaling',
232
+ regions: ['us-east'],
233
+ },
234
+ configuration: {
235
+ source: 'env',
236
+ variables: [{ name: 'DATABASE_URL', required: true, sensitive: true, description: 'DB' }],
237
+ },
238
+ observability: { channels: ['logs', 'metrics'], sinks: ['stdout'] },
239
+ scaling: { strategy: 'horizontal', triggers: ['cpu>80%'] },
240
+ }).success,
241
+ ).toBe(true);
242
+ });
243
+ });
244
+
245
+ describe('ArchitectureApprovalSchema', () => {
246
+ it('accepts a valid approval', () => {
247
+ expect(
248
+ ArchitectureApprovalSchema.safeParse({
249
+ schemaVersion: 1,
250
+ briefId: 'BRIEF-001',
251
+ selectedOptionId: 'OPT-1',
252
+ adrIds: ['ADR-0100'],
253
+ componentMapId: 'CM-1',
254
+ dataModelId: 'DM-1',
255
+ apiContractId: 'API-1',
256
+ securityDesignId: 'SD-1',
257
+ operationalDesignId: 'OD-1',
258
+ approvedBy: 'lead',
259
+ approvedAt: '2026-01-01T00:00:00.000Z',
260
+ }).success,
261
+ ).toBe(true);
262
+ });
263
+ });
@@ -0,0 +1,35 @@
1
+ // packages/contracts/src/architecture/component-map.ts
2
+ //
3
+ // Component and module map (M8 Phase C — M8-13).
4
+
5
+ import { z } from 'zod';
6
+
7
+ export const ComponentKindSchema = z.enum([
8
+ 'frontend',
9
+ 'backend',
10
+ 'service',
11
+ 'data-store',
12
+ 'external-integration',
13
+ 'background-job',
14
+ 'shared-library',
15
+ ]);
16
+
17
+ export const ComponentSchema = z.object({
18
+ id: z.string(),
19
+ kind: ComponentKindSchema,
20
+ name: z.string().min(1),
21
+ responsibility: z.string().min(1),
22
+ dependsOn: z.array(z.string()),
23
+ // Files / modules where this component lives. Filled in during scaffolding.
24
+ filePaths: z.array(z.string()).default([]),
25
+ });
26
+
27
+ export const ComponentMapSchema = z.object({
28
+ schemaVersion: z.literal(1),
29
+ briefId: z.string(),
30
+ components: z.array(ComponentSchema),
31
+ });
32
+
33
+ export type ComponentKind = z.infer<typeof ComponentKindSchema>;
34
+ export type Component = z.infer<typeof ComponentSchema>;
35
+ export type ComponentMap = z.infer<typeof ComponentMapSchema>;