@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 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 (381) hide show
  1. package/README.md +306 -1
  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 +18 -1
  15. package/dist/bridge/bridge.service.d.ts +216 -4
  16. package/dist/bridge/bridge.service.js +2574 -90
  17. package/dist/bridge/bridge.types.d.ts +245 -2
  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 +33 -2
  41. package/dist/cleanup/cleanup.service.js +477 -3
  42. package/dist/cleanup/cleanup.types.d.ts +16 -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/index.d.ts +1 -1
  48. package/dist/cleanup/index.js +1 -1
  49. package/dist/cleanup/internals.d.ts +2 -2
  50. package/dist/cleanup/internals.js +1 -1
  51. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  52. package/dist/cleanup/managed-branch-sweep.js +111 -0
  53. package/dist/cli/cli.help.d.ts +2 -0
  54. package/dist/cli/cli.help.js +279 -0
  55. package/dist/cli/cli.service.d.ts +69 -12
  56. package/dist/cli/cli.service.js +557 -382
  57. package/dist/cli/idle-status.d.ts +84 -0
  58. package/dist/cli/idle-status.js +181 -0
  59. package/dist/cli/local-config.d.ts +13 -0
  60. package/dist/cli/local-config.js +82 -6
  61. package/dist/cli/provider-cli-detection.d.ts +10 -0
  62. package/dist/cli/provider-cli-detection.js +160 -0
  63. package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
  64. package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
  65. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  66. package/dist/runtime/attempt-database-broker.js +390 -0
  67. package/dist/runtime/attempt-node-runtime-launcher.d.ts +18 -0
  68. package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
  69. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  70. package/dist/runtime/attempt-path-operation.js +94 -0
  71. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  72. package/dist/runtime/attempt-private-directory.js +54 -0
  73. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  74. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  75. package/dist/runtime/attempt-process-supervisor.d.ts +121 -0
  76. package/dist/runtime/attempt-process-supervisor.js +471 -0
  77. package/dist/runtime/canonical-source-file.d.ts +3 -0
  78. package/dist/runtime/canonical-source-file.js +54 -0
  79. package/dist/runtime/docker-engine-probe.d.ts +95 -0
  80. package/dist/runtime/docker-engine-probe.js +340 -0
  81. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  82. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  83. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  84. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  85. package/dist/runtime/generated-output-reset.d.ts +20 -0
  86. package/dist/runtime/generated-output-reset.js +157 -0
  87. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  88. package/dist/runtime/host-database-capability-boundary.js +63 -0
  89. package/dist/runtime/host-diagnostics.d.ts +11 -0
  90. package/dist/runtime/host-diagnostics.js +192 -0
  91. package/dist/runtime/host-execution-root.d.ts +4 -0
  92. package/dist/runtime/host-execution-root.js +39 -0
  93. package/dist/runtime/host-facts.d.ts +36 -0
  94. package/dist/runtime/host-facts.js +95 -0
  95. package/dist/runtime/host-listener-inspector.d.ts +51 -0
  96. package/dist/runtime/host-listener-inspector.js +385 -0
  97. package/dist/runtime/host-load-admission.d.ts +67 -0
  98. package/dist/runtime/host-load-admission.js +99 -0
  99. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  100. package/dist/runtime/host-load-child-environment.js +76 -0
  101. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  102. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  103. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  104. package/dist/runtime/host-load-governor-config.js +83 -0
  105. package/dist/runtime/host-load-governor.d.ts +186 -0
  106. package/dist/runtime/host-load-governor.js +632 -0
  107. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  108. package/dist/runtime/host-load-ledger-lock.js +187 -0
  109. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  110. package/dist/runtime/host-load-runtime-settings.js +80 -0
  111. package/dist/runtime/host-load-sampler.d.ts +156 -0
  112. package/dist/runtime/host-load-sampler.js +298 -0
  113. package/dist/runtime/host-load-step-class.d.ts +70 -0
  114. package/dist/runtime/host-load-step-class.js +161 -0
  115. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  116. package/dist/runtime/host-load-step-reaper.js +95 -0
  117. package/dist/runtime/host-load-step-run.d.ts +73 -0
  118. package/dist/runtime/host-load-step-run.js +102 -0
  119. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  120. package/dist/runtime/host-load-test-slot.js +81 -0
  121. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  122. package/dist/runtime/host-load-token-ledger.js +453 -0
  123. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  124. package/dist/runtime/host-load-windows-cpu.js +85 -0
  125. package/dist/runtime/host-port-broker.d.ts +76 -0
  126. package/dist/runtime/host-port-broker.js +333 -0
  127. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  128. package/dist/runtime/host-pressure-stall.js +168 -0
  129. package/dist/runtime/host-runtime-contract.d.ts +74 -0
  130. package/dist/runtime/host-runtime-contract.js +846 -0
  131. package/dist/runtime/host-runtime-lease.d.ts +287 -0
  132. package/dist/runtime/host-runtime-lease.js +2763 -0
  133. package/dist/runtime/host-runtime-promotion.d.ts +55 -0
  134. package/dist/runtime/host-runtime-promotion.js +254 -0
  135. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  136. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  137. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  138. package/dist/runtime/host-runtime-requirements.js +117 -0
  139. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  140. package/dist/runtime/managed-command-teardown.js +596 -0
  141. package/dist/runtime/memory-capacity.d.ts +70 -0
  142. package/dist/runtime/memory-capacity.js +123 -0
  143. package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
  144. package/dist/runtime/native-test-postgres-fallback.js +143 -0
  145. package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
  146. package/dist/runtime/node-host-runtime-adapter.js +286 -0
  147. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  148. package/dist/runtime/pinned-directory-process.js +61 -0
  149. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  150. package/dist/runtime/pinned-source-directory.js +94 -0
  151. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  152. package/dist/runtime/playwright-browser-cache.js +227 -0
  153. package/dist/runtime/playwright-host-runtime-adapter.d.ts +39 -0
  154. package/dist/runtime/playwright-host-runtime-adapter.js +274 -0
  155. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  156. package/dist/runtime/prepared-runtime-identity.js +218 -0
  157. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  158. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  159. package/dist/runtime/runner-settings.d.ts +104 -0
  160. package/dist/runtime/runner-settings.js +236 -0
  161. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  162. package/dist/runtime/runtime-isolation-lease.js +161 -0
  163. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  164. package/dist/runtime/workspace-resource-estimator.js +174 -0
  165. package/dist/sandbox/command-runner.d.ts +4 -0
  166. package/dist/sandbox/command-runner.js +47 -0
  167. package/dist/sandbox/contract.d.ts +5 -0
  168. package/dist/sandbox/contract.js +276 -0
  169. package/dist/sandbox/event-budget.d.ts +11 -0
  170. package/dist/sandbox/event-budget.js +27 -0
  171. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  172. package/dist/sandbox/host-capacity-broker.js +336 -0
  173. package/dist/sandbox/image-policy.d.ts +35 -0
  174. package/dist/sandbox/image-policy.js +247 -0
  175. package/dist/sandbox/index.d.ts +5 -0
  176. package/dist/sandbox/index.js +5 -0
  177. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  178. package/dist/sandbox/lease-watchdog.js +67 -0
  179. package/dist/sandbox/managed-branch.d.ts +13 -0
  180. package/dist/sandbox/managed-branch.js +36 -0
  181. package/dist/sandbox/preflight.d.ts +84 -0
  182. package/dist/sandbox/preflight.js +521 -0
  183. package/dist/sandbox/process.d.ts +20 -0
  184. package/dist/sandbox/process.js +209 -0
  185. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  186. package/dist/sandbox/provider-auth/codex.js +212 -0
  187. package/dist/sandbox/repository-lock.d.ts +6 -0
  188. package/dist/sandbox/repository-lock.js +129 -0
  189. package/dist/sandbox/runtime.d.ts +311 -0
  190. package/dist/sandbox/runtime.js +2407 -0
  191. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  192. package/dist/sandbox/sandbox-cgroups.js +42 -0
  193. package/dist/sandbox/sandbox.types.d.ts +93 -0
  194. package/dist/sandbox/sandbox.types.js +1 -0
  195. package/dist/sandbox/smoke.d.ts +76 -0
  196. package/dist/sandbox/smoke.js +380 -0
  197. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  198. package/dist/sandbox/worker-supervisor.js +36 -0
  199. package/dist/sandbox/worker.d.ts +1 -0
  200. package/dist/sandbox/worker.js +225 -0
  201. package/dist/sandbox/workspace.service.d.ts +13 -0
  202. package/dist/sandbox/workspace.service.js +74 -0
  203. package/dist/session/architect-waits.d.ts +2 -0
  204. package/dist/session/architect-waits.js +138 -0
  205. package/dist/session/managed-attempt-tools.d.ts +48 -0
  206. package/dist/session/managed-attempt-tools.js +1299 -0
  207. package/dist/session/managed-build-coordinator.d.ts +5 -0
  208. package/dist/session/managed-build-coordinator.js +109 -0
  209. package/dist/session/managed-build-receipt.d.ts +26 -0
  210. package/dist/session/managed-build-receipt.js +342 -0
  211. package/dist/session/managed-command-host-load.d.ts +47 -0
  212. package/dist/session/managed-command-host-load.js +83 -0
  213. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  214. package/dist/session/managed-verification-timeouts.js +17 -0
  215. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  216. package/dist/session/mcp-argument-coercion.js +121 -0
  217. package/dist/session/phase-completion.artifacts.d.ts +34 -0
  218. package/dist/session/phase-completion.artifacts.js +903 -0
  219. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  220. package/dist/session/phase-completion.command-validation.js +77 -0
  221. package/dist/session/phase-completion.d.ts +65 -42
  222. package/dist/session/phase-completion.helpers.d.ts +117 -0
  223. package/dist/session/phase-completion.helpers.js +708 -0
  224. package/dist/session/phase-completion.js +130 -3007
  225. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  226. package/dist/session/phase-completion.mcp-args.js +156 -0
  227. package/dist/session/phase-completion.prompts.d.ts +14 -0
  228. package/dist/session/phase-completion.prompts.js +238 -0
  229. package/dist/session/phase-completion.runtime.d.ts +43 -0
  230. package/dist/session/phase-completion.runtime.js +721 -0
  231. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  232. package/dist/session/phase-completion.schema-parts.js +188 -0
  233. package/dist/session/phase-completion.schemas.d.ts +3 -0
  234. package/dist/session/phase-completion.schemas.js +836 -0
  235. package/dist/session/phase-completion.validation.d.ts +37 -0
  236. package/dist/session/phase-completion.validation.js +874 -0
  237. package/dist/session/pre-publication-host-load.d.ts +27 -0
  238. package/dist/session/pre-publication-host-load.js +111 -0
  239. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  240. package/dist/session/pre-publication-native-postgres.js +111 -0
  241. package/dist/session/pre-publication-pass.d.ts +61 -0
  242. package/dist/session/pre-publication-pass.js +148 -0
  243. package/dist/session/pre-publication-process.d.ts +23 -0
  244. package/dist/session/pre-publication-process.js +109 -0
  245. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  246. package/dist/session/pre-publication-skipped-tests.js +109 -0
  247. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  248. package/dist/session/pre-publication-step-execution.js +50 -0
  249. package/dist/session/pre-publication-validation.d.ts +91 -0
  250. package/dist/session/pre-publication-validation.js +670 -0
  251. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  252. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  253. package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
  254. package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
  255. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  256. package/dist/session/provider-cli/claude-background-work.js +181 -0
  257. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  258. package/dist/session/provider-cli/host-build-lock.js +30 -0
  259. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  260. package/dist/session/provider-cli/pre-publication-repair.js +276 -0
  261. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +96 -0
  262. package/dist/session/provider-cli/provider-cli.artifacts.js +818 -0
  263. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  264. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  265. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  266. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  267. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  268. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  269. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  270. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  271. package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
  272. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  273. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  274. package/dist/session/provider-cli/provider-cli.process.d.ts +114 -0
  275. package/dist/session/provider-cli/provider-cli.process.js +757 -0
  276. package/dist/session/provider-cli/provider-cli.prompts.d.ts +62 -0
  277. package/dist/session/provider-cli/provider-cli.prompts.js +770 -0
  278. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  279. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
  280. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  281. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  282. package/dist/session/provider-cli/provider-cli.runtime.d.ts +30 -0
  283. package/dist/session/provider-cli/provider-cli.runtime.js +120 -0
  284. package/dist/session/provider-cli/provider-cli.service.d.ts +53 -53
  285. package/dist/session/provider-cli/provider-cli.service.js +1299 -2523
  286. package/dist/session/provider-cli/provider-cli.types.d.ts +38 -0
  287. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  288. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  289. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  290. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  291. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  292. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  293. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  294. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  295. package/dist/session/provider-cli/provider-output-state.d.ts +40 -0
  296. package/dist/session/provider-cli/provider-output-state.js +832 -0
  297. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  298. package/dist/session/provider-cli/provider-usage.js +28 -5
  299. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  300. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  301. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  302. package/dist/session/publishable-worktree-changes.js +193 -0
  303. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  304. package/dist/session/qa-sidecar-validation.js +28 -0
  305. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  306. package/dist/session/sandbox-host-capacity-gate.js +257 -0
  307. package/dist/session/session-redaction.d.ts +3 -0
  308. package/dist/session/session-redaction.js +298 -0
  309. package/dist/session/session.base.d.ts +14 -1
  310. package/dist/session/session.service.d.ts +17 -2
  311. package/dist/session/session.service.js +708 -60
  312. package/dist/session/session.types.d.ts +327 -3
  313. package/dist/session/session.types.js +951 -10
  314. package/dist/session/sidecar-json-shape.d.ts +31 -0
  315. package/dist/session/sidecar-json-shape.js +217 -0
  316. package/dist/session/unreferenced-exports.d.ts +12 -0
  317. package/dist/session/unreferenced-exports.js +59 -0
  318. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  319. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  320. package/dist/shared/format/format-bytes.d.ts +1 -0
  321. package/dist/shared/format/format-bytes.js +9 -0
  322. package/dist/shared/fs/file-identity.d.ts +10 -0
  323. package/dist/shared/fs/file-identity.js +15 -0
  324. package/dist/shared/fs/replace-file.d.ts +7 -0
  325. package/dist/shared/fs/replace-file.js +33 -0
  326. package/dist/shared/git/git.js +2 -1
  327. package/dist/shared/path/path.d.ts +1 -0
  328. package/dist/shared/path/path.js +21 -1
  329. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  330. package/dist/shared/process/dotnet-toolchain.js +307 -0
  331. package/dist/shared/process/host-process-recovery.d.ts +23 -0
  332. package/dist/shared/process/host-process-recovery.js +99 -0
  333. package/dist/shared/process/host-process-supervisor.d.ts +72 -0
  334. package/dist/shared/process/host-process-supervisor.js +383 -0
  335. package/dist/shared/process/process-tree.d.ts +52 -0
  336. package/dist/shared/process/process-tree.js +144 -0
  337. package/dist/shared/process/process.d.ts +70 -0
  338. package/dist/shared/process/process.js +224 -16
  339. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  340. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  341. package/dist/shared/process/windows-launch.d.ts +26 -0
  342. package/dist/shared/process/windows-launch.js +109 -0
  343. package/dist/shared/provider-capabilities.d.ts +4 -0
  344. package/dist/shared/provider-capabilities.js +95 -0
  345. package/dist/shared/redaction/redaction.d.ts +1 -0
  346. package/dist/shared/redaction/redaction.js +47 -4
  347. package/dist/shared/time/monotonic.d.ts +1 -0
  348. package/dist/shared/time/monotonic.js +8 -0
  349. package/dist/version.d.ts +1 -1
  350. package/dist/version.js +1 -1
  351. package/dist/worktree/artifact-injector.d.ts +3 -2
  352. package/dist/worktree/artifact-injector.js +82 -10
  353. package/dist/worktree/dependency-warmer.d.ts +78 -1
  354. package/dist/worktree/dependency-warmer.js +731 -13
  355. package/dist/worktree/index.d.ts +2 -1
  356. package/dist/worktree/index.js +1 -0
  357. package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
  358. package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
  359. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  360. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  361. package/dist/worktree/wip-git.d.ts +33 -0
  362. package/dist/worktree/wip-git.js +122 -0
  363. package/dist/worktree/wip-refs.d.ts +62 -0
  364. package/dist/worktree/wip-refs.js +119 -0
  365. package/dist/worktree/wip-restore.d.ts +38 -0
  366. package/dist/worktree/wip-restore.js +190 -0
  367. package/dist/worktree/wip-snapshot.d.ts +50 -0
  368. package/dist/worktree/wip-snapshot.js +268 -0
  369. package/dist/worktree/worktree-paths.d.ts +4 -0
  370. package/dist/worktree/worktree-paths.js +30 -0
  371. package/dist/worktree/worktree-wip-events.d.ts +18 -0
  372. package/dist/worktree/worktree-wip-events.js +98 -0
  373. package/dist/worktree/worktree-wip.d.ts +49 -0
  374. package/dist/worktree/worktree-wip.js +182 -0
  375. package/dist/worktree/worktree.base.d.ts +10 -1
  376. package/dist/worktree/worktree.service.d.ts +30 -4
  377. package/dist/worktree/worktree.service.js +379 -54
  378. package/dist/worktree/worktree.types.d.ts +38 -1
  379. package/package.json +12 -7
  380. package/runtime/windows-job-supervisor.ps1 +722 -0
  381. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -0,0 +1,903 @@
