@smartergpt/lexrunner 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1433) hide show
  1. package/.changes/ci-debug-added.txt +1 -0
  2. package/.changeset/tsconfig-solution-build.md +5 -0
  3. package/.editorconfig +9 -0
  4. package/.env.example +8 -0
  5. package/.github/COST_EFFICIENCY.md +60 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  7. package/.github/ISSUE_TEMPLATE/epic.yml +123 -0
  8. package/.github/ISSUE_TEMPLATE/feature_request.md +26 -0
  9. package/.github/ISSUE_TEMPLATE/issue-A1-gate-input-validation.md +380 -0
  10. package/.github/ISSUE_TEMPLATE/issue-B1-scope-validation.md +509 -0
  11. package/.github/ISSUE_TEMPLATE/issue-C1-command-whitelist.md +463 -0
  12. package/.github/ISSUE_TEMPLATE/subtask.yml +153 -0
  13. package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
  14. package/.github/copilot-instructions-old.md +429 -0
  15. package/.github/copilot-instructions.md +33 -0
  16. package/.github/instructions/tests.instructions.md +10 -0
  17. package/.github/workflows/auto-delete-merged-branches.yml +103 -0
  18. package/.github/workflows/benchmarks.yml +72 -0
  19. package/.github/workflows/ci-debug.yml +33 -0
  20. package/.github/workflows/ci.yml +167 -0
  21. package/.github/workflows/cli-smoke-test.yml +345 -0
  22. package/.github/workflows/copilot-setup-steps.yml +20 -0
  23. package/.github/workflows/frame-emission-gate.yml +242 -0
  24. package/.github/workflows/project-auto.yml +24 -0
  25. package/.github/workflows/release.yml +260 -0
  26. package/.github/workflows/slow-cli-tests.yml +37 -0
  27. package/.github/workflows/tag-guard.yml +44 -0
  28. package/.husky/pre-commit +1 -0
  29. package/.nvmrc +2 -0
  30. package/.prettierignore +28 -0
  31. package/.prettierrc.json +10 -0
  32. package/.smartergpt/CONTROL_DECK_VISION.md +226 -0
  33. package/.smartergpt/allowed-commands.json +41 -0
  34. package/.smartergpt/allowed-commands.strict.json +56 -0
  35. package/.smartergpt/deliverables/.live.md +426 -0
  36. package/.smartergpt/deliverables/ISSUE_STATUS_2025-12-28.md +193 -0
  37. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/ADR_DISCUSSION.md +379 -0
  38. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/Answer_claude-haiku.md +109 -0
  39. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/Answer_gemini-flash.md +42 -0
  40. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/Answer_gpt-codex-mini.md +19 -0
  41. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/Answer_raptor-mini.md +37 -0
  42. package/.smartergpt/deliverables/_research/snapshot-contract-feedback/Question.md +37 -0
  43. package/.smartergpt/deliverables/merge-weave-04469e41-24ba-4ed5-b0ff-13c7ea12858d.ndjson +2 -0
  44. package/.smartergpt/deps.yml +3 -0
  45. package/.smartergpt/docs/fanout-templates.md +213 -0
  46. package/.smartergpt/docs/merge-weave-interventions.md +261 -0
  47. package/.smartergpt/docs/test-fix-patterns.md +240 -0
  48. package/.smartergpt/fanout-templates.yml +263 -0
  49. package/.smartergpt/gates.yml +9 -0
  50. package/.smartergpt/intent.md +1 -0
  51. package/.smartergpt/issues/QOL-001-analysis-script-filtering.md +36 -0
  52. package/.smartergpt/issues/QOL-002-log-retention-policy.md +92 -0
  53. package/.smartergpt/issues/QOL-003-realtime-console-feedback.md +44 -0
  54. package/.smartergpt/issues/QOL-004-governance-report-cli.md +44 -0
  55. package/.smartergpt/issues/QOL-005-schema-versioning.md +46 -0
  56. package/.smartergpt/issues/QOL-006-debug-verbose-mode.md +45 -0
  57. package/.smartergpt/issues/QOL-COMPLETION-REPORT.md +359 -0
  58. package/.smartergpt/issues/QOL-REVIEW-SUMMARY.md +111 -0
  59. package/.smartergpt/issues/QOL-ROADMAP.md +71 -0
  60. package/.smartergpt/merge-policy.yml +41 -0
  61. package/.smartergpt/merge-weave-policy.yml +255 -0
  62. package/.smartergpt/o1.json +0 -0
  63. package/.smartergpt/o2.json +0 -0
  64. package/.smartergpt/personas/eager-pm.md +123 -0
  65. package/.smartergpt/personas/example.md +81 -0
  66. package/.smartergpt/personas/senior-dev.md +107 -0
  67. package/.smartergpt/profile.yml +2 -0
  68. package/.smartergpt/prompts/create-project.md +112 -0
  69. package/.smartergpt/prompts/idea.md +64 -0
  70. package/.smartergpt/pull-request-template.md +25 -0
  71. package/.smartergpt/schemas/behavior-rule.schema.d.ts +54 -0
  72. package/.smartergpt/schemas/behavior-rule.schema.js +56 -0
  73. package/.smartergpt/schemas/behavior-rule.schema.json +105 -0
  74. package/.smartergpt/schemas/behavior-rule.schema.ts +60 -0
  75. package/.smartergpt/schemas/execution-plan-v1.d.ts +47 -0
  76. package/.smartergpt/schemas/execution-plan-v1.js +22 -0
  77. package/.smartergpt/schemas/execution-plan-v1.json +113 -0
  78. package/.smartergpt/schemas/execution-plan-v1.ts +32 -0
  79. package/.smartergpt/schemas/execution-plan.schema.json +116 -0
  80. package/.smartergpt/schemas/feature-spec-v0.d.ts +13 -0
  81. package/.smartergpt/schemas/feature-spec-v0.js +12 -0
  82. package/.smartergpt/schemas/feature-spec-v0.json +58 -0
  83. package/.smartergpt/schemas/feature-spec-v0.ts +16 -0
  84. package/.smartergpt/schemas/feature-spec.schema.json +111 -0
  85. package/.smartergpt/schemas/gates.schema.d.ts +48 -0
  86. package/.smartergpt/schemas/gates.schema.js +20 -0
  87. package/.smartergpt/schemas/gates.schema.json +47 -0
  88. package/.smartergpt/schemas/gates.schema.ts +26 -0
  89. package/.smartergpt/schemas/idea.schema.json +81 -0
  90. package/.smartergpt/schemas/runner.scope.schema.d.ts +54 -0
  91. package/.smartergpt/schemas/runner.scope.schema.js +28 -0
  92. package/.smartergpt/schemas/runner.scope.schema.json +75 -0
  93. package/.smartergpt/schemas/runner.scope.schema.ts +36 -0
  94. package/.smartergpt/schemas/runner.stack.schema.d.ts +40 -0
  95. package/.smartergpt/schemas/runner.stack.schema.js +21 -0
  96. package/.smartergpt/schemas/runner.stack.schema.json +51 -0
  97. package/.smartergpt/schemas/runner.stack.schema.ts +27 -0
  98. package/.smartergpt/scope.yml +11 -0
  99. package/.smartergpt/stack.yml +16 -0
  100. package/.smartergpt/test-fix-patterns.yml +106 -0
  101. package/.tool-versions +13 -0
  102. package/AGENTS.md +402 -0
  103. package/CHANGELOG.md +256 -0
  104. package/CLAUDE.md +484 -0
  105. package/CONTRIBUTING.md +345 -0
  106. package/EAGER_PM_FANOUT_ANALYSIS.md +283 -0
  107. package/FAQ.md +292 -0
  108. package/FIXTURE_LIBRARY_SUMMARY.md +327 -0
  109. package/IMPLEMENTATION_SUMMARY.md +222 -0
  110. package/LICENSE +21 -0
  111. package/MANUAL_TEST_GUIDE.md +229 -0
  112. package/MCP-ALIGNMENT-SUMMARY.md +261 -0
  113. package/MCP-CONFIG.md +125 -0
  114. package/MERGE_WEAVE_QUICKSTART.md +450 -0
  115. package/MERGE_WEAVE_SUMMARY.md +259 -0
  116. package/MERGE_WEAVE_USAGE_GUIDE.md +368 -0
  117. package/NOTICE.md +43 -0
  118. package/README.mcp.md +770 -0
  119. package/README.md +1069 -0
  120. package/TEST_INFRASTRUCTURE_ASSESSMENT.md +225 -0
  121. package/bootstrap-lexrunner.sh +396 -0
  122. package/dist/api-7H7SJZIX.js +15 -0
  123. package/dist/api-U3X2WA6D.js +15 -0
  124. package/dist/audit-2TZ2LU72.js +60 -0
  125. package/dist/audit-5HH5BMKI.js +60 -0
  126. package/dist/audit-6K5K333I.js +60 -0
  127. package/dist/audit-DYQWS57J.js +60 -0
  128. package/dist/audit-JBWZ2GZ2.js +60 -0
  129. package/dist/audit-SJF3434D.js +60 -0
  130. package/dist/audit-TICGGVX5.js +60 -0
  131. package/dist/audit-YOBB27PY.js +60 -0
  132. package/dist/autopilot-3GAVXWWC.js +45 -0
  133. package/dist/autopilot-43NOYVQA.js +45 -0
  134. package/dist/autopilot-4UA3OWLU.js +45 -0
  135. package/dist/autopilot-54TK5CCG.js +45 -0
  136. package/dist/autopilot-5BHC2UQT.js +45 -0
  137. package/dist/autopilot-ABZUCVGY.js +45 -0
  138. package/dist/autopilot-ACJZP47Y.js +45 -0
  139. package/dist/autopilot-AL5F5AUS.js +46 -0
  140. package/dist/autopilot-BO67FWUC.js +45 -0
  141. package/dist/autopilot-BR6W4GEX.js +45 -0
  142. package/dist/autopilot-FOR2UKRY.js +45 -0
  143. package/dist/autopilot-GDTTXHEQ.js +45 -0
  144. package/dist/autopilot-GEAMFZBM.js +45 -0
  145. package/dist/autopilot-HDMBRZE6.js +45 -0
  146. package/dist/autopilot-IKI2Y6S4.js +44 -0
  147. package/dist/autopilot-ILTBWWOL.js +46 -0
  148. package/dist/autopilot-KI3MXIFI.js +44 -0
  149. package/dist/autopilot-LWNPZC3J.js +45 -0
  150. package/dist/autopilot-LXPJ4ZXF.js +45 -0
  151. package/dist/autopilot-MDIFIONK.js +46 -0
  152. package/dist/autopilot-NW3LDP6M.js +45 -0
  153. package/dist/autopilot-OKTSCG35.js +45 -0
  154. package/dist/autopilot-OR5PF5PD.js +45 -0
  155. package/dist/autopilot-PE65SBGN.js +45 -0
  156. package/dist/autopilot-PW7I4B6W.js +45 -0
  157. package/dist/autopilot-QMLBL5P6.js +45 -0
  158. package/dist/autopilot-QSN6ZU5O.js +45 -0
  159. package/dist/autopilot-R7EZJOGI.js +46 -0
  160. package/dist/autopilot-T544CPPD.js +44 -0
  161. package/dist/autopilot-TNQB6VGJ.js +44 -0
  162. package/dist/autopilot-UVIYCR6K.js +45 -0
  163. package/dist/autopilot-W3ZTTSH3.js +45 -0
  164. package/dist/autopilot-XPKWOFXO.js +44 -0
  165. package/dist/autopilot-XRX4QWRM.js +44 -0
  166. package/dist/autopilot-Y3BAGNI5.js +44 -0
  167. package/dist/autopilot-ZE64XW2K.js +44 -0
  168. package/dist/chunk-2ESYSVXG.js +48 -0
  169. package/dist/chunk-2VR554P7.js +668 -0
  170. package/dist/chunk-37DOWIVT.js +1084 -0
  171. package/dist/chunk-3DU2DWUP.js +400 -0
  172. package/dist/chunk-3DVXIZFM.js +11166 -0
  173. package/dist/chunk-3FABZF4V.js +811 -0
  174. package/dist/chunk-4FFGNTAV.js +515 -0
  175. package/dist/chunk-4GEC4HC3.js +11221 -0
  176. package/dist/chunk-4RVZNLD4.js +628 -0
  177. package/dist/chunk-55VWJYZY.js +39 -0
  178. package/dist/chunk-5CGWZH5X.js +340 -0
  179. package/dist/chunk-5QKWKK4M.js +11794 -0
  180. package/dist/chunk-5Z3XHND7.js +11755 -0
  181. package/dist/chunk-6A4IE3TI.js +302 -0
  182. package/dist/chunk-6KK5JFFE.js +106 -0
  183. package/dist/chunk-6YC2VSLE.js +11252 -0
  184. package/dist/chunk-7C4K2SHD.js +668 -0
  185. package/dist/chunk-ANXY4RGA.js +11091 -0
  186. package/dist/chunk-ASHKNUBR.js +11312 -0
  187. package/dist/chunk-B3OYDPOP.js +11793 -0
  188. package/dist/chunk-DBH7SQ2S.js +1084 -0
  189. package/dist/chunk-DEI7A5B4.js +11449 -0
  190. package/dist/chunk-DM4GHY3J.js +92 -0
  191. package/dist/chunk-EQKFCZLH.js +9823 -0
  192. package/dist/chunk-FAIJPBT5.js +40 -0
  193. package/dist/chunk-FDDKUDXR.js +11166 -0
  194. package/dist/chunk-FEAR6ETG.js +438 -0
  195. package/dist/chunk-FNBAHK5V.js +72 -0
  196. package/dist/chunk-FXL74C73.js +523 -0
  197. package/dist/chunk-GLJEDX4L.js +10247 -0
  198. package/dist/chunk-GTP4OHD7.js +1107 -0
  199. package/dist/chunk-HIHH7IVO.js +10557 -0
  200. package/dist/chunk-I3VXUVCB.js +10474 -0
  201. package/dist/chunk-I6BIFVWI.js +10519 -0
  202. package/dist/chunk-I72TRUTJ.js +1084 -0
  203. package/dist/chunk-J5B5KT2F.js +368 -0
  204. package/dist/chunk-JMTULZ66.js +11743 -0
  205. package/dist/chunk-JXIQ7HCK.js +11166 -0
  206. package/dist/chunk-K6HVPBDP.js +10692 -0
  207. package/dist/chunk-KBT5Y666.js +521 -0
  208. package/dist/chunk-LETPROKG.js +11092 -0
  209. package/dist/chunk-LLMY2BZF.js +1084 -0
  210. package/dist/chunk-NMNL4US2.js +1084 -0
  211. package/dist/chunk-O2XRP7JK.js +10247 -0
  212. package/dist/chunk-OGPWLFFO.js +11201 -0
  213. package/dist/chunk-OQJUWTZV.js +51 -0
  214. package/dist/chunk-PJRWPLQ6.js +669 -0
  215. package/dist/chunk-PYRVUCJR.js +370 -0
  216. package/dist/chunk-Q6Y524KH.js +669 -0
  217. package/dist/chunk-QF7DM5VW.js +106 -0
  218. package/dist/chunk-QGM4M3NI.js +37 -0
  219. package/dist/chunk-QIIELFTL.js +1107 -0
  220. package/dist/chunk-QUW6N7GR.js +10264 -0
  221. package/dist/chunk-QZASNLQX.js +11223 -0
  222. package/dist/chunk-RMN4IAWO.js +11808 -0
  223. package/dist/chunk-RN5NHU37.js +11465 -0
  224. package/dist/chunk-RNG3RILO.js +11755 -0
  225. package/dist/chunk-RSA6DEB4.js +9748 -0
  226. package/dist/chunk-RURYWSMX.js +10524 -0
  227. package/dist/chunk-SUEXK5U7.js +11201 -0
  228. package/dist/chunk-TVUF55OH.js +11807 -0
  229. package/dist/chunk-U5MMENCP.js +456 -0
  230. package/dist/chunk-U62I2R2D.js +434 -0
  231. package/dist/chunk-UHFMFO54.js +21 -0
  232. package/dist/chunk-UNZBDSEU.js +11166 -0
  233. package/dist/chunk-UOATTNQP.js +334 -0
  234. package/dist/chunk-UZFYNSMJ.js +334 -0
  235. package/dist/chunk-VP37GLU6.js +1084 -0
  236. package/dist/chunk-W6WDKBWO.js +11453 -0
  237. package/dist/chunk-XBKUFNVF.js +10745 -0
  238. package/dist/chunk-XOLVQTIE.js +670 -0
  239. package/dist/chunk-XVFTBVDS.js +257 -0
  240. package/dist/chunk-YABA7DB6.js +11091 -0
  241. package/dist/chunk-YWCJX5KL.js +10557 -0
  242. package/dist/chunk-Z5GP7FSR.js +309 -0
  243. package/dist/chunk-ZBT3DATZ.js +296 -0
  244. package/dist/chunk-ZDBAZXUQ.js +11201 -0
  245. package/dist/chunk-ZEMABYS4.js +92 -0
  246. package/dist/chunk-ZOA4HT7P.js +662 -0
  247. package/dist/cli.cjs +40431 -0
  248. package/dist/cli.d.cts +2709 -0
  249. package/dist/cli.d.ts +2709 -0
  250. package/dist/cli.js +21149 -0
  251. package/dist/commandValidator-42OUDFZ4.js +140 -0
  252. package/dist/commandValidator-7LQHTYL5.js +140 -0
  253. package/dist/commandValidator-AT5OYZFC.js +142 -0
  254. package/dist/commandValidator-DH3CX2OW.js +140 -0
  255. package/dist/commandValidator-GCQC7H4A.js +140 -0
  256. package/dist/commandValidator-K6VWB6O3.js +140 -0
  257. package/dist/commandValidator-L6WNDBYB.js +129 -0
  258. package/dist/commandValidator-O3KSNXD2.js +140 -0
  259. package/dist/commandValidator-ZHMUA5RQ.js +140 -0
  260. package/dist/constraints-M52FVL2X.js +11 -0
  261. package/dist/dist-CSOR2BL2.js +1144 -0
  262. package/dist/dist-PKOIS5NZ.js +1144 -0
  263. package/dist/fileAnalysis-3VMDDJ6I.js +9 -0
  264. package/dist/fileAnalysis-4QLHUT44.js +9 -0
  265. package/dist/fileAnalysis-H6M2Z7ZC.js +9 -0
  266. package/dist/fileAnalysis-HMI7IL6S.js +9 -0
  267. package/dist/fileAnalysis-JHABOPUQ.js +9 -0
  268. package/dist/gateMapping-E5MGNJH5.js +17 -0
  269. package/dist/jsonEnvelope-R4SWKX2N.js +62 -0
  270. package/dist/mergeTreeSimulator-ATOPJ3DU.js +11 -0
  271. package/dist/mergeTreeSimulator-AYUK4TZT.js +11 -0
  272. package/dist/mergeTreeSimulator-BBWJUQBK.js +11 -0
  273. package/dist/mergeTreeSimulator-DJJDRB5N.js +11 -0
  274. package/dist/mergeTreeSimulator-X4BA647P.js +11 -0
  275. package/dist/planDiff-37QHCPKO.js +109 -0
  276. package/dist/planDiff-BQHIUARB.js +109 -0
  277. package/dist/planDiff-QOK6KNB7.js +111 -0
  278. package/dist/planDiff-RXR4CWFS.js +109 -0
  279. package/dist/planDiff-W2BTH2MU.js +109 -0
  280. package/dist/planHistory-4J3Q6AJ3.js +126 -0
  281. package/dist/planHistory-DQRSB2Y7.js +118 -0
  282. package/dist/planHistory-GLCXP6AB.js +126 -0
  283. package/dist/planHistory-SMNRLEKG.js +126 -0
  284. package/dist/planHistory-UO4WZ6GO.js +126 -0
  285. package/dist/planReview-7BWVLABC.js +377 -0
  286. package/dist/planReview-7VB3OYKZ.js +385 -0
  287. package/dist/planReview-FAIBIAE6.js +377 -0
  288. package/dist/planReview-FXQBDNKJ.js +376 -0
  289. package/dist/planReview-HO4YYETA.js +377 -0
  290. package/dist/planReview-I26EKCUK.js +376 -0
  291. package/dist/planReview-JBOAJHSU.js +377 -0
  292. package/dist/planReview-SCNZWC6B.js +376 -0
  293. package/dist/planReview-TU7LMZIY.js +376 -0
  294. package/dist/planViewer-2YZCPVDM.js +155 -0
  295. package/dist/planViewer-72WZFUTU.js +154 -0
  296. package/dist/planViewer-G546TVHV.js +154 -0
  297. package/dist/planViewer-I7ZHNJQF.js +150 -0
  298. package/dist/planViewer-IRXHOY5U.js +155 -0
  299. package/dist/planViewer-IX2ICW45.js +154 -0
  300. package/dist/planViewer-PDWPUOP6.js +155 -0
  301. package/dist/planViewer-PEOADAGZ.js +155 -0
  302. package/dist/planViewer-PFYDEG6V.js +150 -0
  303. package/dist/planViewer-UIPOSRVW.js +151 -0
  304. package/dist/planViewer-V2JUKV7Q.js +154 -0
  305. package/dist/sarif-46TKOOJZ.js +9 -0
  306. package/dist/sarif-63JKTFFI.js +9 -0
  307. package/dist/sarif-CIYIWUNC.js +9 -0
  308. package/dist/sarif-OGAGDL6B.js +9 -0
  309. package/dist/sarif-XIREI5B5.js +9 -0
  310. package/dist/security-3V6FKJDA.js +423 -0
  311. package/dist/security-4JMEUM56.js +423 -0
  312. package/dist/security-QHPEWY5G.js +423 -0
  313. package/dist/security-V2LAL5TP.js +415 -0
  314. package/dist/security-WTASK6T6.js +423 -0
  315. package/dist/security-XE4GHVJD.js +423 -0
  316. package/dist/security-XLXM3UHT.js +423 -0
  317. package/dist/security-YDLHSMVY.js +441 -0
  318. package/dist/security-ZDAEZF7D.js +423 -0
  319. package/dist/signing-3EI734L4.js +14 -0
  320. package/dist/signing-5G7K6JXJ.js +14 -0
  321. package/dist/signing-7DK7SABM.js +14 -0
  322. package/dist/signing-JJJOUGCW.js +14 -0
  323. package/dist/signing-OAJ3MXGA.js +14 -0
  324. package/dist/verify-5F6PUXUQ.js +62 -0
  325. package/dist/verify-5ILURHV2.js +62 -0
  326. package/dist/verify-MRDZJUGO.js +62 -0
  327. package/dist/verify-SCUHB3SA.js +62 -0
  328. package/dist/verify-YZRHN2D3.js +62 -0
  329. package/docs/1.0.0-vertical-slice.md +214 -0
  330. package/docs/ADR-007-INTEGRATION-SUMMARY.md +232 -0
  331. package/docs/ALIASING_FOR_LEXRUNNER.md +709 -0
  332. package/docs/ALIASING_FOR_RUNNER.md +552 -0
  333. package/docs/AX.md +317 -0
  334. package/docs/CHECKPOINT_RESUME.md +208 -0
  335. package/docs/CLI_VERBS.md +219 -0
  336. package/docs/CONFLICT_DETECTION.md +198 -0
  337. package/docs/DISCIPLINED_FAILURE.md +224 -0
  338. package/docs/ENVIRONMENT_QUALITY.md +155 -0
  339. package/docs/ERROR_CODES.md +528 -0
  340. package/docs/EVENT_SCHEMA.md +659 -0
  341. package/docs/EXE-012-investigation-summary.md +300 -0
  342. package/docs/GATE_ATTESTATION_GUIDE.md +237 -0
  343. package/docs/JSON_OUTPUT_SCHEMAS.md +347 -0
  344. package/docs/LEXRUNNER_ALIASING.md +444 -0
  345. package/docs/LEX_INTEGRATION.md +83 -0
  346. package/docs/LEX_PUBLIC_API.md +306 -0
  347. package/docs/LICENSING.md +119 -0
  348. package/docs/MCP-CLI-PARITY.md +410 -0
  349. package/docs/MCP-MIGRATION.md +258 -0
  350. package/docs/MCP-PARITY.md +234 -0
  351. package/docs/MEMORY_TOOLS.md +278 -0
  352. package/docs/MERGE_WEAVE_SETUP.md +643 -0
  353. package/docs/MIGRATION_v0.1.md +760 -0
  354. package/docs/NAMING_CONVENTIONS.md +82 -0
  355. package/docs/PERSONA_FOUNDATION.md +124 -0
  356. package/docs/PHASE3_MEMORY_GUIDE.md +122 -0
  357. package/docs/PLAN_LOCK.md +114 -0
  358. package/docs/README.md +289 -0
  359. package/docs/RUNNER_LIFECYCLE.md +257 -0
  360. package/docs/SAFETY_MECHANISMS.md +325 -0
  361. package/docs/SECURITY_IMPLEMENTATION.md +535 -0
  362. package/docs/TERMS.md +34 -0
  363. package/docs/TOKEN_TRACKING.md +162 -0
  364. package/docs/WORKFLOW_GUIDANCE.md +277 -0
  365. package/docs/adr/ADR-000-product-naming-and-branding.md +115 -0
  366. package/docs/adr/ADR-001-plan-json-frozen-input.md +68 -0
  367. package/docs/adr/ADR-002-two-track-separation.md +84 -0
  368. package/docs/adr/ADR-003-gate-uniform-execution.md +69 -0
  369. package/docs/adr/ADR-004-runner-state-model.md +75 -0
  370. package/docs/adr/ADR-005-merge-pyramid-ordering.md +87 -0
  371. package/docs/adr/ADR-006-schema-versioning-semver.md +81 -0
  372. package/docs/adr/ADR-007-task-snapshot-contract.md +503 -0
  373. package/docs/adr/ADR-008-lex-packaging.md +243 -0
  374. package/docs/adr/ADR-009-ax-test-output-adapters.md +440 -0
  375. package/docs/adr/README.md +32 -0
  376. package/docs/advanced-cli.md +436 -0
  377. package/docs/agent-stall-detection.md +278 -0
  378. package/docs/architecture/executors.md +190 -0
  379. package/docs/architecture.md +316 -0
  380. package/docs/attestation/AX-SHARED-PLEDGE.md +83 -0
  381. package/docs/attestation/AX-SHARED-PLEDGE_v1.0.0.md +99 -0
  382. package/docs/attestation/AX-SHARED-PLEDGE_v1.0.0_VERIFICATION.md +115 -0
  383. package/docs/attestation/Lex_Guff_Version_Contract_Pact_v1.0.0.md +181 -0
  384. package/docs/attestation/README.md +87 -0
  385. package/docs/attestation/ax_pledge_2025-12-02.ots +0 -0
  386. package/docs/attestation/ax_pledge_timestamp_response.tsr +0 -0
  387. package/docs/attestation/copilot_summarization_2025-12-01.ots +0 -0
  388. package/docs/attestation/copilot_summarization_2025-12-01_VERIFICATION.md +100 -0
  389. package/docs/attestation/copilot_summarization_behavior_observation_2025-12-01.md +85 -0
  390. package/docs/attestation/copilot_summarization_screenshot_2025-12-01.png +0 -0
  391. package/docs/attestation/employment_separation_2025-11-26.ots +0 -0
  392. package/docs/attestation/employment_timestamp_response.tsr +0 -0
  393. package/docs/attestation/freetsa_cacert.pem +45 -0
  394. package/docs/attestation/freetsa_tsa.crt +45 -0
  395. package/docs/attestation/lex_employment_separation_2025-11-26.md +85 -0
  396. package/docs/attestation/lex_employment_separation_2025-11-26_VERIFICATION.md +126 -0
  397. package/docs/attestation/patent/2025-12-07-shadow-governance-pct-draft.md +350 -0
  398. package/docs/attestation/patent/2025-12-07-shadow-governance-pct-draft.md.ots +0 -0
  399. package/docs/attestation/patent/2025-12-07-shadow-governance-pct-draft_VERIFICATION.md +130 -0
  400. package/docs/attestation/patent/README.md +75 -0
  401. package/docs/attestation/patent/fig1_write_path.svg +58 -0
  402. package/docs/attestation/patent/fig2_read_normalize_rollup.svg +92 -0
  403. package/docs/attestation/timestamp_response.tsr +0 -0
  404. package/docs/attribution-README.md +264 -0
  405. package/docs/audit-compliance.md +283 -0
  406. package/docs/audit-outputs.md +1213 -0
  407. package/docs/audit-sdk.md +1134 -0
  408. package/docs/autopilot-levels.md +368 -0
  409. package/docs/autopilot.md +288 -0
  410. package/docs/ci-cd-integration.md +580 -0
  411. package/docs/ci-integration-guide.md +369 -0
  412. package/docs/ci-version-validation.md +198 -0
  413. package/docs/cli-mcp-weave-reporting.md +462 -0
  414. package/docs/cli.md +2262 -0
  415. package/docs/cluster-gates-rollback.md +222 -0
  416. package/docs/command-creation-guide.md +485 -0
  417. package/docs/command-whitelist.md +490 -0
  418. package/docs/commands/idea.md +253 -0
  419. package/docs/config.md +245 -0
  420. package/docs/conflict-clustering.md +225 -0
  421. package/docs/conflict-predictor.md +359 -0
  422. package/docs/context-diet.md +249 -0
  423. package/docs/counter-examples.md +199 -0
  424. package/docs/create-project.md +211 -0
  425. package/docs/deliverables-generator.md +299 -0
  426. package/docs/deliverables-management.md +474 -0
  427. package/docs/dependency-parser.md +354 -0
  428. package/docs/determinism.md +299 -0
  429. package/docs/diffgraph-planner.md +1211 -0
  430. package/docs/dogfood/README.md +33 -0
  431. package/docs/dogfood/wave-3-results.md +303 -0
  432. package/docs/dogfood-merge-weave-script.md +224 -0
  433. package/docs/enterprise-onboarding.md +291 -0
  434. package/docs/environment-variables.md +625 -0
  435. package/docs/error-recovery.md +466 -0
  436. package/docs/errors.md +288 -0
  437. package/docs/executor-authoring.md +854 -0
  438. package/docs/executor-decoupling.md +410 -0
  439. package/docs/front-end-capture-pipeline.md +312 -0
  440. package/docs/gate-report-examples.md +380 -0
  441. package/docs/gates.md +319 -0
  442. package/docs/github-automation.md +128 -0
  443. package/docs/governance-metrics.md +368 -0
  444. package/docs/integrations/README.md +588 -0
  445. package/docs/interactive-plan-review.md +493 -0
  446. package/docs/issue-orchestration.md +256 -0
  447. package/docs/lex_ax_session_key_rememberings_v0.1.md +195 -0
  448. package/docs/lexrunner-v1-summary.md +246 -0
  449. package/docs/lexrunner-v2-contract.md +404 -0
  450. package/docs/lexrunner-v2-migration-plan.md +388 -0
  451. package/docs/lexrunner-v2-salvage-map.md +355 -0
  452. package/docs/lexsona-rules.md +154 -0
  453. package/docs/merge-weave-analysis.md +403 -0
  454. package/docs/merge-weave-quickstart.md +770 -0
  455. package/docs/merge-weave-state-machine.md +390 -0
  456. package/docs/migration-guide.md +529 -0
  457. package/docs/monitoring-examples.md +470 -0
  458. package/docs/monitoring-implementation.md +252 -0
  459. package/docs/orchestration.md +234 -0
  460. package/docs/performance-scale.md +359 -0
  461. package/docs/plan-generation.md +407 -0
  462. package/docs/profile-resolution.md +455 -0
  463. package/docs/prompts.md +427 -0
  464. package/docs/quickstart.md +546 -0
  465. package/docs/release-process.md +310 -0
  466. package/docs/sample-prompts/merge-weave/cli-merge-weave-kickoff.md +274 -0
  467. package/docs/sample-prompts/merge-weave/mcp-merge-weave-kickoff.md +480 -0
  468. package/docs/sample-prompts/merge-weave/standalone-merge-weave-kickoff.md +237 -0
  469. package/docs/schemas.md +359 -0
  470. package/docs/scope-validation.md +444 -0
  471. package/docs/security/rotation-guide.md +325 -0
  472. package/docs/specs/Meeting_Control_Stack_Concept_v0.1.0.md +417 -0
  473. package/docs/specs/git-feature-flag-redesign.md +321 -0
  474. package/docs/specs/lex-pr-brief-behavior.md +269 -0
  475. package/docs/specs/smartergpt-structure-v1.md +705 -0
  476. package/docs/specs/task-brief-v0.1.md +224 -0
  477. package/docs/store-architecture.md +61 -0
  478. package/docs/templates/CONTRIBUTING-merge-weave-section.md +33 -0
  479. package/docs/templates/gates.example.yml +109 -0
  480. package/docs/templates/plan.example.json +77 -0
  481. package/docs/thesis/00-EVOLUTION-NOTES.md +383 -0
  482. package/docs/thesis/01-CORE-THESIS.md +285 -0
  483. package/docs/thesis/02-TURN-COST.md +498 -0
  484. package/docs/thesis/03-PERMISSION-TO-FAIL.md +581 -0
  485. package/docs/thesis/04-CROSS-MODEL-CONTINUITY.md +517 -0
  486. package/docs/thesis/05-RULE-FILE-SPEC.md +732 -0
  487. package/docs/thesis/06-CAPABILITY-TIERS.md +723 -0
  488. package/docs/thesis/07-ROBERT-FIELD-REPORT.md +433 -0
  489. package/docs/thesis/08-IMPLEMENTATION-GUIDE.md +1093 -0
  490. package/docs/thesis/09-METRICS-AND-TELEMETRY.md +793 -0
  491. package/docs/thesis/10-FAILURE-MODES.md +716 -0
  492. package/docs/thesis/README.md +151 -0
  493. package/docs/thesis/lex_governance-collab_systems_paper_draft.md +952 -0
  494. package/docs/thesis/lex_governance-collab_systems_paper_draft.pdf +0 -0
  495. package/docs/tool-grounded/READINESS_ANALYSIS.md +527 -0
  496. package/docs/tool-grounded/enforcement.md +361 -0
  497. package/docs/tool-grounded/tool-grounded-a-view-from-the-inside.md +437 -0
  498. package/docs/tool-grounded/tool-grounded-prompt.md +122 -0
  499. package/docs/tool-grounded/tool-grounded-run-centric.md +474 -0
  500. package/docs/troubleshooting-planner.md +910 -0
  501. package/docs/troubleshooting.md +745 -0
  502. package/docs/tutorials/README.md +201 -0
  503. package/docs/tutorials/diffgraph-planner/01-simple-stack.md +460 -0
  504. package/docs/tutorials/diffgraph-planner/02-diamond-pattern.md +431 -0
  505. package/docs/tutorials/diffgraph-planner/03-large-batch.md +525 -0
  506. package/docs/tutorials/diffgraph-planner/04-fixing-cycles.md +526 -0
  507. package/docs/tutorials/diffgraph-planner/05-hybrid-workflow.md +555 -0
  508. package/docs/tutorials/quick-merge-pyramid.md +364 -0
  509. package/docs/tutorials/video-scripts/01-getting-started.md +286 -0
  510. package/docs/tutorials/video-scripts/02-understanding-dependencies.md +376 -0
  511. package/docs/weave-contract.md +116 -0
  512. package/docs/weave-execution-log.md +153 -0
  513. package/docs/workflows/README.md +139 -0
  514. package/docs/workflows/enterprise.md +545 -0
  515. package/docs/workflows/small-team.md +398 -0
  516. package/docs/workflows/solo-developer.md +419 -0
  517. package/dogfood-merge-weave.sh +122 -0
  518. package/examples/README.md +22 -0
  519. package/examples/WORKING_EXAMPLE.md +309 -0
  520. package/examples/analyze-pr-files.js +100 -0
  521. package/examples/autopilot-level4-example.md +234 -0
  522. package/examples/cluster-gates-demo.sh +178 -0
  523. package/examples/complete-security-workflow.ts +248 -0
  524. package/examples/error-recovery/README.md +202 -0
  525. package/examples/executor-manifest.example.yaml +81 -0
  526. package/examples/front-end-capture-pipeline/README.md +99 -0
  527. package/examples/front-end-capture-pipeline/create-project-example.sh +83 -0
  528. package/examples/front-end-capture-pipeline/idea-dark-mode.json +14 -0
  529. package/examples/front-end-capture-pipeline/idea-example.sh +57 -0
  530. package/examples/front-end-capture-pipeline/manual-test-checklist.md +426 -0
  531. package/examples/gates/README.md +165 -0
  532. package/examples/gates/lint-gate.sh +40 -0
  533. package/examples/gates/lint-gate.ts +99 -0
  534. package/examples/gates/test-runner.ts +113 -0
  535. package/examples/gates/vuln-scanner.ts +95 -0
  536. package/examples/github-integration/README.md +111 -0
  537. package/examples/github-integration/example-plan.json +95 -0
  538. package/examples/performance-config.md +388 -0
  539. package/examples/profile-setup/.gitignore.template +66 -0
  540. package/examples/profile-setup/.smartergpt-example/README.md +190 -0
  541. package/examples/profile-setup/.smartergpt.local-example/README.md +365 -0
  542. package/examples/profile-setup/README.md +492 -0
  543. package/examples/profile-setup/cross-repo-prompts/README.md +606 -0
  544. package/examples/safety-framework-demo.ts +130 -0
  545. package/examples/safety-mechanisms-example.ts +191 -0
  546. package/examples/sample-plan.json +87 -0
  547. package/examples/sample-stack.yml +66 -0
  548. package/examples/sarif/README.md +224 -0
  549. package/examples/scope-validation-demo.ts +199 -0
  550. package/examples/security-integration.ts +293 -0
  551. package/examples/token-tracking-example.ts +71 -0
  552. package/executors/senior-dev/ARCHITECTURE.md +182 -0
  553. package/executors/senior-dev/MEMORY_INTEGRATION.md +236 -0
  554. package/executors/senior-dev/QUICK_START.md +145 -0
  555. package/executors/senior-dev/README.md +76 -0
  556. package/executors/senior-dev/examples/sample-review-session.md +228 -0
  557. package/executors/senior-dev/executor-manifest.yaml +79 -0
  558. package/executors/senior-dev/prompts/code-review.prompt.md +78 -0
  559. package/executors/senior-dev/prompts/mentorship-feedback.prompt.md +97 -0
  560. package/executors/senior-dev/prompts/pattern-recognition.prompt.md +80 -0
  561. package/executors/senior-dev/prompts/pr-analysis.prompt.md +75 -0
  562. package/executors/senior-dev/scripts/capture-review-frame.sh +129 -0
  563. package/executors/senior-dev/scripts/prepare-review-context.sh +61 -0
  564. package/executors/senior-dev/scripts/recall-context.sh +87 -0
  565. package/lexrunner-launcher.sh +12 -0
  566. package/mcp-config-example.json +14 -0
  567. package/mcp-server.mjs +1221 -0
  568. package/merge-weave-current-prs.md +170 -0
  569. package/merge-weave-dogfood.json +46 -0
  570. package/merge-weave-plan.json +56 -0
  571. package/package.json +140 -0
  572. package/procedures/merge-weave-main.yaml +90 -0
  573. package/procedures/pr-review.yaml +68 -0
  574. package/project/README.md +50 -0
  575. package/prompts/tool-grounded-mode.md +185 -0
  576. package/schemas/allowed-commands.schema.json +108 -0
  577. package/schemas/audit-events.schema.json +138 -0
  578. package/schemas/audit-events.v1.0.0.schema.json +138 -0
  579. package/schemas/edit-plan.schema.json +80 -0
  580. package/schemas/executor-manifest.schema.json +236 -0
  581. package/schemas/flake-report.schema.json +95 -0
  582. package/schemas/gate-report.schema.json +85 -0
  583. package/schemas/gates/build.schema.json +32 -0
  584. package/schemas/gates/coverage.schema.json +42 -0
  585. package/schemas/gates/lint.schema.json +34 -0
  586. package/schemas/gates/security-scan.schema.json +33 -0
  587. package/schemas/gates/test.schema.json +35 -0
  588. package/schemas/next-option.schema.json +60 -0
  589. package/schemas/persona-snapshot.schema.json +66 -0
  590. package/schemas/plan.schema.json +300 -0
  591. package/schemas/status-response.schema.json +193 -0
  592. package/scripts/README.md +354 -0
  593. package/scripts/analyze-governance-logs.mjs +51 -0
  594. package/scripts/benchmark-ci.ts +339 -0
  595. package/scripts/check-determinism.sh +23 -0
  596. package/scripts/check-license-compliance.mjs +319 -0
  597. package/scripts/check-release-drift.mjs +81 -0
  598. package/scripts/ci-debug.sh +24 -0
  599. package/scripts/ci-smoke.mjs +304 -0
  600. package/scripts/create-sample-repo.sh +245 -0
  601. package/scripts/dogfood-merge-weave.sh +552 -0
  602. package/scripts/gen_mcp_servers.py +252 -0
  603. package/scripts/generate-executor-manifest-schema.ts +30 -0
  604. package/scripts/generate-flake-schema.ts +32 -0
  605. package/scripts/generate-gate-schema.ts +32 -0
  606. package/scripts/generate-plan-schema.ts +30 -0
  607. package/scripts/generate-run-schemas.ts +69 -0
  608. package/scripts/load-prompt.mjs +147 -0
  609. package/scripts/merge-weave-wrapper.sh +445 -0
  610. package/scripts/merge-weave.sh +489 -0
  611. package/scripts/metrics-template.ts +134 -0
  612. package/scripts/package-lex.sh +267 -0
  613. package/scripts/quick-start-merge-weave.sh +218 -0
  614. package/scripts/release-prepare.ts +350 -0
  615. package/scripts/rotate-secrets-example.ts +134 -0
  616. package/scripts/test-lexsona-shadow.mjs +100 -0
  617. package/scripts/validate-manifests.ts +188 -0
  618. package/scripts/verify-audit-phase2.js +175 -0
  619. package/src/ai/README.md +456 -0
  620. package/src/ai/conflictStrategy.ts +223 -0
  621. package/src/ai/conflictStrategyCache.ts +164 -0
  622. package/src/ai/conflictStrategyPrompt.ts +128 -0
  623. package/src/ai/conflictStrategySchema.ts +165 -0
  624. package/src/ai/heuristicFallback.ts +162 -0
  625. package/src/ai/index.ts +64 -0
  626. package/src/ai/riskScoring.ts +174 -0
  627. package/src/aliases/index.ts +16 -0
  628. package/src/aliases/resolver.ts +212 -0
  629. package/src/audit/context.ts +284 -0
  630. package/src/audit/emitter.ts +685 -0
  631. package/src/audit/events.ts +210 -0
  632. package/src/audit/gateMatrix.ts +158 -0
  633. package/src/audit/index.ts +44 -0
  634. package/src/audit/manifest.ts +78 -0
  635. package/src/audit/profiles.ts +93 -0
  636. package/src/audit/redaction.ts +216 -0
  637. package/src/audit/sarif.ts +213 -0
  638. package/src/audit/schema/events.ts +366 -0
  639. package/src/audit/schema/manifest.ts +47 -0
  640. package/src/audit/schema.ts +159 -0
  641. package/src/audit/sdk/index.ts +145 -0
  642. package/src/audit/sdk/types.ts +88 -0
  643. package/src/audit/sidecar.ts +111 -0
  644. package/src/audit/signing.ts +521 -0
  645. package/src/autopilot/README.md +113 -0
  646. package/src/autopilot/artifacts.ts +287 -0
  647. package/src/autopilot/base.ts +132 -0
  648. package/src/autopilot/deliverables.ts +392 -0
  649. package/src/autopilot/index.ts +29 -0
  650. package/src/autopilot/level1.ts +187 -0
  651. package/src/autopilot/level2.ts +262 -0
  652. package/src/autopilot/level3.ts +263 -0
  653. package/src/autopilot/level4.ts +393 -0
  654. package/src/autopilot/safety/README.md +512 -0
  655. package/src/autopilot/safety/SafetyFramework.ts +634 -0
  656. package/src/autopilot/safety/index.ts +16 -0
  657. package/src/autopilot/types.ts +250 -0
  658. package/src/budget/index.ts +56 -0
  659. package/src/budget/manager.ts +547 -0
  660. package/src/budget/schema.ts +305 -0
  661. package/src/budget/tracker.ts +155 -0
  662. package/src/cache/issue-cache.ts +150 -0
  663. package/src/cli/command-map.ts +221 -0
  664. package/src/cli/commands/gate/test.ts +214 -0
  665. package/src/cli/exitHandler.ts +98 -0
  666. package/src/cli/flags.ts +123 -0
  667. package/src/cli/formatSuggestions.ts +202 -0
  668. package/src/cli/formatters.ts +294 -0
  669. package/src/cli/jsonEnvelope.ts +152 -0
  670. package/src/cli/output.ts +61 -0
  671. package/src/cli/runnerLifecycle.ts +118 -0
  672. package/src/cli-audit.ts +76 -0
  673. package/src/cli-security.ts +114 -0
  674. package/src/cli.ts +1231 -0
  675. package/src/commands/audit/index.ts +5 -0
  676. package/src/commands/audit/verify.ts +87 -0
  677. package/src/commands/autopilot.ts +131 -0
  678. package/src/commands/budget.ts +327 -0
  679. package/src/commands/bulkOps.ts +204 -0
  680. package/src/commands/completion.ts +287 -0
  681. package/src/commands/config/validate.ts +428 -0
  682. package/src/commands/config.ts +368 -0
  683. package/src/commands/counterExamples.ts +104 -0
  684. package/src/commands/create-project.ts +338 -0
  685. package/src/commands/discover.ts +192 -0
  686. package/src/commands/doctor.ts +436 -0
  687. package/src/commands/execute.ts +558 -0
  688. package/src/commands/explain.ts +157 -0
  689. package/src/commands/fanout-analyze.ts +684 -0
  690. package/src/commands/fanout-harvest.ts +328 -0
  691. package/src/commands/fanout-monitor.ts +224 -0
  692. package/src/commands/gateAttest.ts +95 -0
  693. package/src/commands/gateImport.ts +142 -0
  694. package/src/commands/gateImportChecks.ts +208 -0
  695. package/src/commands/gateReport.ts +184 -0
  696. package/src/commands/governanceCleanup.ts +171 -0
  697. package/src/commands/governanceReport.ts +497 -0
  698. package/src/commands/guards.ts +50 -0
  699. package/src/commands/idea.ts +281 -0
  700. package/src/commands/init.ts +414 -0
  701. package/src/commands/issues.ts +165 -0
  702. package/src/commands/merge.ts +677 -0
  703. package/src/commands/mergeOrder.ts +68 -0
  704. package/src/commands/metrics.ts +232 -0
  705. package/src/commands/migrateProfile.ts +187 -0
  706. package/src/commands/orchestrate/analyze-issues.ts +203 -0
  707. package/src/commands/orchestrate/assign-batch.ts +204 -0
  708. package/src/commands/orchestrate/generate-deliverables.ts +66 -0
  709. package/src/commands/orchestrate/pinToolchain.ts +102 -0
  710. package/src/commands/orchestrate/plan-batch.ts +119 -0
  711. package/src/commands/orchestrate/predict-conflicts.ts +210 -0
  712. package/src/commands/orchestrate.ts +186 -0
  713. package/src/commands/plan.ts +403 -0
  714. package/src/commands/planDiff.ts +56 -0
  715. package/src/commands/planReview.ts +112 -0
  716. package/src/commands/planViewer.ts +180 -0
  717. package/src/commands/preview-constraints.ts +97 -0
  718. package/src/commands/query.ts +313 -0
  719. package/src/commands/report.ts +56 -0
  720. package/src/commands/retry.ts +60 -0
  721. package/src/commands/schema.ts +128 -0
  722. package/src/commands/security.ts +140 -0
  723. package/src/commands/seniorDev.ts +326 -0
  724. package/src/commands/status.ts +97 -0
  725. package/src/commands/tokenReport.ts +167 -0
  726. package/src/commands/validation.ts +66 -0
  727. package/src/commands/weave-checkpoints.ts +145 -0
  728. package/src/commands/weave-fanout.ts +273 -0
  729. package/src/commands/weave-policy.ts +277 -0
  730. package/src/commands/weave.ts +518 -0
  731. package/src/config/localOverlay.ts +167 -0
  732. package/src/config/pathResolver.ts +106 -0
  733. package/src/config/profileResolver.ts +194 -0
  734. package/src/config/promptsResolver.ts +312 -0
  735. package/src/config/rulesResolver.ts +257 -0
  736. package/src/config/schemas.ts +142 -0
  737. package/src/core/bootstrap.ts +287 -0
  738. package/src/core/enterprise.ts +453 -0
  739. package/src/core/errorRecovery.ts +509 -0
  740. package/src/core/githubPlan.ts +282 -0
  741. package/src/core/inputs.ts +314 -0
  742. package/src/core/multiRepoPlan.ts +353 -0
  743. package/src/core/plan.ts +106 -0
  744. package/src/core/snapshot.ts +189 -0
  745. package/src/errors/adapters.ts +897 -0
  746. package/src/errors/index.ts +231 -0
  747. package/src/executionState.ts +356 -0
  748. package/src/executors/README_FRAME_CONTRACT.md +446 -0
  749. package/src/executors/frameContract.ts +270 -0
  750. package/src/executors/guardrailEnforcement.ts +294 -0
  751. package/src/executors/seniorDev/core.ts +548 -0
  752. package/src/executors/seniorDev/index.ts +30 -0
  753. package/src/executors/seniorDev/types.ts +176 -0
  754. package/src/executors/toolBudget.ts +194 -0
  755. package/src/fanout/analyzer.ts +735 -0
  756. package/src/fanout/github-adapter.ts +262 -0
  757. package/src/fanout/harvest.ts +517 -0
  758. package/src/fanout/monitor.ts +350 -0
  759. package/src/fanout/types.ts +428 -0
  760. package/src/frames/controller.ts +160 -0
  761. package/src/frames/emitter.ts +455 -0
  762. package/src/frames/index.ts +58 -0
  763. package/src/frames/storage.ts +203 -0
  764. package/src/frames/types.ts +258 -0
  765. package/src/gates/checkRunConverter.ts +91 -0
  766. package/src/gates/test/adapters/errors.ts +32 -0
  767. package/src/gates/test/adapters/index.ts +36 -0
  768. package/src/gates/test/adapters/interface.ts +63 -0
  769. package/src/gates/test/adapters/jest-json.ts +370 -0
  770. package/src/gates/test/adapters/junit-xml.ts +400 -0
  771. package/src/gates/test/adapters/registry.ts +149 -0
  772. package/src/gates/test/adapters/vitest-json.ts +339 -0
  773. package/src/gates/test/enrichment/failureId.ts +74 -0
  774. package/src/gates/test/enrichment/index.ts +25 -0
  775. package/src/gates/test/enrichment/nextActions.ts +322 -0
  776. package/src/gates/test/enrichment/rerunTemplates.ts +105 -0
  777. package/src/gates/test/enrichment/signature.ts +58 -0
  778. package/src/gates/test/enrichment/stackParser.ts +149 -0
  779. package/src/gates/test/enrichment/types.ts +67 -0
  780. package/src/gates/test/formatters/markdown.spec.ts +942 -0
  781. package/src/gates/test/formatters/markdown.ts +296 -0
  782. package/src/gates/test/index.ts +54 -0
  783. package/src/gates/test/schema.spec.ts +372 -0
  784. package/src/gates/test/schema.ts +327 -0
  785. package/src/gates/validator.ts +92 -0
  786. package/src/gates.ts +1022 -0
  787. package/src/git/operations.ts +592 -0
  788. package/src/git/parseRemote.ts +22 -0
  789. package/src/github/api.ts +584 -0
  790. package/src/github/batch-ops.ts +215 -0
  791. package/src/github/client.ts +647 -0
  792. package/src/github/contextDiet.ts +205 -0
  793. package/src/github/diffHunks.ts +285 -0
  794. package/src/github/index.ts +11 -0
  795. package/src/github/minimalContext.ts +212 -0
  796. package/src/github/minimalContextClient.ts +105 -0
  797. package/src/github/symbolMap.ts +370 -0
  798. package/src/github/types.ts +166 -0
  799. package/src/governance/index.ts +42 -0
  800. package/src/governance/mcpStatus.ts +258 -0
  801. package/src/governance/timeoutAdjustment.ts +149 -0
  802. package/src/governance/turnCostSummary.ts +182 -0
  803. package/src/hooks/events.ts +374 -0
  804. package/src/hooks/index.ts +8 -0
  805. package/src/hostility/checks.ts +408 -0
  806. package/src/hostility/index.ts +108 -0
  807. package/src/hostility/score.ts +143 -0
  808. package/src/interactive/planDiff.ts +168 -0
  809. package/src/interactive/planHistory.ts +205 -0
  810. package/src/interactive/planReview.ts +531 -0
  811. package/src/learning/counter-example.ts +174 -0
  812. package/src/learning/prompts.ts +107 -0
  813. package/src/learning/storage.ts +230 -0
  814. package/src/lexsona/client.ts +367 -0
  815. package/src/lexsona/index.ts +44 -0
  816. package/src/lexsona/logger.ts +408 -0
  817. package/src/lexsona/types.ts +177 -0
  818. package/src/mcp/DEPRECATED.md +33 -0
  819. package/src/mcp/server.ts +3587 -0
  820. package/src/mcp/types/guided-response.ts +95 -0
  821. package/src/mcp/types.ts +468 -0
  822. package/src/mcp/workflow/state-machine.ts +277 -0
  823. package/src/mergeEligibility.ts +355 -0
  824. package/src/mergeOrder.ts +170 -0
  825. package/src/metrics/export.ts +472 -0
  826. package/src/metrics/index.ts +35 -0
  827. package/src/metrics/turncost.ts +284 -0
  828. package/src/monitoring/README.md +222 -0
  829. package/src/monitoring/audit.ts +98 -0
  830. package/src/monitoring/cache.ts +121 -0
  831. package/src/monitoring/dashboards/grafana-dashboard.json +172 -0
  832. package/src/monitoring/errorRecovery.ts +334 -0
  833. package/src/monitoring/errors.ts +105 -0
  834. package/src/monitoring/fileLogger.ts +194 -0
  835. package/src/monitoring/hallucinations.ts +45 -0
  836. package/src/monitoring/health.ts +171 -0
  837. package/src/monitoring/index.ts +16 -0
  838. package/src/monitoring/lock.ts +158 -0
  839. package/src/monitoring/logger.ts +178 -0
  840. package/src/monitoring/metrics.ts +245 -0
  841. package/src/monitoring/profiler.ts +156 -0
  842. package/src/monitoring/tokenLogger.ts +141 -0
  843. package/src/orchestrate/analyzer.ts +461 -0
  844. package/src/orchestrate/index.ts +6 -0
  845. package/src/orchestrate/types.ts +65 -0
  846. package/src/orchestration/README.md +480 -0
  847. package/src/orchestration/agentAssigner.ts +206 -0
  848. package/src/orchestration/batchPlanner.ts +201 -0
  849. package/src/orchestration/conflictClustering.ts +344 -0
  850. package/src/orchestration/conflictGraph.ts +63 -0
  851. package/src/orchestration/conflictPredictor.ts +170 -0
  852. package/src/orchestration/deliverablesGenerator.ts +345 -0
  853. package/src/orchestration/determinism.ts +232 -0
  854. package/src/orchestration/index.ts +45 -0
  855. package/src/orchestration/mergeTreeSimulator.ts +137 -0
  856. package/src/orchestration/mis.ts +123 -0
  857. package/src/orchestration/toolchainManifest.ts +169 -0
  858. package/src/orchestration/types.ts +103 -0
  859. package/src/performance.README.md +99 -0
  860. package/src/performance.ts +279 -0
  861. package/src/planner/README.md +215 -0
  862. package/src/planner/dependencyParser.ts +404 -0
  863. package/src/planner/dependencyScoring.ts +346 -0
  864. package/src/planner/fileAnalysis.ts +693 -0
  865. package/src/planner/index.ts +41 -0
  866. package/src/planner/scopeValidator.ts +308 -0
  867. package/src/planner/types.ts +80 -0
  868. package/src/planner/validation.ts +493 -0
  869. package/src/preview/constraints.ts +333 -0
  870. package/src/procedures/index.ts +47 -0
  871. package/src/procedures/loader.ts +252 -0
  872. package/src/procedures/schema.ts +191 -0
  873. package/src/procedures/stateMachine.ts +160 -0
  874. package/src/procedures/types.ts +178 -0
  875. package/src/receipts/emit.ts +354 -0
  876. package/src/receipts/index.ts +48 -0
  877. package/src/receipts/schema.ts +227 -0
  878. package/src/report/aggregate.ts +160 -0
  879. package/src/runs/artifacts.ts +315 -0
  880. package/src/runs/attribution.ts +132 -0
  881. package/src/runs/context.ts +54 -0
  882. package/src/runs/decisions.ts +407 -0
  883. package/src/runs/enforcement.ts +395 -0
  884. package/src/runs/failures.ts +517 -0
  885. package/src/runs/index.ts +141 -0
  886. package/src/runs/manager.ts +910 -0
  887. package/src/runs/statusBuilder.ts +233 -0
  888. package/src/runs/storage.ts +290 -0
  889. package/src/runs/types.ts +216 -0
  890. package/src/schema/flakeReport.ts +74 -0
  891. package/src/schema/gateMapping.ts +107 -0
  892. package/src/schema/gateReport.ts +236 -0
  893. package/src/schema/weaveLock.ts +51 -0
  894. package/src/schema.ts +313 -0
  895. package/src/schemas/executorManifest.ts +204 -0
  896. package/src/schemas/feature-spec-v0.ts +40 -0
  897. package/src/schemas/persona.ts +162 -0
  898. package/src/schemas/project.ts +91 -0
  899. package/src/schemas/runCentric.ts +402 -0
  900. package/src/schemas/task-contract.ts +626 -0
  901. package/src/schemas/vacuumReadyPrompt.ts +128 -0
  902. package/src/sdk/index.ts +113 -0
  903. package/src/sdk/parser.ts +101 -0
  904. package/src/sdk/query.ts +315 -0
  905. package/src/sdk/validator.ts +114 -0
  906. package/src/security/README.md +496 -0
  907. package/src/security/authentication.ts +173 -0
  908. package/src/security/authorization.ts +348 -0
  909. package/src/security/commandValidator.ts +195 -0
  910. package/src/security/compliance.ts +688 -0
  911. package/src/security/index.ts +85 -0
  912. package/src/security/policy.ts +399 -0
  913. package/src/security/sarif.ts +179 -0
  914. package/src/security/scanning.ts +362 -0
  915. package/src/security/secrets.ts +520 -0
  916. package/src/shared/git/index.ts +30 -0
  917. package/src/shared/git/runGit.ts +281 -0
  918. package/src/shared/git/runtime.ts +66 -0
  919. package/src/snapshot/builder.ts +229 -0
  920. package/src/snapshot/index.ts +8 -0
  921. package/src/store/CONTRACT.md +189 -0
  922. package/src/store/README.md +22 -0
  923. package/src/store/index.ts +99 -0
  924. package/src/store/inmemory/index.ts +10 -0
  925. package/src/store/inmemory/run-store.ts +268 -0
  926. package/src/store/postgres/.gitkeep +0 -0
  927. package/src/store/run-store.ts +405 -0
  928. package/src/store/sqlite/index.ts +7 -0
  929. package/src/store/sqlite/run-store.ts +525 -0
  930. package/src/store/sqlite/schema.sql +67 -0
  931. package/src/telemetry/frames.ts +179 -0
  932. package/src/telemetry/index.ts +5 -0
  933. package/src/tiers/index.ts +34 -0
  934. package/src/tiers/metrics.ts +156 -0
  935. package/src/tiers/schema.ts +95 -0
  936. package/src/tiers/suggest.ts +183 -0
  937. package/src/types/guardrails.ts +452 -0
  938. package/src/types/index.ts +42 -0
  939. package/src/util/canonicalJson.ts +29 -0
  940. package/src/util/colorControl.ts +46 -0
  941. package/src/util/envUtils.ts +139 -0
  942. package/src/util/hash.ts +69 -0
  943. package/src/util/lockHash.ts +90 -0
  944. package/src/util/minHeap.ts +108 -0
  945. package/src/util/progress.ts +89 -0
  946. package/src/util/tokenEstimator.ts +55 -0
  947. package/src/utils/fingerprint.ts +105 -0
  948. package/src/utils/paths.ts +209 -0
  949. package/src/utils/tokens.ts +151 -0
  950. package/src/utils/validation.ts +53 -0
  951. package/src/verification/diff-applier.ts +60 -0
  952. package/src/verification/engine-verifier.ts +171 -0
  953. package/src/verification/errors.ts +30 -0
  954. package/src/verification/index.ts +13 -0
  955. package/src/weave/audit/index.ts +17 -0
  956. package/src/weave/audit/logger.ts +206 -0
  957. package/src/weave/authority/evaluator.ts +660 -0
  958. package/src/weave/authority/index.ts +30 -0
  959. package/src/weave/authority/schema.ts +292 -0
  960. package/src/weave/checkpoint/index.ts +7 -0
  961. package/src/weave/checkpoint/storage.ts +223 -0
  962. package/src/weave/checkpoint/types.ts +121 -0
  963. package/src/weave/checkpoint/utils.ts +207 -0
  964. package/src/weave/clusterGates.ts +366 -0
  965. package/src/weave/draftPR.ts +214 -0
  966. package/src/weave/executor/d1-executor.ts +822 -0
  967. package/src/weave/executor/d2-executor.ts +381 -0
  968. package/src/weave/executor/index.ts +24 -0
  969. package/src/weave/executor/types.ts +135 -0
  970. package/src/weave/fanout/generator.ts +186 -0
  971. package/src/weave/fanout/index.ts +51 -0
  972. package/src/weave/fanout/loader.ts +134 -0
  973. package/src/weave/fanout/matcher.ts +239 -0
  974. package/src/weave/fanout/schema.ts +178 -0
  975. package/src/weave/frameHelper.ts +126 -0
  976. package/src/weave/gateFailureHandler.ts +405 -0
  977. package/src/weave/index.ts +89 -0
  978. package/src/weave/lockFile.ts +193 -0
  979. package/src/weave/mergeHelpers.ts +377 -0
  980. package/src/weave/mergeWeaveSequential.ts +282 -0
  981. package/src/weave/metrics/calculator.ts +362 -0
  982. package/src/weave/metrics/index.ts +44 -0
  983. package/src/weave/metrics/logger.ts +291 -0
  984. package/src/weave/metrics/schema.ts +505 -0
  985. package/src/weave/planner/index.ts +23 -0
  986. package/src/weave/planner/planner.ts +411 -0
  987. package/src/weave/planner/types.ts +181 -0
  988. package/src/weave/policy/index.ts +63 -0
  989. package/src/weave/policy/loader.ts +148 -0
  990. package/src/weave/policy/schema.ts +290 -0
  991. package/src/weave/post-merge-checks.ts +220 -0
  992. package/src/weave/preflightConflicts.ts +375 -0
  993. package/src/weave/receiptHelper.ts +287 -0
  994. package/src/weave/recovery.ts +232 -0
  995. package/src/weave/resolutionGuidance.ts +173 -0
  996. package/src/weave/stateMachine.ts +426 -0
  997. package/src/weave/testfix/applier.ts +195 -0
  998. package/src/weave/testfix/index.ts +18 -0
  999. package/src/weave/testfix/loader.ts +116 -0
  1000. package/src/weave/testfix/matcher.ts +158 -0
  1001. package/src/weave/testfix/schema.ts +218 -0
  1002. package/src/weave/types.ts +305 -0
  1003. package/src/weave/utils/copilot-completion.ts +76 -0
  1004. package/test-mcp-dogfood.mjs +128 -0
  1005. package/test-mcp.mjs +116 -0
  1006. package/tests/README.md +155 -0
  1007. package/tests/advanced-cli-e2e.spec.ts +218 -0
  1008. package/tests/agentAssigner.spec.ts +261 -0
  1009. package/tests/ai-conflict-strategy-cache.spec.ts +254 -0
  1010. package/tests/ai-conflict-strategy-risk.spec.ts +287 -0
  1011. package/tests/ai-conflict-strategy-schema.spec.ts +252 -0
  1012. package/tests/ai-conflict-strategy.spec.ts +442 -0
  1013. package/tests/aliases/resolver.spec.ts +238 -0
  1014. package/tests/audit/context.spec.ts +283 -0
  1015. package/tests/audit/emitter.spec.ts +347 -0
  1016. package/tests/audit/gateMatrix.spec.ts +335 -0
  1017. package/tests/audit/integration.spec.ts +236 -0
  1018. package/tests/audit/redaction.spec.ts +290 -0
  1019. package/tests/audit/sarif-integration.spec.ts +303 -0
  1020. package/tests/audit/sarif.spec.ts +458 -0
  1021. package/tests/audit/schema-events.spec.ts +421 -0
  1022. package/tests/audit/schema.spec.ts +434 -0
  1023. package/tests/audit/sdk-integration.spec.ts +598 -0
  1024. package/tests/audit/sdk.spec.ts +318 -0
  1025. package/tests/audit/signing-integration.spec.ts +276 -0
  1026. package/tests/audit/signing.spec.ts +350 -0
  1027. package/tests/audit-signing.spec.ts +406 -0
  1028. package/tests/audit-verify-cli.spec.ts +176 -0
  1029. package/tests/autopilot-e2e-level3-4.spec.ts +741 -0
  1030. package/tests/autopilot-integration.spec.ts +274 -0
  1031. package/tests/autopilot-level1.spec.ts +449 -0
  1032. package/tests/autopilot-level2.spec.ts +188 -0
  1033. package/tests/autopilot-level3.spec.ts +266 -0
  1034. package/tests/autopilot-level4.spec.ts +454 -0
  1035. package/tests/autopilot.spec.ts +379 -0
  1036. package/tests/ax-error-adapters.spec.ts +580 -0
  1037. package/tests/batch-planner.spec.ts +500 -0
  1038. package/tests/benchmark-infrastructure.spec.ts +445 -0
  1039. package/tests/benchmarks/README.md +103 -0
  1040. package/tests/benchmarks/baselines/baseline.json +127 -0
  1041. package/tests/benchmarks/core/dependencyResolver.bench.ts +128 -0
  1042. package/tests/benchmarks/core/planParser.bench.ts +114 -0
  1043. package/tests/benchmarks/core/topologicalSort.bench.ts +102 -0
  1044. package/tests/benchmarks/index.ts +36 -0
  1045. package/tests/benchmarks/io/fileOperations.bench.ts +132 -0
  1046. package/tests/benchmarks/io/gitOperations.bench.ts +99 -0
  1047. package/tests/benchmarks/utils/graphGenerator.ts +201 -0
  1048. package/tests/benchmarks/utils/reporter.ts +231 -0
  1049. package/tests/benchmarks/workflows/endToEnd.bench.ts +132 -0
  1050. package/tests/bootstrap.test.ts +319 -0
  1051. package/tests/budget-tracker.spec.ts +279 -0
  1052. package/tests/bulkOps.spec.ts +166 -0
  1053. package/tests/bulletproof-determinism.test.ts +223 -0
  1054. package/tests/canonicalJson.test.ts +130 -0
  1055. package/tests/checkRunConverter.spec.ts +357 -0
  1056. package/tests/cli/commands/gate/test.spec.ts +564 -0
  1057. package/tests/cli/emit-frames-flag.spec.ts +117 -0
  1058. package/tests/cli/exitHandler.spec.ts +314 -0
  1059. package/tests/cli/flags.spec.ts +223 -0
  1060. package/tests/cli/formatters.spec.ts +513 -0
  1061. package/tests/cli/output.spec.ts +221 -0
  1062. package/tests/cli-autopilot.spec.ts +170 -0
  1063. package/tests/cli-budget-guards.spec.ts +210 -0
  1064. package/tests/cli-color-control.spec.ts +334 -0
  1065. package/tests/cli-deliverables-generator.spec.ts +185 -0
  1066. package/tests/cli-determinism.spec.ts +496 -0
  1067. package/tests/cli-init-enterprise.spec.ts +294 -0
  1068. package/tests/cli-init-json.spec.ts +154 -0
  1069. package/tests/cli-init-local.spec.ts +159 -0
  1070. package/tests/cli-json-envelope.spec.ts +140 -0
  1071. package/tests/cli-json.spec.ts +408 -0
  1072. package/tests/cli-orchestrate-plan-batch.spec.ts +329 -0
  1073. package/tests/cli-orchestrate.spec.ts +231 -0
  1074. package/tests/cli-plan-generation.spec.ts +367 -0
  1075. package/tests/cli-plan-review.spec.ts +300 -0
  1076. package/tests/cli-progress.spec.ts +193 -0
  1077. package/tests/cli-ux-enhancements.spec.ts +213 -0
  1078. package/tests/cliJsonPurity.spec.ts +437 -0
  1079. package/tests/cliSuggestDeps.spec.ts +360 -0
  1080. package/tests/cluster-gates-rollback.spec.ts +353 -0
  1081. package/tests/command-validator-integration.spec.ts +305 -0
  1082. package/tests/command-validator.spec.ts +380 -0
  1083. package/tests/commands/autopilot.spec.ts +124 -0
  1084. package/tests/commands/config-validate.spec.ts +301 -0
  1085. package/tests/commands/config.spec.ts +311 -0
  1086. package/tests/commands/create-project.spec.ts +90 -0
  1087. package/tests/commands/doctor.spec.ts +57 -0
  1088. package/tests/commands/execute.spec.ts +293 -0
  1089. package/tests/commands/gateAttest.spec.ts +172 -0
  1090. package/tests/commands/gateImport.spec.ts +176 -0
  1091. package/tests/commands/gateReport.spec.ts +130 -0
  1092. package/tests/commands/guards.spec.ts +114 -0
  1093. package/tests/commands/idea.spec.ts +177 -0
  1094. package/tests/commands/merge.spec.ts +166 -0
  1095. package/tests/commands/plan.spec.ts +123 -0
  1096. package/tests/commands/query.spec.ts +294 -0
  1097. package/tests/commands/report.spec.ts +54 -0
  1098. package/tests/commands/retry.spec.ts +300 -0
  1099. package/tests/commands/schema.spec.ts +136 -0
  1100. package/tests/commands/validation.spec.ts +229 -0
  1101. package/tests/completion.spec.ts +133 -0
  1102. package/tests/config-inspect.spec.ts +202 -0
  1103. package/tests/conflictClustering-e2e.spec.ts +278 -0
  1104. package/tests/conflictClustering.spec.ts +550 -0
  1105. package/tests/conflictGraph.spec.ts +126 -0
  1106. package/tests/conflictPredictor.spec.ts +238 -0
  1107. package/tests/deliverables-generator.spec.ts +329 -0
  1108. package/tests/deliverables.spec.ts +381 -0
  1109. package/tests/dependencyParser-github.spec.ts +244 -0
  1110. package/tests/dependencyParser.spec.ts +386 -0
  1111. package/tests/dependencyScoring.spec.ts +668 -0
  1112. package/tests/deterministic-applicable.test.ts +156 -0
  1113. package/tests/deterministic-build.test.ts +172 -0
  1114. package/tests/deterministic-simple.test.ts +32 -0
  1115. package/tests/discover-suggest-integration.spec.ts +340 -0
  1116. package/tests/dogfood-merge-weave-script.spec.ts +150 -0
  1117. package/tests/e2e/planner.spec.ts +596 -0
  1118. package/tests/e2e-comprehensive.test.ts +500 -0
  1119. package/tests/e2e-determinism.test.ts +293 -0
  1120. package/tests/e2e-synthetic-6pr-weave.spec.ts +329 -0
  1121. package/tests/enterprise-init.spec.ts +350 -0
  1122. package/tests/envUtils.spec.ts +267 -0
  1123. package/tests/error-handling.test.ts +104 -0
  1124. package/tests/error-recovery.spec.ts +451 -0
  1125. package/tests/execution-plan-v1.test.ts +257 -0
  1126. package/tests/executionState-loadGateResults.spec.ts +267 -0
  1127. package/tests/executionState.test.ts +169 -0
  1128. package/tests/executors/README.md +100 -0
  1129. package/tests/executors/frameContract-integration.spec.ts +324 -0
  1130. package/tests/executors/frameContract.spec.ts +531 -0
  1131. package/tests/executors/guardrailEnforcement.spec.ts +424 -0
  1132. package/tests/executors/lifecycle.spec.ts +313 -0
  1133. package/tests/executors/toolBudget.spec.ts +473 -0
  1134. package/tests/feature-spec-v0.test.ts +145 -0
  1135. package/tests/fileAnalysis.spec.ts +946 -0
  1136. package/tests/fingerprint.spec.ts +100 -0
  1137. package/tests/fixtures/README.md +380 -0
  1138. package/tests/fixtures/deliverables/batch-example-plan.json +62 -0
  1139. package/tests/fixtures/executors/README.md +57 -0
  1140. package/tests/fixtures/executors/index.ts +9 -0
  1141. package/tests/fixtures/executors/mock-executor.ts +204 -0
  1142. package/tests/fixtures/executors/registry.ts +51 -0
  1143. package/tests/fixtures/executors/types.ts +95 -0
  1144. package/tests/fixtures/fixtures.spec.ts +307 -0
  1145. package/tests/fixtures/gates/configs.ts +234 -0
  1146. package/tests/fixtures/gates/results.ts +234 -0
  1147. package/tests/fixtures/harvest-bundle-fixture.json +87 -0
  1148. package/tests/fixtures/index.ts +219 -0
  1149. package/tests/fixtures/invalid/plans.ts +178 -0
  1150. package/tests/fixtures/jest/all-passing.json +71 -0
  1151. package/tests/fixtures/jest/snapshot-failures.json +66 -0
  1152. package/tests/fixtures/jest/some-failing.json +100 -0
  1153. package/tests/fixtures/jest/with-location.json +84 -0
  1154. package/tests/fixtures/junit/cdata-messages.xml +29 -0
  1155. package/tests/fixtures/junit/multiple-suites.xml +30 -0
  1156. package/tests/fixtures/junit/single-suite.xml +17 -0
  1157. package/tests/fixtures/junit/with-errors.xml +19 -0
  1158. package/tests/fixtures/junit/with-skipped.xml +18 -0
  1159. package/tests/fixtures/npm-audit.json +32 -0
  1160. package/tests/fixtures/plan.bad-schema.json +5 -0
  1161. package/tests/fixtures/plan.bad-unknown-dep.json +10 -0
  1162. package/tests/fixtures/plan.ci-gates.json +36 -0
  1163. package/tests/fixtures/plan.complex-cycle.json +22 -0
  1164. package/tests/fixtures/plan.cycle.json +14 -0
  1165. package/tests/fixtures/plan.deep-chain.json +95 -0
  1166. package/tests/fixtures/plan.dogfood-execute.json +36 -0
  1167. package/tests/fixtures/plan.gates.json +30 -0
  1168. package/tests/fixtures/plan.integration-pyramid.json +56 -0
  1169. package/tests/fixtures/plan.orphans.json +22 -0
  1170. package/tests/fixtures/plan.parallel.json +30 -0
  1171. package/tests/fixtures/plan.tiny.json +18 -0
  1172. package/tests/fixtures/plan.wide-parallel.json +75 -0
  1173. package/tests/fixtures/plan.with-failures.json +26 -0
  1174. package/tests/fixtures/plan.with-vuln.json +25 -0
  1175. package/tests/fixtures/planner/cross-module.json +101 -0
  1176. package/tests/fixtures/planner/cycle-error.json +56 -0
  1177. package/tests/fixtures/planner/diamond-pattern.json +74 -0
  1178. package/tests/fixtures/planner/empty-repo.json +9 -0
  1179. package/tests/fixtures/planner/file-overlap-heavy.json +110 -0
  1180. package/tests/fixtures/planner/invalid-pr.json +25 -0
  1181. package/tests/fixtures/planner/merge-conflicts.json +42 -0
  1182. package/tests/fixtures/planner/mixed-deps.json +101 -0
  1183. package/tests/fixtures/planner/self-dependency.json +24 -0
  1184. package/tests/fixtures/planner/simple-stack.json +79 -0
  1185. package/tests/fixtures/planner/single-pr.json +25 -0
  1186. package/tests/fixtures/planner/stale-pr.json +40 -0
  1187. package/tests/fixtures/plans/complex.ts +201 -0
  1188. package/tests/fixtures/plans/diamond.ts +115 -0
  1189. package/tests/fixtures/plans/linear.ts +74 -0
  1190. package/tests/fixtures/plans/simple.ts +61 -0
  1191. package/tests/fixtures/prs/basic.ts +175 -0
  1192. package/tests/fixtures/prs/withDeps.ts +197 -0
  1193. package/tests/fixtures/scan-results-clean.sarif +15 -0
  1194. package/tests/fixtures/scan-results.sarif +74 -0
  1195. package/tests/fixtures/scenarios/mergeWorkflows.ts +300 -0
  1196. package/tests/fixtures/scenarios/syntheticWeave.ts +351 -0
  1197. package/tests/fixtures/snapshot/package.json +5 -0
  1198. package/tests/fixtures/snapshot/sample.ts +21 -0
  1199. package/tests/fixtures/utils/cleanup.ts +81 -0
  1200. package/tests/fixtures/utils/mockGitHub.ts +219 -0
  1201. package/tests/fixtures/utils/tempDir.ts +109 -0
  1202. package/tests/fixtures/verification/expected-verification.json +16 -0
  1203. package/tests/fixtures/verification/receipt.json +31 -0
  1204. package/tests/fixtures/verification/snapshot.json +44 -0
  1205. package/tests/fixtures/vitest/all-passing.json +67 -0
  1206. package/tests/fixtures/vitest/complex-nested-suites.json +98 -0
  1207. package/tests/fixtures/vitest/some-failing.json +98 -0
  1208. package/tests/fixtures/vitest/with-coverage.json +97 -0
  1209. package/tests/fixtures-usage-examples.spec.ts +304 -0
  1210. package/tests/flakeReport.spec.ts +267 -0
  1211. package/tests/frames/ci-gate-integration.spec.ts +331 -0
  1212. package/tests/frames/controller.spec.ts +165 -0
  1213. package/tests/frames/emitter.spec.ts +371 -0
  1214. package/tests/frames/idempotency.spec.ts +177 -0
  1215. package/tests/frames/storage.spec.ts +346 -0
  1216. package/tests/frames/types.spec.ts +249 -0
  1217. package/tests/frames/v2-schema-integration.spec.ts +435 -0
  1218. package/tests/gate-working-directory.spec.ts +204 -0
  1219. package/tests/gateMapping.spec.ts +161 -0
  1220. package/tests/gateReportIntegration.spec.ts +175 -0
  1221. package/tests/gateReportValidation.spec.ts +452 -0
  1222. package/tests/gates/test/adapters/jest-json.spec.ts +372 -0
  1223. package/tests/gates/test/adapters/junit-xml.spec.ts +421 -0
  1224. package/tests/gates/test/adapters/registry.spec.ts +376 -0
  1225. package/tests/gates/test/adapters/vitest-json.spec.ts +455 -0
  1226. package/tests/gates/test/enrichment/failureId.spec.ts +131 -0
  1227. package/tests/gates/test/enrichment/nextActions.spec.ts +365 -0
  1228. package/tests/gates/test/enrichment/rerunTemplates.spec.ts +187 -0
  1229. package/tests/gates/test/enrichment/signature.spec.ts +163 -0
  1230. package/tests/gates/test/enrichment/stackParser.spec.ts +203 -0
  1231. package/tests/gates/turncost-integration.spec.ts +221 -0
  1232. package/tests/gates/validation-integration.spec.ts +147 -0
  1233. package/tests/gates/validator.spec.ts +200 -0
  1234. package/tests/gates.test.ts +255 -0
  1235. package/tests/gatesWithPolicy.hostilityTimeoutAdjustment.spec.ts +156 -0
  1236. package/tests/git-operations-receipts.spec.ts +121 -0
  1237. package/tests/git-operations.test.ts +152 -0
  1238. package/tests/git-runtime.spec.ts +175 -0
  1239. package/tests/github-api.labels.spec.ts +21 -0
  1240. package/tests/github-api.test.ts +85 -0
  1241. package/tests/github-context-diet.spec.ts +441 -0
  1242. package/tests/github-diff-hunks.spec.ts +387 -0
  1243. package/tests/github-integration.spec.ts +774 -0
  1244. package/tests/github-minimal-context.spec.ts +338 -0
  1245. package/tests/github-symbol-map.spec.ts +414 -0
  1246. package/tests/githubClient.spec.ts +123 -0
  1247. package/tests/governance/mcpStatus.spec.ts +276 -0
  1248. package/tests/governance/timeoutAdjustment.spec.ts +149 -0
  1249. package/tests/governance/turnCostSummary.spec.ts +188 -0
  1250. package/tests/governance-retention.spec.ts +151 -0
  1251. package/tests/governance-wrapper-delegation.spec.ts +148 -0
  1252. package/tests/guardrails.spec.ts +860 -0
  1253. package/tests/hash.test.ts +83 -0
  1254. package/tests/helpers/cli.ts +23 -0
  1255. package/tests/helpers/getStd.ts +1 -0
  1256. package/tests/helpers/makeGate.ts +19 -0
  1257. package/tests/helpers/plannerTestHelpers.ts +314 -0
  1258. package/tests/hooks/events.spec.ts +518 -0
  1259. package/tests/hostility/checks.spec.ts +295 -0
  1260. package/tests/hostility/integration.spec.ts +123 -0
  1261. package/tests/hostility/score.spec.ts +175 -0
  1262. package/tests/init.spec.ts +270 -0
  1263. package/tests/integration/hipaa-encryption.spec.ts +148 -0
  1264. package/tests/integration/lex-smoke-test.spec.ts +328 -0
  1265. package/tests/integration-e2e.test.ts +244 -0
  1266. package/tests/integration-matrix.test.ts +409 -0
  1267. package/tests/interPRConflicts.spec.ts +254 -0
  1268. package/tests/interactive-plan-history.spec.ts +255 -0
  1269. package/tests/interactive-plan-review.spec.ts +287 -0
  1270. package/tests/issue-analyzer.spec.ts +593 -0
  1271. package/tests/lexsona-integration.spec.ts +311 -0
  1272. package/tests/localOverlay.spec.ts +203 -0
  1273. package/tests/lockHash.spec.ts +167 -0
  1274. package/tests/mcp-auth-errors.spec.ts +190 -0
  1275. package/tests/mcp-contracts.spec.ts +290 -0
  1276. package/tests/mcp-gates-external-plan.spec.ts +146 -0
  1277. package/tests/mcp-granular-tools.spec.ts +208 -0
  1278. package/tests/mcp-runstore-integration.spec.ts +334 -0
  1279. package/tests/mcp-scope-integration.spec.ts +318 -0
  1280. package/tests/mcp-task-handoff.spec.ts +320 -0
  1281. package/tests/mcp-workflow-guide.spec.ts +53 -0
  1282. package/tests/mcp.test.ts +151 -0
  1283. package/tests/merge-conflict-detection.spec.ts +260 -0
  1284. package/tests/mergeEligibility.test.ts +201 -0
  1285. package/tests/mergeLockHash.spec.ts +158 -0
  1286. package/tests/mergeOrder-with-fixtures.spec.ts +215 -0
  1287. package/tests/mergeOrder.test.ts +108 -0
  1288. package/tests/mergeTreeSimulator.spec.ts +145 -0
  1289. package/tests/metrics/export.spec.ts +446 -0
  1290. package/tests/metrics/turncost.spec.ts +309 -0
  1291. package/tests/metrics-template.spec.ts +137 -0
  1292. package/tests/migrateProfile.spec.ts +254 -0
  1293. package/tests/mis.spec.ts +202 -0
  1294. package/tests/monitoring-audit.spec.ts +181 -0
  1295. package/tests/monitoring-cache.spec.ts +331 -0
  1296. package/tests/monitoring-error-recovery.spec.ts +236 -0
  1297. package/tests/monitoring-errors.spec.ts +193 -0
  1298. package/tests/monitoring-fileLogger.spec.ts +319 -0
  1299. package/tests/monitoring-health.spec.ts +152 -0
  1300. package/tests/monitoring-lock.spec.ts +308 -0
  1301. package/tests/monitoring-logger.spec.ts +157 -0
  1302. package/tests/monitoring-metrics.spec.ts +158 -0
  1303. package/tests/monitoring-profiler.spec.ts +197 -0
  1304. package/tests/orchestration-determinism.spec.ts +204 -0
  1305. package/tests/parseRemote.spec.ts +25 -0
  1306. package/tests/pathResolver.spec.ts +122 -0
  1307. package/tests/paths.spec.ts +68 -0
  1308. package/tests/performance.spec.ts +322 -0
  1309. package/tests/pipeline-determinism.spec.ts +597 -0
  1310. package/tests/plan-tier-integration.spec.ts +184 -0
  1311. package/tests/precedence-resolution.spec.ts +682 -0
  1312. package/tests/preflightConflicts.spec.ts +205 -0
  1313. package/tests/procedures/keystone-policy.spec.ts +296 -0
  1314. package/tests/procedures/loader.spec.ts +585 -0
  1315. package/tests/procedures/pr-review.spec.ts +321 -0
  1316. package/tests/profileResolver.spec.ts +375 -0
  1317. package/tests/progress-indicators.spec.ts +139 -0
  1318. package/tests/promptsResolver.spec.ts +443 -0
  1319. package/tests/public-api.spec.ts +272 -0
  1320. package/tests/query.spec.ts +170 -0
  1321. package/tests/receipts.spec.ts +463 -0
  1322. package/tests/release-prepare.spec.ts +268 -0
  1323. package/tests/report.test.ts +335 -0
  1324. package/tests/resolutionGuidance.spec.ts +160 -0
  1325. package/tests/rotate-secrets-example.spec.ts +198 -0
  1326. package/tests/rulesResolver.spec.ts +232 -0
  1327. package/tests/runGit.spec.ts +229 -0
  1328. package/tests/runner-lifecycle-integration.spec.ts +283 -0
  1329. package/tests/runs/artifacts.spec.ts +367 -0
  1330. package/tests/runs/decisions.spec.ts +495 -0
  1331. package/tests/runs/enforcement.spec.ts +555 -0
  1332. package/tests/runs/failures.spec.ts +554 -0
  1333. package/tests/runs/manager-runstore-integration.spec.ts +455 -0
  1334. package/tests/runs/manager.spec.ts +678 -0
  1335. package/tests/runs-manager.spec.ts +485 -0
  1336. package/tests/safety-acceptance.spec.ts +278 -0
  1337. package/tests/safety-enhanced.spec.ts +329 -0
  1338. package/tests/safety-framework.spec.ts +427 -0
  1339. package/tests/safety-guards-integration.spec.ts +213 -0
  1340. package/tests/safety-integration.spec.ts +278 -0
  1341. package/tests/sarif-parser.spec.ts +148 -0
  1342. package/tests/schema.test.ts +88 -0
  1343. package/tests/schemas/behavior-rule.spec.ts +366 -0
  1344. package/tests/schemas/executorManifest.spec.ts +441 -0
  1345. package/tests/schemas/persona-integration.spec.ts +62 -0
  1346. package/tests/schemas/persona.spec.ts +172 -0
  1347. package/tests/schemas/project.spec.ts +247 -0
  1348. package/tests/schemas/run-store.spec.ts +553 -0
  1349. package/tests/schemas/runCentric.spec.ts +463 -0
  1350. package/tests/schemas/vacuumReadyPrompt.spec.ts +515 -0
  1351. package/tests/scope-github-auto-detection.spec.ts +200 -0
  1352. package/tests/scopeValidator.spec.ts +497 -0
  1353. package/tests/security-authentication.spec.ts +42 -0
  1354. package/tests/security-authorization.spec.ts +350 -0
  1355. package/tests/security-cli.spec.ts +264 -0
  1356. package/tests/security-compliance.spec.ts +334 -0
  1357. package/tests/security-policy.spec.ts +295 -0
  1358. package/tests/security-scanning.spec.ts +349 -0
  1359. package/tests/security-secrets.spec.ts +401 -0
  1360. package/tests/store/create-run-store.spec.ts +185 -0
  1361. package/tests/store/inmemory/run-store.spec.ts +533 -0
  1362. package/tests/store/sqlite/run-store.spec.ts +849 -0
  1363. package/tests/telemetry/frames.spec.ts +120 -0
  1364. package/tests/tiers.spec.ts +466 -0
  1365. package/tests/token-usage.spec.ts +309 -0
  1366. package/tests/toolchain-manifest.spec.ts +145 -0
  1367. package/tests/unified-budget.spec.ts +713 -0
  1368. package/tests/unit/cache/issue-cache.spec.ts +131 -0
  1369. package/tests/unit/fanout/analyzer-integration.spec.ts +398 -0
  1370. package/tests/unit/fanout/analyzer.spec.ts +605 -0
  1371. package/tests/unit/fanout/github-adapter.spec.ts +203 -0
  1372. package/tests/unit/fanout/harvest.spec.ts +93 -0
  1373. package/tests/unit/fanout/monitor.spec.ts +297 -0
  1374. package/tests/unit/fanout/types.spec.ts +308 -0
  1375. package/tests/unit/github/batch-ops.spec.ts +179 -0
  1376. package/tests/unit/learning/counter-example.spec.ts +168 -0
  1377. package/tests/unit/learning/storage.spec.ts +154 -0
  1378. package/tests/unit/preview/constraints.spec.ts +429 -0
  1379. package/tests/unit/runs/attribution.spec.ts +204 -0
  1380. package/tests/unit/schemas/task-contract.spec.ts +483 -0
  1381. package/tests/unit/snapshot/builder.spec.ts +389 -0
  1382. package/tests/unit/verification/engine-verifier.spec.ts +279 -0
  1383. package/tests/unit/weave/authority-evaluator.spec.ts +404 -0
  1384. package/tests/unit/weave/authority-schema.spec.ts +199 -0
  1385. package/tests/unit/weave/auto-undraft-integration.spec.ts +349 -0
  1386. package/tests/unit/weave/copilot-completion.spec.ts +182 -0
  1387. package/tests/unit/weave/d1-executor.spec.ts +269 -0
  1388. package/tests/unit/weave/d2-executor.spec.ts +334 -0
  1389. package/tests/unit/weave/fanout-generator.spec.ts +365 -0
  1390. package/tests/unit/weave/fanout-matcher.spec.ts +320 -0
  1391. package/tests/unit/weave/fanout-schema.spec.ts +221 -0
  1392. package/tests/unit/weave/mergeWeaveSequential.spec.ts +268 -0
  1393. package/tests/unit/weave/metrics-calculator.spec.ts +212 -0
  1394. package/tests/unit/weave/metrics-logger.spec.ts +233 -0
  1395. package/tests/unit/weave/metrics-schema.spec.ts +383 -0
  1396. package/tests/unit/weave/multi-repo-plan.spec.ts +221 -0
  1397. package/tests/unit/weave/planner.spec.ts +227 -0
  1398. package/tests/unit/weave/post-merge-checks.spec.ts +342 -0
  1399. package/tests/unit/weave/recovery.spec.ts +306 -0
  1400. package/tests/unit/weave/testfix/applier.spec.ts +364 -0
  1401. package/tests/unit/weave/testfix/e2e.spec.ts +273 -0
  1402. package/tests/unit/weave/testfix/integration.spec.ts +128 -0
  1403. package/tests/unit/weave/testfix/matcher.spec.ts +321 -0
  1404. package/tests/unit/weave/testfix/schema.spec.ts +298 -0
  1405. package/tests/utils/fingerprint.spec.ts +251 -0
  1406. package/tests/utils/paths.spec.ts +284 -0
  1407. package/tests/utils/tokens.spec.ts +210 -0
  1408. package/tests/utils/validation.spec.ts +215 -0
  1409. package/tests/utils-validation.spec.ts +80 -0
  1410. package/tests/validate-manifests.spec.ts +231 -0
  1411. package/tests/validation.spec.ts +501 -0
  1412. package/tests/vuln-gate.spec.ts +341 -0
  1413. package/tests/weave/adr007-integration.spec.ts +309 -0
  1414. package/tests/weave/checkpoint/cli-integration.spec.ts +118 -0
  1415. package/tests/weave/checkpoint/storage.spec.ts +302 -0
  1416. package/tests/weave/checkpoint/utils.spec.ts +223 -0
  1417. package/tests/weave/frameHelper.spec.ts +423 -0
  1418. package/tests/weave/gateFailureHandler.spec.ts +249 -0
  1419. package/tests/weave/lockFile.spec.ts +387 -0
  1420. package/tests/weave/mergeHelpers.spec.ts +173 -0
  1421. package/tests/weave/receiptHelper.spec.ts +261 -0
  1422. package/tests/weave/stateMachine.spec.ts +436 -0
  1423. package/tests/weave-contract.test.ts +517 -0
  1424. package/tests/weave-e2e.spec.ts +279 -0
  1425. package/tests/weaveLock.spec.ts +136 -0
  1426. package/tests/workflow-state-machine.spec.ts +274 -0
  1427. package/tests/write-protection.spec.ts +213 -0
  1428. package/tsconfig.json +18 -0
  1429. package/tsup.config.ts +12 -0
  1430. package/vitest.benchmark.config.ts +17 -0
  1431. package/vitest.config.ts +28 -0
  1432. package/vitest.git.config.ts +12 -0
  1433. package/vitest.slow-cli.config.ts +28 -0
