@backendkit-labs/agent-coding 0.28.5 → 0.29.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 (288) hide show
  1. package/dist/__tests__/context-hooks.test.d.ts +2 -0
  2. package/dist/__tests__/context-hooks.test.d.ts.map +1 -0
  3. package/dist/__tests__/context-hooks.test.js +21 -0
  4. package/dist/__tests__/context-hooks.test.js.map +1 -0
  5. package/dist/__tests__/sandbox.test.js +1 -1
  6. package/dist/__tests__/sandbox.test.js.map +1 -1
  7. package/dist/context-hooks.d.ts +11 -0
  8. package/dist/context-hooks.d.ts.map +1 -0
  9. package/dist/context-hooks.js +23 -0
  10. package/dist/context-hooks.js.map +1 -0
  11. package/dist/context-services.d.ts +12 -0
  12. package/dist/context-services.d.ts.map +1 -0
  13. package/dist/context-services.js +20 -0
  14. package/dist/context-services.js.map +1 -0
  15. package/dist/index.d.ts +5 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +21 -8
  18. package/dist/index.js.map +1 -1
  19. package/dist/orchestration/capability-matrix.d.ts +1 -1
  20. package/dist/orchestration/capability-matrix.d.ts.map +1 -1
  21. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts +2 -0
  22. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts.map +1 -0
  23. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js +42 -0
  24. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js.map +1 -0
  25. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts +2 -0
  26. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts.map +1 -0
  27. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js +64 -0
  28. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js.map +1 -0
  29. package/dist/pipeline/__tests__/engine-brief.test.d.ts +2 -0
  30. package/dist/pipeline/__tests__/engine-brief.test.d.ts.map +1 -0
  31. package/dist/pipeline/__tests__/engine-brief.test.js +159 -0
  32. package/dist/pipeline/__tests__/engine-brief.test.js.map +1 -0
  33. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts +2 -0
  34. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts.map +1 -0
  35. package/dist/pipeline/__tests__/qa-orchestrator.test.js +276 -0
  36. package/dist/pipeline/__tests__/qa-orchestrator.test.js.map +1 -0
  37. package/dist/pipeline/coding-pipeline-hooks.d.ts +28 -0
  38. package/dist/pipeline/coding-pipeline-hooks.d.ts.map +1 -0
  39. package/dist/pipeline/coding-pipeline-hooks.js +91 -0
  40. package/dist/pipeline/coding-pipeline-hooks.js.map +1 -0
  41. package/dist/pipeline/index.d.ts +13 -0
  42. package/dist/pipeline/index.d.ts.map +1 -0
  43. package/dist/pipeline/index.js +44 -0
  44. package/dist/pipeline/index.js.map +1 -0
  45. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts +11 -0
  46. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts.map +1 -0
  47. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js +105 -0
  48. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js.map +1 -0
  49. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts +2 -0
  50. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts.map +1 -0
  51. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js +21 -0
  52. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js.map +1 -0
  53. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts +9 -0
  54. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts.map +1 -0
  55. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js +101 -0
  56. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js.map +1 -0
  57. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts +2 -0
  58. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts.map +1 -0
  59. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js +54 -0
  60. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js.map +1 -0
  61. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts +2 -0
  62. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts.map +1 -0
  63. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js +57 -0
  64. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js.map +1 -0
  65. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts +9 -0
  66. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts.map +1 -0
  67. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js +43 -0
  68. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js.map +1 -0
  69. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts +10 -0
  70. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts.map +1 -0
  71. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js +264 -0
  72. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js.map +1 -0
  73. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts +31 -0
  74. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts.map +1 -0
  75. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js +120 -0
  76. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js.map +1 -0
  77. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts +33 -0
  78. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts.map +1 -0
  79. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js +126 -0
  80. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js.map +1 -0
  81. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts +27 -0
  82. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts.map +1 -0
  83. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js +155 -0
  84. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js.map +1 -0
  85. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts +21 -0
  86. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts.map +1 -0
  87. package/dist/pipeline/orchestration/audit/audit-pending-issues.js +110 -0
  88. package/dist/pipeline/orchestration/audit/audit-pending-issues.js.map +1 -0
  89. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts +39 -0
  90. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts.map +1 -0
  91. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js +65 -0
  92. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js.map +1 -0
  93. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts +30 -0
  94. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts.map +1 -0
  95. package/dist/pipeline/orchestration/audit/audit-report-renderer.js +249 -0
  96. package/dist/pipeline/orchestration/audit/audit-report-renderer.js.map +1 -0
  97. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts +52 -0
  98. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts.map +1 -0
  99. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js +144 -0
  100. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js.map +1 -0
  101. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts +37 -0
  102. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts.map +1 -0
  103. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js +129 -0
  104. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js.map +1 -0
  105. package/dist/pipeline/orchestration/audit/index.d.ts +17 -0
  106. package/dist/pipeline/orchestration/audit/index.d.ts.map +1 -0
  107. package/dist/pipeline/orchestration/audit/index.js +26 -0
  108. package/dist/pipeline/orchestration/audit/index.js.map +1 -0
  109. package/dist/pipeline/orchestration/audit/types.d.ts +79 -0
  110. package/dist/pipeline/orchestration/audit/types.d.ts.map +1 -0
  111. package/dist/pipeline/orchestration/audit/types.js +10 -0
  112. package/dist/pipeline/orchestration/audit/types.js.map +1 -0
  113. package/dist/pipeline/orchestration/audit-reporter.d.ts +133 -0
  114. package/dist/pipeline/orchestration/audit-reporter.d.ts.map +1 -0
  115. package/dist/pipeline/orchestration/audit-reporter.js +322 -0
  116. package/dist/pipeline/orchestration/audit-reporter.js.map +1 -0
  117. package/dist/pipeline/orchestration/config-loader.d.ts +51 -0
  118. package/dist/pipeline/orchestration/config-loader.d.ts.map +1 -0
  119. package/dist/pipeline/orchestration/config-loader.js +215 -0
  120. package/dist/pipeline/orchestration/config-loader.js.map +1 -0
  121. package/dist/pipeline/orchestration/domain-detector.d.ts +36 -0
  122. package/dist/pipeline/orchestration/domain-detector.d.ts.map +1 -0
  123. package/dist/pipeline/orchestration/domain-detector.js +157 -0
  124. package/dist/pipeline/orchestration/domain-detector.js.map +1 -0
  125. package/dist/pipeline/orchestration/fsm.d.ts +92 -0
  126. package/dist/pipeline/orchestration/fsm.d.ts.map +1 -0
  127. package/dist/pipeline/orchestration/fsm.js +243 -0
  128. package/dist/pipeline/orchestration/fsm.js.map +1 -0
  129. package/dist/pipeline/orchestration/gate-resolver.d.ts +52 -0
  130. package/dist/pipeline/orchestration/gate-resolver.d.ts.map +1 -0
  131. package/dist/pipeline/orchestration/gate-resolver.js +120 -0
  132. package/dist/pipeline/orchestration/gate-resolver.js.map +1 -0
  133. package/dist/pipeline/orchestration/index.d.ts +16 -0
  134. package/dist/pipeline/orchestration/index.d.ts.map +1 -0
  135. package/dist/pipeline/orchestration/index.js +32 -0
  136. package/dist/pipeline/orchestration/index.js.map +1 -0
  137. package/dist/pipeline/orchestration/intent-detector.d.ts +37 -0
  138. package/dist/pipeline/orchestration/intent-detector.d.ts.map +1 -0
  139. package/dist/pipeline/orchestration/intent-detector.js +248 -0
  140. package/dist/pipeline/orchestration/intent-detector.js.map +1 -0
  141. package/dist/pipeline/orchestration/keyword-match.d.ts +17 -0
  142. package/dist/pipeline/orchestration/keyword-match.d.ts.map +1 -0
  143. package/dist/pipeline/orchestration/keyword-match.js +26 -0
  144. package/dist/pipeline/orchestration/keyword-match.js.map +1 -0
  145. package/dist/pipeline/orchestration/orchestrator.d.ts +158 -0
  146. package/dist/pipeline/orchestration/orchestrator.d.ts.map +1 -0
  147. package/dist/pipeline/orchestration/orchestrator.js +414 -0
  148. package/dist/pipeline/orchestration/orchestrator.js.map +1 -0
  149. package/dist/pipeline/orchestration/policy-engine.d.ts +54 -0
  150. package/dist/pipeline/orchestration/policy-engine.d.ts.map +1 -0
  151. package/dist/pipeline/orchestration/policy-engine.js +278 -0
  152. package/dist/pipeline/orchestration/policy-engine.js.map +1 -0
  153. package/dist/pipeline/orchestration/risk-scorer.d.ts +38 -0
  154. package/dist/pipeline/orchestration/risk-scorer.d.ts.map +1 -0
  155. package/dist/pipeline/orchestration/risk-scorer.js +145 -0
  156. package/dist/pipeline/orchestration/risk-scorer.js.map +1 -0
  157. package/dist/pipeline/orchestration/task-context.d.ts +205 -0
  158. package/dist/pipeline/orchestration/task-context.d.ts.map +1 -0
  159. package/dist/pipeline/orchestration/task-context.js +162 -0
  160. package/dist/pipeline/orchestration/task-context.js.map +1 -0
  161. package/dist/pipeline/orchestration/types.d.ts +111 -0
  162. package/dist/pipeline/orchestration/types.d.ts.map +1 -0
  163. package/dist/pipeline/orchestration/types.js +37 -0
  164. package/dist/pipeline/orchestration/types.js.map +1 -0
  165. package/dist/pipeline/qa/__tests__/QAService.test.d.ts +2 -0
  166. package/dist/pipeline/qa/__tests__/QAService.test.d.ts.map +1 -0
  167. package/dist/pipeline/qa/__tests__/QAService.test.js +170 -0
  168. package/dist/pipeline/qa/__tests__/QAService.test.js.map +1 -0
  169. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts +2 -0
  170. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts.map +1 -0
  171. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js +39 -0
  172. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js.map +1 -0
  173. package/dist/pipeline/qa/index.d.ts +3 -0
  174. package/dist/pipeline/qa/index.d.ts.map +1 -0
  175. package/dist/pipeline/qa/index.js +6 -0
  176. package/dist/pipeline/qa/index.js.map +1 -0
  177. package/dist/pipeline/qa/qa-service.d.ts +33 -0
  178. package/dist/pipeline/qa/qa-service.d.ts.map +1 -0
  179. package/dist/pipeline/qa/qa-service.js +239 -0
  180. package/dist/pipeline/qa/qa-service.js.map +1 -0
  181. package/dist/pipeline/qa-orchestrator.d.ts +60 -0
  182. package/dist/pipeline/qa-orchestrator.d.ts.map +1 -0
  183. package/dist/pipeline/qa-orchestrator.js +177 -0
  184. package/dist/pipeline/qa-orchestrator.js.map +1 -0
  185. package/dist/pipeline/reflection/domains/agent-domain.d.ts +40 -0
  186. package/dist/pipeline/reflection/domains/agent-domain.d.ts.map +1 -0
  187. package/dist/pipeline/reflection/domains/agent-domain.js +161 -0
  188. package/dist/pipeline/reflection/domains/agent-domain.js.map +1 -0
  189. package/dist/pipeline/reflection/domains/audit-domain.d.ts +46 -0
  190. package/dist/pipeline/reflection/domains/audit-domain.d.ts.map +1 -0
  191. package/dist/pipeline/reflection/domains/audit-domain.js +241 -0
  192. package/dist/pipeline/reflection/domains/audit-domain.js.map +1 -0
  193. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts +40 -0
  194. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts.map +1 -0
  195. package/dist/pipeline/reflection/domains/bootstrap-domain.js +156 -0
  196. package/dist/pipeline/reflection/domains/bootstrap-domain.js.map +1 -0
  197. package/dist/pipeline/reflection/domains/commit-domain.d.ts +40 -0
  198. package/dist/pipeline/reflection/domains/commit-domain.d.ts.map +1 -0
  199. package/dist/pipeline/reflection/domains/commit-domain.js +174 -0
  200. package/dist/pipeline/reflection/domains/commit-domain.js.map +1 -0
  201. package/dist/pipeline/reflection/domains/test-domain.d.ts +40 -0
  202. package/dist/pipeline/reflection/domains/test-domain.d.ts.map +1 -0
  203. package/dist/pipeline/reflection/domains/test-domain.js +194 -0
  204. package/dist/pipeline/reflection/domains/test-domain.js.map +1 -0
  205. package/dist/pipeline/reflection/historical-loader.d.ts +105 -0
  206. package/dist/pipeline/reflection/historical-loader.d.ts.map +1 -0
  207. package/dist/pipeline/reflection/historical-loader.js +462 -0
  208. package/dist/pipeline/reflection/historical-loader.js.map +1 -0
  209. package/dist/pipeline/reflection/hooks/agent-hook.d.ts +72 -0
  210. package/dist/pipeline/reflection/hooks/agent-hook.d.ts.map +1 -0
  211. package/dist/pipeline/reflection/hooks/agent-hook.js +98 -0
  212. package/dist/pipeline/reflection/hooks/agent-hook.js.map +1 -0
  213. package/dist/pipeline/reflection/hooks/audit-hook.d.ts +72 -0
  214. package/dist/pipeline/reflection/hooks/audit-hook.d.ts.map +1 -0
  215. package/dist/pipeline/reflection/hooks/audit-hook.js +112 -0
  216. package/dist/pipeline/reflection/hooks/audit-hook.js.map +1 -0
  217. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts +71 -0
  218. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts.map +1 -0
  219. package/dist/pipeline/reflection/hooks/bootstrap-hook.js +97 -0
  220. package/dist/pipeline/reflection/hooks/bootstrap-hook.js.map +1 -0
  221. package/dist/pipeline/reflection/hooks/commit-hook.d.ts +63 -0
  222. package/dist/pipeline/reflection/hooks/commit-hook.d.ts.map +1 -0
  223. package/dist/pipeline/reflection/hooks/commit-hook.js +90 -0
  224. package/dist/pipeline/reflection/hooks/commit-hook.js.map +1 -0
  225. package/dist/pipeline/reflection/hooks/test-hook.d.ts +65 -0
  226. package/dist/pipeline/reflection/hooks/test-hook.d.ts.map +1 -0
  227. package/dist/pipeline/reflection/hooks/test-hook.js +99 -0
  228. package/dist/pipeline/reflection/hooks/test-hook.js.map +1 -0
  229. package/dist/pipeline/reflection/lessons-memo-generator.d.ts +60 -0
  230. package/dist/pipeline/reflection/lessons-memo-generator.d.ts.map +1 -0
  231. package/dist/pipeline/reflection/lessons-memo-generator.js +286 -0
  232. package/dist/pipeline/reflection/lessons-memo-generator.js.map +1 -0
  233. package/dist/store/ProjectStore.d.ts +1 -1
  234. package/dist/store/ProjectStore.d.ts.map +1 -1
  235. package/dist/store/types.d.ts +28 -0
  236. package/dist/store/types.d.ts.map +1 -0
  237. package/dist/store/types.js +3 -0
  238. package/dist/store/types.js.map +1 -0
  239. package/dist/tools/__tests__/command-parser.test.js +1 -1
  240. package/dist/tools/__tests__/command-parser.test.js.map +1 -1
  241. package/dist/tools/__tests__/declared-facts.test.d.ts +2 -0
  242. package/dist/tools/__tests__/declared-facts.test.d.ts.map +1 -0
  243. package/dist/tools/__tests__/declared-facts.test.js +21 -0
  244. package/dist/tools/__tests__/declared-facts.test.js.map +1 -0
  245. package/dist/tools/__tests__/package-install.test.d.ts +2 -0
  246. package/dist/tools/__tests__/package-install.test.d.ts.map +1 -0
  247. package/dist/tools/__tests__/package-install.test.js +56 -0
  248. package/dist/tools/__tests__/package-install.test.js.map +1 -0
  249. package/dist/tools/__tests__/save-tools.secrets.test.js +1 -1
  250. package/dist/tools/__tests__/save-tools.secrets.test.js.map +1 -1
  251. package/dist/tools/edit-file.d.ts.map +1 -1
  252. package/dist/tools/edit-file.js +1 -0
  253. package/dist/tools/edit-file.js.map +1 -1
  254. package/dist/tools/list-directory.d.ts.map +1 -1
  255. package/dist/tools/list-directory.js +1 -0
  256. package/dist/tools/list-directory.js.map +1 -1
  257. package/dist/tools/package-install.d.ts +11 -0
  258. package/dist/tools/package-install.d.ts.map +1 -0
  259. package/dist/tools/package-install.js +112 -0
  260. package/dist/tools/package-install.js.map +1 -0
  261. package/dist/tools/read-file.d.ts.map +1 -1
  262. package/dist/tools/read-file.js +1 -0
  263. package/dist/tools/read-file.js.map +1 -1
  264. package/dist/tools/run-command.d.ts.map +1 -1
  265. package/dist/tools/run-command.js +5 -1
  266. package/dist/tools/run-command.js.map +1 -1
  267. package/dist/tools/save-audit.d.ts.map +1 -1
  268. package/dist/tools/save-audit.js +7 -6
  269. package/dist/tools/save-audit.js.map +1 -1
  270. package/dist/tools/save-context.d.ts.map +1 -1
  271. package/dist/tools/save-context.js +3 -2
  272. package/dist/tools/save-context.js.map +1 -1
  273. package/dist/tools/save-learning.d.ts.map +1 -1
  274. package/dist/tools/save-learning.js +4 -3
  275. package/dist/tools/save-learning.js.map +1 -1
  276. package/dist/tools/save-user-preference.d.ts.map +1 -1
  277. package/dist/tools/save-user-preference.js +3 -2
  278. package/dist/tools/save-user-preference.js.map +1 -1
  279. package/dist/tools/search-files.d.ts.map +1 -1
  280. package/dist/tools/search-files.js +1 -0
  281. package/dist/tools/search-files.js.map +1 -1
  282. package/dist/tools/update-session.d.ts.map +1 -1
  283. package/dist/tools/update-session.js +3 -2
  284. package/dist/tools/update-session.js.map +1 -1
  285. package/dist/tools/write-file.d.ts.map +1 -1
  286. package/dist/tools/write-file.js +1 -0
  287. package/dist/tools/write-file.js.map +1 -1
  288. package/package.json +63 -44
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ /**
3
+ * Integration test: PolicyPromoter → manifest.yaml → Orchestrator.loadManifestPolicyRules → applyPolicies
4
+ *
5
+ * Verifies the closed feedback loop:
6
+ * 1. ReflectionEngine promotes a detected pattern to manifest.yaml via PolicyPromoter
7
+ * 2. Orchestrator reads manifest.yaml on every orchestrate() call (PolicyStep)
8
+ * 3. The promoted rule fires for matching input and enriches the task context
9
+ */
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
23
+ }) : function(o, v) {
24
+ o["default"] = v;
25
+ });
26
+ var __importStar = (this && this.__importStar) || (function () {
27
+ var ownKeys = function(o) {
28
+ ownKeys = Object.getOwnPropertyNames || function (o) {
29
+ var ar = [];
30
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
+ return ar;
32
+ };
33
+ return ownKeys(o);
34
+ };
35
+ return function (mod) {
36
+ if (mod && mod.__esModule) return mod;
37
+ var result = {};
38
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ })();
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ const os = __importStar(require("os"));
45
+ const path = __importStar(require("path"));
46
+ const fs = __importStar(require("fs/promises"));
47
+ const yaml = __importStar(require("yaml"));
48
+ const agent_core_1 = require("@backendkit-labs/agent-core");
49
+ const orchestrator_1 = require("../orchestrator");
50
+ const policy_engine_1 = require("../policy-engine");
51
+ // ── Fixtures ──────────────────────────────────────────────────────────────────
52
+ let tmpHome;
53
+ const APP_NAME = 'test-reflection-app';
54
+ beforeEach(async () => {
55
+ tmpHome = await fs.mkdtemp(path.join(os.tmpdir(), 'reflection-cycle-'));
56
+ process.env.USERPROFILE = tmpHome;
57
+ process.env.HOME = tmpHome;
58
+ });
59
+ afterEach(async () => {
60
+ await fs.rm(tmpHome, { recursive: true, force: true });
61
+ delete process.env.USERPROFILE;
62
+ delete process.env.HOME;
63
+ });
64
+ function manifestPath() {
65
+ return path.join(tmpHome, `.${APP_NAME}`, 'manifest.yaml');
66
+ }
67
+ function makePattern(overrides = {}) {
68
+ return {
69
+ domain: 'audit',
70
+ failureType: 'security_vulnerability',
71
+ count: 4,
72
+ severity: 'high',
73
+ firstSeen: new Date().toISOString(),
74
+ lastSeen: new Date().toISOString(),
75
+ recordIds: [],
76
+ dominantDimension: 'security',
77
+ dominantGate: 'qa',
78
+ recommendedAction: 'Add security review',
79
+ promotedToPolicy: false,
80
+ ...overrides,
81
+ };
82
+ }
83
+ /** Minimal orchestrator config with only policyEngine enabled (no LLM steps). */
84
+ const MINIMAL_CONFIG = {
85
+ features: {
86
+ intentDetection: false,
87
+ domainDetection: false,
88
+ riskScoring: false,
89
+ policyEngine: true,
90
+ fsm: false,
91
+ qaGate: false,
92
+ commitGate: false,
93
+ },
94
+ riskThresholds: { low: 10, medium: 30, high: 60, critical: 80 },
95
+ riskWeights: {
96
+ breaking_change: 25,
97
+ security_sensitive: 30,
98
+ cross_service_impact: 20,
99
+ db_transactional: 15,
100
+ production_critical: 25,
101
+ complexity: 1,
102
+ },
103
+ };
104
+ // ── PolicyPromoter ────────────────────────────────────────────────────────────
105
+ describe('PolicyPromoter — writes manifest.yaml', () => {
106
+ it('creates manifest.yaml with a policyRules entry', async () => {
107
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
108
+ const rule = await promoter.promote(makePattern());
109
+ expect(rule.id).toMatch(/^POL-AUDI-\d+$/);
110
+ expect(rule.autoGenerated).toBe(true);
111
+ const content = await fs.readFile(manifestPath(), 'utf-8');
112
+ const manifest = yaml.parse(content);
113
+ expect(manifest.policyRules).toHaveLength(1);
114
+ expect(manifest.policyRules[0].id).toBe(rule.id);
115
+ });
116
+ it('promoted rule has if.keywords derived from the failureType', async () => {
117
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
118
+ const rule = await promoter.promote(makePattern({ failureType: 'security_vulnerability' }));
119
+ // Keywords for 'security_vulnerability' include 'auth', 'jwt', 'seguridad'
120
+ expect(rule.if.keywords).toBeDefined();
121
+ expect(rule.if.keywords.length).toBeGreaterThan(0);
122
+ });
123
+ it('idempotent — promoting same pattern twice updates, does not duplicate', async () => {
124
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
125
+ const rule1 = await promoter.promote(makePattern({ failureType: 'jest_timeout', domain: 'test' }));
126
+ await promoter.promote(makePattern({ failureType: 'jest_timeout', domain: 'test' }), rule1.id);
127
+ const manifest = await promoter.readManifest();
128
+ const rules = manifest.policyRules ?? [];
129
+ expect(rules.filter(r => r.id === rule1.id)).toHaveLength(1);
130
+ });
131
+ it('accumulates multiple distinct patterns as separate rules', async () => {
132
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
133
+ await promoter.promote(makePattern({ failureType: 'missing_rollback' }));
134
+ await promoter.promote(makePattern({ domain: 'test', failureType: 'coverage_below_threshold', severity: 'medium' }));
135
+ const rules = await promoter.getExistingRules();
136
+ expect(rules).toHaveLength(2);
137
+ });
138
+ it('updateOutcome records success/failure counts', async () => {
139
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
140
+ const rule = await promoter.promote(makePattern({ failureType: 'missing_logging', severity: 'medium' }));
141
+ await promoter.updateOutcome(rule.id, 'success');
142
+ await promoter.updateOutcome(rule.id, 'failure');
143
+ await promoter.updateOutcome(rule.id, 'success');
144
+ const updated = await promoter.getRuleById(rule.id);
145
+ expect(updated?.outcomes?.success).toBe(2);
146
+ expect(updated?.outcomes?.failure).toBe(1);
147
+ });
148
+ it('removeRule deletes a rule by id', async () => {
149
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
150
+ const rule = await promoter.promote(makePattern());
151
+ await promoter.removeRule(rule.id);
152
+ const rules = await promoter.getExistingRules();
153
+ expect(rules.find(r => r.id === rule.id)).toBeUndefined();
154
+ });
155
+ });
156
+ // ── Orchestrator reads manifest on each orchestrate() ─────────────────────────
157
+ describe('Orchestrator — loadManifestPolicyRules picks up promoted rules', () => {
158
+ it('applies a manifest rule with keyword matching to the user input', async () => {
159
+ // Write a rule directly to manifest.yaml
160
+ const manifestDir = path.join(tmpHome, `.${APP_NAME}`);
161
+ await fs.mkdir(manifestDir, { recursive: true });
162
+ const rule = {
163
+ id: 'POL-AUDI-001',
164
+ name: 'Test Security Rule',
165
+ if: { keywords: ['vulnerabilidad-test-unica', 'test-security-keyword'] },
166
+ then: { requireQaApproval: true, mustInclude: ['security-agent'] },
167
+ trigger: { domain: 'audit', pattern: 'security_vulnerability', minOccurrences: 3 },
168
+ autoGenerated: true,
169
+ createdAt: new Date().toISOString(),
170
+ engineVersion: '1.0.0',
171
+ };
172
+ await fs.writeFile(path.join(manifestDir, 'manifest.yaml'), yaml.stringify({ policyRules: [rule] }));
173
+ const orchestrator = new orchestrator_1.Orchestrator({ appName: APP_NAME, config: MINIMAL_CONFIG });
174
+ const result = await orchestrator.orchestrate('hay una vulnerabilidad-test-unica en el sistema');
175
+ // The promoted rule must fire: qa approval + security agent
176
+ expect(result.task.requiresQaApproval).toBe(true);
177
+ expect(result.selectedAgents.some(a => a.agentId === 'security-agent')).toBe(true);
178
+ });
179
+ it('does not fire a rule when input has no matching keyword', async () => {
180
+ const manifestDir = path.join(tmpHome, `.${APP_NAME}`);
181
+ await fs.mkdir(manifestDir, { recursive: true });
182
+ const rule = {
183
+ id: 'POL-AUDI-001',
184
+ name: 'Specific keyword rule',
185
+ if: { keywords: ['keyword-muy-especifico-xyz'] },
186
+ then: { requireQaApproval: true },
187
+ trigger: { domain: 'audit', pattern: 'security_vulnerability', minOccurrences: 3 },
188
+ autoGenerated: true,
189
+ createdAt: new Date().toISOString(),
190
+ engineVersion: '1.0.0',
191
+ };
192
+ await fs.writeFile(path.join(manifestDir, 'manifest.yaml'), yaml.stringify({ policyRules: [rule] }));
193
+ const orchestrator = new orchestrator_1.Orchestrator({ appName: APP_NAME, config: MINIMAL_CONFIG });
194
+ const result = await orchestrator.orchestrate('write a unit test for the login feature');
195
+ const manifestRuleFired = result.appliedPolicies.some(p => p.rule.includes('keyword-muy-especifico-xyz'));
196
+ expect(manifestRuleFired).toBe(false);
197
+ });
198
+ it('does not throw when manifest does not exist — returns empty rules', async () => {
199
+ const orchestrator = new orchestrator_1.Orchestrator({ appName: APP_NAME, config: MINIMAL_CONFIG });
200
+ // No manifest file written — should silently return []
201
+ await expect(orchestrator.orchestrate('simple question')).resolves.toBeDefined();
202
+ });
203
+ it('picks up newly promoted rules on subsequent orchestrate() calls (no caching)', async () => {
204
+ const promoter = new agent_core_1.PolicyPromoter({ appName: APP_NAME });
205
+ const orchestrator = new orchestrator_1.Orchestrator({ appName: APP_NAME, config: MINIMAL_CONFIG });
206
+ // First call — no rules yet
207
+ await expect(orchestrator.orchestrate('transaccion y rollback')).resolves.toBeDefined();
208
+ // Promote a pattern after the first call
209
+ await promoter.promote(makePattern({ failureType: 'missing_rollback' }));
210
+ // Second call — manifest now has the rule; it should load fresh
211
+ const after = await orchestrator.orchestrate('transaccion y rollback');
212
+ expect(after).toBeDefined();
213
+ // Verify the manifest was written with one rule
214
+ const rules = await promoter.getExistingRules();
215
+ expect(rules).toHaveLength(1);
216
+ });
217
+ });
218
+ // ── evaluatePolicies — unit tests for keyword matching ────────────────────────
219
+ describe('evaluatePolicies — keyword matching in manifest-derived rules', () => {
220
+ it('fires a keyword-based rule when input contains a matching keyword', () => {
221
+ const { createTaskContext } = require('../task-context');
222
+ const task = createTaskContext('quiero revisar el jwt token');
223
+ const rules = [
224
+ {
225
+ if: { keywords: ['jwt', 'auth', 'oauth'] },
226
+ then: { requireQaApproval: true, mustInclude: ['security-agent'] },
227
+ },
228
+ ];
229
+ const result = (0, policy_engine_1.evaluatePolicies)(task, rules, 'quiero revisar el jwt token');
230
+ expect(result.requiredGates).toContain('qa');
231
+ expect(result.mustInclude).toContain('security-agent');
232
+ });
233
+ it('does not fire when input has no matching keyword', () => {
234
+ const { createTaskContext } = require('../task-context');
235
+ const task = createTaskContext('refactor the pagination logic');
236
+ const rules = [
237
+ {
238
+ if: { keywords: ['jwt', 'auth', 'oauth'] },
239
+ then: { requireQaApproval: true, mustInclude: ['security-agent'] },
240
+ },
241
+ ];
242
+ const result = (0, policy_engine_1.evaluatePolicies)(task, rules, 'refactor the pagination logic');
243
+ expect(result.mustInclude).not.toContain('security-agent');
244
+ });
245
+ it('keyword matching is case-insensitive', () => {
246
+ const { createTaskContext } = require('../task-context');
247
+ const task = createTaskContext('fix JWT validation');
248
+ const rules = [{ if: { keywords: ['jwt'] }, then: { requireQaApproval: true } }];
249
+ const result = (0, policy_engine_1.evaluatePolicies)(task, rules, 'fix JWT validation');
250
+ expect(result.requiredGates).toContain('qa');
251
+ });
252
+ it('applies multiple rules when all conditions match', () => {
253
+ const { createTaskContext } = require('../task-context');
254
+ const task = createTaskContext('security auth review');
255
+ const rules = [
256
+ { if: { keywords: ['auth'] }, then: { mustInclude: ['security-agent'] } },
257
+ { if: { keywords: ['review'] }, then: { mustInclude: ['qa-engineer'] } },
258
+ ];
259
+ const result = (0, policy_engine_1.evaluatePolicies)(task, rules, 'security auth review');
260
+ expect(result.mustInclude).toContain('security-agent');
261
+ expect(result.mustInclude).toContain('qa-engineer');
262
+ });
263
+ });
264
+ //# sourceMappingURL=reflection-cycle.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflection-cycle.test.js","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/__tests__/reflection-cycle.test.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,gDAAkC;AAClC,2CAA6B;AAC7B,4DAA6D;AAC7D,kDAA+C;AAC/C,oDAAoD;AAIpD,iFAAiF;AAEjF,IAAI,OAAe,CAAC;AACpB,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AAEvC,UAAU,CAAC,KAAK,IAAI,EAAE;IAClB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CA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,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QACxD,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG;YACV,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE;YACzE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE;SAC3E,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,gCAAgB,EAAC,IAAI,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;QACrE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @description AuditCiBlocker — Bloqueo de deploys en CI/CD.
3
+ *
4
+ * Verifica si hay hallazgos críticos/altos sin resolver y genera
5
+ * reportes de estado para pipelines de CI/CD.
6
+ *
7
+ * Útil para:
8
+ * - `audit check --block-on-critical` en CI
9
+ * - Generar reportes de estado para GitHub Actions / GitLab CI
10
+ * - Fallar el pipeline si hay issues abiertos
11
+ */
12
+ import { GateRecord, CiReport } from './types';
13
+ export declare class AuditCiBlocker {
14
+ private docsDir;
15
+ constructor(docsDir: string);
16
+ /**
17
+ * @description Verifica si hay hallazgos críticos/altos sin resolver.
18
+ * Busca tanto en memoria como en disco.
19
+ * Si retorna true, el pipeline CI/CD debe fallar.
20
+ *
21
+ * @param gates - Gates en memoria para verificar
22
+ */
23
+ hasCriticalOpenFindings(gates: GateRecord[]): Promise<boolean>;
24
+ /**
25
+ * @description Genera reporte de estado para CI/CD.
26
+ *
27
+ * @param gates - Gates en memoria para analizar
28
+ */
29
+ generateCiReport(gates: GateRecord[]): Promise<CiReport>;
30
+ }
31
+ //# sourceMappingURL=audit-ci-blocker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-ci-blocker.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/audit/audit-ci-blocker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI7D,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAI3B;;;;;;OAMG;IACG,uBAAuB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BpE;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;CA0B/D"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * @description AuditCiBlocker — Bloqueo de deploys en CI/CD.
4
+ *
5
+ * Verifica si hay hallazgos críticos/altos sin resolver y genera
6
+ * reportes de estado para pipelines de CI/CD.
7
+ *
8
+ * Útil para:
9
+ * - `audit check --block-on-critical` en CI
10
+ * - Generar reportes de estado para GitHub Actions / GitLab CI
11
+ * - Fallar el pipeline si hay issues abiertos
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.AuditCiBlocker = void 0;
48
+ const path = __importStar(require("path"));
49
+ const fs = __importStar(require("fs/promises"));
50
+ // ── AuditCiBlocker ───────────────────────────────────────────────────────────
51
+ class AuditCiBlocker {
52
+ docsDir;
53
+ constructor(docsDir) {
54
+ this.docsDir = docsDir;
55
+ }
56
+ /**
57
+ * @description Verifica si hay hallazgos críticos/altos sin resolver.
58
+ * Busca tanto en memoria como en disco.
59
+ * Si retorna true, el pipeline CI/CD debe fallar.
60
+ *
61
+ * @param gates - Gates en memoria para verificar
62
+ */
63
+ async hasCriticalOpenFindings(gates) {
64
+ try {
65
+ const files = await fs.readdir(this.docsDir);
66
+ // Buscar pending issues activos
67
+ if (files.some(f => f.startsWith('pending-issues') && f.endsWith('.md')))
68
+ return true;
69
+ // Buscar en informes finales y gates persistidos
70
+ for (const file of files) {
71
+ if (!file.endsWith('.md') || file.startsWith('auto-gates'))
72
+ continue;
73
+ const content = await fs.readFile(path.join(this.docsDir, file), 'utf-8');
74
+ const criticalMatches = (content.match(/\*\*(Crítica|Alta)\*\*/g) ?? []).length;
75
+ const resolvedMatches = (content.match(/Resuelto en commit/g) ?? []).length;
76
+ if (criticalMatches > resolvedMatches)
77
+ return true;
78
+ }
79
+ // Buscar en memoria
80
+ if (gates.some(g => g.hallazgos.some(h => (h.severidad === 'critical' || h.severidad === 'high') && !h.resolvedByCommit)))
81
+ return true;
82
+ return false;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ /**
89
+ * @description Genera reporte de estado para CI/CD.
90
+ *
91
+ * @param gates - Gates en memoria para analizar
92
+ */
93
+ async generateCiReport(gates) {
94
+ const criticalOpen = [];
95
+ const highOpen = [];
96
+ for (const gate of gates) {
97
+ for (const h of gate.hallazgos) {
98
+ if (!h.resolvedByCommit) {
99
+ if (h.severidad === 'critical')
100
+ criticalOpen.push(h);
101
+ else if (h.severidad === 'high')
102
+ highOpen.push(h);
103
+ }
104
+ }
105
+ }
106
+ const ok = criticalOpen.length === 0 && highOpen.length === 0;
107
+ const message = ok
108
+ ? '✅ No open critical or high findings. Deploy allowed.'
109
+ : `❌ ${criticalOpen.length} critical and ${highOpen.length} high finding(s) unresolved. Deploy blocked.`;
110
+ return {
111
+ ok,
112
+ criticalCount: criticalOpen.length,
113
+ highCount: highOpen.length,
114
+ findings: [...criticalOpen, ...highOpen],
115
+ message,
116
+ };
117
+ }
118
+ }
119
+ exports.AuditCiBlocker = AuditCiBlocker;
120
+ //# sourceMappingURL=audit-ci-blocker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-ci-blocker.js","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/audit/audit-ci-blocker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,gDAAkC;AAG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Trazabilidad hallazgo → commit.
3
+ *
4
+ * Permite marcar hallazgos de auditoría como resueltos, asociándolos
5
+ * con un commit SHA específico. Busca tanto en memoria como en disco
6
+ * para actualizar los registros persistidos.
7
+ */
8
+ import { GateRecord } from './types';
9
+ export declare class AuditFindingTracer {
10
+ private docsDir;
11
+ constructor(docsDir: string);
12
+ /**
13
+ * @description Marca un hallazgo como resuelto en memoria y en disco.
14
+ *
15
+ * @param gates - Lista de gates en memoria donde buscar
16
+ * @param findingId - ID del hallazgo a marcar
17
+ * @param commitHash - SHA del commit que lo resuelve
18
+ * @param commitMessage - Mensaje del commit (opcional)
19
+ * @returns true si se encontró y marcó el hallazgo
20
+ */
21
+ markResolved(gates: GateRecord[], findingId: string, commitHash: string, commitMessage?: string): Promise<boolean>;
22
+ /**
23
+ * @description Marca hallazgos como resueltos buscando por archivos modificados
24
+ * en el commit. Útil para hook post-commit.
25
+ *
26
+ * @param gates - Lista de gates en memoria
27
+ * @param commitHash - SHA del commit
28
+ * @param modifiedFiles - Archivos modificados en el commit
29
+ * @returns Cantidad de hallazgos resueltos
30
+ */
31
+ markResolvedByFiles(gates: GateRecord[], commitHash: string, modifiedFiles: string[]): Promise<number>;
32
+ }
33
+ //# sourceMappingURL=audit-finding-tracer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-finding-tracer.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/audit/audit-finding-tracer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAanD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAI3B;;;;;;;;OAQG;IACG,YAAY,CAChB,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC;IAqCnB;;;;;;;;OAQG;IACG,mBAAmB,CACvB,KAAK,EAAE,UAAU,EAAE,EACnB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC;CAanB"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /**
3
+ * @description AuditFindingTracer — Trazabilidad hallazgo → commit.
4
+ *
5
+ * Permite marcar hallazgos de auditoría como resueltos, asociándolos
6
+ * con un commit SHA específico. Busca tanto en memoria como en disco
7
+ * para actualizar los registros persistidos.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.AuditFindingTracer = void 0;
44
+ const path = __importStar(require("path"));
45
+ const fs = __importStar(require("fs/promises"));
46
+ // ── Helpers ──────────────────────────────────────────────────────────────────
47
+ function getFormattedDate() {
48
+ return new Date()
49
+ .toISOString()
50
+ .replace('T', ' ')
51
+ .replace(/\.\d{3}Z/, ' UTC');
52
+ }
53
+ // ── AuditFindingTracer ───────────────────────────────────────────────────────
54
+ class AuditFindingTracer {
55
+ docsDir;
56
+ constructor(docsDir) {
57
+ this.docsDir = docsDir;
58
+ }
59
+ /**
60
+ * @description Marca un hallazgo como resuelto en memoria y en disco.
61
+ *
62
+ * @param gates - Lista de gates en memoria donde buscar
63
+ * @param findingId - ID del hallazgo a marcar
64
+ * @param commitHash - SHA del commit que lo resuelve
65
+ * @param commitMessage - Mensaje del commit (opcional)
66
+ * @returns true si se encontró y marcó el hallazgo
67
+ */
68
+ async markResolved(gates, findingId, commitHash, commitMessage) {
69
+ let found = false;
70
+ const resolvedAt = getFormattedDate();
71
+ // En memoria
72
+ for (const gate of gates) {
73
+ for (const hallazgo of gate.hallazgos) {
74
+ if (hallazgo.id === findingId) {
75
+ hallazgo.resolvedByCommit = commitHash;
76
+ hallazgo.resolvedAt = resolvedAt;
77
+ found = true;
78
+ }
79
+ }
80
+ }
81
+ // En disco
82
+ try {
83
+ const files = await fs.readdir(this.docsDir);
84
+ for (const file of files) {
85
+ if (!file.endsWith('.md') || file.startsWith('auto-gates') || file.startsWith('pending-issues'))
86
+ continue;
87
+ const filePath = path.join(this.docsDir, file);
88
+ let content = await fs.readFile(filePath, 'utf-8');
89
+ const pattern = new RegExp(`\\|\\s*${findingId}\\s*\\|`);
90
+ if (pattern.test(content)) {
91
+ const marker = `*(Resuelto en commit \`${commitHash}\`${commitMessage ? `: ${commitMessage}` : ''} — ${resolvedAt})*`;
92
+ content = content.replace(pattern, `$& ${marker}`);
93
+ await fs.writeFile(filePath, content, 'utf-8');
94
+ found = true;
95
+ }
96
+ }
97
+ }
98
+ catch {
99
+ // Si no existe directorio, no hay archivos que actualizar
100
+ }
101
+ return found;
102
+ }
103
+ /**
104
+ * @description Marca hallazgos como resueltos buscando por archivos modificados
105
+ * en el commit. Útil para hook post-commit.
106
+ *
107
+ * @param gates - Lista de gates en memoria
108
+ * @param commitHash - SHA del commit
109
+ * @param modifiedFiles - Archivos modificados en el commit
110
+ * @returns Cantidad de hallazgos resueltos
111
+ */
112
+ async markResolvedByFiles(gates, commitHash, modifiedFiles) {
113
+ let resolved = 0;
114
+ for (const gate of gates) {
115
+ for (const hallazgo of gate.hallazgos) {
116
+ if (!hallazgo.resolvedByCommit && modifiedFiles.some(f => hallazgo.evidencia.includes(f) || hallazgo.hallazgo.includes(f))) {
117
+ if (await this.markResolved(gates, hallazgo.id, commitHash))
118
+ resolved++;
119
+ }
120
+ }
121
+ }
122
+ return resolved;
123
+ }
124
+ }
125
+ exports.AuditFindingTracer = AuditFindingTracer;
126
+ //# sourceMappingURL=audit-finding-tracer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-finding-tracer.js","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/audit/audit-finding-tracer.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,gDAAkC;AAGlC,gFAAgF;AAEhF,SAAS,gBAAgB;IACvB,OAAO,IAAI,IAAI,EAAE;SACd,WAAW,EAAE;SACb,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,gFAAgF;AAEhF,MAAa,kBAAkB;IACrB,OAAO,CAAS;IAExB,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,KAAmB,EACnB,SAAiB,EACjB,UAAkB,EAClB,aAAsB;QAEtB,IAAI,KAAK,GAAG,KAAK,CAAC;QA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C;oBACnD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBAC/C,KAAK,GAAG,IAAI,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,0DAA0D;QAC5D,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,mBAAmB,CACvB,KAAmB,EACnB,UAAkB,EAClB,aAAuB;QAEvB,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACtC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CACvD,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChE,EAAE,CAAC;oBACF,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;wBAAE,QAAQ,EAAE,CAAC;gBAC1E,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AApFD,gDAoFC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @description AuditLessonsLearned — Analiza y genera lecciones aprendidas
3
+ * a partir de los gates de auditoría ejecutados.
4
+ *
5
+ * Responsabilidades:
6
+ * - Detectar patrones de severidad (críticos/altos)
7
+ * - Identificar dimensiones con más hallazgos
8
+ * - Encontrar keywords recurrentes en hallazgos
9
+ * - Calcular tasa de aprobación QA
10
+ * - Generar memo Markdown de lecciones aprendidas
11
+ */
12
+ import { GateRecord } from './types';
13
+ export declare class AuditLessonsLearned {
14
+ private docsDir;
15
+ constructor(docsDir: string);
16
+ /**
17
+ * @description Analiza los gates y extrae lecciones aprendidas.
18
+ * Retorna un array de strings con las lecciones detectadas.
19
+ */
20
+ analyze(gates: GateRecord[]): string[];
21
+ /**
22
+ * @description Genera un memo Markdown de lecciones aprendidas y lo persiste.
23
+ * Retorna la ruta del archivo, o null si no hay lecciones.
24
+ */
25
+ generateMemo(gates: GateRecord[]): Promise<string | null>;
26
+ }
27
+ //# sourceMappingURL=audit-lessons-learned.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-lessons-learned.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/orchestration/audit/audit-lessons-learned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAanD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAI3B;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE;IAoDtC;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAuChE"}