@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 0.1.4-dev.0098fdb4e213

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 (332) hide show
  1. package/README.md +232 -5
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +132 -0
  4. package/dist/bridge/bridge-chat.types.d.ts +121 -0
  5. package/dist/bridge/bridge-chat.types.js +416 -0
  6. package/dist/bridge/bridge-state-file.d.ts +161 -0
  7. package/dist/bridge/bridge-state-file.js +376 -0
  8. package/dist/bridge/bridge-state-io.d.ts +11 -0
  9. package/dist/bridge/bridge-state-io.js +50 -0
  10. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  11. package/dist/bridge/bridge-state-lock.js +102 -0
  12. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  13. package/dist/bridge/bridge-state-unpublished.js +111 -0
  14. package/dist/bridge/bridge.base.d.ts +13 -1
  15. package/dist/bridge/bridge.service.d.ts +169 -14
  16. package/dist/bridge/bridge.service.js +1868 -330
  17. package/dist/bridge/bridge.types.d.ts +73 -1
  18. package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
  19. package/dist/bridge/dispatch-result-outbox.js +87 -0
  20. package/dist/bridge/dispatch-result-worker.d.ts +2 -0
  21. package/dist/bridge/dispatch-result-worker.js +122 -0
  22. package/dist/bridge/in-flight-registry.d.ts +62 -0
  23. package/dist/bridge/in-flight-registry.js +207 -0
  24. package/dist/bridge/internals.d.ts +2 -0
  25. package/dist/bridge/internals.js +1 -0
  26. package/dist/bridge/local-yield-flag.d.ts +6 -0
  27. package/dist/bridge/local-yield-flag.js +34 -0
  28. package/dist/bridge/readiness-result-outbox.d.ts +25 -0
  29. package/dist/bridge/readiness-result-outbox.js +74 -0
  30. package/dist/bridge/readiness-result-worker.d.ts +2 -0
  31. package/dist/bridge/readiness-result-worker.js +121 -0
  32. package/dist/bridge/runner-host-capabilities.d.ts +20 -0
  33. package/dist/bridge/runner-host-capabilities.js +110 -0
  34. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  35. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  36. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  37. package/dist/bridge/test-postgres-capability.js +120 -0
  38. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  39. package/dist/cleanup/cleanup-wip.js +66 -0
  40. package/dist/cleanup/cleanup.service.d.ts +21 -1
  41. package/dist/cleanup/cleanup.service.js +185 -143
  42. package/dist/cleanup/cleanup.types.d.ts +6 -0
  43. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  44. package/dist/cleanup/forge-owned-paths.js +53 -0
  45. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  46. package/dist/cleanup/host-runtime-ledger.js +130 -0
  47. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  48. package/dist/cleanup/managed-branch-sweep.js +111 -0
  49. package/dist/cli/cli.help.js +78 -16
  50. package/dist/cli/cli.service.d.ts +32 -15
  51. package/dist/cli/cli.service.js +206 -182
  52. package/dist/cli/idle-status.d.ts +84 -0
  53. package/dist/cli/idle-status.js +181 -0
  54. package/dist/cli/local-config.d.ts +7 -0
  55. package/dist/cli/local-config.js +36 -4
  56. package/dist/cli/provider-cli-detection.d.ts +10 -0
  57. package/dist/cli/provider-cli-detection.js +160 -0
  58. package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
  59. package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
  60. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  61. package/dist/runtime/attempt-database-broker.js +390 -0
  62. package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
  63. package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
  64. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  65. package/dist/runtime/attempt-path-operation.js +94 -0
  66. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  67. package/dist/runtime/attempt-private-directory.js +54 -0
  68. package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
  69. package/dist/runtime/attempt-process-supervisor.js +144 -23
  70. package/dist/runtime/canonical-source-file.d.ts +3 -0
  71. package/dist/runtime/canonical-source-file.js +54 -0
  72. package/dist/runtime/docker-engine-probe.d.ts +95 -0
  73. package/dist/runtime/docker-engine-probe.js +340 -0
  74. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  75. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  76. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  77. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  78. package/dist/runtime/generated-output-reset.d.ts +10 -0
  79. package/dist/runtime/generated-output-reset.js +62 -8
  80. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  81. package/dist/runtime/host-database-capability-boundary.js +63 -0
  82. package/dist/runtime/host-diagnostics.d.ts +11 -0
  83. package/dist/runtime/host-diagnostics.js +192 -0
  84. package/dist/runtime/host-execution-root.d.ts +4 -0
  85. package/dist/runtime/host-execution-root.js +39 -0
  86. package/dist/runtime/host-facts.d.ts +36 -0
  87. package/dist/runtime/host-facts.js +95 -0
  88. package/dist/runtime/host-listener-inspector.d.ts +8 -1
  89. package/dist/runtime/host-listener-inspector.js +121 -60
  90. package/dist/runtime/host-load-admission.d.ts +67 -0
  91. package/dist/runtime/host-load-admission.js +99 -0
  92. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  93. package/dist/runtime/host-load-child-environment.js +76 -0
  94. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  95. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  96. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  97. package/dist/runtime/host-load-governor-config.js +83 -0
  98. package/dist/runtime/host-load-governor.d.ts +186 -0
  99. package/dist/runtime/host-load-governor.js +632 -0
  100. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  101. package/dist/runtime/host-load-ledger-lock.js +187 -0
  102. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  103. package/dist/runtime/host-load-runtime-settings.js +80 -0
  104. package/dist/runtime/host-load-sampler.d.ts +156 -0
  105. package/dist/runtime/host-load-sampler.js +298 -0
  106. package/dist/runtime/host-load-step-class.d.ts +70 -0
  107. package/dist/runtime/host-load-step-class.js +161 -0
  108. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  109. package/dist/runtime/host-load-step-reaper.js +95 -0
  110. package/dist/runtime/host-load-step-run.d.ts +73 -0
  111. package/dist/runtime/host-load-step-run.js +102 -0
  112. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  113. package/dist/runtime/host-load-test-slot.js +81 -0
  114. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  115. package/dist/runtime/host-load-token-ledger.js +453 -0
  116. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  117. package/dist/runtime/host-load-windows-cpu.js +85 -0
  118. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  119. package/dist/runtime/host-pressure-stall.js +168 -0
  120. package/dist/runtime/host-runtime-contract.d.ts +28 -1
  121. package/dist/runtime/host-runtime-contract.js +203 -57
  122. package/dist/runtime/host-runtime-lease.d.ts +163 -9
  123. package/dist/runtime/host-runtime-lease.js +1427 -124
  124. package/dist/runtime/host-runtime-promotion.d.ts +35 -3
  125. package/dist/runtime/host-runtime-promotion.js +107 -12
  126. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  127. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  128. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  129. package/dist/runtime/host-runtime-requirements.js +117 -0
  130. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  131. package/dist/runtime/managed-command-teardown.js +596 -0
  132. package/dist/runtime/memory-capacity.d.ts +70 -0
  133. package/dist/runtime/memory-capacity.js +123 -0
  134. package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
  135. package/dist/runtime/native-test-postgres-fallback.js +143 -0
  136. package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
  137. package/dist/runtime/node-host-runtime-adapter.js +29 -11
  138. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  139. package/dist/runtime/pinned-directory-process.js +61 -0
  140. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  141. package/dist/runtime/pinned-source-directory.js +94 -0
  142. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  143. package/dist/runtime/playwright-browser-cache.js +227 -0
  144. package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
  145. package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
  146. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  147. package/dist/runtime/prepared-runtime-identity.js +218 -0
  148. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  149. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  150. package/dist/runtime/runner-settings.d.ts +104 -0
  151. package/dist/runtime/runner-settings.js +236 -0
  152. package/dist/runtime/runtime-isolation-lease.js +4 -1
  153. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  154. package/dist/runtime/workspace-resource-estimator.js +174 -0
  155. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  156. package/dist/sandbox/host-capacity-broker.js +336 -0
  157. package/dist/sandbox/managed-branch.d.ts +13 -0
  158. package/dist/sandbox/managed-branch.js +36 -0
  159. package/dist/sandbox/preflight.d.ts +31 -1
  160. package/dist/sandbox/preflight.js +237 -51
  161. package/dist/sandbox/provider-auth/codex.js +11 -11
  162. package/dist/sandbox/repository-lock.d.ts +2 -1
  163. package/dist/sandbox/repository-lock.js +19 -9
  164. package/dist/sandbox/runtime.d.ts +16 -2
  165. package/dist/sandbox/runtime.js +183 -114
  166. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  167. package/dist/sandbox/sandbox-cgroups.js +42 -0
  168. package/dist/sandbox/sandbox.types.d.ts +7 -0
  169. package/dist/sandbox/workspace.service.js +2 -0
  170. package/dist/session/architect-waits.d.ts +2 -0
  171. package/dist/session/architect-waits.js +138 -0
  172. package/dist/session/managed-attempt-tools.d.ts +37 -1
  173. package/dist/session/managed-attempt-tools.js +822 -84
  174. package/dist/session/managed-build-coordinator.d.ts +5 -0
  175. package/dist/session/managed-build-coordinator.js +109 -0
  176. package/dist/session/managed-build-receipt.d.ts +26 -0
  177. package/dist/session/managed-build-receipt.js +342 -0
  178. package/dist/session/managed-command-host-load.d.ts +47 -0
  179. package/dist/session/managed-command-host-load.js +83 -0
  180. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  181. package/dist/session/managed-verification-timeouts.js +17 -0
  182. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  183. package/dist/session/mcp-argument-coercion.js +121 -0
  184. package/dist/session/phase-completion.artifacts.d.ts +24 -0
  185. package/dist/session/phase-completion.artifacts.js +321 -45
  186. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  187. package/dist/session/phase-completion.command-validation.js +77 -0
  188. package/dist/session/phase-completion.d.ts +23 -1
  189. package/dist/session/phase-completion.helpers.d.ts +5 -0
  190. package/dist/session/phase-completion.helpers.js +43 -19
  191. package/dist/session/phase-completion.js +19 -3
  192. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  193. package/dist/session/phase-completion.mcp-args.js +156 -0
  194. package/dist/session/phase-completion.prompts.js +22 -18
  195. package/dist/session/phase-completion.runtime.d.ts +6 -10
  196. package/dist/session/phase-completion.runtime.js +214 -224
  197. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  198. package/dist/session/phase-completion.schema-parts.js +188 -0
  199. package/dist/session/phase-completion.schemas.d.ts +3 -3
  200. package/dist/session/phase-completion.schemas.js +250 -226
  201. package/dist/session/phase-completion.validation.d.ts +3 -3
  202. package/dist/session/phase-completion.validation.js +135 -89
  203. package/dist/session/pre-publication-host-load.d.ts +27 -0
  204. package/dist/session/pre-publication-host-load.js +111 -0
  205. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  206. package/dist/session/pre-publication-native-postgres.js +111 -0
  207. package/dist/session/pre-publication-pass.d.ts +61 -0
  208. package/dist/session/pre-publication-pass.js +148 -0
  209. package/dist/session/pre-publication-process.d.ts +23 -0
  210. package/dist/session/pre-publication-process.js +109 -0
  211. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  212. package/dist/session/pre-publication-skipped-tests.js +109 -0
  213. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  214. package/dist/session/pre-publication-step-execution.js +50 -0
  215. package/dist/session/pre-publication-validation.d.ts +91 -0
  216. package/dist/session/pre-publication-validation.js +670 -0
  217. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  218. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  219. package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
  220. package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
  221. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  222. package/dist/session/provider-cli/claude-background-work.js +181 -0
  223. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  224. package/dist/session/provider-cli/host-build-lock.js +30 -0
  225. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  226. package/dist/session/provider-cli/pre-publication-repair.js +276 -0
  227. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
  228. package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
  229. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  230. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  231. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  232. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  233. package/dist/session/provider-cli/provider-cli.deterministic.js +34 -2
  234. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  235. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  236. package/dist/session/provider-cli/provider-cli.process.d.ts +85 -19
  237. package/dist/session/provider-cli/provider-cli.process.js +566 -283
  238. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -0
  239. package/dist/session/provider-cli/provider-cli.prompts.js +211 -36
  240. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  241. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  242. package/dist/session/provider-cli/provider-cli.runtime.d.ts +22 -1
  243. package/dist/session/provider-cli/provider-cli.runtime.js +83 -4
  244. package/dist/session/provider-cli/provider-cli.service.d.ts +36 -5
  245. package/dist/session/provider-cli/provider-cli.service.js +818 -99
  246. package/dist/session/provider-cli/provider-cli.types.d.ts +32 -0
  247. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  248. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  249. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  250. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  251. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  252. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  253. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  254. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  255. package/dist/session/provider-cli/provider-output-state.d.ts +18 -0
  256. package/dist/session/provider-cli/provider-output-state.js +376 -17
  257. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  258. package/dist/session/provider-cli/provider-usage.js +28 -5
  259. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  260. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  261. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  262. package/dist/session/publishable-worktree-changes.js +193 -0
  263. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  264. package/dist/session/qa-sidecar-validation.js +28 -0
  265. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  266. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  267. package/dist/session/session-redaction.js +284 -9
  268. package/dist/session/session.base.d.ts +9 -1
  269. package/dist/session/session.service.d.ts +11 -2
  270. package/dist/session/session.service.js +301 -58
  271. package/dist/session/session.types.d.ts +150 -2
  272. package/dist/session/session.types.js +599 -7
  273. package/dist/session/sidecar-json-shape.d.ts +31 -0
  274. package/dist/session/sidecar-json-shape.js +217 -0
  275. package/dist/session/unreferenced-exports.d.ts +12 -0
  276. package/dist/session/unreferenced-exports.js +59 -0
  277. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  278. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  279. package/dist/shared/format/format-bytes.d.ts +1 -0
  280. package/dist/shared/format/format-bytes.js +9 -0
  281. package/dist/shared/fs/file-identity.d.ts +10 -0
  282. package/dist/shared/fs/file-identity.js +15 -0
  283. package/dist/shared/fs/replace-file.d.ts +7 -0
  284. package/dist/shared/fs/replace-file.js +33 -0
  285. package/dist/shared/git/git.js +2 -1
  286. package/dist/shared/path/path.d.ts +1 -0
  287. package/dist/shared/path/path.js +18 -0
  288. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  289. package/dist/shared/process/dotnet-toolchain.js +307 -0
  290. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  291. package/dist/shared/process/host-process-recovery.js +26 -5
  292. package/dist/shared/process/host-process-supervisor.d.ts +16 -1
  293. package/dist/shared/process/host-process-supervisor.js +124 -23
  294. package/dist/shared/process/process-tree.d.ts +52 -0
  295. package/dist/shared/process/process-tree.js +144 -0
  296. package/dist/shared/process/process.d.ts +69 -0
  297. package/dist/shared/process/process.js +223 -16
  298. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  299. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  300. package/dist/shared/process/windows-launch.d.ts +18 -0
  301. package/dist/shared/process/windows-launch.js +68 -0
  302. package/dist/shared/provider-capabilities.d.ts +3 -0
  303. package/dist/shared/provider-capabilities.js +92 -0
  304. package/dist/shared/redaction/redaction.d.ts +1 -0
  305. package/dist/shared/redaction/redaction.js +39 -3
  306. package/dist/shared/time/monotonic.d.ts +1 -0
  307. package/dist/shared/time/monotonic.js +8 -0
  308. package/dist/version.d.ts +1 -1
  309. package/dist/version.js +1 -1
  310. package/dist/worktree/dependency-warmer.d.ts +66 -9
  311. package/dist/worktree/dependency-warmer.js +609 -24
  312. package/dist/worktree/index.d.ts +1 -1
  313. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  314. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  315. package/dist/worktree/wip-git.d.ts +33 -0
  316. package/dist/worktree/wip-git.js +122 -0
  317. package/dist/worktree/wip-refs.d.ts +62 -0
  318. package/dist/worktree/wip-refs.js +119 -0
  319. package/dist/worktree/wip-restore.d.ts +38 -0
  320. package/dist/worktree/wip-restore.js +190 -0
  321. package/dist/worktree/wip-snapshot.d.ts +50 -0
  322. package/dist/worktree/wip-snapshot.js +268 -0
  323. package/dist/worktree/worktree-wip-events.d.ts +18 -0
  324. package/dist/worktree/worktree-wip-events.js +98 -0
  325. package/dist/worktree/worktree-wip.d.ts +49 -0
  326. package/dist/worktree/worktree-wip.js +182 -0
  327. package/dist/worktree/worktree.base.d.ts +7 -1
  328. package/dist/worktree/worktree.service.d.ts +22 -2
  329. package/dist/worktree/worktree.service.js +302 -25
  330. package/dist/worktree/worktree.types.d.ts +36 -1
  331. package/package.json +8 -6
  332. package/runtime/windows-job-supervisor.ps1 +380 -14
