@telora/factory 0.4.5

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 (301) hide show
  1. package/dist/audit.d.ts +69 -0
  2. package/dist/audit.d.ts.map +1 -0
  3. package/dist/audit.js +376 -0
  4. package/dist/audit.js.map +1 -0
  5. package/dist/builder-completion.d.ts +35 -0
  6. package/dist/builder-completion.d.ts.map +1 -0
  7. package/dist/builder-completion.js +375 -0
  8. package/dist/builder-completion.js.map +1 -0
  9. package/dist/builder-spawner.d.ts +40 -0
  10. package/dist/builder-spawner.d.ts.map +1 -0
  11. package/dist/builder-spawner.js +493 -0
  12. package/dist/builder-spawner.js.map +1 -0
  13. package/dist/completion-gate.d.ts +52 -0
  14. package/dist/completion-gate.d.ts.map +1 -0
  15. package/dist/completion-gate.js +336 -0
  16. package/dist/completion-gate.js.map +1 -0
  17. package/dist/completion-report.d.ts +36 -0
  18. package/dist/completion-report.d.ts.map +1 -0
  19. package/dist/completion-report.js +348 -0
  20. package/dist/completion-report.js.map +1 -0
  21. package/dist/completion.d.ts +58 -0
  22. package/dist/completion.d.ts.map +1 -0
  23. package/dist/completion.js +287 -0
  24. package/dist/completion.js.map +1 -0
  25. package/dist/config.d.ts +16 -0
  26. package/dist/config.d.ts.map +1 -0
  27. package/dist/config.js +57 -0
  28. package/dist/config.js.map +1 -0
  29. package/dist/context-manager.d.ts +152 -0
  30. package/dist/context-manager.d.ts.map +1 -0
  31. package/dist/context-manager.js +421 -0
  32. package/dist/context-manager.js.map +1 -0
  33. package/dist/crash-detection.d.ts +70 -0
  34. package/dist/crash-detection.d.ts.map +1 -0
  35. package/dist/crash-detection.js +123 -0
  36. package/dist/crash-detection.js.map +1 -0
  37. package/dist/crash-recovery.d.ts +83 -0
  38. package/dist/crash-recovery.d.ts.map +1 -0
  39. package/dist/crash-recovery.js +522 -0
  40. package/dist/crash-recovery.js.map +1 -0
  41. package/dist/crash-resolution.d.ts +34 -0
  42. package/dist/crash-resolution.d.ts.map +1 -0
  43. package/dist/crash-resolution.js +382 -0
  44. package/dist/crash-resolution.js.map +1 -0
  45. package/dist/escalation.d.ts +150 -0
  46. package/dist/escalation.d.ts.map +1 -0
  47. package/dist/escalation.js +352 -0
  48. package/dist/escalation.js.map +1 -0
  49. package/dist/execution-target.d.ts +31 -0
  50. package/dist/execution-target.d.ts.map +1 -0
  51. package/dist/execution-target.js +71 -0
  52. package/dist/execution-target.js.map +1 -0
  53. package/dist/execution-unit-init.d.ts +28 -0
  54. package/dist/execution-unit-init.d.ts.map +1 -0
  55. package/dist/execution-unit-init.js +115 -0
  56. package/dist/execution-unit-init.js.map +1 -0
  57. package/dist/execution.d.ts +17 -0
  58. package/dist/execution.d.ts.map +1 -0
  59. package/dist/execution.js +20 -0
  60. package/dist/execution.js.map +1 -0
  61. package/dist/factory-engine.d.ts +100 -0
  62. package/dist/factory-engine.d.ts.map +1 -0
  63. package/dist/factory-engine.js +243 -0
  64. package/dist/factory-engine.js.map +1 -0
  65. package/dist/gap-detection.d.ts +43 -0
  66. package/dist/gap-detection.d.ts.map +1 -0
  67. package/dist/gap-detection.js +149 -0
  68. package/dist/gap-detection.js.map +1 -0
  69. package/dist/gate-context.d.ts +23 -0
  70. package/dist/gate-context.d.ts.map +1 -0
  71. package/dist/gate-context.js +63 -0
  72. package/dist/gate-context.js.map +1 -0
  73. package/dist/gate-engine.d.ts +55 -0
  74. package/dist/gate-engine.d.ts.map +1 -0
  75. package/dist/gate-engine.js +191 -0
  76. package/dist/gate-engine.js.map +1 -0
  77. package/dist/gates/adversarial.d.ts +59 -0
  78. package/dist/gates/adversarial.d.ts.map +1 -0
  79. package/dist/gates/adversarial.js +426 -0
  80. package/dist/gates/adversarial.js.map +1 -0
  81. package/dist/gates/adversary-spawner.d.ts +35 -0
  82. package/dist/gates/adversary-spawner.d.ts.map +1 -0
  83. package/dist/gates/adversary-spawner.js +286 -0
  84. package/dist/gates/adversary-spawner.js.map +1 -0
  85. package/dist/gates/adversary-test-dir.d.ts +41 -0
  86. package/dist/gates/adversary-test-dir.d.ts.map +1 -0
  87. package/dist/gates/adversary-test-dir.js +150 -0
  88. package/dist/gates/adversary-test-dir.js.map +1 -0
  89. package/dist/gates/behavioral-parser.d.ts +32 -0
  90. package/dist/gates/behavioral-parser.d.ts.map +1 -0
  91. package/dist/gates/behavioral-parser.js +190 -0
  92. package/dist/gates/behavioral-parser.js.map +1 -0
  93. package/dist/gates/behavioral-runner.d.ts +36 -0
  94. package/dist/gates/behavioral-runner.d.ts.map +1 -0
  95. package/dist/gates/behavioral-runner.js +306 -0
  96. package/dist/gates/behavioral-runner.js.map +1 -0
  97. package/dist/gates/behavioral.d.ts +37 -0
  98. package/dist/gates/behavioral.d.ts.map +1 -0
  99. package/dist/gates/behavioral.js +485 -0
  100. package/dist/gates/behavioral.js.map +1 -0
  101. package/dist/gates/deterministic.d.ts +24 -0
  102. package/dist/gates/deterministic.d.ts.map +1 -0
  103. package/dist/gates/deterministic.js +186 -0
  104. package/dist/gates/deterministic.js.map +1 -0
  105. package/dist/git-factory.d.ts +59 -0
  106. package/dist/git-factory.d.ts.map +1 -0
  107. package/dist/git-factory.js +102 -0
  108. package/dist/git-factory.js.map +1 -0
  109. package/dist/guard-evaluation.d.ts +48 -0
  110. package/dist/guard-evaluation.d.ts.map +1 -0
  111. package/dist/guard-evaluation.js +416 -0
  112. package/dist/guard-evaluation.js.map +1 -0
  113. package/dist/index.d.ts +30 -0
  114. package/dist/index.d.ts.map +1 -0
  115. package/dist/index.js +39 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/instance-completion.d.ts +34 -0
  118. package/dist/instance-completion.d.ts.map +1 -0
  119. package/dist/instance-completion.js +366 -0
  120. package/dist/instance-completion.js.map +1 -0
  121. package/dist/instance-lifecycle.d.ts +15 -0
  122. package/dist/instance-lifecycle.d.ts.map +1 -0
  123. package/dist/instance-lifecycle.js +18 -0
  124. package/dist/instance-lifecycle.js.map +1 -0
  125. package/dist/instance-phase-dispatch.d.ts +75 -0
  126. package/dist/instance-phase-dispatch.d.ts.map +1 -0
  127. package/dist/instance-phase-dispatch.js +674 -0
  128. package/dist/instance-phase-dispatch.js.map +1 -0
  129. package/dist/instance-poll-loop.d.ts +43 -0
  130. package/dist/instance-poll-loop.d.ts.map +1 -0
  131. package/dist/instance-poll-loop.js +360 -0
  132. package/dist/instance-poll-loop.js.map +1 -0
  133. package/dist/instance-state-machine.d.ts +52 -0
  134. package/dist/instance-state-machine.d.ts.map +1 -0
  135. package/dist/instance-state-machine.js +235 -0
  136. package/dist/instance-state-machine.js.map +1 -0
  137. package/dist/log-manager.d.ts +28 -0
  138. package/dist/log-manager.d.ts.map +1 -0
  139. package/dist/log-manager.js +71 -0
  140. package/dist/log-manager.js.map +1 -0
  141. package/dist/pipeline-evaluator.d.ts +61 -0
  142. package/dist/pipeline-evaluator.d.ts.map +1 -0
  143. package/dist/pipeline-evaluator.js +107 -0
  144. package/dist/pipeline-evaluator.js.map +1 -0
  145. package/dist/pipeline-metrics.d.ts +52 -0
  146. package/dist/pipeline-metrics.d.ts.map +1 -0
  147. package/dist/pipeline-metrics.js +40 -0
  148. package/dist/pipeline-metrics.js.map +1 -0
  149. package/dist/pipeline-traversal.d.ts +43 -0
  150. package/dist/pipeline-traversal.d.ts.map +1 -0
  151. package/dist/pipeline-traversal.js +68 -0
  152. package/dist/pipeline-traversal.js.map +1 -0
  153. package/dist/plan-parser.d.ts +76 -0
  154. package/dist/plan-parser.d.ts.map +1 -0
  155. package/dist/plan-parser.js +223 -0
  156. package/dist/plan-parser.js.map +1 -0
  157. package/dist/planning-phase.d.ts +52 -0
  158. package/dist/planning-phase.d.ts.map +1 -0
  159. package/dist/planning-phase.js +444 -0
  160. package/dist/planning-phase.js.map +1 -0
  161. package/dist/planning-prompt.d.ts +64 -0
  162. package/dist/planning-prompt.d.ts.map +1 -0
  163. package/dist/planning-prompt.js +251 -0
  164. package/dist/planning-prompt.js.map +1 -0
  165. package/dist/planning.d.ts +16 -0
  166. package/dist/planning.d.ts.map +1 -0
  167. package/dist/planning.js +17 -0
  168. package/dist/planning.js.map +1 -0
  169. package/dist/process-runner.d.ts +41 -0
  170. package/dist/process-runner.d.ts.map +1 -0
  171. package/dist/process-runner.js +81 -0
  172. package/dist/process-runner.js.map +1 -0
  173. package/dist/product-config.d.ts +34 -0
  174. package/dist/product-config.d.ts.map +1 -0
  175. package/dist/product-config.js +43 -0
  176. package/dist/product-config.js.map +1 -0
  177. package/dist/queries/cycle-evaluations.d.ts +23 -0
  178. package/dist/queries/cycle-evaluations.d.ts.map +1 -0
  179. package/dist/queries/cycle-evaluations.js +37 -0
  180. package/dist/queries/cycle-evaluations.js.map +1 -0
  181. package/dist/queries/escalations.d.ts +30 -0
  182. package/dist/queries/escalations.d.ts.map +1 -0
  183. package/dist/queries/escalations.js +42 -0
  184. package/dist/queries/escalations.js.map +1 -0
  185. package/dist/queries/execution-units.d.ts +76 -0
  186. package/dist/queries/execution-units.d.ts.map +1 -0
  187. package/dist/queries/execution-units.js +109 -0
  188. package/dist/queries/execution-units.js.map +1 -0
  189. package/dist/queries/gate-results.d.ts +32 -0
  190. package/dist/queries/gate-results.d.ts.map +1 -0
  191. package/dist/queries/gate-results.js +44 -0
  192. package/dist/queries/gate-results.js.map +1 -0
  193. package/dist/queries/instances.d.ts +51 -0
  194. package/dist/queries/instances.d.ts.map +1 -0
  195. package/dist/queries/instances.js +77 -0
  196. package/dist/queries/instances.js.map +1 -0
  197. package/dist/queries/sessions.d.ts +50 -0
  198. package/dist/queries/sessions.d.ts.map +1 -0
  199. package/dist/queries/sessions.js +81 -0
  200. package/dist/queries/sessions.js.map +1 -0
  201. package/dist/queries/shared.d.ts +38 -0
  202. package/dist/queries/shared.d.ts.map +1 -0
  203. package/dist/queries/shared.js +119 -0
  204. package/dist/queries/shared.js.map +1 -0
  205. package/dist/queries/specs.d.ts +12 -0
  206. package/dist/queries/specs.d.ts.map +1 -0
  207. package/dist/queries/specs.js +21 -0
  208. package/dist/queries/specs.js.map +1 -0
  209. package/dist/queries/strategies.d.ts +14 -0
  210. package/dist/queries/strategies.d.ts.map +1 -0
  211. package/dist/queries/strategies.js +18 -0
  212. package/dist/queries/strategies.js.map +1 -0
  213. package/dist/queries/work-units.d.ts +42 -0
  214. package/dist/queries/work-units.d.ts.map +1 -0
  215. package/dist/queries/work-units.js +57 -0
  216. package/dist/queries/work-units.js.map +1 -0
  217. package/dist/queries/workflows.d.ts +29 -0
  218. package/dist/queries/workflows.d.ts.map +1 -0
  219. package/dist/queries/workflows.js +103 -0
  220. package/dist/queries/workflows.js.map +1 -0
  221. package/dist/remediation-units.d.ts +40 -0
  222. package/dist/remediation-units.d.ts.map +1 -0
  223. package/dist/remediation-units.js +263 -0
  224. package/dist/remediation-units.js.map +1 -0
  225. package/dist/replanning.d.ts +72 -0
  226. package/dist/replanning.d.ts.map +1 -0
  227. package/dist/replanning.js +403 -0
  228. package/dist/replanning.js.map +1 -0
  229. package/dist/resource-limits.d.ts +62 -0
  230. package/dist/resource-limits.d.ts.map +1 -0
  231. package/dist/resource-limits.js +322 -0
  232. package/dist/resource-limits.js.map +1 -0
  233. package/dist/scheduler.d.ts +98 -0
  234. package/dist/scheduler.d.ts.map +1 -0
  235. package/dist/scheduler.js +203 -0
  236. package/dist/scheduler.js.map +1 -0
  237. package/dist/session-adapter.d.ts +89 -0
  238. package/dist/session-adapter.d.ts.map +1 -0
  239. package/dist/session-adapter.js +108 -0
  240. package/dist/session-adapter.js.map +1 -0
  241. package/dist/sop-generator.d.ts +29 -0
  242. package/dist/sop-generator.d.ts.map +1 -0
  243. package/dist/sop-generator.js +235 -0
  244. package/dist/sop-generator.js.map +1 -0
  245. package/dist/spec-profiles.d.ts +41 -0
  246. package/dist/spec-profiles.d.ts.map +1 -0
  247. package/dist/spec-profiles.js +131 -0
  248. package/dist/spec-profiles.js.map +1 -0
  249. package/dist/strategy-design-graph.d.ts +23 -0
  250. package/dist/strategy-design-graph.d.ts.map +1 -0
  251. package/dist/strategy-design-graph.js +205 -0
  252. package/dist/strategy-design-graph.js.map +1 -0
  253. package/dist/strategy-design-prompt.d.ts +28 -0
  254. package/dist/strategy-design-prompt.d.ts.map +1 -0
  255. package/dist/strategy-design-prompt.js +108 -0
  256. package/dist/strategy-design-prompt.js.map +1 -0
  257. package/dist/strategy-design-schema.d.ts +767 -0
  258. package/dist/strategy-design-schema.d.ts.map +1 -0
  259. package/dist/strategy-design-schema.js +126 -0
  260. package/dist/strategy-design-schema.js.map +1 -0
  261. package/dist/strategy-design.d.ts +69 -0
  262. package/dist/strategy-design.d.ts.map +1 -0
  263. package/dist/strategy-design.js +411 -0
  264. package/dist/strategy-design.js.map +1 -0
  265. package/dist/strategy-gating.d.ts +31 -0
  266. package/dist/strategy-gating.d.ts.map +1 -0
  267. package/dist/strategy-gating.js +276 -0
  268. package/dist/strategy-gating.js.map +1 -0
  269. package/dist/team-prompt-builder.d.ts +47 -0
  270. package/dist/team-prompt-builder.d.ts.map +1 -0
  271. package/dist/team-prompt-builder.js +362 -0
  272. package/dist/team-prompt-builder.js.map +1 -0
  273. package/dist/trace-engine.d.ts +40 -0
  274. package/dist/trace-engine.d.ts.map +1 -0
  275. package/dist/trace-engine.js +344 -0
  276. package/dist/trace-engine.js.map +1 -0
  277. package/dist/types.d.ts +612 -0
  278. package/dist/types.d.ts.map +1 -0
  279. package/dist/types.js +9 -0
  280. package/dist/types.js.map +1 -0
  281. package/dist/unit-session-lifecycle.d.ts +78 -0
  282. package/dist/unit-session-lifecycle.d.ts.map +1 -0
  283. package/dist/unit-session-lifecycle.js +141 -0
  284. package/dist/unit-session-lifecycle.js.map +1 -0
  285. package/dist/unit-session.d.ts +30 -0
  286. package/dist/unit-session.d.ts.map +1 -0
  287. package/dist/unit-session.js +370 -0
  288. package/dist/unit-session.js.map +1 -0
  289. package/dist/watchdogs.d.ts +33 -0
  290. package/dist/watchdogs.d.ts.map +1 -0
  291. package/dist/watchdogs.js +170 -0
  292. package/dist/watchdogs.js.map +1 -0
  293. package/dist/work-unit-scheduler.d.ts +34 -0
  294. package/dist/work-unit-scheduler.d.ts.map +1 -0
  295. package/dist/work-unit-scheduler.js +91 -0
  296. package/dist/work-unit-scheduler.js.map +1 -0
  297. package/dist/workflow-transition.d.ts +90 -0
  298. package/dist/workflow-transition.d.ts.map +1 -0
  299. package/dist/workflow-transition.js +340 -0
  300. package/dist/workflow-transition.js.map +1 -0
  301. package/package.json +65 -0
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Pre-planning codebase audit module.
3
+ *
4
+ * Runs a structured discovery phase that scans the codebase for existing
5
+ * implementations relevant to the specification. The audit produces a
6
+ * report that gets injected into the planning prompt so the planner knows
7
+ * what already exists, what is partially built, and what is truly missing.
8
+ *
9
+ * The audit is best-effort: if it fails for any reason (timeout, parse error,
10
+ * empty output), planning proceeds without the audit report.
11
+ */
12
+ import type { ResourceGovernor } from '@telora/daemon-core';
13
+ import type { AuditReport, FactoryBlueprint, FactoryConfig } from './types.js';
14
+ import type { PersistedStrategy } from './strategy-design.js';
15
+ /**
16
+ * Resolve the audit timeout from blueprint config.
17
+ * - null field → use default (180s)
18
+ * - 0 → no limit (returns null)
19
+ * - positive → that value
20
+ */
21
+ export declare function resolveAuditTimeout(blueprint: FactoryBlueprint): number | null;
22
+ /**
23
+ * Resolve the audit max report chars from blueprint config.
24
+ * - null field → use default (8000)
25
+ * - 0 → no limit (returns null)
26
+ * - positive → that value
27
+ */
28
+ export declare function resolveAuditMaxReportChars(blueprint: FactoryBlueprint): number | null;
29
+ /**
30
+ * Build the prompt that instructs Claude Code to audit the codebase
31
+ * against the specification.
32
+ */
33
+ export declare function buildAuditPrompt(specification: string, blueprint: FactoryBlueprint): string;
34
+ /**
35
+ * Build a scoped audit prompt that focuses on a specific strategy's
36
+ * relevant files and scope rather than the entire codebase.
37
+ */
38
+ export declare function buildScopedAuditPrompt(strategy: PersistedStrategy, specification: string, blueprint: FactoryBlueprint): string;
39
+ /**
40
+ * Run a scoped codebase audit for a single strategy.
41
+ *
42
+ * Focuses the audit on the strategy's technical context and relevant files
43
+ * rather than scanning the entire codebase. Best-effort: returns null on
44
+ * any failure so planning can proceed without it.
45
+ */
46
+ export declare function runScopedCodebaseAudit(worktreePath: string, strategy: PersistedStrategy, specification: string, blueprint: FactoryBlueprint, config: FactoryConfig, governor?: ResourceGovernor | null): Promise<AuditReport | null>;
47
+ /**
48
+ * Run a codebase audit by spawning Claude Code in --print mode.
49
+ *
50
+ * Returns a validated AuditReport on success, or null on ANY failure.
51
+ * This function is designed to be best-effort: it never throws and
52
+ * always returns null on failure so planning can proceed without it.
53
+ *
54
+ * @param worktreePath Path to the git worktree (cwd for Claude Code)
55
+ * @param specification The factory instance specification text
56
+ * @param blueprint The factory blueprint (for operational notes)
57
+ * @param config Factory configuration
58
+ * @returns Validated AuditReport or null on failure
59
+ */
60
+ export declare function runCodebaseAudit(worktreePath: string, specification: string, blueprint: FactoryBlueprint, config: FactoryConfig, governor?: ResourceGovernor | null): Promise<AuditReport | null>;
61
+ /**
62
+ * Format a validated AuditReport as human-readable markdown suitable for
63
+ * injection into the planning prompt.
64
+ *
65
+ * Respects the MAX_REPORT_CHARS budget to avoid blowing up the planning
66
+ * prompt context window.
67
+ */
68
+ export declare function formatAuditReport(report: AuditReport, blueprint: FactoryBlueprint): string;
69
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6C9D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAI9E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAIrF;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,gBAAgB,GAC1B,MAAM,CAiFR;AAMD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,gBAAgB,GAC1B,MAAM,CA8FR;AAMD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACjC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAyF7B;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACjC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA4F7B;AAMD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAmE1F"}
package/dist/audit.js ADDED
@@ -0,0 +1,376 @@
1
+ /**
2
+ * Pre-planning codebase audit module.
3
+ *
4
+ * Runs a structured discovery phase that scans the codebase for existing
5
+ * implementations relevant to the specification. The audit produces a
6
+ * report that gets injected into the planning prompt so the planner knows
7
+ * what already exists, what is partially built, and what is truly missing.
8
+ *
9
+ * The audit is best-effort: if it fails for any reason (timeout, parse error,
10
+ * empty output), planning proceeds without the audit report.
11
+ */
12
+ import { spawnAsync } from './process-runner.js';
13
+ import { z } from 'zod';
14
+ import { buildPlanningEnv, extractWorkPlanJson } from './planning.js';
15
+ // ============================================================================
16
+ // Constants
17
+ // ============================================================================
18
+ /** Default timeout for the audit Claude Code session (3 minutes -- shorter than planning). */
19
+ const DEFAULT_AUDIT_TIMEOUT_MS = 180_000;
20
+ /** Default maximum character length of the formatted audit report to avoid prompt bloat. */
21
+ const DEFAULT_MAX_REPORT_CHARS = 8_000;
22
+ /** Log prefix for this module. */
23
+ const LOG_PREFIX = '[audit]';
24
+ // ============================================================================
25
+ // Zod schemas
26
+ // ============================================================================
27
+ const AuditEntrySchema = z.object({
28
+ area: z.string().min(1),
29
+ description: z.string().min(1),
30
+ relevantFiles: z.array(z.string()),
31
+ confidence: z.enum(['high', 'medium', 'low']),
32
+ });
33
+ const AuditConflictSchema = z.object({
34
+ area: z.string().min(1),
35
+ existingBehavior: z.string().min(1),
36
+ specifiedBehavior: z.string().min(1),
37
+ relevantFiles: z.array(z.string()),
38
+ });
39
+ const AuditReportSchema = z.object({
40
+ existingImplementations: z.array(AuditEntrySchema),
41
+ partialImplementations: z.array(AuditEntrySchema),
42
+ gaps: z.array(AuditEntrySchema),
43
+ conflicts: z.array(AuditConflictSchema),
44
+ summary: z.string().min(1),
45
+ });
46
+ // ============================================================================
47
+ // Blueprint-driven config resolution
48
+ // ============================================================================
49
+ /**
50
+ * Resolve the audit timeout from blueprint config.
51
+ * - null field → use default (180s)
52
+ * - 0 → no limit (returns null)
53
+ * - positive → that value
54
+ */
55
+ export function resolveAuditTimeout(blueprint) {
56
+ if (blueprint.auditTimeoutMs === 0)
57
+ return null;
58
+ if (blueprint.auditTimeoutMs !== null && blueprint.auditTimeoutMs !== undefined)
59
+ return blueprint.auditTimeoutMs;
60
+ return DEFAULT_AUDIT_TIMEOUT_MS;
61
+ }
62
+ /**
63
+ * Resolve the audit max report chars from blueprint config.
64
+ * - null field → use default (8000)
65
+ * - 0 → no limit (returns null)
66
+ * - positive → that value
67
+ */
68
+ export function resolveAuditMaxReportChars(blueprint) {
69
+ if (blueprint.auditMaxReportChars === 0)
70
+ return null;
71
+ if (blueprint.auditMaxReportChars !== null && blueprint.auditMaxReportChars !== undefined)
72
+ return blueprint.auditMaxReportChars;
73
+ return DEFAULT_MAX_REPORT_CHARS;
74
+ }
75
+ // ============================================================================
76
+ // Audit prompt builder
77
+ // ============================================================================
78
+ /**
79
+ * Build the prompt that instructs Claude Code to audit the codebase
80
+ * against the specification.
81
+ */
82
+ export function buildAuditPrompt(specification, blueprint) {
83
+ const parts = [
84
+ 'You are a codebase auditor for a software factory system.',
85
+ 'Your task is to analyze the EXISTING codebase in the current working directory',
86
+ 'against the following specification and produce a structured audit report.',
87
+ '',
88
+ '## Specification',
89
+ specification,
90
+ ];
91
+ if (blueprint.operationalNotes) {
92
+ parts.push('', '## Operational Notes (focus areas)', blueprint.operationalNotes);
93
+ }
94
+ if (blueprint.specConstraints) {
95
+ parts.push('', '## Blueprint Infrastructure Requirements', 'The following requirements are mandated by the factory blueprint and take precedence', 'over spec requirements. Do NOT report conflicts or gaps for items covered here.', '', blueprint.specConstraints);
96
+ }
97
+ parts.push('', '## Instructions', '', 'Scan the codebase thoroughly:', '1. Identify features/components from the specification that are ALREADY FULLY implemented', '2. Identify features that are PARTIALLY implemented (started but incomplete)', '3. Identify features that are complete GAPS (nothing exists yet)', '4. Flag any CONFLICTS where existing code contradicts the specification', '', 'For each entry, list the relevant file paths and your confidence level.', '', '## Audit Scope', 'Report gaps for FUNCTIONAL REQUIREMENTS only -- things specified but not built.', 'Do NOT report as gaps:', '- Test coverage or missing test files (validated externally by the factory gate system)', '- TypeScript type correctness (validated by the deterministic gate: typecheck)', '- Build validity (validated by the deterministic gate: build)', '- Linting or code style (validated by the deterministic gate: lint)', '- E2E or behavioral correctness (validated by behavioral and adversarial gates)', 'If the factory gates pass, these dimensions are already verified. Only report gaps', 'where a functional feature described in the specification is absent from the codebase.', '', '## Output Format', 'Return ONLY a JSON object (no markdown fencing, no commentary) with this exact structure:', '```', '{', ' "existingImplementations": [', ' { "area": "Feature name", "description": "What exists", "relevantFiles": ["path/to/file.ts"], "confidence": "high" }', ' ],', ' "partialImplementations": [', ' { "area": "Feature name", "description": "What exists and what is missing", "relevantFiles": ["path/to/file.ts"], "confidence": "medium" }', ' ],', ' "gaps": [', ' { "area": "Feature name", "description": "What needs to be built", "relevantFiles": [], "confidence": "high" }', ' ],', ' "conflicts": [', ' { "area": "Feature name", "existingBehavior": "What the code does", "specifiedBehavior": "What the spec says", "relevantFiles": ["path/to/file.ts"] }', ' ],', ' "summary": "One-paragraph overview of audit findings"', '}', '```', '', 'Rules:', '- Every area must have a non-empty name and description', '- relevantFiles should contain actual file paths from the codebase', '- confidence: "high" = very sure, "medium" = fairly sure, "low" = uncertain', '- If no entries for a category, use an empty array []', '- Return ONLY the JSON object, nothing else');
98
+ return parts.join('\n');
99
+ }
100
+ // ============================================================================
101
+ // Scoped audit prompt builder (per-strategy)
102
+ // ============================================================================
103
+ /**
104
+ * Build a scoped audit prompt that focuses on a specific strategy's
105
+ * relevant files and scope rather than the entire codebase.
106
+ */
107
+ export function buildScopedAuditPrompt(strategy, specification, blueprint) {
108
+ const parts = [
109
+ 'You are a codebase auditor for a software factory system.',
110
+ 'Your task is to audit the EXISTING codebase scoped to a specific strategy.',
111
+ `Focus your analysis on the "${strategy.name}" strategy scope.`,
112
+ '',
113
+ '## Strategy Scope',
114
+ `**Name:** ${strategy.name}`,
115
+ ];
116
+ if (strategy.description) {
117
+ parts.push(`**Description:** ${strategy.description}`);
118
+ }
119
+ if (strategy.techContext) {
120
+ parts.push('', '**Technical Context (focus areas):**', strategy.techContext);
121
+ }
122
+ parts.push('', '## Full Specification (for reference)', specification);
123
+ if (blueprint.operationalNotes) {
124
+ parts.push('', '## Operational Notes', blueprint.operationalNotes);
125
+ }
126
+ if (blueprint.specConstraints) {
127
+ parts.push('', '## Blueprint Infrastructure Requirements', 'The following requirements are mandated by the factory blueprint and take precedence', 'over spec requirements. Do NOT report conflicts or gaps for items covered here.', '', blueprint.specConstraints);
128
+ }
129
+ parts.push('', '## Instructions', '', `Focus your audit on the "${strategy.name}" strategy scope:`, '1. Identify features within this strategy that are ALREADY FULLY implemented', '2. Identify features that are PARTIALLY implemented', '3. Identify features that are complete GAPS', '4. Flag any CONFLICTS where existing code contradicts the specification', '', 'For each entry, list the relevant file paths and your confidence level.', '', '## Audit Scope', 'Report gaps for FUNCTIONAL REQUIREMENTS only -- things specified but not built.', 'Do NOT report as gaps:', '- Test coverage or missing test files (validated externally by the factory gate system)', '- TypeScript type correctness (validated by the deterministic gate: typecheck)', '- Build validity (validated by the deterministic gate: build)', '- Linting or code style (validated by the deterministic gate: lint)', '- E2E or behavioral correctness (validated by behavioral and adversarial gates)', 'Only report gaps where a functional feature described in the specification is absent.', '', '## Output Format', 'Return ONLY a JSON object (no markdown fencing, no commentary) with this exact structure:', '```', '{', ' "existingImplementations": [', ' { "area": "Feature name", "description": "What exists", "relevantFiles": ["path/to/file.ts"], "confidence": "high" }', ' ],', ' "partialImplementations": [', ' { "area": "Feature name", "description": "What exists and what is missing", "relevantFiles": ["path/to/file.ts"], "confidence": "medium" }', ' ],', ' "gaps": [', ' { "area": "Feature name", "description": "What needs to be built", "relevantFiles": [], "confidence": "high" }', ' ],', ' "conflicts": [', ' { "area": "Feature name", "existingBehavior": "What the code does", "specifiedBehavior": "What the spec says", "relevantFiles": ["path/to/file.ts"] }', ' ],', ' "summary": "One-paragraph overview of audit findings for this strategy"', '}', '```', '', 'Rules:', '- Every area must have a non-empty name and description', '- relevantFiles should contain actual file paths from the codebase', '- confidence: "high" = very sure, "medium" = fairly sure, "low" = uncertain', '- If no entries for a category, use an empty array []', '- Return ONLY the JSON object, nothing else');
130
+ return parts.join('\n');
131
+ }
132
+ // ============================================================================
133
+ // Scoped audit function (per-strategy)
134
+ // ============================================================================
135
+ /**
136
+ * Run a scoped codebase audit for a single strategy.
137
+ *
138
+ * Focuses the audit on the strategy's technical context and relevant files
139
+ * rather than scanning the entire codebase. Best-effort: returns null on
140
+ * any failure so planning can proceed without it.
141
+ */
142
+ export async function runScopedCodebaseAudit(worktreePath, strategy, specification, blueprint, config, governor) {
143
+ const prompt = buildScopedAuditPrompt(strategy, specification, blueprint);
144
+ let rawOutput;
145
+ if (governor)
146
+ await governor.acquireSlot('factory');
147
+ try {
148
+ const args = ['--print', '--output-format', 'json', '--verbose'];
149
+ const env = buildPlanningEnv(config);
150
+ const timeoutMs = resolveAuditTimeout(blueprint);
151
+ console.log(`${LOG_PREFIX} Spawning scoped audit for strategy "${strategy.name}" ` +
152
+ `(timeout: ${timeoutMs === null ? 'none' : `${timeoutMs / 1000}s`})...`);
153
+ rawOutput = await spawnAsync(config.claudeCodePath, args, {
154
+ input: prompt,
155
+ encoding: 'utf-8',
156
+ timeout: timeoutMs ?? undefined,
157
+ cwd: worktreePath,
158
+ env,
159
+ });
160
+ }
161
+ catch (err) {
162
+ const execErr = err;
163
+ if (execErr.killed || execErr.signal === 'SIGTERM') {
164
+ console.warn(`${LOG_PREFIX} Scoped audit for "${strategy.name}" timed out`);
165
+ }
166
+ else {
167
+ console.warn(`${LOG_PREFIX} Scoped audit for "${strategy.name}" failed: ${execErr.message ?? 'unknown error'}`);
168
+ }
169
+ return null;
170
+ }
171
+ finally {
172
+ if (governor)
173
+ governor.releaseSlot('factory');
174
+ }
175
+ if (!rawOutput || rawOutput.trim().length === 0) {
176
+ console.warn(`${LOG_PREFIX} Scoped audit for "${strategy.name}" returned empty output`);
177
+ return null;
178
+ }
179
+ let jsonStr;
180
+ try {
181
+ jsonStr = extractWorkPlanJson(rawOutput);
182
+ }
183
+ catch (err) {
184
+ console.warn(`${LOG_PREFIX} Failed to extract scoped audit JSON for "${strategy.name}": ` +
185
+ `${err instanceof Error ? err.message : String(err)}`);
186
+ return null;
187
+ }
188
+ let parsedJson;
189
+ try {
190
+ parsedJson = JSON.parse(jsonStr);
191
+ }
192
+ catch (err) {
193
+ console.warn(`${LOG_PREFIX} Scoped audit output for "${strategy.name}" is not valid JSON: ` +
194
+ `${err instanceof Error ? err.message : String(err)}`);
195
+ return null;
196
+ }
197
+ // Normalize: AI sometimes returns a bare array instead of an object.
198
+ if (Array.isArray(parsedJson)) {
199
+ if (parsedJson.length === 1 && typeof parsedJson[0] === 'object' && parsedJson[0] !== null && !Array.isArray(parsedJson[0])) {
200
+ parsedJson = parsedJson[0];
201
+ }
202
+ }
203
+ const validation = AuditReportSchema.safeParse(parsedJson);
204
+ if (!validation.success) {
205
+ const issues = validation.error.issues
206
+ .map((i) => `${i.path.join('.')}: ${i.message}`)
207
+ .join('; ');
208
+ const topKeys = typeof parsedJson === 'object' && parsedJson !== null ? Object.keys(parsedJson) : [];
209
+ console.warn(`${LOG_PREFIX} Scoped audit validation failed for "${strategy.name}": ${issues}`);
210
+ console.warn(`${LOG_PREFIX} Parsed object keys: [${topKeys}], preview: ${JSON.stringify(parsedJson).slice(0, 500)}`);
211
+ return null;
212
+ }
213
+ console.log(`${LOG_PREFIX} Scoped audit for "${strategy.name}" completed: ` +
214
+ `${validation.data.existingImplementations.length} existing, ` +
215
+ `${validation.data.partialImplementations.length} partial, ` +
216
+ `${validation.data.gaps.length} gaps`);
217
+ return validation.data;
218
+ }
219
+ // ============================================================================
220
+ // Main audit function
221
+ // ============================================================================
222
+ /**
223
+ * Run a codebase audit by spawning Claude Code in --print mode.
224
+ *
225
+ * Returns a validated AuditReport on success, or null on ANY failure.
226
+ * This function is designed to be best-effort: it never throws and
227
+ * always returns null on failure so planning can proceed without it.
228
+ *
229
+ * @param worktreePath Path to the git worktree (cwd for Claude Code)
230
+ * @param specification The factory instance specification text
231
+ * @param blueprint The factory blueprint (for operational notes)
232
+ * @param config Factory configuration
233
+ * @returns Validated AuditReport or null on failure
234
+ */
235
+ export async function runCodebaseAudit(worktreePath, specification, blueprint, config, governor) {
236
+ const prompt = buildAuditPrompt(specification, blueprint);
237
+ let rawOutput;
238
+ if (governor)
239
+ await governor.acquireSlot('factory');
240
+ try {
241
+ const args = ['--print', '--output-format', 'json', '--verbose'];
242
+ const env = buildPlanningEnv(config);
243
+ const timeoutMs = resolveAuditTimeout(blueprint);
244
+ console.log(`${LOG_PREFIX} Spawning Claude Code for codebase audit (timeout: ${timeoutMs === null ? 'none' : `${timeoutMs / 1000}s`})...`);
245
+ rawOutput = await spawnAsync(config.claudeCodePath, args, {
246
+ input: prompt,
247
+ encoding: 'utf-8',
248
+ timeout: timeoutMs ?? undefined,
249
+ cwd: worktreePath,
250
+ env,
251
+ });
252
+ }
253
+ catch (err) {
254
+ const execErr = err;
255
+ if (execErr.killed || execErr.signal === 'SIGTERM') {
256
+ const timeoutMs = resolveAuditTimeout(blueprint);
257
+ console.warn(`${LOG_PREFIX} Audit timed out after ${timeoutMs === null ? '?' : timeoutMs / 1000}s`);
258
+ }
259
+ else {
260
+ console.warn(`${LOG_PREFIX} Audit Claude Code session failed: ${execErr.message ?? 'unknown error'}`);
261
+ }
262
+ return null;
263
+ }
264
+ finally {
265
+ if (governor)
266
+ governor.releaseSlot('factory');
267
+ }
268
+ if (!rawOutput || rawOutput.trim().length === 0) {
269
+ console.warn(`${LOG_PREFIX} Audit returned empty output`);
270
+ return null;
271
+ }
272
+ // Extract and validate JSON
273
+ let jsonStr;
274
+ try {
275
+ jsonStr = extractWorkPlanJson(rawOutput);
276
+ }
277
+ catch (err) {
278
+ console.warn(`${LOG_PREFIX} Failed to extract audit JSON: ${err instanceof Error ? err.message : String(err)}`);
279
+ return null;
280
+ }
281
+ let parsedJson;
282
+ try {
283
+ parsedJson = JSON.parse(jsonStr);
284
+ }
285
+ catch (err) {
286
+ console.warn(`${LOG_PREFIX} Audit output is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
287
+ return null;
288
+ }
289
+ // Normalize: AI sometimes returns a bare array instead of an object.
290
+ if (Array.isArray(parsedJson)) {
291
+ if (parsedJson.length === 1 && typeof parsedJson[0] === 'object' && parsedJson[0] !== null && !Array.isArray(parsedJson[0])) {
292
+ parsedJson = parsedJson[0];
293
+ }
294
+ }
295
+ const validation = AuditReportSchema.safeParse(parsedJson);
296
+ if (!validation.success) {
297
+ const issues = validation.error.issues
298
+ .map((i) => `${i.path.join('.')}: ${i.message}`)
299
+ .join('; ');
300
+ const topKeys = typeof parsedJson === 'object' && parsedJson !== null ? Object.keys(parsedJson) : [];
301
+ console.warn(`${LOG_PREFIX} Audit report validation failed: ${issues}`);
302
+ console.warn(`${LOG_PREFIX} Parsed object keys: [${topKeys}], preview: ${JSON.stringify(parsedJson).slice(0, 500)}`);
303
+ return null;
304
+ }
305
+ console.log(`${LOG_PREFIX} Audit completed: ` +
306
+ `${validation.data.existingImplementations.length} existing, ` +
307
+ `${validation.data.partialImplementations.length} partial, ` +
308
+ `${validation.data.gaps.length} gaps, ` +
309
+ `${validation.data.conflicts.length} conflicts`);
310
+ return validation.data;
311
+ }
312
+ // ============================================================================
313
+ // Report formatter
314
+ // ============================================================================
315
+ /**
316
+ * Format a validated AuditReport as human-readable markdown suitable for
317
+ * injection into the planning prompt.
318
+ *
319
+ * Respects the MAX_REPORT_CHARS budget to avoid blowing up the planning
320
+ * prompt context window.
321
+ */
322
+ export function formatAuditReport(report, blueprint) {
323
+ const sections = [];
324
+ sections.push(report.summary);
325
+ if (report.existingImplementations.length > 0) {
326
+ sections.push('');
327
+ sections.push('### Already Implemented (no work needed)');
328
+ for (const entry of report.existingImplementations) {
329
+ sections.push(`- **${entry.area}** [${entry.confidence}]: ${entry.description}`);
330
+ if (entry.relevantFiles.length > 0) {
331
+ sections.push(` Files: ${entry.relevantFiles.join(', ')}`);
332
+ }
333
+ }
334
+ }
335
+ if (report.partialImplementations.length > 0) {
336
+ sections.push('');
337
+ sections.push('### Partially Implemented (complete the missing parts)');
338
+ for (const entry of report.partialImplementations) {
339
+ sections.push(`- **${entry.area}** [${entry.confidence}]: ${entry.description}`);
340
+ if (entry.relevantFiles.length > 0) {
341
+ sections.push(` Files: ${entry.relevantFiles.join(', ')}`);
342
+ }
343
+ }
344
+ }
345
+ if (report.gaps.length > 0) {
346
+ sections.push('');
347
+ sections.push('### Gaps (needs building from scratch)');
348
+ for (const entry of report.gaps) {
349
+ sections.push(`- **${entry.area}** [${entry.confidence}]: ${entry.description}`);
350
+ if (entry.relevantFiles.length > 0) {
351
+ sections.push(` Files: ${entry.relevantFiles.join(', ')}`);
352
+ }
353
+ }
354
+ }
355
+ if (report.conflicts.length > 0) {
356
+ sections.push('');
357
+ sections.push('### Conflicts (existing code contradicts specification)');
358
+ for (const conflict of report.conflicts) {
359
+ sections.push(`- **${conflict.area}**`);
360
+ sections.push(` Existing: ${conflict.existingBehavior}`);
361
+ sections.push(` Specified: ${conflict.specifiedBehavior}`);
362
+ if (conflict.relevantFiles.length > 0) {
363
+ sections.push(` Files: ${conflict.relevantFiles.join(', ')}`);
364
+ }
365
+ }
366
+ }
367
+ let formatted = sections.join('\n');
368
+ // Truncate if over budget (null = no limit)
369
+ const maxChars = resolveAuditMaxReportChars(blueprint);
370
+ if (maxChars !== null && formatted.length > maxChars) {
371
+ const truncationNote = '\n\n[Audit report truncated due to size constraints]';
372
+ formatted = formatted.slice(0, maxChars - truncationNote.length) + truncationNote;
373
+ }
374
+ return formatted;
375
+ }
376
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKtE,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,wBAAwB,GAAG,KAAK,CAAC;A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E,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,eAAe,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;YAC1D,QAAQ,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC;YAC5D,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,QAAQ,CAAC,IAAI,CAAC,YAAY,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpC,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACvD,IAAI,QAAQ,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;QACrD,MAAM,cAAc,GAAG,sDAAsD,CAAC;QAC9E,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;IACpF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Builder completion handling and main execution cycle.
3
+ *
4
+ * Handles builder session completion (token accounting, status transitions),
5
+ * and orchestrates the main execution cycle that finds ready work units,
6
+ * spawns builders, tracks strategy progress, and detects global completion.
7
+ *
8
+ * Extracted from execution.ts for focused module boundaries.
9
+ */
10
+ import type { ResourceGovernor } from '@telora/daemon-core';
11
+ import type { FactoryConfig, FactoryInstanceState, BuilderState } from './types.js';
12
+ /**
13
+ * Handle builder session completion.
14
+ *
15
+ * Routes the result through the gate engine (stubbed for now), then:
16
+ * - On gate pass: marks work unit completed, unblocks dependents
17
+ * - On gate fail + retries remaining: feeds output back, increments iteration
18
+ * - On gate fail + retries exhausted: marks work unit failed, escalates
19
+ */
20
+ export declare function handleBuilderCompletion(builder: BuilderState, exitCode: number, state: FactoryInstanceState, _config: FactoryConfig, _governor?: ResourceGovernor | null): Promise<void>;
21
+ /**
22
+ * Run a single execution cycle for a factory instance.
23
+ *
24
+ * This is the main orchestration loop called by the instance lifecycle
25
+ * manager during the "building" phase:
26
+ *
27
+ * 1. Fetch current work units from DB
28
+ * 2. Reconcile orphaned builders and stuck work units
29
+ * 3. Find work units with all dependencies satisfied
30
+ * 4. Spawn builders for ready units (skip if already active)
31
+ * 5. Track strategy progress transitions
32
+ * 6. Detect global completion (all units completed or failed)
33
+ */
34
+ export declare function runExecutionCycle(state: FactoryInstanceState, config: FactoryConfig, governor?: ResourceGovernor | null): Promise<void>;
35
+ //# sourceMappingURL=builder-completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder-completion.d.ts","sourceRoot":"","sources":["../src/builder-completion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,YAAY,EAGb,MAAM,YAAY,CAAC;AAoBpB;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,aAAa,EACtB,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC,CAkFf;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACjC,OAAO,CAAC,IAAI,CAAC,CA2Ff"}