@@ -0,0 +1,1213 @@
1
+ # Audit Outputs - Phase 1: Core Foundation
2
+
3
+ This document covers **Phase 1** of the audit outputs system: NDJSON emitter, envelope structure, basic events, manifest, and summary. This provides the foundation for tamper-evident audit trails supporting SOC 2 and HIPAA 164.312(b) compliance.
4
+
5
+ ## Overview
6
+
7
+ The audit system emits deterministic, machine-readable evidence of tool activity with:
8
+
9
+ - **Minimal metadata** by default (no code bodies, no secrets)
10
+ - **Profile-based configuration** (basic, soc2, hipaa-strict)
11
+ - **NDJSON event streams** with consistent envelope structure
12
+ - **Session manifests** with file hashes and integrity tracking
13
+ - **Extensible foundation** for signatures (Phase 2) and advanced features (Phase 3)
14
+
15
+ ## Quick Start
16
+
17
+ ### Enable Basic Audit Logging
18
+
19
+ ```bash
20
+ # Execute plan with basic audit logging
21
+ lex-pr execute plan.json --audit basic
22
+
23
+ # Output appears in:
24
+ # .smartergpt.local/deliverables/weave-{timestamp}/audit/
25
+ # ├── audit.ndjson # All events
26
+ # ├── audit-manifest.json # File inventory with SHA-256 hashes
27
+ # └── audit-summary.json # Stats: events, durations, status
28
+ ```
29
+
30
+ ### Enable SOC 2 Compliance Mode
31
+
32
+ ```bash
33
+ # SOC 2 profile includes git/ci/os context and gate matrix
34
+ lex-pr execute plan.json --audit soc2
35
+
36
+ # Additional outputs:
37
+ # ├── audit-gate-matrix.json # Pass/fail matrix for all gates
38
+ # └── audit.sig # Signature stub (Phase 2)
39
+ ```
40
+
41
+ ### Enable HIPAA Strict Mode
42
+
43
+ ```bash
44
+ # HIPAA profile requires encryption key and enables PHI redaction
45
+ export LEX_AUDIT_KEY_HEX="0123...cdef" # 64 hex chars (32 bytes)
46
+ lex-pr execute plan.json --audit hipaa-strict
47
+
48
+ # Features:
49
+ # - Paths are hashed (PII protection)
50
+ # - At-rest encryption (AES-256-GCM)
51
+ # - Strict redaction patterns
52
+ # - Output: audit.ndjson.enc (plaintext removed)
53
+ ```
54
+
55
+ ## Audit Profiles
56
+
57
+ ### Profile Comparison
58
+
59
+ | Feature | off | basic | soc2 | hipaa-strict |
60
+ | ------------------- | --- | -------- | -------- | --------------------------------------------- |
61
+ | Event stream | ❌ | ✅ | ✅ | ✅ |
62
+ | Context (git/ci/os) | ❌ | ❌ | ✅ | ✅ |
63
+ | Gate matrix | ❌ | ❌ | ✅ | ✅ |
64
+ | Path hashing | ❌ | ❌ | ❌ | ✅ |
65
+ | PHI redaction | ❌ | ❌ | ❌ | ✅ |
66
+ | Encryption | ❌ | Optional | Optional | **Required** |
67
+ | Signature | ❌ | ❌ | Stub | Stub |
68
+ | Retention | N/A | 365 days | 730 days | 2190 days (6 years, per HIPAA 45 CFR 164.316) |
69
+
70
+ ### Profile Details
71
+
72
+ #### `off` (Default)
73
+
74
+ No audit logging. Use for local development or when compliance is not required.
75
+
76
+ #### `basic`
77
+
78
+ Minimal audit logging for operational visibility:
79
+
80
+ - Events: command invocation, plan validation, gate execution, merge operations
81
+ - No context (git/ci/os)
82
+ - No gate matrix
83
+ - Default redaction: `token|secret|pass|key|auth`
84
+ - Retention: 365 days (recommendation)
85
+
86
+ **Use cases:**
87
+
88
+ - Operational troubleshooting
89
+ - Non-compliance environments
90
+ - Development/staging
91
+
92
+ #### `soc2`
93
+
94
+ Comprehensive audit logging for SOC 2 Type II compliance:
95
+
96
+ - All basic profile features
97
+ - Context: git (commit, branch, remote), ci (actor, workflow), os (platform, arch)
98
+ - Gate matrix: pass/fail status for all gates across all PRs
99
+ - Artifact references (Phase 2)
100
+ - Job IDs for CI correlation
101
+ - Signature stub (Phase 2 implementation)
102
+ - Retention: 730 days (2 years)
103
+
104
+ **Use cases:**
105
+
106
+ - SOC 2 Type II audits
107
+ - Security compliance reporting
108
+ - Change management audits
109
+
110
+ #### `hipaa-strict`
111
+
112
+ Maximum protection for HIPAA 164.312(b) compliance:
113
+
114
+ - All SOC 2 profile features
115
+ - Path hashing: All file paths are SHA-256 hashed
116
+ - PHI redaction: Automatic detection and redaction of PHI patterns (SSN, DOB, medical terms)
117
+ - Strict redaction: Extended patterns including `ssn|ein|dob`
118
+ - **Encryption required**: AES-256-GCM with 32-byte key
119
+ - Fail-closed: Invalid key causes immediate abort and plaintext scrubbing
120
+ - Retention: 2190 days (6 years, per HIPAA 45 CFR 164.316)
121
+
122
+ **Use cases:**
123
+
124
+ - HIPAA-regulated environments
125
+ - Healthcare data processing
126
+ - Maximum security posture
127
+
128
+ ## Event Schema
129
+
130
+ ### Envelope Structure
131
+
132
+ Every event is wrapped in a consistent envelope:
133
+
134
+ ```json
135
+ {
136
+ "schema_version": "0.1.0",
137
+ "event": "gate_finished",
138
+ "ts": "2025-11-02T14:30:28Z",
139
+ "level": "info",
140
+ "session_id": "01JB123456789",
141
+ "run_id": "01JB987654321",
142
+ "tool": {
143
+ "name": "lexrunner",
144
+ "version": "0.1.0"
145
+ },
146
+ "actor": {
147
+ "type": "cli"
148
+ },
149
+ "repo": {
150
+ "remote": "https://github.com/org/repo",
151
+ "branch": "main",
152
+ "commit": "abc123def456"
153
+ },
154
+ "context": {
155
+ "git": { "commit": "abc123", "branch": "main" },
156
+ "ci": { "actor": "github-actions", "workflow": "CI" },
157
+ "os": { "platform": "linux", "arch": "x64" }
158
+ },
159
+ "payload": {
160
+ "item": "166",
161
+ "gate": "lint",
162
+ "exit_code": 0,
163
+ "duration_ms": 6200,
164
+ "status": "pass"
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### Required Envelope Fields
170
+
171
+ - `schema_version`: Event schema version (semver)
172
+ - `event`: Event type (see Event Types below)
173
+ - `ts`: ISO 8601 timestamp (UTC)
174
+ - `level`: `info`, `warn`, or `error`
175
+ - `session_id`: ULID for this execution session
176
+ - `run_id`: ULID for this specific run
177
+ - `tool`: Tool name and version
178
+ - `actor`: Actor type (`cli`, `mcp`, `ci`)
179
+ - `repo`: Repository context (remote, branch, commit)
180
+ - `context`: Optional context blocks (git, ci, os)
181
+ - `payload`: Event-specific data
182
+
183
+ ### Event Types
184
+
185
+ #### Core Events
186
+
187
+ | Event | Description | Payload Fields |
188
+ | ---------------------- | ------------------------- | ------------------------------------- |
189
+ | `command_invocation` | CLI command executed | `argv`, `cwd` |
190
+ | `plan_discovered` | Plan loaded and parsed | `pr_ids`, `base`, `head`, `plan_hash` |
191
+ | `plan_validated` | Plan schema validated | `schema_version`, `warnings[]` |
192
+ | `merge_order_computed` | Dependency order computed | `levels`, `items_per_level[]` |
193
+
194
+ #### Gate Events
195
+
196
+ | Event | Description | Payload Fields |
197
+ | --------------- | ------------------------ | ----------------------------------------------------------------------- |
198
+ | `gate_started` | Gate execution started | `item`, `gate` |
199
+ | `gate_finished` | Gate execution completed | `item`, `gate`, `duration_ms`, `status`, `exit_code`, `artifact_refs[]` |
200
+
201
+ **Status values:** `pass`, `fail`, `skip`, `blocked`
202
+
203
+ #### Merge Events
204
+
205
+ | Event | Description | Payload Fields |
206
+ | ------------------------- | --------------------------- | ------------------------------- |
207
+ | `merge_dry_run_started` | Dry run merge started | `item`, `base`, `head` |
208
+ | `merge_dry_run_finished` | Dry run completed | `item`, `status`, `conflicts[]` |
209
+ | `merge_execute_started` | Real merge started | `item`, `base`, `head` |
210
+ | `merge_conflict_detected` | Conflict found during merge | `item`, `files[]` |
211
+ | `merge_finished` | Merge completed | `item`, `status`, `commit` |
212
+
213
+ #### Artifact & Summary Events
214
+
215
+ | Event | Description | Payload Fields |
216
+ | ------------------ | ----------------------- | -------------------------------------------- |
217
+ | `artifact_written` | Output artifact created | `path`, `sha256`, `bytes` |
218
+ | `error` | Error occurred | `code`, `message`, `where` |
219
+ | `run_summary` | Execution summary | `totals`, `pass_fail_matrix`, `final_status` |
220
+
221
+ ## Output Files
222
+
223
+ ### Directory Structure
224
+
225
+ ```
226
+ .smartergpt.local/deliverables/weave-2025-11-02-143022/audit/
227
+ ├── audit.ndjson # NDJSON event stream
228
+ ├── audit.schema.json # Event envelope schema
229
+ ├── audit-manifest.json # File inventory with SHA-256 hashes
230
+ ├── audit-summary.json # Execution summary
231
+ ├── audit-gate-matrix.json # Gate pass/fail matrix (soc2, hipaa-strict)
232
+ └── audit.sig # Signature stub (Phase 2)
233
+ ```
234
+
235
+ ### `audit.ndjson`
236
+
237
+ Newline-delimited JSON event stream. Each line is a complete event envelope.
238
+
239
+ **Example:**
240
+
241
+ ```json
242
+ {"schema_version":"0.1.0","event":"gate_started","ts":"2025-11-02T14:30:22Z","level":"info","session_id":"01JB123","run_id":"01JB456","tool":{"name":"lexrunner","version":"0.1.0"},"actor":{"type":"cli"},"repo":{},"payload":{"item":"166","gate":"lint"}}
243
+ {"schema_version":"0.1.0","event":"gate_finished","ts":"2025-11-02T14:30:28Z","level":"info","session_id":"01JB123","run_id":"01JB456","tool":{"name":"lexrunner","version":"0.1.0"},"actor":{"type":"cli"},"repo":{},"payload":{"item":"166","gate":"lint","exit_code":0,"duration_ms":6200,"status":"pass"}}
244
+ ```
245
+
246
+ **Processing:**
247
+
248
+ ```bash
249
+ # Extract all gate failures
250
+ cat audit.ndjson | jq 'select(.event == "gate_finished" and .payload.status == "fail")'
251
+
252
+ # Compute total duration
253
+ cat audit.ndjson | jq -s 'map(select(.event == "gate_finished") | .payload.duration_ms) | add'
254
+
255
+ # Count events by type
256
+ cat audit.ndjson | jq -s 'group_by(.event) | map({event: .[0].event, count: length})'
257
+ ```
258
+
259
+ ### `audit-summary.json`
260
+
261
+ High-level execution summary.
262
+
263
+ **Example:**
264
+
265
+ ```json
266
+ {
267
+ "schemaVersion": "1.0.0",
268
+ "timestamp": "2025-11-02T14:35:00Z",
269
+ "sessionId": "01JB123456789",
270
+ "runId": "01JB987654321",
271
+ "profile": "soc2",
272
+ "totalEvents": 127,
273
+ "eventsByType": {
274
+ "command_invocation": 1,
275
+ "plan_discovered": 1,
276
+ "plan_validated": 1,
277
+ "merge_order_computed": 1,
278
+ "gate_started": 42,
279
+ "gate_finished": 42,
280
+ "merge_execute_started": 14,
281
+ "merge_finished": 14,
282
+ "run_summary": 1
283
+ },
284
+ "duration": 123456,
285
+ "finalStatus": "success"
286
+ }
287
+ ```
288
+
289
+ ### `audit-manifest.json`
290
+
291
+ File inventory with SHA-256 integrity hashes. For SOC 2 and HIPAA profiles, also includes CI context (git, CI environment, and OS details).
292
+
293
+ **Example (basic profile):**
294
+
295
+ ```json
296
+ {
297
+ "schemaVersion": "1.0.0",
298
+ "timestamp": "2025-11-02T14:35:00Z",
299
+ "files": [
300
+ {
301
+ "file": "audit.ndjson",
302
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
303
+ "bytes": 524288
304
+ },
305
+ {
306
+ "file": "audit-summary.json",
307
+ "sha256": "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
308
+ "bytes": 1024
309
+ }
310
+ ],
311
+ "totalBytes": 525312
312
+ }
313
+ ```
314
+
315
+ **Example (soc2/hipaa-strict profile with CI context):**
316
+
317
+ ```json
318
+ {
319
+ "schemaVersion": "1.0.0",
320
+ "timestamp": "2025-11-02T14:35:00Z",
321
+ "files": [
322
+ {
323
+ "file": "audit.ndjson",
324
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
325
+ "bytes": 524288
326
+ },
327
+ {
328
+ "file": "audit-gate-matrix.json",
329
+ "sha256": "a1b2c3d4e5f6...",
330
+ "bytes": 4096
331
+ }
332
+ ],
333
+ "totalBytes": 528384,
334
+ "ciContext": {
335
+ "git": {
336
+ "commit": "abc123def456",
337
+ "branch": "main",
338
+ "remote": "git@github.com:owner/repo.git",
339
+ "author": "dev@example.com",
340
+ "committer": "dev@example.com",
341
+ "message": "Fix: Update audit context",
342
+ "dirty": false,
343
+ "tags": ["v1.0.0"]
344
+ },
345
+ "ci": {
346
+ "provider": "github-actions",
347
+ "run_id": "12345678",
348
+ "run_number": "42",
349
+ "workflow": "Merge & Deploy",
350
+ "job": "audit-compliance",
351
+ "actor": "Guffawaffle",
352
+ "event_name": "push",
353
+ "ref": "refs/heads/main",
354
+ "sha": "abc123def456"
355
+ },
356
+ "os": {
357
+ "platform": "linux",
358
+ "release": "5.15.0-1020-azure",
359
+ "arch": "x64",
360
+ "hostname": "runner-001",
361
+ "user": "runner"
362
+ }
363
+ }
364
+ }
365
+ ```
366
+
367
+ ### `audit-gate-matrix.json` (soc2, hipaa-strict)
368
+
369
+ Pass/fail matrix for all gates across all PRs.
370
+
371
+ **Example:**
372
+
373
+ ```json
374
+ {
375
+ "generated_at": "2025-11-02T14:35:00Z",
376
+ "session_id": "01JB123456789",
377
+ "matrix": {
378
+ "166": {
379
+ "lint": { "status": "pass", "duration_ms": 1234 },
380
+ "typecheck": { "status": "pass", "duration_ms": 2345 },
381
+ "unit": { "status": "pass", "duration_ms": 3456 }
382
+ },
383
+ "167": {
384
+ "lint": { "status": "pass", "duration_ms": 1111 },
385
+ "typecheck": { "status": "fail", "duration_ms": 2222, "error": "Type mismatch" },
386
+ "unit": { "status": "blocked", "reason": "typecheck failed" }
387
+ }
388
+ },
389
+ "summary": {
390
+ "total_prs": 2,
391
+ "total_gates": 6,
392
+ "passed": 4,
393
+ "failed": 1,
394
+ "skipped": 0,
395
+ "blocked": 1
396
+ }
397
+ }
398
+ ```
399
+
400
+ ## CLI Flags
401
+
402
+ ### Global Flags
403
+
404
+ ```bash
405
+ lex-pr --audit-profile <profile> [command]
406
+ ```
407
+
408
+ **Options:**
409
+
410
+ - `--audit-profile <profile>`: Audit profile (off|basic|soc2|hipaa-strict) [default: off]
411
+ - `--audit-key <hex>`: Encryption key (64 hex chars, 32 bytes) - overrides `LEX_AUDIT_KEY_HEX` env var
412
+
413
+ **Example:**
414
+
415
+ ```bash
416
+ # Enable basic audit for all commands
417
+ lex-pr --audit-profile basic execute plan.json
418
+
419
+ # Enable HIPAA audit with encryption
420
+ export LEX_AUDIT_KEY_HEX="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
421
+ lex-pr --audit-profile hipaa-strict execute plan.json
422
+ ```
423
+
424
+ ### Command-Specific Flags
425
+
426
+ ```bash
427
+ lex-pr execute plan.json --audit <profile> [options]
428
+ ```
429
+
430
+ **Options:**
431
+
432
+ - `--audit <profile>`: Audit profile (off|basic|soc2|hipaa-strict) [default: off]
433
+ - `--audit-dir <path>`: Output directory [default: `<deliverables>/audit`]
434
+ - `--audit-include-env <keys>`: Comma-separated env var names to include
435
+ - `--audit-redact <regex>`: Custom redaction regex pattern
436
+ - `--audit-hash-paths`: Hash file paths (overrides profile default)
437
+ - `--audit-context <types>`: Context blocks (git,ci,os) - overrides profile default
438
+ - `--audit-sample <percent>`: Sampling percentage for noisy gates [default: 100]
439
+ - `--audit-retain-days <days>`: Retention hint in days
440
+
441
+ **Examples:**
442
+
443
+ ```bash
444
+ # Basic audit to custom directory
445
+ lex-pr execute plan.json --audit basic --audit-dir /tmp/audit
446
+
447
+ # Include specific environment variables
448
+ lex-pr execute plan.json --audit soc2 --audit-include-env CI,GITHUB_ACTOR,RUNNER_OS
449
+
450
+ # Override context to only git
451
+ lex-pr execute plan.json --audit soc2 --audit-context git
452
+
453
+ # Custom redaction pattern
454
+ lex-pr execute plan.json --audit basic --audit-redact 'token|password|apikey'
455
+
456
+ # Sample 50% of gate events (for high-volume workloads)
457
+ lex-pr execute plan.json --audit basic --audit-sample 50
458
+ ```
459
+
460
+ ## Environment Variables
461
+
462
+ | Variable | Description | Example |
463
+ | ---------------------- | -------------------------------------- | ----------------------------- |
464
+ | `LEX_AUDIT_KEY_HEX` | Encryption key (64 hex chars) | `0123...cdef` |
465
+ | `LEX_AUDIT_PHI` | Enable PHI redaction (1=on) | `1` |
466
+ | `LEX_AUDIT_DROP_DIR` | Sidecar file drop directory (auto-set) | `/tmp/lex-audit-session-{id}` |
467
+ | `LEX_AUDIT_SESSION_ID` | Session ID (auto-set) | `01JB123456789` |
468
+
469
+ ## Security & Compliance
470
+
471
+ ### Secret Redaction
472
+
473
+ All audit profiles apply redaction to prevent secrets from being logged.
474
+
475
+ **Default patterns (basic, soc2):**
476
+
477
+ ```
478
+ token|secret|pass|key|auth
479
+ ```
480
+
481
+ **Strict patterns (hipaa-strict):**
482
+
483
+ ```
484
+ token|secret|pass|key|auth|api[_-]?key|bearer|credential|pwd|ssn|ein|dob
485
+ ```
486
+
487
+ **Custom redaction:**
488
+
489
+ ```bash
490
+ lex-pr execute plan.json --audit basic --audit-redact 'my_secret|custom_token'
491
+ ```
492
+
493
+ ### PHI Redaction (HIPAA)
494
+
495
+ HIPAA-strict profile automatically detects and redacts:
496
+
497
+ - Social Security Numbers (SSN)
498
+ - Date of Birth (DOB)
499
+ - Employee Identification Numbers (EIN)
500
+ - Medical record numbers
501
+ - Common PHI patterns
502
+
503
+ **Example:**
504
+
505
+ ```json
506
+ // Before redaction
507
+ {"patient_id": "123-45-6789", "dob": "1990-01-01"}
508
+
509
+ // After redaction
510
+ {"patient_id": "***REDACTED***", "dob": "***REDACTED***", "_phi_redacted": true}
511
+ ```
512
+
513
+ ### Path Hashing (HIPAA)
514
+
515
+ HIPAA-strict profile hashes all file paths to protect PII:
516
+
517
+ **Example:**
518
+
519
+ ```json
520
+ // Before hashing
521
+ {"path": "/projects/patient-data/john-doe/results.csv"}
522
+
523
+ // After hashing
524
+ {"path": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
525
+ ```
526
+
527
+ ### At-Rest Encryption (HIPAA)
528
+
529
+ HIPAA-strict profile requires AES-256-GCM encryption:
530
+
531
+ 1. Set encryption key (32 bytes, 64 hex chars):
532
+
533
+ ```bash
534
+ export LEX_AUDIT_KEY_HEX="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
535
+ ```
536
+
537
+ 2. Run with HIPAA profile:
538
+
539
+ ```bash
540
+ lex-pr execute plan.json --audit hipaa-strict
541
+ ```
542
+
543
+ 3. Output is encrypted:
544
+
545
+ ```
546
+ audit/
547
+ ├── audit.ndjson.enc # Encrypted (AES-256-GCM)
548
+ ├── audit-summary.json # Plaintext (no PHI)
549
+ └── audit-manifest.json # Plaintext (file hashes)
550
+ ```
551
+
552
+ 4. Decrypt for analysis:
553
+ ```bash
554
+ # Decryption script (Phase 2)
555
+ lex-pr audit decrypt audit.ndjson.enc --key-hex $LEX_AUDIT_KEY_HEX
556
+ ```
557
+
558
+ **Fail-closed behavior:**
559
+
560
+ - Invalid key → immediate abort, plaintext scrubbed, `audit.error.json` written
561
+ - Missing key → immediate abort, no plaintext written
562
+ - Encryption failure → immediate abort, partial files scrubbed
563
+
564
+ ## Determinism
565
+
566
+ Audit outputs are deterministic for the same execution:
567
+
568
+ - **Stable event ordering**: Events are emitted in execution order
569
+ - **Canonical JSON**: Objects use sorted keys (via `canonicalJSONStringify`)
570
+ - **No random data**: Session IDs and run IDs can be overridden for testing
571
+ - **Fixed timestamps**: Use `--audit-session-id` and `--audit-run-id` for reproducible tests
572
+
573
+ **Example (testing):**
574
+
575
+ ```typescript
576
+ const emitter = await initAuditEmitter({
577
+ profile: "basic",
578
+ dir: "/tmp/audit",
579
+ sessionId: "test-session-123",
580
+ runId: "test-run-456",
581
+ tool: { name: "lexrunner", version: "0.1.0" },
582
+ });
583
+ ```
584
+
585
+ ## Performance
586
+
587
+ Audit overhead is minimal:
588
+
589
+ - **NDJSON streaming**: Append-only writes, no buffering
590
+ - **Lazy context**: Git/CI/OS context collected once during init
591
+ - **Sampling**: Use `--audit-sample` to reduce volume for noisy gates
592
+ - **Async finalization**: Summary/manifest written after main execution
593
+
594
+ **Benchmarks:**
595
+
596
+ - Basic profile: <1% overhead
597
+ - SOC2 profile: <2% overhead
598
+ - HIPAA profile: <3% overhead (includes encryption)
599
+
600
+ ## Troubleshooting
601
+
602
+ ### No audit files generated
603
+
604
+ **Check:**
605
+
606
+ 1. Is audit profile enabled? (not `off`)
607
+
608
+ ```bash
609
+ lex-pr execute plan.json --audit basic
610
+ ```
611
+
612
+ 2. Check output directory exists:
613
+
614
+ ```bash
615
+ ls -la .smartergpt.local/deliverables/weave-*/audit/
616
+ ```
617
+
618
+ 3. Verify permissions on deliverables directory
619
+
620
+ ### HIPAA encryption fails
621
+
622
+ **Error:** `HIPAA: encryption key required and must be 64 hex chars`
623
+
624
+ **Solution:**
625
+
626
+ ```bash
627
+ # Generate valid key
628
+ export LEX_AUDIT_KEY_HEX=$(openssl rand -hex 32)
629
+ echo "Key: $LEX_AUDIT_KEY_HEX" > /secure/location/audit-key.txt
630
+
631
+ # Use key
632
+ lex-pr execute plan.json --audit hipaa-strict
633
+ ```
634
+
635
+ **Error:** `HIPAA: encryption failed; scrubbed plaintext and aborting`
636
+
637
+ **Solution:**
638
+
639
+ 1. Check key is valid 64 hex chars
640
+ 2. Ensure sufficient disk space
641
+ 3. Check file permissions on audit directory
642
+
643
+ ### Gate matrix not generated
644
+
645
+ **Check:**
646
+
647
+ 1. Profile must be `soc2` or `hipaa-strict` (not `basic`)
648
+ 2. Verify `gate_finished` events are being emitted:
649
+ ```bash
650
+ cat audit.ndjson | jq 'select(.event == "gate_finished")'
651
+ ```
652
+
653
+ ### Events not appearing in NDJSON
654
+
655
+ **Check:**
656
+
657
+ 1. Sampling rate: `--audit-sample 100` (default)
658
+ 2. Profile is not `off`
659
+ 3. Finalization completed (summary exists)
660
+
661
+ ## Next Steps
662
+
663
+ - **Phase 2**: Manifest signatures (KMS, GPG) - See [Phase 2 documentation](#phase-2-signatures-and-verification) below
664
+ - **Phase 3**: Schema versioning, Node SDK, SARIF export
665
+ - **Integration**: CI/CD pipelines, monitoring systems, compliance dashboards
666
+
667
+ ---
668
+
669
+ # Phase 2: Signatures and Verification
670
+
671
+ This section covers Phase 2 of the audit outputs system: **Manifest Signatures** for tamper-evident audit trails using KMS and GPG.
672
+
673
+ ## Overview
674
+
675
+ Audit manifest signing provides cryptographic proof that audit records haven't been tampered with after creation. The system supports two signing methods:
676
+
677
+ 1. **KMS (Recommended)**: Cloud-based key management services (AWS KMS, GCP Cloud KMS, Azure Key Vault)
678
+ 2. **GPG (Fallback)**: Local GPG signing for environments without cloud KMS access
679
+
680
+ ## Signature Providers
681
+
682
+ ### When to Use KMS
683
+
684
+ **Recommended for:**
685
+
686
+ - Production environments
687
+ - SOC 2 / HIPAA compliance requirements
688
+ - Automated CI/CD pipelines
689
+ - Organizations with existing cloud infrastructure
690
+
691
+ **Benefits:**
692
+
693
+ - Centralized key management
694
+ - Automatic key rotation
695
+ - Hardware security module (HSM) backing
696
+ - Built-in access controls and audit logs
697
+ - No secret management in CI/CD
698
+
699
+ **Supported Providers:**
700
+
701
+ - **AWS KMS**: `arn:aws:kms:REGION:ACCOUNT:key/KEY_ID`
702
+ - **GCP Cloud KMS**: `projects/PROJECT/locations/REGION/keyRings/RING/cryptoKeys/KEY`
703
+ - **Azure Key Vault**: `https://VAULT.vault.azure.net/keys/KEY/VERSION`
704
+
705
+ ### When to Use GPG
706
+
707
+ **Recommended for:**
708
+
709
+ - Development and testing
710
+ - Organizations without cloud infrastructure
711
+ - Air-gapped environments
712
+ - Legacy systems
713
+
714
+ **Benefits:**
715
+
716
+ - Works offline
717
+ - No cloud dependency
718
+ - Standard PGP/GPG tooling
719
+ - Verifiable with public key
720
+
721
+ **Considerations:**
722
+
723
+ - Manual key management
724
+ - Private key must be securely stored
725
+ - Key rotation requires pipeline updates
726
+
727
+ ## KMS Setup Guide
728
+
729
+ ### AWS KMS
730
+
731
+ #### 1. Create Signing Key
732
+
733
+ ```bash
734
+ aws kms create-key \
735
+ --description "Audit manifest signing key" \
736
+ --key-usage SIGN_VERIFY \
737
+ --customer-master-key-spec RSA_2048
738
+
739
+ # Note the KeyId from the output
740
+ export KEY_ARN="arn:aws:kms:us-east-1:123456789012:key/abcd-1234..."
741
+ ```
742
+
743
+ #### 2. Configure IAM Permissions
744
+
745
+ Create an IAM policy for the CI/CD role:
746
+
747
+ ```json
748
+ {
749
+ "Version": "2012-10-17",
750
+ "Statement": [
751
+ {
752
+ "Effect": "Allow",
753
+ "Action": ["kms:Sign", "kms:Verify", "kms:DescribeKey"],
754
+ "Resource": "arn:aws:kms:us-east-1:123456789012:key/abcd-1234..."
755
+ }
756
+ ]
757
+ }
758
+ ```
759
+
760
+ Attach to your CI/CD execution role:
761
+
762
+ ```bash
763
+ aws iam put-role-policy \
764
+ --role-name GitHubActionsRole \
765
+ --policy-name AuditSigningPolicy \
766
+ --policy-document file://kms-policy.json
767
+ ```
768
+
769
+ #### 3. Configure Key Rotation
770
+
771
+ Enable automatic rotation (recommended every 365 days):
772
+
773
+ ```bash
774
+ aws kms enable-key-rotation --key-id $KEY_ARN
775
+ ```
776
+
777
+ #### 4. Sign Audit Manifest
778
+
779
+ ```bash
780
+ lex-pr execute --plan plan.json \
781
+ --audit soc2 \
782
+ --audit-signer kms:$KEY_ARN
783
+ ```
784
+
785
+ ### GCP Cloud KMS
786
+
787
+ #### 1. Create Key Ring and Key
788
+
789
+ ```bash
790
+ gcloud kms keyrings create audit-signing \
791
+ --location us-central1
792
+
793
+ gcloud kms keys create manifest-sign-key \
794
+ --location us-central1 \
795
+ --keyring audit-signing \
796
+ --purpose asymmetric-signing \
797
+ --default-algorithm rsa-sign-pss-2048-sha256
798
+
799
+ export KEY_PATH="projects/my-project/locations/us-central1/keyRings/audit-signing/cryptoKeys/manifest-sign-key"
800
+ ```
801
+
802
+ #### 2. Grant Permissions
803
+
804
+ ```bash
805
+ gcloud kms keys add-iam-policy-binding manifest-sign-key \
806
+ --location us-central1 \
807
+ --keyring audit-signing \
808
+ --member serviceAccount:ci-pipeline@my-project.iam.gserviceaccount.com \
809
+ --role roles/cloudkms.signerVerifier
810
+ ```
811
+
812
+ #### 3. Configure Service Account
813
+
814
+ Set up the service account in your CI/CD:
815
+
816
+ ```bash
817
+ # In GitHub Actions
818
+ - uses: google-github-actions/auth@v1
819
+ with:
820
+ credentials_json: ${{ secrets.GCP_SA_KEY }}
821
+ ```
822
+
823
+ #### 4. Sign Audit Manifest
824
+
825
+ ```bash
826
+ lex-pr execute --plan plan.json \
827
+ --audit soc2 \
828
+ --audit-signer kms:$KEY_PATH
829
+ ```
830
+
831
+ ### Azure Key Vault
832
+
833
+ #### 1. Create Key Vault and Key
834
+
835
+ ```bash
836
+ az keyvault create \
837
+ --name audit-vault \
838
+ --resource-group my-rg \
839
+ --location eastus
840
+
841
+ az keyvault key create \
842
+ --vault-name audit-vault \
843
+ --name manifest-signing-key \
844
+ --kty RSA \
845
+ --size 2048 \
846
+ --ops sign verify
847
+
848
+ export KEY_URL="https://audit-vault.vault.azure.net/keys/manifest-signing-key"
849
+ ```
850
+
851
+ #### 2. Grant Access
852
+
853
+ ```bash
854
+ az keyvault set-policy \
855
+ --name audit-vault \
856
+ --object-id <service-principal-id> \
857
+ --key-permissions sign verify
858
+ ```
859
+
860
+ #### 3. Authenticate in CI/CD
861
+
862
+ ```yaml
863
+ # In GitHub Actions
864
+ - uses: azure/login@v1
865
+ with:
866
+ creds: ${{ secrets.AZURE_CREDENTIALS }}
867
+ ```
868
+
869
+ #### 4. Sign Audit Manifest
870
+
871
+ ```bash
872
+ lex-pr execute --plan plan.json \
873
+ --audit soc2 \
874
+ --audit-signer kms:$KEY_URL
875
+ ```
876
+
877
+ ## GPG Setup Guide
878
+
879
+ ### 1. Generate GPG Key
880
+
881
+ ```bash
882
+ # Generate key (use batch mode for automation)
883
+ cat > key-params.txt <<EOF
884
+ Key-Type: RSA
885
+ Key-Length: 2048
886
+ Name-Real: Audit Signing Bot
887
+ Name-Email: audit@example.com
888
+ Expire-Date: 2y
889
+ %no-protection
890
+ %commit
891
+ EOF
892
+
893
+ gpg --batch --generate-key key-params.txt
894
+
895
+ # Get fingerprint
896
+ export GPG_FPR=$(gpg --list-keys --with-colons audit@example.com | awk -F: '/fpr:/ {print $10; exit}')
897
+ echo "Fingerprint: $GPG_FPR"
898
+ ```
899
+
900
+ ### 2. Export Private Key for CI/CD
901
+
902
+ ```bash
903
+ # Export private key (store securely in CI secrets)
904
+ gpg --armor --export-secret-keys $GPG_FPR > private-key.asc
905
+
906
+ # Export public key (can be committed to repo)
907
+ gpg --armor --export $GPG_FPR > public-key.asc
908
+ ```
909
+
910
+ ### 3. Configure CI/CD Secrets
911
+
912
+ In GitHub Actions secrets, add:
913
+
914
+ - `GPG_PRIVATE_KEY`: Contents of `private-key.asc`
915
+ - `GPG_PASSPHRASE`: Passphrase (if protected)
916
+
917
+ ### 4. Import Key in CI Pipeline
918
+
919
+ ```yaml
920
+ # .github/workflows/merge.yml
921
+ - name: Import GPG key
922
+ run: |
923
+ echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
924
+ gpg --list-secret-keys
925
+
926
+ - name: Sign audit manifest
927
+ env:
928
+ GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
929
+ run: |
930
+ lex-pr execute --plan plan.json \
931
+ --audit soc2 \
932
+ --audit-signer gpg:${{ env.GPG_FPR }}
933
+ ```
934
+
935
+ ### 5. Key Rotation
936
+
937
+ When rotating keys:
938
+
939
+ 1. Generate new GPG key
940
+ 2. Update CI/CD secrets with new private key
941
+ 3. Keep old public key for verification of historical records
942
+ 4. Document rotation in audit log
943
+
944
+ ## Signing Behavior
945
+
946
+ ### Output Files
947
+
948
+ When signing is enabled, three files are created:
949
+
950
+ 1. **`audit.sig`**: Detached signature (binary for KMS, ASCII-armored for GPG)
951
+ 2. **`audit.sig.meta`**: Signature metadata (JSON)
952
+ 3. **`audit.pubkey.asc`**: Public key export (GPG only)
953
+
954
+ ### Signature Metadata Structure
955
+
956
+ ```json
957
+ {
958
+ "provider": "kms",
959
+ "algorithm": "RSASSA_PSS_SHA_256",
960
+ "key_ref": "arn:aws:kms:us-east-1:123456789012:key/abcd-1234",
961
+ "signed_at": "2025-10-13T03:30:00Z",
962
+ "manifest_sha256": "a3f2b9c8d1e4f5a6b7c8d9e0f1a2b3c4"
963
+ }
964
+ ```
965
+
966
+ ### Manifest Embedding
967
+
968
+ The `audit-manifest.json` is updated with signing metadata:
969
+
970
+ ```json
971
+ {
972
+ "files": [...],
973
+ "metadata": {...},
974
+ "signing": {
975
+ "provider": "kms",
976
+ "key_ref": "arn:aws:kms:...",
977
+ "algorithm": "RSASSA_PSS_SHA_256",
978
+ "signature_file": "audit.sig",
979
+ "metadata_file": "audit.sig.meta"
980
+ }
981
+ }
982
+ ```
983
+
984
+ ## Verification Guide
985
+
986
+ ### CLI Verification
987
+
988
+ ```bash
989
+ # Verify signature
990
+ lex-pr audit verify --manifest audit-manifest.json
991
+
992
+ # Output (success):
993
+ # ✅ Signature verified
994
+ # Provider: kms
995
+ # Key: arn:aws:kms:us-east-1:123456789012:key/abcd-1234
996
+ # Algorithm: RSASSA_PSS_SHA_256
997
+ # Signed at: 2025-10-13T03:30:00Z
998
+ # Manifest SHA-256: a3f2b9c8d1e4f5a6b7c8d9e0f1a2b3c4
999
+
1000
+ # JSON output
1001
+ lex-pr audit verify --manifest audit-manifest.json --format json
1002
+ ```
1003
+
1004
+ ### Verify in CI/CD
1005
+
1006
+ ```yaml
1007
+ - name: Verify audit signature
1008
+ run: |
1009
+ lex-pr audit verify --manifest .smartergpt.local/deliverables/weave-*/audit/audit-manifest.json
1010
+
1011
+ - name: Upload verified manifest
1012
+ uses: actions/upload-artifact@v3
1013
+ with:
1014
+ name: verified-audit-manifest
1015
+ path: .smartergpt.local/deliverables/weave-*/audit/
1016
+ ```
1017
+
1018
+ ### Local Verification (GPG)
1019
+
1020
+ ```bash
1021
+ # Manual GPG verification
1022
+ gpg --verify audit.sig audit-manifest.json
1023
+
1024
+ # Import public key first if needed
1025
+ gpg --import audit.pubkey.asc
1026
+ ```
1027
+
1028
+ ### SIEM Integration
1029
+
1030
+ Export verification results for ingestion:
1031
+
1032
+ ```bash
1033
+ # Verify and output JSON for SIEM
1034
+ lex-pr audit verify --manifest audit-manifest.json --format json | \
1035
+ jq '{event: "audit_verification", timestamp: .timestamp, status: .status, provider: .result.provider, key: .result.keyInfo}'
1036
+ ```
1037
+
1038
+ Example SIEM payload:
1039
+
1040
+ ```json
1041
+ {
1042
+ "event": "audit_verification",
1043
+ "timestamp": "2025-10-13T03:30:00Z",
1044
+ "status": "verified",
1045
+ "provider": "kms",
1046
+ "key": "arn:aws:kms:us-east-1:123456789012:key/abcd-1234"
1047
+ }
1048
+ ```
1049
+
1050
+ ## Retention Policy
1051
+
1052
+ ### Public Keys and Verification Data
1053
+
1054
+ **Recommended retention:**
1055
+
1056
+ - **SOC 2**: 1 year minimum
1057
+ - **HIPAA**: 6 years minimum
1058
+ - **Financial services**: 7 years typical
1059
+
1060
+ **Storage recommendations:**
1061
+
1062
+ 1. Commit `audit.pubkey.asc` (GPG) to repository
1063
+ 2. Store KMS key ARNs in compliance documentation
1064
+ 3. Archive signatures with audit manifests
1065
+ 4. Maintain key rotation history
1066
+
1067
+ ### Key Archival
1068
+
1069
+ When rotating keys:
1070
+
1071
+ ```bash
1072
+ # Archive old public key
1073
+ mkdir -p audit/keys/archived
1074
+ mv audit.pubkey.asc audit/keys/archived/audit-key-2025-01-01.asc
1075
+ git add audit/keys/archived/
1076
+ git commit -m "Archive audit signing key (rotated)"
1077
+ ```
1078
+
1079
+ ## Security Best Practices
1080
+
1081
+ ### KMS
1082
+
1083
+ 1. **Enable key rotation**: Automatic yearly rotation
1084
+ 2. **Use separate keys**: Don't reuse encryption keys for signing
1085
+ 3. **Restrict permissions**: Principle of least privilege
1086
+ 4. **Enable CloudTrail**: Log all KMS operations
1087
+ 5. **Use resource tags**: Track key usage and ownership
1088
+
1089
+ ### GPG
1090
+
1091
+ 1. **Use strong keys**: RSA 2048+ or ECC
1092
+ 2. **Set expiration**: 2-year maximum
1093
+ 3. **Protect private keys**: Encrypt with passphrase
1094
+ 4. **Revoke compromised keys**: Publish revocation certificate
1095
+ 5. **Backup keys securely**: Use hardware security module or vault
1096
+
1097
+ ## Troubleshooting
1098
+
1099
+ ### KMS Signing Fails
1100
+
1101
+ ```bash
1102
+ # Check AWS credentials
1103
+ aws sts get-caller-identity
1104
+
1105
+ # Verify key exists and permissions
1106
+ aws kms describe-key --key-id $KEY_ARN
1107
+ aws kms get-key-policy --key-id $KEY_ARN --policy-name default
1108
+
1109
+ # Test signing directly
1110
+ echo "test" | aws kms sign \
1111
+ --key-id $KEY_ARN \
1112
+ --message-type RAW \
1113
+ --signing-algorithm RSASSA_PSS_SHA_256 \
1114
+ --message fileb:///dev/stdin
1115
+ ```
1116
+
1117
+ ### GPG Signing Fails
1118
+
1119
+ ```bash
1120
+ # Check GPG version
1121
+ gpg --version
1122
+
1123
+ # List available keys
1124
+ gpg --list-secret-keys
1125
+
1126
+ # Test signing
1127
+ echo "test" | gpg --clearsign --local-user $GPG_FPR
1128
+ ```
1129
+
1130
+ ### Verification Fails
1131
+
1132
+ ```bash
1133
+ # Check manifest hash
1134
+ sha256sum audit-manifest.json
1135
+
1136
+ # Verify metadata matches
1137
+ cat audit.sig.meta | jq .manifest_sha256
1138
+
1139
+ # Check signature file exists
1140
+ ls -lh audit.sig audit.sig.meta
1141
+ ```
1142
+
1143
+ ## Example Workflows
1144
+
1145
+ ### Complete Signing Workflow (AWS)
1146
+
1147
+ ```bash
1148
+ #!/bin/bash
1149
+ set -e
1150
+
1151
+ # Configuration
1152
+ PLAN_FILE="plan.json"
1153
+ KMS_KEY_ARN="arn:aws:kms:us-east-1:123456789012:key/abcd-1234"
1154
+ AUDIT_LEVEL="soc2"
1155
+
1156
+ # Execute with signing
1157
+ lex-pr execute \
1158
+ --plan "$PLAN_FILE" \
1159
+ --audit "$AUDIT_LEVEL" \
1160
+ --audit-signer "kms:$KMS_KEY_ARN"
1161
+
1162
+ # Verify signature
1163
+ lex-pr audit verify --manifest audit-manifest.json
1164
+
1165
+ # Archive results
1166
+ tar czf "audit-$(date +%Y%m%d-%H%M%S).tar.gz" \
1167
+ audit-manifest.json \
1168
+ audit.sig \
1169
+ audit.sig.meta
1170
+
1171
+ echo "Audit manifest signed and verified successfully"
1172
+ ```
1173
+
1174
+ ### Complete Signing Workflow (GPG)
1175
+
1176
+ ```bash
1177
+ #!/bin/bash
1178
+ set -e
1179
+
1180
+ # Configuration
1181
+ PLAN_FILE="plan.json"
1182
+ GPG_FPR="ABCD1234ABCD1234ABCD1234ABCD1234ABCD1234"
1183
+ AUDIT_LEVEL="basic"
1184
+
1185
+ # Import GPG key (if not already imported)
1186
+ if [ -n "$GPG_PRIVATE_KEY" ]; then
1187
+ echo "$GPG_PRIVATE_KEY" | gpg --batch --import
1188
+ fi
1189
+
1190
+ # Execute with signing
1191
+ lex-pr execute \
1192
+ --plan "$PLAN_FILE" \
1193
+ --audit "$AUDIT_LEVEL" \
1194
+ --audit-signer "gpg:$GPG_FPR"
1195
+
1196
+ # Verify signature
1197
+ lex-pr audit verify --manifest audit-manifest.json
1198
+
1199
+ # Archive with public key
1200
+ tar czf "audit-$(date +%Y%m%d-%H%M%S).tar.gz" \
1201
+ audit-manifest.json \
1202
+ audit.sig \
1203
+ audit.sig.meta \
1204
+ audit.pubkey.asc
1205
+
1206
+ echo "Audit manifest signed and verified successfully"
1207
+ ```
1208
+
1209
+ ## Related Documentation
1210
+
1211
+ - [Phase 1: Core Emitter](./audit-outputs.md) - Audit manifest generation
1212
+ - [Security Implementation](./SECURITY_IMPLEMENTATION.md) - Overall security architecture
1213
+ - [CI/CD Integration](./ci-cd-integration.md) - Pipeline setup examples