@@ -1,7 +1,8 @@
1
1
  import { GitClient } from "../../shared/git/git.js";
2
2
  import { type CompletionPhase, type CompletionToolRuntime, type DebugCompletionPhase, type QaCompletionGate } from "../phase-completion.js";
3
- import type { RunOnceDispatchPacket, RunnerDispatchArtifact } from "../session.types.js";
3
+ import type { RunOnceDispatchPacket, RunnerDispatchArtifact, RunnerDispatchSidecar } from "../session.types.js";
4
4
  import type { ProviderCliRunContext } from "./provider-cli.types.js";
5
+ import { type ProviderProcessRunResult } from "./provider-cli.process.js";
5
6
  export declare function emitDraftGateArtifacts(emit: ProviderCliRunContext["emit"], worktreePath: string, workItemId: string): Promise<void>;
6
7
  export declare function emitDecomposeGateArtifacts(emit: ProviderCliRunContext["emit"], worktreePath: string, workItemId: string): Promise<void>;
7
8
  export declare function fileExists(filePath: string): Promise<boolean>;
@@ -9,10 +10,11 @@ export declare function summarizeStderr(stderr: string): string;
9
10
  export declare function waitForCompletionArtifact(worktreePath: string, workItemId: string, phase: "draft" | "decompose", signal?: AbortSignal): Promise<RunnerDispatchArtifact>;