1
+ import crypto from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { redactSecrets } from "../shared/redaction/redaction.js";
5
+ import { assertQaSidecarJsonShape, ensureNoSymbolicLinkPathSegments, isPathUnderRoot, sha256File } from "./qa-sidecar-validation.js";
6
+ import { assertClaimedChangedFilesMatchPublishableDiff } from "./publishable-worktree-changes.js";
7
+ import { coerceJsonStringArguments } from "./mcp-argument-coercion.js";
8
+ import { toolInputSchema } from "./phase-completion.schemas.js";
9
+ import { artifactRootFor, artifactRootForOwner, completionArtifactJsonPath, completionArtifactReportPath, decomposeGateFileNames, draftGateFileNames, phaseFiles, qaGateFileNames, decomposeStatuses, draftStatuses } from "./phase-completion.js";
10
+ import { artifactOwnerFields, artifactReferenceOwnerFields, artifactOwnerRelativeRoot, defaultQaChecklist, fallbackReport, isNodeError, jsonText, normalizeArtifactPayload, normalizeCompletionStatus, normalizeQaGateArtifactPayload, normalizeQaGateStatus, normalizedString, optionalString, numberOrDefault, parseJsonObject, parseOptionalJsonObject, phaseFromToolName, qaArray, qaArtifactRelativePath, qaArtifactRelativePathForOwner, qaEvidenceSource, qaObjectArray, qaPolicyWarnings, qaEvidenceGates, qaStringArray, readOptionalFile, reportMarkdown, requireField, requiredRecord, requiredString, qaGateFromToolName, sha256, stableStringify, validateOptionalWorkItemId, validatePayloadShape, validateQaGatePayloadShape, validateQaScopeRecord, writeFileAtomic, asRecord } from "./phase-completion.validation.js";
11
+ export async function writeDecomposeGateCompletionArtifact(config, gate, toolName, input) {
12
+ const payload = asRecord(input, "Decompose completion payload");
13
+ const status = validateDecomposeGatePayload(gate, payload);
14
+ const redactedPayload = redactSecrets({ ...payload, status, phase: "decompose", gate, tool_name: toolName }, config.redactionSecrets ?? []);
15
+ assertStructuralFieldsUnchanged(payload, redactedPayload);
16
+ if (gate === "decompose_proposal") {
17
+ validatePostRedaction(() => validateDecomposeProposalJson(asRecord(redactedPayload["proposal_json"] ?? redactedPayload["decomposition_json"], "proposal_json")));
18
+ }
19
+ const root = artifactRootFor(config.worktreePath, config.workItemId);
20
+ const artifactPath = path.join(root, decomposeGateFileNames[gate]);
21
+ const reportPath = gate === "decompose_proposal" ? path.join(root, phaseFiles.decompose.reportFileName) : path.join(root, `${gate}.md`);
22
+ const verdictJson = jsonText(redactedPayload);
23
+ const report = optionalString(redactedPayload, "report_markdown") ?? `# ${gate.replace(/_/g, " ")}
24
+
25
+ ${optionalString(redactedPayload, "summary") ?? "Decompose gate recorded."}
26
+ `;
27
+ await publishArtifactBundleAtomic(root, [
28
+ { fileName: path.basename(reportPath), content: report },
29
+ { fileName: path.basename(artifactPath), content: verdictJson }
30
+ ], path.basename(artifactPath));
31
+ return {
32
+ phase: "decompose",
33
+ workItemId: config.workItemId,
34
+ ownerType: config.ownerType,
35
+ ownerId: config.ownerId,
36
+ repoPath: path.resolve(config.worktreePath),
37
+ path: artifactPath,
38
+ reportPath,
39
+ contentHash: sha256(verdictJson),
40
+ status,
41
+ producedBy: config.producedBy ?? "forge-completion-tool"
42
+ };
43
+ }
44
+ export async function writeDraftGateCompletionArtifact(config, gate, toolName, input) {
45
+ const payload = asRecord(input, "Draft completion payload");
46
+ const status = validateDraftGatePayload(gate, payload);
47
+ const redactedPayload = redactSecrets({ ...payload, status, phase: "draft", gate, tool_name: toolName }, config.redactionSecrets ?? []);
48
+ assertStructuralFieldsUnchanged(payload, redactedPayload);
49
+ if (gate === "draft_proposal") {
50
+ validatePostRedaction(() => validateDraftProposalJson(asRecord(redactedPayload["draft_json"], "draft_json")));
51
+ }
52
+ const root = artifactRootFor(config.worktreePath, config.workItemId);
53
+ const artifactPath = path.join(root, draftGateFileNames[gate]);
54
+ const reportPath = gate === "draft_proposal" ? path.join(root, phaseFiles.draft.reportFileName) : path.join(root, `${gate}.md`);
55
+ const verdictJson = jsonText(redactedPayload);
56
+ const report = optionalString(redactedPayload, "report_markdown") ?? `# ${gate.replace(/_/g, " ")}\n\n${optionalString(redactedPayload, "summary") ?? "Draft gate recorded."}\n`;
57
+ await publishArtifactBundleAtomic(root, [
58
+ { fileName: path.basename(reportPath), content: report },
59
+ { fileName: path.basename(artifactPath), content: verdictJson }
60
+ ], path.basename(artifactPath));
61
+ return {
62
+ phase: "draft",
63
+ workItemId: config.workItemId,
64
+ ownerType: config.ownerType,
65
+ ownerId: config.ownerId,
66
+ repoPath: path.resolve(config.worktreePath),
67
+ path: artifactPath,
68
+ reportPath,
69
+ contentHash: sha256(verdictJson),
70
+ status,
71
+ producedBy: config.producedBy ?? "forge-completion-tool"
72
+ };
73
+ }
74
+ /**
75
+ * Judges a Decompose gate call before anything is written and returns its status. The gate's
76
+ * input schema advertises exactly these rules (see the completion tool schema contract test).
77
+ */
78
+ export function validateDecomposeGatePayload(gate, payload) {
79
+ const status = gateStatus(payload, decomposeStatuses);
80
+ if (gate === "decompose_proposal") {
81
+ validateDecomposeProposalJson(asRecord(payload["proposal_json"] ?? payload["decomposition_json"], "proposal_json"));
82
+ }
83
+ else {
84
+ // An earlier Decompose gate's evidence is its summary, and a missing status means pass, so an
85
+ // empty call would otherwise record a pass and move to the next gate.
86
+ requireField(payload, "summary");
87
+ }
88
+ return status;
89
+ }
90
+ /** Judges a Draft gate call before anything is written and returns its status. */
91
+ export function validateDraftGatePayload(gate, payload) {
92
+ const status = gateStatus(payload, draftStatuses);
93
+ if (gate === "draft_proposal") {
94
+ validateDraftProposalJson(asRecord(payload["draft_json"], "draft_json"));
95
+ }
96
+ else {
97
+ // An earlier Draft gate's only evidence is its summary, and a missing status means pass, so an
98
+ // empty call would otherwise record a pass and move to the next gate.
99
+ requireField(payload, "summary");
100
+ }
101
+ return status;
102
+ }
103
+ // Only an omitted status defaults to pass. A status that is present must be one of the advertised
104
+ // values: a typo such as "pas", a blank string or a non-string is rejected rather than advancing
105
+ // the gate as a pass.
106
+ function gateStatus(payload, allowed) {
107
+ const value = payload["status"];
108
+ if (value === undefined || value === null) {
109
+ return "pass";
110
+ }
111
+ const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
112
+ if (!allowed.includes(normalized)) {
113
+ throw new Error(`status must be one of ${allowed.join(", ")}; received ${typeof value === "string" ? `'${value}'` : JSON.stringify(value)}.`);
114
+ }
115
+ return normalized;
116
+ }
117
+ function validateDraftProposalJson(draftJson) {
118
+ if (draftJson.suggested_qa_scope !== undefined && draftJson.suggested_qa_scope !== null) {
119
+ if (!draftJson.suggested_qa_scope || typeof draftJson.suggested_qa_scope !== "object" || Array.isArray(draftJson.suggested_qa_scope)) {
120
+ throw new Error("draft_json.suggested_qa_scope: expected object when present.");
121
+ }
122
+ validateQaScopeRecord(draftJson.suggested_qa_scope, "draft_json.suggested_qa_scope");
123
+ }
124
+ if (isDecompositionDraftJson(draftJson)) {
125
+ return;
126
+ }
127
+ if (isWorkItemDraftJson(draftJson)) {
128
+ for (const key of ["title", "description", "acceptanceCriteria"]) {
129
+ if (typeof draftJson[key] !== "string" || draftJson[key].trim().length === 0) {
130
+ throw new Error(`draft_json.${key}: expected non-empty string`);
131
+ }
132
+ }
133
+ return;
134
+ }
135
+ for (const key of ["title", "summary", "objective", "planningPacket", "decompositionContext"]) {
136
+ if (typeof draftJson[key] !== "string" || draftJson[key].trim().length === 0) {
137
+ throw new Error(`draft_json.${key}: expected non-empty string`);
138
+ }
139
+ }
140
+ }
141
+ function isDecompositionDraftJson(draftJson) {
142
+ const summary = draftJson["summary"];
143
+ return typeof summary === "string"
144
+ && summary.trim().length > 0
145
+ && Array.isArray(draftJson["candidates"]);
146
+ }
147
+ function isWorkItemDraftJson(draftJson) {
148
+ return typeof draftJson.title === "string"
149
+ && typeof draftJson.description === "string"
150
+ && typeof draftJson.acceptanceCriteria === "string";
151
+ }
152
+ function validateDecomposeProposalJson(proposalJson) {
153
+ const candidates = proposalJson.candidates;
154
+ if (!Array.isArray(candidates)) {
155
+ throw new Error("proposal_json.candidates: expected array");
156
+ }
157
+ for (const [index, candidate] of candidates.entries()) {
158
+ if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
159
+ throw new Error(`proposal_json.candidates[${index}]: expected object.`);
160
+ }
161
+ const record = candidate;
162
+ validateOptionalCandidateQaScope(record, "estimated_qa_scope", `proposal_json.candidates[${index}].estimated_qa_scope`);
163
+ validateOptionalCandidateQaScope(record, "estimatedQaScope", `proposal_json.candidates[${index}].estimatedQaScope`);
164
+ validateOptionalCandidateQaScope(record, "qa_scope", `proposal_json.candidates[${index}].qa_scope`);
165
+ validateOptionalCandidateQaScope(record, "qaScope", `proposal_json.candidates[${index}].qaScope`);
166
+ }
167
+ }
168
+ function validateOptionalCandidateQaScope(candidate, key, pathLabel) {
169
+ const value = candidate[key];
170
+ if (value === undefined || value === null) {
171
+ return;
172
+ }
173
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
174
+ throw new Error(`${pathLabel}: expected object when present.`);
175
+ }
176
+ validateQaScopeRecord(value, pathLabel);
177
+ }
178
+ export async function writeCompletionArtifact(config, toolName, input) {
179
+ const phase = phaseFromToolName(toolName);
180
+ if (phase !== config.phase) {
181
+ throw new Error(`Tool ${toolName} is not allowed for phase ${config.phase}.`);
182
+ }
183
+ const qaGate = qaGateFromToolName(toolName);
184
+ if (qaGate && qaGate !== "qa_verdict") {
185
+ return await writeQaGateCompletionArtifact(config, qaGate, input);
186
+ }
187
+ const payload = asRecord(input, "completion payload");
188
+ const status = normalizeCompletionStatus(requiredString(payload, "status"), phase);
189
+ let validationPayload = { ...payload, status };
190
+ if (config.qaCycle && qaGate === "qa_verdict") {
191
+ validationPayload = await synthesizeQaCycleVerdictPayload(config, validationPayload, status);
192
+ }
193
+ validatePayloadShape(phase, validationPayload);
194
+ validateOptionalWorkItemId(validationPayload, config.workItemId);
195
+ if (phase === "comment_repair" && status === "pass") {
196
+ await assertClaimedChangedFilesMatchPublishableDiff(config.worktreePath, validationPayload, toolName);
197
+ }
198
+ const redactedPayload = redactSecrets(validationPayload, config.redactionSecrets ?? []);
199
+ assertStructuralFieldsUnchanged(validationPayload, redactedPayload);
200
+ validatePostRedaction(() => {
201
+ validatePayloadShape(phase, redactedPayload);
202
+ validateOptionalWorkItemId(redactedPayload, config.workItemId);
203
+ });
204
+ const producedBy = optionalString(redactedPayload, "produced_by")
205
+ ?? optionalString(redactedPayload, "producedBy")
206
+ ?? config.producedBy
207
+ ?? "forge-completion-tool";
208
+ if (phase === "qa") {
209
+ return await writeQaCompletionArtifact(config, redactedPayload, status, producedBy);
210
+ }
211
+ if (phase === "architect") {
212
+ return await writeArchitectCompletionArtifact(config, redactedPayload, status, producedBy);
213
+ }
214
+ const artifactWithoutHash = normalizeArtifactPayload(redactedPayload, {
215
+ phase,
216
+ workItemId: config.workItemId,
217
+ ownerType: config.ownerType,
218
+ ownerId: config.ownerId,
219
+ producedBy,
220
+ status
221
+ });
222
+ const contentHash = sha256(stableStringify(artifactWithoutHash));
223
+ const artifact = {
224
+ ...artifactWithoutHash,
225
+ content_hash: contentHash
226
+ };
227
+ const artifactJson = `${JSON.stringify(artifact, null, 2)}\n`;
228
+ const report = reportMarkdown(redactedPayload, phase, status, producedBy, contentHash);
229
+ const artifactPath = completionArtifactJsonPath(config.worktreePath, config.workItemId, phase);
230
+ const reportPath = completionArtifactReportPath(config.worktreePath, config.workItemId, phase);
231
+ await publishArtifactBundleAtomic(path.dirname(artifactPath), [
232
+ { fileName: path.basename(reportPath), content: report },
233
+ { fileName: path.basename(artifactPath), content: artifactJson }
234
+ ], path.basename(artifactPath));
235
+ return {
236
+ phase,
237
+ workItemId: config.workItemId,
238
+ ...artifactReferenceOwnerFields(config),
239
+ repoPath: path.resolve(config.worktreePath),
240
+ path: artifactPath,
241
+ reportPath,
242
+ contentHash,
243
+ status,
244
+ producedBy
245
+ };
246
+ }
247
+ export async function writeArchitectCompletionArtifact(config, payload, status, producedBy) {
248
+ const ownerFields = artifactOwnerFields(config);
249
+ const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
250
+ ? artifactRootForOwner(config.worktreePath, ownerFields.owner_type, ownerFields.owner_id)
251
+ : artifactRootFor(config.worktreePath, config.workItemId);
252
+ const implementationPlanPath = path.join(artifactRoot, "implementation.plan.json");
253
+ const qaPlanPath = path.join(artifactRoot, "qa.plan.json");
254
+ const verdictPath = path.join(artifactRoot, "architect.verdict.json");
255
+ const reportPath = path.join(artifactRoot, "architect.report.md");
256
+ // A needs_revision or blocked verdict has no plan to approve; its schema lets
257
+ // the agent omit both plans, and the bundle still carries a file for each.
258
+ const implementationPlan = architectPlanRecord(payload, "implementation_plan", status);
259
+ const qaPlan = architectPlanRecord(payload, "qa_plan", status);
260
+ const report = optionalString(payload, "report") ?? optionalString(payload, "report_markdown") ?? reportMarkdown(payload, "architect", status, producedBy, "pending");
261
+ const artifactWithoutHash = normalizeArtifactPayload(payload, {
262
+ phase: "architect",
263
+ workItemId: config.workItemId,
264
+ ownerType: config.ownerType,
265
+ ownerId: config.ownerId,
266
+ producedBy,
267
+ status
268
+ });
269
+ const contentHash = sha256(stableStringify(artifactWithoutHash));
270
+ const verdict = {
271
+ ...artifactWithoutHash,
272
+ content_hash: contentHash
273
+ };
274
+ await publishArtifactBundleAtomic(artifactRoot, [
275
+ { fileName: path.basename(implementationPlanPath), content: jsonText(implementationPlan) },
276
+ { fileName: path.basename(qaPlanPath), content: jsonText(qaPlan) },
277
+ { fileName: path.basename(reportPath), content: `${report.trim()}\n` },
278
+ { fileName: path.basename(verdictPath), content: jsonText(verdict) }
279
+ ], path.basename(verdictPath));
280
+ return {
281
+ phase: "architect",
282
+ workItemId: config.workItemId,
283
+ ...artifactReferenceOwnerFields(config),
284
+ repoPath: path.resolve(config.worktreePath),
285
+ path: verdictPath,
286
+ reportPath,
287
+ contentHash,
288
+ status,
289
+ producedBy
290
+ };
291
+ }
292
+ function architectPlanRecord(payload, key, status) {
293
+ if (status !== "pass" && (payload[key] === undefined || payload[key] === null)) {
294
+ return {};
295
+ }
296
+ return requiredRecord(payload, key);
297
+ }
298
+ export async function writeQaGateCompletionArtifact(config, gate, input) {
299
+ const payload = asRecord(input, "QA gate completion payload");
300
+ const status = normalizeQaGateStatus(requiredString(payload, "status"));
301
+ validateQaGatePayloadShape(gate, payload, status);
302
+ validateOptionalWorkItemId(payload, config.workItemId);
303
+ const ownerFields = artifactOwnerFields(config);
304
+ // Every evidence gate's sidecars are merged into the final verdict, which checks each file,
305
+ // so each gate checks its references (exists, under qa/, size and hash match) when it is called.
306
+ const validatedSidecars = qaEvidenceGates.has(gate)
307
+ ? await validateQaSidecarReferences(config.worktreePath, config.workItemId, qaArray(payload, "sidecars", qaEvidenceSource(payload)), ownerFields.owner_type, ownerFields.owner_id)
308
+ : null;
309
+ const redactedPayload = redactSecrets({
310
+ ...payload,
311
+ status,
312
+ ...(validatedSidecars ? { sidecars: validatedSidecars } : {})
313
+ }, config.redactionSecrets ?? []);
314
+ assertStructuralFieldsUnchanged(payload, redactedPayload);
315
+ validatePostRedaction(() => {
316
+ validateQaGatePayloadShape(gate, redactedPayload, status);
317
+ validateOptionalWorkItemId(redactedPayload, config.workItemId);
318
+ });
319
+ if (qaEvidenceGates.has(gate)) {
320
+ await validateQaSidecarReferences(config.worktreePath, config.workItemId, qaArray(redactedPayload, "sidecars", qaEvidenceSource(redactedPayload)), ownerFields.owner_type, ownerFields.owner_id).catch((error) => {
321
+ throw postRedactionValidationError(error);
322
+ });
323
+ }
324
+ const producedBy = optionalString(redactedPayload, "produced_by")
325
+ ?? optionalString(redactedPayload, "producedBy")
326
+ ?? config.producedBy
327
+ ?? "forge-completion-tool";
328
+ const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
329
+ ? artifactRootForOwner(config.worktreePath, ownerFields.owner_type, ownerFields.owner_id)
330
+ : artifactRootFor(config.worktreePath, config.workItemId);
331
+ const fileName = qaGateFileNames[gate];
332
+ const artifactPath = path.join(artifactRoot, fileName);
333
+ const reportPath = path.join(artifactRoot, "qa.report.md");
334
+ const artifactWithoutHash = normalizeQaGateArtifactPayload(redactedPayload, {
335
+ gate,
336
+ workItemId: config.workItemId,
337
+ ownerType: config.ownerType,
338
+ ownerId: config.ownerId,
339
+ producedBy,
340
+ status
341
+ });
342
+ const contentHash = sha256(stableStringify(artifactWithoutHash));
343
+ const artifact = {
344
+ ...artifactWithoutHash,
345
+ content_hash: contentHash
346
+ };
347
+ await writeFileAtomic(artifactPath, jsonText(artifact));
348
+ return {
349
+ phase: "qa",
350
+ workItemId: config.workItemId,
351
+ ...artifactReferenceOwnerFields(config),
352
+ repoPath: path.resolve(config.worktreePath),
353
+ path: artifactPath,
354
+ reportPath,
355
+ contentHash,
356
+ status,
357
+ producedBy
358
+ };
359
+ }
360
+ export async function writeQaCompletionArtifact(config, payload, status, producedBy) {
361
+ const ownerFields = artifactOwnerFields(config);
362
+ const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
363
+ ? artifactRootForOwner(config.worktreePath, ownerFields.owner_type, ownerFields.owner_id)
364
+ : artifactRootFor(config.worktreePath, config.workItemId);
365
+ const planPath = path.join(artifactRoot, "qa.plan.json");
366
+ const evidencePath = path.join(artifactRoot, "qa.evidence.json");
367
+ const findingsPath = path.join(artifactRoot, "qa.findings.json");
368
+ const verdictPath = path.join(artifactRoot, "qa.verdict.json");
369
+ const reportPath = path.join(artifactRoot, "qa.report.md");
370
+ const relativeEvidencePath = ownerFields.owner_type && ownerFields.owner_id
371
+ ? qaArtifactRelativePathForOwner(ownerFields.owner_type, ownerFields.owner_id, "qa.evidence.json")
372
+ : qaArtifactRelativePath(config.workItemId, "qa.evidence.json");
373
+ const relativeFindingsPath = ownerFields.owner_type && ownerFields.owner_id
374
+ ? qaArtifactRelativePathForOwner(ownerFields.owner_type, ownerFields.owner_id, "qa.findings.json")
375
+ : qaArtifactRelativePath(config.workItemId, "qa.findings.json");
376
+ const relativeReportPath = ownerFields.owner_type && ownerFields.owner_id
377
+ ? qaArtifactRelativePathForOwner(ownerFields.owner_type, ownerFields.owner_id, "qa.report.md")
378
+ : qaArtifactRelativePath(config.workItemId, "qa.report.md");
379
+ const evidenceSource = qaEvidenceSource(payload);
380
+ const commands = qaArray(payload, "commands", evidenceSource);
381
+ const browserChecks = qaArray(payload, "browser_checks", evidenceSource);
382
+ const sidecars = await validateQaSidecarReferences(config.worktreePath, config.workItemId, qaArray(payload, "sidecars", evidenceSource), ownerFields.owner_type, ownerFields.owner_id);
383
+ const notes = optionalString(payload, "notes") ?? optionalString(evidenceSource, "notes") ?? "";
384
+ const findings = qaObjectArray(payload, "findings");
385
+ const candidateBugs = qaObjectArray(payload, "candidate_bugs");
386
+ const testedAcceptanceCriteria = qaStringArray(payload, "tested_acceptance_criteria");
387
+ const explicitFindingIds = qaStringArray(payload, "finding_ids");
388
+ const explicitCandidateBugIds = qaStringArray(payload, "candidate_bug_ids");
389
+ const policyWarnings = qaPolicyWarnings(payload);
390
+ const blockerReason = optionalString(payload, "blocker_reason");
391
+ const checklist = qaStringArray(payload, "checklist");
392
+ const planJson = jsonText({
393
+ schema_version: 1,
394
+ phase: "qa",
395
+ ...ownerFields,
396
+ checklist: checklist.length > 0 ? checklist : defaultQaChecklist(status),
397
+ acceptance_criteria: testedAcceptanceCriteria
398
+ });
399
+ const evidenceJson = jsonText({
400
+ schema_version: 1,
401
+ phase: "qa",
402
+ ...ownerFields,
403
+ commands,
404
+ browser_checks: browserChecks,
405
+ sidecars,
406
+ notes
407
+ });
408
+ const findingsJson = jsonText({
409
+ schema_version: 1,
410
+ phase: "qa",
411
+ ...ownerFields,
412
+ findings,
413
+ candidate_bugs: candidateBugs
414
+ });
415
+ const findingIds = status === "pass"
416
+ ? []
417
+ : explicitFindingIds.length > 0
418
+ ? explicitFindingIds
419
+ : findings
420
+ .filter((finding) => normalizedString(finding.scope) === "in_scope")
421
+ .map((finding) => optionalString(finding, "id"))
422
+ .filter((id) => Boolean(id));
423
+ const candidateBugIds = explicitCandidateBugIds.length > 0
424
+ ? explicitCandidateBugIds
425
+ : candidateBugs
426
+ .map((candidateBug) => optionalString(candidateBug, "id"))
427
+ .filter((id) => Boolean(id));
428
+ const verdictWithoutHash = {
429
+ schema_version: numberOrDefault(payload.schema_version, 1),
430
+ phase: "qa",
431
+ ...ownerFields,
432
+ status,
433
+ summary: requiredString(payload, "summary"),
434
+ tested_acceptance_criteria: testedAcceptanceCriteria,
435
+ finding_ids: findingIds,
436
+ candidate_bug_ids: candidateBugIds,
437
+ policy_warnings: policyWarnings,
438
+ blocker_reason: status === "blocked" ? normalizedString(blockerReason) : null,
439
+ evidence_path: relativeEvidencePath,
440
+ findings_path: relativeFindingsPath,
441
+ report_path: relativeReportPath,
442
+ produced_by: producedBy
443
+ };
444
+ const contentHash = sha256(stableStringify({
445
+ plan: JSON.parse(planJson),
446
+ evidence: JSON.parse(evidenceJson),
447
+ findings: JSON.parse(findingsJson),
448
+ verdict: verdictWithoutHash
449
+ }));
450
+ const verdictJson = jsonText({
451
+ ...verdictWithoutHash,
452
+ content_hash: contentHash
453
+ });
454
+ const finalReport = reportMarkdown(payload, "qa", status, producedBy, contentHash);
455
+ await publishArtifactBundleAtomic(artifactRoot, [
456
+ { fileName: path.basename(planPath), content: planJson },
457
+ { fileName: path.basename(evidencePath), content: evidenceJson },
458
+ { fileName: path.basename(findingsPath), content: findingsJson },
459
+ { fileName: path.basename(reportPath), content: finalReport },
460
+ { fileName: path.basename(verdictPath), content: verdictJson }
461
+ ], path.basename(verdictPath));
462
+ return {
463
+ phase: "qa",
464
+ workItemId: config.workItemId,
465
+ ...artifactReferenceOwnerFields(config),
466
+ repoPath: path.resolve(config.worktreePath),
467
+ path: verdictPath,
468
+ reportPath,
469
+ contentHash,
470
+ status,
471
+ producedBy
472
+ };
473
+ }
474
+ async function synthesizeQaCycleVerdictPayload(config, payload, status) {
475
+ const qaPlan = await readInheritedQaGateArtifact(config, "qa_plan");
476
+ const qaRegression = await readInheritedQaGateArtifact(config, "qa_regression");
477
+ const qaApi = await readInheritedQaGateArtifact(config, "qa_api");
478
+ const qaManualWeb = await readInheritedQaGateArtifact(config, "qa_manual_web");
479
+ const qaBugRepro = await readInheritedQaGateArtifact(config, "qa_bug_repro");
480
+ const qaFindings = await readInheritedQaGateArtifact(config, "qa_findings");
481
+ const evidenceGates = [qaRegression, qaApi, qaManualWeb, qaBugRepro];
482
+ const payloadEvidence = qaEvidenceSource(payload);
483
+ const merged = { ...payload };
484
+ const checklist = qaStringArray(payload, "checklist");
485
+ if (checklist.length === 0) {
486
+ const plannedChecklist = qaStringArray(qaPlan, "checklist");
487
+ merged.checklist = plannedChecklist.length > 0 ? plannedChecklist : defaultQaChecklist(status);
488
+ }
489
+ const testedAcceptanceCriteria = qaStringArray(payload, "tested_acceptance_criteria");
490
+ if (testedAcceptanceCriteria.length === 0) {
491
+ const plannedAcceptanceCriteria = qaStringArray(qaPlan, "acceptance_criteria");
492
+ const payloadAcceptanceCriteria = qaStringArray(payload, "acceptance_criteria");
493
+ const acceptanceCriteria = plannedAcceptanceCriteria.length > 0 ? plannedAcceptanceCriteria : payloadAcceptanceCriteria;
494
+ if (acceptanceCriteria.length > 0) {
495
+ merged.tested_acceptance_criteria = acceptanceCriteria;
496
+ }
497
+ }
498
+ const payloadCommands = qaArray(payload, "commands", payloadEvidence);
499
+ const inheritedCommands = evidenceGates.flatMap((gate) => qaArray(gate, "commands"));
500
+ const inheritedDiagnosticCommandNotes = status === "pass"
501
+ ? qaNonPassingCommandNotes(inheritedCommands)
502
+ : [];
503
+ merged.commands = dedupeUnknownArray([
504
+ ...payloadCommands,
505
+ ...(status === "pass" ? inheritedCommands.filter(isQaPassingCommandEvidence) : inheritedCommands)
506
+ ]);
507
+ merged.browser_checks = dedupeUnknownArray([
508
+ ...qaArray(payload, "browser_checks", payloadEvidence),
509
+ ...evidenceGates.flatMap((gate) => qaArray(gate, "browser_checks").map(normalizeInheritedQaBrowserCheck))
510
+ ]);
511
+ merged.sidecars = dedupeUnknownArray([
512
+ ...qaArray(payload, "sidecars", payloadEvidence),
513
+ ...evidenceGates.flatMap((gate) => qaArray(gate, "sidecars"))
514
+ ]);
515
+ const notes = dedupeStrings([
516
+ optionalString(payload, "notes"),
517
+ optionalString(payloadEvidence, "notes"),
518
+ ...evidenceGates.map((gate) => optionalString(gate, "notes")),
519
+ ...inheritedDiagnosticCommandNotes
520
+ ]);
521
+ if (notes.length > 0) {
522
+ merged.notes = notes.join("\n");
523
+ }
524
+ merged.findings = mergeQaObjectArraysById(qaObjectArray(payload, "findings"), qaObjectArray(qaFindings, "findings"));
525
+ merged.candidate_bugs = mergeQaObjectArraysById(qaObjectArray(payload, "candidate_bugs"), qaObjectArray(qaFindings, "candidate_bugs"));
526
+ return merged;
527
+ }
528
+ /**
529
+ * Reads an earlier gate's artifact for the verdict merge. Gates recorded before
530
+ * argument coercion existed may hold a JSON-string array, so the same schema
531
+ * coercion is applied here, and any remaining shape error names the gate file
532
+ * instead of looking like a fault in the verdict payload.
533
+ */
534
+ async function readInheritedQaGateArtifact(config, gate) {
535
+ const artifact = coerceJsonStringArguments(await readQaGateArtifact(config, gate), toolInputSchema("qa", gate));
536
+ // Gates accept sidecars inside the evidence wrapper too; promote them so the verdict inherits
537
+ // them. A top-level value still takes precedence.
538
+ if (artifact.sidecars === undefined || artifact.sidecars === null) {
539
+ const nestedSidecars = qaEvidenceSource(artifact).sidecars;
540
+ if (nestedSidecars !== undefined && nestedSidecars !== null) {
541
+ artifact.sidecars = nestedSidecars;
542
+ }
543
+ }
544
+ for (const key of ["commands", "browser_checks", "sidecars", "checklist", "acceptance_criteria", "findings", "candidate_bugs"]) {
545
+ try {
546
+ qaArray(artifact, key);
547
+ }
548
+ catch (error) {
549
+ throw new Error(`${qaGateFileNames[gate]} recorded by ${gate} has an invalid ${key}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
550
+ }
551
+ }
552
+ return artifact;
553
+ }
554
+ export async function readQaGateArtifact(config, gate) {
555
+ const ownerFields = artifactOwnerFields(config);
556
+ const artifactRoot = ownerFields.owner_type && ownerFields.owner_id
557
+ ? artifactRootForOwner(config.worktreePath, ownerFields.owner_type, ownerFields.owner_id)
558
+ : artifactRootFor(config.worktreePath, config.workItemId);
559
+ const artifactPath = path.join(artifactRoot, qaGateFileNames[gate]);
560
+ const content = await readOptionalFile(artifactPath);
561
+ return content === null ? {} : parseOptionalJsonObject(content, qaGateFileNames[gate]);
562
+ }
563
+ function dedupeUnknownArray(values) {
564
+ const seen = new Set();
565
+ const deduped = [];
566
+ for (const value of values) {
567
+ const key = stableStringify(value);
568
+ if (seen.has(key)) {
569
+ continue;
570
+ }
571
+ seen.add(key);
572
+ deduped.push(value);
573
+ }
574
+ return deduped;
575
+ }
576
+ function isQaPassingCommandEvidence(value) {
577
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
578
+ return false;
579
+ }
580
+ const record = value;
581
+ return record.exit_code === 0 && normalizedString(record.status) === "pass";
582
+ }
583
+ function qaNonPassingCommandNotes(values) {
584
+ return values
585
+ .filter((value) => !isQaPassingCommandEvidence(value))
586
+ .map((value, index) => {
587
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
588
+ return `QA diagnostic command ${index + 1} was omitted from pass evidence because it was not a structured passing command.`;
589
+ }
590
+ const record = value;
591
+ const command = optionalString(record, "command") ?? "<missing command>";
592
+ const status = optionalString(record, "status") ?? "<missing status>";
593
+ const exitCode = typeof record.exit_code === "number" && Number.isFinite(record.exit_code)
594
+ ? String(record.exit_code)
595
+ : "<missing exit_code>";
596
+ const summary = optionalString(record, "summary");
597
+ return `QA diagnostic command omitted from pass evidence: ${command} (status ${status}, exit_code ${exitCode})${summary ? ` — ${summary}` : ""}.`;
598
+ });
599
+ }
600
+ function mergeQaObjectArraysById(primary, fallback) {
601
+ const seen = new Set();
602
+ const merged = [];
603
+ for (const value of [...primary, ...fallback]) {
604
+ const id = optionalString(value, "id");
605
+ const key = id ? `id:${id}` : stableStringify(value);
606
+ if (seen.has(key)) {
607
+ continue;
608
+ }
609
+ seen.add(key);
610
+ merged.push(value);
611
+ }
612
+ return merged;
613
+ }
614
+ function dedupeStrings(values) {
615
+ const seen = new Set();
616
+ const deduped = [];
617
+ for (const value of values) {
618
+ const trimmed = value?.trim();
619
+ if (!trimmed || seen.has(trimmed)) {
620
+ continue;
621
+ }
622
+ seen.add(trimmed);
623
+ deduped.push(trimmed);
624
+ }
625
+ return deduped;
626
+ }
627
+ function normalizeInheritedQaBrowserCheck(browserCheck) {
628
+ if (!browserCheck || typeof browserCheck !== "object" || Array.isArray(browserCheck)) {
629
+ return browserCheck;
630
+ }
631
+ const record = browserCheck;
632
+ if (optionalString(record, "summary")) {
633
+ return record;
634
+ }
635
+ const target = optionalString(record, "url") ?? optionalString(record, "route") ?? "the configured browser target";
636
+ const status = optionalString(record, "status") ?? "recorded";
637
+ return {
638
+ ...record,
639
+ summary: `Inherited browser check ${status} for ${target}.`
640
+ };
641
+ }
642
+ function normalizeSha256ContentHash(contentHash) {
643
+ const normalized = contentHash.trim().toLowerCase();
644
+ return normalized.startsWith("sha256:")
645
+ ? normalized.slice("sha256:".length)
646
+ : normalized;
647
+ }
648
+ async function validateQaSidecarReferences(worktreePath, workItemId, sidecars, ownerType, ownerId) {
649
+ if (sidecars.length === 0) {
650
+ return [];
651
+ }
652
+ const artifactRoot = ownerType && ownerId
653
+ ? artifactRootForOwner(worktreePath, ownerType, ownerId)
654
+ : artifactRootFor(worktreePath, workItemId);
655
+ const qaSidecarRoot = path.resolve(artifactRoot, "qa");
656
+ const validated = [];
657
+ const validatedByPath = new Map();
658
+ for (const [index, sidecar] of sidecars.entries()) {
659
+ if (!sidecar || typeof sidecar !== "object" || Array.isArray(sidecar)) {
660
+ throw new Error(`sidecars[${index}] must be an object.`);
661
+ }
662
+ const record = sidecar;
663
+ const sidecarPath = optionalString(record, "path");
664
+ const contentHash = optionalString(record, "content_hash");
665
+ const bytes = record.bytes;
666
+ if (!sidecarPath || !contentHash || typeof bytes !== "number" || !Number.isFinite(bytes) || bytes <= 0) {
667
+ throw new Error(`sidecars[${index}] must include path, content_hash, and positive bytes.`);
668
+ }
669
+ if (path.isAbsolute(sidecarPath)) {
670
+ throw new Error(`sidecars[${index}].path must be relative to the worktree.`);
671
+ }
672
+ const fullPath = path.resolve(worktreePath, sidecarPath);
673
+ if (!isPathUnderRoot(qaSidecarRoot, fullPath)) {
674
+ throw new Error(`sidecars[${index}].path must be under ${artifactOwnerRelativeRoot(ownerType, ownerId, workItemId)}/qa/.`);
675
+ }
676
+ const stat = await fs.lstat(fullPath).catch((error) => {
677
+ if (isNodeError(error) && error.code === "ENOENT") {
678
+ throw new Error(`sidecars[${index}].path does not exist: ${sidecarPath}`);
679
+ }
680
+ throw error;
681
+ });
682
+ if (!stat.isFile() || stat.isSymbolicLink()) {
683
+ throw new Error(`sidecars[${index}].path must reference a regular file.`);
684
+ }
685
+ await ensureNoSymbolicLinkPathSegments(qaSidecarRoot, path.dirname(fullPath), `sidecars[${index}].path must not traverse symbolic links.`);
686
+ if (stat.size !== bytes) {
687
+ throw new Error(`sidecars[${index}].bytes does not match the referenced file.`);
688
+ }
689
+ const actualHash = await sha256File(fullPath);
690
+ if (actualHash !== normalizeSha256ContentHash(contentHash)) {
691
+ throw new Error(`sidecars[${index}].content_hash does not match the referenced file.`);
692
+ }
693
+ await assertQaSidecarJsonShape(fullPath, sidecarPath, `sidecars[${index}]`);
694
+ const canonicalPath = path.relative(worktreePath, fullPath).split(path.sep).join("/");
695
+ const duplicateKey = canonicalPath.toLowerCase();
696
+ const existing = validatedByPath.get(duplicateKey);
697
+ if (existing) {
698
+ if (existing.contentHash !== actualHash || existing.bytes !== stat.size) {
699
+ throw new Error(`sidecars[${index}] conflicts with another payload for ${canonicalPath}.`);
700
+ }
701
+ continue;
702
+ }
703
+ validatedByPath.set(duplicateKey, { contentHash: actualHash, bytes: stat.size });
704
+ validated.push({
705
+ ...record,
706
+ path: canonicalPath,
707
+ content_hash: actualHash,
708
+ bytes: stat.size
709
+ });
710
+ }
711
+ return validated;
712
+ }
713
+ export async function readCompletionArtifact(worktreePath, workItemId, phase, ownerType, ownerId) {
714
+ const artifactPath = completionArtifactJsonPath(worktreePath, workItemId, phase, ownerType, ownerId);
715
+ const reportPath = completionArtifactReportPath(worktreePath, workItemId, phase, ownerType, ownerId);
716
+ const verdictJson = await readOptionalFile(artifactPath);
717
+ if (verdictJson === null) {
718
+ return null;
719
+ }
720
+ const parsed = parseJsonObject(verdictJson, artifactPath);
721
+ const report = await readOptionalFile(reportPath) ?? fallbackReport(parsed, phase, artifactPath);
722
+ const artifactRoot = path.dirname(artifactPath);
723
+ const implementationPlanJson = phase === "architect"
724
+ ? await readOptionalFile(path.join(artifactRoot, "implementation.plan.json"))
725
+ : null;
726
+ const qaPlanJson = phase === "architect"
727
+ ? await readOptionalFile(path.join(artifactRoot, "qa.plan.json"))
728
+ : null;
729
+ return {
730
+ repoPath: path.resolve(worktreePath),
731
+ path: artifactPath,
732
+ verdictJson,
733
+ implementationPlanJson,
734
+ qaPlanJson,
735
+ report,
736
+ producedBy: optionalString(parsed, "produced_by") ?? optionalString(parsed, "producedBy") ?? "forge-completion-tool",
737
+ status: optionalString(parsed, "status") ?? "unknown",
738
+ phase
739
+ };
740
+ }
741
+ /**
742
+ * Stages a complete phase bundle outside the live artifact directory, then
743
+ * publishes its canonical verdict/marker last. Consumers treat the marker as
744
+ * the bundle's commit point, so they can observe either the old complete bundle
745
+ * or the new complete bundle, never a partially written set. A failed or
746
+ * cancelled publication rolls every touched file back before rejecting.
747
+ */
748
+ export async function publishArtifactBundleAtomic(artifactRoot, files, commitFileName, options = {}) {
749
+ validateArtifactBundleFiles(files, commitFileName);
750
+ throwIfPublicationCancelled(options.signal);
751
+ const parent = path.dirname(artifactRoot);
752
+ const transactionId = `${process.pid}.${crypto.randomUUID()}`;
753
+ const stagingRoot = path.join(parent, `.${path.basename(artifactRoot)}.${transactionId}.publish`);
754
+ const backupRoot = path.join(stagingRoot, ".previous");
755
+ const orderedFiles = [
756
+ ...files.filter((file) => file.fileName !== commitFileName),
757
+ files.find((file) => file.fileName === commitFileName)
758
+ ];
759
+ const backedUp = new Set();
760
+ const published = new Set();
761
+ try {
762
+ await fs.mkdir(parent, { recursive: true });
763
+ await fs.mkdir(stagingRoot, { recursive: false });
764
+ for (const file of orderedFiles) {
765
+ throwIfPublicationCancelled(options.signal);
766
+ const handle = await fs.open(path.join(stagingRoot, file.fileName), "wx");
767
+ try {
768
+ await handle.writeFile(file.content, { encoding: "utf8", signal: options.signal });
769
+ await handle.sync();
770
+ }
771
+ finally {
772
+ await handle.close();
773
+ }
774
+ }
775
+ throwIfPublicationCancelled(options.signal);
776
+ await fs.mkdir(artifactRoot, { recursive: true });
777
+ await fs.mkdir(backupRoot, { recursive: true });
778
+ // Hide the previous commit marker before changing any supporting file.
779
+ for (const fileName of [commitFileName, ...orderedFiles.map((file) => file.fileName).filter((name) => name !== commitFileName)]) {
780
+ const livePath = path.join(artifactRoot, fileName);
781
+ try {
782
+ await fs.rename(livePath, path.join(backupRoot, fileName));
783
+ backedUp.add(fileName);
784
+ }
785
+ catch (error) {
786
+ if (!isNodeError(error) || error.code !== "ENOENT") {
787
+ throw error;
788
+ }
789
+ }
790
+ }
791
+ for (const [index, file] of orderedFiles.entries()) {
792
+ throwIfPublicationCancelled(options.signal);
793
+ await options.beforePublishFile?.(file.fileName, index);
794
+ await fs.rename(path.join(stagingRoot, file.fileName), path.join(artifactRoot, file.fileName));
795
+ published.add(file.fileName);
796
+ }
797
+ }
798
+ catch (error) {
799
+ const rollbackErrors = [];
800
+ for (const file of [...orderedFiles].reverse()) {
801
+ if (!published.has(file.fileName))
802
+ continue;
803
+ await fs.rm(path.join(artifactRoot, file.fileName), { force: true }).catch(() => {
804
+ rollbackErrors.push(file.fileName);
805
+ });
806
+ }
807
+ // Restore the previous marker last for the same observable commit boundary.
808
+ const restoreOrder = [
809
+ ...orderedFiles.filter((file) => file.fileName !== commitFileName),
810
+ orderedFiles.find((file) => file.fileName === commitFileName)
811
+ ];
812
+ for (const file of restoreOrder) {
813
+ if (!backedUp.has(file.fileName))
814
+ continue;
815
+ await fs.rename(path.join(backupRoot, file.fileName), path.join(artifactRoot, file.fileName)).catch(() => {
816
+ rollbackErrors.push(file.fileName);
817
+ });
818
+ }
819
+ if (rollbackErrors.length === 0
820
+ && error instanceof Error
821
+ && error.message.startsWith("artifact_atomic_publish_cancelled:")) {
822
+ throw error;
823
+ }
824
+ const suffix = rollbackErrors.length > 0 ? " Rollback did not restore every bundle file." : "";
825
+ throw new Error(`artifact_atomic_publish_failure: completion artifact bundle was not published.${suffix}`, { cause: error });
826
+ }
827
+ finally {
828
+ await fs.rm(stagingRoot, { recursive: true, force: true }).catch(() => undefined);
829
+ }
830
+ }
831
+ function validateArtifactBundleFiles(files, commitFileName) {
832
+ if (files.length === 0 || !files.some((file) => file.fileName === commitFileName)) {
833
+ throw new Error("artifact_atomic_publish_failure: bundle commit file is missing.");
834
+ }
835
+ const names = new Set();
836
+ for (const file of files) {
837
+ if (!file.fileName || path.basename(file.fileName) !== file.fileName || names.has(file.fileName)) {
838
+ throw new Error("artifact_atomic_publish_failure: bundle file names must be unique safe base names.");
839
+ }
840
+ names.add(file.fileName);
841
+ }
842
+ }
843
+ function throwIfPublicationCancelled(signal) {
844
+ if (signal?.aborted) {
845
+ throw new Error("artifact_atomic_publish_cancelled: completion artifact bundle publication was cancelled.");
846
+ }
847
+ }
848
+ function validatePostRedaction(validate) {
849
+ try {
850
+ validate();
851
+ }
852
+ catch (error) {
853
+ throw postRedactionValidationError(error);
854
+ }
855
+ }
856
+ function postRedactionValidationError(error) {
857
+ const message = error instanceof Error ? error.message : String(error);
858
+ return new Error(`artifact_post_redaction_validation_failed: ${message}`, { cause: error });
859
+ }
860
+ function assertStructuralFieldsUnchanged(original, redacted) {
861
+ if (structuralFieldFingerprint(original) !== structuralFieldFingerprint(redacted)) {
862
+ // This stable code is intentionally safe for telemetry: it does not include
863
+ // the structural value or any candidate secret.
864
+ throw new Error("artifact_redaction_changed_structural_field: redaction changed a structural identifier; the bundle was not published.");
865
+ }
866
+ }
867
+ function structuralFieldFingerprint(value, key = "", result = []) {
868
+ if (Array.isArray(value)) {
869
+ if (isStructuralFieldKey(key) && value.every((item) => item === null || typeof item !== "object")) {
870
+ result.push(stableStringify(value));
871
+ }
872
+ else {
873
+ for (const item of value)
874
+ structuralFieldFingerprint(item, key, result);
875
+ }
876
+ return result.join("\n");
877
+ }
878
+ if (!value || typeof value !== "object") {
879
+ if (isStructuralFieldKey(key))
880
+ result.push(stableStringify(value));
881
+ return result.join("\n");
882
+ }
883
+ for (const [childKey, child] of Object.entries(value)) {
884
+ if (isStructuralFieldKey(childKey)) {
885
+ result.push(`${childKey}:${stableStringify(child)}`);
886
+ }
887
+ else {
888
+ structuralFieldFingerprint(child, childKey, result);
889
+ }
890
+ }
891
+ return result.join("\n");
892
+ }
893
+ function isStructuralFieldKey(key) {
894
+ return key === "id"
895
+ || key === "before"
896
+ || key === "after"
897
+ || key === "from"
898
+ || key === "to"
899
+ || key === "tasks"
900
+ || key === "phases"
901
+ || /(?:^|_)(?:id|ids)$/i.test(key)
902
+ || /(?:Id|Ids)$/.test(key);
903
+ }