@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,168 @@
1
+ // packages/contracts/src/secret-guard/detection-rule.ts
2
+ //
3
+ // Detection rule contract (M11 — M11-02).
4
+ //
5
+ // A detection rule is a named pattern + optional checksum validation that
6
+ // the detector applies to input. Built-in rules cover the common cloud and
7
+ // VCS tokens; the M11 Mod adds Gitleaks as an optional extended scanner.
8
+
9
+ import { z } from 'zod';
10
+ import { SecretKindSchema } from './finding.js';
11
+
12
+ /** ECMAScript has no (?i) flag: build case-insensitive classes explicitly. */
13
+ const ci = (word: string): string =>
14
+ [...word].map((c) => `[${c.toLowerCase()}${c.toUpperCase()}]`).join('');
15
+
16
+ const PLACEHOLDER_WORDS = ['your', 'xxx', 'example', 'changeme', 'placeholder', 'replace', 'none', 'null', 'todo'];
17
+
18
+ /**
19
+ * DhanHQ credentials, matched by NAME because no official token format is
20
+ * pinned here.
21
+ * - NAMED: DHAN_ACCESS_TOKEN / DHAN_API_SECRET / DHAN_PIN / DHAN_TOTP_SECRET
22
+ * assigned a literal of 6+ chars; placeholders are skipped.
23
+ * - GENERIC: any other variable named dhan...token/secret/key assigned a 20+
24
+ * char value that contains a digit (so `self.config.dhan_access_token`
25
+ * does not match) and is not a placeholder.
26
+ */
27
+ // The redactor's own output must never re-match as a credential (idempotence).
28
+ const PLACEHOLDER = `(?!(?:${PLACEHOLDER_WORDS.map(ci).join('|')}|\\[REDACTED))`;
29
+
30
+ const DHAN_NAMED_PATTERN =
31
+ `${ci('dhan')}[_-]?(?:${ci('access')}[_-]?${ci('token')}|${ci('api')}[_-]?${ci('secret')}|${ci('pin')}|${ci('totp')}[_-]?${ci('secret')})` +
32
+ `["']?\\s*[:=]\\s*["']?(?![$<{])${PLACEHOLDER}([^\\s"']{6,})`;
33
+
34
+ const DHAN_GENERIC_PATTERN =
35
+ `${ci('dhan')}[A-Za-z0-9_-]{0,30}?(?:${ci('token')}|${ci('secret')}|${ci('key')})["']?\\s*[:=]\\s*["']?` +
36
+ `${PLACEHOLDER}(?=[A-Za-z0-9_.+/=-]*[0-9])([A-Za-z0-9_.+/=-]{20,})`;
37
+
38
+ /** Bearer credential: header.payload.signature, base64url '{"' prefixes. */
39
+ const JWT_PATTERN = 'eyJ[A-Za-z0-9_-]{10,}\\.eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}';
40
+
41
+ export const DetectionRuleSchema = z.object({
42
+ id: z.string(),
43
+ name: z.string().min(1),
44
+ kind: SecretKindSchema,
45
+ // ECMAScript regex source (string form). The detector compiles and
46
+ // applies this with the global flag.
47
+ pattern: z.string().min(1),
48
+ // Optional checksum validator function name (e.g., "aws-key-checksum").
49
+ // The detector looks up the named validator in a registry; if absent,
50
+ // confidence is downgraded to "medium".
51
+ checksumValidator: z.string().optional(),
52
+ severity: z.enum(['low', 'medium', 'high', 'critical']),
53
+ // Whether this rule is enabled by default.
54
+ enabled: z.boolean().default(true),
55
+ });
56
+
57
+ export type DetectionRule = z.infer<typeof DetectionRuleSchema>;
58
+
59
+ /**
60
+ * Built-in detection rules. The M11 detector ships these by default;
61
+ // additional rules can be loaded from a user configuration.
62
+ */
63
+ export const BUILTIN_DETECTION_RULES: ReadonlyArray<DetectionRule> = [
64
+ {
65
+ id: 'aws-access-key',
66
+ name: 'AWS Access Key ID',
67
+ kind: 'aws-access-key',
68
+ pattern: 'AKIA[0-9A-Z]{16}',
69
+ checksumValidator: 'aws-key-checksum',
70
+ severity: 'high',
71
+ enabled: true,
72
+ },
73
+ {
74
+ id: 'aws-secret-key',
75
+ name: 'AWS Secret Access Key',
76
+ kind: 'aws-secret-key',
77
+ // 40-char base64-ish string after an assignment with aws_secret hint.
78
+ pattern:
79
+ '(?:aws_secret|secretAccessKey|secret_access_key)["\']?\\s*[:=]\\s*["\']?([A-Za-z0-9/+]{40})',
80
+ severity: 'critical',
81
+ enabled: true,
82
+ },
83
+ {
84
+ id: 'github-token',
85
+ name: 'GitHub Personal Access Token',
86
+ kind: 'github-token',
87
+ pattern: 'gh[pousr]_[A-Za-z0-9]{36,}',
88
+ severity: 'critical',
89
+ enabled: true,
90
+ },
91
+ {
92
+ id: 'gitlab-token',
93
+ name: 'GitLab Token',
94
+ kind: 'gitlab-token',
95
+ pattern: 'glpat-[A-Za-z0-9_-]{20}',
96
+ severity: 'high',
97
+ enabled: true,
98
+ },
99
+ {
100
+ id: 'google-api-key',
101
+ name: 'Google API Key',
102
+ kind: 'google-api-key',
103
+ pattern: 'AIza[0-9A-Za-z_-]{35}',
104
+ severity: 'high',
105
+ enabled: true,
106
+ },
107
+ {
108
+ id: 'stripe-key',
109
+ name: 'Stripe Secret Key',
110
+ kind: 'stripe-key',
111
+ pattern: 'sk_(?:live|test)_[0-9a-zA-Z]{24,}',
112
+ severity: 'critical',
113
+ enabled: true,
114
+ },
115
+ {
116
+ id: 'slack-token',
117
+ name: 'Slack Token',
118
+ kind: 'slack-token',
119
+ pattern: 'xox[baprs]-[0-9A-Za-z-]{10,}',
120
+ severity: 'high',
121
+ enabled: true,
122
+ },
123
+ {
124
+ id: 'private-key-pem',
125
+ name: 'PEM Private Key',
126
+ kind: 'private-key-pem',
127
+ pattern: '-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----',
128
+ severity: 'critical',
129
+ enabled: true,
130
+ },
131
+ {
132
+ id: 'generic-api-key',
133
+ name: 'Generic API Key Assignment',
134
+ kind: 'generic-api-key',
135
+ // Heuristic: a variable name containing "key"/"token"/"secret"
136
+ // assigned to a 32+ char string. Low confidence by design.
137
+ // Note: ECMAScript regex does not support the (?i) inline flag, so we
138
+ // use explicit case-insensitive character classes for the variable name.
139
+ pattern:
140
+ '(?:[Aa][Pp][Ii][_\\-]?[Kk][Ee][Yy]|[Aa][Uu][Tt][Hh][_\\-]?[Tt][Oo][Kk][Ee][Nn]|[Ss][Ee][Cc][Rr][Ee][Tt])\\s*[:=]\\s*["\']([A-Za-z0-9_+/=-]{32,})["\']',
141
+ severity: 'medium',
142
+ enabled: true,
143
+ },
144
+ {
145
+ id: 'jwt-token',
146
+ name: 'JSON Web Token (bearer credential)',
147
+ kind: 'jwt-token',
148
+ pattern: JWT_PATTERN,
149
+ severity: 'critical',
150
+ enabled: true,
151
+ },
152
+ {
153
+ id: 'dhan-credential',
154
+ name: 'DhanHQ access token / API secret / PIN / TOTP secret assignment',
155
+ kind: 'dhan-credential',
156
+ pattern: DHAN_NAMED_PATTERN,
157
+ severity: 'critical',
158
+ enabled: true,
159
+ },
160
+ {
161
+ id: 'dhan-credential-generic',
162
+ name: 'DhanHQ-named token, secret or key assignment',
163
+ kind: 'dhan-credential',
164
+ pattern: DHAN_GENERIC_PATTERN,
165
+ severity: 'critical',
166
+ enabled: true,
167
+ },
168
+ ];
@@ -0,0 +1,95 @@
1
+ // packages/contracts/src/secret-guard/finding.ts
2
+ //
3
+ // Secret finding contract (M11 — M11-01).
4
+ //
5
+ // A SecretFinding is the scanner-neutral representation of a detected
6
+ // secret. Different scanners (built-in, Gitleaks, TruffleHog) produce
7
+ // findings in this common shape so that downstream redaction and reporting
8
+ // do not depend on which scanner ran.
9
+
10
+ import { z } from 'zod';
11
+
12
+ export const SecretKindSchema = z.enum([
13
+ 'aws-access-key',
14
+ 'aws-secret-key',
15
+ 'github-token',
16
+ 'gitlab-token',
17
+ 'google-api-key',
18
+ 'google-oauth-id',
19
+ 'stripe-key',
20
+ 'slack-token',
21
+ 'generic-api-key',
22
+ 'private-key-pem',
23
+ 'jwt',
24
+ 'jwt-token',
25
+ 'dhan-credential',
26
+ 'connection-string',
27
+ 'bearer-token',
28
+ 'unknown',
29
+ ]);
30
+
31
+ // Renamed to SecretSeveritySchema to avoid collision with the
32
+ // specification.ts SeveritySchema (which is 3-level "low|medium|high" for
33
+ // risk severity). Secret severity is 4-level because secrets can be
34
+ // "critical" (e.g., production keys).
35
+ export const SecretSeveritySchema = z.enum(['low', 'medium', 'high', 'critical']);
36
+
37
+ export const SecretFindingSchema = z.object({
38
+ id: z.string(),
39
+ kind: SecretKindSchema,
40
+ // Where the secret was found.
41
+ location: z
42
+ .object({
43
+ // File path (if file-based).
44
+ filePath: z.string().optional(),
45
+ // 1-indexed line number (if known).
46
+ line: z.number().int().positive().optional(),
47
+ // 1-indexed column (if known).
48
+ column: z.number().int().nonnegative().optional(),
49
+ // 0-indexed offset (if known).
50
+ offset: z.number().int().nonnegative().optional(),
51
+ // Length of the matched secret in bytes.
52
+ length: z.number().int().positive(),
53
+ // Source: where the secret was observed.
54
+ source: z.enum([
55
+ 'file-read',
56
+ 'file-write',
57
+ 'tool-output',
58
+ 'git-staged',
59
+ 'git-commit',
60
+ 'git-push',
61
+ 'mcp-response',
62
+ ]),
63
+ })
64
+ .refine((l) => l.filePath !== undefined || l.offset !== undefined, {
65
+ message: 'location must have filePath or offset',
66
+ }),
67
+ // The detector that produced this finding.
68
+ detector: z.enum(['builtin', 'gitleaks', 'trufflehog', 'custom']),
69
+ // Confidence: high = pattern + checksum valid; medium = pattern only;
70
+ // low = heuristic match.
71
+ confidence: z.enum(['low', 'medium', 'high']),
72
+ severity: SecretSeveritySchema,
73
+ // A redacted preview: first 4 chars + "…" + last 4 chars, only if the
74
+ // secret is long enough. NEVER the full secret.
75
+ redactedPreview: z.string(),
76
+ // Whether the finding was confirmed to be redacted in the output.
77
+ // INVARIANT (post-M7 §5): a finding does not prove redaction. This flag
78
+ // is set only after the redactor has verified the value is gone.
79
+ redacted: z.boolean().default(false),
80
+ });
81
+
82
+ export type SecretKind = z.infer<typeof SecretKindSchema>;
83
+ export type SecretSeverity = z.infer<typeof SecretSeveritySchema>;
84
+ export type SecretFinding = z.infer<typeof SecretFindingSchema>;
85
+
86
+ /**
87
+ * Produce a redacted preview of a secret value. NEVER returns the full
88
+ * value. For secrets shorter than 12 chars, returns "[REDACTED:<n>]".
89
+ */
90
+ export function redactedPreview(value: string): string {
91
+ if (value.length < 12) {
92
+ return `[REDACTED:${value.length}]`;
93
+ }
94
+ return `${value.slice(0, 4)}…${value.slice(-4)}`;
95
+ }
@@ -0,0 +1,5 @@
1
+ // packages/contracts/src/secret-guard/index.ts
2
+ export * from './finding.js';
3
+ export * from './detection-rule.js';
4
+ export * from './redaction-policy.js';
5
+ export * from './scanner-failure.js';
@@ -0,0 +1,34 @@
1
+ // packages/contracts/src/secret-guard/redaction-policy.ts
2
+ //
3
+ // Redaction policy (M11 — M11-04).
4
+ //
5
+ // The redactor replaces detected secret values with a placeholder in tool
6
+ // output, file writes, and git operations. The policy declares what
7
+ // placeholder to use and how to handle repeated and partial occurrences.
8
+
9
+ import { z } from 'zod';
10
+
11
+ export const REDACTION_POLICY_SCHEMA_VERSION = 1 as const;
12
+
13
+ export const RedactionPolicySchema = z.object({
14
+ schemaVersion: z.literal(REDACTION_POLICY_SCHEMA_VERSION),
15
+ // Placeholder format: "[REDACTED:<kind>:<id>]" by default.
16
+ placeholderFormat: z
17
+ .enum(['[REDACTED]', '[REDACTED:<kind>]', '[REDACTED:<kind>:<id>]'])
18
+ .default('[REDACTED:<kind>:<id>]'),
19
+ // Whether to redact partial occurrences (e.g., a secret that spans
20
+ // multiple lines or appears in a base64-encoded payload).
21
+ redactPartial: z.boolean().default(true),
22
+ // Whether to redact repeated occurrences in the same output.
23
+ redactRepeated: z.boolean().default(true),
24
+ // Maximum input size (bytes) the redactor will process. Inputs larger
25
+ // than this are returned with a "REDACTION_SKIPPED_TOO_LARGE" notice
26
+ // rather than being silently passed through.
27
+ maxInputBytes: z.number().int().positive().default(1_000_000),
28
+ // Explicit ignore paths (e.g., test fixtures that intentionally contain
29
+ // synthetic secrets). MUST be specific paths, not globs that could
30
+ // match arbitrary files.
31
+ ignorePaths: z.array(z.string()).default([]),
32
+ });
33
+
34
+ export type RedactionPolicy = z.infer<typeof RedactionPolicySchema>;
@@ -0,0 +1,47 @@
1
+ // packages/contracts/src/secret-guard/scanner-failure.ts
2
+ //
3
+ // Scanner failure behavior (M11 — M11-09).
4
+ //
5
+ // INVARIANT (post-M7 §5): a scanner failure MUST be visible. It MUST NOT
6
+ // be reported as a clean result. The ScannerOutcome contract makes this
7
+ // explicit: the outcome is one of "clean", "findings", "failed", or
8
+ // "skipped-too-large" — never an implicit "clean" when the scanner errored.
9
+
10
+ import { z } from 'zod';
11
+
12
+ export const ScannerOutcomeSchema = z.enum([
13
+ 'clean', // scanner ran successfully and found no secrets
14
+ 'findings', // scanner ran successfully and found secrets
15
+ 'failed', // scanner errored; results are NOT trustworthy
16
+ 'skipped-too-large', // input exceeded maxInputBytes; not scanned
17
+ 'skipped-ignored', // path was in ignorePaths; not scanned
18
+ ]);
19
+
20
+ export const ScannerResultSchema = z.object({
21
+ outcome: ScannerOutcomeSchema,
22
+ // Present only when outcome === "findings".
23
+ findings: z
24
+ .array(
25
+ z.object({
26
+ id: z.string(),
27
+ kind: z.string(),
28
+ redactedPreview: z.string(),
29
+ }),
30
+ )
31
+ .default([]),
32
+ // Present only when outcome === "failed". NEVER includes the input that
33
+ // caused the failure (could contain a secret).
34
+ error: z
35
+ .object({
36
+ code: z.string(),
37
+ message: z.string(),
38
+ })
39
+ .optional(),
40
+ // The number of bytes scanned (or skipped).
41
+ bytesProcessed: z.number().int().nonnegative(),
42
+ // Duration in milliseconds.
43
+ durationMs: z.number().int().nonnegative(),
44
+ });
45
+
46
+ export type ScannerOutcome = z.infer<typeof ScannerOutcomeSchema>;
47
+ export type ScannerResult = z.infer<typeof ScannerResultSchema>;
@@ -0,0 +1,130 @@
1
+ // packages/contracts/src/secret-guard/secret-guard.test.ts
2
+ import { describe, expect, it } from 'vitest';
3
+ import { SecretFindingSchema, redactedPreview } from './finding.js';
4
+ import { BUILTIN_DETECTION_RULES, DetectionRuleSchema } from './detection-rule.js';
5
+ import { RedactionPolicySchema } from './redaction-policy.js';
6
+ import { ScannerResultSchema, ScannerOutcomeSchema } from './scanner-failure.js';
7
+
8
+ describe('redactedPreview', () => {
9
+ it('returns a redacted preview for long secrets', () => {
10
+ expect(redactedPreview('AKIAIOSFODNN7EXAMPLE')).toBe('AKIA…MPLE');
11
+ });
12
+ it('returns [REDACTED:n] for short values', () => {
13
+ expect(redactedPreview('short')).toBe('[REDACTED:5]');
14
+ });
15
+ });
16
+
17
+ describe('SecretFindingSchema', () => {
18
+ it('accepts a file-based finding', () => {
19
+ expect(
20
+ SecretFindingSchema.safeParse({
21
+ id: 'F-1',
22
+ kind: 'github-token',
23
+ location: {
24
+ filePath: 'src/config.ts',
25
+ line: 12,
26
+ column: 5,
27
+ length: 40,
28
+ source: 'file-read',
29
+ },
30
+ detector: 'builtin',
31
+ confidence: 'high',
32
+ severity: 'critical',
33
+ redactedPreview: 'ghp_…abcd',
34
+ redacted: false,
35
+ }).success,
36
+ ).toBe(true);
37
+ });
38
+ it('rejects a finding with neither filePath nor offset', () => {
39
+ expect(
40
+ SecretFindingSchema.safeParse({
41
+ id: 'F-1',
42
+ kind: 'github-token',
43
+ location: { length: 40, source: 'tool-output' },
44
+ detector: 'builtin',
45
+ confidence: 'high',
46
+ severity: 'critical',
47
+ redactedPreview: 'ghp_…abcd',
48
+ }).success,
49
+ ).toBe(false);
50
+ });
51
+ });
52
+
53
+ describe('DetectionRuleSchema and BUILTIN_DETECTION_RULES', () => {
54
+ it('validates every built-in rule', () => {
55
+ for (const rule of BUILTIN_DETECTION_RULES) {
56
+ expect(DetectionRuleSchema.safeParse(rule).success).toBe(true);
57
+ }
58
+ });
59
+ it('includes rules for AWS, GitHub, GitLab, Google, Stripe, Slack, PEM, generic', () => {
60
+ const kinds = BUILTIN_DETECTION_RULES.map((r) => r.kind);
61
+ expect(kinds).toContain('aws-access-key');
62
+ expect(kinds).toContain('github-token');
63
+ expect(kinds).toContain('gitlab-token');
64
+ expect(kinds).toContain('google-api-key');
65
+ expect(kinds).toContain('stripe-key');
66
+ expect(kinds).toContain('slack-token');
67
+ expect(kinds).toContain('private-key-pem');
68
+ expect(kinds).toContain('generic-api-key');
69
+ });
70
+ });
71
+
72
+ describe('RedactionPolicySchema', () => {
73
+ it('accepts a default policy', () => {
74
+ expect(
75
+ RedactionPolicySchema.safeParse({
76
+ schemaVersion: 1,
77
+ placeholderFormat: '[REDACTED:<kind>:<id>]',
78
+ redactPartial: true,
79
+ redactRepeated: true,
80
+ maxInputBytes: 1_000_000,
81
+ ignorePaths: [],
82
+ }).success,
83
+ ).toBe(true);
84
+ });
85
+ });
86
+
87
+ describe('ScannerOutcomeSchema', () => {
88
+ it('accepts the five outcome kinds', () => {
89
+ for (const o of ['clean', 'findings', 'failed', 'skipped-too-large', 'skipped-ignored']) {
90
+ expect(ScannerOutcomeSchema.safeParse(o).success).toBe(true);
91
+ }
92
+ });
93
+ it("rejects 'success' (a scanner cannot report implicit success)", () => {
94
+ expect(ScannerOutcomeSchema.safeParse('success').success).toBe(false);
95
+ });
96
+ });
97
+
98
+ describe('ScannerResultSchema', () => {
99
+ it('accepts a clean result', () => {
100
+ expect(
101
+ ScannerResultSchema.safeParse({
102
+ outcome: 'clean',
103
+ findings: [],
104
+ bytesProcessed: 100,
105
+ durationMs: 5,
106
+ }).success,
107
+ ).toBe(true);
108
+ });
109
+ it('accepts a failed result with an error (no input echoed)', () => {
110
+ expect(
111
+ ScannerResultSchema.safeParse({
112
+ outcome: 'failed',
113
+ findings: [],
114
+ error: { code: 'REGEX_TIMEOUT', message: 'regex timed out' },
115
+ bytesProcessed: 0,
116
+ durationMs: 5000,
117
+ }).success,
118
+ ).toBe(true);
119
+ });
120
+ it('accepts a skipped-too-large result', () => {
121
+ expect(
122
+ ScannerResultSchema.safeParse({
123
+ outcome: 'skipped-too-large',
124
+ findings: [],
125
+ bytesProcessed: 5_000_000,
126
+ durationMs: 0,
127
+ }).success,
128
+ ).toBe(true);
129
+ });
130
+ });
@@ -0,0 +1,2 @@
1
+ // packages/contracts/src/specification/index.ts
2
+ export * from './specification.js';
@@ -0,0 +1,79 @@
1
+ // packages/contracts/src/specification/specification.ts
2
+ //
3
+ // Feature specification contract. Declared in M0; produced by the
4
+ // requirements-engineering skill in M3 and validated by kit validate-spec.
5
+ //
6
+ // See docs/contracts/CONTRACTS.md §4.
7
+
8
+ import { z } from 'zod';
9
+
10
+ export const SpecificationSectionSchema = z.enum([
11
+ 'overview',
12
+ 'problem',
13
+ 'scope',
14
+ 'actors',
15
+ 'functionalRequirements',
16
+ 'nonFunctionalRequirements',
17
+ 'acceptanceCriteria',
18
+ 'edgeCases',
19
+ 'dependencies',
20
+ 'risks',
21
+ 'openQuestions',
22
+ ]);
23
+
24
+ export const SeveritySchema = z.enum(['low', 'medium', 'high']);
25
+
26
+ export const AcceptanceCriterionSchema = z.object({
27
+ id: z.string(),
28
+ criterion: z.string().min(1),
29
+ });
30
+
31
+ export const RequirementSchema = z.object({
32
+ id: z.string(),
33
+ statement: z.string().min(1),
34
+ });
35
+
36
+ export const RiskSchema = z.object({
37
+ id: z.string(),
38
+ severity: SeveritySchema,
39
+ description: z.string().min(1),
40
+ });
41
+
42
+ export const OpenQuestionSchema = z.object({
43
+ id: z.string(),
44
+ question: z.string().min(1),
45
+ resolved: z.boolean(),
46
+ });
47
+
48
+ export const FeatureSpecificationSchema = z
49
+ .object({
50
+ id: z.string().regex(/^[A-Z]+-[0-9]{3,}$/, 'id must match FEATURE-NNN'),
51
+ title: z.string().min(1).max(200),
52
+ overview: z.string().min(1),
53
+ problem: z.string().min(1),
54
+ scope: z.object({
55
+ in: z.array(z.string()),
56
+ out: z.array(z.string()),
57
+ }),
58
+ actors: z.array(z.object({ name: z.string(), role: z.string() })),
59
+ functionalRequirements: z.array(RequirementSchema),
60
+ nonFunctionalRequirements: z.array(RequirementSchema),
61
+ acceptanceCriteria: z.array(AcceptanceCriterionSchema),
62
+ edgeCases: z.array(z.string()),
63
+ dependencies: z.array(z.string()),
64
+ risks: z.array(RiskSchema),
65
+ openQuestions: z.array(OpenQuestionSchema),
66
+ })
67
+ .strict();
68
+
69
+ export type FeatureSpecification = z.infer<typeof FeatureSpecificationSchema>;
70
+
71
+ export const BddScenarioSchema = z.object({
72
+ feature: z.string().min(1),
73
+ scenario: z.string().min(1),
74
+ given: z.array(z.string()),
75
+ when: z.array(z.string()),
76
+ then: z.array(z.string()),
77
+ });
78
+
79
+ export type BddScenario = z.infer<typeof BddScenarioSchema>;
@@ -0,0 +1,2 @@
1
+ // packages/contracts/src/stack-pack/index.ts
2
+ export * from './manifest.js';
@@ -0,0 +1,60 @@
1
+ // packages/contracts/src/stack-pack/manifest.ts
2
+ //
3
+ // M14 stack pack manifest (M14-01, M14-02). Each stack pack declares its
4
+ // compatibility, the skills/references/templates/scripts/policies it
5
+ // provides, and the conventions it imposes.
6
+
7
+ import { z } from 'zod';
8
+
9
+ export const STACK_PACK_MANIFEST_SCHEMA_VERSION = 1 as const;
10
+
11
+ export const StackPackManifestSchema = z.object({
12
+ schemaVersion: z.literal(STACK_PACK_MANIFEST_SCHEMA_VERSION),
13
+ id: z.string().regex(/^[a-z][a-z0-9-]*$/, 'stack id must be kebab-case'),
14
+ name: z.string().min(1),
15
+ description: z.string().min(1),
16
+ version: z.string().regex(/^\d+\.\d+\.\d+$/, 'semver'),
17
+ // The stacks this pack covers (e.g., ["node-typescript"]).
18
+ stacks: z.array(z.string()).min(1),
19
+ // Required kit compatibility.
20
+ kitCompatibility: z.string().min(1),
21
+ // Skills this pack provides (relative paths within the pack).
22
+ skills: z.array(z.string()).default([]),
23
+ // Reference documents (markdown).
24
+ references: z.array(z.string()).default([]),
25
+ // Project templates this pack provides.
26
+ templates: z.array(z.string()).default([]),
27
+ // Deterministic scripts (lint, test, build, typecheck commands).
28
+ scripts: z
29
+ .array(
30
+ z.object({
31
+ name: z.string(),
32
+ command: z.array(z.string().min(1)).min(1),
33
+ description: z.string(),
34
+ }),
35
+ )
36
+ .default([]),
37
+ // Stack-specific policies (e.g., "always use service objects in Rails").
38
+ policies: z.array(z.string()).default([]),
39
+ // Whether this pack depends on another pack.
40
+ dependsOn: z.array(z.string()).default([]),
41
+ });
42
+
43
+ export type StackPackManifest = z.infer<typeof StackPackManifestSchema>;
44
+
45
+ /**
46
+ * Skill loading rules (M14-02). How the kit discovers and loads
47
+ * stack-specific skills.
48
+ */
49
+ export const SkillLoadingRuleSchema = z.object({
50
+ // The skill name to load.
51
+ skill: z.string().min(1),
52
+ // The stacks that should load this skill.
53
+ appliesToStacks: z.array(z.string()),
54
+ // The trigger that loads the skill (on-demand vs always-loaded).
55
+ trigger: z.enum(['on-demand', 'always-loaded']).default('on-demand'),
56
+ // The path within the pack where the skill lives.
57
+ path: z.string().min(1),
58
+ });
59
+
60
+ export type SkillLoadingRule = z.infer<typeof SkillLoadingRuleSchema>;
@@ -0,0 +1,2 @@
1
+ // packages/contracts/src/verification/index.ts
2
+ export * from './report.js';