10
11
  export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
11
12
  export declare function cleanupCompletionTools(completionTools: CompletionToolRuntime, emit: ProviderCliRunContext["emit"]): Promise<void>;
12
- export declare function commitWorktreeChanges(git: GitClient, worktreePath: string, workItemId: string): Promise<{
13
+ export declare function commitWorktreeChanges(git: GitClient, worktreePath: string, workItemId: string, alreadyStagedChangedFiles?: readonly string[]): Promise<{
13
14
  readonly commitSha: string;
14
15
  readonly changedFiles: readonly string[];
15
16
  }>;
17
+ export declare function stagePublishableWorktreeChanges(git: GitClient, worktreePath: string): Promise<readonly string[]>;
16
18
  export declare function phaseCompleteEventType(phase: CompletionPhase): string;
17
19
  export declare function isDebugCompletionPhaseForProvider(phase: CompletionPhase): phase is DebugCompletionPhase;
18
20
  export declare function emitQaArtifactRecorded(emit: ProviderCliRunContext["emit"], worktreePath: string, artifact: RunnerDispatchArtifact): Promise<void>;
@@ -20,6 +22,7 @@ export declare function readQaCompletionArtifactBundle(worktreePath: string, wor
20
22
  export declare function hasCompleteQaArtifactBundle(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<boolean>;
21
23
  export declare function enforceQaBrowserLaunchTargetGate(dispatch: RunOnceDispatchPacket, artifact: RunnerDispatchArtifact): Promise<void>;
22
24
  export declare function validateQaBundleSidecarReferences(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<void>;
25
+ export declare function readQaBundleSidecars(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<RunnerDispatchSidecar[]>;
23
26
  export declare function emitQaStructuredEvents(emit: ProviderCliRunContext["emit"], artifact: RunnerDispatchArtifact): Promise<void>;
24
27
  interface QaGateArtifactSnapshot {
25
28
  readonly gate: QaCompletionGate;
@@ -89,5 +92,5 @@ export declare class LiveCompletionArtifactEmitter {
89
92
  private pollQueued;
90
93
  private poll;
91
94
  }
92
- export declare function readCompletionArtifactsForRun(worktreePath: string, workItemId: string, phase: CompletionPhase, developCycle: boolean, debugCycle: boolean): Promise<RunnerDispatchArtifact[]>;
95
+ export declare function readCompletionArtifactsForRun(worktreePath: string, workItemId: string, phase: CompletionPhase, developCycle: boolean, debugCycle: boolean, providerResult?: Pick<ProviderProcessRunResult, "terminalStopReason"> | null): Promise<RunnerDispatchArtifact[]>;
93
96
  export {};
@@ -2,10 +2,14 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { artifactRootFor, artifactRootForOwner, debugCompletionPhaseOrder, draftCompletionGateOrder, qaCompletionGateOrder, readCompletionArtifact } from "../phase-completion.js";
4
4
  import { ensureNoSymbolicLinkPathSegments, isPathUnderRoot, sha256File } from "../qa-sidecar-validation.js";
5
+ import { isRuntimeOnlyPath, stagePublishableWorktreeChangeSet } from "../publishable-worktree-changes.js";
6
+ import { providerCompletionToolMissingFailure } from "./provider-cli.process.js";
5
7
  import { hasLaunchTarget } from "./provider-cli.qa-sidecars.js";
6
8
  import { clip, isNodeError, messageFromError, normalizedString, parseJsonLine, stringField } from "./provider-output-state.js";
9
+ import { assertMergeResolutionPreservesUpstreamChanges, isMergeInProgress, mergeResolutionCommitNotes } from "./provider-cli.merge-integrity.js";
10
+ const maxTransportedQaSidecarBytes = 8 * 1024 * 1024;
11
+ const maxTransportedQaSidecarsTotalBytes = 16 * 1024 * 1024;
7
12
  const developCyclePhaseOrder = ["implementation", "self_review", "validation"];
8
- const nonPublishableWorktreePaths = [".forge", ".local"];
9
13
  export async function emitDraftGateArtifacts(emit, worktreePath, workItemId) {
10
14
  const draftArtifactFiles = {
11
15
  draft_intent: "draft.intent.json",
@@ -146,24 +150,28 @@ export async function cleanupCompletionTools(completionTools, emit) {
146
150
  }).catch(() => undefined);
147
151
  }
148
152
  }
149
- export async function commitWorktreeChanges(git, worktreePath, workItemId) {
150
- await git.run(worktreePath, ["add", "-A"]);
151
- for (const reservedPath of nonPublishableWorktreePaths) {
152
- await git.run(worktreePath, ["reset", "--", reservedPath]).catch(() => "");
153
- }
154
- const changedFiles = (await git.run(worktreePath, ["diff", "--cached", "--name-only"]))
155
- .split(/\r?\n/)
156
- .map((line) => line.trim())
157
- .filter(Boolean);
158
- if (changedFiles.length > 0) {
159
- await git.run(worktreePath, ["commit", "-m", `provider cli changeset for ${workItemId.slice(0, 8)}`]);
160
- }
161
- else {
162
- await git.run(worktreePath, ["commit", "--allow-empty", "-m", `provider cli completed for ${workItemId.slice(0, 8)}`]);
153
+ export async function commitWorktreeChanges(git, worktreePath, workItemId, alreadyStagedChangedFiles) {
154
+ const changedFiles = alreadyStagedChangedFiles ?? await stagePublishableWorktreeChanges(git, worktreePath);
155
+ const mergeReport = await assertMergeResolutionPreservesUpstreamChanges(git, worktreePath, { ignorePath: isRuntimeOnlyPath });
156
+ // A merge is always finalized, even when every change it brought is unpublishable
157
+ // runtime output; skipping the commit would leave MERGE_HEAD dangling.
158
+ const merging = await isMergeInProgress(git, worktreePath);
159
+ if (changedFiles.length > 0 || merging) {
160
+ const notes = mergeResolutionCommitNotes(mergeReport).flatMap(note => ["-m", note]);
161
+ await git.run(worktreePath, [
162
+ "commit",
163
+ ...(changedFiles.length === 0 ? ["--allow-empty"] : []),
164
+ "-m",
165
+ `provider cli changeset for ${workItemId.slice(0, 8)}`,
166
+ ...notes,
167
+ ]);
163
168
  }
164
169
  const commitSha = (await git.run(worktreePath, ["rev-parse", "HEAD"])).trim();
165
170
  return { commitSha, changedFiles };
166
171
  }
172
+ export async function stagePublishableWorktreeChanges(git, worktreePath) {
173
+ return (await stagePublishableWorktreeChangeSet(git, worktreePath)).publishable;
174
+ }
167
175
  export function phaseCompleteEventType(phase) {
168
176
  return phase === "implementation" ? "implementation_complete" : `${phase}_complete`;
169
177
  }
@@ -212,12 +220,13 @@ export async function readQaCompletionArtifactBundle(worktreePath, workItemId, o
212
220
  const planJson = await fs.readFile(path.join(artifactRoot, qaArtifactFileNames.plan), "utf8");
213
221
  const evidenceJson = await fs.readFile(path.join(artifactRoot, qaArtifactFileNames.evidence), "utf8");
214
222
  const findingsJson = await fs.readFile(path.join(artifactRoot, qaArtifactFileNames.findings), "utf8");
215
- await validateQaBundleSidecarReferences(worktreePath, workItemId, ownerType, ownerId);
223
+ const sidecars = await readQaBundleSidecars(worktreePath, workItemId, ownerType, ownerId);
216
224
  return {
217
225
  ...artifact,
218
226
  planJson,
219
227
  evidenceJson,
220
- findingsJson
228
+ findingsJson,
229
+ sidecars
221
230
  };
222
231
  }
223
232
  export async function hasCompleteQaArtifactBundle(worktreePath, workItemId, ownerType, ownerId) {
@@ -274,15 +283,21 @@ function hasPassingRepositoryPlaywrightEvidence(evidence) {
274
283
  });
275
284
  }
276
285
  export async function validateQaBundleSidecarReferences(worktreePath, workItemId, ownerType, ownerId) {
286
+ await readQaBundleSidecars(worktreePath, workItemId, ownerType, ownerId);
287
+ }
288
+ export async function readQaBundleSidecars(worktreePath, workItemId, ownerType, ownerId) {
277
289
  const artifactRoot = ownerType && ownerId
278
290
  ? artifactRootForOwner(worktreePath, ownerType, ownerId)
279
291
  : artifactRootFor(worktreePath, workItemId);
280
292
  const evidence = await readJsonObjectFile(path.join(artifactRoot, qaArtifactFileNames.evidence));
281
293
  const sidecars = arrayField(evidence, "sidecars");
282
294
  if (sidecars.length === 0) {
283
- return;
295
+ return [];
284
296
  }
285
297
  const qaSidecarRoot = path.resolve(artifactRoot, "qa");
298
+ const transported = [];
299
+ const transportedByPath = new Map();
300
+ let totalBytes = 0;
286
301
  for (const [index, sidecar] of sidecars.entries()) {
287
302
  const sidecarPath = stringField(sidecar, "path");
288
303
  const expectedHash = stringField(sidecar, "content_hash");
@@ -312,11 +327,36 @@ export async function validateQaBundleSidecarReferences(worktreePath, workItemId
312
327
  if (stat.size !== expectedBytes) {
313
328
  throw new Error(`QA sidecar ${index} bytes do not match the referenced file.`);
314
329
  }
330
+ if (stat.size > maxTransportedQaSidecarBytes) {
331
+ throw new Error(`QA sidecar ${index} exceeds the ${maxTransportedQaSidecarBytes}-byte transport limit.`);
332
+ }
315
333
  const actualHash = await sha256File(fullPath);
316
334
  if (actualHash !== expectedHash.trim().toLowerCase()) {
317
335
  throw new Error(`QA sidecar ${index} content_hash does not match the referenced file.`);
318
336
  }
337
+ const canonicalPath = path.relative(worktreePath, fullPath).split(path.sep).join("/");
338
+ const duplicateKey = canonicalPath.toLowerCase();
339
+ const existing = transportedByPath.get(duplicateKey);
340
+ if (existing) {
341
+ if (existing.contentHash !== actualHash || existing.bytes !== stat.size) {
342
+ throw new Error(`QA sidecar ${index} conflicts with another payload for ${canonicalPath}.`);
343
+ }
344
+ continue;
345
+ }
346
+ totalBytes += stat.size;
347
+ if (totalBytes > maxTransportedQaSidecarsTotalBytes) {
348
+ throw new Error(`QA sidecars exceed the ${maxTransportedQaSidecarsTotalBytes}-byte total transport limit.`);
349
+ }
350
+ const content = await fs.readFile(fullPath);
351
+ transportedByPath.set(duplicateKey, { contentHash: actualHash, bytes: stat.size });
352
+ transported.push({
353
+ path: canonicalPath,
354
+ contentBase64: content.toString("base64"),
355
+ contentHash: actualHash,
356
+ bytes: stat.size
357
+ });
319
358
  }
359
+ return transported;
320
360
  }
321
361
  export async function emitQaStructuredEvents(emit, artifact) {
322
362
  const artifactRoot = path.dirname(artifact.path);
@@ -745,11 +785,11 @@ export class LiveCompletionArtifactEmitter {
745
785
  }
746
786
  }
747
787
  }
748
- export async function readCompletionArtifactsForRun(worktreePath, workItemId, phase, developCycle, debugCycle) {
788
+ export async function readCompletionArtifactsForRun(worktreePath, workItemId, phase, developCycle, debugCycle, providerResult) {
749
789
  if (!developCycle && !debugCycle) {
750
790
  const artifact = await readCompletionArtifact(worktreePath, workItemId, phase);
751
791
  if (!artifact) {
752
- throw new Error(`Provider CLI completed but did not call the Forge ${phase} completion tool.`);
792
+ throw providerCompletionToolMissingFailure(`Provider CLI completed but did not call the Forge ${phase} completion tool.`, providerResult);
753
793
  }
754
794
  return [artifact];
755
795
  }
@@ -761,11 +801,11 @@ export async function readCompletionArtifactsForRun(worktreePath, workItemId, ph
761
801
  const artifact = await readCompletionArtifact(worktreePath, workItemId, expectedPhase);
762
802
  if (!artifact) {
763
803
  if (artifacts.length === 0) {
764
- throw new Error(`Provider CLI completed but did not call the Forge ${expectedPhase} completion tool.`);
804
+ throw providerCompletionToolMissingFailure(`Provider CLI completed but did not call the Forge ${expectedPhase} completion tool.`, providerResult);
765
805
  }
766
806
  const previous = artifacts[artifacts.length - 1];
767
807
  if ((previous.status ?? "").trim().toLowerCase() === "pass") {
768
- throw new Error(`Provider CLI completed after ${previous.phase} passed but did not call the Forge ${expectedPhase} completion tool.`);
808
+ throw providerCompletionToolMissingFailure(`Provider CLI completed after ${previous.phase} passed but did not call the Forge ${expectedPhase} completion tool.`, providerResult);
769
809
  }
770
810
  return artifacts;
771
811
  }
@@ -0,0 +1,7 @@
1
+ export interface ProviderChildEnvironmentOptions {
2
+ readonly parentEnv?: NodeJS.ProcessEnv;
3
+ readonly platform?: NodeJS.Platform;
4
+ readonly homeDir?: string;
5
+ readonly arch?: string;
6
+ }
7
+ export declare function buildProviderChildEnvironment(requestEnv?: Readonly<Record<string, string>>, options?: ProviderChildEnvironmentOptions): NodeJS.ProcessEnv;
@@ -0,0 +1,75 @@
1
+ import os from "node:os";
2
+ import { normalizeWindowsProviderEnvironment, windowsAllowedProviderParentEnvNames } from "./provider-cli.windows-environment.js";
3
+ // The environment a provider child process starts with: an allowlist of the Bridge's own
4
+ // variables, the request's values, the Windows defaults, then the .NET build-server settings.
5
+ // CLAUDE_CONFIG_DIR is not passed: it would point Claude Code at a user configuration directory
6
+ // of the host's choosing (provider-user-config-isolation.ts). Claude signs in from the provider
7
+ // home's default `.claude` directory under HOME or USERPROFILE, or with a Forge-granted API key.
8
+ const allowedProviderParentEnvNames = [
9
+ "PATH",
10
+ "HOME",
11
+ "USERPROFILE",
12
+ "TMPDIR",
13
+ "TEMP",
14
+ "TMP",
15
+ "LANG"
16
+ ];
17
+ export function buildProviderChildEnvironment(requestEnv, options = {}) {
18
+ const parentEnv = options.parentEnv ?? process.env;
19
+ const platform = options.platform ?? process.platform;
20
+ const env = {};
21
+ for (const [key, value] of Object.entries(parentEnv)) {
22
+ if (typeof value === "string" && isAllowedProviderParentEnv(key, platform)) {
23
+ env[key] = value;
24
+ }
25
+ }
26
+ if (requestEnv) {
27
+ for (const [key, value] of Object.entries(requestEnv)) {
28
+ const trimmedKey = key.trim();
29
+ if (trimmedKey.length > 0) {
30
+ env[trimmedKey] = value;
31
+ }
32
+ }
33
+ }
34
+ if (platform === "win32") {
35
+ normalizeWindowsProviderEnvironment(env, parentEnv, options.homeDir ?? os.homedir(), options.arch ?? os.arch());
36
+ }
37
+ normalizeProviderBuildEnvironment(env);
38
+ return env;
39
+ }
40
+ function normalizeProviderBuildEnvironment(env) {
41
+ // Provider sessions are long lived and commonly run many dotnet builds. Persistent
42
+ // MSBuild and Roslyn compiler servers otherwise survive individual commands and can
43
+ // retain more memory than the active Forge lane. Keep those caches process-scoped by
44
+ // default on every runner OS; an explicitly supplied request value still wins.
45
+ setCanonicalProviderBuildEnvironmentValue(env, "DOTNET_CLI_USE_MSBUILD_SERVER", "0");
46
+ setCanonicalProviderBuildEnvironmentValue(env, "MSBUILDDISABLENODEREUSE", "1");
47
+ setCanonicalProviderBuildEnvironmentValue(env, "UseSharedCompilation", "false");
48
+ }
49
+ function setCanonicalProviderBuildEnvironmentValue(env, name, value) {
50
+ // The dotnet CLI uses case-sensitive environment lookup on POSIX, while MSBuild
51
+ // property names are case-insensitive on every OS. Collapse request aliases to
52
+ // one canonical key so the explicit value wins without producing ambiguity.
53
+ const exact = env[name];
54
+ const alias = Object.entries(env).find(([key, candidate]) => key !== name
55
+ && key.toLowerCase() === name.toLowerCase()
56
+ && typeof candidate === "string"
57
+ && candidate.trim().length > 0)?.[1];
58
+ const resolved = typeof exact === "string" && exact.trim().length > 0
59
+ ? exact
60
+ : alias ?? value;
61
+ for (const key of Object.keys(env)) {
62
+ if (key !== name && key.toLowerCase() === name.toLowerCase()) {
63
+ delete env[key];
64
+ }
65
+ }
66
+ env[name] = resolved;
67
+ }
68
+ function isAllowedProviderParentEnv(key, platform = process.platform) {
69
+ return isAllowedProviderParentEnvName(key, allowedProviderParentEnvNames)
70
+ || key.toUpperCase().startsWith("LC_")
71
+ || (platform === "win32" && isAllowedProviderParentEnvName(key, windowsAllowedProviderParentEnvNames));
72
+ }
73
+ function isAllowedProviderParentEnvName(key, allowedNames) {
74
+ return allowedNames.some((allowed) => allowed.toLowerCase() === key.toLowerCase());
75
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProviderProcessRunResult } from "./provider-cli.process.js";
2
+ export declare function isCodexModelsCacheSchemaFailure(result: ProviderProcessRunResult): boolean;
3
+ export declare function quarantineIncompatibleCodexModelsCache(requestEnv?: Readonly<Record<string, string>>): Promise<boolean>;
@@ -0,0 +1,37 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { readEnvironmentValue } from "./provider-cli.windows-environment.js";
6
+ const maximumRecoverableCodexModelsCacheBytes = 16 * 1024 * 1024;
7
+ export function isCodexModelsCacheSchemaFailure(result) {
8
+ const output = `${result.stderr}\n${result.stdout}`.toLowerCase();
9
+ return output.includes("base_instructions")
10
+ && output.includes("missing field")
11
+ && (output.includes("models_cache") || output.includes("models cache") || output.includes("model cache"));
12
+ }
13
+ export async function quarantineIncompatibleCodexModelsCache(requestEnv) {
14
+ const configuredHome = readEnvironmentValue(requestEnv ?? {}, "CODEX_HOME")
15
+ ?? readEnvironmentValue(process.env, "CODEX_HOME")
16
+ ?? readEnvironmentValue(process.env, "FORGE_CODEX_HOME");
17
+ const codexHome = path.resolve(configuredHome ?? path.join(os.homedir(), ".codex"));
18
+ if (!path.isAbsolute(codexHome) || codexHome === path.parse(codexHome).root)
19
+ return false;
20
+ const cachePath = path.join(codexHome, "models_cache.json");
21
+ const cacheStat = await fs.promises.lstat(cachePath).catch(error => {
22
+ if (error.code === "ENOENT")
23
+ return null;
24
+ throw error;
25
+ });
26
+ if (!cacheStat
27
+ || !cacheStat.isFile()
28
+ || cacheStat.isSymbolicLink()
29
+ || cacheStat.nlink !== 1
30
+ || cacheStat.size <= 0
31
+ || cacheStat.size > maximumRecoverableCodexModelsCacheBytes) {
32
+ return false;
33
+ }
34
+ const quarantinePath = path.join(codexHome, `models_cache.forge-incompatible-${Date.now()}-${randomUUID()}.json`);
35
+ await fs.promises.rename(cachePath, quarantinePath);
36
+ return true;
37
+ }
@@ -3,12 +3,13 @@ import path from "node:path";
3
3
  import { GitClient } from "../../shared/git/git.js";
4
4
  import { buildSpecBody, selectLaneCommand } from "../../worktree/artifact-injector.js";
5
5
  import { completionPhaseFromDispatch, debugCompletionPhaseOrder, expectedCompletionToolName, expectedDebugCompletionToolName, expectedQaCompletionToolName, qaCompletionGateOrder, readCompletionArtifact, usesDebugCycleCompletion, usesDevelopCycleCompletion, writeCompletionArtifact } from "../phase-completion.js";
6
- import { emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitQaArtifactRecorded, emitQaGateAccepted, emitQaStructuredEvents, isDebugCompletionPhaseForProvider, nextQaGate, phaseCompleteEventType, qaArtifactRootForDispatch, readQaCompletionArtifactBundle, readQaGateArtifact } from "./provider-cli.artifacts.js";
6
+ import { commitWorktreeChanges, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitQaArtifactRecorded, emitQaGateAccepted, emitQaStructuredEvents, isDebugCompletionPhaseForProvider, nextQaGate, phaseCompleteEventType, qaArtifactRootForDispatch, readQaCompletionArtifactBundle, readQaGateArtifact } from "./provider-cli.artifacts.js";
7
7
  import { deterministicBrowserCheck, deterministicBrowserSidecar, hasLaunchTarget, writeQaSidecarFiles } from "./provider-cli.qa-sidecars.js";
8
8
  import { buildProviderCliCommand, formatProviderCliCommand, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch, singleLine } from "./provider-cli.prompts.js";
9
9
  import { estimatedDeterministicUsage, exactRedactionSecrets } from "./provider-cli.runtime.js";
10
10
  import { buildProviderUsageEvent } from "./provider-usage.js";
11
11
  import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
12
+ import { assertRepairHeadEpoch } from "./provider-cli.repair-epoch.js";
12
13
  import { deterministicArchitectPayload, deterministicCompletionPayload, deterministicQaGatePayload } from "./provider-cli.deterministic-payloads.js";
13
14
  export class DeterministicProviderCliService {
14
15
  git;
@@ -211,6 +212,7 @@ export class DeterministicProviderCliService {
211
212
  }
212
213
  async runPullRequestRepair(context, route) {
213
214
  const { dispatch, worktree } = context;
215
+ await assertRepairHeadEpoch(context, this.git);
214
216
  const repairChecks = route === "ci_repair" || isPullRequestCheckRepairDispatch(dispatch);
215
217
  const addressComments = isPullRequestCommentsDispatch(dispatch);
216
218
  let repairArtifact = null;
@@ -238,7 +240,37 @@ export class DeterministicProviderCliService {
238
240
  throw new Error(`Deterministic CI repair did not produce ${reference.path}.`);
239
241
  await emitCompletionArtifactRecorded(context.emit, worktree.worktreePath, repairArtifact);
240
242
  }
241
- await this.git.run(worktree.worktreePath, ["commit", "--allow-empty", "-m", `forge bridge ${repairChecks ? "ci repair" : addressComments ? "pr comments" : "conflict resolve"} for ${dispatch.workItem.id.slice(0, 8)}`]);
243
+ if (addressComments) {
244
+ const actionable = dispatch.pullRequest?.reviewFindings.filter(finding => finding.actionable) ?? [];
245
+ if (actionable.length === 0 || !dispatch.pullRequest?.reviewIssueKey || !dispatch.pullRequest.headSha) {
246
+ throw new Error("Deterministic comment repair requires a durable actionable finding snapshot.");
247
+ }
248
+ await writeCompletionArtifact({
249
+ worktreePath: worktree.worktreePath,
250
+ workItemId: dispatch.workItem.id,
251
+ phase: "comment_repair",
252
+ producedBy: "forge-deterministic-provider",
253
+ }, expectedCompletionToolName("comment_repair"), {
254
+ status: "pass",
255
+ summary: "Recorded deterministic decision-required outcomes without changing source.",
256
+ repair_head_sha: dispatch.pullRequest.headSha,
257
+ repair_issue_key: dispatch.pullRequest.reviewIssueKey,
258
+ dispositions: actionable.map(finding => ({
259
+ claim_id: finding.claimId,
260
+ kind: finding.kind,
261
+ body_sha256: finding.bodySha256,
262
+ disposition: "needs_decision",
263
+ evidence: "The deterministic provider cannot evaluate semantic review feedback."
264
+ })),
265
+ changed_files: [],
266
+ validation: []
267
+ });
268
+ repairArtifact = await readCompletionArtifact(worktree.worktreePath, dispatch.workItem.id, "comment_repair");
269
+ if (!repairArtifact)
270
+ throw new Error("Deterministic comment repair did not produce its completion artifact.");
271
+ await emitCompletionArtifactRecorded(context.emit, worktree.worktreePath, repairArtifact);
272
+ }
273
+ await commitWorktreeChanges(this.git, worktree.worktreePath, dispatch.workItem.id);
242
274
  await context.emit(buildProviderUsageEvent(dispatch, estimatedDeterministicUsage()));
243
275
  await context.emit({
244
276
  role: "assistant",
@@ -0,0 +1,89 @@
1
+ import type { GitClient } from "../../shared/git/git.js";
2
+ import { ForgeFailureError } from "../session.types.js";
3
+ /**
4
+ * Publication guards for a provider-run `git merge --no-commit` that Forge Bridge
5
+ * turns into the final merge commit (the conflict-resolve lane, and any repair
6
+ * lane that merges the target branch).
7
+ *
8
+ * Forge stages with `git add -A` and then unstages worktree-local runtime paths
9
+ * such as `.forge` and `.local`. Unstaging resets those paths to HEAD, which is
10
+ * the story side of the merge. Without these guards that silently reverted every
11
+ * upstream change under those paths and re-added files the target branch had
12
+ * deleted (issue #491: 253 files on story/829e1219ee16 and story/6ac8c6c6e704).
13
+ */
14
+ type GitRunner = Pick<GitClient, "run">;
15
+ export interface InProgressMerge {
16
+ readonly headSha: string;
17
+ readonly mergeHeadSha: string;
18
+ readonly mergeBaseSha: string;
19
+ }
20
+ export interface MergeResolutionReport {
21
+ /**
22
+ * Paths the target branch deleted that the story had changed and that the
23
+ * resolution keeps. These are deliberate modify/delete decisions, recorded in
24
+ * the merge commit message so reviewers see them.
25
+ */
26
+ readonly keptOverUpstreamDeletion: readonly string[];
27
+ }
28
+ export type UnresolvedMergeConflictKind = "deleted_by_upstream" | "deleted_by_story" | "missing_while_unmerged" | "unresolved_binary" | "conflict_markers";
29
+ export interface UnresolvedMergeConflict {
30
+ readonly path: string;
31
+ readonly kind: UnresolvedMergeConflictKind;
32
+ }
33
+ /**
34
+ * The publication would re-add files that the target branch deleted, or revert
35
+ * target-branch edits, on paths the story never changed. Forge refuses to commit
36
+ * or push such a merge.
37
+ */
38
+ export declare class MergeResolutionRevertsUpstreamChangesError extends ForgeFailureError {
39
+ readonly merge: InProgressMerge;
40
+ readonly resurrectedPaths: readonly string[];
41
+ readonly revertedPaths: readonly string[];
42
+ readonly code = "merge_resolution_reverts_upstream_changes";
43
+ constructor(merge: InProgressMerge, resurrectedPaths: readonly string[], revertedPaths: readonly string[]);
44
+ }
45
+ /**
46
+ * A conflict is still unresolved when Forge would stage the merge: a
47
+ * modify/delete conflict nobody decided (`git add -A` would silently keep the
48
+ * modified side), or a content conflict whose file still has conflict markers
49
+ * (`git add -A` would commit them).
50
+ */
51
+ export declare class MergeResolutionUnresolvedConflictError extends ForgeFailureError {
52
+ readonly conflicts: readonly UnresolvedMergeConflict[];
53
+ readonly code = "merge_resolution_unresolved_conflict";
54
+ constructor(conflicts: readonly UnresolvedMergeConflict[]);
55
+ }
56
+ /** True while MERGE_HEAD exists, whether or not the histories share a merge base. */
57
+ export declare function isMergeInProgress(git: GitRunner, worktreePath: string): Promise<boolean>;
58
+ export declare function readInProgressMerge(git: GitRunner, worktreePath: string): Promise<InProgressMerge | null>;
59
+ /**
60
+ * Fails before `git add -A` can silently resolve a conflict:
61
+ * - a modify/delete conflict, by keeping whatever is on disk;
62
+ * - a binary (or other marker-less) conflict, by staging whichever side is on disk;
63
+ * - a content conflict, by staging its conflict markers. This includes markers
64
+ * the provider already staged, which clears the unmerged stages, so every path
65
+ * both sides changed is checked too.
66
+ * A text conflict the agent resolved in the working tree without `git add` is
67
+ * still unmerged here and is accepted once its markers are gone.
68
+ */
69
+ export declare function assertNoUnresolvedMergeConflicts(git: GitRunner, worktreePath: string): Promise<void>;
70
+ export declare function readUnresolvedMergeConflicts(git: GitRunner, worktreePath: string, merge: InProgressMerge): Promise<readonly UnresolvedMergeConflict[]>;
71
+ /**
72
+ * Staging excludes some worktree changes (Forge runtime output) by unstaging them
73
+ * back to HEAD. During a merge HEAD is the story side, so an excluded path the merge
74
+ * itself changed would lose the target's change. Given the excluded candidate
75
+ * paths, put the merge-owned ones back into the index: the target branch's version
76
+ * where the story never touched the path, and the agent's working-tree resolution
77
+ * where both sides changed it. Returns the restored paths; the rest stay excluded.
78
+ */
79
+ export declare function restoreMergeOwnedPaths(git: GitRunner, worktreePath: string, candidatePaths: readonly string[]): Promise<readonly string[]>;
80
+ /**
81
+ * Final check on the index Forge is about to commit. Throws when the merge
82
+ * resolution re-adds a path the target branch deleted, or drops a target-branch
83
+ * edit, on a path the story never changed.
84
+ */
85
+ export declare function assertMergeResolutionPreservesUpstreamChanges(git: GitRunner, worktreePath: string, options?: {
86
+ readonly ignorePath?: (filePath: string) => boolean;
87
+ }): Promise<MergeResolutionReport>;
88
+ export declare function mergeResolutionCommitNotes(report: MergeResolutionReport): readonly string[];
89
+ export {};